Uploaded image for project: 'Swift'
  1. Swift
  2. SR-6979

ThinToThickFunction derived pointers do not need to be retained/released

    XMLWordPrintable

    Details

      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.

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            gottesmm Michael Gottesman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: