@@ -94,26 +94,27 @@ void func() {
94
94
// CIR" cir.store %[[TMP]], %[[INIT_2]] : !s32i, !cir.ptr<!s32i>
95
95
96
96
// LLVM: define void @func()
97
- // LLVM-NEXT: %[[ARR_ALLOCA :.*]] = alloca [10 x i32], i64 1, align 16
97
+ // LLVM-NEXT: %[[ARR :.*]] = alloca [10 x i32], i64 1, align 16
98
98
// LLVM-NEXT: %[[INIT:.*]] = alloca i32, i64 1, align 4
99
99
// LLVM-NEXT: %[[INIT_2:.*]] = alloca i32, i64 1, align 4
100
- // LLVM-NEXT: %[[ARR_PTR:.*]] = getelementptr i32, ptr %[[ARR_ALLOCA ]], i32 0
100
+ // LLVM-NEXT: %[[ARR_PTR:.*]] = getelementptr i32, ptr %[[ARR ]], i32 0
101
101
// LLVM-NEXT: %[[ELE_PTR:.*]] = getelementptr i32, ptr %[[ARR_PTR]], i64 0
102
- // LLVM-NEXT: %[[TMP :.*]] = load i32, ptr %[[ELE_PTR]], align 4
103
- // LLVM-NEXT: store i32 %[[TMP ]], ptr %[[INIT]], align 4
104
- // LLVM-NEXT: %[[ARR_PTR:.*]] = getelementptr i32, ptr %[[ARR_ALLOCA ]], i32 0
102
+ // LLVM-NEXT: %[[TMP_1 :.*]] = load i32, ptr %[[ELE_PTR]], align 4
103
+ // LLVM-NEXT: store i32 %[[TMP_1 ]], ptr %[[INIT]], align 4
104
+ // LLVM-NEXT: %[[ARR_PTR:.*]] = getelementptr i32, ptr %[[ARR ]], i32 0
105
105
// LLVM-NEXT: %[[ELE_PTR:.*]] = getelementptr i32, ptr %[[ARR_PTR]], i64 1
106
- // LLVM-NEXT: %[[TMP:.*]] = load i32, ptr %[[ELE_PTR]], align 4
107
-
108
- // OGCG: %arr = alloca [10 x i32], align 16
109
- // OGCG: %e = alloca i32, align 4
110
- // OGCG: %e2 = alloca i32, align 4
111
- // OGCG: %arrayidx = getelementptr inbounds [10 x i32], ptr %arr, i64 0, i64 0
112
- // OGCG: %0 = load i32, ptr %arrayidx, align 16
113
- // OGCG: store i32 %0, ptr %e, align 4
114
- // OGCG: %arrayidx1 = getelementptr inbounds [10 x i32], ptr %arr, i64 0, i64 1
115
- // OGCG: %1 = load i32, ptr %arrayidx1, align 4
116
- // OGCG: store i32 %1, ptr %e2, align 4
106
+ // LLVM-NEXT: %[[TMP_2:.*]] = load i32, ptr %[[ELE_PTR]], align 4
107
+ // LLVM-NEXT: store i32 %[[TMP_2]], ptr %[[INIT_2]], align 4
108
+
109
+ // OGCG: %[[ARR:.*]] = alloca [10 x i32], align 16
110
+ // OGCG: %[[INIT:.*]] = alloca i32, align 4
111
+ // OGCG: %[[INIT_2:.*]] = alloca i32, align 4
112
+ // OGCG: %[[ELE_PTR:.*]] = getelementptr inbounds [10 x i32], ptr %[[ARR]], i64 0, i64 0
113
+ // OGCG: %[[TMP_1:.*]] = load i32, ptr %[[ELE_PTR]], align 16
114
+ // OGCG: store i32 %[[TMP_1]], ptr %[[INIT]], align 4
115
+ // OGCG: %[[ELE_PTR:.*]] = getelementptr inbounds [10 x i32], ptr %[[ARR]], i64 0, i64 1
116
+ // OGCG: %[[TMP_2:.*]] = load i32, ptr %[[ELE_PTR]], align 4
117
+ // OGCG: store i32 %[[TMP_2]], ptr %[[INIT_2]], align 4
117
118
118
119
void func2 () {
119
120
int arr[2 ] = {5 };
@@ -135,9 +136,9 @@ void func2() {
135
136
// CIR: cir.store %[[ELE_1_PTR]], %[[ELE_ALLOCA]] : !cir.ptr<!s32i>, !cir.ptr<!cir.ptr<!s32i>>
136
137
137
138
// LLVM: define void @func2()
138
- // LLVM: %[[ARR_ALLOCA :.*]] = alloca [2 x i32], i64 1, align 4
139
+ // LLVM: %[[ARR :.*]] = alloca [2 x i32], i64 1, align 4
139
140
// LLVM: %[[TMP:.*]] = alloca ptr, i64 1, align 8
140
- // LLVM: %[[ARR_PTR:.*]] = getelementptr i32, ptr %[[ARR_ALLOCA ]], i32 0
141
+ // LLVM: %[[ARR_PTR:.*]] = getelementptr i32, ptr %[[ARR ]], i32 0
141
142
// LLVM: store i32 5, ptr %[[ARR_PTR]], align 4
142
143
// LLVM: %[[ELE_1_PTR:.*]] = getelementptr i32, ptr %[[ARR_PTR]], i64 1
143
144
// LLVM: store ptr %[[ELE_1_PTR]], ptr %[[TMP]], align 8
@@ -146,8 +147,8 @@ void func2() {
146
147
// LLVM: %[[ELE_1:.*]] = getelementptr i32, ptr %[[TMP2]], i64 1
147
148
// LLVM: store ptr %[[ELE_1]], ptr %[[TMP]], align 8
148
149
149
- // OGCG: %arr = alloca [2 x i32], align 4
150
- // OGCG: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %arr , ptr align 4 @[[FUN2_ARR]], i64 8, i1 false)
150
+ // OGCG: %[[ARR:.*]] = alloca [2 x i32], align 4
151
+ // OGCG: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %[[ARR]] , ptr align 4 @[[FUN2_ARR]], i64 8, i1 false)
151
152
152
153
void func3 () {
153
154
int arr[2 ] = {5 , 6 };
@@ -175,31 +176,31 @@ void func3() {
175
176
// CIR: cir.store %[[ELE_TMP]], %[[INIT]] : !s32i, !cir.ptr<!s32i>
176
177
177
178
// LLVM: define void @func3()
178
- // LLVM: %[[ARR_ALLOCA :.*]] = alloca [2 x i32], i64 1, align 4
179
+ // LLVM: %[[ARR :.*]] = alloca [2 x i32], i64 1, align 4
179
180
// LLVM: %[[IDX:.*]] = alloca i32, i64 1, align 4
180
181
// LLVM: %[[INIT:.*]] = alloca i32, i64 1, align 4
181
- // LLVM: %[[ARR_PTR:.*]] = getelementptr i32, ptr %[[ARR_ALLOCA ]], i32 0
182
+ // LLVM: %[[ARR_PTR:.*]] = getelementptr i32, ptr %[[ARR ]], i32 0
182
183
// LLVM: store i32 5, ptr %[[ARR_PTR]], align 4
183
184
// LLVM: %[[ELE_1_PTR:.*]] = getelementptr i32, ptr %[[ARR_PTR]], i64 1
184
185
// LLVM: store i32 6, ptr %[[ELE_1_PTR]], align 4
185
186
// LLVM: store i32 1, ptr %[[IDX]], align 4
186
187
// LLVM: %[[TMP1:.*]] = load i32, ptr %[[IDX]], align 4
187
- // LLVM: %[[ARR_PTR:.*]] = getelementptr i32, ptr %[[ARR_ALLOCA ]], i32 0
188
+ // LLVM: %[[ARR_PTR:.*]] = getelementptr i32, ptr %[[ARR ]], i32 0
188
189
// LLVM: %[[IDX_I64:.*]] = sext i32 %[[TMP1]] to i64
189
190
// LLVM: %[[ELE:.*]] = getelementptr i32, ptr %[[ARR_PTR]], i64 %[[IDX_I64]]
190
191
// LLVM: %[[TMP2:.*]] = load i32, ptr %[[ELE]], align 4
191
192
// LLVM: store i32 %[[TMP2]], ptr %[[INIT]], align 4
192
193
193
- // OGCG: %arr = alloca [2 x i32], align 4
194
- // OGCG: %idx = alloca i32, align 4
195
- // OGCG: %e = alloca i32, align 4
196
- // OGCG: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %arr , ptr align 4 @[[FUN3_ARR]], i64 8, i1 false)
197
- // OGCG: store i32 1, ptr %idx , align 4
198
- // OGCG: %0 = load i32, ptr %idx , align 4
199
- // OGCG: %idxprom = sext i32 %0 to i64
200
- // OGCG: %arrayidx = getelementptr inbounds [2 x i32], ptr %arr , i64 0, i64 %idxprom
201
- // OGCG: %1 = load i32, ptr %arrayidx , align 4
202
- // OGCG: store i32 %1 , ptr %e , align 4
194
+ // OGCG: %[[ARR:.*]] = alloca [2 x i32], align 4
195
+ // OGCG: %[[IDX:.*]] = alloca i32, align 4
196
+ // OGCG: %[[INIT:.*]] = alloca i32, align 4
197
+ // OGCG: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %[[ARR]] , ptr align 4 @[[FUN3_ARR]], i64 8, i1 false)
198
+ // OGCG: store i32 1, ptr %[[IDX]] , align 4
199
+ // OGCG: %[[TMP:.*]] = load i32, ptr %[[IDX]] , align 4
200
+ // OGCG: %[[IDX_I64:.*]] = sext i32 %[[TMP]] to i64
201
+ // OGCG: %[[ELE:.*]] = getelementptr inbounds [2 x i32], ptr %[[ARR]] , i64 0, i64 %[[IDX_I64]]
202
+ // OGCG: %[[TMP_2:.*]] = load i32, ptr %[[ELE]] , align 4
203
+ // OGCG: store i32 %[[TMP_2:.*]] , ptr %[[INIT]] , align 4
203
204
204
205
void func4 () {
205
206
int arr[2 ][1 ] = {{5 }, {6 }};
@@ -227,28 +228,28 @@ void func4() {
227
228
// CIR: cir.store %[[TMP]], %[[INIT]] : !s32i, !cir.ptr<!s32i>
228
229
229
230
// LLVM: define void @func4()
230
- // LLVM: %[[ARR_ALLOCA :.*]] = alloca [2 x [1 x i32]], i64 1, align 4
231
+ // LLVM: %[[ARR :.*]] = alloca [2 x [1 x i32]], i64 1, align 4
231
232
// LLVM: %[[INIT:.*]] = alloca i32, i64 1, align 4
232
- // LLVM: %[[ARR_PTR:.*]] = getelementptr [1 x i32], ptr %[[ARR_ALLOCA ]], i32 0
233
+ // LLVM: %[[ARR_PTR:.*]] = getelementptr [1 x i32], ptr %[[ARR ]], i32 0
233
234
// LLVM: %[[ARR_0_0:.*]] = getelementptr i32, ptr %[[ARR_PTR]], i32 0
234
235
// LLVM: store i32 5, ptr %[[ARR_0_0]], align 4
235
236
// LLVM: %[[ARR_1:.*]] = getelementptr [1 x i32], ptr %[[ARR_PTR]], i64 1
236
237
// LLVM: %[[ARR_1_0:.*]] = getelementptr i32, ptr %[[ARR_1]], i32 0
237
238
// LLVM: store i32 6, ptr %[[ARR_1_0]], align 4
238
- // LLVM: %[[ARR_PTR:.*]] = getelementptr [1 x i32], ptr %[[ARR_ALLOCA ]], i32 0
239
+ // LLVM: %[[ARR_PTR:.*]] = getelementptr [1 x i32], ptr %[[ARR ]], i32 0
239
240
// LLVM: %[[ARR_1:.*]] = getelementptr [1 x i32], ptr %[[ARR_PTR]], i64 1
240
241
// LLVM: %[[ARR_1_0:.*]] = getelementptr i32, ptr %[[ARR_1]], i32 0
241
242
// LLVM: %[[ELE_PTR:.*]] = getelementptr i32, ptr %[[ARR_1_0]], i64 0
242
243
// LLVM: %[[TMP:.*]] = load i32, ptr %[[ELE_PTR]], align 4
243
244
// LLVM: store i32 %[[TMP]], ptr %[[INIT]], align 4
244
245
245
- // OGCG: %arr = alloca [2 x [1 x i32]], align 4
246
- // OGCG: %e = alloca i32, align 4
247
- // OGCG: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %arr , ptr align 4 @[[FUN4_ARR]], i64 8, i1 false)
248
- // OGCG: %arrayidx = getelementptr inbounds [2 x [1 x i32]], ptr %arr , i64 0, i64 1
249
- // OGCG: %arrayidx1 = getelementptr inbounds [1 x i32], ptr %arrayidx , i64 0, i64 0
250
- // OGCG: %0 = load i32, ptr %arrayidx1 , align 4
251
- // OGCG: store i32 %0 , ptr %e , align 4
246
+ // OGCG: %[[ARR:.*]] = alloca [2 x [1 x i32]], align 4
247
+ // OGCG: %[[INIT:.*]] = alloca i32, align 4
248
+ // OGCG: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %[[ARR]] , ptr align 4 @[[FUN4_ARR]], i64 8, i1 false)
249
+ // OGCG: %[[ARR_1:.*]] = getelementptr inbounds [2 x [1 x i32]], ptr %[[ARR]] , i64 0, i64 1
250
+ // OGCG: %[[ARR_1_0:.*]] = getelementptr inbounds [1 x i32], ptr %[[ARR_1]] , i64 0, i64 0
251
+ // OGCG: %[[TMP:.*]] = load i32, ptr %[[ARR_1_0]] , align 4
252
+ // OGCG: store i32 %[[TMP]] , ptr %[[INIT]] , align 4
252
253
253
254
void func5 () {
254
255
int arr[2 ][1 ] = {{5 }};
@@ -271,9 +272,9 @@ void func5() {
271
272
// CIR: cir.store %10, %[[ARR_PTR]] : !cir.ptr<!cir.array<!s32i x 1>>, !cir.ptr<!cir.ptr<!cir.array<!s32i x 1>>>
272
273
273
274
// LLVM: define void @func5()
274
- // LLVM: %[[ARR_ALLOCA :.*]] = alloca [2 x [1 x i32]], i64 1, align 4
275
+ // LLVM: %[[ARR :.*]] = alloca [2 x [1 x i32]], i64 1, align 4
275
276
// LLVM: %[[TMP:.*]] = alloca ptr, i64 1, align 8
276
- // LLVM: %[[ARR_PTR:.*]] = getelementptr [1 x i32], ptr %[[ARR_ALLOCA ]], i32 0
277
+ // LLVM: %[[ARR_PTR:.*]] = getelementptr [1 x i32], ptr %[[ARR ]], i32 0
277
278
// LLVM: %[[ARR_0:.*]] = getelementptr i32, ptr %[[ARR_PTR]], i32 0
278
279
// LLVM: store i32 5, ptr %[[ARR_0]], align 4
279
280
// LLVM: %[[ARR_1:.*]] = getelementptr [1 x i32], ptr %[[ARR_PTR]], i64 1
@@ -283,8 +284,8 @@ void func5() {
283
284
// LLVM: %[[ARR_1_PTR:.*]] = getelementptr [1 x i32], ptr %[[ARR_1_VAL]], i64 1
284
285
// LLVM: store ptr %[[ARR_1_PTR]], ptr %[[TMP]], align 8
285
286
286
- // ORGC: %arr = alloca [2 x [1 x i32]], align 4
287
- // ORGC: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %arr , ptr align 4 @[[FUN5_ARR]], i64 8, i1 false)
287
+ // ORGC: %[[ARR:.*]] = alloca [2 x [1 x i32]], align 4
288
+ // ORGC: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %[[ARR]] , ptr align 4 @[[FUN5_ARR]], i64 8, i1 false)
288
289
289
290
void func6 () {
290
291
int x = 4 ;
@@ -313,13 +314,13 @@ void func6() {
313
314
// LLVM: %[[ELE_1:.*]] = getelementptr i32, ptr %[[ELE_0]], i64 1
314
315
// LLVM: store i32 5, ptr %[[ELE_1]], align 4
315
316
316
- // OGCG: %x = alloca i32, align 4
317
- // OGCG: %arr = alloca [2 x i32], align 4
318
- // OGCG: store i32 4, ptr %x , align 4
319
- // OGCG: %0 = load i32, ptr %x , align 4
320
- // OGCG: store i32 %0 , ptr %arr , align 4
321
- // OGCG: %arrayinit.element = getelementptr inbounds i32, ptr %arr , i64 1
322
- // OGCG: store i32 5, ptr %arrayinit.element , align 4
317
+ // OGCG: %[[VAR:.*]] = alloca i32, align 4
318
+ // OGCG: %[[ARR:.*]] = alloca [2 x i32], align 4
319
+ // OGCG: store i32 4, ptr %[[VAR]] , align 4
320
+ // OGCG: %[[ELE_0:.*]] = load i32, ptr %[[VAR]] , align 4
321
+ // OGCG: store i32 %[[ELE_0]] , ptr %[[ARR]] , align 4
322
+ // OGCG: %[[ELE_1:.*]] = getelementptr inbounds i32, ptr %[[ARR]] , i64 1
323
+ // OGCG: store i32 5, ptr %[[ELE_1:.*]] , align 4
323
324
324
325
void func7 () {
325
326
int * arr[1 ] = {};
0 commit comments