// #target: macos-x64 module foo; extern fn void printf(char*, ...); fn void test1(variant z) { int* w = z.ptr; printf("%d\n", *w); } fn void test2(int[] z) { int* w = z.ptr; printf("%d\n", *w); } fn void main() { int x = 123; int y = 293483; int[2] w = { 144, 772 }; test1(&x); test2(w[..]); } /* #expect: foo.ll %variant = type { i8*, i64 } %"int[]" = type { i32*, i64 } @"ct$int" = linkonce constant %.introspect { i8 2, i64 4, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8 define void @foo_test1(i64 %0, i8* %1) #0 { entry: %z = alloca %variant, align 8 %w = alloca i32*, align 8 %pair = bitcast %variant* %z to { i64, i8* }* %2 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %pair, i32 0, i32 0 store i64 %0, i64* %2, align 8 %3 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %pair, i32 0, i32 1 store i8* %1, i8** %3, align 8 %4 = getelementptr inbounds %variant, %variant* %z, i32 0, i32 0 %5 = load i8*, i8** %4, align 8 %ptrptr = bitcast i8* %5 to i32* store i32* %ptrptr, i32** %w, align 8 %6 = load i32*, i32** %w, align 8 %7 = load i32, i32* %6, align 8 call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %7) ret void } ; Function Attrs: nounwind define void @foo_test2(i8* %0, i64 %1) #0 { entry: %z = alloca %"int[]", align 8 %w = alloca i32*, align 8 %pair = bitcast %"int[]"* %z to { i8*, i64 }* %2 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 0 store i8* %0, i8** %2, align 8 %3 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 1 store i64 %1, i64* %3, align 8 %4 = getelementptr inbounds %"int[]", %"int[]"* %z, i32 0, i32 0 %5 = load i32*, i32** %4, align 8 store i32* %5, i32** %w, align 8 %6 = load i32*, i32** %w, align 8 %7 = load i32, i32* %6, align 8 call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i32 %7) ret void } ; Function Attrs: nounwind define void @foo_main() #0 { entry: %x = alloca i32, align 4 %y = alloca i32, align 4 %w = alloca [2 x i32], align 4 %taddr = alloca %variant, align 8 %taddr1 = alloca %"int[]", align 8 store i32 123, i32* %x, align 4 store i32 293483, i32* %y, align 4 %0 = bitcast [2 x i32]* %w to i8* call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 4 bitcast ([2 x i32]* @.__const to i8*), i32 8, i1 false) %1 = bitcast i32* %x to i8* %2 = insertvalue %variant undef, i8* %1, 0 %3 = insertvalue %variant %2, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 store %variant %3, %variant* %taddr, align 8 %4 = bitcast %variant* %taddr to { i64, i8* }* %5 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %4, i32 0, i32 0 %lo = load i64, i64* %5, align 8 %6 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %4, i32 0, i32 1 %hi = load i8*, i8** %6, align 8 call void @foo_test1(i64 %lo, i8* %hi) %7 = getelementptr inbounds [2 x i32], [2 x i32]* %w, i64 0, i64 0 %8 = insertvalue %"int[]" undef, i32* %7, 0 %9 = insertvalue %"int[]" %8, i64 2, 1 store %"int[]" %9, %"int[]"* %taddr1, align 8 %10 = bitcast %"int[]"* %taddr1 to { i8*, i64 }* %11 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %10, i32 0, i32 0 %lo2 = load i8*, i8** %11, align 8 %12 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %10, i32 0, i32 1 %hi3 = load i64, i64* %12, align 8 call void @foo_test2(i8* %lo2, i64 %hi3) ret void }