1 ; RUN: opt -S -passes=objc-arc,objc-arc-contract < %s | FileCheck %s
3 ; The optimizer should be able to move the autorelease past two phi nodes
4 ; and fold it with the release in bb65.
7 ; CHECK: call ptr @llvm.objc.retainAutorelease
8 ; CHECK: br label %bb76
10 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
11 target triple = "x86_64-apple-darwin11.0.0"
20 @"\01L_OBJC_SELECTOR_REFERENCES_11" = external hidden global ptr, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
21 @"\01L_OBJC_SELECTOR_REFERENCES_421455" = external hidden global ptr, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
22 @"\01L_OBJC_SELECTOR_REFERENCES_598" = external hidden global ptr, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
23 @"\01L_OBJC_SELECTOR_REFERENCES_620" = external hidden global ptr, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
24 @"\01L_OBJC_SELECTOR_REFERENCES_622" = external hidden global ptr, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
25 @"\01L_OBJC_SELECTOR_REFERENCES_624" = external hidden global ptr, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
26 @"\01L_OBJC_SELECTOR_REFERENCES_626" = external hidden global ptr, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
28 declare ptr @objc_msgSend(ptr, ptr, ...)
30 declare ptr @llvm.objc.retain(ptr)
32 declare void @llvm.objc.release(ptr)
34 declare ptr @llvm.objc.autorelease(ptr)
36 define hidden ptr @foo(ptr %arg, ptr %arg3) {
38 %tmp16 = load ptr, ptr @"\01L_OBJC_SELECTOR_REFERENCES_620", align 8
39 %tmp18 = call ptr @objc_msgSend(ptr %arg3, ptr %tmp16)
40 %tmp19 = load ptr, ptr @"\01L_OBJC_SELECTOR_REFERENCES_622", align 8
41 %tmp21 = call ptr @objc_msgSend(ptr %tmp18, ptr %tmp19)
42 %tmp23 = call ptr @llvm.objc.retain(ptr %tmp21) nounwind
43 %tmp26 = icmp eq ptr %tmp23, null
44 br i1 %tmp26, label %bb81, label %bb27
47 %tmp29 = load ptr, ptr @"\01L_OBJC_SELECTOR_REFERENCES_11", align 8
48 %tmp31 = call ptr @objc_msgSend(ptr %arg, ptr %tmp29)
49 %tmp34 = call ptr @llvm.objc.retain(ptr %tmp31) nounwind
50 %tmp37 = load ptr, ptr @"\01L_OBJC_SELECTOR_REFERENCES_421455", align 8
51 %tmp39 = call ptr @objc_msgSend(ptr %tmp34, ptr %tmp37)
52 %tmp41 = call ptr @llvm.objc.retain(ptr %tmp39) nounwind
53 %tmp44 = icmp eq ptr %tmp41, null
54 br i1 %tmp44, label %bb45, label %bb55
57 %tmp47 = load ptr, ptr @"\01L_OBJC_SELECTOR_REFERENCES_624", align 8
58 %tmp49 = call ptr @objc_msgSend(ptr %tmp34, ptr %tmp47)
59 %tmp52 = call ptr @llvm.objc.retain(ptr %tmp49) nounwind
60 call void @llvm.objc.release(ptr %tmp41) nounwind
63 bb55: ; preds = %bb27, %bb45
64 %tmp13.0 = phi ptr [ %tmp41, %bb27 ], [ %tmp49, %bb45 ]
65 %tmp57 = icmp eq ptr %tmp13.0, null
66 br i1 %tmp57, label %bb76, label %bb58
69 %tmp60 = load ptr, ptr @"\01L_OBJC_SELECTOR_REFERENCES_598", align 8
70 %tmp62 = call signext i8 @objc_msgSend(ptr %tmp13.0, ptr %tmp60)
71 %tmp64 = icmp eq i8 %tmp62, 0
72 br i1 %tmp64, label %bb76, label %bb65
75 %tmp68 = load ptr, ptr @"\01L_OBJC_SELECTOR_REFERENCES_626", align 8
76 %tmp70 = call ptr @objc_msgSend(ptr %tmp13.0, ptr %tmp68, ptr %tmp23)
77 %tmp73 = call ptr @llvm.objc.retain(ptr %tmp70) nounwind
80 bb76: ; preds = %bb58, %bb55, %bb65
81 %tmp10.0 = phi ptr [ %tmp70, %bb65 ], [ null, %bb58 ], [ null, %bb55 ]
82 call void @llvm.objc.release(ptr %tmp13.0) nounwind
83 call void @llvm.objc.release(ptr %tmp34) nounwind
86 bb81: ; preds = %bb, %bb76
87 %tmp10.1 = phi ptr [ %tmp10.0, %bb76 ], [ null, %bb ]
88 %tmp84 = call ptr @llvm.objc.retain(ptr %tmp10.1) nounwind
89 call void @llvm.objc.release(ptr %tmp23) nounwind
90 %tmp87 = call ptr @llvm.objc.autorelease(ptr %tmp84) nounwind
91 call void @llvm.objc.release(ptr %tmp10.1) nounwind