mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
52 lines
1.7 KiB
Plaintext
52 lines
1.7 KiB
Plaintext
// #target: mingw-x64
|
|
module splat;
|
|
|
|
extern fn int sum_us(int... x);
|
|
|
|
fn void test()
|
|
{
|
|
sum_us(1, 2, 3);
|
|
int[3] x = { 1, 2, 3 };
|
|
int[] z = &x;
|
|
sum_us(...x);
|
|
sum_us(...z);
|
|
sum_us();
|
|
}
|
|
|
|
/* #expect: splat.ll
|
|
|
|
declare i32 @sum_us(ptr align 8) #0
|
|
|
|
; Function Attrs:
|
|
define void @splat.test() #0 {
|
|
entry:
|
|
%varargslots = alloca [3 x i32], align 4
|
|
%indirectarg = alloca %"int[]", align 8
|
|
%x = alloca [3 x i32], align 4
|
|
%z = alloca %"int[]", align 8
|
|
%indirectarg2 = alloca %"int[]", align 8
|
|
%indirectarg3 = alloca %"int[]", align 8
|
|
%indirectarg4 = alloca %"int[]", align 8
|
|
store i32 1, ptr %varargslots, align 4
|
|
%ptradd = getelementptr inbounds i8, ptr %varargslots, i64 4
|
|
store i32 2, ptr %ptradd, align 4
|
|
%ptradd1 = getelementptr inbounds i8, ptr %varargslots, i64 8
|
|
store i32 3, ptr %ptradd1, align 4
|
|
%0 = insertvalue %"int[]" undef, ptr %varargslots, 0
|
|
%"$$temp" = insertvalue %"int[]" %0, i64 3, 1
|
|
store %"int[]" %"$$temp", ptr %indirectarg, align 8
|
|
%1 = call i32 @sum_us(ptr align 8 %indirectarg)
|
|
call void @llvm.memcpy.p0.p0.i32(ptr align 4 %x, ptr align 4 @.__const, i32 12, i1 false)
|
|
%2 = insertvalue %"int[]" undef, ptr %x, 0
|
|
%3 = insertvalue %"int[]" %2, i64 3, 1
|
|
store %"int[]" %3, ptr %z, align 8
|
|
%4 = insertvalue %"int[]" undef, ptr %x, 0
|
|
%5 = insertvalue %"int[]" %4, i64 3, 1
|
|
store %"int[]" %5, ptr %indirectarg2, align 8
|
|
%6 = call i32 @sum_us(ptr align 8 %indirectarg2)
|
|
call void @llvm.memcpy.p0.p0.i32(ptr align 8 %indirectarg3, ptr align 8 %z, i32 16, i1 false)
|
|
%7 = call i32 @sum_us(ptr align 8 %indirectarg3)
|
|
store %"int[]" zeroinitializer, ptr %indirectarg4, align 8
|
|
%8 = call i32 @sum_us(ptr align 8 %indirectarg4)
|
|
ret void
|