swiftlang/swift

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

Open

#49,527 建立於 2018年2月11日

在 GitHub 查看
 (0 留言) (0 反應) (0 負責人)Swift (69,989 star) (10,719 fork)batch import
bugcompilergood first issueperformance

描述

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.

貢獻者指南