@@ -94,26 +94,27 @@ void func() {
9494// CIR" cir.store %[[TMP]], %[[INIT_2]] : !s32i, !cir.ptr<!s32i>
9595
9696// 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
9898// LLVM-NEXT: %[[INIT:.*]] = alloca i32, i64 1, align 4
9999// 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
101101// 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
105105// 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
117118
118119void func2 () {
119120 int arr[2 ] = {5 };
@@ -135,9 +136,9 @@ void func2() {
135136// CIR: cir.store %[[ELE_1_PTR]], %[[ELE_ALLOCA]] : !cir.ptr<!s32i>, !cir.ptr<!cir.ptr<!s32i>>
136137
137138// 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
139140// 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
141142// LLVM: store i32 5, ptr %[[ARR_PTR]], align 4
142143// LLVM: %[[ELE_1_PTR:.*]] = getelementptr i32, ptr %[[ARR_PTR]], i64 1
143144// LLVM: store ptr %[[ELE_1_PTR]], ptr %[[TMP]], align 8
@@ -146,8 +147,8 @@ void func2() {
146147// LLVM: %[[ELE_1:.*]] = getelementptr i32, ptr %[[TMP2]], i64 1
147148// LLVM: store ptr %[[ELE_1]], ptr %[[TMP]], align 8
148149
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)
151152
152153void func3 () {
153154 int arr[2 ] = {5 , 6 };
@@ -175,31 +176,31 @@ void func3() {
175176// CIR: cir.store %[[ELE_TMP]], %[[INIT]] : !s32i, !cir.ptr<!s32i>
176177
177178// 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
179180// LLVM: %[[IDX:.*]] = alloca i32, i64 1, align 4
180181// 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
182183// LLVM: store i32 5, ptr %[[ARR_PTR]], align 4
183184// LLVM: %[[ELE_1_PTR:.*]] = getelementptr i32, ptr %[[ARR_PTR]], i64 1
184185// LLVM: store i32 6, ptr %[[ELE_1_PTR]], align 4
185186// LLVM: store i32 1, ptr %[[IDX]], align 4
186187// 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
188189// LLVM: %[[IDX_I64:.*]] = sext i32 %[[TMP1]] to i64
189190// LLVM: %[[ELE:.*]] = getelementptr i32, ptr %[[ARR_PTR]], i64 %[[IDX_I64]]
190191// LLVM: %[[TMP2:.*]] = load i32, ptr %[[ELE]], align 4
191192// LLVM: store i32 %[[TMP2]], ptr %[[INIT]], align 4
192193
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
203204
204205void func4 () {
205206 int arr[2 ][1 ] = {{5 }, {6 }};
@@ -227,28 +228,28 @@ void func4() {
227228// CIR: cir.store %[[TMP]], %[[INIT]] : !s32i, !cir.ptr<!s32i>
228229
229230// 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
231232// 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
233234// LLVM: %[[ARR_0_0:.*]] = getelementptr i32, ptr %[[ARR_PTR]], i32 0
234235// LLVM: store i32 5, ptr %[[ARR_0_0]], align 4
235236// LLVM: %[[ARR_1:.*]] = getelementptr [1 x i32], ptr %[[ARR_PTR]], i64 1
236237// LLVM: %[[ARR_1_0:.*]] = getelementptr i32, ptr %[[ARR_1]], i32 0
237238// 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
239240// LLVM: %[[ARR_1:.*]] = getelementptr [1 x i32], ptr %[[ARR_PTR]], i64 1
240241// LLVM: %[[ARR_1_0:.*]] = getelementptr i32, ptr %[[ARR_1]], i32 0
241242// LLVM: %[[ELE_PTR:.*]] = getelementptr i32, ptr %[[ARR_1_0]], i64 0
242243// LLVM: %[[TMP:.*]] = load i32, ptr %[[ELE_PTR]], align 4
243244// LLVM: store i32 %[[TMP]], ptr %[[INIT]], align 4
244245
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
252253
253254void func5 () {
254255 int arr[2 ][1 ] = {{5 }};
@@ -271,9 +272,9 @@ void func5() {
271272// CIR: cir.store %10, %[[ARR_PTR]] : !cir.ptr<!cir.array<!s32i x 1>>, !cir.ptr<!cir.ptr<!cir.array<!s32i x 1>>>
272273
273274// 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
275276// 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
277278// LLVM: %[[ARR_0:.*]] = getelementptr i32, ptr %[[ARR_PTR]], i32 0
278279// LLVM: store i32 5, ptr %[[ARR_0]], align 4
279280// LLVM: %[[ARR_1:.*]] = getelementptr [1 x i32], ptr %[[ARR_PTR]], i64 1
@@ -283,8 +284,8 @@ void func5() {
283284// LLVM: %[[ARR_1_PTR:.*]] = getelementptr [1 x i32], ptr %[[ARR_1_VAL]], i64 1
284285// LLVM: store ptr %[[ARR_1_PTR]], ptr %[[TMP]], align 8
285286
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)
288289
289290void func6 () {
290291 int x = 4 ;
@@ -313,13 +314,13 @@ void func6() {
313314// LLVM: %[[ELE_1:.*]] = getelementptr i32, ptr %[[ELE_0]], i64 1
314315// LLVM: store i32 5, ptr %[[ELE_1]], align 4
315316
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
323324
324325void func7 () {
325326 int * arr[1 ] = {};
0 commit comments