swiftlang/swift

[SR-6979] ThinToThickFunction derived pointers do not need to be retained/released

Open

#49.527 aperta il 11 feb 2018

Vedi su GitHub
 (0 commenti) (0 reazioni) (0 assegnatari)Swift (10.719 fork)batch import
bugcompilergood first issueperformance

Metriche repository

Star
 (69.989 star)
Metriche merge PR
 (Merge medio 8g 17h) (510 PR mergiate in 30 g)

Descrizione

Previous ID SR-6979
Radar None
Original Reporter @gottesmm
Type Bug
Votes 0
Component/s Compiler
Labels Bug, Performance, StarterBug
Assignee None
Priority Medium

md5: 570977381e8bce3c10e08267eb895f6f

Issue Description:

I was reading some SIL recently:

  debug_value undef : $Error, var, name "$error", argno 1 // id: %0                                                               
  // function_ref thrower()                                                                                                       
  %1 = function_ref @$S8rethrows7throwerSiyKF : $@convention(thin) () -> (Int, @error Error) // user: %2                          
  %2 = thin_to_thick_function %1 : $@convention(thin) () -> (Int, @error Error) to $@callee_guaranteed () -> (Int, @error Error) \
// user: %3                                                                                                                       
  %3 = convert_function %2 : $@callee_guaranteed () -> (Int, @error Error) to $@noescape @callee_guaranteed () -> (Int, @error Er\
ror) // users: %11, %7, %5                                                                                                        
  // function_ref rethrower(_:)                                                                                                   
  %4 = function_ref @$S8rethrows9rethroweryS2iyKXEKF : $@convention(thin) (@guaranteed @noescape @callee_guaranteed () -> (Int, @\
error Error)) -> (Int, @error Error) // user: %5                                                                                  
  try_apply %4(%3) : $@convention(thin) (@guaranteed @noescape @callee_guaranteed () -> (Int, @error Error)) -> (Int, @error Erro\
r), normal bb1, error bb2 // id: %5                                                                                               
                                                                                                                                  
bb1(%6 : $Int):                                   // Preds: bb0                                                                   
  strong_release %3 : $@noescape @callee_guaranteed () -> (Int, @error Error) // id: %7
  ...

%7 should be able to be removed. I imagine though this peephole would need to be done late in the pipeline since it breaks semantic sil invariants.

Guida contributor