Skip to content

Commit 4de115b

Browse files
committed
update tests
1 parent 4dbcde3 commit 4de115b

File tree

2 files changed

+18
-73
lines changed

2 files changed

+18
-73
lines changed

clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerFunction.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,7 @@ mlir::Value createCoercedValue(mlir::Value Src, mlir::Type Ty,
337337
}
338338

339339
auto &bld = CGF.getRewriter();
340-
auto alloca = bld.create<AllocaOp>(
341-
Src.getLoc(), bld.getType<PointerType>(Ty), Ty,
342-
/*name=*/llvm::StringRef(""), /*alignment=*/bld.getI64IntegerAttr(4));
340+
auto alloca = createTmpAlloca(CGF, Src.getLoc(), Ty);
343341
Src = findAlloca(Src.getDefiningOp());
344342
createMemCpy(CGF, alloca, Src, SrcSize.getFixedValue());
345343
return bld.create<LoadOp>(Src.getLoc(), alloca.getResult());

clang/test/CIR/CallConvLowering/AArch64/aarch64-cc-structs.c

Lines changed: 17 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -206,80 +206,27 @@ GT_128 call_and_get_gt_128() {
206206
// LLVM: call void @llvm.memcpy.p0.p0.i64(ptr %[[#V1]], ptr %[[#V2]], i64 12, i1 false)
207207
void passS(S s) {}
208208

209-
typedef struct {
210-
uint8_t a;
211-
uint16_t b;
212-
uint8_t c;
213-
} S_PAD;
214-
215-
// CHECK: cir.func {{.*@ret_s_pad}}() -> !u48i
216-
// CHECK: %[[#V0:]] = cir.alloca !ty_S_PAD, !cir.ptr<!ty_S_PAD>, ["__retval"] {alignment = 2 : i64}
217-
// CHECK: %[[#V1:]] = cir.load %[[#V0]] : !cir.ptr<!ty_S_PAD>, !ty_S_PAD
218-
// CHECK: %[[#V2:]] = cir.alloca !u48i, !cir.ptr<!u48i>, [""] {alignment = 2 : i64}
219-
// CHECK: %[[#V3:]] = cir.cast(bitcast, %[[#V0]] : !cir.ptr<!ty_S_PAD>)
220-
// CHECK: %[[#V4:]] = cir.cast(bitcast, %[[#V2:]] : !cir.ptr<!u48i>), !cir.ptr<!void>
221-
// CHECK: %[[#V5:]] = cir.const #cir.int<6> : !u64i
222-
// CHECK: cir.libc.memcpy %[[#V5]] bytes from %[[#V3]] to %[[#V4]] : !u64i, !cir.ptr<!void>
223-
// CHECK: %[[#V6:]] = cir.load %[[#V2]] : !cir.ptr<!u48i>
224-
// CHECK: cir.return %[[#V6]]
225-
226-
// LLVM: i48 @ret_s_pad()
227-
// LLVM: %[[#V1:]] = alloca %struct.S_PAD, i64 1, align 2
228-
// LLVM: %[[#V2:]] = load %struct.S_PAD, ptr %[[#V1]], align 2
229-
// LLVM: %[[#V3:]] = alloca i48, i64 1, align 2
230-
// LLVM: call void @llvm.memcpy.p0.p0.i64(ptr %[[#V3]], ptr %[[#V1]], i64 6, i1 false)
231-
// LLVM: %[[#V4:]] = load i48, ptr %[[#V3]]
232-
// LLVM: ret i48 %[[#V4]]
233-
S_PAD ret_s_pad() {
234-
S_PAD s;
235-
return s;
236-
}
237-
238-
typedef struct {
239-
int a;
240-
int b;
241-
short c;
242-
} GT_64_LT_128;
243-
244-
// CHECK: @pass_gt_64_lt_128(%arg0: !cir.array<!u64i x 2>
245-
// CHECK: %[[#V0:]] = cir.alloca !ty_GT_64_LT_128_, !cir.ptr<!ty_GT_64_LT_128_>, [""] {alignment = 4 : i64}
209+
// CHECK: @callS()
210+
// CHECK: %[[#V0:]] = cir.alloca !ty_S, !cir.ptr<!ty_S>, ["s"] {alignment = 4 : i64}
246211
// CHECK: %[[#V1:]] = cir.alloca !cir.array<!u64i x 2>, !cir.ptr<!cir.array<!u64i x 2>>, ["tmp"] {alignment = 8 : i64}
247-
// CHECK: cir.store %arg0, %[[#V1]] : !cir.array<!u64i x 2>, !cir.ptr<!cir.array<!u64i x 2>>
248-
// CHECK: %[[#V2:]] = cir.cast(bitcast, %[[#V1]] : !cir.ptr<!cir.array<!u64i x 2>>), !cir.ptr<!void>
249-
// CHECK: %[[#V3:]] = cir.cast(bitcast, %[[#V0]] : !cir.ptr<!ty_GT_64_LT_128_>), !cir.ptr<!void>
250-
// CHECK: %[[#V4:]] = cir.const #cir.int<12> : !u64i
251-
// CHECK: cir.libc.memcpy %[[#V4]] bytes from %[[#V2]] to %[[#V3]] : !u64i, !cir.ptr<!void> -> !cir.ptr<!void>
252-
// CHECK: cir.return
253-
254-
// LLVM: @pass_gt_64_lt_128([2 x i64] %[[#V0:]])
255-
// LLVM: %[[#V2:]] = alloca %struct.GT_64_LT_128, i64 1, align 4
256-
// LLVM: %[[#V3:]] = alloca [2 x i64], i64 1, align 8
257-
// LLVM: store [2 x i64] %[[#V0]], ptr %[[#V3]], align 8
258-
// LLVM: call void @llvm.memcpy.p0.p0.i64(ptr %[[#V2]], ptr %[[#V3]], i64 12, i1 false)
259-
// LLVM: ret void
260-
void pass_gt_64_lt_128(GT_64_LT_128 s) {}
261-
262-
// CHECK: @call_gt_64_lt_128()
263-
// CHECK: %[[#V0:]] = cir.alloca !ty_GT_64_LT_128_, !cir.ptr<!ty_GT_64_LT_128_>, ["s"] {alignment = 4 : i64}
264-
// CHECK: %[[#V1:]] = cir.load %[[#V0]] : !cir.ptr<!ty_GT_64_LT_128_>, !ty_GT_64_LT_128_
265-
// CHECK: %[[#V2:]] = cir.alloca !cir.array<!u64i x 2>, !cir.ptr<!cir.array<!u64i x 2>>, [""] {alignment = 4 : i64}
266-
// CHECK: %[[#V3:]] = cir.cast(bitcast, %[[#V0]] : !cir.ptr<!ty_GT_64_LT_128_>), !cir.ptr<!void>
267-
// CHECK: %[[#V4:]] = cir.cast(bitcast, %[[#V2]] : !cir.ptr<!cir.array<!u64i x 2>>), !cir.ptr<!void>
212+
// CHECK: %[[#V2:]] = cir.load %[[#V0]] : !cir.ptr<!ty_S>, !ty_S
213+
// CHECK: %[[#V3:]] = cir.cast(bitcast, %[[#V0]] : !cir.ptr<!ty_S>), !cir.ptr<!void>
214+
// CHECK: %[[#V4:]] = cir.cast(bitcast, %[[#V1]] : !cir.ptr<!cir.array<!u64i x 2>>), !cir.ptr<!void>
268215
// CHECK: %[[#V5:]] = cir.const #cir.int<12> : !u64i
269216
// CHECK: cir.libc.memcpy %[[#V5]] bytes from %[[#V3]] to %[[#V4]] : !u64i, !cir.ptr<!void> -> !cir.ptr<!void>
270-
// CHECK: %[[#V6:]] = cir.load %[[#V2]] : !cir.ptr<!cir.array<!u64i x 2>>, !cir.array<!u64i x 2>
271-
// CHECK: cir.call @pass_gt_64_lt_128(%[[#V6]]) : (!cir.array<!u64i x 2>) -> ()
217+
// CHECK: %[[#V6:]] = cir.load %[[#V1]] : !cir.ptr<!cir.array<!u64i x 2>>, !cir.array<!u64i x 2>
218+
// CHECK: cir.call @passS(%[[#V6]]) : (!cir.array<!u64i x 2>) -> ()
272219
// CHECK: cir.return
273220

274-
// LLVM: @call_gt_64_lt_128()
275-
// LLVM: %[[#V1:]] = alloca %struct.GT_64_LT_128, i64 1, align 4
276-
// LLVM: %[[#V2:]] = load %struct.GT_64_LT_128, ptr %[[#V1]], align 4
277-
// LLVM: %[[#V3:]] = alloca [2 x i64], i64 1, align 4
278-
// LLVM: call void @llvm.memcpy.p0.p0.i64(ptr %[[#V3]], ptr %[[#V1]], i64 12, i1 false)
279-
// LLVM: %[[#V4:]] = load [2 x i64], ptr %[[#V3]], align 8
280-
// LLVM: call void @pass_gt_64_lt_128([2 x i64] %[[#V4]])
221+
// LLVM: @callS()
222+
// LLVM: %[[#V1:]] = alloca %struct.S, i64 1, align 4
223+
// LLVM: %[[#V2:]] = alloca [2 x i64], i64 1, align 8
224+
// LLVM: %[[#V3:]] = load %struct.S, ptr %[[#V1]], align 4
225+
// LLVM: call void @llvm.memcpy.p0.p0.i64(ptr %[[#V2]], ptr %[[#V1]], i64 12, i1 false)
226+
// LLVM: %[[#V4:]] = load [2 x i64], ptr %[[#V2]], align 8
227+
// LLVM: call void @passS([2 x i64] %[[#V4]])
281228
// LLVM: ret void
282-
void call_gt_64_lt_128() {
283-
GT_64_LT_128 s;
284-
pass_gt_64_lt_128(s);
229+
void callS() {
230+
S s;
231+
passS(s);
285232
}

0 commit comments

Comments
 (0)