Files
c3c/test/test_suite/constants/const_var_copy.c3t

31 lines
848 B
Plaintext

// #target: macos-x64
module foo;
const char[100] FOO = { [50] = 1 };
const int[<4>] BAR = { 1, 2, 3, 4 };
fn void test(int z)
{
char s = FOO[z];
int zd = BAR[z];
}
/* #expect: foo.ll
@foo.FOO = local_unnamed_addr constant { [50 x i8], i8, [49 x i8] } { [50 x i8] zeroinitializer, i8 1, [49 x i8] zeroinitializer }, align 16
@foo.BAR = local_unnamed_addr constant <4 x i32> <i32 1, i32 2, i32 3, i32 4>, align 16
; Function Attrs:
define void @foo.test(i32 %0) #0 {
entry:
%s = alloca i8, align 1
%zd = alloca i32, align 4
%sext = sext i32 %0 to i64
%ptradd = getelementptr inbounds i8, ptr @foo.FOO, i64 %sext
%1 = load i8, ptr %ptradd, align 1
store i8 %1, ptr %s, align 1
%sext1 = sext i32 %0 to i64
%2 = extractelement <4 x i32> <i32 1, i32 2, i32 3, i32 4>, i64 %sext1
store i32 %2, ptr %zd, align 4
ret void
}