1 ; RUN: opt -objc-arc-contract -S < %s | FileCheck %s
9 declare %0* @"\01-[NSAttributedString(Terminal) pathAtIndex:effectiveRange:]"(%1*, i8* nocapture, i64, %2*) optsize
10 declare i8* @llvm.objc.retainAutoreleasedReturnValue(i8*)
11 declare i8* @objc_msgSend_fixup(i8*, i8*, ...)
12 declare i8* @objc_msgSend(i8*, i8*, ...)
13 declare void @llvm.objc.release(i8*)
14 declare %2 @NSUnionRange(i64, i64, i64, i64) optsize
15 declare i8* @llvm.objc.autoreleaseReturnValue(i8*)
16 declare i8* @llvm.objc.autorelease(i8*)
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() {
24 %tmp = bitcast %4* undef to i8*
25 %tmp1 = tail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %tmp) nounwind
29 br i1 undef, label %bb6, label %bb4
32 switch i64 undef, label %bb5 [
33 i64 9223372036854775807, label %bb6
40 bb6: ; preds = %bb5, %bb4, %bb4, %bb3
41 %tmp7 = phi %4* [ undef, %bb5 ], [ undef, %bb4 ], [ undef, %bb3 ], [ undef, %bb4 ]
45 ; When rewriting operands for a phi which has multiple operands
46 ; for the same block, use the exactly same value in each block.
48 ; CHECK-LABEL: define void @test1(
49 ; CHECK: %0 = bitcast i8* %tmp3 to %0*
50 ; CHECK: br i1 undef, label %bb7, label %bb7
52 ; CHECK: %tmp8 = phi %0* [ %0, %bb ], [ %0, %bb ]
54 define void @test1() {
56 %tmp = tail call %0* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to %0* ()*)()
57 %tmp2 = bitcast %0* %tmp to i8*
58 %tmp3 = tail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %tmp2) nounwind
59 br i1 undef, label %bb7, label %bb7
61 bb7: ; preds = %bb6, %bb6, %bb5
62 %tmp8 = phi %0* [ %tmp, %bb ], [ %tmp, %bb ]
66 ; When looking for the defining instruction for an objc_retainAutoreleasedReturnValue
67 ; call, handle the case where it's an invoke in a different basic block.
70 ; CHECK: define void @_Z6doTestP8NSString() personality i8* bitcast (i32 (...)* @__gxx_personality_sj0 to i8*) {
71 ; CHECK: invoke.cont: ; preds = %entry
72 ; CHECK-NEXT: call void asm sideeffect "mov\09r7, r7\09\09@ marker for objc_retainAutoreleaseReturnValue", ""()
73 ; CHECK-NEXT: %tmp = tail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %call) [[NUW:#[0-9]+]]
75 define void @_Z6doTestP8NSString() personality i8* bitcast (i32 (...)* @__gxx_personality_sj0 to i8*) {
77 %call = invoke i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* ()*)()
78 to label %invoke.cont unwind label %lpad
80 invoke.cont: ; preds = %entry
81 %tmp = tail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %call) nounwind
84 lpad: ; preds = %entry
85 %tmp1 = landingpad { i8*, i32 }
87 resume { i8*, i32 } undef
90 !llvm.module.flags = !{!0}
92 !0 = !{i32 1, !"clang.arc.retainAutoreleasedReturnValueMarker", !"mov\09r7, r7\09\09@ marker for objc_retainAutoreleaseReturnValue"}
94 ; CHECK: attributes #0 = { optsize }
95 ; CHECK: attributes [[NUW]] = { nounwind }