Home | History | Annotate | Download | only in ObjCARC
      1 ; RUN: opt -S -objc-arc-contract < %s | FileCheck %s
      2 
      3 target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
      4 target triple = "i686--windows-msvc19.11.0"
      5 
      6 %0 = type opaque
      7 
      8 declare i32 @__CxxFrameHandler3(...)
      9 declare dllimport void @objc_release(i8*) local_unnamed_addr
     10 declare dllimport i8* @objc_retain(i8* returned) local_unnamed_addr
     11 
     12 @p = global i8* null, align 4
     13 
     14 declare void @f() local_unnamed_addr
     15 
     16 define void @g() local_unnamed_addr personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
     17 entry:
     18   %tmp = load i8*, i8** @p, align 4
     19   %cast = bitcast i8* %tmp to %0*
     20   %tmp1 = tail call i8* @objc_retain(i8* %tmp) #0
     21   ; Split the basic block to ensure bitcast ends up in entry.split.
     22   br label %entry.split
     23 
     24 entry.split:
     25   invoke void @f()
     26           to label %invoke.cont unwind label %catch.dispatch
     27 
     28 ; Dummy nested catchswitch to test looping through the dominator tree.
     29 catch.dispatch:
     30   %tmp2 = catchswitch within none [label %catch] unwind label %catch.dispatch1
     31 
     32 catch:
     33   %tmp3 = catchpad within %tmp2 [i8* null, i32 64, i8* null]
     34   catchret from %tmp3 to label %invoke.cont
     35 
     36 catch.dispatch1:
     37   %tmp4 = catchswitch within none [label %catch1] unwind label %ehcleanup
     38 
     39 catch1:
     40   %tmp5 = catchpad within %tmp4 [i8 *null, i32 64, i8* null]
     41   catchret from %tmp5 to label %invoke.cont
     42 
     43 invoke.cont:
     44   %tmp6 = load i8*, i8** @p, align 4
     45   %cast1 = bitcast i8* %tmp6 to %0*
     46   %tmp7 = tail call i8* @objc_retain(i8* %tmp6) #0
     47   call void @objc_release(i8* %tmp) #0, !clang.imprecise_release !0
     48   ; Split the basic block to ensure bitcast ends up in invoke.cont.split.
     49   br label %invoke.cont.split
     50 
     51 invoke.cont.split:
     52   invoke void @f()
     53           to label %invoke.cont1 unwind label %ehcleanup
     54 
     55 invoke.cont1:
     56   ret void
     57 
     58 ehcleanup:
     59   %tmp8 = phi %0* [ %cast, %catch.dispatch1 ], [ %cast1, %invoke.cont.split ]
     60   %tmp9 = cleanuppad within none []
     61   %tmp10 = bitcast %0* %tmp8 to i8*
     62   call void @objc_release(i8* %tmp10) #0 [ "funclet"(token %tmp9) ]
     63   cleanupret from %tmp9 unwind to caller
     64 }
     65 
     66 ; CHECK-LABEL: entry.split:
     67 ; CHECK-NEXT:    %0 = bitcast i8* %tmp1 to %0*
     68 ; CHECK-NEXT:    invoke void @f()
     69 ; CHECK-NEXT:            to label %invoke.cont unwind label %catch.dispatch
     70 
     71 ; CHECK-LABEL: invoke.cont.split:
     72 ; CHECK-NEXT:    %1 = bitcast i8* %tmp7 to %0*
     73 ; CHECK-NEXT:    invoke void @f()
     74 ; CHECK-NEXT:            to label %invoke.cont1 unwind label %ehcleanup
     75 
     76 ; CHECK-LABEL: ehcleanup:
     77 ; CHECK-NEXT:    %tmp8 = phi %0* [ %0, %catch.dispatch1 ], [ %1, %invoke.cont.split ]
     78 
     79 attributes #0 = { nounwind }
     80 
     81 !0 = !{}
     82