1 ; RUN: opt -passes=objc-arc-contract -S < %s | FileCheck %s
9 declare ptr @"\01-[NSAttributedString(Terminal) pathAtIndex:effectiveRange:]"(ptr, ptr nocapture, i64, ptr) optsize
10 declare ptr @llvm.objc.retainAutoreleasedReturnValue(ptr)
11 declare ptr @objc_msgSend_fixup(ptr, ptr, ...)
12 declare ptr @objc_msgSend(ptr, ptr, ...)
13 declare void @llvm.objc.release(ptr)
14 declare %2 @NSUnionRange(i64, i64, i64, i64) optsize
15 declare ptr @llvm.objc.autoreleaseReturnValue(ptr)
16 declare ptr @llvm.objc.autorelease(ptr)
17 declare i32 @__gxx_personality_sj0(...)
19 ; Don't get in trouble on bugpointed code.
21 ; CHECK-LABEL: define void @test0(
22 define void @test0(i1 %arg) {
24 %tmp1 = tail call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr undef) nounwind
28 br i1 %arg, label %bb6, label %bb4
31 switch i64 undef, label %bb5 [
32 i64 9223372036854775807, label %bb6
39 bb6: ; preds = %bb5, %bb4, %bb4, %bb3
40 %tmp7 = phi ptr [ undef, %bb5 ], [ undef, %bb4 ], [ undef, %bb3 ], [ undef, %bb4 ]
44 ; When rewriting operands for a phi which has multiple operands
45 ; for the same block, use the exactly same value in each block.
47 ; CHECK-LABEL: define void @test1(
48 ; CHECK: br i1 %arg, label %bb7, label %bb7
50 ; CHECK: %tmp8 = phi ptr [ %tmp3, %bb ], [ %tmp3, %bb ]
52 define void @test1(i1 %arg) {
54 %tmp = tail call ptr @objc_msgSend()
55 %tmp3 = tail call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr %tmp) nounwind
56 br i1 %arg, label %bb7, label %bb7
58 bb7: ; preds = %bb6, %bb6, %bb5
59 %tmp8 = phi ptr [ %tmp, %bb ], [ %tmp, %bb ]
63 ; When looking for the defining instruction for an objc_retainAutoreleasedReturnValue
64 ; call, handle the case where it's an invoke in a different basic block.
67 ; CHECK: define void @_Z6doTestP8NSString() personality ptr @__gxx_personality_sj0 {
68 ; CHECK: invoke.cont: ; preds = %entry
69 ; CHECK-NEXT: call void asm sideeffect "mov\09r7, r7\09\09@ marker for objc_retainAutoreleaseReturnValue", ""()
70 ; CHECK-NEXT: %tmp = tail call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr %call) [[NUW:#[0-9]+]]
72 define void @_Z6doTestP8NSString() personality ptr @__gxx_personality_sj0 {
74 %call = invoke ptr @objc_msgSend()
75 to label %invoke.cont unwind label %lpad
77 invoke.cont: ; preds = %entry
78 %tmp = tail call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr %call) nounwind
81 lpad: ; preds = %entry
82 %tmp1 = landingpad { ptr, i32 }
84 resume { ptr, i32 } undef
87 !llvm.module.flags = !{!0}
89 !0 = !{i32 1, !"clang.arc.retainAutoreleasedReturnValueMarker", !"mov\09r7, r7\09\09@ marker for objc_retainAutoreleaseReturnValue"}
91 ; CHECK: attributes #0 = { optsize }
92 ; CHECK: attributes [[NUW]] = { nounwind }