1 ; RUN: opt < %s -aa-pipeline=basic-aa -passes=aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s
3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5 %struct = type { i32, i32, i32 }
7 ; CHECK-LABEL: test_simple
9 ; CHECK-DAG: MayAlias: %struct* %st, i32* %x
10 ; CHECK-DAG: MayAlias: %struct* %st, i32* %y
11 ; CHECK-DAG: MayAlias: %struct* %st, i32* %z
13 ; CHECK-DAG: NoAlias: i32* %x, i32* %y
14 ; CHECK-DAG: NoAlias: i32* %x, i32* %z
15 ; CHECK-DAG: NoAlias: i32* %y, i32* %z
17 ; CHECK-DAG: MayAlias: %struct* %st, %struct* %y
18 ; CHECK-DAG: MayAlias: i32* %x, %struct* %y
19 ; CHECK-DAG: MayAlias: i32* %x, i80* %y
21 ; CHECK-DAG: MayAlias: %struct* %st, i64* %y
22 ; CHECK-DAG: MayAlias: i64* %y, i32* %z
23 ; CHECK-DAG: NoAlias: i32* %x, i64* %y
25 ; CHECK-DAG: MustAlias: %struct* %y, i32* %y
26 ; CHECK-DAG: MustAlias: i64* %y, i32* %y
27 ; CHECK-DAG: MustAlias: i80* %y, i32* %y
29 define void @test_simple(ptr %st, i64 %i, i64 %j, i64 %k) {
30 %x = getelementptr inbounds %struct, ptr %st, i64 %i, i32 0
31 %y = getelementptr inbounds %struct, ptr %st, i64 %j, i32 1
32 %z = getelementptr inbounds %struct, ptr %st, i64 %k, i32 2
43 ; As the GEP is not inbounds, these pointers may alias due to overflow.
44 ; CHECK-LABEL: test_not_inbounds
45 ; CHECK: MayAlias: i32* %x, i32* %y
46 define void @test_not_inbounds(ptr %st, i64 %i, i64 %j, i64 %k) {
47 %x = getelementptr %struct, ptr %st, i64 %i, i32 0
48 %y = getelementptr %struct, ptr %st, i64 %j, i32 1
54 ; CHECK-LABEL: test_in_array
56 ; CHECK-DAG: MayAlias: [1 x %struct]* %st, i32* %x
57 ; CHECK-DAG: MayAlias: [1 x %struct]* %st, i32* %y
58 ; CHECK-DAG: MayAlias: [1 x %struct]* %st, i32* %z
60 ; CHECK-DAG: NoAlias: i32* %x, i32* %y
61 ; CHECK-DAG: NoAlias: i32* %x, i32* %z
62 ; CHECK-DAG: NoAlias: i32* %y, i32* %z
64 ; CHECK-DAG: MayAlias: [1 x %struct]* %st, %struct* %y
65 ; CHECK-DAG: MayAlias: i32* %x, %struct* %y
66 ; CHECK-DAG: MayAlias: i32* %x, i80* %y
68 ; CHECK-DAG: MayAlias: [1 x %struct]* %st, i64* %y
69 ; CHECK-DAG: MayAlias: i64* %y, i32* %z
70 ; CHECK-DAG: NoAlias: i32* %x, i64* %y
72 ; CHECK-DAG: MustAlias: %struct* %y, i32* %y
73 ; CHECK-DAG: MustAlias: i64* %y, i32* %y
74 ; CHECK-DAG: MustAlias: i80* %y, i32* %y
76 define void @test_in_array(ptr %st, i64 %i, i64 %j, i64 %k, i64 %i1, i64 %j1, i64 %k1) {
77 %x = getelementptr inbounds [1 x %struct], ptr %st, i64 %i, i64 %i1, i32 0
78 %y = getelementptr inbounds [1 x %struct], ptr %st, i64 %j, i64 %j1, i32 1
79 %z = getelementptr inbounds [1 x %struct], ptr %st, i64 %k, i64 %k1, i32 2
80 load [1 x %struct], ptr %st
90 ; CHECK-LABEL: test_in_3d_array
92 ; CHECK-DAG: MayAlias: [1 x [1 x [1 x %struct]]]* %st, i32* %x
93 ; CHECK-DAG: MayAlias: [1 x [1 x [1 x %struct]]]* %st, i32* %y
94 ; CHECK-DAG: MayAlias: [1 x [1 x [1 x %struct]]]* %st, i32* %z
96 ; CHECK-DAG: NoAlias: i32* %x, i32* %y
97 ; CHECK-DAG: NoAlias: i32* %x, i32* %z
98 ; CHECK-DAG: NoAlias: i32* %y, i32* %z
100 ; CHECK-DAG: MayAlias: [1 x [1 x [1 x %struct]]]* %st, %struct* %y
101 ; CHECK-DAG: MayAlias: i32* %x, %struct* %y
102 ; CHECK-DAG: MayAlias: i32* %x, i80* %y
104 ; CHECK-DAG: MayAlias: [1 x [1 x [1 x %struct]]]* %st, i64* %y
105 ; CHECK-DAG: MayAlias: i64* %y, i32* %z
106 ; CHECK-DAG: NoAlias: i32* %x, i64* %y
108 ; CHECK-DAG: MustAlias: %struct* %y, i32* %y
109 ; CHECK-DAG: MustAlias: i64* %y, i32* %y
110 ; CHECK-DAG: MustAlias: i80* %y, i32* %y
112 define void @test_in_3d_array(ptr %st, i64 %i, i64 %j, i64 %k, i64 %i1, i64 %j1, i64 %k1, i64 %i2, i64 %j2, i64 %k2, i64 %i3, i64 %j3, i64 %k3) {
113 %x = getelementptr inbounds [1 x [1 x [1 x %struct]]], ptr %st, i64 %i, i64 %i1, i64 %i2, i64 %i3, i32 0
114 %y = getelementptr inbounds [1 x [1 x [1 x %struct]]], ptr %st, i64 %j, i64 %j1, i64 %j2, i64 %j3, i32 1
115 %z = getelementptr inbounds [1 x [1 x [1 x %struct]]], ptr %st, i64 %k, i64 %k1, i64 %k2, i64 %k3, i32 2
116 load [1 x [1 x [1 x %struct]]], ptr %st
126 ; CHECK-LABEL: test_same_underlying_object_same_indices
128 ; CHECK-DAG: NoAlias: i32* %x, i32* %x2
129 ; CHECK-DAG: NoAlias: i32* %y, i32* %y2
130 ; CHECK-DAG: NoAlias: i32* %z, i32* %z2
132 ; CHECK-DAG: NoAlias: i32* %x, i32* %y2
133 ; CHECK-DAG: NoAlias: i32* %x, i32* %z2
135 ; CHECK-DAG: NoAlias: i32* %x2, i32* %y
136 ; CHECK-DAG: NoAlias: i32* %y, i32* %z2
138 ; CHECK-DAG: NoAlias: i32* %x2, i32* %z
139 ; CHECK-DAG: NoAlias: i32* %y2, i32* %z
141 define void @test_same_underlying_object_same_indices(ptr %st, i64 %i, i64 %j, i64 %k) {
142 %st2 = getelementptr inbounds %struct, ptr %st, i32 10
143 %x2 = getelementptr inbounds %struct, ptr %st2, i64 %i, i32 0
144 %y2 = getelementptr inbounds %struct, ptr %st2, i64 %j, i32 1
145 %z2 = getelementptr inbounds %struct, ptr %st2, i64 %k, i32 2
146 %x = getelementptr inbounds %struct, ptr %st, i64 %i, i32 0
147 %y = getelementptr inbounds %struct, ptr %st, i64 %j, i32 1
148 %z = getelementptr inbounds %struct, ptr %st, i64 %k, i32 2
158 ; CHECK-LABEL: test_same_underlying_object_different_indices
160 ; CHECK-DAG: MayAlias: i32* %x, i32* %x2
161 ; CHECK-DAG: MayAlias: i32* %y, i32* %y2
162 ; CHECK-DAG: MayAlias: i32* %z, i32* %z2
164 ; CHECK-DAG: NoAlias: i32* %x, i32* %y2
165 ; CHECK-DAG: NoAlias: i32* %x, i32* %z2
167 ; CHECK-DAG: NoAlias: i32* %x2, i32* %y
168 ; CHECK-DAG: NoAlias: i32* %y, i32* %z2
170 ; CHECK-DAG: NoAlias: i32* %x2, i32* %z
171 ; CHECK-DAG: NoAlias: i32* %y2, i32* %z
173 define void @test_same_underlying_object_different_indices(ptr %st, i64 %i1, i64 %j1, i64 %k1, i64 %i2, i64 %k2, i64 %j2) {
174 %st2 = getelementptr inbounds %struct, ptr %st, i32 10
175 %x2 = getelementptr inbounds %struct, ptr %st2, i64 %i2, i32 0
176 %y2 = getelementptr inbounds %struct, ptr %st2, i64 %j2, i32 1
177 %z2 = getelementptr inbounds %struct, ptr %st2, i64 %k2, i32 2
178 %x = getelementptr inbounds %struct, ptr %st, i64 %i1, i32 0
179 %y = getelementptr inbounds %struct, ptr %st, i64 %j1, i32 1
180 %z = getelementptr inbounds %struct, ptr %st, i64 %k1, i32 2
191 %struct2 = type { [1 x { i32, i32 }], [2 x { i32 }] }
193 ; CHECK-LABEL: test_struct_in_array
194 ; CHECK-DAG: MustAlias: i32* %x, i32* %y
195 define void @test_struct_in_array(ptr %st, i64 %i, i64 %j, i64 %k) {
196 %x = getelementptr inbounds %struct2, ptr %st, i32 0, i32 1, i32 1, i32 0
197 %y = getelementptr inbounds %struct2, ptr %st, i32 0, i32 0, i32 1, i32 1
203 ; PR27418 - Treat GEP indices with the same value but different types the same
204 ; CHECK-LABEL: test_different_index_types
205 ; CHECK: MustAlias: i16* %tmp1, i16* %tmp2
206 define void @test_different_index_types(ptr %arr) {
207 %tmp1 = getelementptr inbounds [2 x i16], ptr %arr, i16 0, i32 1
208 %tmp2 = getelementptr inbounds [2 x i16], ptr %arr, i16 0, i16 1