aboutsummaryrefslogtreecommitdiffstats
path: root/test/Analysis/BasicAA/struct-geps.ll
blob: 3764d48f803c0406ac16cec9dc30031590a27c25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s

target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"

%struct = type { i32, i32, i32 }

; CHECK-LABEL: test_simple

; CHECK-DAG: PartialAlias: %struct* %st, i32* %x
; CHECK-DAG: PartialAlias: %struct* %st, i32* %y
; CHECK-DAG: PartialAlias: %struct* %st, i32* %z

; CHECK-DAG: NoAlias: i32* %x, i32* %y
; CHECK-DAG: NoAlias: i32* %x, i32* %z
; CHECK-DAG: NoAlias: i32* %y, i32* %z

; CHECK-DAG: PartialAlias: %struct* %st, %struct* %y_12
; CHECK-DAG: PartialAlias: %struct* %y_12, i32* %x
; CHECK-DAG: PartialAlias: i32* %x, i80* %y_10

; CHECK-DAG: PartialAlias: %struct* %st, i64* %y_8
; CHECK-DAG: PartialAlias: i32* %z, i64* %y_8
; CHECK-DAG: NoAlias: i32* %x, i64* %y_8

; CHECK-DAG: MustAlias: %struct* %y_12, i32* %y
; CHECK-DAG: MustAlias: i32* %y, i64* %y_8
; CHECK-DAG: MustAlias: i32* %y, i80* %y_10

define void @test_simple(%struct* %st, i64 %i, i64 %j, i64 %k) {
  %x = getelementptr %struct* %st, i64 %i, i32 0
  %y = getelementptr %struct* %st, i64 %j, i32 1
  %z = getelementptr %struct* %st, i64 %k, i32 2
  %y_12 = bitcast i32* %y to %struct*
  %y_10 = bitcast i32* %y to i80*
  %y_8 = bitcast i32* %y to i64*
  ret void
}

; CHECK-LABEL: test_in_array

; CHECK-DAG: PartialAlias: [1 x %struct]* %st, i32* %x
; CHECK-DAG: PartialAlias: [1 x %struct]* %st, i32* %y
; CHECK-DAG: PartialAlias: [1 x %struct]* %st, i32* %z

; CHECK-DAG: NoAlias: i32* %x, i32* %y
; CHECK-DAG: NoAlias: i32* %x, i32* %z
; CHECK-DAG: NoAlias: i32* %y, i32* %z

; CHECK-DAG: PartialAlias: %struct* %y_12, [1 x %struct]* %st
; CHECK-DAG: PartialAlias: %struct* %y_12, i32* %x
; CHECK-DAG: PartialAlias: i32* %x, i80* %y_10

; CHECK-DAG: PartialAlias: [1 x %struct]* %st, i64* %y_8
; CHECK-DAG: PartialAlias: i32* %z, i64* %y_8
; CHECK-DAG: NoAlias: i32* %x, i64* %y_8

; CHECK-DAG: MustAlias: %struct* %y_12, i32* %y
; CHECK-DAG: MustAlias: i32* %y, i64* %y_8
; CHECK-DAG: MustAlias: i32* %y, i80* %y_10

define void @test_in_array([1 x %struct]* %st, i64 %i, i64 %j, i64 %k, i64 %i1, i64 %j1, i64 %k1) {
  %x = getelementptr [1 x %struct]* %st, i64 %i, i64 %i1, i32 0
  %y = getelementptr [1 x %struct]* %st, i64 %j, i64 %j1, i32 1
  %z = getelementptr [1 x %struct]* %st, i64 %k, i64 %k1, i32 2
  %y_12 = bitcast i32* %y to %struct*
  %y_10 = bitcast i32* %y to i80*
  %y_8 = bitcast i32* %y to i64*
  ret void
}

; CHECK-LABEL: test_in_3d_array

; CHECK-DAG: PartialAlias: [1 x [1 x [1 x %struct]]]* %st, i32* %x
; CHECK-DAG: PartialAlias: [1 x [1 x [1 x %struct]]]* %st, i32* %y
; CHECK-DAG: PartialAlias: [1 x [1 x [1 x %struct]]]* %st, i32* %z

; CHECK-DAG: NoAlias: i32* %x, i32* %y
; CHECK-DAG: NoAlias: i32* %x, i32* %z
; CHECK-DAG: NoAlias: i32* %y, i32* %z

; CHECK-DAG: PartialAlias: %struct* %y_12, [1 x [1 x [1 x %struct]]]* %st
; CHECK-DAG: PartialAlias: %struct* %y_12, i32* %x
; CHECK-DAG: PartialAlias: i32* %x, i80* %y_10

; CHECK-DAG: PartialAlias: [1 x [1 x [1 x %struct]]]* %st, i64* %y_8
; CHECK-DAG: PartialAlias: i32* %z, i64* %y_8
; CHECK-DAG: NoAlias: i32* %x, i64* %y_8

; CHECK-DAG: MustAlias: %struct* %y_12, i32* %y
; CHECK-DAG: MustAlias: i32* %y, i64* %y_8
; CHECK-DAG: MustAlias: i32* %y, i80* %y_10

define void @test_in_3d_array([1 x [1 x [1 x %struct]]]* %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) {
  %x = getelementptr [1 x [1 x [1 x %struct]]]* %st, i64 %i, i64 %i1, i64 %i2, i64 %i3, i32 0
  %y = getelementptr [1 x [1 x [1 x %struct]]]* %st, i64 %j, i64 %j1, i64 %j2, i64 %j3, i32 1
  %z = getelementptr [1 x [1 x [1 x %struct]]]* %st, i64 %k, i64 %k1, i64 %k2, i64 %k3, i32 2
  %y_12 = bitcast i32* %y to %struct*
  %y_10 = bitcast i32* %y to i80*
  %y_8 = bitcast i32* %y to i64*
  ret void
}

; CHECK-LABEL: test_same_underlying_object_same_indices

; CHECK-DAG: NoAlias: i32* %x, i32* %x2
; CHECK-DAG: NoAlias: i32* %y, i32* %y2
; CHECK-DAG: NoAlias: i32* %z, i32* %z2

; CHECK-DAG: PartialAlias: i32* %x, i32* %y2
; CHECK-DAG: PartialAlias: i32* %x, i32* %z2

; CHECK-DAG: PartialAlias: i32* %x2, i32* %y
; CHECK-DAG: PartialAlias: i32* %y, i32* %z2

; CHECK-DAG: PartialAlias: i32* %x2, i32* %z
; CHECK-DAG: PartialAlias: i32* %y2, i32* %z

define void @test_same_underlying_object_same_indices(%struct* %st, i64 %i, i64 %j, i64 %k) {
  %st2 = getelementptr %struct* %st, i32 10
  %x2 = getelementptr %struct* %st2, i64 %i, i32 0
  %y2 = getelementptr %struct* %st2, i64 %j, i32 1
  %z2 = getelementptr %struct* %st2, i64 %k, i32 2
  %x = getelementptr %struct* %st, i64 %i, i32 0
  %y = getelementptr %struct* %st, i64 %j, i32 1
  %z = getelementptr %struct* %st, i64 %k, i32 2
  ret void
}

; CHECK-LABEL: test_same_underlying_object_different_indices

; CHECK-DAG: PartialAlias: i32* %x, i32* %x2
; CHECK-DAG: PartialAlias: i32* %y, i32* %y2
; CHECK-DAG: PartialAlias: i32* %z, i32* %z2

; CHECK-DAG: PartialAlias: i32* %x, i32* %y2
; CHECK-DAG: PartialAlias: i32* %x, i32* %z2

; CHECK-DAG: PartialAlias: i32* %x2, i32* %y
; CHECK-DAG: PartialAlias: i32* %y, i32* %z2

; CHECK-DAG: PartialAlias: i32* %x2, i32* %z
; CHECK-DAG: PartialAlias: i32* %y2, i32* %z

define void @test_same_underlying_object_different_indices(%struct* %st, i64 %i1, i64 %j1, i64 %k1, i64 %i2, i64 %k2, i64 %j2) {
  %st2 = getelementptr %struct* %st, i32 10
  %x2 = getelementptr %struct* %st2, i64 %i2, i32 0
  %y2 = getelementptr %struct* %st2, i64 %j2, i32 1
  %z2 = getelementptr %struct* %st2, i64 %k2, i32 2
  %x = getelementptr %struct* %st, i64 %i1, i32 0
  %y = getelementptr %struct* %st, i64 %j1, i32 1
  %z = getelementptr %struct* %st, i64 %k1, i32 2
  ret void
}


%struct2 = type { [1 x { i32, i32 }], [2 x { i32 }] }

; CHECK-LABEL: test_struct_in_array
; CHECK-DAG: MustAlias: i32* %x, i32* %y
define void @test_struct_in_array(%struct2* %st, i64 %i, i64 %j, i64 %k) {
  %x = getelementptr %struct2* %st, i32 0, i32 1, i32 1, i32 0
  %y = getelementptr %struct2* %st, i32 0, i32 0, i32 1, i32 1
  ret void
}