1 ; RUN: opt -aa-pipeline=basic-aa -passes='print<memoryssa>,verify<memoryssa>' -disable-output < %s 2>&1 | FileCheck %s
3 %struct.hoge = type { i32, %struct.widget }
4 %struct.widget = type { i64 }
6 define hidden void @quux(ptr %f) align 2 {
7 %tmp = getelementptr inbounds %struct.hoge, ptr %f, i64 0, i32 1, i32 0
8 %tmp24 = getelementptr inbounds %struct.hoge, ptr %f, i64 0, i32 1
11 bb26: ; preds = %bb77, %0
12 ; CHECK: 3 = MemoryPhi({%0,liveOnEntry},{bb77,2})
13 ; CHECK-NEXT: br i1 undef, label %bb68, label %bb77
14 br i1 undef, label %bb68, label %bb77
17 ; CHECK: MemoryUse(liveOnEntry)
18 ; CHECK-NEXT: %tmp69 = load i64, ptr null, align 8
19 %tmp69 = load i64, ptr null, align 8
20 ; CHECK: 1 = MemoryDef(3)
21 ; CHECK-NEXT: store i64 %tmp69, ptr %tmp, align 8
22 store i64 %tmp69, ptr %tmp, align 8
25 bb77: ; preds = %bb68, %bb26
26 ; CHECK: 2 = MemoryPhi({bb26,3},{bb68,1})
28 ; CHECK-NEXT: %tmp78 = load ptr, ptr %tmp24, align 8
29 %tmp78 = load ptr, ptr %tmp24, align 8
30 %tmp79 = getelementptr inbounds i64, ptr %tmp78, i64 undef
34 define hidden void @quux_no_null_opt(ptr %f) align 2 #0 {
35 ; CHECK-LABEL: quux_no_null_opt(
36 %tmp = getelementptr inbounds %struct.hoge, ptr %f, i64 0, i32 1, i32 0
37 %tmp24 = getelementptr inbounds %struct.hoge, ptr %f, i64 0, i32 1
40 bb26: ; preds = %bb77, %0
41 ; CHECK: 3 = MemoryPhi({%0,liveOnEntry},{bb77,2})
42 ; CHECK-NEXT: br i1 undef, label %bb68, label %bb77
43 br i1 undef, label %bb68, label %bb77
47 ; CHECK-NEXT: %tmp69 = load i64, ptr null, align 8
48 %tmp69 = load i64, ptr null, align 8
49 ; CHECK: 1 = MemoryDef(3)
50 ; CHECK-NEXT: store i64 %tmp69, ptr %tmp, align 8
51 store i64 %tmp69, ptr %tmp, align 8
54 bb77: ; preds = %bb68, %bb26
55 ; CHECK: 2 = MemoryPhi({bb26,3},{bb68,1})
57 ; CHECK-NEXT: %tmp78 = load ptr, ptr %tmp24, align 8
58 %tmp78 = load ptr, ptr %tmp24, align 8
59 %tmp79 = getelementptr inbounds i64, ptr %tmp78, i64 undef
63 ; CHECK-LABEL: define void @quux_skip
64 define void @quux_skip(ptr noalias %f, ptr noalias %g) align 2 {
65 %tmp = getelementptr inbounds %struct.hoge, ptr %f, i64 0, i32 1, i32 0
66 %tmp24 = getelementptr inbounds %struct.hoge, ptr %f, i64 0, i32 1
69 bb26: ; preds = %bb77, %0
70 ; CHECK: 3 = MemoryPhi({%0,liveOnEntry},{bb77,2})
71 ; CHECK-NEXT: br i1 undef, label %bb68, label %bb77
72 br i1 undef, label %bb68, label %bb77
76 ; CHECK-NEXT: %tmp69 = load i64, ptr %g, align 8
77 %tmp69 = load i64, ptr %g, align 8
78 ; CHECK: 1 = MemoryDef(3)
79 ; CHECK-NEXT: store i64 %tmp69, ptr %g, align 8
80 store i64 %tmp69, ptr %g, align 8
83 bb77: ; preds = %bb68, %bb26
84 ; CHECK: 2 = MemoryPhi({bb26,3},{bb68,1})
85 ; CHECK: MemoryUse(liveOnEntry)
86 ; CHECK-NEXT: %tmp78 = load ptr, ptr %tmp24, align 8
87 %tmp78 = load ptr, ptr %tmp24, align 8
91 ; CHECK-LABEL: define void @quux_dominated
92 define void @quux_dominated(ptr noalias %f, ptr noalias %g) align 2 {
93 %tmp = getelementptr inbounds %struct.hoge, ptr %f, i64 0, i32 1, i32 0
94 %tmp24 = getelementptr inbounds %struct.hoge, ptr %f, i64 0, i32 1
97 bb26: ; preds = %bb77, %0
98 ; CHECK: 3 = MemoryPhi({%0,liveOnEntry},{bb77,2})
100 ; CHECK-NEXT: load ptr, ptr %tmp24, align 8
101 load ptr, ptr %tmp24, align 8
102 br i1 undef, label %bb68, label %bb77
104 bb68: ; preds = %bb26
105 ; CHECK: MemoryUse(3)
106 ; CHECK-NEXT: %tmp69 = load i64, ptr %g, align 8
107 %tmp69 = load i64, ptr %g, align 8
108 ; CHECK: 1 = MemoryDef(3)
109 ; CHECK-NEXT: store i64 %tmp69, ptr %g, align 8
110 store i64 %tmp69, ptr %g, align 8
113 bb77: ; preds = %bb68, %bb26
114 ; CHECK: 4 = MemoryPhi({bb26,3},{bb68,1})
115 ; CHECK: 2 = MemoryDef(4)
116 ; CHECK-NEXT: store ptr null, ptr %tmp24, align 8
117 store ptr null, ptr %tmp24, align 8
121 ; CHECK-LABEL: define void @quux_nodominate
122 define void @quux_nodominate(ptr noalias %f, ptr noalias %g) align 2 {
123 %tmp = getelementptr inbounds %struct.hoge, ptr %f, i64 0, i32 1, i32 0
124 %tmp24 = getelementptr inbounds %struct.hoge, ptr %f, i64 0, i32 1
127 bb26: ; preds = %bb77, %0
128 ; CHECK: 3 = MemoryPhi({%0,liveOnEntry},{bb77,2})
129 ; CHECK: MemoryUse(liveOnEntry)
130 ; CHECK-NEXT: load ptr, ptr %tmp24, align 8
131 load ptr, ptr %tmp24, align 8
132 br i1 undef, label %bb68, label %bb77
134 bb68: ; preds = %bb26
135 ; CHECK: MemoryUse(3)
136 ; CHECK-NEXT: %tmp69 = load i64, ptr %g, align 8
137 %tmp69 = load i64, ptr %g, align 8
138 ; CHECK: 1 = MemoryDef(3)
139 ; CHECK-NEXT: store i64 %tmp69, ptr %g, align 8
140 store i64 %tmp69, ptr %g, align 8
143 bb77: ; preds = %bb68, %bb26
144 ; CHECK: 2 = MemoryPhi({bb26,3},{bb68,1})
145 ; CHECK-NEXT: br label %bb26
149 attributes #0 = { null_pointer_is_valid }