1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=objc-arc < %s | FileCheck %s
4 target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
5 target triple = "i686--windows-msvc"
7 declare ptr @f(ptr, ptr)
9 declare i32 @__CxxFrameHandler3(...)
11 declare dllimport ptr @llvm.objc.autoreleaseReturnValue(ptr returned)
12 declare dllimport ptr @llvm.objc.retain(ptr returned)
13 declare dllimport ptr @llvm.objc.retainAutoreleasedReturnValue(ptr returned)
14 declare dllimport void @llvm.objc.release(ptr)
16 define ptr @g(ptr %p, ptr %q) local_unnamed_addr personality ptr @__CxxFrameHandler3 {
19 ; CHECK-NEXT: [[TMP0:%.*]] = tail call ptr @llvm.objc.retain(ptr [[P:%.*]]) #[[ATTR0:[0-9]+]]
20 ; CHECK-NEXT: [[V1:%.*]] = call ptr @f(ptr null, ptr null)
21 ; CHECK-NEXT: [[CALL:%.*]] = invoke ptr @f(ptr [[P]], ptr [[Q:%.*]])
22 ; CHECK-NEXT: to label [[INVOKE_CONT:%.*]] unwind label [[CATCH_DISPATCH:%.*]], !clang.arc.no_objc_arc_exceptions !0
23 ; CHECK: catch.dispatch:
24 ; CHECK-NEXT: [[TMP1:%.*]] = catchswitch within none [label %catch] unwind to caller
26 ; CHECK-NEXT: [[TMP2:%.*]] = catchpad within [[TMP1]] [ptr null, i32 64, ptr null]
27 ; CHECK-NEXT: catchret from [[TMP2]] to label [[CLEANUP:%.*]]
29 ; CHECK-NEXT: [[TMP3:%.*]] = tail call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr [[CALL]]) #[[ATTR0]]
30 ; CHECK-NEXT: br label [[CLEANUP]]
32 ; CHECK-NEXT: [[RETVAL_0:%.*]] = phi ptr [ [[CALL]], [[INVOKE_CONT]] ], [ null, [[CATCH:%.*]] ]
33 ; CHECK-NEXT: tail call void @llvm.objc.release(ptr [[P]]) #[[ATTR0]], !clang.imprecise_release !0
34 ; CHECK-NEXT: [[TMP4:%.*]] = tail call ptr @llvm.objc.autoreleaseReturnValue(ptr [[RETVAL_0]]) #[[ATTR0]]
35 ; CHECK-NEXT: ret ptr [[RETVAL_0]]
38 %0 = tail call ptr @llvm.objc.retain(ptr %p) #0
39 ; the following call prevents ARC optimizer from removing the retain/release
41 %v1 = call ptr @f(ptr null, ptr null)
42 %1 = tail call ptr @llvm.objc.retain(ptr %q) #0
43 %call = invoke ptr @f(ptr %p, ptr %q)
44 to label %invoke.cont unwind label %catch.dispatch, !clang.arc.no_objc_arc_exceptions !0
47 %2 = catchswitch within none [label %catch] unwind to caller
50 %3 = catchpad within %2 [ptr null, i32 64, ptr null]
51 catchret from %3 to label %cleanup
54 %4 = tail call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr %call) #0
58 %retval.0 = phi ptr [ %call, %invoke.cont ], [ null, %catch ]
59 tail call void @llvm.objc.release(ptr %q) #0, !clang.imprecise_release !0
60 tail call void @llvm.objc.release(ptr %p) #0, !clang.imprecise_release !0
61 %5 = tail call ptr @llvm.objc.autoreleaseReturnValue(ptr %retval.0) #0
65 attributes #0 = { nounwind }