• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -objc-arc-contract -S < %s | FileCheck %s
2; rdar://9511608
3
4%0 = type opaque
5%1 = type opaque
6%2 = type { i64, i64 }
7%3 = type { i8*, i8* }
8%4 = type opaque
9
10declare %0* @"\01-[NSAttributedString(Terminal) pathAtIndex:effectiveRange:]"(%1*, i8* nocapture, i64, %2*) optsize
11declare i8* @objc_retainAutoreleasedReturnValue(i8*)
12declare i8* @objc_msgSend_fixup(i8*, %3*, ...)
13declare void @objc_release(i8*)
14declare %2 @NSUnionRange(i64, i64, i64, i64) optsize
15declare i8* @objc_autoreleaseReturnValue(i8*)
16declare i8* @objc_autorelease(i8*)
17declare i8* @objc_msgSend() nonlazybind
18
19; Don't get in trouble on bugpointed code.
20
21; CHECK: define void @test0(
22define void @test0() {
23bb:
24  %tmp = bitcast %4* undef to i8*
25  %tmp1 = tail call i8* @objc_retainAutoreleasedReturnValue(i8* %tmp) nounwind
26  br label %bb3
27
28bb3:                                              ; preds = %bb2
29  br i1 undef, label %bb6, label %bb4
30
31bb4:                                              ; preds = %bb3
32  switch i64 undef, label %bb5 [
33    i64 9223372036854775807, label %bb6
34    i64 0, label %bb6
35  ]
36
37bb5:                                              ; preds = %bb4
38  br label %bb6
39
40bb6:                                              ; preds = %bb5, %bb4, %bb4, %bb3
41  %tmp7 = phi %4* [ undef, %bb5 ], [ undef, %bb4 ], [ undef, %bb3 ], [ undef, %bb4 ]
42  unreachable
43}
44
45; When rewriting operands for a phi which has multiple operands
46; for the same block, use the exactly same value in each block.
47
48; CHECK: define void @test1(
49; CHECK: %0 = bitcast i8* %tmp3 to %0*
50; CHECK: br i1 undef, label %bb7, label %bb7
51; CHECK: bb7:
52; CHECK: %tmp8 = phi %0* [ %0, %bb ], [ %0, %bb ]
53define void @test1() {
54bb:
55  %tmp = tail call %0* bitcast (i8* ()* @objc_msgSend to %0* ()*)()
56  %tmp2 = bitcast %0* %tmp to i8*
57  %tmp3 = tail call i8* @objc_retainAutoreleasedReturnValue(i8* %tmp2) nounwind
58  br i1 undef, label %bb7, label %bb7
59
60bb7:                                              ; preds = %bb6, %bb6, %bb5
61  %tmp8 = phi %0* [ %tmp, %bb ], [ %tmp, %bb ]
62  unreachable
63}
64