Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gottesmm opened this issue Feb 11, 2018 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself good first issue Good for newcomers performance

Comments

@gottesmm
Copy link
Contributor

Previous ID SR-6979
Radar None
Original Reporter @gottesmm
Type Bug
Additional Detail from JIRA
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.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself good first issue Good for newcomers performance
Projects
None yet
Development

No branches or pull requests

1 participant