xref: /llvm-project/llvm/test/Transforms/ObjCARC/contract-storestrong-funclet.ll (revision 01e4f41b43b57dee751146fde9992c660bd7c714)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -mtriple=i686-unknown-windows-msvc -passes=objc-arc-contract -S -o - %s | FileCheck %s
3
4declare void @f()
5declare i32 @__CxxFrameHandler3(...)
6declare dllimport ptr @llvm.objc.retain(ptr)
7declare dllimport ptr @llvm.objc.retainAutoreleasedReturnValue(ptr)
8declare dllimport void @llvm.objc.release(ptr)
9
10@x = external global ptr
11
12define void @g(ptr %p) personality ptr @__CxxFrameHandler3 {
13; CHECK-LABEL: @g(
14; CHECK-NEXT:    invoke void @f()
15; CHECK-NEXT:    to label [[INVOKE_CONT:%.*]] unwind label [[EHCLEANUP:%.*]]
16; CHECK:       invoke.cont:
17; CHECK-NEXT:    tail call void @llvm.objc.storeStrong(ptr @x, ptr [[P:%.*]]) #[[ATTR0:[0-9]+]]
18; CHECK-NEXT:    ret void
19; CHECK:       ehcleanup:
20; CHECK-NEXT:    [[TMP1:%.*]] = cleanuppad within none []
21; CHECK-NEXT:    tail call void @llvm.objc.storeStrong(ptr @x, ptr [[P]]) #[[ATTR0]] [ "funclet"(token [[TMP1]]) ]
22; CHECK-NEXT:    cleanupret from [[TMP1]] unwind to caller
23;
24  invoke void @f() to label %invoke.cont unwind label %ehcleanup
25
26invoke.cont:
27  %call = tail call ptr @llvm.objc.retain(ptr %p) nounwind
28  %tmp = load ptr, ptr @x, align 4
29  store ptr %call, ptr @x, align 4
30  tail call void @llvm.objc.release(ptr %tmp) nounwind
31  ret void
32
33ehcleanup:
34  %1 = cleanuppad within none []
35  %call1 = tail call ptr @llvm.objc.retain(ptr %p) nounwind [ "funclet"(token %1) ]
36  %tmp1 = load ptr, ptr @x, align 4
37  store ptr %call1, ptr @x, align 4
38  tail call void @llvm.objc.release(ptr %tmp1) nounwind [ "funclet"(token %1) ]
39  cleanupret from %1 unwind to caller
40}
41