swiftlang/swift

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

Open

#49 527 ouverte le 11 févr. 2018

Voir sur GitHub
 (0 commentaires) (0 réactions) (0 assignés)Swift (10 719 forks)batch import
bugcompilergood first issueperformance

Métriques du dépôt

Stars
 (69 989 stars)
Métriques de merge PR
 (Merge moyen 8j 17h) (510 PRs mergées en 30 j)

Description

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.

Guide contributeur