diff --git a/internal/cabi/_testdata/arch.sh b/internal/cabi/_testdata/arch.sh new file mode 100755 index 00000000..64d753af --- /dev/null +++ b/internal/cabi/_testdata/arch.sh @@ -0,0 +1,13 @@ +#!/bin/sh +mkdir -p arch/amd64 +mkdir -p arch/arm64 +mkdir -p arch/i386 +mkdir -p arch/armv6 +mkdir -p arch/riscv64 +mkdir -p arch/wasm32 +(cd arch/amd64 && clang -target amd64-unknown-linux-gnu -S -emit-llvm ../../wrap/*.c) +(cd arch/arm64 && clang -target aarch64-linux-gnu -S -emit-llvm ../../wrap/*.c) +(cd arch/i386 && clang -target i386-unknown-linux-gnu -S -emit-llvm ../../wrap/*.c) +(cd arch/armv6 && clang -target armv6l-unknown-linux-gnueabihf -S -emit-llvm ../../wrap/*.c) +(cd arch/riscv64 && clang -target riscv64-unknown-elf -S -emit-llvm ../../wrap/*.c) +(cd arch/wasm32 && clang -target wasm32-unknown-emscripten -S -emit-llvm ../../wrap/*.c) \ No newline at end of file diff --git a/internal/cabi/_testdata/arch/amd64/array_float32.ll b/internal/cabi/_testdata/arch/amd64/array_float32.ll new file mode 100644 index 00000000..ed92f825 --- /dev/null +++ b/internal/cabi/_testdata/arch/amd64/array_float32.ll @@ -0,0 +1,244 @@ +; ModuleID = '../../wrap/array_float32.c' +source_filename = "../../wrap/array_float32.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "amd64-unknown-linux-gnu" + +%struct.array1 = type { [1 x float] } +%struct.array2 = type { [2 x float] } +%struct.array3 = type { [3 x float] } +%struct.array4 = type { [4 x float] } +%struct.array5 = type { [5 x float] } +%struct.array6 = type { [6 x float] } +%struct.array7 = type { [7 x float] } +%struct.array8 = type { [8 x float] } +%struct.array9 = type { [9 x float] } +%struct.array10 = type { [10 x float] } +%struct.array11 = type { [11 x float] } +%struct.array12 = type { [12 x float] } +%struct.array13 = type { [13 x float] } +%struct.array14 = type { [14 x float] } +%struct.array15 = type { [15 x float] } +%struct.array16 = type { [16 x float] } +%struct.array17 = type { [17 x float] } +%struct.array18 = type { [18 x float] } +%struct.array19 = type { [19 x float] } +%struct.array20 = type { [20 x float] } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local float @demo1(float %0) #0 { + %2 = alloca %struct.array1, align 4 + %3 = alloca %struct.array1, align 4 + %4 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + %5 = bitcast [1 x float]* %4 to float* + store float %0, float* %5, align 4 + %6 = bitcast %struct.array1* %2 to i8* + %7 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %6, i8* align 4 %7, i64 4, i1 false) + %8 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %9 = bitcast [1 x float]* %8 to float* + %10 = load float, float* %9, align 4 + ret float %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local <2 x float> @demo2(<2 x float> %0) #2 { + %2 = alloca %struct.array2, align 4 + %3 = alloca %struct.array2, align 4 + %4 = getelementptr inbounds %struct.array2, %struct.array2* %3, i32 0, i32 0 + %5 = bitcast [2 x float]* %4 to <2 x float>* + store <2 x float> %0, <2 x float>* %5, align 4 + %6 = bitcast %struct.array2* %2 to i8* + %7 = bitcast %struct.array2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %6, i8* align 4 %7, i64 8, i1 false) + %8 = getelementptr inbounds %struct.array2, %struct.array2* %2, i32 0, i32 0 + %9 = bitcast [2 x float]* %8 to <2 x float>* + %10 = load <2 x float>, <2 x float>* %9, align 4 + ret <2 x float> %10 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { <2 x float>, float } @demo3(<2 x float> %0, float %1) #2 { + %3 = alloca %struct.array3, align 4 + %4 = alloca %struct.array3, align 4 + %5 = alloca { <2 x float>, float }, align 4 + %6 = alloca { <2 x float>, float }, align 8 + %7 = getelementptr inbounds { <2 x float>, float }, { <2 x float>, float }* %5, i32 0, i32 0 + store <2 x float> %0, <2 x float>* %7, align 4 + %8 = getelementptr inbounds { <2 x float>, float }, { <2 x float>, float }* %5, i32 0, i32 1 + store float %1, float* %8, align 4 + %9 = bitcast %struct.array3* %4 to i8* + %10 = bitcast { <2 x float>, float }* %5 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %9, i8* align 4 %10, i64 12, i1 false) + %11 = bitcast %struct.array3* %3 to i8* + %12 = bitcast %struct.array3* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %11, i8* align 4 %12, i64 12, i1 false) + %13 = getelementptr inbounds %struct.array3, %struct.array3* %3, i32 0, i32 0 + %14 = bitcast { <2 x float>, float }* %6 to i8* + %15 = bitcast [3 x float]* %13 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %14, i8* align 4 %15, i64 12, i1 false) + %16 = load { <2 x float>, float }, { <2 x float>, float }* %6, align 8 + ret { <2 x float>, float } %16 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { <2 x float>, <2 x float> } @demo4(<2 x float> %0, <2 x float> %1) #2 { + %3 = alloca %struct.array4, align 4 + %4 = alloca %struct.array4, align 4 + %5 = bitcast %struct.array4* %4 to { <2 x float>, <2 x float> }* + %6 = getelementptr inbounds { <2 x float>, <2 x float> }, { <2 x float>, <2 x float> }* %5, i32 0, i32 0 + store <2 x float> %0, <2 x float>* %6, align 4 + %7 = getelementptr inbounds { <2 x float>, <2 x float> }, { <2 x float>, <2 x float> }* %5, i32 0, i32 1 + store <2 x float> %1, <2 x float>* %7, align 4 + %8 = bitcast %struct.array4* %3 to i8* + %9 = bitcast %struct.array4* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %8, i8* align 4 %9, i64 16, i1 false) + %10 = getelementptr inbounds %struct.array4, %struct.array4* %3, i32 0, i32 0 + %11 = bitcast [4 x float]* %10 to { <2 x float>, <2 x float> }* + %12 = load { <2 x float>, <2 x float> }, { <2 x float>, <2 x float> }* %11, align 4 + ret { <2 x float>, <2 x float> } %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 4 %0, %struct.array5* noundef byval(%struct.array5) align 8 %1) #0 { + %3 = bitcast %struct.array5* %0 to i8* + %4 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 4 %0, %struct.array6* noundef byval(%struct.array6) align 8 %1) #0 { + %3 = bitcast %struct.array6* %0 to i8* + %4 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 4 %0, %struct.array7* noundef byval(%struct.array7) align 8 %1) #0 { + %3 = bitcast %struct.array7* %0 to i8* + %4 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 4 %0, %struct.array8* noundef byval(%struct.array8) align 8 %1) #0 { + %3 = bitcast %struct.array8* %0 to i8* + %4 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 4 %0, %struct.array9* noundef byval(%struct.array9) align 8 %1) #0 { + %3 = bitcast %struct.array9* %0 to i8* + %4 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 4 %0, %struct.array10* noundef byval(%struct.array10) align 8 %1) #0 { + %3 = bitcast %struct.array10* %0 to i8* + %4 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 4 %0, %struct.array11* noundef byval(%struct.array11) align 8 %1) #0 { + %3 = bitcast %struct.array11* %0 to i8* + %4 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 4 %0, %struct.array12* noundef byval(%struct.array12) align 8 %1) #0 { + %3 = bitcast %struct.array12* %0 to i8* + %4 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 4 %0, %struct.array13* noundef byval(%struct.array13) align 8 %1) #0 { + %3 = bitcast %struct.array13* %0 to i8* + %4 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 4 %0, %struct.array14* noundef byval(%struct.array14) align 8 %1) #0 { + %3 = bitcast %struct.array14* %0 to i8* + %4 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 4 %0, %struct.array15* noundef byval(%struct.array15) align 8 %1) #0 { + %3 = bitcast %struct.array15* %0 to i8* + %4 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 4 %0, %struct.array16* noundef byval(%struct.array16) align 8 %1) #0 { + %3 = bitcast %struct.array16* %0 to i8* + %4 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 4 %0, %struct.array17* noundef byval(%struct.array17) align 8 %1) #0 { + %3 = bitcast %struct.array17* %0 to i8* + %4 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 4 %0, %struct.array18* noundef byval(%struct.array18) align 8 %1) #0 { + %3 = bitcast %struct.array18* %0 to i8* + %4 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 4 %0, %struct.array19* noundef byval(%struct.array19) align 8 %1) #0 { + %3 = bitcast %struct.array19* %0 to i8* + %4 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 4 %0, %struct.array20* noundef byval(%struct.array20) align 8 %1) #0 { + %3 = bitcast %struct.array20* %0 to i8* + %4 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } +attributes #2 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="64" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } + +!llvm.module.flags = !{!0, !1, !2, !3, !4} +!llvm.ident = !{!5} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{i32 7, !"frame-pointer", i32 2} +!5 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/amd64/array_float64.ll b/internal/cabi/_testdata/arch/amd64/array_float64.ll new file mode 100644 index 00000000..c0e54fcc --- /dev/null +++ b/internal/cabi/_testdata/arch/amd64/array_float64.ll @@ -0,0 +1,219 @@ +; ModuleID = '../../wrap/array_float64.c' +source_filename = "../../wrap/array_float64.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "amd64-unknown-linux-gnu" + +%struct.array1 = type { [1 x double] } +%struct.array2 = type { [2 x double] } +%struct.array3 = type { [3 x double] } +%struct.array4 = type { [4 x double] } +%struct.array5 = type { [5 x double] } +%struct.array6 = type { [6 x double] } +%struct.array7 = type { [7 x double] } +%struct.array8 = type { [8 x double] } +%struct.array9 = type { [9 x double] } +%struct.array10 = type { [10 x double] } +%struct.array11 = type { [11 x double] } +%struct.array12 = type { [12 x double] } +%struct.array13 = type { [13 x double] } +%struct.array14 = type { [14 x double] } +%struct.array15 = type { [15 x double] } +%struct.array16 = type { [16 x double] } +%struct.array17 = type { [17 x double] } +%struct.array18 = type { [18 x double] } +%struct.array19 = type { [19 x double] } +%struct.array20 = type { [20 x double] } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local double @demo1(double %0) #0 { + %2 = alloca %struct.array1, align 8 + %3 = alloca %struct.array1, align 8 + %4 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + %5 = bitcast [1 x double]* %4 to double* + store double %0, double* %5, align 8 + %6 = bitcast %struct.array1* %2 to i8* + %7 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %6, i8* align 8 %7, i64 8, i1 false) + %8 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %9 = bitcast [1 x double]* %8 to double* + %10 = load double, double* %9, align 8 + ret double %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { double, double } @demo2(double %0, double %1) #0 { + %3 = alloca %struct.array2, align 8 + %4 = alloca %struct.array2, align 8 + %5 = bitcast %struct.array2* %4 to { double, double }* + %6 = getelementptr inbounds { double, double }, { double, double }* %5, i32 0, i32 0 + store double %0, double* %6, align 8 + %7 = getelementptr inbounds { double, double }, { double, double }* %5, i32 0, i32 1 + store double %1, double* %7, align 8 + %8 = bitcast %struct.array2* %3 to i8* + %9 = bitcast %struct.array2* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %8, i8* align 8 %9, i64 16, i1 false) + %10 = getelementptr inbounds %struct.array2, %struct.array2* %3, i32 0, i32 0 + %11 = bitcast [2 x double]* %10 to { double, double }* + %12 = load { double, double }, { double, double }* %11, align 8 + ret { double, double } %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo3(%struct.array3* noalias sret(%struct.array3) align 8 %0, %struct.array3* noundef byval(%struct.array3) align 8 %1) #0 { + %3 = bitcast %struct.array3* %0 to i8* + %4 = bitcast %struct.array3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo4(%struct.array4* noalias sret(%struct.array4) align 8 %0, %struct.array4* noundef byval(%struct.array4) align 8 %1) #0 { + %3 = bitcast %struct.array4* %0 to i8* + %4 = bitcast %struct.array4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 8 %0, %struct.array5* noundef byval(%struct.array5) align 8 %1) #0 { + %3 = bitcast %struct.array5* %0 to i8* + %4 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 8 %0, %struct.array6* noundef byval(%struct.array6) align 8 %1) #0 { + %3 = bitcast %struct.array6* %0 to i8* + %4 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 8 %0, %struct.array7* noundef byval(%struct.array7) align 8 %1) #0 { + %3 = bitcast %struct.array7* %0 to i8* + %4 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 8 %0, %struct.array8* noundef byval(%struct.array8) align 8 %1) #0 { + %3 = bitcast %struct.array8* %0 to i8* + %4 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 8 %0, %struct.array9* noundef byval(%struct.array9) align 8 %1) #0 { + %3 = bitcast %struct.array9* %0 to i8* + %4 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 8 %0, %struct.array10* noundef byval(%struct.array10) align 8 %1) #0 { + %3 = bitcast %struct.array10* %0 to i8* + %4 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 8 %0, %struct.array11* noundef byval(%struct.array11) align 8 %1) #0 { + %3 = bitcast %struct.array11* %0 to i8* + %4 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 8 %0, %struct.array12* noundef byval(%struct.array12) align 8 %1) #0 { + %3 = bitcast %struct.array12* %0 to i8* + %4 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 8 %0, %struct.array13* noundef byval(%struct.array13) align 8 %1) #0 { + %3 = bitcast %struct.array13* %0 to i8* + %4 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 8 %0, %struct.array14* noundef byval(%struct.array14) align 8 %1) #0 { + %3 = bitcast %struct.array14* %0 to i8* + %4 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 8 %0, %struct.array15* noundef byval(%struct.array15) align 8 %1) #0 { + %3 = bitcast %struct.array15* %0 to i8* + %4 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 8 %0, %struct.array16* noundef byval(%struct.array16) align 8 %1) #0 { + %3 = bitcast %struct.array16* %0 to i8* + %4 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 8 %0, %struct.array17* noundef byval(%struct.array17) align 8 %1) #0 { + %3 = bitcast %struct.array17* %0 to i8* + %4 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 8 %0, %struct.array18* noundef byval(%struct.array18) align 8 %1) #0 { + %3 = bitcast %struct.array18* %0 to i8* + %4 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 8 %0, %struct.array19* noundef byval(%struct.array19) align 8 %1) #0 { + %3 = bitcast %struct.array19* %0 to i8* + %4 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 8 %0, %struct.array20* noundef byval(%struct.array20) align 8 %1) #0 { + %3 = bitcast %struct.array20* %0 to i8* + %4 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4} +!llvm.ident = !{!5} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{i32 7, !"frame-pointer", i32 2} +!5 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/amd64/array_int16.ll b/internal/cabi/_testdata/arch/amd64/array_int16.ll new file mode 100644 index 00000000..200398f5 --- /dev/null +++ b/internal/cabi/_testdata/arch/amd64/array_int16.ll @@ -0,0 +1,297 @@ +; ModuleID = '../../wrap/array_int16.c' +source_filename = "../../wrap/array_int16.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "amd64-unknown-linux-gnu" + +%struct.array1 = type { [1 x i16] } +%struct.array2 = type { [2 x i16] } +%struct.array3 = type { [3 x i16] } +%struct.array4 = type { [4 x i16] } +%struct.array5 = type { [5 x i16] } +%struct.array6 = type { [6 x i16] } +%struct.array7 = type { [7 x i16] } +%struct.array8 = type { [8 x i16] } +%struct.array9 = type { [9 x i16] } +%struct.array10 = type { [10 x i16] } +%struct.array11 = type { [11 x i16] } +%struct.array12 = type { [12 x i16] } +%struct.array13 = type { [13 x i16] } +%struct.array14 = type { [14 x i16] } +%struct.array15 = type { [15 x i16] } +%struct.array16 = type { [16 x i16] } +%struct.array17 = type { [17 x i16] } +%struct.array18 = type { [18 x i16] } +%struct.array19 = type { [19 x i16] } +%struct.array20 = type { [20 x i16] } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i16 @demo1(i16 %0) #0 { + %2 = alloca %struct.array1, align 2 + %3 = alloca %struct.array1, align 2 + %4 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + %5 = bitcast [1 x i16]* %4 to i16* + store i16 %0, i16* %5, align 2 + %6 = bitcast %struct.array1* %2 to i8* + %7 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %6, i8* align 2 %7, i64 2, i1 false) + %8 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %9 = bitcast [1 x i16]* %8 to i16* + %10 = load i16, i16* %9, align 2 + ret i16 %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i32 @demo2(i32 %0) #0 { + %2 = alloca %struct.array2, align 2 + %3 = alloca %struct.array2, align 2 + %4 = getelementptr inbounds %struct.array2, %struct.array2* %3, i32 0, i32 0 + %5 = bitcast [2 x i16]* %4 to i32* + store i32 %0, i32* %5, align 2 + %6 = bitcast %struct.array2* %2 to i8* + %7 = bitcast %struct.array2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %6, i8* align 2 %7, i64 4, i1 false) + %8 = getelementptr inbounds %struct.array2, %struct.array2* %2, i32 0, i32 0 + %9 = bitcast [2 x i16]* %8 to i32* + %10 = load i32, i32* %9, align 2 + ret i32 %10 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i48 @demo3(i48 %0) #0 { + %2 = alloca %struct.array3, align 2 + %3 = alloca %struct.array3, align 2 + %4 = alloca i48, align 8 + %5 = alloca i48, align 8 + %6 = getelementptr inbounds %struct.array3, %struct.array3* %3, i32 0, i32 0 + store i48 %0, i48* %4, align 8 + %7 = bitcast [3 x i16]* %6 to i8* + %8 = bitcast i48* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %7, i8* align 8 %8, i64 6, i1 false) + %9 = bitcast %struct.array3* %2 to i8* + %10 = bitcast %struct.array3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %9, i8* align 2 %10, i64 6, i1 false) + %11 = getelementptr inbounds %struct.array3, %struct.array3* %2, i32 0, i32 0 + %12 = bitcast i48* %5 to i8* + %13 = bitcast [3 x i16]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 2 %13, i64 6, i1 false) + %14 = load i48, i48* %5, align 8 + ret i48 %14 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i64 @demo4(i64 %0) #0 { + %2 = alloca %struct.array4, align 2 + %3 = alloca %struct.array4, align 2 + %4 = getelementptr inbounds %struct.array4, %struct.array4* %3, i32 0, i32 0 + %5 = bitcast [4 x i16]* %4 to i64* + store i64 %0, i64* %5, align 2 + %6 = bitcast %struct.array4* %2 to i8* + %7 = bitcast %struct.array4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %6, i8* align 2 %7, i64 8, i1 false) + %8 = getelementptr inbounds %struct.array4, %struct.array4* %2, i32 0, i32 0 + %9 = bitcast [4 x i16]* %8 to i64* + %10 = load i64, i64* %9, align 2 + ret i64 %10 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i64, i16 } @demo5(i64 %0, i16 %1) #0 { + %3 = alloca %struct.array5, align 2 + %4 = alloca %struct.array5, align 2 + %5 = alloca { i64, i16 }, align 2 + %6 = alloca { i64, i16 }, align 8 + %7 = getelementptr inbounds { i64, i16 }, { i64, i16 }* %5, i32 0, i32 0 + store i64 %0, i64* %7, align 2 + %8 = getelementptr inbounds { i64, i16 }, { i64, i16 }* %5, i32 0, i32 1 + store i16 %1, i16* %8, align 2 + %9 = bitcast %struct.array5* %4 to i8* + %10 = bitcast { i64, i16 }* %5 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %9, i8* align 2 %10, i64 10, i1 false) + %11 = bitcast %struct.array5* %3 to i8* + %12 = bitcast %struct.array5* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %11, i8* align 2 %12, i64 10, i1 false) + %13 = getelementptr inbounds %struct.array5, %struct.array5* %3, i32 0, i32 0 + %14 = bitcast { i64, i16 }* %6 to i8* + %15 = bitcast [5 x i16]* %13 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %14, i8* align 2 %15, i64 10, i1 false) + %16 = load { i64, i16 }, { i64, i16 }* %6, align 8 + ret { i64, i16 } %16 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i64, i32 } @demo6(i64 %0, i32 %1) #0 { + %3 = alloca %struct.array6, align 2 + %4 = alloca %struct.array6, align 2 + %5 = alloca { i64, i32 }, align 2 + %6 = alloca { i64, i32 }, align 8 + %7 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %5, i32 0, i32 0 + store i64 %0, i64* %7, align 2 + %8 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %5, i32 0, i32 1 + store i32 %1, i32* %8, align 2 + %9 = bitcast %struct.array6* %4 to i8* + %10 = bitcast { i64, i32 }* %5 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %9, i8* align 2 %10, i64 12, i1 false) + %11 = bitcast %struct.array6* %3 to i8* + %12 = bitcast %struct.array6* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %11, i8* align 2 %12, i64 12, i1 false) + %13 = getelementptr inbounds %struct.array6, %struct.array6* %3, i32 0, i32 0 + %14 = bitcast { i64, i32 }* %6 to i8* + %15 = bitcast [6 x i16]* %13 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %14, i8* align 2 %15, i64 12, i1 false) + %16 = load { i64, i32 }, { i64, i32 }* %6, align 8 + ret { i64, i32 } %16 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i64, i48 } @demo7(i64 %0, i48 %1) #0 { + %3 = alloca %struct.array7, align 2 + %4 = alloca %struct.array7, align 2 + %5 = alloca { i64, i48 }, align 2 + %6 = alloca { i64, i48 }, align 8 + %7 = getelementptr inbounds { i64, i48 }, { i64, i48 }* %5, i32 0, i32 0 + store i64 %0, i64* %7, align 2 + %8 = getelementptr inbounds { i64, i48 }, { i64, i48 }* %5, i32 0, i32 1 + store i48 %1, i48* %8, align 2 + %9 = bitcast %struct.array7* %4 to i8* + %10 = bitcast { i64, i48 }* %5 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %9, i8* align 2 %10, i64 14, i1 false) + %11 = bitcast %struct.array7* %3 to i8* + %12 = bitcast %struct.array7* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %11, i8* align 2 %12, i64 14, i1 false) + %13 = getelementptr inbounds %struct.array7, %struct.array7* %3, i32 0, i32 0 + %14 = bitcast { i64, i48 }* %6 to i8* + %15 = bitcast [7 x i16]* %13 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %14, i8* align 2 %15, i64 14, i1 false) + %16 = load { i64, i48 }, { i64, i48 }* %6, align 8 + ret { i64, i48 } %16 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i64, i64 } @demo8(i64 %0, i64 %1) #0 { + %3 = alloca %struct.array8, align 2 + %4 = alloca %struct.array8, align 2 + %5 = bitcast %struct.array8* %4 to { i64, i64 }* + %6 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %5, i32 0, i32 0 + store i64 %0, i64* %6, align 2 + %7 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %5, i32 0, i32 1 + store i64 %1, i64* %7, align 2 + %8 = bitcast %struct.array8* %3 to i8* + %9 = bitcast %struct.array8* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %8, i8* align 2 %9, i64 16, i1 false) + %10 = getelementptr inbounds %struct.array8, %struct.array8* %3, i32 0, i32 0 + %11 = bitcast [8 x i16]* %10 to { i64, i64 }* + %12 = load { i64, i64 }, { i64, i64 }* %11, align 2 + ret { i64, i64 } %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 2 %0, %struct.array9* noundef byval(%struct.array9) align 8 %1) #0 { + %3 = bitcast %struct.array9* %0 to i8* + %4 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 8 %4, i64 18, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 2 %0, %struct.array10* noundef byval(%struct.array10) align 8 %1) #0 { + %3 = bitcast %struct.array10* %0 to i8* + %4 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 8 %4, i64 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 2 %0, %struct.array11* noundef byval(%struct.array11) align 8 %1) #0 { + %3 = bitcast %struct.array11* %0 to i8* + %4 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 8 %4, i64 22, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 2 %0, %struct.array12* noundef byval(%struct.array12) align 8 %1) #0 { + %3 = bitcast %struct.array12* %0 to i8* + %4 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 8 %4, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 2 %0, %struct.array13* noundef byval(%struct.array13) align 8 %1) #0 { + %3 = bitcast %struct.array13* %0 to i8* + %4 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 8 %4, i64 26, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 2 %0, %struct.array14* noundef byval(%struct.array14) align 8 %1) #0 { + %3 = bitcast %struct.array14* %0 to i8* + %4 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 8 %4, i64 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 2 %0, %struct.array15* noundef byval(%struct.array15) align 8 %1) #0 { + %3 = bitcast %struct.array15* %0 to i8* + %4 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 8 %4, i64 30, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 2 %0, %struct.array16* noundef byval(%struct.array16) align 8 %1) #0 { + %3 = bitcast %struct.array16* %0 to i8* + %4 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 8 %4, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 2 %0, %struct.array17* noundef byval(%struct.array17) align 8 %1) #0 { + %3 = bitcast %struct.array17* %0 to i8* + %4 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 8 %4, i64 34, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 2 %0, %struct.array18* noundef byval(%struct.array18) align 8 %1) #0 { + %3 = bitcast %struct.array18* %0 to i8* + %4 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 8 %4, i64 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 2 %0, %struct.array19* noundef byval(%struct.array19) align 8 %1) #0 { + %3 = bitcast %struct.array19* %0 to i8* + %4 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 8 %4, i64 38, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 2 %0, %struct.array20* noundef byval(%struct.array20) align 8 %1) #0 { + %3 = bitcast %struct.array20* %0 to i8* + %4 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 8 %4, i64 40, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4} +!llvm.ident = !{!5} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{i32 7, !"frame-pointer", i32 2} +!5 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/amd64/array_int32.ll b/internal/cabi/_testdata/arch/amd64/array_int32.ll new file mode 100644 index 00000000..5261accf --- /dev/null +++ b/internal/cabi/_testdata/arch/amd64/array_int32.ll @@ -0,0 +1,243 @@ +; ModuleID = '../../wrap/array_int32.c' +source_filename = "../../wrap/array_int32.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "amd64-unknown-linux-gnu" + +%struct.array1 = type { [1 x i32] } +%struct.array2 = type { [2 x i32] } +%struct.array3 = type { [3 x i32] } +%struct.array4 = type { [4 x i32] } +%struct.array5 = type { [5 x i32] } +%struct.array6 = type { [6 x i32] } +%struct.array7 = type { [7 x i32] } +%struct.array8 = type { [8 x i32] } +%struct.array9 = type { [9 x i32] } +%struct.array10 = type { [10 x i32] } +%struct.array11 = type { [11 x i32] } +%struct.array12 = type { [12 x i32] } +%struct.array13 = type { [13 x i32] } +%struct.array14 = type { [14 x i32] } +%struct.array15 = type { [15 x i32] } +%struct.array16 = type { [16 x i32] } +%struct.array17 = type { [17 x i32] } +%struct.array18 = type { [18 x i32] } +%struct.array19 = type { [19 x i32] } +%struct.array20 = type { [20 x i32] } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i32 @demo1(i32 %0) #0 { + %2 = alloca %struct.array1, align 4 + %3 = alloca %struct.array1, align 4 + %4 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + %5 = bitcast [1 x i32]* %4 to i32* + store i32 %0, i32* %5, align 4 + %6 = bitcast %struct.array1* %2 to i8* + %7 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %6, i8* align 4 %7, i64 4, i1 false) + %8 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %9 = bitcast [1 x i32]* %8 to i32* + %10 = load i32, i32* %9, align 4 + ret i32 %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i64 @demo2(i64 %0) #0 { + %2 = alloca %struct.array2, align 4 + %3 = alloca %struct.array2, align 4 + %4 = getelementptr inbounds %struct.array2, %struct.array2* %3, i32 0, i32 0 + %5 = bitcast [2 x i32]* %4 to i64* + store i64 %0, i64* %5, align 4 + %6 = bitcast %struct.array2* %2 to i8* + %7 = bitcast %struct.array2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %6, i8* align 4 %7, i64 8, i1 false) + %8 = getelementptr inbounds %struct.array2, %struct.array2* %2, i32 0, i32 0 + %9 = bitcast [2 x i32]* %8 to i64* + %10 = load i64, i64* %9, align 4 + ret i64 %10 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i64, i32 } @demo3(i64 %0, i32 %1) #0 { + %3 = alloca %struct.array3, align 4 + %4 = alloca %struct.array3, align 4 + %5 = alloca { i64, i32 }, align 4 + %6 = alloca { i64, i32 }, align 8 + %7 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %5, i32 0, i32 0 + store i64 %0, i64* %7, align 4 + %8 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %5, i32 0, i32 1 + store i32 %1, i32* %8, align 4 + %9 = bitcast %struct.array3* %4 to i8* + %10 = bitcast { i64, i32 }* %5 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %9, i8* align 4 %10, i64 12, i1 false) + %11 = bitcast %struct.array3* %3 to i8* + %12 = bitcast %struct.array3* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %11, i8* align 4 %12, i64 12, i1 false) + %13 = getelementptr inbounds %struct.array3, %struct.array3* %3, i32 0, i32 0 + %14 = bitcast { i64, i32 }* %6 to i8* + %15 = bitcast [3 x i32]* %13 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %14, i8* align 4 %15, i64 12, i1 false) + %16 = load { i64, i32 }, { i64, i32 }* %6, align 8 + ret { i64, i32 } %16 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i64, i64 } @demo4(i64 %0, i64 %1) #0 { + %3 = alloca %struct.array4, align 4 + %4 = alloca %struct.array4, align 4 + %5 = bitcast %struct.array4* %4 to { i64, i64 }* + %6 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %5, i32 0, i32 0 + store i64 %0, i64* %6, align 4 + %7 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %5, i32 0, i32 1 + store i64 %1, i64* %7, align 4 + %8 = bitcast %struct.array4* %3 to i8* + %9 = bitcast %struct.array4* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %8, i8* align 4 %9, i64 16, i1 false) + %10 = getelementptr inbounds %struct.array4, %struct.array4* %3, i32 0, i32 0 + %11 = bitcast [4 x i32]* %10 to { i64, i64 }* + %12 = load { i64, i64 }, { i64, i64 }* %11, align 4 + ret { i64, i64 } %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 4 %0, %struct.array5* noundef byval(%struct.array5) align 8 %1) #0 { + %3 = bitcast %struct.array5* %0 to i8* + %4 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 4 %0, %struct.array6* noundef byval(%struct.array6) align 8 %1) #0 { + %3 = bitcast %struct.array6* %0 to i8* + %4 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 4 %0, %struct.array7* noundef byval(%struct.array7) align 8 %1) #0 { + %3 = bitcast %struct.array7* %0 to i8* + %4 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 4 %0, %struct.array8* noundef byval(%struct.array8) align 8 %1) #0 { + %3 = bitcast %struct.array8* %0 to i8* + %4 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 4 %0, %struct.array9* noundef byval(%struct.array9) align 8 %1) #0 { + %3 = bitcast %struct.array9* %0 to i8* + %4 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 4 %0, %struct.array10* noundef byval(%struct.array10) align 8 %1) #0 { + %3 = bitcast %struct.array10* %0 to i8* + %4 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 4 %0, %struct.array11* noundef byval(%struct.array11) align 8 %1) #0 { + %3 = bitcast %struct.array11* %0 to i8* + %4 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 4 %0, %struct.array12* noundef byval(%struct.array12) align 8 %1) #0 { + %3 = bitcast %struct.array12* %0 to i8* + %4 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 4 %0, %struct.array13* noundef byval(%struct.array13) align 8 %1) #0 { + %3 = bitcast %struct.array13* %0 to i8* + %4 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 4 %0, %struct.array14* noundef byval(%struct.array14) align 8 %1) #0 { + %3 = bitcast %struct.array14* %0 to i8* + %4 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 4 %0, %struct.array15* noundef byval(%struct.array15) align 8 %1) #0 { + %3 = bitcast %struct.array15* %0 to i8* + %4 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 4 %0, %struct.array16* noundef byval(%struct.array16) align 8 %1) #0 { + %3 = bitcast %struct.array16* %0 to i8* + %4 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 4 %0, %struct.array17* noundef byval(%struct.array17) align 8 %1) #0 { + %3 = bitcast %struct.array17* %0 to i8* + %4 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 4 %0, %struct.array18* noundef byval(%struct.array18) align 8 %1) #0 { + %3 = bitcast %struct.array18* %0 to i8* + %4 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 4 %0, %struct.array19* noundef byval(%struct.array19) align 8 %1) #0 { + %3 = bitcast %struct.array19* %0 to i8* + %4 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 4 %0, %struct.array20* noundef byval(%struct.array20) align 8 %1) #0 { + %3 = bitcast %struct.array20* %0 to i8* + %4 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4} +!llvm.ident = !{!5} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{i32 7, !"frame-pointer", i32 2} +!5 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/amd64/array_int64.ll b/internal/cabi/_testdata/arch/amd64/array_int64.ll new file mode 100644 index 00000000..b9c55aa2 --- /dev/null +++ b/internal/cabi/_testdata/arch/amd64/array_int64.ll @@ -0,0 +1,219 @@ +; ModuleID = '../../wrap/array_int64.c' +source_filename = "../../wrap/array_int64.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "amd64-unknown-linux-gnu" + +%struct.array1 = type { [1 x i64] } +%struct.array2 = type { [2 x i64] } +%struct.array3 = type { [3 x i64] } +%struct.array4 = type { [4 x i64] } +%struct.array5 = type { [5 x i64] } +%struct.array6 = type { [6 x i64] } +%struct.array7 = type { [7 x i64] } +%struct.array8 = type { [8 x i64] } +%struct.array9 = type { [9 x i64] } +%struct.array10 = type { [10 x i64] } +%struct.array11 = type { [11 x i64] } +%struct.array12 = type { [12 x i64] } +%struct.array13 = type { [13 x i64] } +%struct.array14 = type { [14 x i64] } +%struct.array15 = type { [15 x i64] } +%struct.array16 = type { [16 x i64] } +%struct.array17 = type { [17 x i64] } +%struct.array18 = type { [18 x i64] } +%struct.array19 = type { [19 x i64] } +%struct.array20 = type { [20 x i64] } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i64 @demo1(i64 %0) #0 { + %2 = alloca %struct.array1, align 8 + %3 = alloca %struct.array1, align 8 + %4 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + %5 = bitcast [1 x i64]* %4 to i64* + store i64 %0, i64* %5, align 8 + %6 = bitcast %struct.array1* %2 to i8* + %7 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %6, i8* align 8 %7, i64 8, i1 false) + %8 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %9 = bitcast [1 x i64]* %8 to i64* + %10 = load i64, i64* %9, align 8 + ret i64 %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i64, i64 } @demo2(i64 %0, i64 %1) #0 { + %3 = alloca %struct.array2, align 8 + %4 = alloca %struct.array2, align 8 + %5 = bitcast %struct.array2* %4 to { i64, i64 }* + %6 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %5, i32 0, i32 0 + store i64 %0, i64* %6, align 8 + %7 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %5, i32 0, i32 1 + store i64 %1, i64* %7, align 8 + %8 = bitcast %struct.array2* %3 to i8* + %9 = bitcast %struct.array2* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %8, i8* align 8 %9, i64 16, i1 false) + %10 = getelementptr inbounds %struct.array2, %struct.array2* %3, i32 0, i32 0 + %11 = bitcast [2 x i64]* %10 to { i64, i64 }* + %12 = load { i64, i64 }, { i64, i64 }* %11, align 8 + ret { i64, i64 } %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo3(%struct.array3* noalias sret(%struct.array3) align 8 %0, %struct.array3* noundef byval(%struct.array3) align 8 %1) #0 { + %3 = bitcast %struct.array3* %0 to i8* + %4 = bitcast %struct.array3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo4(%struct.array4* noalias sret(%struct.array4) align 8 %0, %struct.array4* noundef byval(%struct.array4) align 8 %1) #0 { + %3 = bitcast %struct.array4* %0 to i8* + %4 = bitcast %struct.array4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 8 %0, %struct.array5* noundef byval(%struct.array5) align 8 %1) #0 { + %3 = bitcast %struct.array5* %0 to i8* + %4 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 8 %0, %struct.array6* noundef byval(%struct.array6) align 8 %1) #0 { + %3 = bitcast %struct.array6* %0 to i8* + %4 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 8 %0, %struct.array7* noundef byval(%struct.array7) align 8 %1) #0 { + %3 = bitcast %struct.array7* %0 to i8* + %4 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 8 %0, %struct.array8* noundef byval(%struct.array8) align 8 %1) #0 { + %3 = bitcast %struct.array8* %0 to i8* + %4 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 8 %0, %struct.array9* noundef byval(%struct.array9) align 8 %1) #0 { + %3 = bitcast %struct.array9* %0 to i8* + %4 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 8 %0, %struct.array10* noundef byval(%struct.array10) align 8 %1) #0 { + %3 = bitcast %struct.array10* %0 to i8* + %4 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 8 %0, %struct.array11* noundef byval(%struct.array11) align 8 %1) #0 { + %3 = bitcast %struct.array11* %0 to i8* + %4 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 8 %0, %struct.array12* noundef byval(%struct.array12) align 8 %1) #0 { + %3 = bitcast %struct.array12* %0 to i8* + %4 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 8 %0, %struct.array13* noundef byval(%struct.array13) align 8 %1) #0 { + %3 = bitcast %struct.array13* %0 to i8* + %4 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 8 %0, %struct.array14* noundef byval(%struct.array14) align 8 %1) #0 { + %3 = bitcast %struct.array14* %0 to i8* + %4 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 8 %0, %struct.array15* noundef byval(%struct.array15) align 8 %1) #0 { + %3 = bitcast %struct.array15* %0 to i8* + %4 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 8 %0, %struct.array16* noundef byval(%struct.array16) align 8 %1) #0 { + %3 = bitcast %struct.array16* %0 to i8* + %4 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 8 %0, %struct.array17* noundef byval(%struct.array17) align 8 %1) #0 { + %3 = bitcast %struct.array17* %0 to i8* + %4 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 8 %0, %struct.array18* noundef byval(%struct.array18) align 8 %1) #0 { + %3 = bitcast %struct.array18* %0 to i8* + %4 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 8 %0, %struct.array19* noundef byval(%struct.array19) align 8 %1) #0 { + %3 = bitcast %struct.array19* %0 to i8* + %4 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 8 %0, %struct.array20* noundef byval(%struct.array20) align 8 %1) #0 { + %3 = bitcast %struct.array20* %0 to i8* + %4 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4} +!llvm.ident = !{!5} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{i32 7, !"frame-pointer", i32 2} +!5 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/amd64/array_int8.ll b/internal/cabi/_testdata/arch/amd64/array_int8.ll new file mode 100644 index 00000000..85b85e64 --- /dev/null +++ b/internal/cabi/_testdata/arch/amd64/array_int8.ll @@ -0,0 +1,411 @@ +; ModuleID = '../../wrap/array_int8.c' +source_filename = "../../wrap/array_int8.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "amd64-unknown-linux-gnu" + +%struct.array1 = type { [1 x i8] } +%struct.array2 = type { [2 x i8] } +%struct.array3 = type { [3 x i8] } +%struct.array4 = type { [4 x i8] } +%struct.array5 = type { [5 x i8] } +%struct.array6 = type { [6 x i8] } +%struct.array7 = type { [7 x i8] } +%struct.array8 = type { [8 x i8] } +%struct.array9 = type { [9 x i8] } +%struct.array10 = type { [10 x i8] } +%struct.array11 = type { [11 x i8] } +%struct.array12 = type { [12 x i8] } +%struct.array13 = type { [13 x i8] } +%struct.array14 = type { [14 x i8] } +%struct.array15 = type { [15 x i8] } +%struct.array16 = type { [16 x i8] } +%struct.array17 = type { [17 x i8] } +%struct.array18 = type { [18 x i8] } +%struct.array19 = type { [19 x i8] } +%struct.array20 = type { [20 x i8] } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i8 @demo1(i8 %0) #0 { + %2 = alloca %struct.array1, align 1 + %3 = alloca %struct.array1, align 1 + %4 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + %5 = bitcast [1 x i8]* %4 to i8* + store i8 %0, i8* %5, align 1 + %6 = bitcast %struct.array1* %2 to i8* + %7 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 1 %7, i64 1, i1 false) + %8 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %9 = bitcast [1 x i8]* %8 to i8* + %10 = load i8, i8* %9, align 1 + ret i8 %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i16 @demo2(i16 %0) #0 { + %2 = alloca %struct.array2, align 1 + %3 = alloca %struct.array2, align 1 + %4 = getelementptr inbounds %struct.array2, %struct.array2* %3, i32 0, i32 0 + %5 = bitcast [2 x i8]* %4 to i16* + store i16 %0, i16* %5, align 1 + %6 = bitcast %struct.array2* %2 to i8* + %7 = bitcast %struct.array2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 1 %7, i64 2, i1 false) + %8 = getelementptr inbounds %struct.array2, %struct.array2* %2, i32 0, i32 0 + %9 = bitcast [2 x i8]* %8 to i16* + %10 = load i16, i16* %9, align 1 + ret i16 %10 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i24 @demo3(i24 %0) #0 { + %2 = alloca %struct.array3, align 1 + %3 = alloca %struct.array3, align 1 + %4 = alloca i24, align 4 + %5 = alloca i24, align 4 + %6 = getelementptr inbounds %struct.array3, %struct.array3* %3, i32 0, i32 0 + store i24 %0, i24* %4, align 4 + %7 = bitcast [3 x i8]* %6 to i8* + %8 = bitcast i24* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 4 %8, i64 3, i1 false) + %9 = bitcast %struct.array3* %2 to i8* + %10 = bitcast %struct.array3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 3, i1 false) + %11 = getelementptr inbounds %struct.array3, %struct.array3* %2, i32 0, i32 0 + %12 = bitcast i24* %5 to i8* + %13 = bitcast [3 x i8]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %12, i8* align 1 %13, i64 3, i1 false) + %14 = load i24, i24* %5, align 4 + ret i24 %14 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i32 @demo4(i32 %0) #0 { + %2 = alloca %struct.array4, align 1 + %3 = alloca %struct.array4, align 1 + %4 = getelementptr inbounds %struct.array4, %struct.array4* %3, i32 0, i32 0 + %5 = bitcast [4 x i8]* %4 to i32* + store i32 %0, i32* %5, align 1 + %6 = bitcast %struct.array4* %2 to i8* + %7 = bitcast %struct.array4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 1 %7, i64 4, i1 false) + %8 = getelementptr inbounds %struct.array4, %struct.array4* %2, i32 0, i32 0 + %9 = bitcast [4 x i8]* %8 to i32* + %10 = load i32, i32* %9, align 1 + ret i32 %10 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i40 @demo5(i40 %0) #0 { + %2 = alloca %struct.array5, align 1 + %3 = alloca %struct.array5, align 1 + %4 = alloca i40, align 8 + %5 = alloca i40, align 8 + %6 = getelementptr inbounds %struct.array5, %struct.array5* %3, i32 0, i32 0 + store i40 %0, i40* %4, align 8 + %7 = bitcast [5 x i8]* %6 to i8* + %8 = bitcast i40* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 8 %8, i64 5, i1 false) + %9 = bitcast %struct.array5* %2 to i8* + %10 = bitcast %struct.array5* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 5, i1 false) + %11 = getelementptr inbounds %struct.array5, %struct.array5* %2, i32 0, i32 0 + %12 = bitcast i40* %5 to i8* + %13 = bitcast [5 x i8]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 1 %13, i64 5, i1 false) + %14 = load i40, i40* %5, align 8 + ret i40 %14 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i48 @demo6(i48 %0) #0 { + %2 = alloca %struct.array6, align 1 + %3 = alloca %struct.array6, align 1 + %4 = alloca i48, align 8 + %5 = alloca i48, align 8 + %6 = getelementptr inbounds %struct.array6, %struct.array6* %3, i32 0, i32 0 + store i48 %0, i48* %4, align 8 + %7 = bitcast [6 x i8]* %6 to i8* + %8 = bitcast i48* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 8 %8, i64 6, i1 false) + %9 = bitcast %struct.array6* %2 to i8* + %10 = bitcast %struct.array6* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 6, i1 false) + %11 = getelementptr inbounds %struct.array6, %struct.array6* %2, i32 0, i32 0 + %12 = bitcast i48* %5 to i8* + %13 = bitcast [6 x i8]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 1 %13, i64 6, i1 false) + %14 = load i48, i48* %5, align 8 + ret i48 %14 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i56 @demo7(i56 %0) #0 { + %2 = alloca %struct.array7, align 1 + %3 = alloca %struct.array7, align 1 + %4 = alloca i56, align 8 + %5 = alloca i56, align 8 + %6 = getelementptr inbounds %struct.array7, %struct.array7* %3, i32 0, i32 0 + store i56 %0, i56* %4, align 8 + %7 = bitcast [7 x i8]* %6 to i8* + %8 = bitcast i56* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 8 %8, i64 7, i1 false) + %9 = bitcast %struct.array7* %2 to i8* + %10 = bitcast %struct.array7* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 7, i1 false) + %11 = getelementptr inbounds %struct.array7, %struct.array7* %2, i32 0, i32 0 + %12 = bitcast i56* %5 to i8* + %13 = bitcast [7 x i8]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 1 %13, i64 7, i1 false) + %14 = load i56, i56* %5, align 8 + ret i56 %14 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i64 @demo8(i64 %0) #0 { + %2 = alloca %struct.array8, align 1 + %3 = alloca %struct.array8, align 1 + %4 = getelementptr inbounds %struct.array8, %struct.array8* %3, i32 0, i32 0 + %5 = bitcast [8 x i8]* %4 to i64* + store i64 %0, i64* %5, align 1 + %6 = bitcast %struct.array8* %2 to i8* + %7 = bitcast %struct.array8* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 1 %7, i64 8, i1 false) + %8 = getelementptr inbounds %struct.array8, %struct.array8* %2, i32 0, i32 0 + %9 = bitcast [8 x i8]* %8 to i64* + %10 = load i64, i64* %9, align 1 + ret i64 %10 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i64, i8 } @demo9(i64 %0, i8 %1) #0 { + %3 = alloca %struct.array9, align 1 + %4 = alloca %struct.array9, align 1 + %5 = alloca { i64, i8 }, align 1 + %6 = alloca { i64, i8 }, align 8 + %7 = getelementptr inbounds { i64, i8 }, { i64, i8 }* %5, i32 0, i32 0 + store i64 %0, i64* %7, align 1 + %8 = getelementptr inbounds { i64, i8 }, { i64, i8 }* %5, i32 0, i32 1 + store i8 %1, i8* %8, align 1 + %9 = bitcast %struct.array9* %4 to i8* + %10 = bitcast { i64, i8 }* %5 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 9, i1 false) + %11 = bitcast %struct.array9* %3 to i8* + %12 = bitcast %struct.array9* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %11, i8* align 1 %12, i64 9, i1 false) + %13 = getelementptr inbounds %struct.array9, %struct.array9* %3, i32 0, i32 0 + %14 = bitcast { i64, i8 }* %6 to i8* + %15 = bitcast [9 x i8]* %13 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %14, i8* align 1 %15, i64 9, i1 false) + %16 = load { i64, i8 }, { i64, i8 }* %6, align 8 + ret { i64, i8 } %16 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i64, i16 } @demo10(i64 %0, i16 %1) #0 { + %3 = alloca %struct.array10, align 1 + %4 = alloca %struct.array10, align 1 + %5 = alloca { i64, i16 }, align 1 + %6 = alloca { i64, i16 }, align 8 + %7 = getelementptr inbounds { i64, i16 }, { i64, i16 }* %5, i32 0, i32 0 + store i64 %0, i64* %7, align 1 + %8 = getelementptr inbounds { i64, i16 }, { i64, i16 }* %5, i32 0, i32 1 + store i16 %1, i16* %8, align 1 + %9 = bitcast %struct.array10* %4 to i8* + %10 = bitcast { i64, i16 }* %5 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 10, i1 false) + %11 = bitcast %struct.array10* %3 to i8* + %12 = bitcast %struct.array10* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %11, i8* align 1 %12, i64 10, i1 false) + %13 = getelementptr inbounds %struct.array10, %struct.array10* %3, i32 0, i32 0 + %14 = bitcast { i64, i16 }* %6 to i8* + %15 = bitcast [10 x i8]* %13 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %14, i8* align 1 %15, i64 10, i1 false) + %16 = load { i64, i16 }, { i64, i16 }* %6, align 8 + ret { i64, i16 } %16 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i64, i24 } @demo11(i64 %0, i24 %1) #0 { + %3 = alloca %struct.array11, align 1 + %4 = alloca %struct.array11, align 1 + %5 = alloca { i64, i24 }, align 1 + %6 = alloca { i64, i24 }, align 8 + %7 = getelementptr inbounds { i64, i24 }, { i64, i24 }* %5, i32 0, i32 0 + store i64 %0, i64* %7, align 1 + %8 = getelementptr inbounds { i64, i24 }, { i64, i24 }* %5, i32 0, i32 1 + store i24 %1, i24* %8, align 1 + %9 = bitcast %struct.array11* %4 to i8* + %10 = bitcast { i64, i24 }* %5 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 11, i1 false) + %11 = bitcast %struct.array11* %3 to i8* + %12 = bitcast %struct.array11* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %11, i8* align 1 %12, i64 11, i1 false) + %13 = getelementptr inbounds %struct.array11, %struct.array11* %3, i32 0, i32 0 + %14 = bitcast { i64, i24 }* %6 to i8* + %15 = bitcast [11 x i8]* %13 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %14, i8* align 1 %15, i64 11, i1 false) + %16 = load { i64, i24 }, { i64, i24 }* %6, align 8 + ret { i64, i24 } %16 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i64, i32 } @demo12(i64 %0, i32 %1) #0 { + %3 = alloca %struct.array12, align 1 + %4 = alloca %struct.array12, align 1 + %5 = alloca { i64, i32 }, align 1 + %6 = alloca { i64, i32 }, align 8 + %7 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %5, i32 0, i32 0 + store i64 %0, i64* %7, align 1 + %8 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %5, i32 0, i32 1 + store i32 %1, i32* %8, align 1 + %9 = bitcast %struct.array12* %4 to i8* + %10 = bitcast { i64, i32 }* %5 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 12, i1 false) + %11 = bitcast %struct.array12* %3 to i8* + %12 = bitcast %struct.array12* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %11, i8* align 1 %12, i64 12, i1 false) + %13 = getelementptr inbounds %struct.array12, %struct.array12* %3, i32 0, i32 0 + %14 = bitcast { i64, i32 }* %6 to i8* + %15 = bitcast [12 x i8]* %13 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %14, i8* align 1 %15, i64 12, i1 false) + %16 = load { i64, i32 }, { i64, i32 }* %6, align 8 + ret { i64, i32 } %16 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i64, i40 } @demo13(i64 %0, i40 %1) #0 { + %3 = alloca %struct.array13, align 1 + %4 = alloca %struct.array13, align 1 + %5 = alloca { i64, i40 }, align 1 + %6 = alloca { i64, i40 }, align 8 + %7 = getelementptr inbounds { i64, i40 }, { i64, i40 }* %5, i32 0, i32 0 + store i64 %0, i64* %7, align 1 + %8 = getelementptr inbounds { i64, i40 }, { i64, i40 }* %5, i32 0, i32 1 + store i40 %1, i40* %8, align 1 + %9 = bitcast %struct.array13* %4 to i8* + %10 = bitcast { i64, i40 }* %5 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 13, i1 false) + %11 = bitcast %struct.array13* %3 to i8* + %12 = bitcast %struct.array13* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %11, i8* align 1 %12, i64 13, i1 false) + %13 = getelementptr inbounds %struct.array13, %struct.array13* %3, i32 0, i32 0 + %14 = bitcast { i64, i40 }* %6 to i8* + %15 = bitcast [13 x i8]* %13 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %14, i8* align 1 %15, i64 13, i1 false) + %16 = load { i64, i40 }, { i64, i40 }* %6, align 8 + ret { i64, i40 } %16 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i64, i48 } @demo14(i64 %0, i48 %1) #0 { + %3 = alloca %struct.array14, align 1 + %4 = alloca %struct.array14, align 1 + %5 = alloca { i64, i48 }, align 1 + %6 = alloca { i64, i48 }, align 8 + %7 = getelementptr inbounds { i64, i48 }, { i64, i48 }* %5, i32 0, i32 0 + store i64 %0, i64* %7, align 1 + %8 = getelementptr inbounds { i64, i48 }, { i64, i48 }* %5, i32 0, i32 1 + store i48 %1, i48* %8, align 1 + %9 = bitcast %struct.array14* %4 to i8* + %10 = bitcast { i64, i48 }* %5 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 14, i1 false) + %11 = bitcast %struct.array14* %3 to i8* + %12 = bitcast %struct.array14* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %11, i8* align 1 %12, i64 14, i1 false) + %13 = getelementptr inbounds %struct.array14, %struct.array14* %3, i32 0, i32 0 + %14 = bitcast { i64, i48 }* %6 to i8* + %15 = bitcast [14 x i8]* %13 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %14, i8* align 1 %15, i64 14, i1 false) + %16 = load { i64, i48 }, { i64, i48 }* %6, align 8 + ret { i64, i48 } %16 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i64, i56 } @demo15(i64 %0, i56 %1) #0 { + %3 = alloca %struct.array15, align 1 + %4 = alloca %struct.array15, align 1 + %5 = alloca { i64, i56 }, align 1 + %6 = alloca { i64, i56 }, align 8 + %7 = getelementptr inbounds { i64, i56 }, { i64, i56 }* %5, i32 0, i32 0 + store i64 %0, i64* %7, align 1 + %8 = getelementptr inbounds { i64, i56 }, { i64, i56 }* %5, i32 0, i32 1 + store i56 %1, i56* %8, align 1 + %9 = bitcast %struct.array15* %4 to i8* + %10 = bitcast { i64, i56 }* %5 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 15, i1 false) + %11 = bitcast %struct.array15* %3 to i8* + %12 = bitcast %struct.array15* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %11, i8* align 1 %12, i64 15, i1 false) + %13 = getelementptr inbounds %struct.array15, %struct.array15* %3, i32 0, i32 0 + %14 = bitcast { i64, i56 }* %6 to i8* + %15 = bitcast [15 x i8]* %13 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %14, i8* align 1 %15, i64 15, i1 false) + %16 = load { i64, i56 }, { i64, i56 }* %6, align 8 + ret { i64, i56 } %16 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i64, i64 } @demo16(i64 %0, i64 %1) #0 { + %3 = alloca %struct.array16, align 1 + %4 = alloca %struct.array16, align 1 + %5 = bitcast %struct.array16* %4 to { i64, i64 }* + %6 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %5, i32 0, i32 0 + store i64 %0, i64* %6, align 1 + %7 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %5, i32 0, i32 1 + store i64 %1, i64* %7, align 1 + %8 = bitcast %struct.array16* %3 to i8* + %9 = bitcast %struct.array16* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 16, i1 false) + %10 = getelementptr inbounds %struct.array16, %struct.array16* %3, i32 0, i32 0 + %11 = bitcast [16 x i8]* %10 to { i64, i64 }* + %12 = load { i64, i64 }, { i64, i64 }* %11, align 1 + ret { i64, i64 } %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 1 %0, %struct.array17* noundef byval(%struct.array17) align 8 %1) #0 { + %3 = bitcast %struct.array17* %0 to i8* + %4 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %3, i8* align 8 %4, i64 17, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 1 %0, %struct.array18* noundef byval(%struct.array18) align 8 %1) #0 { + %3 = bitcast %struct.array18* %0 to i8* + %4 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %3, i8* align 8 %4, i64 18, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 1 %0, %struct.array19* noundef byval(%struct.array19) align 8 %1) #0 { + %3 = bitcast %struct.array19* %0 to i8* + %4 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %3, i8* align 8 %4, i64 19, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 1 %0, %struct.array20* noundef byval(%struct.array20) align 8 %1) #0 { + %3 = bitcast %struct.array20* %0 to i8* + %4 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %3, i8* align 8 %4, i64 20, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4} +!llvm.ident = !{!5} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{i32 7, !"frame-pointer", i32 2} +!5 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/amd64/array_pointer.ll b/internal/cabi/_testdata/arch/amd64/array_pointer.ll new file mode 100644 index 00000000..6be43ba6 --- /dev/null +++ b/internal/cabi/_testdata/arch/amd64/array_pointer.ll @@ -0,0 +1,219 @@ +; ModuleID = '../../wrap/array_pointer.c' +source_filename = "../../wrap/array_pointer.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "amd64-unknown-linux-gnu" + +%struct.array1 = type { [1 x i8*] } +%struct.array2 = type { [2 x i8*] } +%struct.array3 = type { [3 x i8*] } +%struct.array4 = type { [4 x i8*] } +%struct.array5 = type { [5 x i8*] } +%struct.array6 = type { [6 x i8*] } +%struct.array7 = type { [7 x i8*] } +%struct.array8 = type { [8 x i8*] } +%struct.array9 = type { [9 x i8*] } +%struct.array10 = type { [10 x i8*] } +%struct.array11 = type { [11 x i8*] } +%struct.array12 = type { [12 x i8*] } +%struct.array13 = type { [13 x i8*] } +%struct.array14 = type { [14 x i8*] } +%struct.array15 = type { [15 x i8*] } +%struct.array16 = type { [16 x i8*] } +%struct.array17 = type { [17 x i8*] } +%struct.array18 = type { [18 x i8*] } +%struct.array19 = type { [19 x i8*] } +%struct.array20 = type { [20 x i8*] } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i8* @demo1(i8* %0) #0 { + %2 = alloca %struct.array1, align 8 + %3 = alloca %struct.array1, align 8 + %4 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + %5 = bitcast [1 x i8*]* %4 to i8** + store i8* %0, i8** %5, align 8 + %6 = bitcast %struct.array1* %2 to i8* + %7 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %6, i8* align 8 %7, i64 8, i1 false) + %8 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %9 = bitcast [1 x i8*]* %8 to i8** + %10 = load i8*, i8** %9, align 8 + ret i8* %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i8*, i8* } @demo2(i8* %0, i8* %1) #0 { + %3 = alloca %struct.array2, align 8 + %4 = alloca %struct.array2, align 8 + %5 = bitcast %struct.array2* %4 to { i8*, i8* }* + %6 = getelementptr inbounds { i8*, i8* }, { i8*, i8* }* %5, i32 0, i32 0 + store i8* %0, i8** %6, align 8 + %7 = getelementptr inbounds { i8*, i8* }, { i8*, i8* }* %5, i32 0, i32 1 + store i8* %1, i8** %7, align 8 + %8 = bitcast %struct.array2* %3 to i8* + %9 = bitcast %struct.array2* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %8, i8* align 8 %9, i64 16, i1 false) + %10 = getelementptr inbounds %struct.array2, %struct.array2* %3, i32 0, i32 0 + %11 = bitcast [2 x i8*]* %10 to { i8*, i8* }* + %12 = load { i8*, i8* }, { i8*, i8* }* %11, align 8 + ret { i8*, i8* } %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo3(%struct.array3* noalias sret(%struct.array3) align 8 %0, %struct.array3* noundef byval(%struct.array3) align 8 %1) #0 { + %3 = bitcast %struct.array3* %0 to i8* + %4 = bitcast %struct.array3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo4(%struct.array4* noalias sret(%struct.array4) align 8 %0, %struct.array4* noundef byval(%struct.array4) align 8 %1) #0 { + %3 = bitcast %struct.array4* %0 to i8* + %4 = bitcast %struct.array4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 8 %0, %struct.array5* noundef byval(%struct.array5) align 8 %1) #0 { + %3 = bitcast %struct.array5* %0 to i8* + %4 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 8 %0, %struct.array6* noundef byval(%struct.array6) align 8 %1) #0 { + %3 = bitcast %struct.array6* %0 to i8* + %4 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 8 %0, %struct.array7* noundef byval(%struct.array7) align 8 %1) #0 { + %3 = bitcast %struct.array7* %0 to i8* + %4 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 8 %0, %struct.array8* noundef byval(%struct.array8) align 8 %1) #0 { + %3 = bitcast %struct.array8* %0 to i8* + %4 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 8 %0, %struct.array9* noundef byval(%struct.array9) align 8 %1) #0 { + %3 = bitcast %struct.array9* %0 to i8* + %4 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 8 %0, %struct.array10* noundef byval(%struct.array10) align 8 %1) #0 { + %3 = bitcast %struct.array10* %0 to i8* + %4 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 8 %0, %struct.array11* noundef byval(%struct.array11) align 8 %1) #0 { + %3 = bitcast %struct.array11* %0 to i8* + %4 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 8 %0, %struct.array12* noundef byval(%struct.array12) align 8 %1) #0 { + %3 = bitcast %struct.array12* %0 to i8* + %4 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 8 %0, %struct.array13* noundef byval(%struct.array13) align 8 %1) #0 { + %3 = bitcast %struct.array13* %0 to i8* + %4 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 8 %0, %struct.array14* noundef byval(%struct.array14) align 8 %1) #0 { + %3 = bitcast %struct.array14* %0 to i8* + %4 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 8 %0, %struct.array15* noundef byval(%struct.array15) align 8 %1) #0 { + %3 = bitcast %struct.array15* %0 to i8* + %4 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 8 %0, %struct.array16* noundef byval(%struct.array16) align 8 %1) #0 { + %3 = bitcast %struct.array16* %0 to i8* + %4 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 8 %0, %struct.array17* noundef byval(%struct.array17) align 8 %1) #0 { + %3 = bitcast %struct.array17* %0 to i8* + %4 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 8 %0, %struct.array18* noundef byval(%struct.array18) align 8 %1) #0 { + %3 = bitcast %struct.array18* %0 to i8* + %4 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 8 %0, %struct.array19* noundef byval(%struct.array19) align 8 %1) #0 { + %3 = bitcast %struct.array19* %0 to i8* + %4 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 8 %0, %struct.array20* noundef byval(%struct.array20) align 8 %1) #0 { + %3 = bitcast %struct.array20* %0 to i8* + %4 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4} +!llvm.ident = !{!5} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{i32 7, !"frame-pointer", i32 2} +!5 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/amd64/array_uintptr.ll b/internal/cabi/_testdata/arch/amd64/array_uintptr.ll new file mode 100644 index 00000000..506349c2 --- /dev/null +++ b/internal/cabi/_testdata/arch/amd64/array_uintptr.ll @@ -0,0 +1,219 @@ +; ModuleID = '../../wrap/array_uintptr.c' +source_filename = "../../wrap/array_uintptr.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "amd64-unknown-linux-gnu" + +%struct.array1 = type { [1 x i8*] } +%struct.array2 = type { [2 x i8*] } +%struct.array3 = type { [3 x i8*] } +%struct.array4 = type { [4 x i8*] } +%struct.array5 = type { [5 x i8*] } +%struct.array6 = type { [6 x i8*] } +%struct.array7 = type { [7 x i8*] } +%struct.array8 = type { [8 x i8*] } +%struct.array9 = type { [9 x i8*] } +%struct.array10 = type { [10 x i8*] } +%struct.array11 = type { [11 x i8*] } +%struct.array12 = type { [12 x i8*] } +%struct.array13 = type { [13 x i8*] } +%struct.array14 = type { [14 x i8*] } +%struct.array15 = type { [15 x i8*] } +%struct.array16 = type { [16 x i8*] } +%struct.array17 = type { [17 x i8*] } +%struct.array18 = type { [18 x i8*] } +%struct.array19 = type { [19 x i8*] } +%struct.array20 = type { [20 x i8*] } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i8* @demo1(i8* %0) #0 { + %2 = alloca %struct.array1, align 8 + %3 = alloca %struct.array1, align 8 + %4 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + %5 = bitcast [1 x i8*]* %4 to i8** + store i8* %0, i8** %5, align 8 + %6 = bitcast %struct.array1* %2 to i8* + %7 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %6, i8* align 8 %7, i64 8, i1 false) + %8 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %9 = bitcast [1 x i8*]* %8 to i8** + %10 = load i8*, i8** %9, align 8 + ret i8* %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i8*, i8* } @demo2(i8* %0, i8* %1) #0 { + %3 = alloca %struct.array2, align 8 + %4 = alloca %struct.array2, align 8 + %5 = bitcast %struct.array2* %4 to { i8*, i8* }* + %6 = getelementptr inbounds { i8*, i8* }, { i8*, i8* }* %5, i32 0, i32 0 + store i8* %0, i8** %6, align 8 + %7 = getelementptr inbounds { i8*, i8* }, { i8*, i8* }* %5, i32 0, i32 1 + store i8* %1, i8** %7, align 8 + %8 = bitcast %struct.array2* %3 to i8* + %9 = bitcast %struct.array2* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %8, i8* align 8 %9, i64 16, i1 false) + %10 = getelementptr inbounds %struct.array2, %struct.array2* %3, i32 0, i32 0 + %11 = bitcast [2 x i8*]* %10 to { i8*, i8* }* + %12 = load { i8*, i8* }, { i8*, i8* }* %11, align 8 + ret { i8*, i8* } %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo3(%struct.array3* noalias sret(%struct.array3) align 8 %0, %struct.array3* noundef byval(%struct.array3) align 8 %1) #0 { + %3 = bitcast %struct.array3* %0 to i8* + %4 = bitcast %struct.array3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo4(%struct.array4* noalias sret(%struct.array4) align 8 %0, %struct.array4* noundef byval(%struct.array4) align 8 %1) #0 { + %3 = bitcast %struct.array4* %0 to i8* + %4 = bitcast %struct.array4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 8 %0, %struct.array5* noundef byval(%struct.array5) align 8 %1) #0 { + %3 = bitcast %struct.array5* %0 to i8* + %4 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 8 %0, %struct.array6* noundef byval(%struct.array6) align 8 %1) #0 { + %3 = bitcast %struct.array6* %0 to i8* + %4 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 8 %0, %struct.array7* noundef byval(%struct.array7) align 8 %1) #0 { + %3 = bitcast %struct.array7* %0 to i8* + %4 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 8 %0, %struct.array8* noundef byval(%struct.array8) align 8 %1) #0 { + %3 = bitcast %struct.array8* %0 to i8* + %4 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 8 %0, %struct.array9* noundef byval(%struct.array9) align 8 %1) #0 { + %3 = bitcast %struct.array9* %0 to i8* + %4 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 8 %0, %struct.array10* noundef byval(%struct.array10) align 8 %1) #0 { + %3 = bitcast %struct.array10* %0 to i8* + %4 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 8 %0, %struct.array11* noundef byval(%struct.array11) align 8 %1) #0 { + %3 = bitcast %struct.array11* %0 to i8* + %4 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 8 %0, %struct.array12* noundef byval(%struct.array12) align 8 %1) #0 { + %3 = bitcast %struct.array12* %0 to i8* + %4 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 8 %0, %struct.array13* noundef byval(%struct.array13) align 8 %1) #0 { + %3 = bitcast %struct.array13* %0 to i8* + %4 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 8 %0, %struct.array14* noundef byval(%struct.array14) align 8 %1) #0 { + %3 = bitcast %struct.array14* %0 to i8* + %4 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 8 %0, %struct.array15* noundef byval(%struct.array15) align 8 %1) #0 { + %3 = bitcast %struct.array15* %0 to i8* + %4 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 8 %0, %struct.array16* noundef byval(%struct.array16) align 8 %1) #0 { + %3 = bitcast %struct.array16* %0 to i8* + %4 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 8 %0, %struct.array17* noundef byval(%struct.array17) align 8 %1) #0 { + %3 = bitcast %struct.array17* %0 to i8* + %4 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 8 %0, %struct.array18* noundef byval(%struct.array18) align 8 %1) #0 { + %3 = bitcast %struct.array18* %0 to i8* + %4 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 8 %0, %struct.array19* noundef byval(%struct.array19) align 8 %1) #0 { + %3 = bitcast %struct.array19* %0 to i8* + %4 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 8 %0, %struct.array20* noundef byval(%struct.array20) align 8 %1) #0 { + %3 = bitcast %struct.array20* %0 to i8* + %4 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4} +!llvm.ident = !{!5} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{i32 7, !"frame-pointer", i32 2} +!5 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/amd64/basic.ll b/internal/cabi/_testdata/arch/amd64/basic.ll new file mode 100644 index 00000000..4d42e66f --- /dev/null +++ b/internal/cabi/_testdata/arch/amd64/basic.ll @@ -0,0 +1,72 @@ +; ModuleID = '../../wrap/basic.c' +source_filename = "../../wrap/basic.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "amd64-unknown-linux-gnu" + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local signext i8 @basic_int8(i8 noundef signext %0) #0 { + %2 = alloca i8, align 1 + store i8 %0, i8* %2, align 1 + %3 = load i8, i8* %2, align 1 + ret i8 %3 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local signext i16 @basic_int16(i16 noundef signext %0) #0 { + %2 = alloca i16, align 2 + store i16 %0, i16* %2, align 2 + %3 = load i16, i16* %2, align 2 + ret i16 %3 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i32 @basic_int32(i32 noundef %0) #0 { + %2 = alloca i32, align 4 + store i32 %0, i32* %2, align 4 + %3 = load i32, i32* %2, align 4 + ret i32 %3 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i64 @basic_int64(i64 noundef %0) #0 { + %2 = alloca i64, align 8 + store i64 %0, i64* %2, align 8 + %3 = load i64, i64* %2, align 8 + ret i64 %3 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local float @basic_float32(float noundef %0) #0 { + %2 = alloca float, align 4 + store float %0, float* %2, align 4 + %3 = load float, float* %2, align 4 + ret float %3 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local double @basic_float64(double noundef %0) #0 { + %2 = alloca double, align 8 + store double %0, double* %2, align 8 + %3 = load double, double* %2, align 8 + ret double %3 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i8* @basic_uintptr(i8* noundef %0) #0 { + %2 = alloca i8*, align 8 + store i8* %0, i8** %2, align 8 + %3 = load i8*, i8** %2, align 8 + ret i8* %3 +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } + +!llvm.module.flags = !{!0, !1, !2, !3, !4} +!llvm.ident = !{!5} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{i32 7, !"frame-pointer", i32 2} +!5 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/amd64/struct_float32.ll b/internal/cabi/_testdata/arch/amd64/struct_float32.ll new file mode 100644 index 00000000..0fc0e8ed --- /dev/null +++ b/internal/cabi/_testdata/arch/amd64/struct_float32.ll @@ -0,0 +1,238 @@ +; ModuleID = '../../wrap/struct_float32.c' +source_filename = "../../wrap/struct_float32.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "amd64-unknown-linux-gnu" + +%struct.point1 = type { float } +%struct.point2 = type { float, float } +%struct.point3 = type { float, float, float } +%struct.point4 = type { float, float, float, float } +%struct.point5 = type { float, float, float, float, float } +%struct.point6 = type { float, float, float, float, float, float } +%struct.point7 = type { float, float, float, float, float, float, float } +%struct.point8 = type { float, float, float, float, float, float, float, float } +%struct.point9 = type { float, float, float, float, float, float, float, float, float } +%struct.point10 = type { float, float, float, float, float, float, float, float, float, float } +%struct.point11 = type { float, float, float, float, float, float, float, float, float, float, float } +%struct.point12 = type { float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point13 = type { float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point14 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point15 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point16 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point17 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point18 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point19 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point20 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local float @demo1(float %0) #0 { + %2 = alloca %struct.point1, align 4 + %3 = alloca %struct.point1, align 4 + %4 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + store float %0, float* %4, align 4 + %5 = bitcast %struct.point1* %2 to i8* + %6 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 4, i1 false) + %7 = getelementptr inbounds %struct.point1, %struct.point1* %2, i32 0, i32 0 + %8 = load float, float* %7, align 4 + ret float %8 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local <2 x float> @demo2(<2 x float> %0) #2 { + %2 = alloca %struct.point2, align 4 + %3 = alloca %struct.point2, align 4 + %4 = bitcast %struct.point2* %3 to <2 x float>* + store <2 x float> %0, <2 x float>* %4, align 4 + %5 = bitcast %struct.point2* %2 to i8* + %6 = bitcast %struct.point2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 8, i1 false) + %7 = bitcast %struct.point2* %2 to <2 x float>* + %8 = load <2 x float>, <2 x float>* %7, align 4 + ret <2 x float> %8 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { <2 x float>, float } @demo3(<2 x float> %0, float %1) #2 { + %3 = alloca %struct.point3, align 4 + %4 = alloca %struct.point3, align 4 + %5 = alloca { <2 x float>, float }, align 4 + %6 = alloca { <2 x float>, float }, align 8 + %7 = getelementptr inbounds { <2 x float>, float }, { <2 x float>, float }* %5, i32 0, i32 0 + store <2 x float> %0, <2 x float>* %7, align 4 + %8 = getelementptr inbounds { <2 x float>, float }, { <2 x float>, float }* %5, i32 0, i32 1 + store float %1, float* %8, align 4 + %9 = bitcast %struct.point3* %4 to i8* + %10 = bitcast { <2 x float>, float }* %5 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %9, i8* align 4 %10, i64 12, i1 false) + %11 = bitcast %struct.point3* %3 to i8* + %12 = bitcast %struct.point3* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %11, i8* align 4 %12, i64 12, i1 false) + %13 = bitcast { <2 x float>, float }* %6 to i8* + %14 = bitcast %struct.point3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %13, i8* align 4 %14, i64 12, i1 false) + %15 = load { <2 x float>, float }, { <2 x float>, float }* %6, align 8 + ret { <2 x float>, float } %15 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { <2 x float>, <2 x float> } @demo4(<2 x float> %0, <2 x float> %1) #2 { + %3 = alloca %struct.point4, align 4 + %4 = alloca %struct.point4, align 4 + %5 = bitcast %struct.point4* %4 to { <2 x float>, <2 x float> }* + %6 = getelementptr inbounds { <2 x float>, <2 x float> }, { <2 x float>, <2 x float> }* %5, i32 0, i32 0 + store <2 x float> %0, <2 x float>* %6, align 4 + %7 = getelementptr inbounds { <2 x float>, <2 x float> }, { <2 x float>, <2 x float> }* %5, i32 0, i32 1 + store <2 x float> %1, <2 x float>* %7, align 4 + %8 = bitcast %struct.point4* %3 to i8* + %9 = bitcast %struct.point4* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %8, i8* align 4 %9, i64 16, i1 false) + %10 = bitcast %struct.point4* %3 to { <2 x float>, <2 x float> }* + %11 = load { <2 x float>, <2 x float> }, { <2 x float>, <2 x float> }* %10, align 4 + ret { <2 x float>, <2 x float> } %11 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.point5* noalias sret(%struct.point5) align 4 %0, %struct.point5* noundef byval(%struct.point5) align 8 %1) #0 { + %3 = bitcast %struct.point5* %0 to i8* + %4 = bitcast %struct.point5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.point6* noalias sret(%struct.point6) align 4 %0, %struct.point6* noundef byval(%struct.point6) align 8 %1) #0 { + %3 = bitcast %struct.point6* %0 to i8* + %4 = bitcast %struct.point6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.point7* noalias sret(%struct.point7) align 4 %0, %struct.point7* noundef byval(%struct.point7) align 8 %1) #0 { + %3 = bitcast %struct.point7* %0 to i8* + %4 = bitcast %struct.point7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.point8* noalias sret(%struct.point8) align 4 %0, %struct.point8* noundef byval(%struct.point8) align 8 %1) #0 { + %3 = bitcast %struct.point8* %0 to i8* + %4 = bitcast %struct.point8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 4 %0, %struct.point9* noundef byval(%struct.point9) align 8 %1) #0 { + %3 = bitcast %struct.point9* %0 to i8* + %4 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 4 %0, %struct.point10* noundef byval(%struct.point10) align 8 %1) #0 { + %3 = bitcast %struct.point10* %0 to i8* + %4 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 4 %0, %struct.point11* noundef byval(%struct.point11) align 8 %1) #0 { + %3 = bitcast %struct.point11* %0 to i8* + %4 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 4 %0, %struct.point12* noundef byval(%struct.point12) align 8 %1) #0 { + %3 = bitcast %struct.point12* %0 to i8* + %4 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 4 %0, %struct.point13* noundef byval(%struct.point13) align 8 %1) #0 { + %3 = bitcast %struct.point13* %0 to i8* + %4 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 4 %0, %struct.point14* noundef byval(%struct.point14) align 8 %1) #0 { + %3 = bitcast %struct.point14* %0 to i8* + %4 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 4 %0, %struct.point15* noundef byval(%struct.point15) align 8 %1) #0 { + %3 = bitcast %struct.point15* %0 to i8* + %4 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 4 %0, %struct.point16* noundef byval(%struct.point16) align 8 %1) #0 { + %3 = bitcast %struct.point16* %0 to i8* + %4 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 4 %0, %struct.point17* noundef byval(%struct.point17) align 8 %1) #0 { + %3 = bitcast %struct.point17* %0 to i8* + %4 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 4 %0, %struct.point18* noundef byval(%struct.point18) align 8 %1) #0 { + %3 = bitcast %struct.point18* %0 to i8* + %4 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 4 %0, %struct.point19* noundef byval(%struct.point19) align 8 %1) #0 { + %3 = bitcast %struct.point19* %0 to i8* + %4 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 4 %0, %struct.point20* noundef byval(%struct.point20) align 8 %1) #0 { + %3 = bitcast %struct.point20* %0 to i8* + %4 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } +attributes #2 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="64" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } + +!llvm.module.flags = !{!0, !1, !2, !3, !4} +!llvm.ident = !{!5} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{i32 7, !"frame-pointer", i32 2} +!5 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/amd64/struct_float64.ll b/internal/cabi/_testdata/arch/amd64/struct_float64.ll new file mode 100644 index 00000000..877f29f5 --- /dev/null +++ b/internal/cabi/_testdata/arch/amd64/struct_float64.ll @@ -0,0 +1,216 @@ +; ModuleID = '../../wrap/struct_float64.c' +source_filename = "../../wrap/struct_float64.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "amd64-unknown-linux-gnu" + +%struct.point1 = type { double } +%struct.point2 = type { double, double } +%struct.point3 = type { double, double, double } +%struct.point4 = type { double, double, double, double } +%struct.point5 = type { double, double, double, double, double } +%struct.point6 = type { double, double, double, double, double, double } +%struct.point7 = type { double, double, double, double, double, double, double } +%struct.point8 = type { double, double, double, double, double, double, double, double } +%struct.point9 = type { double, double, double, double, double, double, double, double, double } +%struct.point10 = type { double, double, double, double, double, double, double, double, double, double } +%struct.point11 = type { double, double, double, double, double, double, double, double, double, double, double } +%struct.point12 = type { double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point13 = type { double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point14 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point15 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point16 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point17 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point18 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point19 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point20 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local double @demo1(double %0) #0 { + %2 = alloca %struct.point1, align 8 + %3 = alloca %struct.point1, align 8 + %4 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + store double %0, double* %4, align 8 + %5 = bitcast %struct.point1* %2 to i8* + %6 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 8, i1 false) + %7 = getelementptr inbounds %struct.point1, %struct.point1* %2, i32 0, i32 0 + %8 = load double, double* %7, align 8 + ret double %8 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { double, double } @demo2(double %0, double %1) #0 { + %3 = alloca %struct.point2, align 8 + %4 = alloca %struct.point2, align 8 + %5 = bitcast %struct.point2* %4 to { double, double }* + %6 = getelementptr inbounds { double, double }, { double, double }* %5, i32 0, i32 0 + store double %0, double* %6, align 8 + %7 = getelementptr inbounds { double, double }, { double, double }* %5, i32 0, i32 1 + store double %1, double* %7, align 8 + %8 = bitcast %struct.point2* %3 to i8* + %9 = bitcast %struct.point2* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %8, i8* align 8 %9, i64 16, i1 false) + %10 = bitcast %struct.point2* %3 to { double, double }* + %11 = load { double, double }, { double, double }* %10, align 8 + ret { double, double } %11 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo3(%struct.point3* noalias sret(%struct.point3) align 8 %0, %struct.point3* noundef byval(%struct.point3) align 8 %1) #0 { + %3 = bitcast %struct.point3* %0 to i8* + %4 = bitcast %struct.point3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo4(%struct.point4* noalias sret(%struct.point4) align 8 %0, %struct.point4* noundef byval(%struct.point4) align 8 %1) #0 { + %3 = bitcast %struct.point4* %0 to i8* + %4 = bitcast %struct.point4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.point5* noalias sret(%struct.point5) align 8 %0, %struct.point5* noundef byval(%struct.point5) align 8 %1) #0 { + %3 = bitcast %struct.point5* %0 to i8* + %4 = bitcast %struct.point5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.point6* noalias sret(%struct.point6) align 8 %0, %struct.point6* noundef byval(%struct.point6) align 8 %1) #0 { + %3 = bitcast %struct.point6* %0 to i8* + %4 = bitcast %struct.point6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.point7* noalias sret(%struct.point7) align 8 %0, %struct.point7* noundef byval(%struct.point7) align 8 %1) #0 { + %3 = bitcast %struct.point7* %0 to i8* + %4 = bitcast %struct.point7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.point8* noalias sret(%struct.point8) align 8 %0, %struct.point8* noundef byval(%struct.point8) align 8 %1) #0 { + %3 = bitcast %struct.point8* %0 to i8* + %4 = bitcast %struct.point8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 8 %0, %struct.point9* noundef byval(%struct.point9) align 8 %1) #0 { + %3 = bitcast %struct.point9* %0 to i8* + %4 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 8 %0, %struct.point10* noundef byval(%struct.point10) align 8 %1) #0 { + %3 = bitcast %struct.point10* %0 to i8* + %4 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 8 %0, %struct.point11* noundef byval(%struct.point11) align 8 %1) #0 { + %3 = bitcast %struct.point11* %0 to i8* + %4 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 8 %0, %struct.point12* noundef byval(%struct.point12) align 8 %1) #0 { + %3 = bitcast %struct.point12* %0 to i8* + %4 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 8 %0, %struct.point13* noundef byval(%struct.point13) align 8 %1) #0 { + %3 = bitcast %struct.point13* %0 to i8* + %4 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 8 %0, %struct.point14* noundef byval(%struct.point14) align 8 %1) #0 { + %3 = bitcast %struct.point14* %0 to i8* + %4 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 8 %0, %struct.point15* noundef byval(%struct.point15) align 8 %1) #0 { + %3 = bitcast %struct.point15* %0 to i8* + %4 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 8 %0, %struct.point16* noundef byval(%struct.point16) align 8 %1) #0 { + %3 = bitcast %struct.point16* %0 to i8* + %4 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 8 %0, %struct.point17* noundef byval(%struct.point17) align 8 %1) #0 { + %3 = bitcast %struct.point17* %0 to i8* + %4 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 8 %0, %struct.point18* noundef byval(%struct.point18) align 8 %1) #0 { + %3 = bitcast %struct.point18* %0 to i8* + %4 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 8 %0, %struct.point19* noundef byval(%struct.point19) align 8 %1) #0 { + %3 = bitcast %struct.point19* %0 to i8* + %4 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 8 %0, %struct.point20* noundef byval(%struct.point20) align 8 %1) #0 { + %3 = bitcast %struct.point20* %0 to i8* + %4 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4} +!llvm.ident = !{!5} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{i32 7, !"frame-pointer", i32 2} +!5 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/amd64/struct_int16.ll b/internal/cabi/_testdata/arch/amd64/struct_int16.ll new file mode 100644 index 00000000..5755bca0 --- /dev/null +++ b/internal/cabi/_testdata/arch/amd64/struct_int16.ll @@ -0,0 +1,285 @@ +; ModuleID = '../../wrap/struct_int16.c' +source_filename = "../../wrap/struct_int16.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "amd64-unknown-linux-gnu" + +%struct.point1 = type { i16 } +%struct.point2 = type { i16, i16 } +%struct.point3 = type { i16, i16, i16 } +%struct.point4 = type { i16, i16, i16, i16 } +%struct.point5 = type { i16, i16, i16, i16, i16 } +%struct.point6 = type { i16, i16, i16, i16, i16, i16 } +%struct.point7 = type { i16, i16, i16, i16, i16, i16, i16 } +%struct.point8 = type { i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point9 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point10 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point11 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point12 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point13 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point14 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point15 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point16 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point17 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point18 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point19 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point20 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i16 @demo1(i16 %0) #0 { + %2 = alloca %struct.point1, align 2 + %3 = alloca %struct.point1, align 2 + %4 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + store i16 %0, i16* %4, align 2 + %5 = bitcast %struct.point1* %2 to i8* + %6 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 2, i1 false) + %7 = getelementptr inbounds %struct.point1, %struct.point1* %2, i32 0, i32 0 + %8 = load i16, i16* %7, align 2 + ret i16 %8 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i32 @demo2(i32 %0) #0 { + %2 = alloca %struct.point2, align 2 + %3 = alloca %struct.point2, align 2 + %4 = bitcast %struct.point2* %3 to i32* + store i32 %0, i32* %4, align 2 + %5 = bitcast %struct.point2* %2 to i8* + %6 = bitcast %struct.point2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 4, i1 false) + %7 = bitcast %struct.point2* %2 to i32* + %8 = load i32, i32* %7, align 2 + ret i32 %8 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i48 @demo3(i48 %0) #0 { + %2 = alloca %struct.point3, align 2 + %3 = alloca %struct.point3, align 2 + %4 = alloca i48, align 8 + %5 = alloca i48, align 8 + store i48 %0, i48* %4, align 8 + %6 = bitcast %struct.point3* %3 to i8* + %7 = bitcast i48* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %6, i8* align 8 %7, i64 6, i1 false) + %8 = bitcast %struct.point3* %2 to i8* + %9 = bitcast %struct.point3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %8, i8* align 2 %9, i64 6, i1 false) + %10 = bitcast i48* %5 to i8* + %11 = bitcast %struct.point3* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 2 %11, i64 6, i1 false) + %12 = load i48, i48* %5, align 8 + ret i48 %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i64 @demo4(i64 %0) #0 { + %2 = alloca %struct.point4, align 2 + %3 = alloca %struct.point4, align 2 + %4 = bitcast %struct.point4* %3 to i64* + store i64 %0, i64* %4, align 2 + %5 = bitcast %struct.point4* %2 to i8* + %6 = bitcast %struct.point4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 8, i1 false) + %7 = bitcast %struct.point4* %2 to i64* + %8 = load i64, i64* %7, align 2 + ret i64 %8 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i64, i16 } @demo5(i64 %0, i16 %1) #0 { + %3 = alloca %struct.point5, align 2 + %4 = alloca %struct.point5, align 2 + %5 = alloca { i64, i16 }, align 2 + %6 = alloca { i64, i16 }, align 8 + %7 = getelementptr inbounds { i64, i16 }, { i64, i16 }* %5, i32 0, i32 0 + store i64 %0, i64* %7, align 2 + %8 = getelementptr inbounds { i64, i16 }, { i64, i16 }* %5, i32 0, i32 1 + store i16 %1, i16* %8, align 2 + %9 = bitcast %struct.point5* %4 to i8* + %10 = bitcast { i64, i16 }* %5 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %9, i8* align 2 %10, i64 10, i1 false) + %11 = bitcast %struct.point5* %3 to i8* + %12 = bitcast %struct.point5* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %11, i8* align 2 %12, i64 10, i1 false) + %13 = bitcast { i64, i16 }* %6 to i8* + %14 = bitcast %struct.point5* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %13, i8* align 2 %14, i64 10, i1 false) + %15 = load { i64, i16 }, { i64, i16 }* %6, align 8 + ret { i64, i16 } %15 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i64, i32 } @demo6(i64 %0, i32 %1) #0 { + %3 = alloca %struct.point6, align 2 + %4 = alloca %struct.point6, align 2 + %5 = alloca { i64, i32 }, align 2 + %6 = alloca { i64, i32 }, align 8 + %7 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %5, i32 0, i32 0 + store i64 %0, i64* %7, align 2 + %8 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %5, i32 0, i32 1 + store i32 %1, i32* %8, align 2 + %9 = bitcast %struct.point6* %4 to i8* + %10 = bitcast { i64, i32 }* %5 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %9, i8* align 2 %10, i64 12, i1 false) + %11 = bitcast %struct.point6* %3 to i8* + %12 = bitcast %struct.point6* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %11, i8* align 2 %12, i64 12, i1 false) + %13 = bitcast { i64, i32 }* %6 to i8* + %14 = bitcast %struct.point6* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %13, i8* align 2 %14, i64 12, i1 false) + %15 = load { i64, i32 }, { i64, i32 }* %6, align 8 + ret { i64, i32 } %15 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i64, i48 } @demo7(i64 %0, i48 %1) #0 { + %3 = alloca %struct.point7, align 2 + %4 = alloca %struct.point7, align 2 + %5 = alloca { i64, i48 }, align 2 + %6 = alloca { i64, i48 }, align 8 + %7 = getelementptr inbounds { i64, i48 }, { i64, i48 }* %5, i32 0, i32 0 + store i64 %0, i64* %7, align 2 + %8 = getelementptr inbounds { i64, i48 }, { i64, i48 }* %5, i32 0, i32 1 + store i48 %1, i48* %8, align 2 + %9 = bitcast %struct.point7* %4 to i8* + %10 = bitcast { i64, i48 }* %5 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %9, i8* align 2 %10, i64 14, i1 false) + %11 = bitcast %struct.point7* %3 to i8* + %12 = bitcast %struct.point7* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %11, i8* align 2 %12, i64 14, i1 false) + %13 = bitcast { i64, i48 }* %6 to i8* + %14 = bitcast %struct.point7* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %13, i8* align 2 %14, i64 14, i1 false) + %15 = load { i64, i48 }, { i64, i48 }* %6, align 8 + ret { i64, i48 } %15 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i64, i64 } @demo8(i64 %0, i64 %1) #0 { + %3 = alloca %struct.point8, align 2 + %4 = alloca %struct.point8, align 2 + %5 = bitcast %struct.point8* %4 to { i64, i64 }* + %6 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %5, i32 0, i32 0 + store i64 %0, i64* %6, align 2 + %7 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %5, i32 0, i32 1 + store i64 %1, i64* %7, align 2 + %8 = bitcast %struct.point8* %3 to i8* + %9 = bitcast %struct.point8* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %8, i8* align 2 %9, i64 16, i1 false) + %10 = bitcast %struct.point8* %3 to { i64, i64 }* + %11 = load { i64, i64 }, { i64, i64 }* %10, align 2 + ret { i64, i64 } %11 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 2 %0, %struct.point9* noundef byval(%struct.point9) align 8 %1) #0 { + %3 = bitcast %struct.point9* %0 to i8* + %4 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 8 %4, i64 18, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 2 %0, %struct.point10* noundef byval(%struct.point10) align 8 %1) #0 { + %3 = bitcast %struct.point10* %0 to i8* + %4 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 8 %4, i64 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 2 %0, %struct.point11* noundef byval(%struct.point11) align 8 %1) #0 { + %3 = bitcast %struct.point11* %0 to i8* + %4 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 8 %4, i64 22, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 2 %0, %struct.point12* noundef byval(%struct.point12) align 8 %1) #0 { + %3 = bitcast %struct.point12* %0 to i8* + %4 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 8 %4, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 2 %0, %struct.point13* noundef byval(%struct.point13) align 8 %1) #0 { + %3 = bitcast %struct.point13* %0 to i8* + %4 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 8 %4, i64 26, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 2 %0, %struct.point14* noundef byval(%struct.point14) align 8 %1) #0 { + %3 = bitcast %struct.point14* %0 to i8* + %4 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 8 %4, i64 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 2 %0, %struct.point15* noundef byval(%struct.point15) align 8 %1) #0 { + %3 = bitcast %struct.point15* %0 to i8* + %4 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 8 %4, i64 30, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 2 %0, %struct.point16* noundef byval(%struct.point16) align 8 %1) #0 { + %3 = bitcast %struct.point16* %0 to i8* + %4 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 8 %4, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 2 %0, %struct.point17* noundef byval(%struct.point17) align 8 %1) #0 { + %3 = bitcast %struct.point17* %0 to i8* + %4 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 8 %4, i64 34, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 2 %0, %struct.point18* noundef byval(%struct.point18) align 8 %1) #0 { + %3 = bitcast %struct.point18* %0 to i8* + %4 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 8 %4, i64 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 2 %0, %struct.point19* noundef byval(%struct.point19) align 8 %1) #0 { + %3 = bitcast %struct.point19* %0 to i8* + %4 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 8 %4, i64 38, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 2 %0, %struct.point20* noundef byval(%struct.point20) align 8 %1) #0 { + %3 = bitcast %struct.point20* %0 to i8* + %4 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 8 %4, i64 40, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4} +!llvm.ident = !{!5} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{i32 7, !"frame-pointer", i32 2} +!5 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/amd64/struct_int32.ll b/internal/cabi/_testdata/arch/amd64/struct_int32.ll new file mode 100644 index 00000000..72b8c37e --- /dev/null +++ b/internal/cabi/_testdata/arch/amd64/struct_int32.ll @@ -0,0 +1,237 @@ +; ModuleID = '../../wrap/struct_int32.c' +source_filename = "../../wrap/struct_int32.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "amd64-unknown-linux-gnu" + +%struct.point1 = type { i32 } +%struct.point2 = type { i32, i32 } +%struct.point3 = type { i32, i32, i32 } +%struct.point4 = type { i32, i32, i32, i32 } +%struct.point5 = type { i32, i32, i32, i32, i32 } +%struct.point6 = type { i32, i32, i32, i32, i32, i32 } +%struct.point7 = type { i32, i32, i32, i32, i32, i32, i32 } +%struct.point8 = type { i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point9 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point10 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point11 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point12 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point13 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point14 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point15 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point16 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point17 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point18 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point19 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point20 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i32 @demo1(i32 %0) #0 { + %2 = alloca %struct.point1, align 4 + %3 = alloca %struct.point1, align 4 + %4 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + store i32 %0, i32* %4, align 4 + %5 = bitcast %struct.point1* %2 to i8* + %6 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 4, i1 false) + %7 = getelementptr inbounds %struct.point1, %struct.point1* %2, i32 0, i32 0 + %8 = load i32, i32* %7, align 4 + ret i32 %8 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i64 @demo2(i64 %0) #0 { + %2 = alloca %struct.point2, align 4 + %3 = alloca %struct.point2, align 4 + %4 = bitcast %struct.point2* %3 to i64* + store i64 %0, i64* %4, align 4 + %5 = bitcast %struct.point2* %2 to i8* + %6 = bitcast %struct.point2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 8, i1 false) + %7 = bitcast %struct.point2* %2 to i64* + %8 = load i64, i64* %7, align 4 + ret i64 %8 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i64, i32 } @demo3(i64 %0, i32 %1) #0 { + %3 = alloca %struct.point3, align 4 + %4 = alloca %struct.point3, align 4 + %5 = alloca { i64, i32 }, align 4 + %6 = alloca { i64, i32 }, align 8 + %7 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %5, i32 0, i32 0 + store i64 %0, i64* %7, align 4 + %8 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %5, i32 0, i32 1 + store i32 %1, i32* %8, align 4 + %9 = bitcast %struct.point3* %4 to i8* + %10 = bitcast { i64, i32 }* %5 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %9, i8* align 4 %10, i64 12, i1 false) + %11 = bitcast %struct.point3* %3 to i8* + %12 = bitcast %struct.point3* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %11, i8* align 4 %12, i64 12, i1 false) + %13 = bitcast { i64, i32 }* %6 to i8* + %14 = bitcast %struct.point3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %13, i8* align 4 %14, i64 12, i1 false) + %15 = load { i64, i32 }, { i64, i32 }* %6, align 8 + ret { i64, i32 } %15 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i64, i64 } @demo4(i64 %0, i64 %1) #0 { + %3 = alloca %struct.point4, align 4 + %4 = alloca %struct.point4, align 4 + %5 = bitcast %struct.point4* %4 to { i64, i64 }* + %6 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %5, i32 0, i32 0 + store i64 %0, i64* %6, align 4 + %7 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %5, i32 0, i32 1 + store i64 %1, i64* %7, align 4 + %8 = bitcast %struct.point4* %3 to i8* + %9 = bitcast %struct.point4* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %8, i8* align 4 %9, i64 16, i1 false) + %10 = bitcast %struct.point4* %3 to { i64, i64 }* + %11 = load { i64, i64 }, { i64, i64 }* %10, align 4 + ret { i64, i64 } %11 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.point5* noalias sret(%struct.point5) align 4 %0, %struct.point5* noundef byval(%struct.point5) align 8 %1) #0 { + %3 = bitcast %struct.point5* %0 to i8* + %4 = bitcast %struct.point5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.point6* noalias sret(%struct.point6) align 4 %0, %struct.point6* noundef byval(%struct.point6) align 8 %1) #0 { + %3 = bitcast %struct.point6* %0 to i8* + %4 = bitcast %struct.point6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.point7* noalias sret(%struct.point7) align 4 %0, %struct.point7* noundef byval(%struct.point7) align 8 %1) #0 { + %3 = bitcast %struct.point7* %0 to i8* + %4 = bitcast %struct.point7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.point8* noalias sret(%struct.point8) align 4 %0, %struct.point8* noundef byval(%struct.point8) align 8 %1) #0 { + %3 = bitcast %struct.point8* %0 to i8* + %4 = bitcast %struct.point8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 4 %0, %struct.point9* noundef byval(%struct.point9) align 8 %1) #0 { + %3 = bitcast %struct.point9* %0 to i8* + %4 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 4 %0, %struct.point10* noundef byval(%struct.point10) align 8 %1) #0 { + %3 = bitcast %struct.point10* %0 to i8* + %4 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 4 %0, %struct.point11* noundef byval(%struct.point11) align 8 %1) #0 { + %3 = bitcast %struct.point11* %0 to i8* + %4 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 4 %0, %struct.point12* noundef byval(%struct.point12) align 8 %1) #0 { + %3 = bitcast %struct.point12* %0 to i8* + %4 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 4 %0, %struct.point13* noundef byval(%struct.point13) align 8 %1) #0 { + %3 = bitcast %struct.point13* %0 to i8* + %4 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 4 %0, %struct.point14* noundef byval(%struct.point14) align 8 %1) #0 { + %3 = bitcast %struct.point14* %0 to i8* + %4 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 4 %0, %struct.point15* noundef byval(%struct.point15) align 8 %1) #0 { + %3 = bitcast %struct.point15* %0 to i8* + %4 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 4 %0, %struct.point16* noundef byval(%struct.point16) align 8 %1) #0 { + %3 = bitcast %struct.point16* %0 to i8* + %4 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 4 %0, %struct.point17* noundef byval(%struct.point17) align 8 %1) #0 { + %3 = bitcast %struct.point17* %0 to i8* + %4 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 4 %0, %struct.point18* noundef byval(%struct.point18) align 8 %1) #0 { + %3 = bitcast %struct.point18* %0 to i8* + %4 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 4 %0, %struct.point19* noundef byval(%struct.point19) align 8 %1) #0 { + %3 = bitcast %struct.point19* %0 to i8* + %4 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 4 %0, %struct.point20* noundef byval(%struct.point20) align 8 %1) #0 { + %3 = bitcast %struct.point20* %0 to i8* + %4 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 8 %4, i64 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4} +!llvm.ident = !{!5} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{i32 7, !"frame-pointer", i32 2} +!5 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/amd64/struct_int64.ll b/internal/cabi/_testdata/arch/amd64/struct_int64.ll new file mode 100644 index 00000000..18d31ec0 --- /dev/null +++ b/internal/cabi/_testdata/arch/amd64/struct_int64.ll @@ -0,0 +1,216 @@ +; ModuleID = '../../wrap/struct_int64.c' +source_filename = "../../wrap/struct_int64.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "amd64-unknown-linux-gnu" + +%struct.point1 = type { i64 } +%struct.point2 = type { i64, i64 } +%struct.point3 = type { i64, i64, i64 } +%struct.point4 = type { i64, i64, i64, i64 } +%struct.point5 = type { i64, i64, i64, i64, i64 } +%struct.point6 = type { i64, i64, i64, i64, i64, i64 } +%struct.point7 = type { i64, i64, i64, i64, i64, i64, i64 } +%struct.point8 = type { i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point9 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point10 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point11 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point12 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point13 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point14 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point15 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point16 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point17 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point18 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point19 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point20 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i64 @demo1(i64 %0) #0 { + %2 = alloca %struct.point1, align 8 + %3 = alloca %struct.point1, align 8 + %4 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + store i64 %0, i64* %4, align 8 + %5 = bitcast %struct.point1* %2 to i8* + %6 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 8, i1 false) + %7 = getelementptr inbounds %struct.point1, %struct.point1* %2, i32 0, i32 0 + %8 = load i64, i64* %7, align 8 + ret i64 %8 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i64, i64 } @demo2(i64 %0, i64 %1) #0 { + %3 = alloca %struct.point2, align 8 + %4 = alloca %struct.point2, align 8 + %5 = bitcast %struct.point2* %4 to { i64, i64 }* + %6 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %5, i32 0, i32 0 + store i64 %0, i64* %6, align 8 + %7 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %5, i32 0, i32 1 + store i64 %1, i64* %7, align 8 + %8 = bitcast %struct.point2* %3 to i8* + %9 = bitcast %struct.point2* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %8, i8* align 8 %9, i64 16, i1 false) + %10 = bitcast %struct.point2* %3 to { i64, i64 }* + %11 = load { i64, i64 }, { i64, i64 }* %10, align 8 + ret { i64, i64 } %11 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo3(%struct.point3* noalias sret(%struct.point3) align 8 %0, %struct.point3* noundef byval(%struct.point3) align 8 %1) #0 { + %3 = bitcast %struct.point3* %0 to i8* + %4 = bitcast %struct.point3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo4(%struct.point4* noalias sret(%struct.point4) align 8 %0, %struct.point4* noundef byval(%struct.point4) align 8 %1) #0 { + %3 = bitcast %struct.point4* %0 to i8* + %4 = bitcast %struct.point4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.point5* noalias sret(%struct.point5) align 8 %0, %struct.point5* noundef byval(%struct.point5) align 8 %1) #0 { + %3 = bitcast %struct.point5* %0 to i8* + %4 = bitcast %struct.point5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.point6* noalias sret(%struct.point6) align 8 %0, %struct.point6* noundef byval(%struct.point6) align 8 %1) #0 { + %3 = bitcast %struct.point6* %0 to i8* + %4 = bitcast %struct.point6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.point7* noalias sret(%struct.point7) align 8 %0, %struct.point7* noundef byval(%struct.point7) align 8 %1) #0 { + %3 = bitcast %struct.point7* %0 to i8* + %4 = bitcast %struct.point7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.point8* noalias sret(%struct.point8) align 8 %0, %struct.point8* noundef byval(%struct.point8) align 8 %1) #0 { + %3 = bitcast %struct.point8* %0 to i8* + %4 = bitcast %struct.point8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 8 %0, %struct.point9* noundef byval(%struct.point9) align 8 %1) #0 { + %3 = bitcast %struct.point9* %0 to i8* + %4 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 8 %0, %struct.point10* noundef byval(%struct.point10) align 8 %1) #0 { + %3 = bitcast %struct.point10* %0 to i8* + %4 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 8 %0, %struct.point11* noundef byval(%struct.point11) align 8 %1) #0 { + %3 = bitcast %struct.point11* %0 to i8* + %4 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 8 %0, %struct.point12* noundef byval(%struct.point12) align 8 %1) #0 { + %3 = bitcast %struct.point12* %0 to i8* + %4 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 8 %0, %struct.point13* noundef byval(%struct.point13) align 8 %1) #0 { + %3 = bitcast %struct.point13* %0 to i8* + %4 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 8 %0, %struct.point14* noundef byval(%struct.point14) align 8 %1) #0 { + %3 = bitcast %struct.point14* %0 to i8* + %4 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 8 %0, %struct.point15* noundef byval(%struct.point15) align 8 %1) #0 { + %3 = bitcast %struct.point15* %0 to i8* + %4 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 8 %0, %struct.point16* noundef byval(%struct.point16) align 8 %1) #0 { + %3 = bitcast %struct.point16* %0 to i8* + %4 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 8 %0, %struct.point17* noundef byval(%struct.point17) align 8 %1) #0 { + %3 = bitcast %struct.point17* %0 to i8* + %4 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 8 %0, %struct.point18* noundef byval(%struct.point18) align 8 %1) #0 { + %3 = bitcast %struct.point18* %0 to i8* + %4 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 8 %0, %struct.point19* noundef byval(%struct.point19) align 8 %1) #0 { + %3 = bitcast %struct.point19* %0 to i8* + %4 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 8 %0, %struct.point20* noundef byval(%struct.point20) align 8 %1) #0 { + %3 = bitcast %struct.point20* %0 to i8* + %4 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4} +!llvm.ident = !{!5} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{i32 7, !"frame-pointer", i32 2} +!5 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/amd64/struct_int8.ll b/internal/cabi/_testdata/arch/amd64/struct_int8.ll new file mode 100644 index 00000000..3d8538ac --- /dev/null +++ b/internal/cabi/_testdata/arch/amd64/struct_int8.ll @@ -0,0 +1,387 @@ +; ModuleID = '../../wrap/struct_int8.c' +source_filename = "../../wrap/struct_int8.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "amd64-unknown-linux-gnu" + +%struct.point1 = type { i8 } +%struct.point2 = type { i8, i8 } +%struct.point3 = type { i8, i8, i8 } +%struct.point4 = type { i8, i8, i8, i8 } +%struct.point5 = type { i8, i8, i8, i8, i8 } +%struct.point6 = type { i8, i8, i8, i8, i8, i8 } +%struct.point7 = type { i8, i8, i8, i8, i8, i8, i8 } +%struct.point8 = type { i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point9 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point10 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point11 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point12 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point13 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point14 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point15 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point16 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point17 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point18 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point19 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point20 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i8 @demo1(i8 %0) #0 { + %2 = alloca %struct.point1, align 1 + %3 = alloca %struct.point1, align 1 + %4 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + store i8 %0, i8* %4, align 1 + %5 = bitcast %struct.point1* %2 to i8* + %6 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %5, i8* align 1 %6, i64 1, i1 false) + %7 = getelementptr inbounds %struct.point1, %struct.point1* %2, i32 0, i32 0 + %8 = load i8, i8* %7, align 1 + ret i8 %8 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i16 @demo2(i16 %0) #0 { + %2 = alloca %struct.point2, align 1 + %3 = alloca %struct.point2, align 1 + %4 = bitcast %struct.point2* %3 to i16* + store i16 %0, i16* %4, align 1 + %5 = bitcast %struct.point2* %2 to i8* + %6 = bitcast %struct.point2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %5, i8* align 1 %6, i64 2, i1 false) + %7 = bitcast %struct.point2* %2 to i16* + %8 = load i16, i16* %7, align 1 + ret i16 %8 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i24 @demo3(i24 %0) #0 { + %2 = alloca %struct.point3, align 1 + %3 = alloca %struct.point3, align 1 + %4 = alloca i24, align 4 + %5 = alloca i24, align 4 + store i24 %0, i24* %4, align 4 + %6 = bitcast %struct.point3* %3 to i8* + %7 = bitcast i24* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 4 %7, i64 3, i1 false) + %8 = bitcast %struct.point3* %2 to i8* + %9 = bitcast %struct.point3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 3, i1 false) + %10 = bitcast i24* %5 to i8* + %11 = bitcast %struct.point3* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %10, i8* align 1 %11, i64 3, i1 false) + %12 = load i24, i24* %5, align 4 + ret i24 %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i32 @demo4(i32 %0) #0 { + %2 = alloca %struct.point4, align 1 + %3 = alloca %struct.point4, align 1 + %4 = bitcast %struct.point4* %3 to i32* + store i32 %0, i32* %4, align 1 + %5 = bitcast %struct.point4* %2 to i8* + %6 = bitcast %struct.point4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %5, i8* align 1 %6, i64 4, i1 false) + %7 = bitcast %struct.point4* %2 to i32* + %8 = load i32, i32* %7, align 1 + ret i32 %8 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i40 @demo5(i40 %0) #0 { + %2 = alloca %struct.point5, align 1 + %3 = alloca %struct.point5, align 1 + %4 = alloca i40, align 8 + %5 = alloca i40, align 8 + store i40 %0, i40* %4, align 8 + %6 = bitcast %struct.point5* %3 to i8* + %7 = bitcast i40* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 8 %7, i64 5, i1 false) + %8 = bitcast %struct.point5* %2 to i8* + %9 = bitcast %struct.point5* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 5, i1 false) + %10 = bitcast i40* %5 to i8* + %11 = bitcast %struct.point5* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 1 %11, i64 5, i1 false) + %12 = load i40, i40* %5, align 8 + ret i40 %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i48 @demo6(i48 %0) #0 { + %2 = alloca %struct.point6, align 1 + %3 = alloca %struct.point6, align 1 + %4 = alloca i48, align 8 + %5 = alloca i48, align 8 + store i48 %0, i48* %4, align 8 + %6 = bitcast %struct.point6* %3 to i8* + %7 = bitcast i48* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 8 %7, i64 6, i1 false) + %8 = bitcast %struct.point6* %2 to i8* + %9 = bitcast %struct.point6* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 6, i1 false) + %10 = bitcast i48* %5 to i8* + %11 = bitcast %struct.point6* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 1 %11, i64 6, i1 false) + %12 = load i48, i48* %5, align 8 + ret i48 %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i56 @demo7(i56 %0) #0 { + %2 = alloca %struct.point7, align 1 + %3 = alloca %struct.point7, align 1 + %4 = alloca i56, align 8 + %5 = alloca i56, align 8 + store i56 %0, i56* %4, align 8 + %6 = bitcast %struct.point7* %3 to i8* + %7 = bitcast i56* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 8 %7, i64 7, i1 false) + %8 = bitcast %struct.point7* %2 to i8* + %9 = bitcast %struct.point7* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 7, i1 false) + %10 = bitcast i56* %5 to i8* + %11 = bitcast %struct.point7* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 1 %11, i64 7, i1 false) + %12 = load i56, i56* %5, align 8 + ret i56 %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i64 @demo8(i64 %0) #0 { + %2 = alloca %struct.point8, align 1 + %3 = alloca %struct.point8, align 1 + %4 = bitcast %struct.point8* %3 to i64* + store i64 %0, i64* %4, align 1 + %5 = bitcast %struct.point8* %2 to i8* + %6 = bitcast %struct.point8* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %5, i8* align 1 %6, i64 8, i1 false) + %7 = bitcast %struct.point8* %2 to i64* + %8 = load i64, i64* %7, align 1 + ret i64 %8 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i64, i8 } @demo9(i64 %0, i8 %1) #0 { + %3 = alloca %struct.point9, align 1 + %4 = alloca %struct.point9, align 1 + %5 = alloca { i64, i8 }, align 1 + %6 = alloca { i64, i8 }, align 8 + %7 = getelementptr inbounds { i64, i8 }, { i64, i8 }* %5, i32 0, i32 0 + store i64 %0, i64* %7, align 1 + %8 = getelementptr inbounds { i64, i8 }, { i64, i8 }* %5, i32 0, i32 1 + store i8 %1, i8* %8, align 1 + %9 = bitcast %struct.point9* %4 to i8* + %10 = bitcast { i64, i8 }* %5 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 9, i1 false) + %11 = bitcast %struct.point9* %3 to i8* + %12 = bitcast %struct.point9* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %11, i8* align 1 %12, i64 9, i1 false) + %13 = bitcast { i64, i8 }* %6 to i8* + %14 = bitcast %struct.point9* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %13, i8* align 1 %14, i64 9, i1 false) + %15 = load { i64, i8 }, { i64, i8 }* %6, align 8 + ret { i64, i8 } %15 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i64, i16 } @demo10(i64 %0, i16 %1) #0 { + %3 = alloca %struct.point10, align 1 + %4 = alloca %struct.point10, align 1 + %5 = alloca { i64, i16 }, align 1 + %6 = alloca { i64, i16 }, align 8 + %7 = getelementptr inbounds { i64, i16 }, { i64, i16 }* %5, i32 0, i32 0 + store i64 %0, i64* %7, align 1 + %8 = getelementptr inbounds { i64, i16 }, { i64, i16 }* %5, i32 0, i32 1 + store i16 %1, i16* %8, align 1 + %9 = bitcast %struct.point10* %4 to i8* + %10 = bitcast { i64, i16 }* %5 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 10, i1 false) + %11 = bitcast %struct.point10* %3 to i8* + %12 = bitcast %struct.point10* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %11, i8* align 1 %12, i64 10, i1 false) + %13 = bitcast { i64, i16 }* %6 to i8* + %14 = bitcast %struct.point10* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %13, i8* align 1 %14, i64 10, i1 false) + %15 = load { i64, i16 }, { i64, i16 }* %6, align 8 + ret { i64, i16 } %15 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i64, i24 } @demo11(i64 %0, i24 %1) #0 { + %3 = alloca %struct.point11, align 1 + %4 = alloca %struct.point11, align 1 + %5 = alloca { i64, i24 }, align 1 + %6 = alloca { i64, i24 }, align 8 + %7 = getelementptr inbounds { i64, i24 }, { i64, i24 }* %5, i32 0, i32 0 + store i64 %0, i64* %7, align 1 + %8 = getelementptr inbounds { i64, i24 }, { i64, i24 }* %5, i32 0, i32 1 + store i24 %1, i24* %8, align 1 + %9 = bitcast %struct.point11* %4 to i8* + %10 = bitcast { i64, i24 }* %5 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 11, i1 false) + %11 = bitcast %struct.point11* %3 to i8* + %12 = bitcast %struct.point11* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %11, i8* align 1 %12, i64 11, i1 false) + %13 = bitcast { i64, i24 }* %6 to i8* + %14 = bitcast %struct.point11* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %13, i8* align 1 %14, i64 11, i1 false) + %15 = load { i64, i24 }, { i64, i24 }* %6, align 8 + ret { i64, i24 } %15 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i64, i32 } @demo12(i64 %0, i32 %1) #0 { + %3 = alloca %struct.point12, align 1 + %4 = alloca %struct.point12, align 1 + %5 = alloca { i64, i32 }, align 1 + %6 = alloca { i64, i32 }, align 8 + %7 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %5, i32 0, i32 0 + store i64 %0, i64* %7, align 1 + %8 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %5, i32 0, i32 1 + store i32 %1, i32* %8, align 1 + %9 = bitcast %struct.point12* %4 to i8* + %10 = bitcast { i64, i32 }* %5 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 12, i1 false) + %11 = bitcast %struct.point12* %3 to i8* + %12 = bitcast %struct.point12* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %11, i8* align 1 %12, i64 12, i1 false) + %13 = bitcast { i64, i32 }* %6 to i8* + %14 = bitcast %struct.point12* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %13, i8* align 1 %14, i64 12, i1 false) + %15 = load { i64, i32 }, { i64, i32 }* %6, align 8 + ret { i64, i32 } %15 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i64, i40 } @demo13(i64 %0, i40 %1) #0 { + %3 = alloca %struct.point13, align 1 + %4 = alloca %struct.point13, align 1 + %5 = alloca { i64, i40 }, align 1 + %6 = alloca { i64, i40 }, align 8 + %7 = getelementptr inbounds { i64, i40 }, { i64, i40 }* %5, i32 0, i32 0 + store i64 %0, i64* %7, align 1 + %8 = getelementptr inbounds { i64, i40 }, { i64, i40 }* %5, i32 0, i32 1 + store i40 %1, i40* %8, align 1 + %9 = bitcast %struct.point13* %4 to i8* + %10 = bitcast { i64, i40 }* %5 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 13, i1 false) + %11 = bitcast %struct.point13* %3 to i8* + %12 = bitcast %struct.point13* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %11, i8* align 1 %12, i64 13, i1 false) + %13 = bitcast { i64, i40 }* %6 to i8* + %14 = bitcast %struct.point13* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %13, i8* align 1 %14, i64 13, i1 false) + %15 = load { i64, i40 }, { i64, i40 }* %6, align 8 + ret { i64, i40 } %15 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i64, i48 } @demo14(i64 %0, i48 %1) #0 { + %3 = alloca %struct.point14, align 1 + %4 = alloca %struct.point14, align 1 + %5 = alloca { i64, i48 }, align 1 + %6 = alloca { i64, i48 }, align 8 + %7 = getelementptr inbounds { i64, i48 }, { i64, i48 }* %5, i32 0, i32 0 + store i64 %0, i64* %7, align 1 + %8 = getelementptr inbounds { i64, i48 }, { i64, i48 }* %5, i32 0, i32 1 + store i48 %1, i48* %8, align 1 + %9 = bitcast %struct.point14* %4 to i8* + %10 = bitcast { i64, i48 }* %5 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 14, i1 false) + %11 = bitcast %struct.point14* %3 to i8* + %12 = bitcast %struct.point14* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %11, i8* align 1 %12, i64 14, i1 false) + %13 = bitcast { i64, i48 }* %6 to i8* + %14 = bitcast %struct.point14* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %13, i8* align 1 %14, i64 14, i1 false) + %15 = load { i64, i48 }, { i64, i48 }* %6, align 8 + ret { i64, i48 } %15 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i64, i56 } @demo15(i64 %0, i56 %1) #0 { + %3 = alloca %struct.point15, align 1 + %4 = alloca %struct.point15, align 1 + %5 = alloca { i64, i56 }, align 1 + %6 = alloca { i64, i56 }, align 8 + %7 = getelementptr inbounds { i64, i56 }, { i64, i56 }* %5, i32 0, i32 0 + store i64 %0, i64* %7, align 1 + %8 = getelementptr inbounds { i64, i56 }, { i64, i56 }* %5, i32 0, i32 1 + store i56 %1, i56* %8, align 1 + %9 = bitcast %struct.point15* %4 to i8* + %10 = bitcast { i64, i56 }* %5 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 15, i1 false) + %11 = bitcast %struct.point15* %3 to i8* + %12 = bitcast %struct.point15* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %11, i8* align 1 %12, i64 15, i1 false) + %13 = bitcast { i64, i56 }* %6 to i8* + %14 = bitcast %struct.point15* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %13, i8* align 1 %14, i64 15, i1 false) + %15 = load { i64, i56 }, { i64, i56 }* %6, align 8 + ret { i64, i56 } %15 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i64, i64 } @demo16(i64 %0, i64 %1) #0 { + %3 = alloca %struct.point16, align 1 + %4 = alloca %struct.point16, align 1 + %5 = bitcast %struct.point16* %4 to { i64, i64 }* + %6 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %5, i32 0, i32 0 + store i64 %0, i64* %6, align 1 + %7 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %5, i32 0, i32 1 + store i64 %1, i64* %7, align 1 + %8 = bitcast %struct.point16* %3 to i8* + %9 = bitcast %struct.point16* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 16, i1 false) + %10 = bitcast %struct.point16* %3 to { i64, i64 }* + %11 = load { i64, i64 }, { i64, i64 }* %10, align 1 + ret { i64, i64 } %11 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 1 %0, %struct.point17* noundef byval(%struct.point17) align 8 %1) #0 { + %3 = bitcast %struct.point17* %0 to i8* + %4 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %3, i8* align 8 %4, i64 17, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 1 %0, %struct.point18* noundef byval(%struct.point18) align 8 %1) #0 { + %3 = bitcast %struct.point18* %0 to i8* + %4 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %3, i8* align 8 %4, i64 18, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 1 %0, %struct.point19* noundef byval(%struct.point19) align 8 %1) #0 { + %3 = bitcast %struct.point19* %0 to i8* + %4 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %3, i8* align 8 %4, i64 19, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 1 %0, %struct.point20* noundef byval(%struct.point20) align 8 %1) #0 { + %3 = bitcast %struct.point20* %0 to i8* + %4 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %3, i8* align 8 %4, i64 20, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4} +!llvm.ident = !{!5} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{i32 7, !"frame-pointer", i32 2} +!5 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/amd64/struct_uintptr.ll b/internal/cabi/_testdata/arch/amd64/struct_uintptr.ll new file mode 100644 index 00000000..1eb9e86c --- /dev/null +++ b/internal/cabi/_testdata/arch/amd64/struct_uintptr.ll @@ -0,0 +1,216 @@ +; ModuleID = '../../wrap/struct_uintptr.c' +source_filename = "../../wrap/struct_uintptr.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "amd64-unknown-linux-gnu" + +%struct.point1 = type { i8* } +%struct.point2 = type { i8*, i8* } +%struct.point3 = type { i8*, i8*, i8* } +%struct.point4 = type { i8*, i8*, i8*, i8* } +%struct.point5 = type { i8*, i8*, i8*, i8*, i8* } +%struct.point6 = type { i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point7 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point8 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point9 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point10 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point11 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point12 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point13 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point14 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point15 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point16 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point17 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point18 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point19 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point20 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i8* @demo1(i8* %0) #0 { + %2 = alloca %struct.point1, align 8 + %3 = alloca %struct.point1, align 8 + %4 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + store i8* %0, i8** %4, align 8 + %5 = bitcast %struct.point1* %2 to i8* + %6 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 8, i1 false) + %7 = getelementptr inbounds %struct.point1, %struct.point1* %2, i32 0, i32 0 + %8 = load i8*, i8** %7, align 8 + ret i8* %8 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local { i8*, i8* } @demo2(i8* %0, i8* %1) #0 { + %3 = alloca %struct.point2, align 8 + %4 = alloca %struct.point2, align 8 + %5 = bitcast %struct.point2* %4 to { i8*, i8* }* + %6 = getelementptr inbounds { i8*, i8* }, { i8*, i8* }* %5, i32 0, i32 0 + store i8* %0, i8** %6, align 8 + %7 = getelementptr inbounds { i8*, i8* }, { i8*, i8* }* %5, i32 0, i32 1 + store i8* %1, i8** %7, align 8 + %8 = bitcast %struct.point2* %3 to i8* + %9 = bitcast %struct.point2* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %8, i8* align 8 %9, i64 16, i1 false) + %10 = bitcast %struct.point2* %3 to { i8*, i8* }* + %11 = load { i8*, i8* }, { i8*, i8* }* %10, align 8 + ret { i8*, i8* } %11 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo3(%struct.point3* noalias sret(%struct.point3) align 8 %0, %struct.point3* noundef byval(%struct.point3) align 8 %1) #0 { + %3 = bitcast %struct.point3* %0 to i8* + %4 = bitcast %struct.point3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo4(%struct.point4* noalias sret(%struct.point4) align 8 %0, %struct.point4* noundef byval(%struct.point4) align 8 %1) #0 { + %3 = bitcast %struct.point4* %0 to i8* + %4 = bitcast %struct.point4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.point5* noalias sret(%struct.point5) align 8 %0, %struct.point5* noundef byval(%struct.point5) align 8 %1) #0 { + %3 = bitcast %struct.point5* %0 to i8* + %4 = bitcast %struct.point5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.point6* noalias sret(%struct.point6) align 8 %0, %struct.point6* noundef byval(%struct.point6) align 8 %1) #0 { + %3 = bitcast %struct.point6* %0 to i8* + %4 = bitcast %struct.point6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.point7* noalias sret(%struct.point7) align 8 %0, %struct.point7* noundef byval(%struct.point7) align 8 %1) #0 { + %3 = bitcast %struct.point7* %0 to i8* + %4 = bitcast %struct.point7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.point8* noalias sret(%struct.point8) align 8 %0, %struct.point8* noundef byval(%struct.point8) align 8 %1) #0 { + %3 = bitcast %struct.point8* %0 to i8* + %4 = bitcast %struct.point8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 8 %0, %struct.point9* noundef byval(%struct.point9) align 8 %1) #0 { + %3 = bitcast %struct.point9* %0 to i8* + %4 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 8 %0, %struct.point10* noundef byval(%struct.point10) align 8 %1) #0 { + %3 = bitcast %struct.point10* %0 to i8* + %4 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 8 %0, %struct.point11* noundef byval(%struct.point11) align 8 %1) #0 { + %3 = bitcast %struct.point11* %0 to i8* + %4 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 8 %0, %struct.point12* noundef byval(%struct.point12) align 8 %1) #0 { + %3 = bitcast %struct.point12* %0 to i8* + %4 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 8 %0, %struct.point13* noundef byval(%struct.point13) align 8 %1) #0 { + %3 = bitcast %struct.point13* %0 to i8* + %4 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 8 %0, %struct.point14* noundef byval(%struct.point14) align 8 %1) #0 { + %3 = bitcast %struct.point14* %0 to i8* + %4 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 8 %0, %struct.point15* noundef byval(%struct.point15) align 8 %1) #0 { + %3 = bitcast %struct.point15* %0 to i8* + %4 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 8 %0, %struct.point16* noundef byval(%struct.point16) align 8 %1) #0 { + %3 = bitcast %struct.point16* %0 to i8* + %4 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 8 %0, %struct.point17* noundef byval(%struct.point17) align 8 %1) #0 { + %3 = bitcast %struct.point17* %0 to i8* + %4 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 8 %0, %struct.point18* noundef byval(%struct.point18) align 8 %1) #0 { + %3 = bitcast %struct.point18* %0 to i8* + %4 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 8 %0, %struct.point19* noundef byval(%struct.point19) align 8 %1) #0 { + %3 = bitcast %struct.point19* %0 to i8* + %4 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 8 %0, %struct.point20* noundef byval(%struct.point20) align 8 %1) #0 { + %3 = bitcast %struct.point20* %0 to i8* + %4 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4} +!llvm.ident = !{!5} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{i32 7, !"frame-pointer", i32 2} +!5 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/arm64/array_float32.ll b/internal/cabi/_testdata/arch/arm64/array_float32.ll new file mode 100644 index 00000000..1d005bf8 --- /dev/null +++ b/internal/cabi/_testdata/arch/arm64/array_float32.ll @@ -0,0 +1,225 @@ +; ModuleID = '../../wrap/array_float32.c' +source_filename = "../../wrap/array_float32.c" +target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" +target triple = "aarch64-unknown-linux-gnu" + +%struct.array1 = type { [1 x float] } +%struct.array2 = type { [2 x float] } +%struct.array3 = type { [3 x float] } +%struct.array4 = type { [4 x float] } +%struct.array5 = type { [5 x float] } +%struct.array6 = type { [6 x float] } +%struct.array7 = type { [7 x float] } +%struct.array8 = type { [8 x float] } +%struct.array9 = type { [9 x float] } +%struct.array10 = type { [10 x float] } +%struct.array11 = type { [11 x float] } +%struct.array12 = type { [12 x float] } +%struct.array13 = type { [13 x float] } +%struct.array14 = type { [14 x float] } +%struct.array15 = type { [15 x float] } +%struct.array16 = type { [16 x float] } +%struct.array17 = type { [17 x float] } +%struct.array18 = type { [18 x float] } +%struct.array19 = type { [19 x float] } +%struct.array20 = type { [20 x float] } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local %struct.array1 @demo1([1 x float] %0) #0 { + %2 = alloca %struct.array1, align 4 + %3 = alloca %struct.array1, align 4 + %4 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + store [1 x float] %0, [1 x float]* %4, align 4 + %5 = bitcast %struct.array1* %2 to i8* + %6 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 4, i1 false) + %7 = load %struct.array1, %struct.array1* %2, align 4 + ret %struct.array1 %7 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local %struct.array2 @demo2([2 x float] %0) #0 { + %2 = alloca %struct.array2, align 4 + %3 = alloca %struct.array2, align 4 + %4 = getelementptr inbounds %struct.array2, %struct.array2* %3, i32 0, i32 0 + store [2 x float] %0, [2 x float]* %4, align 4 + %5 = bitcast %struct.array2* %2 to i8* + %6 = bitcast %struct.array2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 8, i1 false) + %7 = load %struct.array2, %struct.array2* %2, align 4 + ret %struct.array2 %7 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local %struct.array3 @demo3([3 x float] %0) #0 { + %2 = alloca %struct.array3, align 4 + %3 = alloca %struct.array3, align 4 + %4 = getelementptr inbounds %struct.array3, %struct.array3* %3, i32 0, i32 0 + store [3 x float] %0, [3 x float]* %4, align 4 + %5 = bitcast %struct.array3* %2 to i8* + %6 = bitcast %struct.array3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 12, i1 false) + %7 = load %struct.array3, %struct.array3* %2, align 4 + ret %struct.array3 %7 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local %struct.array4 @demo4([4 x float] %0) #0 { + %2 = alloca %struct.array4, align 4 + %3 = alloca %struct.array4, align 4 + %4 = getelementptr inbounds %struct.array4, %struct.array4* %3, i32 0, i32 0 + store [4 x float] %0, [4 x float]* %4, align 4 + %5 = bitcast %struct.array4* %2 to i8* + %6 = bitcast %struct.array4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 16, i1 false) + %7 = load %struct.array4, %struct.array4* %2, align 4 + ret %struct.array4 %7 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 4 %0, %struct.array5* noundef %1) #0 { + %3 = bitcast %struct.array5* %0 to i8* + %4 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 4 %0, %struct.array6* noundef %1) #0 { + %3 = bitcast %struct.array6* %0 to i8* + %4 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 4 %0, %struct.array7* noundef %1) #0 { + %3 = bitcast %struct.array7* %0 to i8* + %4 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 4 %0, %struct.array8* noundef %1) #0 { + %3 = bitcast %struct.array8* %0 to i8* + %4 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 4 %0, %struct.array9* noundef %1) #0 { + %3 = bitcast %struct.array9* %0 to i8* + %4 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 4 %0, %struct.array10* noundef %1) #0 { + %3 = bitcast %struct.array10* %0 to i8* + %4 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 4 %0, %struct.array11* noundef %1) #0 { + %3 = bitcast %struct.array11* %0 to i8* + %4 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 4 %0, %struct.array12* noundef %1) #0 { + %3 = bitcast %struct.array12* %0 to i8* + %4 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 4 %0, %struct.array13* noundef %1) #0 { + %3 = bitcast %struct.array13* %0 to i8* + %4 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 4 %0, %struct.array14* noundef %1) #0 { + %3 = bitcast %struct.array14* %0 to i8* + %4 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 4 %0, %struct.array15* noundef %1) #0 { + %3 = bitcast %struct.array15* %0 to i8* + %4 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 4 %0, %struct.array16* noundef %1) #0 { + %3 = bitcast %struct.array16* %0 to i8* + %4 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 4 %0, %struct.array17* noundef %1) #0 { + %3 = bitcast %struct.array17* %0 to i8* + %4 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 4 %0, %struct.array18* noundef %1) #0 { + %3 = bitcast %struct.array18* %0 to i8* + %4 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 4 %0, %struct.array19* noundef %1) #0 { + %3 = bitcast %struct.array19* %0 to i8* + %4 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 4 %0, %struct.array20* noundef %1) #0 { + %3 = bitcast %struct.array20* %0 to i8* + %4 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="non-leaf" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon,+v8a" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 8, !"branch-target-enforcement", i32 0} +!2 = !{i32 8, !"sign-return-address", i32 0} +!3 = !{i32 8, !"sign-return-address-all", i32 0} +!4 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!5 = !{i32 7, !"PIC Level", i32 2} +!6 = !{i32 7, !"PIE Level", i32 2} +!7 = !{i32 7, !"uwtable", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 1} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/arm64/array_float64.ll b/internal/cabi/_testdata/arch/arm64/array_float64.ll new file mode 100644 index 00000000..a82bb215 --- /dev/null +++ b/internal/cabi/_testdata/arch/arm64/array_float64.ll @@ -0,0 +1,225 @@ +; ModuleID = '../../wrap/array_float64.c' +source_filename = "../../wrap/array_float64.c" +target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" +target triple = "aarch64-unknown-linux-gnu" + +%struct.array1 = type { [1 x double] } +%struct.array2 = type { [2 x double] } +%struct.array3 = type { [3 x double] } +%struct.array4 = type { [4 x double] } +%struct.array5 = type { [5 x double] } +%struct.array6 = type { [6 x double] } +%struct.array7 = type { [7 x double] } +%struct.array8 = type { [8 x double] } +%struct.array9 = type { [9 x double] } +%struct.array10 = type { [10 x double] } +%struct.array11 = type { [11 x double] } +%struct.array12 = type { [12 x double] } +%struct.array13 = type { [13 x double] } +%struct.array14 = type { [14 x double] } +%struct.array15 = type { [15 x double] } +%struct.array16 = type { [16 x double] } +%struct.array17 = type { [17 x double] } +%struct.array18 = type { [18 x double] } +%struct.array19 = type { [19 x double] } +%struct.array20 = type { [20 x double] } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local %struct.array1 @demo1([1 x double] %0) #0 { + %2 = alloca %struct.array1, align 8 + %3 = alloca %struct.array1, align 8 + %4 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + store [1 x double] %0, [1 x double]* %4, align 8 + %5 = bitcast %struct.array1* %2 to i8* + %6 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 8, i1 false) + %7 = load %struct.array1, %struct.array1* %2, align 8 + ret %struct.array1 %7 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local %struct.array2 @demo2([2 x double] %0) #0 { + %2 = alloca %struct.array2, align 8 + %3 = alloca %struct.array2, align 8 + %4 = getelementptr inbounds %struct.array2, %struct.array2* %3, i32 0, i32 0 + store [2 x double] %0, [2 x double]* %4, align 8 + %5 = bitcast %struct.array2* %2 to i8* + %6 = bitcast %struct.array2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 16, i1 false) + %7 = load %struct.array2, %struct.array2* %2, align 8 + ret %struct.array2 %7 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local %struct.array3 @demo3([3 x double] %0) #0 { + %2 = alloca %struct.array3, align 8 + %3 = alloca %struct.array3, align 8 + %4 = getelementptr inbounds %struct.array3, %struct.array3* %3, i32 0, i32 0 + store [3 x double] %0, [3 x double]* %4, align 8 + %5 = bitcast %struct.array3* %2 to i8* + %6 = bitcast %struct.array3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 24, i1 false) + %7 = load %struct.array3, %struct.array3* %2, align 8 + ret %struct.array3 %7 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local %struct.array4 @demo4([4 x double] %0) #0 { + %2 = alloca %struct.array4, align 8 + %3 = alloca %struct.array4, align 8 + %4 = getelementptr inbounds %struct.array4, %struct.array4* %3, i32 0, i32 0 + store [4 x double] %0, [4 x double]* %4, align 8 + %5 = bitcast %struct.array4* %2 to i8* + %6 = bitcast %struct.array4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 32, i1 false) + %7 = load %struct.array4, %struct.array4* %2, align 8 + ret %struct.array4 %7 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 8 %0, %struct.array5* noundef %1) #0 { + %3 = bitcast %struct.array5* %0 to i8* + %4 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 8 %0, %struct.array6* noundef %1) #0 { + %3 = bitcast %struct.array6* %0 to i8* + %4 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 8 %0, %struct.array7* noundef %1) #0 { + %3 = bitcast %struct.array7* %0 to i8* + %4 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 8 %0, %struct.array8* noundef %1) #0 { + %3 = bitcast %struct.array8* %0 to i8* + %4 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 8 %0, %struct.array9* noundef %1) #0 { + %3 = bitcast %struct.array9* %0 to i8* + %4 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 8 %0, %struct.array10* noundef %1) #0 { + %3 = bitcast %struct.array10* %0 to i8* + %4 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 8 %0, %struct.array11* noundef %1) #0 { + %3 = bitcast %struct.array11* %0 to i8* + %4 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 8 %0, %struct.array12* noundef %1) #0 { + %3 = bitcast %struct.array12* %0 to i8* + %4 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 8 %0, %struct.array13* noundef %1) #0 { + %3 = bitcast %struct.array13* %0 to i8* + %4 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 8 %0, %struct.array14* noundef %1) #0 { + %3 = bitcast %struct.array14* %0 to i8* + %4 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 8 %0, %struct.array15* noundef %1) #0 { + %3 = bitcast %struct.array15* %0 to i8* + %4 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 8 %0, %struct.array16* noundef %1) #0 { + %3 = bitcast %struct.array16* %0 to i8* + %4 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 8 %0, %struct.array17* noundef %1) #0 { + %3 = bitcast %struct.array17* %0 to i8* + %4 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 8 %0, %struct.array18* noundef %1) #0 { + %3 = bitcast %struct.array18* %0 to i8* + %4 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 8 %0, %struct.array19* noundef %1) #0 { + %3 = bitcast %struct.array19* %0 to i8* + %4 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 8 %0, %struct.array20* noundef %1) #0 { + %3 = bitcast %struct.array20* %0 to i8* + %4 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="non-leaf" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon,+v8a" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 8, !"branch-target-enforcement", i32 0} +!2 = !{i32 8, !"sign-return-address", i32 0} +!3 = !{i32 8, !"sign-return-address-all", i32 0} +!4 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!5 = !{i32 7, !"PIC Level", i32 2} +!6 = !{i32 7, !"PIE Level", i32 2} +!7 = !{i32 7, !"uwtable", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 1} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/arm64/array_int16.ll b/internal/cabi/_testdata/arch/arm64/array_int16.ll new file mode 100644 index 00000000..ea3c40a8 --- /dev/null +++ b/internal/cabi/_testdata/arch/arm64/array_int16.ll @@ -0,0 +1,299 @@ +; ModuleID = '../../wrap/array_int16.c' +source_filename = "../../wrap/array_int16.c" +target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" +target triple = "aarch64-unknown-linux-gnu" + +%struct.array1 = type { [1 x i16] } +%struct.array2 = type { [2 x i16] } +%struct.array3 = type { [3 x i16] } +%struct.array4 = type { [4 x i16] } +%struct.array5 = type { [5 x i16] } +%struct.array6 = type { [6 x i16] } +%struct.array7 = type { [7 x i16] } +%struct.array8 = type { [8 x i16] } +%struct.array9 = type { [9 x i16] } +%struct.array10 = type { [10 x i16] } +%struct.array11 = type { [11 x i16] } +%struct.array12 = type { [12 x i16] } +%struct.array13 = type { [13 x i16] } +%struct.array14 = type { [14 x i16] } +%struct.array15 = type { [15 x i16] } +%struct.array16 = type { [16 x i16] } +%struct.array17 = type { [17 x i16] } +%struct.array18 = type { [18 x i16] } +%struct.array19 = type { [19 x i16] } +%struct.array20 = type { [20 x i16] } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i16 @demo1(i64 %0) #0 { + %2 = alloca %struct.array1, align 2 + %3 = alloca %struct.array1, align 2 + %4 = alloca i64, align 8 + %5 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + store i64 %0, i64* %4, align 8 + %6 = bitcast [1 x i16]* %5 to i8* + %7 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %6, i8* align 8 %7, i64 2, i1 false) + %8 = bitcast %struct.array1* %2 to i8* + %9 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %8, i8* align 2 %9, i64 2, i1 false) + %10 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %11 = bitcast [1 x i16]* %10 to i16* + %12 = load i16, i16* %11, align 2 + ret i16 %12 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i32 @demo2(i64 %0) #0 { + %2 = alloca %struct.array2, align 2 + %3 = alloca %struct.array2, align 2 + %4 = alloca i64, align 8 + %5 = getelementptr inbounds %struct.array2, %struct.array2* %3, i32 0, i32 0 + store i64 %0, i64* %4, align 8 + %6 = bitcast [2 x i16]* %5 to i8* + %7 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %6, i8* align 8 %7, i64 4, i1 false) + %8 = bitcast %struct.array2* %2 to i8* + %9 = bitcast %struct.array2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %8, i8* align 2 %9, i64 4, i1 false) + %10 = getelementptr inbounds %struct.array2, %struct.array2* %2, i32 0, i32 0 + %11 = bitcast [2 x i16]* %10 to i32* + %12 = load i32, i32* %11, align 2 + ret i32 %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i48 @demo3(i64 %0) #0 { + %2 = alloca %struct.array3, align 2 + %3 = alloca %struct.array3, align 2 + %4 = alloca i64, align 8 + %5 = alloca i48, align 8 + %6 = getelementptr inbounds %struct.array3, %struct.array3* %3, i32 0, i32 0 + store i64 %0, i64* %4, align 8 + %7 = bitcast [3 x i16]* %6 to i8* + %8 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %7, i8* align 8 %8, i64 6, i1 false) + %9 = bitcast %struct.array3* %2 to i8* + %10 = bitcast %struct.array3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %9, i8* align 2 %10, i64 6, i1 false) + %11 = getelementptr inbounds %struct.array3, %struct.array3* %2, i32 0, i32 0 + %12 = bitcast i48* %5 to i8* + %13 = bitcast [3 x i16]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 2 %13, i64 6, i1 false) + %14 = load i48, i48* %5, align 8 + ret i48 %14 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i64 @demo4(i64 %0) #0 { + %2 = alloca %struct.array4, align 2 + %3 = alloca %struct.array4, align 2 + %4 = getelementptr inbounds %struct.array4, %struct.array4* %3, i32 0, i32 0 + %5 = bitcast [4 x i16]* %4 to i64* + store i64 %0, i64* %5, align 2 + %6 = bitcast %struct.array4* %2 to i8* + %7 = bitcast %struct.array4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %6, i8* align 2 %7, i64 8, i1 false) + %8 = getelementptr inbounds %struct.array4, %struct.array4* %2, i32 0, i32 0 + %9 = bitcast [4 x i16]* %8 to i64* + %10 = load i64, i64* %9, align 2 + ret i64 %10 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo5([2 x i64] %0) #0 { + %2 = alloca %struct.array5, align 2 + %3 = alloca %struct.array5, align 2 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + %6 = getelementptr inbounds %struct.array5, %struct.array5* %3, i32 0, i32 0 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %7 = bitcast [5 x i16]* %6 to i8* + %8 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %7, i8* align 8 %8, i64 10, i1 false) + %9 = bitcast %struct.array5* %2 to i8* + %10 = bitcast %struct.array5* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %9, i8* align 2 %10, i64 10, i1 false) + %11 = getelementptr inbounds %struct.array5, %struct.array5* %2, i32 0, i32 0 + %12 = bitcast [2 x i64]* %5 to i8* + %13 = bitcast [5 x i16]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 2 %13, i64 10, i1 false) + %14 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %14 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo6([2 x i64] %0) #0 { + %2 = alloca %struct.array6, align 2 + %3 = alloca %struct.array6, align 2 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + %6 = getelementptr inbounds %struct.array6, %struct.array6* %3, i32 0, i32 0 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %7 = bitcast [6 x i16]* %6 to i8* + %8 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %7, i8* align 8 %8, i64 12, i1 false) + %9 = bitcast %struct.array6* %2 to i8* + %10 = bitcast %struct.array6* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %9, i8* align 2 %10, i64 12, i1 false) + %11 = getelementptr inbounds %struct.array6, %struct.array6* %2, i32 0, i32 0 + %12 = bitcast [2 x i64]* %5 to i8* + %13 = bitcast [6 x i16]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 2 %13, i64 12, i1 false) + %14 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %14 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo7([2 x i64] %0) #0 { + %2 = alloca %struct.array7, align 2 + %3 = alloca %struct.array7, align 2 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + %6 = getelementptr inbounds %struct.array7, %struct.array7* %3, i32 0, i32 0 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %7 = bitcast [7 x i16]* %6 to i8* + %8 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %7, i8* align 8 %8, i64 14, i1 false) + %9 = bitcast %struct.array7* %2 to i8* + %10 = bitcast %struct.array7* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %9, i8* align 2 %10, i64 14, i1 false) + %11 = getelementptr inbounds %struct.array7, %struct.array7* %2, i32 0, i32 0 + %12 = bitcast [2 x i64]* %5 to i8* + %13 = bitcast [7 x i16]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 2 %13, i64 14, i1 false) + %14 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %14 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo8([2 x i64] %0) #0 { + %2 = alloca %struct.array8, align 2 + %3 = alloca %struct.array8, align 2 + %4 = getelementptr inbounds %struct.array8, %struct.array8* %3, i32 0, i32 0 + %5 = bitcast [8 x i16]* %4 to [2 x i64]* + store [2 x i64] %0, [2 x i64]* %5, align 2 + %6 = bitcast %struct.array8* %2 to i8* + %7 = bitcast %struct.array8* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %6, i8* align 2 %7, i64 16, i1 false) + %8 = getelementptr inbounds %struct.array8, %struct.array8* %2, i32 0, i32 0 + %9 = bitcast [8 x i16]* %8 to [2 x i64]* + %10 = load [2 x i64], [2 x i64]* %9, align 2 + ret [2 x i64] %10 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 2 %0, %struct.array9* noundef %1) #0 { + %3 = bitcast %struct.array9* %0 to i8* + %4 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 2 %4, i64 18, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 2 %0, %struct.array10* noundef %1) #0 { + %3 = bitcast %struct.array10* %0 to i8* + %4 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 2 %4, i64 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 2 %0, %struct.array11* noundef %1) #0 { + %3 = bitcast %struct.array11* %0 to i8* + %4 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 2 %4, i64 22, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 2 %0, %struct.array12* noundef %1) #0 { + %3 = bitcast %struct.array12* %0 to i8* + %4 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 2 %4, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 2 %0, %struct.array13* noundef %1) #0 { + %3 = bitcast %struct.array13* %0 to i8* + %4 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 2 %4, i64 26, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 2 %0, %struct.array14* noundef %1) #0 { + %3 = bitcast %struct.array14* %0 to i8* + %4 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 2 %4, i64 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 2 %0, %struct.array15* noundef %1) #0 { + %3 = bitcast %struct.array15* %0 to i8* + %4 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 2 %4, i64 30, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 2 %0, %struct.array16* noundef %1) #0 { + %3 = bitcast %struct.array16* %0 to i8* + %4 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 2 %4, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 2 %0, %struct.array17* noundef %1) #0 { + %3 = bitcast %struct.array17* %0 to i8* + %4 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 2 %4, i64 34, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 2 %0, %struct.array18* noundef %1) #0 { + %3 = bitcast %struct.array18* %0 to i8* + %4 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 2 %4, i64 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 2 %0, %struct.array19* noundef %1) #0 { + %3 = bitcast %struct.array19* %0 to i8* + %4 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 2 %4, i64 38, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 2 %0, %struct.array20* noundef %1) #0 { + %3 = bitcast %struct.array20* %0 to i8* + %4 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 2 %4, i64 40, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="non-leaf" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon,+v8a" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 8, !"branch-target-enforcement", i32 0} +!2 = !{i32 8, !"sign-return-address", i32 0} +!3 = !{i32 8, !"sign-return-address-all", i32 0} +!4 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!5 = !{i32 7, !"PIC Level", i32 2} +!6 = !{i32 7, !"PIE Level", i32 2} +!7 = !{i32 7, !"uwtable", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 1} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/arm64/array_int32.ll b/internal/cabi/_testdata/arch/arm64/array_int32.ll new file mode 100644 index 00000000..be330c4f --- /dev/null +++ b/internal/cabi/_testdata/arch/arm64/array_int32.ll @@ -0,0 +1,246 @@ +; ModuleID = '../../wrap/array_int32.c' +source_filename = "../../wrap/array_int32.c" +target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" +target triple = "aarch64-unknown-linux-gnu" + +%struct.array1 = type { [1 x i32] } +%struct.array2 = type { [2 x i32] } +%struct.array3 = type { [3 x i32] } +%struct.array4 = type { [4 x i32] } +%struct.array5 = type { [5 x i32] } +%struct.array6 = type { [6 x i32] } +%struct.array7 = type { [7 x i32] } +%struct.array8 = type { [8 x i32] } +%struct.array9 = type { [9 x i32] } +%struct.array10 = type { [10 x i32] } +%struct.array11 = type { [11 x i32] } +%struct.array12 = type { [12 x i32] } +%struct.array13 = type { [13 x i32] } +%struct.array14 = type { [14 x i32] } +%struct.array15 = type { [15 x i32] } +%struct.array16 = type { [16 x i32] } +%struct.array17 = type { [17 x i32] } +%struct.array18 = type { [18 x i32] } +%struct.array19 = type { [19 x i32] } +%struct.array20 = type { [20 x i32] } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i32 @demo1(i64 %0) #0 { + %2 = alloca %struct.array1, align 4 + %3 = alloca %struct.array1, align 4 + %4 = alloca i64, align 8 + %5 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + store i64 %0, i64* %4, align 8 + %6 = bitcast [1 x i32]* %5 to i8* + %7 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %6, i8* align 8 %7, i64 4, i1 false) + %8 = bitcast %struct.array1* %2 to i8* + %9 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %8, i8* align 4 %9, i64 4, i1 false) + %10 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %11 = bitcast [1 x i32]* %10 to i32* + %12 = load i32, i32* %11, align 4 + ret i32 %12 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i64 @demo2(i64 %0) #0 { + %2 = alloca %struct.array2, align 4 + %3 = alloca %struct.array2, align 4 + %4 = getelementptr inbounds %struct.array2, %struct.array2* %3, i32 0, i32 0 + %5 = bitcast [2 x i32]* %4 to i64* + store i64 %0, i64* %5, align 4 + %6 = bitcast %struct.array2* %2 to i8* + %7 = bitcast %struct.array2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %6, i8* align 4 %7, i64 8, i1 false) + %8 = getelementptr inbounds %struct.array2, %struct.array2* %2, i32 0, i32 0 + %9 = bitcast [2 x i32]* %8 to i64* + %10 = load i64, i64* %9, align 4 + ret i64 %10 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo3([2 x i64] %0) #0 { + %2 = alloca %struct.array3, align 4 + %3 = alloca %struct.array3, align 4 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + %6 = getelementptr inbounds %struct.array3, %struct.array3* %3, i32 0, i32 0 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %7 = bitcast [3 x i32]* %6 to i8* + %8 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %7, i8* align 8 %8, i64 12, i1 false) + %9 = bitcast %struct.array3* %2 to i8* + %10 = bitcast %struct.array3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %9, i8* align 4 %10, i64 12, i1 false) + %11 = getelementptr inbounds %struct.array3, %struct.array3* %2, i32 0, i32 0 + %12 = bitcast [2 x i64]* %5 to i8* + %13 = bitcast [3 x i32]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 4 %13, i64 12, i1 false) + %14 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %14 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo4([2 x i64] %0) #0 { + %2 = alloca %struct.array4, align 4 + %3 = alloca %struct.array4, align 4 + %4 = getelementptr inbounds %struct.array4, %struct.array4* %3, i32 0, i32 0 + %5 = bitcast [4 x i32]* %4 to [2 x i64]* + store [2 x i64] %0, [2 x i64]* %5, align 4 + %6 = bitcast %struct.array4* %2 to i8* + %7 = bitcast %struct.array4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %6, i8* align 4 %7, i64 16, i1 false) + %8 = getelementptr inbounds %struct.array4, %struct.array4* %2, i32 0, i32 0 + %9 = bitcast [4 x i32]* %8 to [2 x i64]* + %10 = load [2 x i64], [2 x i64]* %9, align 4 + ret [2 x i64] %10 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 4 %0, %struct.array5* noundef %1) #0 { + %3 = bitcast %struct.array5* %0 to i8* + %4 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 4 %0, %struct.array6* noundef %1) #0 { + %3 = bitcast %struct.array6* %0 to i8* + %4 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 4 %0, %struct.array7* noundef %1) #0 { + %3 = bitcast %struct.array7* %0 to i8* + %4 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 4 %0, %struct.array8* noundef %1) #0 { + %3 = bitcast %struct.array8* %0 to i8* + %4 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 4 %0, %struct.array9* noundef %1) #0 { + %3 = bitcast %struct.array9* %0 to i8* + %4 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 4 %0, %struct.array10* noundef %1) #0 { + %3 = bitcast %struct.array10* %0 to i8* + %4 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 4 %0, %struct.array11* noundef %1) #0 { + %3 = bitcast %struct.array11* %0 to i8* + %4 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 4 %0, %struct.array12* noundef %1) #0 { + %3 = bitcast %struct.array12* %0 to i8* + %4 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 4 %0, %struct.array13* noundef %1) #0 { + %3 = bitcast %struct.array13* %0 to i8* + %4 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 4 %0, %struct.array14* noundef %1) #0 { + %3 = bitcast %struct.array14* %0 to i8* + %4 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 4 %0, %struct.array15* noundef %1) #0 { + %3 = bitcast %struct.array15* %0 to i8* + %4 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 4 %0, %struct.array16* noundef %1) #0 { + %3 = bitcast %struct.array16* %0 to i8* + %4 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 4 %0, %struct.array17* noundef %1) #0 { + %3 = bitcast %struct.array17* %0 to i8* + %4 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 4 %0, %struct.array18* noundef %1) #0 { + %3 = bitcast %struct.array18* %0 to i8* + %4 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 4 %0, %struct.array19* noundef %1) #0 { + %3 = bitcast %struct.array19* %0 to i8* + %4 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 4 %0, %struct.array20* noundef %1) #0 { + %3 = bitcast %struct.array20* %0 to i8* + %4 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="non-leaf" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon,+v8a" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 8, !"branch-target-enforcement", i32 0} +!2 = !{i32 8, !"sign-return-address", i32 0} +!3 = !{i32 8, !"sign-return-address-all", i32 0} +!4 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!5 = !{i32 7, !"PIC Level", i32 2} +!6 = !{i32 7, !"PIE Level", i32 2} +!7 = !{i32 7, !"uwtable", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 1} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/arm64/array_int64.ll b/internal/cabi/_testdata/arch/arm64/array_int64.ll new file mode 100644 index 00000000..f65dcef6 --- /dev/null +++ b/internal/cabi/_testdata/arch/arm64/array_int64.ll @@ -0,0 +1,219 @@ +; ModuleID = '../../wrap/array_int64.c' +source_filename = "../../wrap/array_int64.c" +target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" +target triple = "aarch64-unknown-linux-gnu" + +%struct.array1 = type { [1 x i64] } +%struct.array2 = type { [2 x i64] } +%struct.array3 = type { [3 x i64] } +%struct.array4 = type { [4 x i64] } +%struct.array5 = type { [5 x i64] } +%struct.array6 = type { [6 x i64] } +%struct.array7 = type { [7 x i64] } +%struct.array8 = type { [8 x i64] } +%struct.array9 = type { [9 x i64] } +%struct.array10 = type { [10 x i64] } +%struct.array11 = type { [11 x i64] } +%struct.array12 = type { [12 x i64] } +%struct.array13 = type { [13 x i64] } +%struct.array14 = type { [14 x i64] } +%struct.array15 = type { [15 x i64] } +%struct.array16 = type { [16 x i64] } +%struct.array17 = type { [17 x i64] } +%struct.array18 = type { [18 x i64] } +%struct.array19 = type { [19 x i64] } +%struct.array20 = type { [20 x i64] } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i64 @demo1(i64 %0) #0 { + %2 = alloca %struct.array1, align 8 + %3 = alloca %struct.array1, align 8 + %4 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + %5 = bitcast [1 x i64]* %4 to i64* + store i64 %0, i64* %5, align 8 + %6 = bitcast %struct.array1* %2 to i8* + %7 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %6, i8* align 8 %7, i64 8, i1 false) + %8 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %9 = bitcast [1 x i64]* %8 to i64* + %10 = load i64, i64* %9, align 8 + ret i64 %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo2([2 x i64] %0) #0 { + %2 = alloca %struct.array2, align 8 + %3 = alloca %struct.array2, align 8 + %4 = getelementptr inbounds %struct.array2, %struct.array2* %3, i32 0, i32 0 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %5 = bitcast %struct.array2* %2 to i8* + %6 = bitcast %struct.array2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 16, i1 false) + %7 = getelementptr inbounds %struct.array2, %struct.array2* %2, i32 0, i32 0 + %8 = load [2 x i64], [2 x i64]* %7, align 8 + ret [2 x i64] %8 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo3(%struct.array3* noalias sret(%struct.array3) align 8 %0, %struct.array3* noundef %1) #0 { + %3 = bitcast %struct.array3* %0 to i8* + %4 = bitcast %struct.array3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo4(%struct.array4* noalias sret(%struct.array4) align 8 %0, %struct.array4* noundef %1) #0 { + %3 = bitcast %struct.array4* %0 to i8* + %4 = bitcast %struct.array4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 8 %0, %struct.array5* noundef %1) #0 { + %3 = bitcast %struct.array5* %0 to i8* + %4 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 8 %0, %struct.array6* noundef %1) #0 { + %3 = bitcast %struct.array6* %0 to i8* + %4 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 8 %0, %struct.array7* noundef %1) #0 { + %3 = bitcast %struct.array7* %0 to i8* + %4 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 8 %0, %struct.array8* noundef %1) #0 { + %3 = bitcast %struct.array8* %0 to i8* + %4 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 8 %0, %struct.array9* noundef %1) #0 { + %3 = bitcast %struct.array9* %0 to i8* + %4 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 8 %0, %struct.array10* noundef %1) #0 { + %3 = bitcast %struct.array10* %0 to i8* + %4 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 8 %0, %struct.array11* noundef %1) #0 { + %3 = bitcast %struct.array11* %0 to i8* + %4 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 8 %0, %struct.array12* noundef %1) #0 { + %3 = bitcast %struct.array12* %0 to i8* + %4 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 8 %0, %struct.array13* noundef %1) #0 { + %3 = bitcast %struct.array13* %0 to i8* + %4 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 8 %0, %struct.array14* noundef %1) #0 { + %3 = bitcast %struct.array14* %0 to i8* + %4 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 8 %0, %struct.array15* noundef %1) #0 { + %3 = bitcast %struct.array15* %0 to i8* + %4 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 8 %0, %struct.array16* noundef %1) #0 { + %3 = bitcast %struct.array16* %0 to i8* + %4 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 8 %0, %struct.array17* noundef %1) #0 { + %3 = bitcast %struct.array17* %0 to i8* + %4 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 8 %0, %struct.array18* noundef %1) #0 { + %3 = bitcast %struct.array18* %0 to i8* + %4 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 8 %0, %struct.array19* noundef %1) #0 { + %3 = bitcast %struct.array19* %0 to i8* + %4 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 8 %0, %struct.array20* noundef %1) #0 { + %3 = bitcast %struct.array20* %0 to i8* + %4 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="non-leaf" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon,+v8a" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 8, !"branch-target-enforcement", i32 0} +!2 = !{i32 8, !"sign-return-address", i32 0} +!3 = !{i32 8, !"sign-return-address-all", i32 0} +!4 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!5 = !{i32 7, !"PIC Level", i32 2} +!6 = !{i32 7, !"PIE Level", i32 2} +!7 = !{i32 7, !"uwtable", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 1} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/arm64/array_int8.ll b/internal/cabi/_testdata/arch/arm64/array_int8.ll new file mode 100644 index 00000000..8f539ce5 --- /dev/null +++ b/internal/cabi/_testdata/arch/arm64/array_int8.ll @@ -0,0 +1,408 @@ +; ModuleID = '../../wrap/array_int8.c' +source_filename = "../../wrap/array_int8.c" +target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" +target triple = "aarch64-unknown-linux-gnu" + +%struct.array1 = type { [1 x i8] } +%struct.array2 = type { [2 x i8] } +%struct.array3 = type { [3 x i8] } +%struct.array4 = type { [4 x i8] } +%struct.array5 = type { [5 x i8] } +%struct.array6 = type { [6 x i8] } +%struct.array7 = type { [7 x i8] } +%struct.array8 = type { [8 x i8] } +%struct.array9 = type { [9 x i8] } +%struct.array10 = type { [10 x i8] } +%struct.array11 = type { [11 x i8] } +%struct.array12 = type { [12 x i8] } +%struct.array13 = type { [13 x i8] } +%struct.array14 = type { [14 x i8] } +%struct.array15 = type { [15 x i8] } +%struct.array16 = type { [16 x i8] } +%struct.array17 = type { [17 x i8] } +%struct.array18 = type { [18 x i8] } +%struct.array19 = type { [19 x i8] } +%struct.array20 = type { [20 x i8] } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i8 @demo1(i64 %0) #0 { + %2 = alloca %struct.array1, align 1 + %3 = alloca %struct.array1, align 1 + %4 = alloca i64, align 8 + %5 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + store i64 %0, i64* %4, align 8 + %6 = bitcast [1 x i8]* %5 to i8* + %7 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 8 %7, i64 1, i1 false) + %8 = bitcast %struct.array1* %2 to i8* + %9 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 1, i1 false) + %10 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %11 = bitcast [1 x i8]* %10 to i8* + %12 = load i8, i8* %11, align 1 + ret i8 %12 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i16 @demo2(i64 %0) #0 { + %2 = alloca %struct.array2, align 1 + %3 = alloca %struct.array2, align 1 + %4 = alloca i64, align 8 + %5 = getelementptr inbounds %struct.array2, %struct.array2* %3, i32 0, i32 0 + store i64 %0, i64* %4, align 8 + %6 = bitcast [2 x i8]* %5 to i8* + %7 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 8 %7, i64 2, i1 false) + %8 = bitcast %struct.array2* %2 to i8* + %9 = bitcast %struct.array2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 2, i1 false) + %10 = getelementptr inbounds %struct.array2, %struct.array2* %2, i32 0, i32 0 + %11 = bitcast [2 x i8]* %10 to i16* + %12 = load i16, i16* %11, align 1 + ret i16 %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i24 @demo3(i64 %0) #0 { + %2 = alloca %struct.array3, align 1 + %3 = alloca %struct.array3, align 1 + %4 = alloca i64, align 8 + %5 = alloca i24, align 4 + %6 = getelementptr inbounds %struct.array3, %struct.array3* %3, i32 0, i32 0 + store i64 %0, i64* %4, align 8 + %7 = bitcast [3 x i8]* %6 to i8* + %8 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 8 %8, i64 3, i1 false) + %9 = bitcast %struct.array3* %2 to i8* + %10 = bitcast %struct.array3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 3, i1 false) + %11 = getelementptr inbounds %struct.array3, %struct.array3* %2, i32 0, i32 0 + %12 = bitcast i24* %5 to i8* + %13 = bitcast [3 x i8]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %12, i8* align 1 %13, i64 3, i1 false) + %14 = load i24, i24* %5, align 4 + ret i24 %14 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i32 @demo4(i64 %0) #0 { + %2 = alloca %struct.array4, align 1 + %3 = alloca %struct.array4, align 1 + %4 = alloca i64, align 8 + %5 = getelementptr inbounds %struct.array4, %struct.array4* %3, i32 0, i32 0 + store i64 %0, i64* %4, align 8 + %6 = bitcast [4 x i8]* %5 to i8* + %7 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 8 %7, i64 4, i1 false) + %8 = bitcast %struct.array4* %2 to i8* + %9 = bitcast %struct.array4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 4, i1 false) + %10 = getelementptr inbounds %struct.array4, %struct.array4* %2, i32 0, i32 0 + %11 = bitcast [4 x i8]* %10 to i32* + %12 = load i32, i32* %11, align 1 + ret i32 %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i40 @demo5(i64 %0) #0 { + %2 = alloca %struct.array5, align 1 + %3 = alloca %struct.array5, align 1 + %4 = alloca i64, align 8 + %5 = alloca i40, align 8 + %6 = getelementptr inbounds %struct.array5, %struct.array5* %3, i32 0, i32 0 + store i64 %0, i64* %4, align 8 + %7 = bitcast [5 x i8]* %6 to i8* + %8 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 8 %8, i64 5, i1 false) + %9 = bitcast %struct.array5* %2 to i8* + %10 = bitcast %struct.array5* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 5, i1 false) + %11 = getelementptr inbounds %struct.array5, %struct.array5* %2, i32 0, i32 0 + %12 = bitcast i40* %5 to i8* + %13 = bitcast [5 x i8]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 1 %13, i64 5, i1 false) + %14 = load i40, i40* %5, align 8 + ret i40 %14 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i48 @demo6(i64 %0) #0 { + %2 = alloca %struct.array6, align 1 + %3 = alloca %struct.array6, align 1 + %4 = alloca i64, align 8 + %5 = alloca i48, align 8 + %6 = getelementptr inbounds %struct.array6, %struct.array6* %3, i32 0, i32 0 + store i64 %0, i64* %4, align 8 + %7 = bitcast [6 x i8]* %6 to i8* + %8 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 8 %8, i64 6, i1 false) + %9 = bitcast %struct.array6* %2 to i8* + %10 = bitcast %struct.array6* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 6, i1 false) + %11 = getelementptr inbounds %struct.array6, %struct.array6* %2, i32 0, i32 0 + %12 = bitcast i48* %5 to i8* + %13 = bitcast [6 x i8]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 1 %13, i64 6, i1 false) + %14 = load i48, i48* %5, align 8 + ret i48 %14 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i56 @demo7(i64 %0) #0 { + %2 = alloca %struct.array7, align 1 + %3 = alloca %struct.array7, align 1 + %4 = alloca i64, align 8 + %5 = alloca i56, align 8 + %6 = getelementptr inbounds %struct.array7, %struct.array7* %3, i32 0, i32 0 + store i64 %0, i64* %4, align 8 + %7 = bitcast [7 x i8]* %6 to i8* + %8 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 8 %8, i64 7, i1 false) + %9 = bitcast %struct.array7* %2 to i8* + %10 = bitcast %struct.array7* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 7, i1 false) + %11 = getelementptr inbounds %struct.array7, %struct.array7* %2, i32 0, i32 0 + %12 = bitcast i56* %5 to i8* + %13 = bitcast [7 x i8]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 1 %13, i64 7, i1 false) + %14 = load i56, i56* %5, align 8 + ret i56 %14 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i64 @demo8(i64 %0) #0 { + %2 = alloca %struct.array8, align 1 + %3 = alloca %struct.array8, align 1 + %4 = getelementptr inbounds %struct.array8, %struct.array8* %3, i32 0, i32 0 + %5 = bitcast [8 x i8]* %4 to i64* + store i64 %0, i64* %5, align 1 + %6 = bitcast %struct.array8* %2 to i8* + %7 = bitcast %struct.array8* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 1 %7, i64 8, i1 false) + %8 = getelementptr inbounds %struct.array8, %struct.array8* %2, i32 0, i32 0 + %9 = bitcast [8 x i8]* %8 to i64* + %10 = load i64, i64* %9, align 1 + ret i64 %10 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo9([2 x i64] %0) #0 { + %2 = alloca %struct.array9, align 1 + %3 = alloca %struct.array9, align 1 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + %6 = getelementptr inbounds %struct.array9, %struct.array9* %3, i32 0, i32 0 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %7 = bitcast [9 x i8]* %6 to i8* + %8 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 8 %8, i64 9, i1 false) + %9 = bitcast %struct.array9* %2 to i8* + %10 = bitcast %struct.array9* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 9, i1 false) + %11 = getelementptr inbounds %struct.array9, %struct.array9* %2, i32 0, i32 0 + %12 = bitcast [2 x i64]* %5 to i8* + %13 = bitcast [9 x i8]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 1 %13, i64 9, i1 false) + %14 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %14 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo10([2 x i64] %0) #0 { + %2 = alloca %struct.array10, align 1 + %3 = alloca %struct.array10, align 1 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + %6 = getelementptr inbounds %struct.array10, %struct.array10* %3, i32 0, i32 0 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %7 = bitcast [10 x i8]* %6 to i8* + %8 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 8 %8, i64 10, i1 false) + %9 = bitcast %struct.array10* %2 to i8* + %10 = bitcast %struct.array10* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 10, i1 false) + %11 = getelementptr inbounds %struct.array10, %struct.array10* %2, i32 0, i32 0 + %12 = bitcast [2 x i64]* %5 to i8* + %13 = bitcast [10 x i8]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 1 %13, i64 10, i1 false) + %14 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %14 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo11([2 x i64] %0) #0 { + %2 = alloca %struct.array11, align 1 + %3 = alloca %struct.array11, align 1 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + %6 = getelementptr inbounds %struct.array11, %struct.array11* %3, i32 0, i32 0 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %7 = bitcast [11 x i8]* %6 to i8* + %8 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 8 %8, i64 11, i1 false) + %9 = bitcast %struct.array11* %2 to i8* + %10 = bitcast %struct.array11* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 11, i1 false) + %11 = getelementptr inbounds %struct.array11, %struct.array11* %2, i32 0, i32 0 + %12 = bitcast [2 x i64]* %5 to i8* + %13 = bitcast [11 x i8]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 1 %13, i64 11, i1 false) + %14 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %14 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo12([2 x i64] %0) #0 { + %2 = alloca %struct.array12, align 1 + %3 = alloca %struct.array12, align 1 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + %6 = getelementptr inbounds %struct.array12, %struct.array12* %3, i32 0, i32 0 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %7 = bitcast [12 x i8]* %6 to i8* + %8 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 8 %8, i64 12, i1 false) + %9 = bitcast %struct.array12* %2 to i8* + %10 = bitcast %struct.array12* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 12, i1 false) + %11 = getelementptr inbounds %struct.array12, %struct.array12* %2, i32 0, i32 0 + %12 = bitcast [2 x i64]* %5 to i8* + %13 = bitcast [12 x i8]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 1 %13, i64 12, i1 false) + %14 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %14 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo13([2 x i64] %0) #0 { + %2 = alloca %struct.array13, align 1 + %3 = alloca %struct.array13, align 1 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + %6 = getelementptr inbounds %struct.array13, %struct.array13* %3, i32 0, i32 0 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %7 = bitcast [13 x i8]* %6 to i8* + %8 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 8 %8, i64 13, i1 false) + %9 = bitcast %struct.array13* %2 to i8* + %10 = bitcast %struct.array13* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 13, i1 false) + %11 = getelementptr inbounds %struct.array13, %struct.array13* %2, i32 0, i32 0 + %12 = bitcast [2 x i64]* %5 to i8* + %13 = bitcast [13 x i8]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 1 %13, i64 13, i1 false) + %14 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %14 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo14([2 x i64] %0) #0 { + %2 = alloca %struct.array14, align 1 + %3 = alloca %struct.array14, align 1 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + %6 = getelementptr inbounds %struct.array14, %struct.array14* %3, i32 0, i32 0 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %7 = bitcast [14 x i8]* %6 to i8* + %8 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 8 %8, i64 14, i1 false) + %9 = bitcast %struct.array14* %2 to i8* + %10 = bitcast %struct.array14* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 14, i1 false) + %11 = getelementptr inbounds %struct.array14, %struct.array14* %2, i32 0, i32 0 + %12 = bitcast [2 x i64]* %5 to i8* + %13 = bitcast [14 x i8]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 1 %13, i64 14, i1 false) + %14 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %14 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo15([2 x i64] %0) #0 { + %2 = alloca %struct.array15, align 1 + %3 = alloca %struct.array15, align 1 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + %6 = getelementptr inbounds %struct.array15, %struct.array15* %3, i32 0, i32 0 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %7 = bitcast [15 x i8]* %6 to i8* + %8 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 8 %8, i64 15, i1 false) + %9 = bitcast %struct.array15* %2 to i8* + %10 = bitcast %struct.array15* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 15, i1 false) + %11 = getelementptr inbounds %struct.array15, %struct.array15* %2, i32 0, i32 0 + %12 = bitcast [2 x i64]* %5 to i8* + %13 = bitcast [15 x i8]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 1 %13, i64 15, i1 false) + %14 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %14 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo16([2 x i64] %0) #0 { + %2 = alloca %struct.array16, align 1 + %3 = alloca %struct.array16, align 1 + %4 = getelementptr inbounds %struct.array16, %struct.array16* %3, i32 0, i32 0 + %5 = bitcast [16 x i8]* %4 to [2 x i64]* + store [2 x i64] %0, [2 x i64]* %5, align 1 + %6 = bitcast %struct.array16* %2 to i8* + %7 = bitcast %struct.array16* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 1 %7, i64 16, i1 false) + %8 = getelementptr inbounds %struct.array16, %struct.array16* %2, i32 0, i32 0 + %9 = bitcast [16 x i8]* %8 to [2 x i64]* + %10 = load [2 x i64], [2 x i64]* %9, align 1 + ret [2 x i64] %10 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 1 %0, %struct.array17* noundef %1) #0 { + %3 = bitcast %struct.array17* %0 to i8* + %4 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %3, i8* align 1 %4, i64 17, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 1 %0, %struct.array18* noundef %1) #0 { + %3 = bitcast %struct.array18* %0 to i8* + %4 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %3, i8* align 1 %4, i64 18, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 1 %0, %struct.array19* noundef %1) #0 { + %3 = bitcast %struct.array19* %0 to i8* + %4 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %3, i8* align 1 %4, i64 19, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 1 %0, %struct.array20* noundef %1) #0 { + %3 = bitcast %struct.array20* %0 to i8* + %4 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %3, i8* align 1 %4, i64 20, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="non-leaf" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon,+v8a" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 8, !"branch-target-enforcement", i32 0} +!2 = !{i32 8, !"sign-return-address", i32 0} +!3 = !{i32 8, !"sign-return-address-all", i32 0} +!4 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!5 = !{i32 7, !"PIC Level", i32 2} +!6 = !{i32 7, !"PIE Level", i32 2} +!7 = !{i32 7, !"uwtable", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 1} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/arm64/array_pointer.ll b/internal/cabi/_testdata/arch/arm64/array_pointer.ll new file mode 100644 index 00000000..c6e43e0e --- /dev/null +++ b/internal/cabi/_testdata/arch/arm64/array_pointer.ll @@ -0,0 +1,221 @@ +; ModuleID = '../../wrap/array_pointer.c' +source_filename = "../../wrap/array_pointer.c" +target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" +target triple = "aarch64-unknown-linux-gnu" + +%struct.array1 = type { [1 x i8*] } +%struct.array2 = type { [2 x i8*] } +%struct.array3 = type { [3 x i8*] } +%struct.array4 = type { [4 x i8*] } +%struct.array5 = type { [5 x i8*] } +%struct.array6 = type { [6 x i8*] } +%struct.array7 = type { [7 x i8*] } +%struct.array8 = type { [8 x i8*] } +%struct.array9 = type { [9 x i8*] } +%struct.array10 = type { [10 x i8*] } +%struct.array11 = type { [11 x i8*] } +%struct.array12 = type { [12 x i8*] } +%struct.array13 = type { [13 x i8*] } +%struct.array14 = type { [14 x i8*] } +%struct.array15 = type { [15 x i8*] } +%struct.array16 = type { [16 x i8*] } +%struct.array17 = type { [17 x i8*] } +%struct.array18 = type { [18 x i8*] } +%struct.array19 = type { [19 x i8*] } +%struct.array20 = type { [20 x i8*] } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i64 @demo1(i64 %0) #0 { + %2 = alloca %struct.array1, align 8 + %3 = alloca %struct.array1, align 8 + %4 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + %5 = bitcast [1 x i8*]* %4 to i64* + store i64 %0, i64* %5, align 8 + %6 = bitcast %struct.array1* %2 to i8* + %7 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %6, i8* align 8 %7, i64 8, i1 false) + %8 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %9 = bitcast [1 x i8*]* %8 to i64* + %10 = load i64, i64* %9, align 8 + ret i64 %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo2([2 x i64] %0) #0 { + %2 = alloca %struct.array2, align 8 + %3 = alloca %struct.array2, align 8 + %4 = getelementptr inbounds %struct.array2, %struct.array2* %3, i32 0, i32 0 + %5 = bitcast [2 x i8*]* %4 to [2 x i64]* + store [2 x i64] %0, [2 x i64]* %5, align 8 + %6 = bitcast %struct.array2* %2 to i8* + %7 = bitcast %struct.array2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %6, i8* align 8 %7, i64 16, i1 false) + %8 = getelementptr inbounds %struct.array2, %struct.array2* %2, i32 0, i32 0 + %9 = bitcast [2 x i8*]* %8 to [2 x i64]* + %10 = load [2 x i64], [2 x i64]* %9, align 8 + ret [2 x i64] %10 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo3(%struct.array3* noalias sret(%struct.array3) align 8 %0, %struct.array3* noundef %1) #0 { + %3 = bitcast %struct.array3* %0 to i8* + %4 = bitcast %struct.array3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo4(%struct.array4* noalias sret(%struct.array4) align 8 %0, %struct.array4* noundef %1) #0 { + %3 = bitcast %struct.array4* %0 to i8* + %4 = bitcast %struct.array4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 8 %0, %struct.array5* noundef %1) #0 { + %3 = bitcast %struct.array5* %0 to i8* + %4 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 8 %0, %struct.array6* noundef %1) #0 { + %3 = bitcast %struct.array6* %0 to i8* + %4 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 8 %0, %struct.array7* noundef %1) #0 { + %3 = bitcast %struct.array7* %0 to i8* + %4 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 8 %0, %struct.array8* noundef %1) #0 { + %3 = bitcast %struct.array8* %0 to i8* + %4 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 8 %0, %struct.array9* noundef %1) #0 { + %3 = bitcast %struct.array9* %0 to i8* + %4 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 8 %0, %struct.array10* noundef %1) #0 { + %3 = bitcast %struct.array10* %0 to i8* + %4 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 8 %0, %struct.array11* noundef %1) #0 { + %3 = bitcast %struct.array11* %0 to i8* + %4 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 8 %0, %struct.array12* noundef %1) #0 { + %3 = bitcast %struct.array12* %0 to i8* + %4 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 8 %0, %struct.array13* noundef %1) #0 { + %3 = bitcast %struct.array13* %0 to i8* + %4 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 8 %0, %struct.array14* noundef %1) #0 { + %3 = bitcast %struct.array14* %0 to i8* + %4 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 8 %0, %struct.array15* noundef %1) #0 { + %3 = bitcast %struct.array15* %0 to i8* + %4 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 8 %0, %struct.array16* noundef %1) #0 { + %3 = bitcast %struct.array16* %0 to i8* + %4 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 8 %0, %struct.array17* noundef %1) #0 { + %3 = bitcast %struct.array17* %0 to i8* + %4 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 8 %0, %struct.array18* noundef %1) #0 { + %3 = bitcast %struct.array18* %0 to i8* + %4 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 8 %0, %struct.array19* noundef %1) #0 { + %3 = bitcast %struct.array19* %0 to i8* + %4 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 8 %0, %struct.array20* noundef %1) #0 { + %3 = bitcast %struct.array20* %0 to i8* + %4 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="non-leaf" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon,+v8a" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 8, !"branch-target-enforcement", i32 0} +!2 = !{i32 8, !"sign-return-address", i32 0} +!3 = !{i32 8, !"sign-return-address-all", i32 0} +!4 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!5 = !{i32 7, !"PIC Level", i32 2} +!6 = !{i32 7, !"PIE Level", i32 2} +!7 = !{i32 7, !"uwtable", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 1} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/arm64/array_uintptr.ll b/internal/cabi/_testdata/arch/arm64/array_uintptr.ll new file mode 100644 index 00000000..47786df5 --- /dev/null +++ b/internal/cabi/_testdata/arch/arm64/array_uintptr.ll @@ -0,0 +1,221 @@ +; ModuleID = '../../wrap/array_uintptr.c' +source_filename = "../../wrap/array_uintptr.c" +target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" +target triple = "aarch64-unknown-linux-gnu" + +%struct.array1 = type { [1 x i8*] } +%struct.array2 = type { [2 x i8*] } +%struct.array3 = type { [3 x i8*] } +%struct.array4 = type { [4 x i8*] } +%struct.array5 = type { [5 x i8*] } +%struct.array6 = type { [6 x i8*] } +%struct.array7 = type { [7 x i8*] } +%struct.array8 = type { [8 x i8*] } +%struct.array9 = type { [9 x i8*] } +%struct.array10 = type { [10 x i8*] } +%struct.array11 = type { [11 x i8*] } +%struct.array12 = type { [12 x i8*] } +%struct.array13 = type { [13 x i8*] } +%struct.array14 = type { [14 x i8*] } +%struct.array15 = type { [15 x i8*] } +%struct.array16 = type { [16 x i8*] } +%struct.array17 = type { [17 x i8*] } +%struct.array18 = type { [18 x i8*] } +%struct.array19 = type { [19 x i8*] } +%struct.array20 = type { [20 x i8*] } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i64 @demo1(i64 %0) #0 { + %2 = alloca %struct.array1, align 8 + %3 = alloca %struct.array1, align 8 + %4 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + %5 = bitcast [1 x i8*]* %4 to i64* + store i64 %0, i64* %5, align 8 + %6 = bitcast %struct.array1* %2 to i8* + %7 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %6, i8* align 8 %7, i64 8, i1 false) + %8 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %9 = bitcast [1 x i8*]* %8 to i64* + %10 = load i64, i64* %9, align 8 + ret i64 %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo2([2 x i64] %0) #0 { + %2 = alloca %struct.array2, align 8 + %3 = alloca %struct.array2, align 8 + %4 = getelementptr inbounds %struct.array2, %struct.array2* %3, i32 0, i32 0 + %5 = bitcast [2 x i8*]* %4 to [2 x i64]* + store [2 x i64] %0, [2 x i64]* %5, align 8 + %6 = bitcast %struct.array2* %2 to i8* + %7 = bitcast %struct.array2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %6, i8* align 8 %7, i64 16, i1 false) + %8 = getelementptr inbounds %struct.array2, %struct.array2* %2, i32 0, i32 0 + %9 = bitcast [2 x i8*]* %8 to [2 x i64]* + %10 = load [2 x i64], [2 x i64]* %9, align 8 + ret [2 x i64] %10 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo3(%struct.array3* noalias sret(%struct.array3) align 8 %0, %struct.array3* noundef %1) #0 { + %3 = bitcast %struct.array3* %0 to i8* + %4 = bitcast %struct.array3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo4(%struct.array4* noalias sret(%struct.array4) align 8 %0, %struct.array4* noundef %1) #0 { + %3 = bitcast %struct.array4* %0 to i8* + %4 = bitcast %struct.array4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 8 %0, %struct.array5* noundef %1) #0 { + %3 = bitcast %struct.array5* %0 to i8* + %4 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 8 %0, %struct.array6* noundef %1) #0 { + %3 = bitcast %struct.array6* %0 to i8* + %4 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 8 %0, %struct.array7* noundef %1) #0 { + %3 = bitcast %struct.array7* %0 to i8* + %4 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 8 %0, %struct.array8* noundef %1) #0 { + %3 = bitcast %struct.array8* %0 to i8* + %4 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 8 %0, %struct.array9* noundef %1) #0 { + %3 = bitcast %struct.array9* %0 to i8* + %4 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 8 %0, %struct.array10* noundef %1) #0 { + %3 = bitcast %struct.array10* %0 to i8* + %4 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 8 %0, %struct.array11* noundef %1) #0 { + %3 = bitcast %struct.array11* %0 to i8* + %4 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 8 %0, %struct.array12* noundef %1) #0 { + %3 = bitcast %struct.array12* %0 to i8* + %4 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 8 %0, %struct.array13* noundef %1) #0 { + %3 = bitcast %struct.array13* %0 to i8* + %4 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 8 %0, %struct.array14* noundef %1) #0 { + %3 = bitcast %struct.array14* %0 to i8* + %4 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 8 %0, %struct.array15* noundef %1) #0 { + %3 = bitcast %struct.array15* %0 to i8* + %4 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 8 %0, %struct.array16* noundef %1) #0 { + %3 = bitcast %struct.array16* %0 to i8* + %4 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 8 %0, %struct.array17* noundef %1) #0 { + %3 = bitcast %struct.array17* %0 to i8* + %4 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 8 %0, %struct.array18* noundef %1) #0 { + %3 = bitcast %struct.array18* %0 to i8* + %4 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 8 %0, %struct.array19* noundef %1) #0 { + %3 = bitcast %struct.array19* %0 to i8* + %4 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 8 %0, %struct.array20* noundef %1) #0 { + %3 = bitcast %struct.array20* %0 to i8* + %4 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="non-leaf" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon,+v8a" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 8, !"branch-target-enforcement", i32 0} +!2 = !{i32 8, !"sign-return-address", i32 0} +!3 = !{i32 8, !"sign-return-address-all", i32 0} +!4 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!5 = !{i32 7, !"PIC Level", i32 2} +!6 = !{i32 7, !"PIE Level", i32 2} +!7 = !{i32 7, !"uwtable", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 1} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/arm64/basic.ll b/internal/cabi/_testdata/arch/arm64/basic.ll new file mode 100644 index 00000000..1575fdcf --- /dev/null +++ b/internal/cabi/_testdata/arch/arm64/basic.ll @@ -0,0 +1,76 @@ +; ModuleID = '../../wrap/basic.c' +source_filename = "../../wrap/basic.c" +target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" +target triple = "aarch64-unknown-linux-gnu" + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i8 @basic_int8(i8 noundef %0) #0 { + %2 = alloca i8, align 1 + store i8 %0, i8* %2, align 1 + %3 = load i8, i8* %2, align 1 + ret i8 %3 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i16 @basic_int16(i16 noundef %0) #0 { + %2 = alloca i16, align 2 + store i16 %0, i16* %2, align 2 + %3 = load i16, i16* %2, align 2 + ret i16 %3 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i32 @basic_int32(i32 noundef %0) #0 { + %2 = alloca i32, align 4 + store i32 %0, i32* %2, align 4 + %3 = load i32, i32* %2, align 4 + ret i32 %3 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i64 @basic_int64(i64 noundef %0) #0 { + %2 = alloca i64, align 8 + store i64 %0, i64* %2, align 8 + %3 = load i64, i64* %2, align 8 + ret i64 %3 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local float @basic_float32(float noundef %0) #0 { + %2 = alloca float, align 4 + store float %0, float* %2, align 4 + %3 = load float, float* %2, align 4 + ret float %3 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local double @basic_float64(double noundef %0) #0 { + %2 = alloca double, align 8 + store double %0, double* %2, align 8 + %3 = load double, double* %2, align 8 + ret double %3 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i8* @basic_uintptr(i8* noundef %0) #0 { + %2 = alloca i8*, align 8 + store i8* %0, i8** %2, align 8 + %3 = load i8*, i8** %2, align 8 + ret i8* %3 +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="non-leaf" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon,+v8a" } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 8, !"branch-target-enforcement", i32 0} +!2 = !{i32 8, !"sign-return-address", i32 0} +!3 = !{i32 8, !"sign-return-address-all", i32 0} +!4 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!5 = !{i32 7, !"PIC Level", i32 2} +!6 = !{i32 7, !"PIE Level", i32 2} +!7 = !{i32 7, !"uwtable", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 1} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/arm64/struct_float32.ll b/internal/cabi/_testdata/arch/arm64/struct_float32.ll new file mode 100644 index 00000000..66c3f565 --- /dev/null +++ b/internal/cabi/_testdata/arch/arm64/struct_float32.ll @@ -0,0 +1,226 @@ +; ModuleID = '../../wrap/struct_float32.c' +source_filename = "../../wrap/struct_float32.c" +target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" +target triple = "aarch64-unknown-linux-gnu" + +%struct.point1 = type { float } +%struct.point2 = type { float, float } +%struct.point3 = type { float, float, float } +%struct.point4 = type { float, float, float, float } +%struct.point5 = type { float, float, float, float, float } +%struct.point6 = type { float, float, float, float, float, float } +%struct.point7 = type { float, float, float, float, float, float, float } +%struct.point8 = type { float, float, float, float, float, float, float, float } +%struct.point9 = type { float, float, float, float, float, float, float, float, float } +%struct.point10 = type { float, float, float, float, float, float, float, float, float, float } +%struct.point11 = type { float, float, float, float, float, float, float, float, float, float, float } +%struct.point12 = type { float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point13 = type { float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point14 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point15 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point16 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point17 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point18 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point19 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point20 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local %struct.point1 @demo1([1 x float] %0) #0 { + %2 = alloca %struct.point1, align 4 + %3 = alloca %struct.point1, align 4 + %4 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + %5 = bitcast float* %4 to [1 x float]* + store [1 x float] %0, [1 x float]* %5, align 4 + %6 = bitcast %struct.point1* %2 to i8* + %7 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %6, i8* align 4 %7, i64 4, i1 false) + %8 = load %struct.point1, %struct.point1* %2, align 4 + ret %struct.point1 %8 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local %struct.point2 @demo2([2 x float] %0) #0 { + %2 = alloca %struct.point2, align 4 + %3 = alloca %struct.point2, align 4 + %4 = bitcast %struct.point2* %3 to [2 x float]* + store [2 x float] %0, [2 x float]* %4, align 4 + %5 = bitcast %struct.point2* %2 to i8* + %6 = bitcast %struct.point2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 8, i1 false) + %7 = load %struct.point2, %struct.point2* %2, align 4 + ret %struct.point2 %7 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local %struct.point3 @demo3([3 x float] %0) #0 { + %2 = alloca %struct.point3, align 4 + %3 = alloca %struct.point3, align 4 + %4 = bitcast %struct.point3* %3 to [3 x float]* + store [3 x float] %0, [3 x float]* %4, align 4 + %5 = bitcast %struct.point3* %2 to i8* + %6 = bitcast %struct.point3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 12, i1 false) + %7 = load %struct.point3, %struct.point3* %2, align 4 + ret %struct.point3 %7 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local %struct.point4 @demo4([4 x float] %0) #0 { + %2 = alloca %struct.point4, align 4 + %3 = alloca %struct.point4, align 4 + %4 = bitcast %struct.point4* %3 to [4 x float]* + store [4 x float] %0, [4 x float]* %4, align 4 + %5 = bitcast %struct.point4* %2 to i8* + %6 = bitcast %struct.point4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 16, i1 false) + %7 = load %struct.point4, %struct.point4* %2, align 4 + ret %struct.point4 %7 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.point5* noalias sret(%struct.point5) align 4 %0, %struct.point5* noundef %1) #0 { + %3 = bitcast %struct.point5* %0 to i8* + %4 = bitcast %struct.point5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.point6* noalias sret(%struct.point6) align 4 %0, %struct.point6* noundef %1) #0 { + %3 = bitcast %struct.point6* %0 to i8* + %4 = bitcast %struct.point6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.point7* noalias sret(%struct.point7) align 4 %0, %struct.point7* noundef %1) #0 { + %3 = bitcast %struct.point7* %0 to i8* + %4 = bitcast %struct.point7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.point8* noalias sret(%struct.point8) align 4 %0, %struct.point8* noundef %1) #0 { + %3 = bitcast %struct.point8* %0 to i8* + %4 = bitcast %struct.point8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 4 %0, %struct.point9* noundef %1) #0 { + %3 = bitcast %struct.point9* %0 to i8* + %4 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 4 %0, %struct.point10* noundef %1) #0 { + %3 = bitcast %struct.point10* %0 to i8* + %4 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 4 %0, %struct.point11* noundef %1) #0 { + %3 = bitcast %struct.point11* %0 to i8* + %4 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 4 %0, %struct.point12* noundef %1) #0 { + %3 = bitcast %struct.point12* %0 to i8* + %4 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 4 %0, %struct.point13* noundef %1) #0 { + %3 = bitcast %struct.point13* %0 to i8* + %4 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 4 %0, %struct.point14* noundef %1) #0 { + %3 = bitcast %struct.point14* %0 to i8* + %4 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 4 %0, %struct.point15* noundef %1) #0 { + %3 = bitcast %struct.point15* %0 to i8* + %4 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 4 %0, %struct.point16* noundef %1) #0 { + %3 = bitcast %struct.point16* %0 to i8* + %4 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 4 %0, %struct.point17* noundef %1) #0 { + %3 = bitcast %struct.point17* %0 to i8* + %4 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 4 %0, %struct.point18* noundef %1) #0 { + %3 = bitcast %struct.point18* %0 to i8* + %4 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 4 %0, %struct.point19* noundef %1) #0 { + %3 = bitcast %struct.point19* %0 to i8* + %4 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 4 %0, %struct.point20* noundef %1) #0 { + %3 = bitcast %struct.point20* %0 to i8* + %4 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="non-leaf" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon,+v8a" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 8, !"branch-target-enforcement", i32 0} +!2 = !{i32 8, !"sign-return-address", i32 0} +!3 = !{i32 8, !"sign-return-address-all", i32 0} +!4 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!5 = !{i32 7, !"PIC Level", i32 2} +!6 = !{i32 7, !"PIE Level", i32 2} +!7 = !{i32 7, !"uwtable", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 1} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/arm64/struct_float64.ll b/internal/cabi/_testdata/arch/arm64/struct_float64.ll new file mode 100644 index 00000000..bf49cf8f --- /dev/null +++ b/internal/cabi/_testdata/arch/arm64/struct_float64.ll @@ -0,0 +1,226 @@ +; ModuleID = '../../wrap/struct_float64.c' +source_filename = "../../wrap/struct_float64.c" +target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" +target triple = "aarch64-unknown-linux-gnu" + +%struct.point1 = type { double } +%struct.point2 = type { double, double } +%struct.point3 = type { double, double, double } +%struct.point4 = type { double, double, double, double } +%struct.point5 = type { double, double, double, double, double } +%struct.point6 = type { double, double, double, double, double, double } +%struct.point7 = type { double, double, double, double, double, double, double } +%struct.point8 = type { double, double, double, double, double, double, double, double } +%struct.point9 = type { double, double, double, double, double, double, double, double, double } +%struct.point10 = type { double, double, double, double, double, double, double, double, double, double } +%struct.point11 = type { double, double, double, double, double, double, double, double, double, double, double } +%struct.point12 = type { double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point13 = type { double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point14 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point15 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point16 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point17 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point18 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point19 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point20 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local %struct.point1 @demo1([1 x double] %0) #0 { + %2 = alloca %struct.point1, align 8 + %3 = alloca %struct.point1, align 8 + %4 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + %5 = bitcast double* %4 to [1 x double]* + store [1 x double] %0, [1 x double]* %5, align 8 + %6 = bitcast %struct.point1* %2 to i8* + %7 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %6, i8* align 8 %7, i64 8, i1 false) + %8 = load %struct.point1, %struct.point1* %2, align 8 + ret %struct.point1 %8 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local %struct.point2 @demo2([2 x double] %0) #0 { + %2 = alloca %struct.point2, align 8 + %3 = alloca %struct.point2, align 8 + %4 = bitcast %struct.point2* %3 to [2 x double]* + store [2 x double] %0, [2 x double]* %4, align 8 + %5 = bitcast %struct.point2* %2 to i8* + %6 = bitcast %struct.point2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 16, i1 false) + %7 = load %struct.point2, %struct.point2* %2, align 8 + ret %struct.point2 %7 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local %struct.point3 @demo3([3 x double] %0) #0 { + %2 = alloca %struct.point3, align 8 + %3 = alloca %struct.point3, align 8 + %4 = bitcast %struct.point3* %3 to [3 x double]* + store [3 x double] %0, [3 x double]* %4, align 8 + %5 = bitcast %struct.point3* %2 to i8* + %6 = bitcast %struct.point3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 24, i1 false) + %7 = load %struct.point3, %struct.point3* %2, align 8 + ret %struct.point3 %7 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local %struct.point4 @demo4([4 x double] %0) #0 { + %2 = alloca %struct.point4, align 8 + %3 = alloca %struct.point4, align 8 + %4 = bitcast %struct.point4* %3 to [4 x double]* + store [4 x double] %0, [4 x double]* %4, align 8 + %5 = bitcast %struct.point4* %2 to i8* + %6 = bitcast %struct.point4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 32, i1 false) + %7 = load %struct.point4, %struct.point4* %2, align 8 + ret %struct.point4 %7 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.point5* noalias sret(%struct.point5) align 8 %0, %struct.point5* noundef %1) #0 { + %3 = bitcast %struct.point5* %0 to i8* + %4 = bitcast %struct.point5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.point6* noalias sret(%struct.point6) align 8 %0, %struct.point6* noundef %1) #0 { + %3 = bitcast %struct.point6* %0 to i8* + %4 = bitcast %struct.point6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.point7* noalias sret(%struct.point7) align 8 %0, %struct.point7* noundef %1) #0 { + %3 = bitcast %struct.point7* %0 to i8* + %4 = bitcast %struct.point7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.point8* noalias sret(%struct.point8) align 8 %0, %struct.point8* noundef %1) #0 { + %3 = bitcast %struct.point8* %0 to i8* + %4 = bitcast %struct.point8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 8 %0, %struct.point9* noundef %1) #0 { + %3 = bitcast %struct.point9* %0 to i8* + %4 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 8 %0, %struct.point10* noundef %1) #0 { + %3 = bitcast %struct.point10* %0 to i8* + %4 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 8 %0, %struct.point11* noundef %1) #0 { + %3 = bitcast %struct.point11* %0 to i8* + %4 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 8 %0, %struct.point12* noundef %1) #0 { + %3 = bitcast %struct.point12* %0 to i8* + %4 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 8 %0, %struct.point13* noundef %1) #0 { + %3 = bitcast %struct.point13* %0 to i8* + %4 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 8 %0, %struct.point14* noundef %1) #0 { + %3 = bitcast %struct.point14* %0 to i8* + %4 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 8 %0, %struct.point15* noundef %1) #0 { + %3 = bitcast %struct.point15* %0 to i8* + %4 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 8 %0, %struct.point16* noundef %1) #0 { + %3 = bitcast %struct.point16* %0 to i8* + %4 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 8 %0, %struct.point17* noundef %1) #0 { + %3 = bitcast %struct.point17* %0 to i8* + %4 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 8 %0, %struct.point18* noundef %1) #0 { + %3 = bitcast %struct.point18* %0 to i8* + %4 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 8 %0, %struct.point19* noundef %1) #0 { + %3 = bitcast %struct.point19* %0 to i8* + %4 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 8 %0, %struct.point20* noundef %1) #0 { + %3 = bitcast %struct.point20* %0 to i8* + %4 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="non-leaf" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon,+v8a" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 8, !"branch-target-enforcement", i32 0} +!2 = !{i32 8, !"sign-return-address", i32 0} +!3 = !{i32 8, !"sign-return-address-all", i32 0} +!4 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!5 = !{i32 7, !"PIC Level", i32 2} +!6 = !{i32 7, !"PIE Level", i32 2} +!7 = !{i32 7, !"uwtable", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 1} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/arm64/struct_int16.ll b/internal/cabi/_testdata/arch/arm64/struct_int16.ll new file mode 100644 index 00000000..f8a8da24 --- /dev/null +++ b/internal/cabi/_testdata/arch/arm64/struct_int16.ll @@ -0,0 +1,281 @@ +; ModuleID = '../../wrap/struct_int16.c' +source_filename = "../../wrap/struct_int16.c" +target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" +target triple = "aarch64-unknown-linux-gnu" + +%struct.point1 = type { i16 } +%struct.point2 = type { i16, i16 } +%struct.point3 = type { i16, i16, i16 } +%struct.point4 = type { i16, i16, i16, i16 } +%struct.point5 = type { i16, i16, i16, i16, i16 } +%struct.point6 = type { i16, i16, i16, i16, i16, i16 } +%struct.point7 = type { i16, i16, i16, i16, i16, i16, i16 } +%struct.point8 = type { i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point9 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point10 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point11 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point12 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point13 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point14 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point15 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point16 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point17 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point18 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point19 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point20 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i16 @demo1(i64 %0) #0 { + %2 = alloca %struct.point1, align 2 + %3 = alloca %struct.point1, align 2 + %4 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + %5 = trunc i64 %0 to i16 + store i16 %5, i16* %4, align 2 + %6 = bitcast %struct.point1* %2 to i8* + %7 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %6, i8* align 2 %7, i64 2, i1 false) + %8 = getelementptr inbounds %struct.point1, %struct.point1* %2, i32 0, i32 0 + %9 = load i16, i16* %8, align 2 + ret i16 %9 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i32 @demo2(i64 %0) #0 { + %2 = alloca %struct.point2, align 2 + %3 = alloca %struct.point2, align 2 + %4 = alloca i64, align 8 + store i64 %0, i64* %4, align 8 + %5 = bitcast %struct.point2* %3 to i8* + %6 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 8 %6, i64 4, i1 false) + %7 = bitcast %struct.point2* %2 to i8* + %8 = bitcast %struct.point2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %7, i8* align 2 %8, i64 4, i1 false) + %9 = bitcast %struct.point2* %2 to i32* + %10 = load i32, i32* %9, align 2 + ret i32 %10 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i48 @demo3(i64 %0) #0 { + %2 = alloca %struct.point3, align 2 + %3 = alloca %struct.point3, align 2 + %4 = alloca i64, align 8 + %5 = alloca i48, align 8 + store i64 %0, i64* %4, align 8 + %6 = bitcast %struct.point3* %3 to i8* + %7 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %6, i8* align 8 %7, i64 6, i1 false) + %8 = bitcast %struct.point3* %2 to i8* + %9 = bitcast %struct.point3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %8, i8* align 2 %9, i64 6, i1 false) + %10 = bitcast i48* %5 to i8* + %11 = bitcast %struct.point3* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 2 %11, i64 6, i1 false) + %12 = load i48, i48* %5, align 8 + ret i48 %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i64 @demo4(i64 %0) #0 { + %2 = alloca %struct.point4, align 2 + %3 = alloca %struct.point4, align 2 + %4 = bitcast %struct.point4* %3 to i64* + store i64 %0, i64* %4, align 2 + %5 = bitcast %struct.point4* %2 to i8* + %6 = bitcast %struct.point4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 8, i1 false) + %7 = bitcast %struct.point4* %2 to i64* + %8 = load i64, i64* %7, align 2 + ret i64 %8 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo5([2 x i64] %0) #0 { + %2 = alloca %struct.point5, align 2 + %3 = alloca %struct.point5, align 2 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %6 = bitcast %struct.point5* %3 to i8* + %7 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %6, i8* align 8 %7, i64 10, i1 false) + %8 = bitcast %struct.point5* %2 to i8* + %9 = bitcast %struct.point5* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %8, i8* align 2 %9, i64 10, i1 false) + %10 = bitcast [2 x i64]* %5 to i8* + %11 = bitcast %struct.point5* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 2 %11, i64 10, i1 false) + %12 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo6([2 x i64] %0) #0 { + %2 = alloca %struct.point6, align 2 + %3 = alloca %struct.point6, align 2 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %6 = bitcast %struct.point6* %3 to i8* + %7 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %6, i8* align 8 %7, i64 12, i1 false) + %8 = bitcast %struct.point6* %2 to i8* + %9 = bitcast %struct.point6* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %8, i8* align 2 %9, i64 12, i1 false) + %10 = bitcast [2 x i64]* %5 to i8* + %11 = bitcast %struct.point6* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 2 %11, i64 12, i1 false) + %12 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo7([2 x i64] %0) #0 { + %2 = alloca %struct.point7, align 2 + %3 = alloca %struct.point7, align 2 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %6 = bitcast %struct.point7* %3 to i8* + %7 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %6, i8* align 8 %7, i64 14, i1 false) + %8 = bitcast %struct.point7* %2 to i8* + %9 = bitcast %struct.point7* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %8, i8* align 2 %9, i64 14, i1 false) + %10 = bitcast [2 x i64]* %5 to i8* + %11 = bitcast %struct.point7* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 2 %11, i64 14, i1 false) + %12 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo8([2 x i64] %0) #0 { + %2 = alloca %struct.point8, align 2 + %3 = alloca %struct.point8, align 2 + %4 = bitcast %struct.point8* %3 to [2 x i64]* + store [2 x i64] %0, [2 x i64]* %4, align 2 + %5 = bitcast %struct.point8* %2 to i8* + %6 = bitcast %struct.point8* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 16, i1 false) + %7 = bitcast %struct.point8* %2 to [2 x i64]* + %8 = load [2 x i64], [2 x i64]* %7, align 2 + ret [2 x i64] %8 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 2 %0, %struct.point9* noundef %1) #0 { + %3 = bitcast %struct.point9* %0 to i8* + %4 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 2 %4, i64 18, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 2 %0, %struct.point10* noundef %1) #0 { + %3 = bitcast %struct.point10* %0 to i8* + %4 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 2 %4, i64 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 2 %0, %struct.point11* noundef %1) #0 { + %3 = bitcast %struct.point11* %0 to i8* + %4 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 2 %4, i64 22, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 2 %0, %struct.point12* noundef %1) #0 { + %3 = bitcast %struct.point12* %0 to i8* + %4 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 2 %4, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 2 %0, %struct.point13* noundef %1) #0 { + %3 = bitcast %struct.point13* %0 to i8* + %4 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 2 %4, i64 26, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 2 %0, %struct.point14* noundef %1) #0 { + %3 = bitcast %struct.point14* %0 to i8* + %4 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 2 %4, i64 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 2 %0, %struct.point15* noundef %1) #0 { + %3 = bitcast %struct.point15* %0 to i8* + %4 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 2 %4, i64 30, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 2 %0, %struct.point16* noundef %1) #0 { + %3 = bitcast %struct.point16* %0 to i8* + %4 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 2 %4, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 2 %0, %struct.point17* noundef %1) #0 { + %3 = bitcast %struct.point17* %0 to i8* + %4 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 2 %4, i64 34, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 2 %0, %struct.point18* noundef %1) #0 { + %3 = bitcast %struct.point18* %0 to i8* + %4 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 2 %4, i64 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 2 %0, %struct.point19* noundef %1) #0 { + %3 = bitcast %struct.point19* %0 to i8* + %4 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 2 %4, i64 38, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 2 %0, %struct.point20* noundef %1) #0 { + %3 = bitcast %struct.point20* %0 to i8* + %4 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %3, i8* align 2 %4, i64 40, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="non-leaf" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon,+v8a" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 8, !"branch-target-enforcement", i32 0} +!2 = !{i32 8, !"sign-return-address", i32 0} +!3 = !{i32 8, !"sign-return-address-all", i32 0} +!4 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!5 = !{i32 7, !"PIC Level", i32 2} +!6 = !{i32 7, !"PIE Level", i32 2} +!7 = !{i32 7, !"uwtable", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 1} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/arm64/struct_int32.ll b/internal/cabi/_testdata/arch/arm64/struct_int32.ll new file mode 100644 index 00000000..97020292 --- /dev/null +++ b/internal/cabi/_testdata/arch/arm64/struct_int32.ll @@ -0,0 +1,236 @@ +; ModuleID = '../../wrap/struct_int32.c' +source_filename = "../../wrap/struct_int32.c" +target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" +target triple = "aarch64-unknown-linux-gnu" + +%struct.point1 = type { i32 } +%struct.point2 = type { i32, i32 } +%struct.point3 = type { i32, i32, i32 } +%struct.point4 = type { i32, i32, i32, i32 } +%struct.point5 = type { i32, i32, i32, i32, i32 } +%struct.point6 = type { i32, i32, i32, i32, i32, i32 } +%struct.point7 = type { i32, i32, i32, i32, i32, i32, i32 } +%struct.point8 = type { i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point9 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point10 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point11 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point12 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point13 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point14 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point15 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point16 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point17 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point18 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point19 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point20 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i32 @demo1(i64 %0) #0 { + %2 = alloca %struct.point1, align 4 + %3 = alloca %struct.point1, align 4 + %4 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + %5 = trunc i64 %0 to i32 + store i32 %5, i32* %4, align 4 + %6 = bitcast %struct.point1* %2 to i8* + %7 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %6, i8* align 4 %7, i64 4, i1 false) + %8 = getelementptr inbounds %struct.point1, %struct.point1* %2, i32 0, i32 0 + %9 = load i32, i32* %8, align 4 + ret i32 %9 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i64 @demo2(i64 %0) #0 { + %2 = alloca %struct.point2, align 4 + %3 = alloca %struct.point2, align 4 + %4 = bitcast %struct.point2* %3 to i64* + store i64 %0, i64* %4, align 4 + %5 = bitcast %struct.point2* %2 to i8* + %6 = bitcast %struct.point2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 8, i1 false) + %7 = bitcast %struct.point2* %2 to i64* + %8 = load i64, i64* %7, align 4 + ret i64 %8 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo3([2 x i64] %0) #0 { + %2 = alloca %struct.point3, align 4 + %3 = alloca %struct.point3, align 4 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %6 = bitcast %struct.point3* %3 to i8* + %7 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %6, i8* align 8 %7, i64 12, i1 false) + %8 = bitcast %struct.point3* %2 to i8* + %9 = bitcast %struct.point3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %8, i8* align 4 %9, i64 12, i1 false) + %10 = bitcast [2 x i64]* %5 to i8* + %11 = bitcast %struct.point3* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 4 %11, i64 12, i1 false) + %12 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo4([2 x i64] %0) #0 { + %2 = alloca %struct.point4, align 4 + %3 = alloca %struct.point4, align 4 + %4 = bitcast %struct.point4* %3 to [2 x i64]* + store [2 x i64] %0, [2 x i64]* %4, align 4 + %5 = bitcast %struct.point4* %2 to i8* + %6 = bitcast %struct.point4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 16, i1 false) + %7 = bitcast %struct.point4* %2 to [2 x i64]* + %8 = load [2 x i64], [2 x i64]* %7, align 4 + ret [2 x i64] %8 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.point5* noalias sret(%struct.point5) align 4 %0, %struct.point5* noundef %1) #0 { + %3 = bitcast %struct.point5* %0 to i8* + %4 = bitcast %struct.point5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.point6* noalias sret(%struct.point6) align 4 %0, %struct.point6* noundef %1) #0 { + %3 = bitcast %struct.point6* %0 to i8* + %4 = bitcast %struct.point6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.point7* noalias sret(%struct.point7) align 4 %0, %struct.point7* noundef %1) #0 { + %3 = bitcast %struct.point7* %0 to i8* + %4 = bitcast %struct.point7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.point8* noalias sret(%struct.point8) align 4 %0, %struct.point8* noundef %1) #0 { + %3 = bitcast %struct.point8* %0 to i8* + %4 = bitcast %struct.point8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 4 %0, %struct.point9* noundef %1) #0 { + %3 = bitcast %struct.point9* %0 to i8* + %4 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 4 %0, %struct.point10* noundef %1) #0 { + %3 = bitcast %struct.point10* %0 to i8* + %4 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 4 %0, %struct.point11* noundef %1) #0 { + %3 = bitcast %struct.point11* %0 to i8* + %4 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 4 %0, %struct.point12* noundef %1) #0 { + %3 = bitcast %struct.point12* %0 to i8* + %4 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 4 %0, %struct.point13* noundef %1) #0 { + %3 = bitcast %struct.point13* %0 to i8* + %4 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 4 %0, %struct.point14* noundef %1) #0 { + %3 = bitcast %struct.point14* %0 to i8* + %4 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 4 %0, %struct.point15* noundef %1) #0 { + %3 = bitcast %struct.point15* %0 to i8* + %4 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 4 %0, %struct.point16* noundef %1) #0 { + %3 = bitcast %struct.point16* %0 to i8* + %4 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 4 %0, %struct.point17* noundef %1) #0 { + %3 = bitcast %struct.point17* %0 to i8* + %4 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 4 %0, %struct.point18* noundef %1) #0 { + %3 = bitcast %struct.point18* %0 to i8* + %4 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 4 %0, %struct.point19* noundef %1) #0 { + %3 = bitcast %struct.point19* %0 to i8* + %4 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 4 %0, %struct.point20* noundef %1) #0 { + %3 = bitcast %struct.point20* %0 to i8* + %4 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="non-leaf" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon,+v8a" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 8, !"branch-target-enforcement", i32 0} +!2 = !{i32 8, !"sign-return-address", i32 0} +!3 = !{i32 8, !"sign-return-address-all", i32 0} +!4 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!5 = !{i32 7, !"PIC Level", i32 2} +!6 = !{i32 7, !"PIE Level", i32 2} +!7 = !{i32 7, !"uwtable", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 1} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/arm64/struct_int64.ll b/internal/cabi/_testdata/arch/arm64/struct_int64.ll new file mode 100644 index 00000000..5efcf2a5 --- /dev/null +++ b/internal/cabi/_testdata/arch/arm64/struct_int64.ll @@ -0,0 +1,217 @@ +; ModuleID = '../../wrap/struct_int64.c' +source_filename = "../../wrap/struct_int64.c" +target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" +target triple = "aarch64-unknown-linux-gnu" + +%struct.point1 = type { i64 } +%struct.point2 = type { i64, i64 } +%struct.point3 = type { i64, i64, i64 } +%struct.point4 = type { i64, i64, i64, i64 } +%struct.point5 = type { i64, i64, i64, i64, i64 } +%struct.point6 = type { i64, i64, i64, i64, i64, i64 } +%struct.point7 = type { i64, i64, i64, i64, i64, i64, i64 } +%struct.point8 = type { i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point9 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point10 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point11 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point12 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point13 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point14 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point15 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point16 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point17 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point18 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point19 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point20 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i64 @demo1(i64 %0) #0 { + %2 = alloca %struct.point1, align 8 + %3 = alloca %struct.point1, align 8 + %4 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + store i64 %0, i64* %4, align 8 + %5 = bitcast %struct.point1* %2 to i8* + %6 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 8, i1 false) + %7 = getelementptr inbounds %struct.point1, %struct.point1* %2, i32 0, i32 0 + %8 = load i64, i64* %7, align 8 + ret i64 %8 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo2([2 x i64] %0) #0 { + %2 = alloca %struct.point2, align 8 + %3 = alloca %struct.point2, align 8 + %4 = bitcast %struct.point2* %3 to [2 x i64]* + store [2 x i64] %0, [2 x i64]* %4, align 8 + %5 = bitcast %struct.point2* %2 to i8* + %6 = bitcast %struct.point2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 16, i1 false) + %7 = bitcast %struct.point2* %2 to [2 x i64]* + %8 = load [2 x i64], [2 x i64]* %7, align 8 + ret [2 x i64] %8 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo3(%struct.point3* noalias sret(%struct.point3) align 8 %0, %struct.point3* noundef %1) #0 { + %3 = bitcast %struct.point3* %0 to i8* + %4 = bitcast %struct.point3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo4(%struct.point4* noalias sret(%struct.point4) align 8 %0, %struct.point4* noundef %1) #0 { + %3 = bitcast %struct.point4* %0 to i8* + %4 = bitcast %struct.point4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.point5* noalias sret(%struct.point5) align 8 %0, %struct.point5* noundef %1) #0 { + %3 = bitcast %struct.point5* %0 to i8* + %4 = bitcast %struct.point5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.point6* noalias sret(%struct.point6) align 8 %0, %struct.point6* noundef %1) #0 { + %3 = bitcast %struct.point6* %0 to i8* + %4 = bitcast %struct.point6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.point7* noalias sret(%struct.point7) align 8 %0, %struct.point7* noundef %1) #0 { + %3 = bitcast %struct.point7* %0 to i8* + %4 = bitcast %struct.point7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.point8* noalias sret(%struct.point8) align 8 %0, %struct.point8* noundef %1) #0 { + %3 = bitcast %struct.point8* %0 to i8* + %4 = bitcast %struct.point8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 8 %0, %struct.point9* noundef %1) #0 { + %3 = bitcast %struct.point9* %0 to i8* + %4 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 8 %0, %struct.point10* noundef %1) #0 { + %3 = bitcast %struct.point10* %0 to i8* + %4 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 8 %0, %struct.point11* noundef %1) #0 { + %3 = bitcast %struct.point11* %0 to i8* + %4 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 8 %0, %struct.point12* noundef %1) #0 { + %3 = bitcast %struct.point12* %0 to i8* + %4 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 8 %0, %struct.point13* noundef %1) #0 { + %3 = bitcast %struct.point13* %0 to i8* + %4 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 8 %0, %struct.point14* noundef %1) #0 { + %3 = bitcast %struct.point14* %0 to i8* + %4 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 8 %0, %struct.point15* noundef %1) #0 { + %3 = bitcast %struct.point15* %0 to i8* + %4 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 8 %0, %struct.point16* noundef %1) #0 { + %3 = bitcast %struct.point16* %0 to i8* + %4 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 8 %0, %struct.point17* noundef %1) #0 { + %3 = bitcast %struct.point17* %0 to i8* + %4 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 8 %0, %struct.point18* noundef %1) #0 { + %3 = bitcast %struct.point18* %0 to i8* + %4 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 8 %0, %struct.point19* noundef %1) #0 { + %3 = bitcast %struct.point19* %0 to i8* + %4 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 8 %0, %struct.point20* noundef %1) #0 { + %3 = bitcast %struct.point20* %0 to i8* + %4 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="non-leaf" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon,+v8a" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 8, !"branch-target-enforcement", i32 0} +!2 = !{i32 8, !"sign-return-address", i32 0} +!3 = !{i32 8, !"sign-return-address-all", i32 0} +!4 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!5 = !{i32 7, !"PIC Level", i32 2} +!6 = !{i32 7, !"PIE Level", i32 2} +!7 = !{i32 7, !"uwtable", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 1} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/arm64/struct_int8.ll b/internal/cabi/_testdata/arch/arm64/struct_int8.ll new file mode 100644 index 00000000..78546882 --- /dev/null +++ b/internal/cabi/_testdata/arch/arm64/struct_int8.ll @@ -0,0 +1,374 @@ +; ModuleID = '../../wrap/struct_int8.c' +source_filename = "../../wrap/struct_int8.c" +target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" +target triple = "aarch64-unknown-linux-gnu" + +%struct.point1 = type { i8 } +%struct.point2 = type { i8, i8 } +%struct.point3 = type { i8, i8, i8 } +%struct.point4 = type { i8, i8, i8, i8 } +%struct.point5 = type { i8, i8, i8, i8, i8 } +%struct.point6 = type { i8, i8, i8, i8, i8, i8 } +%struct.point7 = type { i8, i8, i8, i8, i8, i8, i8 } +%struct.point8 = type { i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point9 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point10 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point11 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point12 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point13 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point14 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point15 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point16 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point17 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point18 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point19 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point20 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i8 @demo1(i64 %0) #0 { + %2 = alloca %struct.point1, align 1 + %3 = alloca %struct.point1, align 1 + %4 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + %5 = trunc i64 %0 to i8 + store i8 %5, i8* %4, align 1 + %6 = bitcast %struct.point1* %2 to i8* + %7 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 1 %7, i64 1, i1 false) + %8 = getelementptr inbounds %struct.point1, %struct.point1* %2, i32 0, i32 0 + %9 = load i8, i8* %8, align 1 + ret i8 %9 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i16 @demo2(i64 %0) #0 { + %2 = alloca %struct.point2, align 1 + %3 = alloca %struct.point2, align 1 + %4 = alloca i64, align 8 + store i64 %0, i64* %4, align 8 + %5 = bitcast %struct.point2* %3 to i8* + %6 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %5, i8* align 8 %6, i64 2, i1 false) + %7 = bitcast %struct.point2* %2 to i8* + %8 = bitcast %struct.point2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 1 %8, i64 2, i1 false) + %9 = bitcast %struct.point2* %2 to i16* + %10 = load i16, i16* %9, align 1 + ret i16 %10 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i24 @demo3(i64 %0) #0 { + %2 = alloca %struct.point3, align 1 + %3 = alloca %struct.point3, align 1 + %4 = alloca i64, align 8 + %5 = alloca i24, align 4 + store i64 %0, i64* %4, align 8 + %6 = bitcast %struct.point3* %3 to i8* + %7 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 8 %7, i64 3, i1 false) + %8 = bitcast %struct.point3* %2 to i8* + %9 = bitcast %struct.point3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 3, i1 false) + %10 = bitcast i24* %5 to i8* + %11 = bitcast %struct.point3* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %10, i8* align 1 %11, i64 3, i1 false) + %12 = load i24, i24* %5, align 4 + ret i24 %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i32 @demo4(i64 %0) #0 { + %2 = alloca %struct.point4, align 1 + %3 = alloca %struct.point4, align 1 + %4 = alloca i64, align 8 + store i64 %0, i64* %4, align 8 + %5 = bitcast %struct.point4* %3 to i8* + %6 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %5, i8* align 8 %6, i64 4, i1 false) + %7 = bitcast %struct.point4* %2 to i8* + %8 = bitcast %struct.point4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 1 %8, i64 4, i1 false) + %9 = bitcast %struct.point4* %2 to i32* + %10 = load i32, i32* %9, align 1 + ret i32 %10 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i40 @demo5(i64 %0) #0 { + %2 = alloca %struct.point5, align 1 + %3 = alloca %struct.point5, align 1 + %4 = alloca i64, align 8 + %5 = alloca i40, align 8 + store i64 %0, i64* %4, align 8 + %6 = bitcast %struct.point5* %3 to i8* + %7 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 8 %7, i64 5, i1 false) + %8 = bitcast %struct.point5* %2 to i8* + %9 = bitcast %struct.point5* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 5, i1 false) + %10 = bitcast i40* %5 to i8* + %11 = bitcast %struct.point5* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 1 %11, i64 5, i1 false) + %12 = load i40, i40* %5, align 8 + ret i40 %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i48 @demo6(i64 %0) #0 { + %2 = alloca %struct.point6, align 1 + %3 = alloca %struct.point6, align 1 + %4 = alloca i64, align 8 + %5 = alloca i48, align 8 + store i64 %0, i64* %4, align 8 + %6 = bitcast %struct.point6* %3 to i8* + %7 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 8 %7, i64 6, i1 false) + %8 = bitcast %struct.point6* %2 to i8* + %9 = bitcast %struct.point6* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 6, i1 false) + %10 = bitcast i48* %5 to i8* + %11 = bitcast %struct.point6* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 1 %11, i64 6, i1 false) + %12 = load i48, i48* %5, align 8 + ret i48 %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i56 @demo7(i64 %0) #0 { + %2 = alloca %struct.point7, align 1 + %3 = alloca %struct.point7, align 1 + %4 = alloca i64, align 8 + %5 = alloca i56, align 8 + store i64 %0, i64* %4, align 8 + %6 = bitcast %struct.point7* %3 to i8* + %7 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 8 %7, i64 7, i1 false) + %8 = bitcast %struct.point7* %2 to i8* + %9 = bitcast %struct.point7* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 7, i1 false) + %10 = bitcast i56* %5 to i8* + %11 = bitcast %struct.point7* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 1 %11, i64 7, i1 false) + %12 = load i56, i56* %5, align 8 + ret i56 %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i64 @demo8(i64 %0) #0 { + %2 = alloca %struct.point8, align 1 + %3 = alloca %struct.point8, align 1 + %4 = bitcast %struct.point8* %3 to i64* + store i64 %0, i64* %4, align 1 + %5 = bitcast %struct.point8* %2 to i8* + %6 = bitcast %struct.point8* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %5, i8* align 1 %6, i64 8, i1 false) + %7 = bitcast %struct.point8* %2 to i64* + %8 = load i64, i64* %7, align 1 + ret i64 %8 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo9([2 x i64] %0) #0 { + %2 = alloca %struct.point9, align 1 + %3 = alloca %struct.point9, align 1 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %6 = bitcast %struct.point9* %3 to i8* + %7 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 8 %7, i64 9, i1 false) + %8 = bitcast %struct.point9* %2 to i8* + %9 = bitcast %struct.point9* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 9, i1 false) + %10 = bitcast [2 x i64]* %5 to i8* + %11 = bitcast %struct.point9* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 1 %11, i64 9, i1 false) + %12 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo10([2 x i64] %0) #0 { + %2 = alloca %struct.point10, align 1 + %3 = alloca %struct.point10, align 1 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %6 = bitcast %struct.point10* %3 to i8* + %7 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 8 %7, i64 10, i1 false) + %8 = bitcast %struct.point10* %2 to i8* + %9 = bitcast %struct.point10* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 10, i1 false) + %10 = bitcast [2 x i64]* %5 to i8* + %11 = bitcast %struct.point10* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 1 %11, i64 10, i1 false) + %12 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo11([2 x i64] %0) #0 { + %2 = alloca %struct.point11, align 1 + %3 = alloca %struct.point11, align 1 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %6 = bitcast %struct.point11* %3 to i8* + %7 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 8 %7, i64 11, i1 false) + %8 = bitcast %struct.point11* %2 to i8* + %9 = bitcast %struct.point11* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 11, i1 false) + %10 = bitcast [2 x i64]* %5 to i8* + %11 = bitcast %struct.point11* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 1 %11, i64 11, i1 false) + %12 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo12([2 x i64] %0) #0 { + %2 = alloca %struct.point12, align 1 + %3 = alloca %struct.point12, align 1 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %6 = bitcast %struct.point12* %3 to i8* + %7 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 8 %7, i64 12, i1 false) + %8 = bitcast %struct.point12* %2 to i8* + %9 = bitcast %struct.point12* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 12, i1 false) + %10 = bitcast [2 x i64]* %5 to i8* + %11 = bitcast %struct.point12* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 1 %11, i64 12, i1 false) + %12 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo13([2 x i64] %0) #0 { + %2 = alloca %struct.point13, align 1 + %3 = alloca %struct.point13, align 1 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %6 = bitcast %struct.point13* %3 to i8* + %7 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 8 %7, i64 13, i1 false) + %8 = bitcast %struct.point13* %2 to i8* + %9 = bitcast %struct.point13* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 13, i1 false) + %10 = bitcast [2 x i64]* %5 to i8* + %11 = bitcast %struct.point13* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 1 %11, i64 13, i1 false) + %12 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo14([2 x i64] %0) #0 { + %2 = alloca %struct.point14, align 1 + %3 = alloca %struct.point14, align 1 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %6 = bitcast %struct.point14* %3 to i8* + %7 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 8 %7, i64 14, i1 false) + %8 = bitcast %struct.point14* %2 to i8* + %9 = bitcast %struct.point14* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 14, i1 false) + %10 = bitcast [2 x i64]* %5 to i8* + %11 = bitcast %struct.point14* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 1 %11, i64 14, i1 false) + %12 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo15([2 x i64] %0) #0 { + %2 = alloca %struct.point15, align 1 + %3 = alloca %struct.point15, align 1 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %6 = bitcast %struct.point15* %3 to i8* + %7 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 8 %7, i64 15, i1 false) + %8 = bitcast %struct.point15* %2 to i8* + %9 = bitcast %struct.point15* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 15, i1 false) + %10 = bitcast [2 x i64]* %5 to i8* + %11 = bitcast %struct.point15* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 1 %11, i64 15, i1 false) + %12 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %12 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo16([2 x i64] %0) #0 { + %2 = alloca %struct.point16, align 1 + %3 = alloca %struct.point16, align 1 + %4 = bitcast %struct.point16* %3 to [2 x i64]* + store [2 x i64] %0, [2 x i64]* %4, align 1 + %5 = bitcast %struct.point16* %2 to i8* + %6 = bitcast %struct.point16* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %5, i8* align 1 %6, i64 16, i1 false) + %7 = bitcast %struct.point16* %2 to [2 x i64]* + %8 = load [2 x i64], [2 x i64]* %7, align 1 + ret [2 x i64] %8 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 1 %0, %struct.point17* noundef %1) #0 { + %3 = bitcast %struct.point17* %0 to i8* + %4 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %3, i8* align 1 %4, i64 17, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 1 %0, %struct.point18* noundef %1) #0 { + %3 = bitcast %struct.point18* %0 to i8* + %4 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %3, i8* align 1 %4, i64 18, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 1 %0, %struct.point19* noundef %1) #0 { + %3 = bitcast %struct.point19* %0 to i8* + %4 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %3, i8* align 1 %4, i64 19, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 1 %0, %struct.point20* noundef %1) #0 { + %3 = bitcast %struct.point20* %0 to i8* + %4 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %3, i8* align 1 %4, i64 20, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="non-leaf" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon,+v8a" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 8, !"branch-target-enforcement", i32 0} +!2 = !{i32 8, !"sign-return-address", i32 0} +!3 = !{i32 8, !"sign-return-address-all", i32 0} +!4 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!5 = !{i32 7, !"PIC Level", i32 2} +!6 = !{i32 7, !"PIE Level", i32 2} +!7 = !{i32 7, !"uwtable", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 1} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/arm64/struct_uintptr.ll b/internal/cabi/_testdata/arch/arm64/struct_uintptr.ll new file mode 100644 index 00000000..4ddf4007 --- /dev/null +++ b/internal/cabi/_testdata/arch/arm64/struct_uintptr.ll @@ -0,0 +1,219 @@ +; ModuleID = '../../wrap/struct_uintptr.c' +source_filename = "../../wrap/struct_uintptr.c" +target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" +target triple = "aarch64-unknown-linux-gnu" + +%struct.point1 = type { i8* } +%struct.point2 = type { i8*, i8* } +%struct.point3 = type { i8*, i8*, i8* } +%struct.point4 = type { i8*, i8*, i8*, i8* } +%struct.point5 = type { i8*, i8*, i8*, i8*, i8* } +%struct.point6 = type { i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point7 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point8 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point9 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point10 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point11 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point12 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point13 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point14 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point15 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point16 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point17 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point18 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point19 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point20 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i64 @demo1(i64 %0) #0 { + %2 = alloca %struct.point1, align 8 + %3 = alloca %struct.point1, align 8 + %4 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + %5 = inttoptr i64 %0 to i8* + store i8* %5, i8** %4, align 8 + %6 = bitcast %struct.point1* %2 to i8* + %7 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %6, i8* align 8 %7, i64 8, i1 false) + %8 = getelementptr inbounds %struct.point1, %struct.point1* %2, i32 0, i32 0 + %9 = load i8*, i8** %8, align 8 + %10 = ptrtoint i8* %9 to i64 + ret i64 %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local [2 x i64] @demo2([2 x i64] %0) #0 { + %2 = alloca %struct.point2, align 8 + %3 = alloca %struct.point2, align 8 + %4 = bitcast %struct.point2* %3 to [2 x i64]* + store [2 x i64] %0, [2 x i64]* %4, align 8 + %5 = bitcast %struct.point2* %2 to i8* + %6 = bitcast %struct.point2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 16, i1 false) + %7 = bitcast %struct.point2* %2 to [2 x i64]* + %8 = load [2 x i64], [2 x i64]* %7, align 8 + ret [2 x i64] %8 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo3(%struct.point3* noalias sret(%struct.point3) align 8 %0, %struct.point3* noundef %1) #0 { + %3 = bitcast %struct.point3* %0 to i8* + %4 = bitcast %struct.point3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo4(%struct.point4* noalias sret(%struct.point4) align 8 %0, %struct.point4* noundef %1) #0 { + %3 = bitcast %struct.point4* %0 to i8* + %4 = bitcast %struct.point4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.point5* noalias sret(%struct.point5) align 8 %0, %struct.point5* noundef %1) #0 { + %3 = bitcast %struct.point5* %0 to i8* + %4 = bitcast %struct.point5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.point6* noalias sret(%struct.point6) align 8 %0, %struct.point6* noundef %1) #0 { + %3 = bitcast %struct.point6* %0 to i8* + %4 = bitcast %struct.point6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.point7* noalias sret(%struct.point7) align 8 %0, %struct.point7* noundef %1) #0 { + %3 = bitcast %struct.point7* %0 to i8* + %4 = bitcast %struct.point7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.point8* noalias sret(%struct.point8) align 8 %0, %struct.point8* noundef %1) #0 { + %3 = bitcast %struct.point8* %0 to i8* + %4 = bitcast %struct.point8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 8 %0, %struct.point9* noundef %1) #0 { + %3 = bitcast %struct.point9* %0 to i8* + %4 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 8 %0, %struct.point10* noundef %1) #0 { + %3 = bitcast %struct.point10* %0 to i8* + %4 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 8 %0, %struct.point11* noundef %1) #0 { + %3 = bitcast %struct.point11* %0 to i8* + %4 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 8 %0, %struct.point12* noundef %1) #0 { + %3 = bitcast %struct.point12* %0 to i8* + %4 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 8 %0, %struct.point13* noundef %1) #0 { + %3 = bitcast %struct.point13* %0 to i8* + %4 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 8 %0, %struct.point14* noundef %1) #0 { + %3 = bitcast %struct.point14* %0 to i8* + %4 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 8 %0, %struct.point15* noundef %1) #0 { + %3 = bitcast %struct.point15* %0 to i8* + %4 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 8 %0, %struct.point16* noundef %1) #0 { + %3 = bitcast %struct.point16* %0 to i8* + %4 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 8 %0, %struct.point17* noundef %1) #0 { + %3 = bitcast %struct.point17* %0 to i8* + %4 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 8 %0, %struct.point18* noundef %1) #0 { + %3 = bitcast %struct.point18* %0 to i8* + %4 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 8 %0, %struct.point19* noundef %1) #0 { + %3 = bitcast %struct.point19* %0 to i8* + %4 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 8 %0, %struct.point20* noundef %1) #0 { + %3 = bitcast %struct.point20* %0 to i8* + %4 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="non-leaf" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon,+v8a" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 8, !"branch-target-enforcement", i32 0} +!2 = !{i32 8, !"sign-return-address", i32 0} +!3 = !{i32 8, !"sign-return-address-all", i32 0} +!4 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!5 = !{i32 7, !"PIC Level", i32 2} +!6 = !{i32 7, !"PIE Level", i32 2} +!7 = !{i32 7, !"uwtable", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 1} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/armv6/array_float32.ll b/internal/cabi/_testdata/arch/armv6/array_float32.ll new file mode 100644 index 00000000..31011f75 --- /dev/null +++ b/internal/cabi/_testdata/arch/armv6/array_float32.ll @@ -0,0 +1,269 @@ +; ModuleID = '../../wrap/array_float32.c' +source_filename = "../../wrap/array_float32.c" +target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64" +target triple = "armv6kz-unknown-linux-gnueabihf" + +%struct.array1 = type { [1 x float] } +%struct.array2 = type { [2 x float] } +%struct.array3 = type { [3 x float] } +%struct.array4 = type { [4 x float] } +%struct.array5 = type { [5 x float] } +%struct.array6 = type { [6 x float] } +%struct.array7 = type { [7 x float] } +%struct.array8 = type { [8 x float] } +%struct.array9 = type { [9 x float] } +%struct.array10 = type { [10 x float] } +%struct.array11 = type { [11 x float] } +%struct.array12 = type { [12 x float] } +%struct.array13 = type { [13 x float] } +%struct.array14 = type { [14 x float] } +%struct.array15 = type { [15 x float] } +%struct.array16 = type { [16 x float] } +%struct.array17 = type { [17 x float] } +%struct.array18 = type { [18 x float] } +%struct.array19 = type { [19 x float] } +%struct.array20 = type { [20 x float] } + +; Function Attrs: noinline nounwind optnone +define dso_local %struct.array1 @demo1(%struct.array1 %0) #0 { + %2 = alloca %struct.array1, align 4 + %3 = alloca %struct.array1, align 4 + store %struct.array1 %0, %struct.array1* %3, align 4 + %4 = bitcast %struct.array1* %2 to i8* + %5 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %4, i8* align 4 %5, i32 4, i1 false) + %6 = load %struct.array1, %struct.array1* %2, align 4 + ret %struct.array1 %6 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define dso_local %struct.array2 @demo2(%struct.array2 %0) #0 { + %2 = alloca %struct.array2, align 4 + %3 = alloca %struct.array2, align 4 + store %struct.array2 %0, %struct.array2* %3, align 4 + %4 = bitcast %struct.array2* %2 to i8* + %5 = bitcast %struct.array2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %4, i8* align 4 %5, i32 8, i1 false) + %6 = load %struct.array2, %struct.array2* %2, align 4 + ret %struct.array2 %6 +} + +; Function Attrs: noinline nounwind optnone +define dso_local %struct.array3 @demo3(%struct.array3 %0) #0 { + %2 = alloca %struct.array3, align 4 + %3 = alloca %struct.array3, align 4 + store %struct.array3 %0, %struct.array3* %3, align 4 + %4 = bitcast %struct.array3* %2 to i8* + %5 = bitcast %struct.array3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %4, i8* align 4 %5, i32 12, i1 false) + %6 = load %struct.array3, %struct.array3* %2, align 4 + ret %struct.array3 %6 +} + +; Function Attrs: noinline nounwind optnone +define dso_local %struct.array4 @demo4(%struct.array4 %0) #0 { + %2 = alloca %struct.array4, align 4 + %3 = alloca %struct.array4, align 4 + store %struct.array4 %0, %struct.array4* %3, align 4 + %4 = bitcast %struct.array4* %2 to i8* + %5 = bitcast %struct.array4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %4, i8* align 4 %5, i32 16, i1 false) + %6 = load %struct.array4, %struct.array4* %2, align 4 + ret %struct.array4 %6 +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 4 %0, [5 x i32] %1) #0 { + %3 = alloca %struct.array5, align 4 + %4 = getelementptr inbounds %struct.array5, %struct.array5* %3, i32 0, i32 0 + %5 = bitcast [5 x float]* %4 to [5 x i32]* + store [5 x i32] %1, [5 x i32]* %5, align 4 + %6 = bitcast %struct.array5* %0 to i8* + %7 = bitcast %struct.array5* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 4 %0, [6 x i32] %1) #0 { + %3 = alloca %struct.array6, align 4 + %4 = getelementptr inbounds %struct.array6, %struct.array6* %3, i32 0, i32 0 + %5 = bitcast [6 x float]* %4 to [6 x i32]* + store [6 x i32] %1, [6 x i32]* %5, align 4 + %6 = bitcast %struct.array6* %0 to i8* + %7 = bitcast %struct.array6* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 4 %0, [7 x i32] %1) #0 { + %3 = alloca %struct.array7, align 4 + %4 = getelementptr inbounds %struct.array7, %struct.array7* %3, i32 0, i32 0 + %5 = bitcast [7 x float]* %4 to [7 x i32]* + store [7 x i32] %1, [7 x i32]* %5, align 4 + %6 = bitcast %struct.array7* %0 to i8* + %7 = bitcast %struct.array7* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 4 %0, [8 x i32] %1) #0 { + %3 = alloca %struct.array8, align 4 + %4 = getelementptr inbounds %struct.array8, %struct.array8* %3, i32 0, i32 0 + %5 = bitcast [8 x float]* %4 to [8 x i32]* + store [8 x i32] %1, [8 x i32]* %5, align 4 + %6 = bitcast %struct.array8* %0 to i8* + %7 = bitcast %struct.array8* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 4 %0, [9 x i32] %1) #0 { + %3 = alloca %struct.array9, align 4 + %4 = getelementptr inbounds %struct.array9, %struct.array9* %3, i32 0, i32 0 + %5 = bitcast [9 x float]* %4 to [9 x i32]* + store [9 x i32] %1, [9 x i32]* %5, align 4 + %6 = bitcast %struct.array9* %0 to i8* + %7 = bitcast %struct.array9* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 4 %0, [10 x i32] %1) #0 { + %3 = alloca %struct.array10, align 4 + %4 = getelementptr inbounds %struct.array10, %struct.array10* %3, i32 0, i32 0 + %5 = bitcast [10 x float]* %4 to [10 x i32]* + store [10 x i32] %1, [10 x i32]* %5, align 4 + %6 = bitcast %struct.array10* %0 to i8* + %7 = bitcast %struct.array10* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 4 %0, [11 x i32] %1) #0 { + %3 = alloca %struct.array11, align 4 + %4 = getelementptr inbounds %struct.array11, %struct.array11* %3, i32 0, i32 0 + %5 = bitcast [11 x float]* %4 to [11 x i32]* + store [11 x i32] %1, [11 x i32]* %5, align 4 + %6 = bitcast %struct.array11* %0 to i8* + %7 = bitcast %struct.array11* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 4 %0, [12 x i32] %1) #0 { + %3 = alloca %struct.array12, align 4 + %4 = getelementptr inbounds %struct.array12, %struct.array12* %3, i32 0, i32 0 + %5 = bitcast [12 x float]* %4 to [12 x i32]* + store [12 x i32] %1, [12 x i32]* %5, align 4 + %6 = bitcast %struct.array12* %0 to i8* + %7 = bitcast %struct.array12* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 4 %0, [13 x i32] %1) #0 { + %3 = alloca %struct.array13, align 4 + %4 = getelementptr inbounds %struct.array13, %struct.array13* %3, i32 0, i32 0 + %5 = bitcast [13 x float]* %4 to [13 x i32]* + store [13 x i32] %1, [13 x i32]* %5, align 4 + %6 = bitcast %struct.array13* %0 to i8* + %7 = bitcast %struct.array13* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 4 %0, [14 x i32] %1) #0 { + %3 = alloca %struct.array14, align 4 + %4 = getelementptr inbounds %struct.array14, %struct.array14* %3, i32 0, i32 0 + %5 = bitcast [14 x float]* %4 to [14 x i32]* + store [14 x i32] %1, [14 x i32]* %5, align 4 + %6 = bitcast %struct.array14* %0 to i8* + %7 = bitcast %struct.array14* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 4 %0, [15 x i32] %1) #0 { + %3 = alloca %struct.array15, align 4 + %4 = getelementptr inbounds %struct.array15, %struct.array15* %3, i32 0, i32 0 + %5 = bitcast [15 x float]* %4 to [15 x i32]* + store [15 x i32] %1, [15 x i32]* %5, align 4 + %6 = bitcast %struct.array15* %0 to i8* + %7 = bitcast %struct.array15* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 4 %0, [16 x i32] %1) #0 { + %3 = alloca %struct.array16, align 4 + %4 = getelementptr inbounds %struct.array16, %struct.array16* %3, i32 0, i32 0 + %5 = bitcast [16 x float]* %4 to [16 x i32]* + store [16 x i32] %1, [16 x i32]* %5, align 4 + %6 = bitcast %struct.array16* %0 to i8* + %7 = bitcast %struct.array16* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 4 %0, %struct.array17* noundef byval(%struct.array17) align 4 %1) #0 { + %3 = bitcast %struct.array17* %0 to i8* + %4 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 4 %0, %struct.array18* noundef byval(%struct.array18) align 4 %1) #0 { + %3 = bitcast %struct.array18* %0 to i8* + %4 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 4 %0, %struct.array19* noundef byval(%struct.array19) align 4 %1) #0 { + %3 = bitcast %struct.array19* %0 to i8* + %4 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 4 %0, %struct.array20* noundef byval(%struct.array20) align 4 %1) #0 { + %3 = bitcast %struct.array20* %0 to i8* + %4 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="arm1176jzf-s" "target-features"="+armv6kz,+dsp,+fp64,+strict-align,+vfp2,+vfp2sp,-aes,-d32,-fp-armv8,-fp-armv8d16,-fp-armv8d16sp,-fp-armv8sp,-fp16,-fp16fml,-fullfp16,-neon,-sha2,-thumb-mode,-vfp3,-vfp3d16,-vfp3d16sp,-vfp3sp,-vfp4,-vfp4d16,-vfp4d16sp,-vfp4sp" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"min_enum_size", i32 4} +!2 = !{i32 8, !"branch-target-enforcement", i32 0} +!3 = !{i32 8, !"sign-return-address", i32 0} +!4 = !{i32 8, !"sign-return-address-all", i32 0} +!5 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!6 = !{i32 7, !"PIC Level", i32 2} +!7 = !{i32 7, !"PIE Level", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 2} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/armv6/array_float64.ll b/internal/cabi/_testdata/arch/armv6/array_float64.ll new file mode 100644 index 00000000..f1cb5710 --- /dev/null +++ b/internal/cabi/_testdata/arch/armv6/array_float64.ll @@ -0,0 +1,237 @@ +; ModuleID = '../../wrap/array_float64.c' +source_filename = "../../wrap/array_float64.c" +target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64" +target triple = "armv6kz-unknown-linux-gnueabihf" + +%struct.array1 = type { [1 x double] } +%struct.array2 = type { [2 x double] } +%struct.array3 = type { [3 x double] } +%struct.array4 = type { [4 x double] } +%struct.array5 = type { [5 x double] } +%struct.array6 = type { [6 x double] } +%struct.array7 = type { [7 x double] } +%struct.array8 = type { [8 x double] } +%struct.array9 = type { [9 x double] } +%struct.array10 = type { [10 x double] } +%struct.array11 = type { [11 x double] } +%struct.array12 = type { [12 x double] } +%struct.array13 = type { [13 x double] } +%struct.array14 = type { [14 x double] } +%struct.array15 = type { [15 x double] } +%struct.array16 = type { [16 x double] } +%struct.array17 = type { [17 x double] } +%struct.array18 = type { [18 x double] } +%struct.array19 = type { [19 x double] } +%struct.array20 = type { [20 x double] } + +; Function Attrs: noinline nounwind optnone +define dso_local %struct.array1 @demo1(%struct.array1 %0) #0 { + %2 = alloca %struct.array1, align 8 + %3 = alloca %struct.array1, align 8 + store %struct.array1 %0, %struct.array1* %3, align 8 + %4 = bitcast %struct.array1* %2 to i8* + %5 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %4, i8* align 8 %5, i32 8, i1 false) + %6 = load %struct.array1, %struct.array1* %2, align 8 + ret %struct.array1 %6 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define dso_local %struct.array2 @demo2(%struct.array2 %0) #0 { + %2 = alloca %struct.array2, align 8 + %3 = alloca %struct.array2, align 8 + store %struct.array2 %0, %struct.array2* %3, align 8 + %4 = bitcast %struct.array2* %2 to i8* + %5 = bitcast %struct.array2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %4, i8* align 8 %5, i32 16, i1 false) + %6 = load %struct.array2, %struct.array2* %2, align 8 + ret %struct.array2 %6 +} + +; Function Attrs: noinline nounwind optnone +define dso_local %struct.array3 @demo3(%struct.array3 %0) #0 { + %2 = alloca %struct.array3, align 8 + %3 = alloca %struct.array3, align 8 + store %struct.array3 %0, %struct.array3* %3, align 8 + %4 = bitcast %struct.array3* %2 to i8* + %5 = bitcast %struct.array3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %4, i8* align 8 %5, i32 24, i1 false) + %6 = load %struct.array3, %struct.array3* %2, align 8 + ret %struct.array3 %6 +} + +; Function Attrs: noinline nounwind optnone +define dso_local %struct.array4 @demo4(%struct.array4 %0) #0 { + %2 = alloca %struct.array4, align 8 + %3 = alloca %struct.array4, align 8 + store %struct.array4 %0, %struct.array4* %3, align 8 + %4 = bitcast %struct.array4* %2 to i8* + %5 = bitcast %struct.array4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %4, i8* align 8 %5, i32 32, i1 false) + %6 = load %struct.array4, %struct.array4* %2, align 8 + ret %struct.array4 %6 +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 8 %0, [5 x i64] %1) #0 { + %3 = alloca %struct.array5, align 8 + %4 = getelementptr inbounds %struct.array5, %struct.array5* %3, i32 0, i32 0 + %5 = bitcast [5 x double]* %4 to [5 x i64]* + store [5 x i64] %1, [5 x i64]* %5, align 8 + %6 = bitcast %struct.array5* %0 to i8* + %7 = bitcast %struct.array5* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %6, i8* align 8 %7, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 8 %0, [6 x i64] %1) #0 { + %3 = alloca %struct.array6, align 8 + %4 = getelementptr inbounds %struct.array6, %struct.array6* %3, i32 0, i32 0 + %5 = bitcast [6 x double]* %4 to [6 x i64]* + store [6 x i64] %1, [6 x i64]* %5, align 8 + %6 = bitcast %struct.array6* %0 to i8* + %7 = bitcast %struct.array6* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %6, i8* align 8 %7, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 8 %0, [7 x i64] %1) #0 { + %3 = alloca %struct.array7, align 8 + %4 = getelementptr inbounds %struct.array7, %struct.array7* %3, i32 0, i32 0 + %5 = bitcast [7 x double]* %4 to [7 x i64]* + store [7 x i64] %1, [7 x i64]* %5, align 8 + %6 = bitcast %struct.array7* %0 to i8* + %7 = bitcast %struct.array7* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %6, i8* align 8 %7, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 8 %0, [8 x i64] %1) #0 { + %3 = alloca %struct.array8, align 8 + %4 = getelementptr inbounds %struct.array8, %struct.array8* %3, i32 0, i32 0 + %5 = bitcast [8 x double]* %4 to [8 x i64]* + store [8 x i64] %1, [8 x i64]* %5, align 8 + %6 = bitcast %struct.array8* %0 to i8* + %7 = bitcast %struct.array8* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %6, i8* align 8 %7, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 8 %0, %struct.array9* noundef byval(%struct.array9) align 8 %1) #0 { + %3 = bitcast %struct.array9* %0 to i8* + %4 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 8 %0, %struct.array10* noundef byval(%struct.array10) align 8 %1) #0 { + %3 = bitcast %struct.array10* %0 to i8* + %4 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 8 %0, %struct.array11* noundef byval(%struct.array11) align 8 %1) #0 { + %3 = bitcast %struct.array11* %0 to i8* + %4 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 8 %0, %struct.array12* noundef byval(%struct.array12) align 8 %1) #0 { + %3 = bitcast %struct.array12* %0 to i8* + %4 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 8 %0, %struct.array13* noundef byval(%struct.array13) align 8 %1) #0 { + %3 = bitcast %struct.array13* %0 to i8* + %4 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 8 %0, %struct.array14* noundef byval(%struct.array14) align 8 %1) #0 { + %3 = bitcast %struct.array14* %0 to i8* + %4 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 8 %0, %struct.array15* noundef byval(%struct.array15) align 8 %1) #0 { + %3 = bitcast %struct.array15* %0 to i8* + %4 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 8 %0, %struct.array16* noundef byval(%struct.array16) align 8 %1) #0 { + %3 = bitcast %struct.array16* %0 to i8* + %4 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 8 %0, %struct.array17* noundef byval(%struct.array17) align 8 %1) #0 { + %3 = bitcast %struct.array17* %0 to i8* + %4 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 8 %0, %struct.array18* noundef byval(%struct.array18) align 8 %1) #0 { + %3 = bitcast %struct.array18* %0 to i8* + %4 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 8 %0, %struct.array19* noundef byval(%struct.array19) align 8 %1) #0 { + %3 = bitcast %struct.array19* %0 to i8* + %4 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 8 %0, %struct.array20* noundef byval(%struct.array20) align 8 %1) #0 { + %3 = bitcast %struct.array20* %0 to i8* + %4 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="arm1176jzf-s" "target-features"="+armv6kz,+dsp,+fp64,+strict-align,+vfp2,+vfp2sp,-aes,-d32,-fp-armv8,-fp-armv8d16,-fp-armv8d16sp,-fp-armv8sp,-fp16,-fp16fml,-fullfp16,-neon,-sha2,-thumb-mode,-vfp3,-vfp3d16,-vfp3d16sp,-vfp3sp,-vfp4,-vfp4d16,-vfp4d16sp,-vfp4sp" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"min_enum_size", i32 4} +!2 = !{i32 8, !"branch-target-enforcement", i32 0} +!3 = !{i32 8, !"sign-return-address", i32 0} +!4 = !{i32 8, !"sign-return-address-all", i32 0} +!5 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!6 = !{i32 7, !"PIC Level", i32 2} +!7 = !{i32 7, !"PIE Level", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 2} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/armv6/array_int16.ll b/internal/cabi/_testdata/arch/armv6/array_int16.ll new file mode 100644 index 00000000..47aab250 --- /dev/null +++ b/internal/cabi/_testdata/arch/armv6/array_int16.ll @@ -0,0 +1,323 @@ +; ModuleID = '../../wrap/array_int16.c' +source_filename = "../../wrap/array_int16.c" +target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64" +target triple = "armv6kz-unknown-linux-gnueabihf" + +%struct.array1 = type { [1 x i16] } +%struct.array2 = type { [2 x i16] } +%struct.array3 = type { [3 x i16] } +%struct.array4 = type { [4 x i16] } +%struct.array5 = type { [5 x i16] } +%struct.array6 = type { [6 x i16] } +%struct.array7 = type { [7 x i16] } +%struct.array8 = type { [8 x i16] } +%struct.array9 = type { [9 x i16] } +%struct.array10 = type { [10 x i16] } +%struct.array11 = type { [11 x i16] } +%struct.array12 = type { [12 x i16] } +%struct.array13 = type { [13 x i16] } +%struct.array14 = type { [14 x i16] } +%struct.array15 = type { [15 x i16] } +%struct.array16 = type { [16 x i16] } +%struct.array17 = type { [17 x i16] } +%struct.array18 = type { [18 x i16] } +%struct.array19 = type { [19 x i16] } +%struct.array20 = type { [20 x i16] } + +; Function Attrs: noinline nounwind optnone +define dso_local i16 @demo1([1 x i32] %0) #0 { + %2 = alloca %struct.array1, align 2 + %3 = alloca %struct.array1, align 2 + %4 = alloca [1 x i32], align 4 + %5 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + store [1 x i32] %0, [1 x i32]* %4, align 4 + %6 = bitcast [1 x i16]* %5 to i8* + %7 = bitcast [1 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %6, i8* align 4 %7, i32 2, i1 false) + %8 = bitcast %struct.array1* %2 to i8* + %9 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %8, i8* align 2 %9, i32 2, i1 false) + %10 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %11 = bitcast [1 x i16]* %10 to i16* + %12 = load i16, i16* %11, align 2 + ret i16 %12 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define dso_local i32 @demo2([1 x i32] %0) #0 { + %2 = alloca %struct.array2, align 2 + %3 = alloca %struct.array2, align 2 + %4 = getelementptr inbounds %struct.array2, %struct.array2* %3, i32 0, i32 0 + %5 = bitcast [2 x i16]* %4 to [1 x i32]* + store [1 x i32] %0, [1 x i32]* %5, align 2 + %6 = bitcast %struct.array2* %2 to i8* + %7 = bitcast %struct.array2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %6, i8* align 2 %7, i32 4, i1 false) + %8 = getelementptr inbounds %struct.array2, %struct.array2* %2, i32 0, i32 0 + %9 = bitcast [2 x i16]* %8 to i32* + %10 = load i32, i32* %9, align 2 + ret i32 %10 +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo3(%struct.array3* noalias sret(%struct.array3) align 2 %0, [2 x i32] %1) #0 { + %3 = alloca %struct.array3, align 2 + %4 = alloca [2 x i32], align 4 + %5 = getelementptr inbounds %struct.array3, %struct.array3* %3, i32 0, i32 0 + store [2 x i32] %1, [2 x i32]* %4, align 4 + %6 = bitcast [3 x i16]* %5 to i8* + %7 = bitcast [2 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %6, i8* align 4 %7, i32 6, i1 false) + %8 = bitcast %struct.array3* %0 to i8* + %9 = bitcast %struct.array3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %8, i8* align 2 %9, i32 6, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo4(%struct.array4* noalias sret(%struct.array4) align 2 %0, [2 x i32] %1) #0 { + %3 = alloca %struct.array4, align 2 + %4 = getelementptr inbounds %struct.array4, %struct.array4* %3, i32 0, i32 0 + %5 = bitcast [4 x i16]* %4 to [2 x i32]* + store [2 x i32] %1, [2 x i32]* %5, align 2 + %6 = bitcast %struct.array4* %0 to i8* + %7 = bitcast %struct.array4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %6, i8* align 2 %7, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 2 %0, [3 x i32] %1) #0 { + %3 = alloca %struct.array5, align 2 + %4 = alloca [3 x i32], align 4 + %5 = getelementptr inbounds %struct.array5, %struct.array5* %3, i32 0, i32 0 + store [3 x i32] %1, [3 x i32]* %4, align 4 + %6 = bitcast [5 x i16]* %5 to i8* + %7 = bitcast [3 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %6, i8* align 4 %7, i32 10, i1 false) + %8 = bitcast %struct.array5* %0 to i8* + %9 = bitcast %struct.array5* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %8, i8* align 2 %9, i32 10, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 2 %0, [3 x i32] %1) #0 { + %3 = alloca %struct.array6, align 2 + %4 = getelementptr inbounds %struct.array6, %struct.array6* %3, i32 0, i32 0 + %5 = bitcast [6 x i16]* %4 to [3 x i32]* + store [3 x i32] %1, [3 x i32]* %5, align 2 + %6 = bitcast %struct.array6* %0 to i8* + %7 = bitcast %struct.array6* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %6, i8* align 2 %7, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 2 %0, [4 x i32] %1) #0 { + %3 = alloca %struct.array7, align 2 + %4 = alloca [4 x i32], align 4 + %5 = getelementptr inbounds %struct.array7, %struct.array7* %3, i32 0, i32 0 + store [4 x i32] %1, [4 x i32]* %4, align 4 + %6 = bitcast [7 x i16]* %5 to i8* + %7 = bitcast [4 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %6, i8* align 4 %7, i32 14, i1 false) + %8 = bitcast %struct.array7* %0 to i8* + %9 = bitcast %struct.array7* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %8, i8* align 2 %9, i32 14, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 2 %0, [4 x i32] %1) #0 { + %3 = alloca %struct.array8, align 2 + %4 = getelementptr inbounds %struct.array8, %struct.array8* %3, i32 0, i32 0 + %5 = bitcast [8 x i16]* %4 to [4 x i32]* + store [4 x i32] %1, [4 x i32]* %5, align 2 + %6 = bitcast %struct.array8* %0 to i8* + %7 = bitcast %struct.array8* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %6, i8* align 2 %7, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 2 %0, [5 x i32] %1) #0 { + %3 = alloca %struct.array9, align 2 + %4 = alloca [5 x i32], align 4 + %5 = getelementptr inbounds %struct.array9, %struct.array9* %3, i32 0, i32 0 + store [5 x i32] %1, [5 x i32]* %4, align 4 + %6 = bitcast [9 x i16]* %5 to i8* + %7 = bitcast [5 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %6, i8* align 4 %7, i32 18, i1 false) + %8 = bitcast %struct.array9* %0 to i8* + %9 = bitcast %struct.array9* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %8, i8* align 2 %9, i32 18, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 2 %0, [5 x i32] %1) #0 { + %3 = alloca %struct.array10, align 2 + %4 = getelementptr inbounds %struct.array10, %struct.array10* %3, i32 0, i32 0 + %5 = bitcast [10 x i16]* %4 to [5 x i32]* + store [5 x i32] %1, [5 x i32]* %5, align 2 + %6 = bitcast %struct.array10* %0 to i8* + %7 = bitcast %struct.array10* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %6, i8* align 2 %7, i32 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 2 %0, [6 x i32] %1) #0 { + %3 = alloca %struct.array11, align 2 + %4 = alloca [6 x i32], align 4 + %5 = getelementptr inbounds %struct.array11, %struct.array11* %3, i32 0, i32 0 + store [6 x i32] %1, [6 x i32]* %4, align 4 + %6 = bitcast [11 x i16]* %5 to i8* + %7 = bitcast [6 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %6, i8* align 4 %7, i32 22, i1 false) + %8 = bitcast %struct.array11* %0 to i8* + %9 = bitcast %struct.array11* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %8, i8* align 2 %9, i32 22, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 2 %0, [6 x i32] %1) #0 { + %3 = alloca %struct.array12, align 2 + %4 = getelementptr inbounds %struct.array12, %struct.array12* %3, i32 0, i32 0 + %5 = bitcast [12 x i16]* %4 to [6 x i32]* + store [6 x i32] %1, [6 x i32]* %5, align 2 + %6 = bitcast %struct.array12* %0 to i8* + %7 = bitcast %struct.array12* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %6, i8* align 2 %7, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 2 %0, [7 x i32] %1) #0 { + %3 = alloca %struct.array13, align 2 + %4 = alloca [7 x i32], align 4 + %5 = getelementptr inbounds %struct.array13, %struct.array13* %3, i32 0, i32 0 + store [7 x i32] %1, [7 x i32]* %4, align 4 + %6 = bitcast [13 x i16]* %5 to i8* + %7 = bitcast [7 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %6, i8* align 4 %7, i32 26, i1 false) + %8 = bitcast %struct.array13* %0 to i8* + %9 = bitcast %struct.array13* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %8, i8* align 2 %9, i32 26, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 2 %0, [7 x i32] %1) #0 { + %3 = alloca %struct.array14, align 2 + %4 = getelementptr inbounds %struct.array14, %struct.array14* %3, i32 0, i32 0 + %5 = bitcast [14 x i16]* %4 to [7 x i32]* + store [7 x i32] %1, [7 x i32]* %5, align 2 + %6 = bitcast %struct.array14* %0 to i8* + %7 = bitcast %struct.array14* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %6, i8* align 2 %7, i32 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 2 %0, [8 x i32] %1) #0 { + %3 = alloca %struct.array15, align 2 + %4 = alloca [8 x i32], align 4 + %5 = getelementptr inbounds %struct.array15, %struct.array15* %3, i32 0, i32 0 + store [8 x i32] %1, [8 x i32]* %4, align 4 + %6 = bitcast [15 x i16]* %5 to i8* + %7 = bitcast [8 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %6, i8* align 4 %7, i32 30, i1 false) + %8 = bitcast %struct.array15* %0 to i8* + %9 = bitcast %struct.array15* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %8, i8* align 2 %9, i32 30, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 2 %0, [8 x i32] %1) #0 { + %3 = alloca %struct.array16, align 2 + %4 = getelementptr inbounds %struct.array16, %struct.array16* %3, i32 0, i32 0 + %5 = bitcast [16 x i16]* %4 to [8 x i32]* + store [8 x i32] %1, [8 x i32]* %5, align 2 + %6 = bitcast %struct.array16* %0 to i8* + %7 = bitcast %struct.array16* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %6, i8* align 2 %7, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 2 %0, [9 x i32] %1) #0 { + %3 = alloca %struct.array17, align 2 + %4 = alloca [9 x i32], align 4 + %5 = getelementptr inbounds %struct.array17, %struct.array17* %3, i32 0, i32 0 + store [9 x i32] %1, [9 x i32]* %4, align 4 + %6 = bitcast [17 x i16]* %5 to i8* + %7 = bitcast [9 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %6, i8* align 4 %7, i32 34, i1 false) + %8 = bitcast %struct.array17* %0 to i8* + %9 = bitcast %struct.array17* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %8, i8* align 2 %9, i32 34, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 2 %0, [9 x i32] %1) #0 { + %3 = alloca %struct.array18, align 2 + %4 = getelementptr inbounds %struct.array18, %struct.array18* %3, i32 0, i32 0 + %5 = bitcast [18 x i16]* %4 to [9 x i32]* + store [9 x i32] %1, [9 x i32]* %5, align 2 + %6 = bitcast %struct.array18* %0 to i8* + %7 = bitcast %struct.array18* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %6, i8* align 2 %7, i32 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 2 %0, [10 x i32] %1) #0 { + %3 = alloca %struct.array19, align 2 + %4 = alloca [10 x i32], align 4 + %5 = getelementptr inbounds %struct.array19, %struct.array19* %3, i32 0, i32 0 + store [10 x i32] %1, [10 x i32]* %4, align 4 + %6 = bitcast [19 x i16]* %5 to i8* + %7 = bitcast [10 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %6, i8* align 4 %7, i32 38, i1 false) + %8 = bitcast %struct.array19* %0 to i8* + %9 = bitcast %struct.array19* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %8, i8* align 2 %9, i32 38, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 2 %0, [10 x i32] %1) #0 { + %3 = alloca %struct.array20, align 2 + %4 = getelementptr inbounds %struct.array20, %struct.array20* %3, i32 0, i32 0 + %5 = bitcast [20 x i16]* %4 to [10 x i32]* + store [10 x i32] %1, [10 x i32]* %5, align 2 + %6 = bitcast %struct.array20* %0 to i8* + %7 = bitcast %struct.array20* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %6, i8* align 2 %7, i32 40, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="arm1176jzf-s" "target-features"="+armv6kz,+dsp,+fp64,+strict-align,+vfp2,+vfp2sp,-aes,-d32,-fp-armv8,-fp-armv8d16,-fp-armv8d16sp,-fp-armv8sp,-fp16,-fp16fml,-fullfp16,-neon,-sha2,-thumb-mode,-vfp3,-vfp3d16,-vfp3d16sp,-vfp3sp,-vfp4,-vfp4d16,-vfp4d16sp,-vfp4sp" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"min_enum_size", i32 4} +!2 = !{i32 8, !"branch-target-enforcement", i32 0} +!3 = !{i32 8, !"sign-return-address", i32 0} +!4 = !{i32 8, !"sign-return-address-all", i32 0} +!5 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!6 = !{i32 7, !"PIC Level", i32 2} +!7 = !{i32 7, !"PIE Level", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 2} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/armv6/array_int32.ll b/internal/cabi/_testdata/arch/armv6/array_int32.ll new file mode 100644 index 00000000..4592e84c --- /dev/null +++ b/internal/cabi/_testdata/arch/armv6/array_int32.ll @@ -0,0 +1,257 @@ +; ModuleID = '../../wrap/array_int32.c' +source_filename = "../../wrap/array_int32.c" +target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64" +target triple = "armv6kz-unknown-linux-gnueabihf" + +%struct.array1 = type { [1 x i32] } +%struct.array2 = type { [2 x i32] } +%struct.array3 = type { [3 x i32] } +%struct.array4 = type { [4 x i32] } +%struct.array5 = type { [5 x i32] } +%struct.array6 = type { [6 x i32] } +%struct.array7 = type { [7 x i32] } +%struct.array8 = type { [8 x i32] } +%struct.array9 = type { [9 x i32] } +%struct.array10 = type { [10 x i32] } +%struct.array11 = type { [11 x i32] } +%struct.array12 = type { [12 x i32] } +%struct.array13 = type { [13 x i32] } +%struct.array14 = type { [14 x i32] } +%struct.array15 = type { [15 x i32] } +%struct.array16 = type { [16 x i32] } +%struct.array17 = type { [17 x i32] } +%struct.array18 = type { [18 x i32] } +%struct.array19 = type { [19 x i32] } +%struct.array20 = type { [20 x i32] } + +; Function Attrs: noinline nounwind optnone +define dso_local i32 @demo1([1 x i32] %0) #0 { + %2 = alloca %struct.array1, align 4 + %3 = alloca %struct.array1, align 4 + %4 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + store [1 x i32] %0, [1 x i32]* %4, align 4 + %5 = bitcast %struct.array1* %2 to i8* + %6 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 4, i1 false) + %7 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %8 = bitcast [1 x i32]* %7 to i32* + %9 = load i32, i32* %8, align 4 + ret i32 %9 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo2(%struct.array2* noalias sret(%struct.array2) align 4 %0, [2 x i32] %1) #0 { + %3 = alloca %struct.array2, align 4 + %4 = getelementptr inbounds %struct.array2, %struct.array2* %3, i32 0, i32 0 + store [2 x i32] %1, [2 x i32]* %4, align 4 + %5 = bitcast %struct.array2* %0 to i8* + %6 = bitcast %struct.array2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo3(%struct.array3* noalias sret(%struct.array3) align 4 %0, [3 x i32] %1) #0 { + %3 = alloca %struct.array3, align 4 + %4 = getelementptr inbounds %struct.array3, %struct.array3* %3, i32 0, i32 0 + store [3 x i32] %1, [3 x i32]* %4, align 4 + %5 = bitcast %struct.array3* %0 to i8* + %6 = bitcast %struct.array3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo4(%struct.array4* noalias sret(%struct.array4) align 4 %0, [4 x i32] %1) #0 { + %3 = alloca %struct.array4, align 4 + %4 = getelementptr inbounds %struct.array4, %struct.array4* %3, i32 0, i32 0 + store [4 x i32] %1, [4 x i32]* %4, align 4 + %5 = bitcast %struct.array4* %0 to i8* + %6 = bitcast %struct.array4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 4 %0, [5 x i32] %1) #0 { + %3 = alloca %struct.array5, align 4 + %4 = getelementptr inbounds %struct.array5, %struct.array5* %3, i32 0, i32 0 + store [5 x i32] %1, [5 x i32]* %4, align 4 + %5 = bitcast %struct.array5* %0 to i8* + %6 = bitcast %struct.array5* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 4 %0, [6 x i32] %1) #0 { + %3 = alloca %struct.array6, align 4 + %4 = getelementptr inbounds %struct.array6, %struct.array6* %3, i32 0, i32 0 + store [6 x i32] %1, [6 x i32]* %4, align 4 + %5 = bitcast %struct.array6* %0 to i8* + %6 = bitcast %struct.array6* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 4 %0, [7 x i32] %1) #0 { + %3 = alloca %struct.array7, align 4 + %4 = getelementptr inbounds %struct.array7, %struct.array7* %3, i32 0, i32 0 + store [7 x i32] %1, [7 x i32]* %4, align 4 + %5 = bitcast %struct.array7* %0 to i8* + %6 = bitcast %struct.array7* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 4 %0, [8 x i32] %1) #0 { + %3 = alloca %struct.array8, align 4 + %4 = getelementptr inbounds %struct.array8, %struct.array8* %3, i32 0, i32 0 + store [8 x i32] %1, [8 x i32]* %4, align 4 + %5 = bitcast %struct.array8* %0 to i8* + %6 = bitcast %struct.array8* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 4 %0, [9 x i32] %1) #0 { + %3 = alloca %struct.array9, align 4 + %4 = getelementptr inbounds %struct.array9, %struct.array9* %3, i32 0, i32 0 + store [9 x i32] %1, [9 x i32]* %4, align 4 + %5 = bitcast %struct.array9* %0 to i8* + %6 = bitcast %struct.array9* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 4 %0, [10 x i32] %1) #0 { + %3 = alloca %struct.array10, align 4 + %4 = getelementptr inbounds %struct.array10, %struct.array10* %3, i32 0, i32 0 + store [10 x i32] %1, [10 x i32]* %4, align 4 + %5 = bitcast %struct.array10* %0 to i8* + %6 = bitcast %struct.array10* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 4 %0, [11 x i32] %1) #0 { + %3 = alloca %struct.array11, align 4 + %4 = getelementptr inbounds %struct.array11, %struct.array11* %3, i32 0, i32 0 + store [11 x i32] %1, [11 x i32]* %4, align 4 + %5 = bitcast %struct.array11* %0 to i8* + %6 = bitcast %struct.array11* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 4 %0, [12 x i32] %1) #0 { + %3 = alloca %struct.array12, align 4 + %4 = getelementptr inbounds %struct.array12, %struct.array12* %3, i32 0, i32 0 + store [12 x i32] %1, [12 x i32]* %4, align 4 + %5 = bitcast %struct.array12* %0 to i8* + %6 = bitcast %struct.array12* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 4 %0, [13 x i32] %1) #0 { + %3 = alloca %struct.array13, align 4 + %4 = getelementptr inbounds %struct.array13, %struct.array13* %3, i32 0, i32 0 + store [13 x i32] %1, [13 x i32]* %4, align 4 + %5 = bitcast %struct.array13* %0 to i8* + %6 = bitcast %struct.array13* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 4 %0, [14 x i32] %1) #0 { + %3 = alloca %struct.array14, align 4 + %4 = getelementptr inbounds %struct.array14, %struct.array14* %3, i32 0, i32 0 + store [14 x i32] %1, [14 x i32]* %4, align 4 + %5 = bitcast %struct.array14* %0 to i8* + %6 = bitcast %struct.array14* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 4 %0, [15 x i32] %1) #0 { + %3 = alloca %struct.array15, align 4 + %4 = getelementptr inbounds %struct.array15, %struct.array15* %3, i32 0, i32 0 + store [15 x i32] %1, [15 x i32]* %4, align 4 + %5 = bitcast %struct.array15* %0 to i8* + %6 = bitcast %struct.array15* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 4 %0, [16 x i32] %1) #0 { + %3 = alloca %struct.array16, align 4 + %4 = getelementptr inbounds %struct.array16, %struct.array16* %3, i32 0, i32 0 + store [16 x i32] %1, [16 x i32]* %4, align 4 + %5 = bitcast %struct.array16* %0 to i8* + %6 = bitcast %struct.array16* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 4 %0, %struct.array17* noundef byval(%struct.array17) align 4 %1) #0 { + %3 = bitcast %struct.array17* %0 to i8* + %4 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 4 %0, %struct.array18* noundef byval(%struct.array18) align 4 %1) #0 { + %3 = bitcast %struct.array18* %0 to i8* + %4 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 4 %0, %struct.array19* noundef byval(%struct.array19) align 4 %1) #0 { + %3 = bitcast %struct.array19* %0 to i8* + %4 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 4 %0, %struct.array20* noundef byval(%struct.array20) align 4 %1) #0 { + %3 = bitcast %struct.array20* %0 to i8* + %4 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="arm1176jzf-s" "target-features"="+armv6kz,+dsp,+fp64,+strict-align,+vfp2,+vfp2sp,-aes,-d32,-fp-armv8,-fp-armv8d16,-fp-armv8d16sp,-fp-armv8sp,-fp16,-fp16fml,-fullfp16,-neon,-sha2,-thumb-mode,-vfp3,-vfp3d16,-vfp3d16sp,-vfp3sp,-vfp4,-vfp4d16,-vfp4d16sp,-vfp4sp" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"min_enum_size", i32 4} +!2 = !{i32 8, !"branch-target-enforcement", i32 0} +!3 = !{i32 8, !"sign-return-address", i32 0} +!4 = !{i32 8, !"sign-return-address-all", i32 0} +!5 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!6 = !{i32 7, !"PIC Level", i32 2} +!7 = !{i32 7, !"PIE Level", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 2} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/armv6/array_int64.ll b/internal/cabi/_testdata/arch/armv6/array_int64.ll new file mode 100644 index 00000000..8d0b3402 --- /dev/null +++ b/internal/cabi/_testdata/arch/armv6/array_int64.ll @@ -0,0 +1,229 @@ +; ModuleID = '../../wrap/array_int64.c' +source_filename = "../../wrap/array_int64.c" +target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64" +target triple = "armv6kz-unknown-linux-gnueabihf" + +%struct.array1 = type { [1 x i64] } +%struct.array2 = type { [2 x i64] } +%struct.array3 = type { [3 x i64] } +%struct.array4 = type { [4 x i64] } +%struct.array5 = type { [5 x i64] } +%struct.array6 = type { [6 x i64] } +%struct.array7 = type { [7 x i64] } +%struct.array8 = type { [8 x i64] } +%struct.array9 = type { [9 x i64] } +%struct.array10 = type { [10 x i64] } +%struct.array11 = type { [11 x i64] } +%struct.array12 = type { [12 x i64] } +%struct.array13 = type { [13 x i64] } +%struct.array14 = type { [14 x i64] } +%struct.array15 = type { [15 x i64] } +%struct.array16 = type { [16 x i64] } +%struct.array17 = type { [17 x i64] } +%struct.array18 = type { [18 x i64] } +%struct.array19 = type { [19 x i64] } +%struct.array20 = type { [20 x i64] } + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo1(%struct.array1* noalias sret(%struct.array1) align 8 %0, [1 x i64] %1) #0 { + %3 = alloca %struct.array1, align 8 + %4 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + store [1 x i64] %1, [1 x i64]* %4, align 8 + %5 = bitcast %struct.array1* %0 to i8* + %6 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %5, i8* align 8 %6, i32 8, i1 false) + ret void +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo2(%struct.array2* noalias sret(%struct.array2) align 8 %0, [2 x i64] %1) #0 { + %3 = alloca %struct.array2, align 8 + %4 = getelementptr inbounds %struct.array2, %struct.array2* %3, i32 0, i32 0 + store [2 x i64] %1, [2 x i64]* %4, align 8 + %5 = bitcast %struct.array2* %0 to i8* + %6 = bitcast %struct.array2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %5, i8* align 8 %6, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo3(%struct.array3* noalias sret(%struct.array3) align 8 %0, [3 x i64] %1) #0 { + %3 = alloca %struct.array3, align 8 + %4 = getelementptr inbounds %struct.array3, %struct.array3* %3, i32 0, i32 0 + store [3 x i64] %1, [3 x i64]* %4, align 8 + %5 = bitcast %struct.array3* %0 to i8* + %6 = bitcast %struct.array3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %5, i8* align 8 %6, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo4(%struct.array4* noalias sret(%struct.array4) align 8 %0, [4 x i64] %1) #0 { + %3 = alloca %struct.array4, align 8 + %4 = getelementptr inbounds %struct.array4, %struct.array4* %3, i32 0, i32 0 + store [4 x i64] %1, [4 x i64]* %4, align 8 + %5 = bitcast %struct.array4* %0 to i8* + %6 = bitcast %struct.array4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %5, i8* align 8 %6, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 8 %0, [5 x i64] %1) #0 { + %3 = alloca %struct.array5, align 8 + %4 = getelementptr inbounds %struct.array5, %struct.array5* %3, i32 0, i32 0 + store [5 x i64] %1, [5 x i64]* %4, align 8 + %5 = bitcast %struct.array5* %0 to i8* + %6 = bitcast %struct.array5* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %5, i8* align 8 %6, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 8 %0, [6 x i64] %1) #0 { + %3 = alloca %struct.array6, align 8 + %4 = getelementptr inbounds %struct.array6, %struct.array6* %3, i32 0, i32 0 + store [6 x i64] %1, [6 x i64]* %4, align 8 + %5 = bitcast %struct.array6* %0 to i8* + %6 = bitcast %struct.array6* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %5, i8* align 8 %6, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 8 %0, [7 x i64] %1) #0 { + %3 = alloca %struct.array7, align 8 + %4 = getelementptr inbounds %struct.array7, %struct.array7* %3, i32 0, i32 0 + store [7 x i64] %1, [7 x i64]* %4, align 8 + %5 = bitcast %struct.array7* %0 to i8* + %6 = bitcast %struct.array7* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %5, i8* align 8 %6, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 8 %0, [8 x i64] %1) #0 { + %3 = alloca %struct.array8, align 8 + %4 = getelementptr inbounds %struct.array8, %struct.array8* %3, i32 0, i32 0 + store [8 x i64] %1, [8 x i64]* %4, align 8 + %5 = bitcast %struct.array8* %0 to i8* + %6 = bitcast %struct.array8* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %5, i8* align 8 %6, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 8 %0, %struct.array9* noundef byval(%struct.array9) align 8 %1) #0 { + %3 = bitcast %struct.array9* %0 to i8* + %4 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 8 %0, %struct.array10* noundef byval(%struct.array10) align 8 %1) #0 { + %3 = bitcast %struct.array10* %0 to i8* + %4 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 8 %0, %struct.array11* noundef byval(%struct.array11) align 8 %1) #0 { + %3 = bitcast %struct.array11* %0 to i8* + %4 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 8 %0, %struct.array12* noundef byval(%struct.array12) align 8 %1) #0 { + %3 = bitcast %struct.array12* %0 to i8* + %4 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 8 %0, %struct.array13* noundef byval(%struct.array13) align 8 %1) #0 { + %3 = bitcast %struct.array13* %0 to i8* + %4 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 8 %0, %struct.array14* noundef byval(%struct.array14) align 8 %1) #0 { + %3 = bitcast %struct.array14* %0 to i8* + %4 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 8 %0, %struct.array15* noundef byval(%struct.array15) align 8 %1) #0 { + %3 = bitcast %struct.array15* %0 to i8* + %4 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 8 %0, %struct.array16* noundef byval(%struct.array16) align 8 %1) #0 { + %3 = bitcast %struct.array16* %0 to i8* + %4 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 8 %0, %struct.array17* noundef byval(%struct.array17) align 8 %1) #0 { + %3 = bitcast %struct.array17* %0 to i8* + %4 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 8 %0, %struct.array18* noundef byval(%struct.array18) align 8 %1) #0 { + %3 = bitcast %struct.array18* %0 to i8* + %4 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 8 %0, %struct.array19* noundef byval(%struct.array19) align 8 %1) #0 { + %3 = bitcast %struct.array19* %0 to i8* + %4 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 8 %0, %struct.array20* noundef byval(%struct.array20) align 8 %1) #0 { + %3 = bitcast %struct.array20* %0 to i8* + %4 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="arm1176jzf-s" "target-features"="+armv6kz,+dsp,+fp64,+strict-align,+vfp2,+vfp2sp,-aes,-d32,-fp-armv8,-fp-armv8d16,-fp-armv8d16sp,-fp-armv8sp,-fp16,-fp16fml,-fullfp16,-neon,-sha2,-thumb-mode,-vfp3,-vfp3d16,-vfp3d16sp,-vfp3sp,-vfp4,-vfp4d16,-vfp4d16sp,-vfp4sp" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"min_enum_size", i32 4} +!2 = !{i32 8, !"branch-target-enforcement", i32 0} +!3 = !{i32 8, !"sign-return-address", i32 0} +!4 = !{i32 8, !"sign-return-address-all", i32 0} +!5 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!6 = !{i32 7, !"PIC Level", i32 2} +!7 = !{i32 7, !"PIE Level", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 2} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/armv6/array_int8.ll b/internal/cabi/_testdata/arch/armv6/array_int8.ll new file mode 100644 index 00000000..650cdb0f --- /dev/null +++ b/internal/cabi/_testdata/arch/armv6/array_int8.ll @@ -0,0 +1,349 @@ +; ModuleID = '../../wrap/array_int8.c' +source_filename = "../../wrap/array_int8.c" +target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64" +target triple = "armv6kz-unknown-linux-gnueabihf" + +%struct.array1 = type { [1 x i8] } +%struct.array2 = type { [2 x i8] } +%struct.array3 = type { [3 x i8] } +%struct.array4 = type { [4 x i8] } +%struct.array5 = type { [5 x i8] } +%struct.array6 = type { [6 x i8] } +%struct.array7 = type { [7 x i8] } +%struct.array8 = type { [8 x i8] } +%struct.array9 = type { [9 x i8] } +%struct.array10 = type { [10 x i8] } +%struct.array11 = type { [11 x i8] } +%struct.array12 = type { [12 x i8] } +%struct.array13 = type { [13 x i8] } +%struct.array14 = type { [14 x i8] } +%struct.array15 = type { [15 x i8] } +%struct.array16 = type { [16 x i8] } +%struct.array17 = type { [17 x i8] } +%struct.array18 = type { [18 x i8] } +%struct.array19 = type { [19 x i8] } +%struct.array20 = type { [20 x i8] } + +; Function Attrs: noinline nounwind optnone +define dso_local i8 @demo1([1 x i32] %0) #0 { + %2 = alloca %struct.array1, align 1 + %3 = alloca %struct.array1, align 1 + %4 = alloca [1 x i32], align 4 + %5 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + store [1 x i32] %0, [1 x i32]* %4, align 4 + %6 = bitcast [1 x i8]* %5 to i8* + %7 = bitcast [1 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %6, i8* align 4 %7, i32 1, i1 false) + %8 = bitcast %struct.array1* %2 to i8* + %9 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %8, i8* align 1 %9, i32 1, i1 false) + %10 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %11 = bitcast [1 x i8]* %10 to i8* + %12 = load i8, i8* %11, align 1 + ret i8 %12 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define dso_local i16 @demo2([1 x i32] %0) #0 { + %2 = alloca %struct.array2, align 1 + %3 = alloca %struct.array2, align 1 + %4 = alloca [1 x i32], align 4 + %5 = getelementptr inbounds %struct.array2, %struct.array2* %3, i32 0, i32 0 + store [1 x i32] %0, [1 x i32]* %4, align 4 + %6 = bitcast [2 x i8]* %5 to i8* + %7 = bitcast [1 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %6, i8* align 4 %7, i32 2, i1 false) + %8 = bitcast %struct.array2* %2 to i8* + %9 = bitcast %struct.array2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %8, i8* align 1 %9, i32 2, i1 false) + %10 = getelementptr inbounds %struct.array2, %struct.array2* %2, i32 0, i32 0 + %11 = bitcast [2 x i8]* %10 to i16* + %12 = load i16, i16* %11, align 1 + ret i16 %12 +} + +; Function Attrs: noinline nounwind optnone +define dso_local i32 @demo3([1 x i32] %0) #0 { + %2 = alloca %struct.array3, align 1 + %3 = alloca %struct.array3, align 1 + %4 = alloca [1 x i32], align 4 + %5 = alloca i32, align 4 + %6 = getelementptr inbounds %struct.array3, %struct.array3* %3, i32 0, i32 0 + store [1 x i32] %0, [1 x i32]* %4, align 4 + %7 = bitcast [3 x i8]* %6 to i8* + %8 = bitcast [1 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %7, i8* align 4 %8, i32 3, i1 false) + %9 = bitcast %struct.array3* %2 to i8* + %10 = bitcast %struct.array3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %9, i8* align 1 %10, i32 3, i1 false) + %11 = getelementptr inbounds %struct.array3, %struct.array3* %2, i32 0, i32 0 + %12 = bitcast i32* %5 to i8* + %13 = bitcast [3 x i8]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %12, i8* align 1 %13, i32 3, i1 false) + %14 = load i32, i32* %5, align 4 + ret i32 %14 +} + +; Function Attrs: noinline nounwind optnone +define dso_local i32 @demo4([1 x i32] %0) #0 { + %2 = alloca %struct.array4, align 1 + %3 = alloca %struct.array4, align 1 + %4 = getelementptr inbounds %struct.array4, %struct.array4* %3, i32 0, i32 0 + %5 = bitcast [4 x i8]* %4 to [1 x i32]* + store [1 x i32] %0, [1 x i32]* %5, align 1 + %6 = bitcast %struct.array4* %2 to i8* + %7 = bitcast %struct.array4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %6, i8* align 1 %7, i32 4, i1 false) + %8 = getelementptr inbounds %struct.array4, %struct.array4* %2, i32 0, i32 0 + %9 = bitcast [4 x i8]* %8 to i32* + %10 = load i32, i32* %9, align 1 + ret i32 %10 +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 1 %0, [2 x i32] %1) #0 { + %3 = alloca %struct.array5, align 1 + %4 = alloca [2 x i32], align 4 + %5 = getelementptr inbounds %struct.array5, %struct.array5* %3, i32 0, i32 0 + store [2 x i32] %1, [2 x i32]* %4, align 4 + %6 = bitcast [5 x i8]* %5 to i8* + %7 = bitcast [2 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %6, i8* align 4 %7, i32 5, i1 false) + %8 = bitcast %struct.array5* %0 to i8* + %9 = bitcast %struct.array5* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %8, i8* align 1 %9, i32 5, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 1 %0, [2 x i32] %1) #0 { + %3 = alloca %struct.array6, align 1 + %4 = alloca [2 x i32], align 4 + %5 = getelementptr inbounds %struct.array6, %struct.array6* %3, i32 0, i32 0 + store [2 x i32] %1, [2 x i32]* %4, align 4 + %6 = bitcast [6 x i8]* %5 to i8* + %7 = bitcast [2 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %6, i8* align 4 %7, i32 6, i1 false) + %8 = bitcast %struct.array6* %0 to i8* + %9 = bitcast %struct.array6* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %8, i8* align 1 %9, i32 6, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 1 %0, [2 x i32] %1) #0 { + %3 = alloca %struct.array7, align 1 + %4 = alloca [2 x i32], align 4 + %5 = getelementptr inbounds %struct.array7, %struct.array7* %3, i32 0, i32 0 + store [2 x i32] %1, [2 x i32]* %4, align 4 + %6 = bitcast [7 x i8]* %5 to i8* + %7 = bitcast [2 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %6, i8* align 4 %7, i32 7, i1 false) + %8 = bitcast %struct.array7* %0 to i8* + %9 = bitcast %struct.array7* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %8, i8* align 1 %9, i32 7, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 1 %0, [2 x i32] %1) #0 { + %3 = alloca %struct.array8, align 1 + %4 = getelementptr inbounds %struct.array8, %struct.array8* %3, i32 0, i32 0 + %5 = bitcast [8 x i8]* %4 to [2 x i32]* + store [2 x i32] %1, [2 x i32]* %5, align 1 + %6 = bitcast %struct.array8* %0 to i8* + %7 = bitcast %struct.array8* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %6, i8* align 1 %7, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 1 %0, [3 x i32] %1) #0 { + %3 = alloca %struct.array9, align 1 + %4 = alloca [3 x i32], align 4 + %5 = getelementptr inbounds %struct.array9, %struct.array9* %3, i32 0, i32 0 + store [3 x i32] %1, [3 x i32]* %4, align 4 + %6 = bitcast [9 x i8]* %5 to i8* + %7 = bitcast [3 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %6, i8* align 4 %7, i32 9, i1 false) + %8 = bitcast %struct.array9* %0 to i8* + %9 = bitcast %struct.array9* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %8, i8* align 1 %9, i32 9, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 1 %0, [3 x i32] %1) #0 { + %3 = alloca %struct.array10, align 1 + %4 = alloca [3 x i32], align 4 + %5 = getelementptr inbounds %struct.array10, %struct.array10* %3, i32 0, i32 0 + store [3 x i32] %1, [3 x i32]* %4, align 4 + %6 = bitcast [10 x i8]* %5 to i8* + %7 = bitcast [3 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %6, i8* align 4 %7, i32 10, i1 false) + %8 = bitcast %struct.array10* %0 to i8* + %9 = bitcast %struct.array10* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %8, i8* align 1 %9, i32 10, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 1 %0, [3 x i32] %1) #0 { + %3 = alloca %struct.array11, align 1 + %4 = alloca [3 x i32], align 4 + %5 = getelementptr inbounds %struct.array11, %struct.array11* %3, i32 0, i32 0 + store [3 x i32] %1, [3 x i32]* %4, align 4 + %6 = bitcast [11 x i8]* %5 to i8* + %7 = bitcast [3 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %6, i8* align 4 %7, i32 11, i1 false) + %8 = bitcast %struct.array11* %0 to i8* + %9 = bitcast %struct.array11* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %8, i8* align 1 %9, i32 11, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 1 %0, [3 x i32] %1) #0 { + %3 = alloca %struct.array12, align 1 + %4 = getelementptr inbounds %struct.array12, %struct.array12* %3, i32 0, i32 0 + %5 = bitcast [12 x i8]* %4 to [3 x i32]* + store [3 x i32] %1, [3 x i32]* %5, align 1 + %6 = bitcast %struct.array12* %0 to i8* + %7 = bitcast %struct.array12* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %6, i8* align 1 %7, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 1 %0, [4 x i32] %1) #0 { + %3 = alloca %struct.array13, align 1 + %4 = alloca [4 x i32], align 4 + %5 = getelementptr inbounds %struct.array13, %struct.array13* %3, i32 0, i32 0 + store [4 x i32] %1, [4 x i32]* %4, align 4 + %6 = bitcast [13 x i8]* %5 to i8* + %7 = bitcast [4 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %6, i8* align 4 %7, i32 13, i1 false) + %8 = bitcast %struct.array13* %0 to i8* + %9 = bitcast %struct.array13* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %8, i8* align 1 %9, i32 13, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 1 %0, [4 x i32] %1) #0 { + %3 = alloca %struct.array14, align 1 + %4 = alloca [4 x i32], align 4 + %5 = getelementptr inbounds %struct.array14, %struct.array14* %3, i32 0, i32 0 + store [4 x i32] %1, [4 x i32]* %4, align 4 + %6 = bitcast [14 x i8]* %5 to i8* + %7 = bitcast [4 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %6, i8* align 4 %7, i32 14, i1 false) + %8 = bitcast %struct.array14* %0 to i8* + %9 = bitcast %struct.array14* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %8, i8* align 1 %9, i32 14, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 1 %0, [4 x i32] %1) #0 { + %3 = alloca %struct.array15, align 1 + %4 = alloca [4 x i32], align 4 + %5 = getelementptr inbounds %struct.array15, %struct.array15* %3, i32 0, i32 0 + store [4 x i32] %1, [4 x i32]* %4, align 4 + %6 = bitcast [15 x i8]* %5 to i8* + %7 = bitcast [4 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %6, i8* align 4 %7, i32 15, i1 false) + %8 = bitcast %struct.array15* %0 to i8* + %9 = bitcast %struct.array15* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %8, i8* align 1 %9, i32 15, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 1 %0, [4 x i32] %1) #0 { + %3 = alloca %struct.array16, align 1 + %4 = getelementptr inbounds %struct.array16, %struct.array16* %3, i32 0, i32 0 + %5 = bitcast [16 x i8]* %4 to [4 x i32]* + store [4 x i32] %1, [4 x i32]* %5, align 1 + %6 = bitcast %struct.array16* %0 to i8* + %7 = bitcast %struct.array16* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %6, i8* align 1 %7, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 1 %0, [5 x i32] %1) #0 { + %3 = alloca %struct.array17, align 1 + %4 = alloca [5 x i32], align 4 + %5 = getelementptr inbounds %struct.array17, %struct.array17* %3, i32 0, i32 0 + store [5 x i32] %1, [5 x i32]* %4, align 4 + %6 = bitcast [17 x i8]* %5 to i8* + %7 = bitcast [5 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %6, i8* align 4 %7, i32 17, i1 false) + %8 = bitcast %struct.array17* %0 to i8* + %9 = bitcast %struct.array17* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %8, i8* align 1 %9, i32 17, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 1 %0, [5 x i32] %1) #0 { + %3 = alloca %struct.array18, align 1 + %4 = alloca [5 x i32], align 4 + %5 = getelementptr inbounds %struct.array18, %struct.array18* %3, i32 0, i32 0 + store [5 x i32] %1, [5 x i32]* %4, align 4 + %6 = bitcast [18 x i8]* %5 to i8* + %7 = bitcast [5 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %6, i8* align 4 %7, i32 18, i1 false) + %8 = bitcast %struct.array18* %0 to i8* + %9 = bitcast %struct.array18* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %8, i8* align 1 %9, i32 18, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 1 %0, [5 x i32] %1) #0 { + %3 = alloca %struct.array19, align 1 + %4 = alloca [5 x i32], align 4 + %5 = getelementptr inbounds %struct.array19, %struct.array19* %3, i32 0, i32 0 + store [5 x i32] %1, [5 x i32]* %4, align 4 + %6 = bitcast [19 x i8]* %5 to i8* + %7 = bitcast [5 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %6, i8* align 4 %7, i32 19, i1 false) + %8 = bitcast %struct.array19* %0 to i8* + %9 = bitcast %struct.array19* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %8, i8* align 1 %9, i32 19, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 1 %0, [5 x i32] %1) #0 { + %3 = alloca %struct.array20, align 1 + %4 = getelementptr inbounds %struct.array20, %struct.array20* %3, i32 0, i32 0 + %5 = bitcast [20 x i8]* %4 to [5 x i32]* + store [5 x i32] %1, [5 x i32]* %5, align 1 + %6 = bitcast %struct.array20* %0 to i8* + %7 = bitcast %struct.array20* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %6, i8* align 1 %7, i32 20, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="arm1176jzf-s" "target-features"="+armv6kz,+dsp,+fp64,+strict-align,+vfp2,+vfp2sp,-aes,-d32,-fp-armv8,-fp-armv8d16,-fp-armv8d16sp,-fp-armv8sp,-fp16,-fp16fml,-fullfp16,-neon,-sha2,-thumb-mode,-vfp3,-vfp3d16,-vfp3d16sp,-vfp3sp,-vfp4,-vfp4d16,-vfp4d16sp,-vfp4sp" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"min_enum_size", i32 4} +!2 = !{i32 8, !"branch-target-enforcement", i32 0} +!3 = !{i32 8, !"sign-return-address", i32 0} +!4 = !{i32 8, !"sign-return-address-all", i32 0} +!5 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!6 = !{i32 7, !"PIC Level", i32 2} +!7 = !{i32 7, !"PIE Level", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 2} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/armv6/array_pointer.ll b/internal/cabi/_testdata/arch/armv6/array_pointer.ll new file mode 100644 index 00000000..a2339857 --- /dev/null +++ b/internal/cabi/_testdata/arch/armv6/array_pointer.ll @@ -0,0 +1,273 @@ +; ModuleID = '../../wrap/array_pointer.c' +source_filename = "../../wrap/array_pointer.c" +target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64" +target triple = "armv6kz-unknown-linux-gnueabihf" + +%struct.array1 = type { [1 x i8*] } +%struct.array2 = type { [2 x i8*] } +%struct.array3 = type { [3 x i8*] } +%struct.array4 = type { [4 x i8*] } +%struct.array5 = type { [5 x i8*] } +%struct.array6 = type { [6 x i8*] } +%struct.array7 = type { [7 x i8*] } +%struct.array8 = type { [8 x i8*] } +%struct.array9 = type { [9 x i8*] } +%struct.array10 = type { [10 x i8*] } +%struct.array11 = type { [11 x i8*] } +%struct.array12 = type { [12 x i8*] } +%struct.array13 = type { [13 x i8*] } +%struct.array14 = type { [14 x i8*] } +%struct.array15 = type { [15 x i8*] } +%struct.array16 = type { [16 x i8*] } +%struct.array17 = type { [17 x i8*] } +%struct.array18 = type { [18 x i8*] } +%struct.array19 = type { [19 x i8*] } +%struct.array20 = type { [20 x i8*] } + +; Function Attrs: noinline nounwind optnone +define dso_local i32 @demo1([1 x i32] %0) #0 { + %2 = alloca %struct.array1, align 4 + %3 = alloca %struct.array1, align 4 + %4 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + %5 = bitcast [1 x i8*]* %4 to [1 x i32]* + store [1 x i32] %0, [1 x i32]* %5, align 4 + %6 = bitcast %struct.array1* %2 to i8* + %7 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 4, i1 false) + %8 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %9 = bitcast [1 x i8*]* %8 to i32* + %10 = load i32, i32* %9, align 4 + ret i32 %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo2(%struct.array2* noalias sret(%struct.array2) align 4 %0, [2 x i32] %1) #0 { + %3 = alloca %struct.array2, align 4 + %4 = getelementptr inbounds %struct.array2, %struct.array2* %3, i32 0, i32 0 + %5 = bitcast [2 x i8*]* %4 to [2 x i32]* + store [2 x i32] %1, [2 x i32]* %5, align 4 + %6 = bitcast %struct.array2* %0 to i8* + %7 = bitcast %struct.array2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo3(%struct.array3* noalias sret(%struct.array3) align 4 %0, [3 x i32] %1) #0 { + %3 = alloca %struct.array3, align 4 + %4 = getelementptr inbounds %struct.array3, %struct.array3* %3, i32 0, i32 0 + %5 = bitcast [3 x i8*]* %4 to [3 x i32]* + store [3 x i32] %1, [3 x i32]* %5, align 4 + %6 = bitcast %struct.array3* %0 to i8* + %7 = bitcast %struct.array3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo4(%struct.array4* noalias sret(%struct.array4) align 4 %0, [4 x i32] %1) #0 { + %3 = alloca %struct.array4, align 4 + %4 = getelementptr inbounds %struct.array4, %struct.array4* %3, i32 0, i32 0 + %5 = bitcast [4 x i8*]* %4 to [4 x i32]* + store [4 x i32] %1, [4 x i32]* %5, align 4 + %6 = bitcast %struct.array4* %0 to i8* + %7 = bitcast %struct.array4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 4 %0, [5 x i32] %1) #0 { + %3 = alloca %struct.array5, align 4 + %4 = getelementptr inbounds %struct.array5, %struct.array5* %3, i32 0, i32 0 + %5 = bitcast [5 x i8*]* %4 to [5 x i32]* + store [5 x i32] %1, [5 x i32]* %5, align 4 + %6 = bitcast %struct.array5* %0 to i8* + %7 = bitcast %struct.array5* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 4 %0, [6 x i32] %1) #0 { + %3 = alloca %struct.array6, align 4 + %4 = getelementptr inbounds %struct.array6, %struct.array6* %3, i32 0, i32 0 + %5 = bitcast [6 x i8*]* %4 to [6 x i32]* + store [6 x i32] %1, [6 x i32]* %5, align 4 + %6 = bitcast %struct.array6* %0 to i8* + %7 = bitcast %struct.array6* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 4 %0, [7 x i32] %1) #0 { + %3 = alloca %struct.array7, align 4 + %4 = getelementptr inbounds %struct.array7, %struct.array7* %3, i32 0, i32 0 + %5 = bitcast [7 x i8*]* %4 to [7 x i32]* + store [7 x i32] %1, [7 x i32]* %5, align 4 + %6 = bitcast %struct.array7* %0 to i8* + %7 = bitcast %struct.array7* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 4 %0, [8 x i32] %1) #0 { + %3 = alloca %struct.array8, align 4 + %4 = getelementptr inbounds %struct.array8, %struct.array8* %3, i32 0, i32 0 + %5 = bitcast [8 x i8*]* %4 to [8 x i32]* + store [8 x i32] %1, [8 x i32]* %5, align 4 + %6 = bitcast %struct.array8* %0 to i8* + %7 = bitcast %struct.array8* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 4 %0, [9 x i32] %1) #0 { + %3 = alloca %struct.array9, align 4 + %4 = getelementptr inbounds %struct.array9, %struct.array9* %3, i32 0, i32 0 + %5 = bitcast [9 x i8*]* %4 to [9 x i32]* + store [9 x i32] %1, [9 x i32]* %5, align 4 + %6 = bitcast %struct.array9* %0 to i8* + %7 = bitcast %struct.array9* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 4 %0, [10 x i32] %1) #0 { + %3 = alloca %struct.array10, align 4 + %4 = getelementptr inbounds %struct.array10, %struct.array10* %3, i32 0, i32 0 + %5 = bitcast [10 x i8*]* %4 to [10 x i32]* + store [10 x i32] %1, [10 x i32]* %5, align 4 + %6 = bitcast %struct.array10* %0 to i8* + %7 = bitcast %struct.array10* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 4 %0, [11 x i32] %1) #0 { + %3 = alloca %struct.array11, align 4 + %4 = getelementptr inbounds %struct.array11, %struct.array11* %3, i32 0, i32 0 + %5 = bitcast [11 x i8*]* %4 to [11 x i32]* + store [11 x i32] %1, [11 x i32]* %5, align 4 + %6 = bitcast %struct.array11* %0 to i8* + %7 = bitcast %struct.array11* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 4 %0, [12 x i32] %1) #0 { + %3 = alloca %struct.array12, align 4 + %4 = getelementptr inbounds %struct.array12, %struct.array12* %3, i32 0, i32 0 + %5 = bitcast [12 x i8*]* %4 to [12 x i32]* + store [12 x i32] %1, [12 x i32]* %5, align 4 + %6 = bitcast %struct.array12* %0 to i8* + %7 = bitcast %struct.array12* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 4 %0, [13 x i32] %1) #0 { + %3 = alloca %struct.array13, align 4 + %4 = getelementptr inbounds %struct.array13, %struct.array13* %3, i32 0, i32 0 + %5 = bitcast [13 x i8*]* %4 to [13 x i32]* + store [13 x i32] %1, [13 x i32]* %5, align 4 + %6 = bitcast %struct.array13* %0 to i8* + %7 = bitcast %struct.array13* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 4 %0, [14 x i32] %1) #0 { + %3 = alloca %struct.array14, align 4 + %4 = getelementptr inbounds %struct.array14, %struct.array14* %3, i32 0, i32 0 + %5 = bitcast [14 x i8*]* %4 to [14 x i32]* + store [14 x i32] %1, [14 x i32]* %5, align 4 + %6 = bitcast %struct.array14* %0 to i8* + %7 = bitcast %struct.array14* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 4 %0, [15 x i32] %1) #0 { + %3 = alloca %struct.array15, align 4 + %4 = getelementptr inbounds %struct.array15, %struct.array15* %3, i32 0, i32 0 + %5 = bitcast [15 x i8*]* %4 to [15 x i32]* + store [15 x i32] %1, [15 x i32]* %5, align 4 + %6 = bitcast %struct.array15* %0 to i8* + %7 = bitcast %struct.array15* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 4 %0, [16 x i32] %1) #0 { + %3 = alloca %struct.array16, align 4 + %4 = getelementptr inbounds %struct.array16, %struct.array16* %3, i32 0, i32 0 + %5 = bitcast [16 x i8*]* %4 to [16 x i32]* + store [16 x i32] %1, [16 x i32]* %5, align 4 + %6 = bitcast %struct.array16* %0 to i8* + %7 = bitcast %struct.array16* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 4 %0, %struct.array17* noundef byval(%struct.array17) align 4 %1) #0 { + %3 = bitcast %struct.array17* %0 to i8* + %4 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 4 %0, %struct.array18* noundef byval(%struct.array18) align 4 %1) #0 { + %3 = bitcast %struct.array18* %0 to i8* + %4 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 4 %0, %struct.array19* noundef byval(%struct.array19) align 4 %1) #0 { + %3 = bitcast %struct.array19* %0 to i8* + %4 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 4 %0, %struct.array20* noundef byval(%struct.array20) align 4 %1) #0 { + %3 = bitcast %struct.array20* %0 to i8* + %4 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="arm1176jzf-s" "target-features"="+armv6kz,+dsp,+fp64,+strict-align,+vfp2,+vfp2sp,-aes,-d32,-fp-armv8,-fp-armv8d16,-fp-armv8d16sp,-fp-armv8sp,-fp16,-fp16fml,-fullfp16,-neon,-sha2,-thumb-mode,-vfp3,-vfp3d16,-vfp3d16sp,-vfp3sp,-vfp4,-vfp4d16,-vfp4d16sp,-vfp4sp" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"min_enum_size", i32 4} +!2 = !{i32 8, !"branch-target-enforcement", i32 0} +!3 = !{i32 8, !"sign-return-address", i32 0} +!4 = !{i32 8, !"sign-return-address-all", i32 0} +!5 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!6 = !{i32 7, !"PIC Level", i32 2} +!7 = !{i32 7, !"PIE Level", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 2} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/armv6/array_uintptr.ll b/internal/cabi/_testdata/arch/armv6/array_uintptr.ll new file mode 100644 index 00000000..95ee95f2 --- /dev/null +++ b/internal/cabi/_testdata/arch/armv6/array_uintptr.ll @@ -0,0 +1,273 @@ +; ModuleID = '../../wrap/array_uintptr.c' +source_filename = "../../wrap/array_uintptr.c" +target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64" +target triple = "armv6kz-unknown-linux-gnueabihf" + +%struct.array1 = type { [1 x i8*] } +%struct.array2 = type { [2 x i8*] } +%struct.array3 = type { [3 x i8*] } +%struct.array4 = type { [4 x i8*] } +%struct.array5 = type { [5 x i8*] } +%struct.array6 = type { [6 x i8*] } +%struct.array7 = type { [7 x i8*] } +%struct.array8 = type { [8 x i8*] } +%struct.array9 = type { [9 x i8*] } +%struct.array10 = type { [10 x i8*] } +%struct.array11 = type { [11 x i8*] } +%struct.array12 = type { [12 x i8*] } +%struct.array13 = type { [13 x i8*] } +%struct.array14 = type { [14 x i8*] } +%struct.array15 = type { [15 x i8*] } +%struct.array16 = type { [16 x i8*] } +%struct.array17 = type { [17 x i8*] } +%struct.array18 = type { [18 x i8*] } +%struct.array19 = type { [19 x i8*] } +%struct.array20 = type { [20 x i8*] } + +; Function Attrs: noinline nounwind optnone +define dso_local i32 @demo1([1 x i32] %0) #0 { + %2 = alloca %struct.array1, align 4 + %3 = alloca %struct.array1, align 4 + %4 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + %5 = bitcast [1 x i8*]* %4 to [1 x i32]* + store [1 x i32] %0, [1 x i32]* %5, align 4 + %6 = bitcast %struct.array1* %2 to i8* + %7 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 4, i1 false) + %8 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %9 = bitcast [1 x i8*]* %8 to i32* + %10 = load i32, i32* %9, align 4 + ret i32 %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo2(%struct.array2* noalias sret(%struct.array2) align 4 %0, [2 x i32] %1) #0 { + %3 = alloca %struct.array2, align 4 + %4 = getelementptr inbounds %struct.array2, %struct.array2* %3, i32 0, i32 0 + %5 = bitcast [2 x i8*]* %4 to [2 x i32]* + store [2 x i32] %1, [2 x i32]* %5, align 4 + %6 = bitcast %struct.array2* %0 to i8* + %7 = bitcast %struct.array2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo3(%struct.array3* noalias sret(%struct.array3) align 4 %0, [3 x i32] %1) #0 { + %3 = alloca %struct.array3, align 4 + %4 = getelementptr inbounds %struct.array3, %struct.array3* %3, i32 0, i32 0 + %5 = bitcast [3 x i8*]* %4 to [3 x i32]* + store [3 x i32] %1, [3 x i32]* %5, align 4 + %6 = bitcast %struct.array3* %0 to i8* + %7 = bitcast %struct.array3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo4(%struct.array4* noalias sret(%struct.array4) align 4 %0, [4 x i32] %1) #0 { + %3 = alloca %struct.array4, align 4 + %4 = getelementptr inbounds %struct.array4, %struct.array4* %3, i32 0, i32 0 + %5 = bitcast [4 x i8*]* %4 to [4 x i32]* + store [4 x i32] %1, [4 x i32]* %5, align 4 + %6 = bitcast %struct.array4* %0 to i8* + %7 = bitcast %struct.array4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 4 %0, [5 x i32] %1) #0 { + %3 = alloca %struct.array5, align 4 + %4 = getelementptr inbounds %struct.array5, %struct.array5* %3, i32 0, i32 0 + %5 = bitcast [5 x i8*]* %4 to [5 x i32]* + store [5 x i32] %1, [5 x i32]* %5, align 4 + %6 = bitcast %struct.array5* %0 to i8* + %7 = bitcast %struct.array5* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 4 %0, [6 x i32] %1) #0 { + %3 = alloca %struct.array6, align 4 + %4 = getelementptr inbounds %struct.array6, %struct.array6* %3, i32 0, i32 0 + %5 = bitcast [6 x i8*]* %4 to [6 x i32]* + store [6 x i32] %1, [6 x i32]* %5, align 4 + %6 = bitcast %struct.array6* %0 to i8* + %7 = bitcast %struct.array6* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 4 %0, [7 x i32] %1) #0 { + %3 = alloca %struct.array7, align 4 + %4 = getelementptr inbounds %struct.array7, %struct.array7* %3, i32 0, i32 0 + %5 = bitcast [7 x i8*]* %4 to [7 x i32]* + store [7 x i32] %1, [7 x i32]* %5, align 4 + %6 = bitcast %struct.array7* %0 to i8* + %7 = bitcast %struct.array7* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 4 %0, [8 x i32] %1) #0 { + %3 = alloca %struct.array8, align 4 + %4 = getelementptr inbounds %struct.array8, %struct.array8* %3, i32 0, i32 0 + %5 = bitcast [8 x i8*]* %4 to [8 x i32]* + store [8 x i32] %1, [8 x i32]* %5, align 4 + %6 = bitcast %struct.array8* %0 to i8* + %7 = bitcast %struct.array8* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 4 %0, [9 x i32] %1) #0 { + %3 = alloca %struct.array9, align 4 + %4 = getelementptr inbounds %struct.array9, %struct.array9* %3, i32 0, i32 0 + %5 = bitcast [9 x i8*]* %4 to [9 x i32]* + store [9 x i32] %1, [9 x i32]* %5, align 4 + %6 = bitcast %struct.array9* %0 to i8* + %7 = bitcast %struct.array9* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 4 %0, [10 x i32] %1) #0 { + %3 = alloca %struct.array10, align 4 + %4 = getelementptr inbounds %struct.array10, %struct.array10* %3, i32 0, i32 0 + %5 = bitcast [10 x i8*]* %4 to [10 x i32]* + store [10 x i32] %1, [10 x i32]* %5, align 4 + %6 = bitcast %struct.array10* %0 to i8* + %7 = bitcast %struct.array10* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 4 %0, [11 x i32] %1) #0 { + %3 = alloca %struct.array11, align 4 + %4 = getelementptr inbounds %struct.array11, %struct.array11* %3, i32 0, i32 0 + %5 = bitcast [11 x i8*]* %4 to [11 x i32]* + store [11 x i32] %1, [11 x i32]* %5, align 4 + %6 = bitcast %struct.array11* %0 to i8* + %7 = bitcast %struct.array11* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 4 %0, [12 x i32] %1) #0 { + %3 = alloca %struct.array12, align 4 + %4 = getelementptr inbounds %struct.array12, %struct.array12* %3, i32 0, i32 0 + %5 = bitcast [12 x i8*]* %4 to [12 x i32]* + store [12 x i32] %1, [12 x i32]* %5, align 4 + %6 = bitcast %struct.array12* %0 to i8* + %7 = bitcast %struct.array12* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 4 %0, [13 x i32] %1) #0 { + %3 = alloca %struct.array13, align 4 + %4 = getelementptr inbounds %struct.array13, %struct.array13* %3, i32 0, i32 0 + %5 = bitcast [13 x i8*]* %4 to [13 x i32]* + store [13 x i32] %1, [13 x i32]* %5, align 4 + %6 = bitcast %struct.array13* %0 to i8* + %7 = bitcast %struct.array13* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 4 %0, [14 x i32] %1) #0 { + %3 = alloca %struct.array14, align 4 + %4 = getelementptr inbounds %struct.array14, %struct.array14* %3, i32 0, i32 0 + %5 = bitcast [14 x i8*]* %4 to [14 x i32]* + store [14 x i32] %1, [14 x i32]* %5, align 4 + %6 = bitcast %struct.array14* %0 to i8* + %7 = bitcast %struct.array14* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 4 %0, [15 x i32] %1) #0 { + %3 = alloca %struct.array15, align 4 + %4 = getelementptr inbounds %struct.array15, %struct.array15* %3, i32 0, i32 0 + %5 = bitcast [15 x i8*]* %4 to [15 x i32]* + store [15 x i32] %1, [15 x i32]* %5, align 4 + %6 = bitcast %struct.array15* %0 to i8* + %7 = bitcast %struct.array15* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 4 %0, [16 x i32] %1) #0 { + %3 = alloca %struct.array16, align 4 + %4 = getelementptr inbounds %struct.array16, %struct.array16* %3, i32 0, i32 0 + %5 = bitcast [16 x i8*]* %4 to [16 x i32]* + store [16 x i32] %1, [16 x i32]* %5, align 4 + %6 = bitcast %struct.array16* %0 to i8* + %7 = bitcast %struct.array16* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 4 %0, %struct.array17* noundef byval(%struct.array17) align 4 %1) #0 { + %3 = bitcast %struct.array17* %0 to i8* + %4 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 4 %0, %struct.array18* noundef byval(%struct.array18) align 4 %1) #0 { + %3 = bitcast %struct.array18* %0 to i8* + %4 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 4 %0, %struct.array19* noundef byval(%struct.array19) align 4 %1) #0 { + %3 = bitcast %struct.array19* %0 to i8* + %4 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 4 %0, %struct.array20* noundef byval(%struct.array20) align 4 %1) #0 { + %3 = bitcast %struct.array20* %0 to i8* + %4 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="arm1176jzf-s" "target-features"="+armv6kz,+dsp,+fp64,+strict-align,+vfp2,+vfp2sp,-aes,-d32,-fp-armv8,-fp-armv8d16,-fp-armv8d16sp,-fp-armv8sp,-fp16,-fp16fml,-fullfp16,-neon,-sha2,-thumb-mode,-vfp3,-vfp3d16,-vfp3d16sp,-vfp3sp,-vfp4,-vfp4d16,-vfp4d16sp,-vfp4sp" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"min_enum_size", i32 4} +!2 = !{i32 8, !"branch-target-enforcement", i32 0} +!3 = !{i32 8, !"sign-return-address", i32 0} +!4 = !{i32 8, !"sign-return-address-all", i32 0} +!5 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!6 = !{i32 7, !"PIC Level", i32 2} +!7 = !{i32 7, !"PIE Level", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 2} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/armv6/basic.ll b/internal/cabi/_testdata/arch/armv6/basic.ll new file mode 100644 index 00000000..76d01838 --- /dev/null +++ b/internal/cabi/_testdata/arch/armv6/basic.ll @@ -0,0 +1,76 @@ +; ModuleID = '../../wrap/basic.c' +source_filename = "../../wrap/basic.c" +target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64" +target triple = "armv6kz-unknown-linux-gnueabihf" + +; Function Attrs: noinline nounwind optnone +define dso_local zeroext i8 @basic_int8(i8 noundef zeroext %0) #0 { + %2 = alloca i8, align 1 + store i8 %0, i8* %2, align 1 + %3 = load i8, i8* %2, align 1 + ret i8 %3 +} + +; Function Attrs: noinline nounwind optnone +define dso_local signext i16 @basic_int16(i16 noundef signext %0) #0 { + %2 = alloca i16, align 2 + store i16 %0, i16* %2, align 2 + %3 = load i16, i16* %2, align 2 + ret i16 %3 +} + +; Function Attrs: noinline nounwind optnone +define dso_local i32 @basic_int32(i32 noundef %0) #0 { + %2 = alloca i32, align 4 + store i32 %0, i32* %2, align 4 + %3 = load i32, i32* %2, align 4 + ret i32 %3 +} + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @basic_int64(i64 noundef %0) #0 { + %2 = alloca i64, align 8 + store i64 %0, i64* %2, align 8 + %3 = load i64, i64* %2, align 8 + ret i64 %3 +} + +; Function Attrs: noinline nounwind optnone +define dso_local float @basic_float32(float noundef %0) #0 { + %2 = alloca float, align 4 + store float %0, float* %2, align 4 + %3 = load float, float* %2, align 4 + ret float %3 +} + +; Function Attrs: noinline nounwind optnone +define dso_local double @basic_float64(double noundef %0) #0 { + %2 = alloca double, align 8 + store double %0, double* %2, align 8 + %3 = load double, double* %2, align 8 + ret double %3 +} + +; Function Attrs: noinline nounwind optnone +define dso_local i8* @basic_uintptr(i8* noundef %0) #0 { + %2 = alloca i8*, align 4 + store i8* %0, i8** %2, align 4 + %3 = load i8*, i8** %2, align 4 + ret i8* %3 +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="arm1176jzf-s" "target-features"="+armv6kz,+dsp,+fp64,+strict-align,+vfp2,+vfp2sp,-aes,-d32,-fp-armv8,-fp-armv8d16,-fp-armv8d16sp,-fp-armv8sp,-fp16,-fp16fml,-fullfp16,-neon,-sha2,-thumb-mode,-vfp3,-vfp3d16,-vfp3d16sp,-vfp3sp,-vfp4,-vfp4d16,-vfp4d16sp,-vfp4sp" } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"min_enum_size", i32 4} +!2 = !{i32 8, !"branch-target-enforcement", i32 0} +!3 = !{i32 8, !"sign-return-address", i32 0} +!4 = !{i32 8, !"sign-return-address-all", i32 0} +!5 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!6 = !{i32 7, !"PIC Level", i32 2} +!7 = !{i32 7, !"PIE Level", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 2} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/armv6/struct_float32.ll b/internal/cabi/_testdata/arch/armv6/struct_float32.ll new file mode 100644 index 00000000..b5e1a322 --- /dev/null +++ b/internal/cabi/_testdata/arch/armv6/struct_float32.ll @@ -0,0 +1,257 @@ +; ModuleID = '../../wrap/struct_float32.c' +source_filename = "../../wrap/struct_float32.c" +target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64" +target triple = "armv6kz-unknown-linux-gnueabihf" + +%struct.point1 = type { float } +%struct.point2 = type { float, float } +%struct.point3 = type { float, float, float } +%struct.point4 = type { float, float, float, float } +%struct.point5 = type { float, float, float, float, float } +%struct.point6 = type { float, float, float, float, float, float } +%struct.point7 = type { float, float, float, float, float, float, float } +%struct.point8 = type { float, float, float, float, float, float, float, float } +%struct.point9 = type { float, float, float, float, float, float, float, float, float } +%struct.point10 = type { float, float, float, float, float, float, float, float, float, float } +%struct.point11 = type { float, float, float, float, float, float, float, float, float, float, float } +%struct.point12 = type { float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point13 = type { float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point14 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point15 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point16 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point17 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point18 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point19 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point20 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } + +; Function Attrs: noinline nounwind optnone +define dso_local %struct.point1 @demo1(%struct.point1 %0) #0 { + %2 = alloca %struct.point1, align 4 + %3 = alloca %struct.point1, align 4 + store %struct.point1 %0, %struct.point1* %3, align 4 + %4 = bitcast %struct.point1* %2 to i8* + %5 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %4, i8* align 4 %5, i32 4, i1 false) + %6 = load %struct.point1, %struct.point1* %2, align 4 + ret %struct.point1 %6 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define dso_local %struct.point2 @demo2(%struct.point2 %0) #0 { + %2 = alloca %struct.point2, align 4 + %3 = alloca %struct.point2, align 4 + store %struct.point2 %0, %struct.point2* %3, align 4 + %4 = bitcast %struct.point2* %2 to i8* + %5 = bitcast %struct.point2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %4, i8* align 4 %5, i32 8, i1 false) + %6 = load %struct.point2, %struct.point2* %2, align 4 + ret %struct.point2 %6 +} + +; Function Attrs: noinline nounwind optnone +define dso_local %struct.point3 @demo3(%struct.point3 %0) #0 { + %2 = alloca %struct.point3, align 4 + %3 = alloca %struct.point3, align 4 + store %struct.point3 %0, %struct.point3* %3, align 4 + %4 = bitcast %struct.point3* %2 to i8* + %5 = bitcast %struct.point3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %4, i8* align 4 %5, i32 12, i1 false) + %6 = load %struct.point3, %struct.point3* %2, align 4 + ret %struct.point3 %6 +} + +; Function Attrs: noinline nounwind optnone +define dso_local %struct.point4 @demo4(%struct.point4 %0) #0 { + %2 = alloca %struct.point4, align 4 + %3 = alloca %struct.point4, align 4 + store %struct.point4 %0, %struct.point4* %3, align 4 + %4 = bitcast %struct.point4* %2 to i8* + %5 = bitcast %struct.point4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %4, i8* align 4 %5, i32 16, i1 false) + %6 = load %struct.point4, %struct.point4* %2, align 4 + ret %struct.point4 %6 +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo5(%struct.point5* noalias sret(%struct.point5) align 4 %0, [5 x i32] %1) #0 { + %3 = alloca %struct.point5, align 4 + %4 = bitcast %struct.point5* %3 to [5 x i32]* + store [5 x i32] %1, [5 x i32]* %4, align 4 + %5 = bitcast %struct.point5* %0 to i8* + %6 = bitcast %struct.point5* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo6(%struct.point6* noalias sret(%struct.point6) align 4 %0, [6 x i32] %1) #0 { + %3 = alloca %struct.point6, align 4 + %4 = bitcast %struct.point6* %3 to [6 x i32]* + store [6 x i32] %1, [6 x i32]* %4, align 4 + %5 = bitcast %struct.point6* %0 to i8* + %6 = bitcast %struct.point6* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo7(%struct.point7* noalias sret(%struct.point7) align 4 %0, [7 x i32] %1) #0 { + %3 = alloca %struct.point7, align 4 + %4 = bitcast %struct.point7* %3 to [7 x i32]* + store [7 x i32] %1, [7 x i32]* %4, align 4 + %5 = bitcast %struct.point7* %0 to i8* + %6 = bitcast %struct.point7* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo8(%struct.point8* noalias sret(%struct.point8) align 4 %0, [8 x i32] %1) #0 { + %3 = alloca %struct.point8, align 4 + %4 = bitcast %struct.point8* %3 to [8 x i32]* + store [8 x i32] %1, [8 x i32]* %4, align 4 + %5 = bitcast %struct.point8* %0 to i8* + %6 = bitcast %struct.point8* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 4 %0, [9 x i32] %1) #0 { + %3 = alloca %struct.point9, align 4 + %4 = bitcast %struct.point9* %3 to [9 x i32]* + store [9 x i32] %1, [9 x i32]* %4, align 4 + %5 = bitcast %struct.point9* %0 to i8* + %6 = bitcast %struct.point9* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 4 %0, [10 x i32] %1) #0 { + %3 = alloca %struct.point10, align 4 + %4 = bitcast %struct.point10* %3 to [10 x i32]* + store [10 x i32] %1, [10 x i32]* %4, align 4 + %5 = bitcast %struct.point10* %0 to i8* + %6 = bitcast %struct.point10* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 4 %0, [11 x i32] %1) #0 { + %3 = alloca %struct.point11, align 4 + %4 = bitcast %struct.point11* %3 to [11 x i32]* + store [11 x i32] %1, [11 x i32]* %4, align 4 + %5 = bitcast %struct.point11* %0 to i8* + %6 = bitcast %struct.point11* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 4 %0, [12 x i32] %1) #0 { + %3 = alloca %struct.point12, align 4 + %4 = bitcast %struct.point12* %3 to [12 x i32]* + store [12 x i32] %1, [12 x i32]* %4, align 4 + %5 = bitcast %struct.point12* %0 to i8* + %6 = bitcast %struct.point12* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 4 %0, [13 x i32] %1) #0 { + %3 = alloca %struct.point13, align 4 + %4 = bitcast %struct.point13* %3 to [13 x i32]* + store [13 x i32] %1, [13 x i32]* %4, align 4 + %5 = bitcast %struct.point13* %0 to i8* + %6 = bitcast %struct.point13* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 4 %0, [14 x i32] %1) #0 { + %3 = alloca %struct.point14, align 4 + %4 = bitcast %struct.point14* %3 to [14 x i32]* + store [14 x i32] %1, [14 x i32]* %4, align 4 + %5 = bitcast %struct.point14* %0 to i8* + %6 = bitcast %struct.point14* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 4 %0, [15 x i32] %1) #0 { + %3 = alloca %struct.point15, align 4 + %4 = bitcast %struct.point15* %3 to [15 x i32]* + store [15 x i32] %1, [15 x i32]* %4, align 4 + %5 = bitcast %struct.point15* %0 to i8* + %6 = bitcast %struct.point15* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 4 %0, [16 x i32] %1) #0 { + %3 = alloca %struct.point16, align 4 + %4 = bitcast %struct.point16* %3 to [16 x i32]* + store [16 x i32] %1, [16 x i32]* %4, align 4 + %5 = bitcast %struct.point16* %0 to i8* + %6 = bitcast %struct.point16* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 4 %0, %struct.point17* noundef byval(%struct.point17) align 4 %1) #0 { + %3 = bitcast %struct.point17* %0 to i8* + %4 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 4 %0, %struct.point18* noundef byval(%struct.point18) align 4 %1) #0 { + %3 = bitcast %struct.point18* %0 to i8* + %4 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 4 %0, %struct.point19* noundef byval(%struct.point19) align 4 %1) #0 { + %3 = bitcast %struct.point19* %0 to i8* + %4 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 4 %0, %struct.point20* noundef byval(%struct.point20) align 4 %1) #0 { + %3 = bitcast %struct.point20* %0 to i8* + %4 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="arm1176jzf-s" "target-features"="+armv6kz,+dsp,+fp64,+strict-align,+vfp2,+vfp2sp,-aes,-d32,-fp-armv8,-fp-armv8d16,-fp-armv8d16sp,-fp-armv8sp,-fp16,-fp16fml,-fullfp16,-neon,-sha2,-thumb-mode,-vfp3,-vfp3d16,-vfp3d16sp,-vfp3sp,-vfp4,-vfp4d16,-vfp4d16sp,-vfp4sp" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"min_enum_size", i32 4} +!2 = !{i32 8, !"branch-target-enforcement", i32 0} +!3 = !{i32 8, !"sign-return-address", i32 0} +!4 = !{i32 8, !"sign-return-address-all", i32 0} +!5 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!6 = !{i32 7, !"PIC Level", i32 2} +!7 = !{i32 7, !"PIE Level", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 2} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/armv6/struct_float64.ll b/internal/cabi/_testdata/arch/armv6/struct_float64.ll new file mode 100644 index 00000000..7d00d869 --- /dev/null +++ b/internal/cabi/_testdata/arch/armv6/struct_float64.ll @@ -0,0 +1,233 @@ +; ModuleID = '../../wrap/struct_float64.c' +source_filename = "../../wrap/struct_float64.c" +target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64" +target triple = "armv6kz-unknown-linux-gnueabihf" + +%struct.point1 = type { double } +%struct.point2 = type { double, double } +%struct.point3 = type { double, double, double } +%struct.point4 = type { double, double, double, double } +%struct.point5 = type { double, double, double, double, double } +%struct.point6 = type { double, double, double, double, double, double } +%struct.point7 = type { double, double, double, double, double, double, double } +%struct.point8 = type { double, double, double, double, double, double, double, double } +%struct.point9 = type { double, double, double, double, double, double, double, double, double } +%struct.point10 = type { double, double, double, double, double, double, double, double, double, double } +%struct.point11 = type { double, double, double, double, double, double, double, double, double, double, double } +%struct.point12 = type { double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point13 = type { double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point14 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point15 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point16 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point17 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point18 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point19 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point20 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } + +; Function Attrs: noinline nounwind optnone +define dso_local %struct.point1 @demo1(%struct.point1 %0) #0 { + %2 = alloca %struct.point1, align 8 + %3 = alloca %struct.point1, align 8 + store %struct.point1 %0, %struct.point1* %3, align 8 + %4 = bitcast %struct.point1* %2 to i8* + %5 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %4, i8* align 8 %5, i32 8, i1 false) + %6 = load %struct.point1, %struct.point1* %2, align 8 + ret %struct.point1 %6 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define dso_local %struct.point2 @demo2(%struct.point2 %0) #0 { + %2 = alloca %struct.point2, align 8 + %3 = alloca %struct.point2, align 8 + store %struct.point2 %0, %struct.point2* %3, align 8 + %4 = bitcast %struct.point2* %2 to i8* + %5 = bitcast %struct.point2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %4, i8* align 8 %5, i32 16, i1 false) + %6 = load %struct.point2, %struct.point2* %2, align 8 + ret %struct.point2 %6 +} + +; Function Attrs: noinline nounwind optnone +define dso_local %struct.point3 @demo3(%struct.point3 %0) #0 { + %2 = alloca %struct.point3, align 8 + %3 = alloca %struct.point3, align 8 + store %struct.point3 %0, %struct.point3* %3, align 8 + %4 = bitcast %struct.point3* %2 to i8* + %5 = bitcast %struct.point3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %4, i8* align 8 %5, i32 24, i1 false) + %6 = load %struct.point3, %struct.point3* %2, align 8 + ret %struct.point3 %6 +} + +; Function Attrs: noinline nounwind optnone +define dso_local %struct.point4 @demo4(%struct.point4 %0) #0 { + %2 = alloca %struct.point4, align 8 + %3 = alloca %struct.point4, align 8 + store %struct.point4 %0, %struct.point4* %3, align 8 + %4 = bitcast %struct.point4* %2 to i8* + %5 = bitcast %struct.point4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %4, i8* align 8 %5, i32 32, i1 false) + %6 = load %struct.point4, %struct.point4* %2, align 8 + ret %struct.point4 %6 +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo5(%struct.point5* noalias sret(%struct.point5) align 8 %0, [5 x i64] %1) #0 { + %3 = alloca %struct.point5, align 8 + %4 = bitcast %struct.point5* %3 to [5 x i64]* + store [5 x i64] %1, [5 x i64]* %4, align 8 + %5 = bitcast %struct.point5* %0 to i8* + %6 = bitcast %struct.point5* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %5, i8* align 8 %6, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo6(%struct.point6* noalias sret(%struct.point6) align 8 %0, [6 x i64] %1) #0 { + %3 = alloca %struct.point6, align 8 + %4 = bitcast %struct.point6* %3 to [6 x i64]* + store [6 x i64] %1, [6 x i64]* %4, align 8 + %5 = bitcast %struct.point6* %0 to i8* + %6 = bitcast %struct.point6* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %5, i8* align 8 %6, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo7(%struct.point7* noalias sret(%struct.point7) align 8 %0, [7 x i64] %1) #0 { + %3 = alloca %struct.point7, align 8 + %4 = bitcast %struct.point7* %3 to [7 x i64]* + store [7 x i64] %1, [7 x i64]* %4, align 8 + %5 = bitcast %struct.point7* %0 to i8* + %6 = bitcast %struct.point7* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %5, i8* align 8 %6, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo8(%struct.point8* noalias sret(%struct.point8) align 8 %0, [8 x i64] %1) #0 { + %3 = alloca %struct.point8, align 8 + %4 = bitcast %struct.point8* %3 to [8 x i64]* + store [8 x i64] %1, [8 x i64]* %4, align 8 + %5 = bitcast %struct.point8* %0 to i8* + %6 = bitcast %struct.point8* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %5, i8* align 8 %6, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 8 %0, %struct.point9* noundef byval(%struct.point9) align 8 %1) #0 { + %3 = bitcast %struct.point9* %0 to i8* + %4 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 8 %0, %struct.point10* noundef byval(%struct.point10) align 8 %1) #0 { + %3 = bitcast %struct.point10* %0 to i8* + %4 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 8 %0, %struct.point11* noundef byval(%struct.point11) align 8 %1) #0 { + %3 = bitcast %struct.point11* %0 to i8* + %4 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 8 %0, %struct.point12* noundef byval(%struct.point12) align 8 %1) #0 { + %3 = bitcast %struct.point12* %0 to i8* + %4 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 8 %0, %struct.point13* noundef byval(%struct.point13) align 8 %1) #0 { + %3 = bitcast %struct.point13* %0 to i8* + %4 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 8 %0, %struct.point14* noundef byval(%struct.point14) align 8 %1) #0 { + %3 = bitcast %struct.point14* %0 to i8* + %4 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 8 %0, %struct.point15* noundef byval(%struct.point15) align 8 %1) #0 { + %3 = bitcast %struct.point15* %0 to i8* + %4 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 8 %0, %struct.point16* noundef byval(%struct.point16) align 8 %1) #0 { + %3 = bitcast %struct.point16* %0 to i8* + %4 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 8 %0, %struct.point17* noundef byval(%struct.point17) align 8 %1) #0 { + %3 = bitcast %struct.point17* %0 to i8* + %4 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 8 %0, %struct.point18* noundef byval(%struct.point18) align 8 %1) #0 { + %3 = bitcast %struct.point18* %0 to i8* + %4 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 8 %0, %struct.point19* noundef byval(%struct.point19) align 8 %1) #0 { + %3 = bitcast %struct.point19* %0 to i8* + %4 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 8 %0, %struct.point20* noundef byval(%struct.point20) align 8 %1) #0 { + %3 = bitcast %struct.point20* %0 to i8* + %4 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="arm1176jzf-s" "target-features"="+armv6kz,+dsp,+fp64,+strict-align,+vfp2,+vfp2sp,-aes,-d32,-fp-armv8,-fp-armv8d16,-fp-armv8d16sp,-fp-armv8sp,-fp16,-fp16fml,-fullfp16,-neon,-sha2,-thumb-mode,-vfp3,-vfp3d16,-vfp3d16sp,-vfp3sp,-vfp4,-vfp4d16,-vfp4d16sp,-vfp4sp" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"min_enum_size", i32 4} +!2 = !{i32 8, !"branch-target-enforcement", i32 0} +!3 = !{i32 8, !"sign-return-address", i32 0} +!4 = !{i32 8, !"sign-return-address-all", i32 0} +!5 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!6 = !{i32 7, !"PIC Level", i32 2} +!7 = !{i32 7, !"PIE Level", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 2} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/armv6/struct_int16.ll b/internal/cabi/_testdata/arch/armv6/struct_int16.ll new file mode 100644 index 00000000..e4b92005 --- /dev/null +++ b/internal/cabi/_testdata/arch/armv6/struct_int16.ll @@ -0,0 +1,302 @@ +; ModuleID = '../../wrap/struct_int16.c' +source_filename = "../../wrap/struct_int16.c" +target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64" +target triple = "armv6kz-unknown-linux-gnueabihf" + +%struct.point1 = type { i16 } +%struct.point2 = type { i16, i16 } +%struct.point3 = type { i16, i16, i16 } +%struct.point4 = type { i16, i16, i16, i16 } +%struct.point5 = type { i16, i16, i16, i16, i16 } +%struct.point6 = type { i16, i16, i16, i16, i16, i16 } +%struct.point7 = type { i16, i16, i16, i16, i16, i16, i16 } +%struct.point8 = type { i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point9 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point10 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point11 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point12 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point13 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point14 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point15 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point16 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point17 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point18 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point19 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point20 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } + +; Function Attrs: noinline nounwind optnone +define dso_local i16 @demo1([1 x i32] %0) #0 { + %2 = alloca %struct.point1, align 2 + %3 = alloca %struct.point1, align 2 + %4 = alloca [1 x i32], align 4 + %5 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + store [1 x i32] %0, [1 x i32]* %4, align 4 + %6 = bitcast i16* %5 to i8* + %7 = bitcast [1 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %6, i8* align 4 %7, i32 2, i1 false) + %8 = bitcast %struct.point1* %2 to i8* + %9 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %8, i8* align 2 %9, i32 2, i1 false) + %10 = getelementptr inbounds %struct.point1, %struct.point1* %2, i32 0, i32 0 + %11 = load i16, i16* %10, align 2 + ret i16 %11 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define dso_local i32 @demo2([1 x i32] %0) #0 { + %2 = alloca %struct.point2, align 2 + %3 = alloca %struct.point2, align 2 + %4 = bitcast %struct.point2* %3 to [1 x i32]* + store [1 x i32] %0, [1 x i32]* %4, align 2 + %5 = bitcast %struct.point2* %2 to i8* + %6 = bitcast %struct.point2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 2 %6, i32 4, i1 false) + %7 = bitcast %struct.point2* %2 to i32* + %8 = load i32, i32* %7, align 2 + ret i32 %8 +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo3(%struct.point3* noalias sret(%struct.point3) align 2 %0, [2 x i32] %1) #0 { + %3 = alloca %struct.point3, align 2 + %4 = alloca [2 x i32], align 4 + store [2 x i32] %1, [2 x i32]* %4, align 4 + %5 = bitcast %struct.point3* %3 to i8* + %6 = bitcast [2 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 6, i1 false) + %7 = bitcast %struct.point3* %0 to i8* + %8 = bitcast %struct.point3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %7, i8* align 2 %8, i32 6, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo4(%struct.point4* noalias sret(%struct.point4) align 2 %0, [2 x i32] %1) #0 { + %3 = alloca %struct.point4, align 2 + %4 = bitcast %struct.point4* %3 to [2 x i32]* + store [2 x i32] %1, [2 x i32]* %4, align 2 + %5 = bitcast %struct.point4* %0 to i8* + %6 = bitcast %struct.point4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 2 %6, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo5(%struct.point5* noalias sret(%struct.point5) align 2 %0, [3 x i32] %1) #0 { + %3 = alloca %struct.point5, align 2 + %4 = alloca [3 x i32], align 4 + store [3 x i32] %1, [3 x i32]* %4, align 4 + %5 = bitcast %struct.point5* %3 to i8* + %6 = bitcast [3 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 10, i1 false) + %7 = bitcast %struct.point5* %0 to i8* + %8 = bitcast %struct.point5* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %7, i8* align 2 %8, i32 10, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo6(%struct.point6* noalias sret(%struct.point6) align 2 %0, [3 x i32] %1) #0 { + %3 = alloca %struct.point6, align 2 + %4 = bitcast %struct.point6* %3 to [3 x i32]* + store [3 x i32] %1, [3 x i32]* %4, align 2 + %5 = bitcast %struct.point6* %0 to i8* + %6 = bitcast %struct.point6* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 2 %6, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo7(%struct.point7* noalias sret(%struct.point7) align 2 %0, [4 x i32] %1) #0 { + %3 = alloca %struct.point7, align 2 + %4 = alloca [4 x i32], align 4 + store [4 x i32] %1, [4 x i32]* %4, align 4 + %5 = bitcast %struct.point7* %3 to i8* + %6 = bitcast [4 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 14, i1 false) + %7 = bitcast %struct.point7* %0 to i8* + %8 = bitcast %struct.point7* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %7, i8* align 2 %8, i32 14, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo8(%struct.point8* noalias sret(%struct.point8) align 2 %0, [4 x i32] %1) #0 { + %3 = alloca %struct.point8, align 2 + %4 = bitcast %struct.point8* %3 to [4 x i32]* + store [4 x i32] %1, [4 x i32]* %4, align 2 + %5 = bitcast %struct.point8* %0 to i8* + %6 = bitcast %struct.point8* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 2 %6, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 2 %0, [5 x i32] %1) #0 { + %3 = alloca %struct.point9, align 2 + %4 = alloca [5 x i32], align 4 + store [5 x i32] %1, [5 x i32]* %4, align 4 + %5 = bitcast %struct.point9* %3 to i8* + %6 = bitcast [5 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 18, i1 false) + %7 = bitcast %struct.point9* %0 to i8* + %8 = bitcast %struct.point9* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %7, i8* align 2 %8, i32 18, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 2 %0, [5 x i32] %1) #0 { + %3 = alloca %struct.point10, align 2 + %4 = bitcast %struct.point10* %3 to [5 x i32]* + store [5 x i32] %1, [5 x i32]* %4, align 2 + %5 = bitcast %struct.point10* %0 to i8* + %6 = bitcast %struct.point10* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 2 %6, i32 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 2 %0, [6 x i32] %1) #0 { + %3 = alloca %struct.point11, align 2 + %4 = alloca [6 x i32], align 4 + store [6 x i32] %1, [6 x i32]* %4, align 4 + %5 = bitcast %struct.point11* %3 to i8* + %6 = bitcast [6 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 22, i1 false) + %7 = bitcast %struct.point11* %0 to i8* + %8 = bitcast %struct.point11* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %7, i8* align 2 %8, i32 22, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 2 %0, [6 x i32] %1) #0 { + %3 = alloca %struct.point12, align 2 + %4 = bitcast %struct.point12* %3 to [6 x i32]* + store [6 x i32] %1, [6 x i32]* %4, align 2 + %5 = bitcast %struct.point12* %0 to i8* + %6 = bitcast %struct.point12* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 2 %6, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 2 %0, [7 x i32] %1) #0 { + %3 = alloca %struct.point13, align 2 + %4 = alloca [7 x i32], align 4 + store [7 x i32] %1, [7 x i32]* %4, align 4 + %5 = bitcast %struct.point13* %3 to i8* + %6 = bitcast [7 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 26, i1 false) + %7 = bitcast %struct.point13* %0 to i8* + %8 = bitcast %struct.point13* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %7, i8* align 2 %8, i32 26, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 2 %0, [7 x i32] %1) #0 { + %3 = alloca %struct.point14, align 2 + %4 = bitcast %struct.point14* %3 to [7 x i32]* + store [7 x i32] %1, [7 x i32]* %4, align 2 + %5 = bitcast %struct.point14* %0 to i8* + %6 = bitcast %struct.point14* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 2 %6, i32 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 2 %0, [8 x i32] %1) #0 { + %3 = alloca %struct.point15, align 2 + %4 = alloca [8 x i32], align 4 + store [8 x i32] %1, [8 x i32]* %4, align 4 + %5 = bitcast %struct.point15* %3 to i8* + %6 = bitcast [8 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 30, i1 false) + %7 = bitcast %struct.point15* %0 to i8* + %8 = bitcast %struct.point15* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %7, i8* align 2 %8, i32 30, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 2 %0, [8 x i32] %1) #0 { + %3 = alloca %struct.point16, align 2 + %4 = bitcast %struct.point16* %3 to [8 x i32]* + store [8 x i32] %1, [8 x i32]* %4, align 2 + %5 = bitcast %struct.point16* %0 to i8* + %6 = bitcast %struct.point16* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 2 %6, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 2 %0, [9 x i32] %1) #0 { + %3 = alloca %struct.point17, align 2 + %4 = alloca [9 x i32], align 4 + store [9 x i32] %1, [9 x i32]* %4, align 4 + %5 = bitcast %struct.point17* %3 to i8* + %6 = bitcast [9 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 34, i1 false) + %7 = bitcast %struct.point17* %0 to i8* + %8 = bitcast %struct.point17* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %7, i8* align 2 %8, i32 34, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 2 %0, [9 x i32] %1) #0 { + %3 = alloca %struct.point18, align 2 + %4 = bitcast %struct.point18* %3 to [9 x i32]* + store [9 x i32] %1, [9 x i32]* %4, align 2 + %5 = bitcast %struct.point18* %0 to i8* + %6 = bitcast %struct.point18* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 2 %6, i32 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 2 %0, [10 x i32] %1) #0 { + %3 = alloca %struct.point19, align 2 + %4 = alloca [10 x i32], align 4 + store [10 x i32] %1, [10 x i32]* %4, align 4 + %5 = bitcast %struct.point19* %3 to i8* + %6 = bitcast [10 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 38, i1 false) + %7 = bitcast %struct.point19* %0 to i8* + %8 = bitcast %struct.point19* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %7, i8* align 2 %8, i32 38, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 2 %0, [10 x i32] %1) #0 { + %3 = alloca %struct.point20, align 2 + %4 = bitcast %struct.point20* %3 to [10 x i32]* + store [10 x i32] %1, [10 x i32]* %4, align 2 + %5 = bitcast %struct.point20* %0 to i8* + %6 = bitcast %struct.point20* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 2 %6, i32 40, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="arm1176jzf-s" "target-features"="+armv6kz,+dsp,+fp64,+strict-align,+vfp2,+vfp2sp,-aes,-d32,-fp-armv8,-fp-armv8d16,-fp-armv8d16sp,-fp-armv8sp,-fp16,-fp16fml,-fullfp16,-neon,-sha2,-thumb-mode,-vfp3,-vfp3d16,-vfp3d16sp,-vfp3sp,-vfp4,-vfp4d16,-vfp4d16sp,-vfp4sp" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"min_enum_size", i32 4} +!2 = !{i32 8, !"branch-target-enforcement", i32 0} +!3 = !{i32 8, !"sign-return-address", i32 0} +!4 = !{i32 8, !"sign-return-address-all", i32 0} +!5 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!6 = !{i32 7, !"PIC Level", i32 2} +!7 = !{i32 7, !"PIE Level", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 2} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/armv6/struct_int32.ll b/internal/cabi/_testdata/arch/armv6/struct_int32.ll new file mode 100644 index 00000000..d7919514 --- /dev/null +++ b/internal/cabi/_testdata/arch/armv6/struct_int32.ll @@ -0,0 +1,257 @@ +; ModuleID = '../../wrap/struct_int32.c' +source_filename = "../../wrap/struct_int32.c" +target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64" +target triple = "armv6kz-unknown-linux-gnueabihf" + +%struct.point1 = type { i32 } +%struct.point2 = type { i32, i32 } +%struct.point3 = type { i32, i32, i32 } +%struct.point4 = type { i32, i32, i32, i32 } +%struct.point5 = type { i32, i32, i32, i32, i32 } +%struct.point6 = type { i32, i32, i32, i32, i32, i32 } +%struct.point7 = type { i32, i32, i32, i32, i32, i32, i32 } +%struct.point8 = type { i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point9 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point10 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point11 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point12 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point13 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point14 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point15 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point16 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point17 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point18 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point19 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point20 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } + +; Function Attrs: noinline nounwind optnone +define dso_local i32 @demo1([1 x i32] %0) #0 { + %2 = alloca %struct.point1, align 4 + %3 = alloca %struct.point1, align 4 + %4 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + %5 = bitcast i32* %4 to [1 x i32]* + store [1 x i32] %0, [1 x i32]* %5, align 4 + %6 = bitcast %struct.point1* %2 to i8* + %7 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 4, i1 false) + %8 = getelementptr inbounds %struct.point1, %struct.point1* %2, i32 0, i32 0 + %9 = load i32, i32* %8, align 4 + ret i32 %9 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo2(%struct.point2* noalias sret(%struct.point2) align 4 %0, [2 x i32] %1) #0 { + %3 = alloca %struct.point2, align 4 + %4 = bitcast %struct.point2* %3 to [2 x i32]* + store [2 x i32] %1, [2 x i32]* %4, align 4 + %5 = bitcast %struct.point2* %0 to i8* + %6 = bitcast %struct.point2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo3(%struct.point3* noalias sret(%struct.point3) align 4 %0, [3 x i32] %1) #0 { + %3 = alloca %struct.point3, align 4 + %4 = bitcast %struct.point3* %3 to [3 x i32]* + store [3 x i32] %1, [3 x i32]* %4, align 4 + %5 = bitcast %struct.point3* %0 to i8* + %6 = bitcast %struct.point3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo4(%struct.point4* noalias sret(%struct.point4) align 4 %0, [4 x i32] %1) #0 { + %3 = alloca %struct.point4, align 4 + %4 = bitcast %struct.point4* %3 to [4 x i32]* + store [4 x i32] %1, [4 x i32]* %4, align 4 + %5 = bitcast %struct.point4* %0 to i8* + %6 = bitcast %struct.point4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo5(%struct.point5* noalias sret(%struct.point5) align 4 %0, [5 x i32] %1) #0 { + %3 = alloca %struct.point5, align 4 + %4 = bitcast %struct.point5* %3 to [5 x i32]* + store [5 x i32] %1, [5 x i32]* %4, align 4 + %5 = bitcast %struct.point5* %0 to i8* + %6 = bitcast %struct.point5* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo6(%struct.point6* noalias sret(%struct.point6) align 4 %0, [6 x i32] %1) #0 { + %3 = alloca %struct.point6, align 4 + %4 = bitcast %struct.point6* %3 to [6 x i32]* + store [6 x i32] %1, [6 x i32]* %4, align 4 + %5 = bitcast %struct.point6* %0 to i8* + %6 = bitcast %struct.point6* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo7(%struct.point7* noalias sret(%struct.point7) align 4 %0, [7 x i32] %1) #0 { + %3 = alloca %struct.point7, align 4 + %4 = bitcast %struct.point7* %3 to [7 x i32]* + store [7 x i32] %1, [7 x i32]* %4, align 4 + %5 = bitcast %struct.point7* %0 to i8* + %6 = bitcast %struct.point7* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo8(%struct.point8* noalias sret(%struct.point8) align 4 %0, [8 x i32] %1) #0 { + %3 = alloca %struct.point8, align 4 + %4 = bitcast %struct.point8* %3 to [8 x i32]* + store [8 x i32] %1, [8 x i32]* %4, align 4 + %5 = bitcast %struct.point8* %0 to i8* + %6 = bitcast %struct.point8* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 4 %0, [9 x i32] %1) #0 { + %3 = alloca %struct.point9, align 4 + %4 = bitcast %struct.point9* %3 to [9 x i32]* + store [9 x i32] %1, [9 x i32]* %4, align 4 + %5 = bitcast %struct.point9* %0 to i8* + %6 = bitcast %struct.point9* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 4 %0, [10 x i32] %1) #0 { + %3 = alloca %struct.point10, align 4 + %4 = bitcast %struct.point10* %3 to [10 x i32]* + store [10 x i32] %1, [10 x i32]* %4, align 4 + %5 = bitcast %struct.point10* %0 to i8* + %6 = bitcast %struct.point10* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 4 %0, [11 x i32] %1) #0 { + %3 = alloca %struct.point11, align 4 + %4 = bitcast %struct.point11* %3 to [11 x i32]* + store [11 x i32] %1, [11 x i32]* %4, align 4 + %5 = bitcast %struct.point11* %0 to i8* + %6 = bitcast %struct.point11* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 4 %0, [12 x i32] %1) #0 { + %3 = alloca %struct.point12, align 4 + %4 = bitcast %struct.point12* %3 to [12 x i32]* + store [12 x i32] %1, [12 x i32]* %4, align 4 + %5 = bitcast %struct.point12* %0 to i8* + %6 = bitcast %struct.point12* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 4 %0, [13 x i32] %1) #0 { + %3 = alloca %struct.point13, align 4 + %4 = bitcast %struct.point13* %3 to [13 x i32]* + store [13 x i32] %1, [13 x i32]* %4, align 4 + %5 = bitcast %struct.point13* %0 to i8* + %6 = bitcast %struct.point13* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 4 %0, [14 x i32] %1) #0 { + %3 = alloca %struct.point14, align 4 + %4 = bitcast %struct.point14* %3 to [14 x i32]* + store [14 x i32] %1, [14 x i32]* %4, align 4 + %5 = bitcast %struct.point14* %0 to i8* + %6 = bitcast %struct.point14* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 4 %0, [15 x i32] %1) #0 { + %3 = alloca %struct.point15, align 4 + %4 = bitcast %struct.point15* %3 to [15 x i32]* + store [15 x i32] %1, [15 x i32]* %4, align 4 + %5 = bitcast %struct.point15* %0 to i8* + %6 = bitcast %struct.point15* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 4 %0, [16 x i32] %1) #0 { + %3 = alloca %struct.point16, align 4 + %4 = bitcast %struct.point16* %3 to [16 x i32]* + store [16 x i32] %1, [16 x i32]* %4, align 4 + %5 = bitcast %struct.point16* %0 to i8* + %6 = bitcast %struct.point16* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 4 %0, %struct.point17* noundef byval(%struct.point17) align 4 %1) #0 { + %3 = bitcast %struct.point17* %0 to i8* + %4 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 4 %0, %struct.point18* noundef byval(%struct.point18) align 4 %1) #0 { + %3 = bitcast %struct.point18* %0 to i8* + %4 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 4 %0, %struct.point19* noundef byval(%struct.point19) align 4 %1) #0 { + %3 = bitcast %struct.point19* %0 to i8* + %4 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 4 %0, %struct.point20* noundef byval(%struct.point20) align 4 %1) #0 { + %3 = bitcast %struct.point20* %0 to i8* + %4 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="arm1176jzf-s" "target-features"="+armv6kz,+dsp,+fp64,+strict-align,+vfp2,+vfp2sp,-aes,-d32,-fp-armv8,-fp-armv8d16,-fp-armv8d16sp,-fp-armv8sp,-fp16,-fp16fml,-fullfp16,-neon,-sha2,-thumb-mode,-vfp3,-vfp3d16,-vfp3d16sp,-vfp3sp,-vfp4,-vfp4d16,-vfp4d16sp,-vfp4sp" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"min_enum_size", i32 4} +!2 = !{i32 8, !"branch-target-enforcement", i32 0} +!3 = !{i32 8, !"sign-return-address", i32 0} +!4 = !{i32 8, !"sign-return-address-all", i32 0} +!5 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!6 = !{i32 7, !"PIC Level", i32 2} +!7 = !{i32 7, !"PIE Level", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 2} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/armv6/struct_int64.ll b/internal/cabi/_testdata/arch/armv6/struct_int64.ll new file mode 100644 index 00000000..68d17466 --- /dev/null +++ b/internal/cabi/_testdata/arch/armv6/struct_int64.ll @@ -0,0 +1,230 @@ +; ModuleID = '../../wrap/struct_int64.c' +source_filename = "../../wrap/struct_int64.c" +target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64" +target triple = "armv6kz-unknown-linux-gnueabihf" + +%struct.point1 = type { i64 } +%struct.point2 = type { i64, i64 } +%struct.point3 = type { i64, i64, i64 } +%struct.point4 = type { i64, i64, i64, i64 } +%struct.point5 = type { i64, i64, i64, i64, i64 } +%struct.point6 = type { i64, i64, i64, i64, i64, i64 } +%struct.point7 = type { i64, i64, i64, i64, i64, i64, i64 } +%struct.point8 = type { i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point9 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point10 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point11 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point12 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point13 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point14 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point15 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point16 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point17 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point18 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point19 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point20 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo1(%struct.point1* noalias sret(%struct.point1) align 8 %0, [1 x i64] %1) #0 { + %3 = alloca %struct.point1, align 8 + %4 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + %5 = bitcast i64* %4 to [1 x i64]* + store [1 x i64] %1, [1 x i64]* %5, align 8 + %6 = bitcast %struct.point1* %0 to i8* + %7 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %6, i8* align 8 %7, i32 8, i1 false) + ret void +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo2(%struct.point2* noalias sret(%struct.point2) align 8 %0, [2 x i64] %1) #0 { + %3 = alloca %struct.point2, align 8 + %4 = bitcast %struct.point2* %3 to [2 x i64]* + store [2 x i64] %1, [2 x i64]* %4, align 8 + %5 = bitcast %struct.point2* %0 to i8* + %6 = bitcast %struct.point2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %5, i8* align 8 %6, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo3(%struct.point3* noalias sret(%struct.point3) align 8 %0, [3 x i64] %1) #0 { + %3 = alloca %struct.point3, align 8 + %4 = bitcast %struct.point3* %3 to [3 x i64]* + store [3 x i64] %1, [3 x i64]* %4, align 8 + %5 = bitcast %struct.point3* %0 to i8* + %6 = bitcast %struct.point3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %5, i8* align 8 %6, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo4(%struct.point4* noalias sret(%struct.point4) align 8 %0, [4 x i64] %1) #0 { + %3 = alloca %struct.point4, align 8 + %4 = bitcast %struct.point4* %3 to [4 x i64]* + store [4 x i64] %1, [4 x i64]* %4, align 8 + %5 = bitcast %struct.point4* %0 to i8* + %6 = bitcast %struct.point4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %5, i8* align 8 %6, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo5(%struct.point5* noalias sret(%struct.point5) align 8 %0, [5 x i64] %1) #0 { + %3 = alloca %struct.point5, align 8 + %4 = bitcast %struct.point5* %3 to [5 x i64]* + store [5 x i64] %1, [5 x i64]* %4, align 8 + %5 = bitcast %struct.point5* %0 to i8* + %6 = bitcast %struct.point5* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %5, i8* align 8 %6, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo6(%struct.point6* noalias sret(%struct.point6) align 8 %0, [6 x i64] %1) #0 { + %3 = alloca %struct.point6, align 8 + %4 = bitcast %struct.point6* %3 to [6 x i64]* + store [6 x i64] %1, [6 x i64]* %4, align 8 + %5 = bitcast %struct.point6* %0 to i8* + %6 = bitcast %struct.point6* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %5, i8* align 8 %6, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo7(%struct.point7* noalias sret(%struct.point7) align 8 %0, [7 x i64] %1) #0 { + %3 = alloca %struct.point7, align 8 + %4 = bitcast %struct.point7* %3 to [7 x i64]* + store [7 x i64] %1, [7 x i64]* %4, align 8 + %5 = bitcast %struct.point7* %0 to i8* + %6 = bitcast %struct.point7* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %5, i8* align 8 %6, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo8(%struct.point8* noalias sret(%struct.point8) align 8 %0, [8 x i64] %1) #0 { + %3 = alloca %struct.point8, align 8 + %4 = bitcast %struct.point8* %3 to [8 x i64]* + store [8 x i64] %1, [8 x i64]* %4, align 8 + %5 = bitcast %struct.point8* %0 to i8* + %6 = bitcast %struct.point8* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %5, i8* align 8 %6, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 8 %0, %struct.point9* noundef byval(%struct.point9) align 8 %1) #0 { + %3 = bitcast %struct.point9* %0 to i8* + %4 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 8 %0, %struct.point10* noundef byval(%struct.point10) align 8 %1) #0 { + %3 = bitcast %struct.point10* %0 to i8* + %4 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 8 %0, %struct.point11* noundef byval(%struct.point11) align 8 %1) #0 { + %3 = bitcast %struct.point11* %0 to i8* + %4 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 8 %0, %struct.point12* noundef byval(%struct.point12) align 8 %1) #0 { + %3 = bitcast %struct.point12* %0 to i8* + %4 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 8 %0, %struct.point13* noundef byval(%struct.point13) align 8 %1) #0 { + %3 = bitcast %struct.point13* %0 to i8* + %4 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 8 %0, %struct.point14* noundef byval(%struct.point14) align 8 %1) #0 { + %3 = bitcast %struct.point14* %0 to i8* + %4 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 8 %0, %struct.point15* noundef byval(%struct.point15) align 8 %1) #0 { + %3 = bitcast %struct.point15* %0 to i8* + %4 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 8 %0, %struct.point16* noundef byval(%struct.point16) align 8 %1) #0 { + %3 = bitcast %struct.point16* %0 to i8* + %4 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 8 %0, %struct.point17* noundef byval(%struct.point17) align 8 %1) #0 { + %3 = bitcast %struct.point17* %0 to i8* + %4 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 8 %0, %struct.point18* noundef byval(%struct.point18) align 8 %1) #0 { + %3 = bitcast %struct.point18* %0 to i8* + %4 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 8 %0, %struct.point19* noundef byval(%struct.point19) align 8 %1) #0 { + %3 = bitcast %struct.point19* %0 to i8* + %4 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 8 %0, %struct.point20* noundef byval(%struct.point20) align 8 %1) #0 { + %3 = bitcast %struct.point20* %0 to i8* + %4 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="arm1176jzf-s" "target-features"="+armv6kz,+dsp,+fp64,+strict-align,+vfp2,+vfp2sp,-aes,-d32,-fp-armv8,-fp-armv8d16,-fp-armv8d16sp,-fp-armv8sp,-fp16,-fp16fml,-fullfp16,-neon,-sha2,-thumb-mode,-vfp3,-vfp3d16,-vfp3d16sp,-vfp3sp,-vfp4,-vfp4d16,-vfp4d16sp,-vfp4sp" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"min_enum_size", i32 4} +!2 = !{i32 8, !"branch-target-enforcement", i32 0} +!3 = !{i32 8, !"sign-return-address", i32 0} +!4 = !{i32 8, !"sign-return-address-all", i32 0} +!5 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!6 = !{i32 7, !"PIC Level", i32 2} +!7 = !{i32 7, !"PIE Level", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 2} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/armv6/struct_int8.ll b/internal/cabi/_testdata/arch/armv6/struct_int8.ll new file mode 100644 index 00000000..7554849b --- /dev/null +++ b/internal/cabi/_testdata/arch/armv6/struct_int8.ll @@ -0,0 +1,325 @@ +; ModuleID = '../../wrap/struct_int8.c' +source_filename = "../../wrap/struct_int8.c" +target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64" +target triple = "armv6kz-unknown-linux-gnueabihf" + +%struct.point1 = type { i8 } +%struct.point2 = type { i8, i8 } +%struct.point3 = type { i8, i8, i8 } +%struct.point4 = type { i8, i8, i8, i8 } +%struct.point5 = type { i8, i8, i8, i8, i8 } +%struct.point6 = type { i8, i8, i8, i8, i8, i8 } +%struct.point7 = type { i8, i8, i8, i8, i8, i8, i8 } +%struct.point8 = type { i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point9 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point10 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point11 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point12 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point13 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point14 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point15 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point16 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point17 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point18 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point19 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point20 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } + +; Function Attrs: noinline nounwind optnone +define dso_local i8 @demo1([1 x i32] %0) #0 { + %2 = alloca %struct.point1, align 1 + %3 = alloca %struct.point1, align 1 + %4 = alloca [1 x i32], align 4 + %5 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + store [1 x i32] %0, [1 x i32]* %4, align 4 + %6 = bitcast [1 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 1, i1 false) + %7 = bitcast %struct.point1* %2 to i8* + %8 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %7, i8* align 1 %8, i32 1, i1 false) + %9 = getelementptr inbounds %struct.point1, %struct.point1* %2, i32 0, i32 0 + %10 = load i8, i8* %9, align 1 + ret i8 %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define dso_local i16 @demo2([1 x i32] %0) #0 { + %2 = alloca %struct.point2, align 1 + %3 = alloca %struct.point2, align 1 + %4 = alloca [1 x i32], align 4 + store [1 x i32] %0, [1 x i32]* %4, align 4 + %5 = bitcast %struct.point2* %3 to i8* + %6 = bitcast [1 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 2, i1 false) + %7 = bitcast %struct.point2* %2 to i8* + %8 = bitcast %struct.point2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %7, i8* align 1 %8, i32 2, i1 false) + %9 = bitcast %struct.point2* %2 to i16* + %10 = load i16, i16* %9, align 1 + ret i16 %10 +} + +; Function Attrs: noinline nounwind optnone +define dso_local i32 @demo3([1 x i32] %0) #0 { + %2 = alloca %struct.point3, align 1 + %3 = alloca %struct.point3, align 1 + %4 = alloca [1 x i32], align 4 + %5 = alloca i32, align 4 + store [1 x i32] %0, [1 x i32]* %4, align 4 + %6 = bitcast %struct.point3* %3 to i8* + %7 = bitcast [1 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %6, i8* align 4 %7, i32 3, i1 false) + %8 = bitcast %struct.point3* %2 to i8* + %9 = bitcast %struct.point3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %8, i8* align 1 %9, i32 3, i1 false) + %10 = bitcast i32* %5 to i8* + %11 = bitcast %struct.point3* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %10, i8* align 1 %11, i32 3, i1 false) + %12 = load i32, i32* %5, align 4 + ret i32 %12 +} + +; Function Attrs: noinline nounwind optnone +define dso_local i32 @demo4([1 x i32] %0) #0 { + %2 = alloca %struct.point4, align 1 + %3 = alloca %struct.point4, align 1 + %4 = bitcast %struct.point4* %3 to [1 x i32]* + store [1 x i32] %0, [1 x i32]* %4, align 1 + %5 = bitcast %struct.point4* %2 to i8* + %6 = bitcast %struct.point4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 1 %6, i32 4, i1 false) + %7 = bitcast %struct.point4* %2 to i32* + %8 = load i32, i32* %7, align 1 + ret i32 %8 +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo5(%struct.point5* noalias sret(%struct.point5) align 1 %0, [2 x i32] %1) #0 { + %3 = alloca %struct.point5, align 1 + %4 = alloca [2 x i32], align 4 + store [2 x i32] %1, [2 x i32]* %4, align 4 + %5 = bitcast %struct.point5* %3 to i8* + %6 = bitcast [2 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 5, i1 false) + %7 = bitcast %struct.point5* %0 to i8* + %8 = bitcast %struct.point5* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %7, i8* align 1 %8, i32 5, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo6(%struct.point6* noalias sret(%struct.point6) align 1 %0, [2 x i32] %1) #0 { + %3 = alloca %struct.point6, align 1 + %4 = alloca [2 x i32], align 4 + store [2 x i32] %1, [2 x i32]* %4, align 4 + %5 = bitcast %struct.point6* %3 to i8* + %6 = bitcast [2 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 6, i1 false) + %7 = bitcast %struct.point6* %0 to i8* + %8 = bitcast %struct.point6* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %7, i8* align 1 %8, i32 6, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo7(%struct.point7* noalias sret(%struct.point7) align 1 %0, [2 x i32] %1) #0 { + %3 = alloca %struct.point7, align 1 + %4 = alloca [2 x i32], align 4 + store [2 x i32] %1, [2 x i32]* %4, align 4 + %5 = bitcast %struct.point7* %3 to i8* + %6 = bitcast [2 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 7, i1 false) + %7 = bitcast %struct.point7* %0 to i8* + %8 = bitcast %struct.point7* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %7, i8* align 1 %8, i32 7, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo8(%struct.point8* noalias sret(%struct.point8) align 1 %0, [2 x i32] %1) #0 { + %3 = alloca %struct.point8, align 1 + %4 = bitcast %struct.point8* %3 to [2 x i32]* + store [2 x i32] %1, [2 x i32]* %4, align 1 + %5 = bitcast %struct.point8* %0 to i8* + %6 = bitcast %struct.point8* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 1 %6, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 1 %0, [3 x i32] %1) #0 { + %3 = alloca %struct.point9, align 1 + %4 = alloca [3 x i32], align 4 + store [3 x i32] %1, [3 x i32]* %4, align 4 + %5 = bitcast %struct.point9* %3 to i8* + %6 = bitcast [3 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 9, i1 false) + %7 = bitcast %struct.point9* %0 to i8* + %8 = bitcast %struct.point9* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %7, i8* align 1 %8, i32 9, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 1 %0, [3 x i32] %1) #0 { + %3 = alloca %struct.point10, align 1 + %4 = alloca [3 x i32], align 4 + store [3 x i32] %1, [3 x i32]* %4, align 4 + %5 = bitcast %struct.point10* %3 to i8* + %6 = bitcast [3 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 10, i1 false) + %7 = bitcast %struct.point10* %0 to i8* + %8 = bitcast %struct.point10* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %7, i8* align 1 %8, i32 10, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 1 %0, [3 x i32] %1) #0 { + %3 = alloca %struct.point11, align 1 + %4 = alloca [3 x i32], align 4 + store [3 x i32] %1, [3 x i32]* %4, align 4 + %5 = bitcast %struct.point11* %3 to i8* + %6 = bitcast [3 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 11, i1 false) + %7 = bitcast %struct.point11* %0 to i8* + %8 = bitcast %struct.point11* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %7, i8* align 1 %8, i32 11, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 1 %0, [3 x i32] %1) #0 { + %3 = alloca %struct.point12, align 1 + %4 = bitcast %struct.point12* %3 to [3 x i32]* + store [3 x i32] %1, [3 x i32]* %4, align 1 + %5 = bitcast %struct.point12* %0 to i8* + %6 = bitcast %struct.point12* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 1 %6, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 1 %0, [4 x i32] %1) #0 { + %3 = alloca %struct.point13, align 1 + %4 = alloca [4 x i32], align 4 + store [4 x i32] %1, [4 x i32]* %4, align 4 + %5 = bitcast %struct.point13* %3 to i8* + %6 = bitcast [4 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 13, i1 false) + %7 = bitcast %struct.point13* %0 to i8* + %8 = bitcast %struct.point13* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %7, i8* align 1 %8, i32 13, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 1 %0, [4 x i32] %1) #0 { + %3 = alloca %struct.point14, align 1 + %4 = alloca [4 x i32], align 4 + store [4 x i32] %1, [4 x i32]* %4, align 4 + %5 = bitcast %struct.point14* %3 to i8* + %6 = bitcast [4 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 14, i1 false) + %7 = bitcast %struct.point14* %0 to i8* + %8 = bitcast %struct.point14* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %7, i8* align 1 %8, i32 14, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 1 %0, [4 x i32] %1) #0 { + %3 = alloca %struct.point15, align 1 + %4 = alloca [4 x i32], align 4 + store [4 x i32] %1, [4 x i32]* %4, align 4 + %5 = bitcast %struct.point15* %3 to i8* + %6 = bitcast [4 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 15, i1 false) + %7 = bitcast %struct.point15* %0 to i8* + %8 = bitcast %struct.point15* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %7, i8* align 1 %8, i32 15, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 1 %0, [4 x i32] %1) #0 { + %3 = alloca %struct.point16, align 1 + %4 = bitcast %struct.point16* %3 to [4 x i32]* + store [4 x i32] %1, [4 x i32]* %4, align 1 + %5 = bitcast %struct.point16* %0 to i8* + %6 = bitcast %struct.point16* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 1 %6, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 1 %0, [5 x i32] %1) #0 { + %3 = alloca %struct.point17, align 1 + %4 = alloca [5 x i32], align 4 + store [5 x i32] %1, [5 x i32]* %4, align 4 + %5 = bitcast %struct.point17* %3 to i8* + %6 = bitcast [5 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 17, i1 false) + %7 = bitcast %struct.point17* %0 to i8* + %8 = bitcast %struct.point17* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %7, i8* align 1 %8, i32 17, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 1 %0, [5 x i32] %1) #0 { + %3 = alloca %struct.point18, align 1 + %4 = alloca [5 x i32], align 4 + store [5 x i32] %1, [5 x i32]* %4, align 4 + %5 = bitcast %struct.point18* %3 to i8* + %6 = bitcast [5 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 18, i1 false) + %7 = bitcast %struct.point18* %0 to i8* + %8 = bitcast %struct.point18* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %7, i8* align 1 %8, i32 18, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 1 %0, [5 x i32] %1) #0 { + %3 = alloca %struct.point19, align 1 + %4 = alloca [5 x i32], align 4 + store [5 x i32] %1, [5 x i32]* %4, align 4 + %5 = bitcast %struct.point19* %3 to i8* + %6 = bitcast [5 x i32]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 19, i1 false) + %7 = bitcast %struct.point19* %0 to i8* + %8 = bitcast %struct.point19* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %7, i8* align 1 %8, i32 19, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 1 %0, [5 x i32] %1) #0 { + %3 = alloca %struct.point20, align 1 + %4 = bitcast %struct.point20* %3 to [5 x i32]* + store [5 x i32] %1, [5 x i32]* %4, align 1 + %5 = bitcast %struct.point20* %0 to i8* + %6 = bitcast %struct.point20* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 1 %6, i32 20, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="arm1176jzf-s" "target-features"="+armv6kz,+dsp,+fp64,+strict-align,+vfp2,+vfp2sp,-aes,-d32,-fp-armv8,-fp-armv8d16,-fp-armv8d16sp,-fp-armv8sp,-fp16,-fp16fml,-fullfp16,-neon,-sha2,-thumb-mode,-vfp3,-vfp3d16,-vfp3d16sp,-vfp3sp,-vfp4,-vfp4d16,-vfp4d16sp,-vfp4sp" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"min_enum_size", i32 4} +!2 = !{i32 8, !"branch-target-enforcement", i32 0} +!3 = !{i32 8, !"sign-return-address", i32 0} +!4 = !{i32 8, !"sign-return-address-all", i32 0} +!5 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!6 = !{i32 7, !"PIC Level", i32 2} +!7 = !{i32 7, !"PIE Level", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 2} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/armv6/struct_uintptr.ll b/internal/cabi/_testdata/arch/armv6/struct_uintptr.ll new file mode 100644 index 00000000..caf23465 --- /dev/null +++ b/internal/cabi/_testdata/arch/armv6/struct_uintptr.ll @@ -0,0 +1,258 @@ +; ModuleID = '../../wrap/struct_uintptr.c' +source_filename = "../../wrap/struct_uintptr.c" +target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64" +target triple = "armv6kz-unknown-linux-gnueabihf" + +%struct.point1 = type { i8* } +%struct.point2 = type { i8*, i8* } +%struct.point3 = type { i8*, i8*, i8* } +%struct.point4 = type { i8*, i8*, i8*, i8* } +%struct.point5 = type { i8*, i8*, i8*, i8*, i8* } +%struct.point6 = type { i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point7 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point8 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point9 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point10 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point11 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point12 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point13 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point14 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point15 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point16 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point17 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point18 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point19 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point20 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } + +; Function Attrs: noinline nounwind optnone +define dso_local i32 @demo1([1 x i32] %0) #0 { + %2 = alloca %struct.point1, align 4 + %3 = alloca %struct.point1, align 4 + %4 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + %5 = bitcast i8** %4 to [1 x i32]* + store [1 x i32] %0, [1 x i32]* %5, align 4 + %6 = bitcast %struct.point1* %2 to i8* + %7 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 4, i1 false) + %8 = getelementptr inbounds %struct.point1, %struct.point1* %2, i32 0, i32 0 + %9 = load i8*, i8** %8, align 4 + %10 = ptrtoint i8* %9 to i32 + ret i32 %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo2(%struct.point2* noalias sret(%struct.point2) align 4 %0, [2 x i32] %1) #0 { + %3 = alloca %struct.point2, align 4 + %4 = bitcast %struct.point2* %3 to [2 x i32]* + store [2 x i32] %1, [2 x i32]* %4, align 4 + %5 = bitcast %struct.point2* %0 to i8* + %6 = bitcast %struct.point2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo3(%struct.point3* noalias sret(%struct.point3) align 4 %0, [3 x i32] %1) #0 { + %3 = alloca %struct.point3, align 4 + %4 = bitcast %struct.point3* %3 to [3 x i32]* + store [3 x i32] %1, [3 x i32]* %4, align 4 + %5 = bitcast %struct.point3* %0 to i8* + %6 = bitcast %struct.point3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo4(%struct.point4* noalias sret(%struct.point4) align 4 %0, [4 x i32] %1) #0 { + %3 = alloca %struct.point4, align 4 + %4 = bitcast %struct.point4* %3 to [4 x i32]* + store [4 x i32] %1, [4 x i32]* %4, align 4 + %5 = bitcast %struct.point4* %0 to i8* + %6 = bitcast %struct.point4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo5(%struct.point5* noalias sret(%struct.point5) align 4 %0, [5 x i32] %1) #0 { + %3 = alloca %struct.point5, align 4 + %4 = bitcast %struct.point5* %3 to [5 x i32]* + store [5 x i32] %1, [5 x i32]* %4, align 4 + %5 = bitcast %struct.point5* %0 to i8* + %6 = bitcast %struct.point5* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo6(%struct.point6* noalias sret(%struct.point6) align 4 %0, [6 x i32] %1) #0 { + %3 = alloca %struct.point6, align 4 + %4 = bitcast %struct.point6* %3 to [6 x i32]* + store [6 x i32] %1, [6 x i32]* %4, align 4 + %5 = bitcast %struct.point6* %0 to i8* + %6 = bitcast %struct.point6* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo7(%struct.point7* noalias sret(%struct.point7) align 4 %0, [7 x i32] %1) #0 { + %3 = alloca %struct.point7, align 4 + %4 = bitcast %struct.point7* %3 to [7 x i32]* + store [7 x i32] %1, [7 x i32]* %4, align 4 + %5 = bitcast %struct.point7* %0 to i8* + %6 = bitcast %struct.point7* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo8(%struct.point8* noalias sret(%struct.point8) align 4 %0, [8 x i32] %1) #0 { + %3 = alloca %struct.point8, align 4 + %4 = bitcast %struct.point8* %3 to [8 x i32]* + store [8 x i32] %1, [8 x i32]* %4, align 4 + %5 = bitcast %struct.point8* %0 to i8* + %6 = bitcast %struct.point8* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 4 %0, [9 x i32] %1) #0 { + %3 = alloca %struct.point9, align 4 + %4 = bitcast %struct.point9* %3 to [9 x i32]* + store [9 x i32] %1, [9 x i32]* %4, align 4 + %5 = bitcast %struct.point9* %0 to i8* + %6 = bitcast %struct.point9* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 4 %0, [10 x i32] %1) #0 { + %3 = alloca %struct.point10, align 4 + %4 = bitcast %struct.point10* %3 to [10 x i32]* + store [10 x i32] %1, [10 x i32]* %4, align 4 + %5 = bitcast %struct.point10* %0 to i8* + %6 = bitcast %struct.point10* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 4 %0, [11 x i32] %1) #0 { + %3 = alloca %struct.point11, align 4 + %4 = bitcast %struct.point11* %3 to [11 x i32]* + store [11 x i32] %1, [11 x i32]* %4, align 4 + %5 = bitcast %struct.point11* %0 to i8* + %6 = bitcast %struct.point11* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 4 %0, [12 x i32] %1) #0 { + %3 = alloca %struct.point12, align 4 + %4 = bitcast %struct.point12* %3 to [12 x i32]* + store [12 x i32] %1, [12 x i32]* %4, align 4 + %5 = bitcast %struct.point12* %0 to i8* + %6 = bitcast %struct.point12* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 4 %0, [13 x i32] %1) #0 { + %3 = alloca %struct.point13, align 4 + %4 = bitcast %struct.point13* %3 to [13 x i32]* + store [13 x i32] %1, [13 x i32]* %4, align 4 + %5 = bitcast %struct.point13* %0 to i8* + %6 = bitcast %struct.point13* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 4 %0, [14 x i32] %1) #0 { + %3 = alloca %struct.point14, align 4 + %4 = bitcast %struct.point14* %3 to [14 x i32]* + store [14 x i32] %1, [14 x i32]* %4, align 4 + %5 = bitcast %struct.point14* %0 to i8* + %6 = bitcast %struct.point14* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 4 %0, [15 x i32] %1) #0 { + %3 = alloca %struct.point15, align 4 + %4 = bitcast %struct.point15* %3 to [15 x i32]* + store [15 x i32] %1, [15 x i32]* %4, align 4 + %5 = bitcast %struct.point15* %0 to i8* + %6 = bitcast %struct.point15* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 4 %0, [16 x i32] %1) #0 { + %3 = alloca %struct.point16, align 4 + %4 = bitcast %struct.point16* %3 to [16 x i32]* + store [16 x i32] %1, [16 x i32]* %4, align 4 + %5 = bitcast %struct.point16* %0 to i8* + %6 = bitcast %struct.point16* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 4 %0, %struct.point17* noundef byval(%struct.point17) align 4 %1) #0 { + %3 = bitcast %struct.point17* %0 to i8* + %4 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 4 %0, %struct.point18* noundef byval(%struct.point18) align 4 %1) #0 { + %3 = bitcast %struct.point18* %0 to i8* + %4 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 4 %0, %struct.point19* noundef byval(%struct.point19) align 4 %1) #0 { + %3 = bitcast %struct.point19* %0 to i8* + %4 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 4 %0, %struct.point20* noundef byval(%struct.point20) align 4 %1) #0 { + %3 = bitcast %struct.point20* %0 to i8* + %4 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="arm1176jzf-s" "target-features"="+armv6kz,+dsp,+fp64,+strict-align,+vfp2,+vfp2sp,-aes,-d32,-fp-armv8,-fp-armv8d16,-fp-armv8d16sp,-fp-armv8sp,-fp16,-fp16fml,-fullfp16,-neon,-sha2,-thumb-mode,-vfp3,-vfp3d16,-vfp3d16sp,-vfp3sp,-vfp4,-vfp4d16,-vfp4d16sp,-vfp4sp" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!llvm.ident = !{!9} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"min_enum_size", i32 4} +!2 = !{i32 8, !"branch-target-enforcement", i32 0} +!3 = !{i32 8, !"sign-return-address", i32 0} +!4 = !{i32 8, !"sign-return-address-all", i32 0} +!5 = !{i32 8, !"sign-return-address-with-bkey", i32 0} +!6 = !{i32 7, !"PIC Level", i32 2} +!7 = !{i32 7, !"PIE Level", i32 2} +!8 = !{i32 7, !"frame-pointer", i32 2} +!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/i386/array_float32.ll b/internal/cabi/_testdata/arch/i386/array_float32.ll new file mode 100644 index 00000000..e18a030e --- /dev/null +++ b/internal/cabi/_testdata/arch/i386/array_float32.ll @@ -0,0 +1,262 @@ +; ModuleID = '../../wrap/array_float32.c' +source_filename = "../../wrap/array_float32.c" +target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128" +target triple = "i386-unknown-linux-gnu" + +%struct.array1 = type { [1 x float] } +%struct.array2 = type { [2 x float] } +%struct.array3 = type { [3 x float] } +%struct.array4 = type { [4 x float] } +%struct.array5 = type { [5 x float] } +%struct.array6 = type { [6 x float] } +%struct.array7 = type { [7 x float] } +%struct.array8 = type { [8 x float] } +%struct.array9 = type { [9 x float] } +%struct.array10 = type { [10 x float] } +%struct.array11 = type { [11 x float] } +%struct.array12 = type { [12 x float] } +%struct.array13 = type { [13 x float] } +%struct.array14 = type { [14 x float] } +%struct.array15 = type { [15 x float] } +%struct.array16 = type { [16 x float] } +%struct.array17 = type { [17 x float] } +%struct.array18 = type { [18 x float] } +%struct.array19 = type { [19 x float] } +%struct.array20 = type { [20 x float] } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo1(%struct.array1* noalias sret(%struct.array1) align 4 %0, %struct.array1* noundef byval(%struct.array1) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array1* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array1* %0 to i8* + %6 = bitcast %struct.array1* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 4, i1 false) + ret void +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo2(%struct.array2* noalias sret(%struct.array2) align 4 %0, %struct.array2* noundef byval(%struct.array2) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array2* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array2* %0 to i8* + %6 = bitcast %struct.array2* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo3(%struct.array3* noalias sret(%struct.array3) align 4 %0, %struct.array3* noundef byval(%struct.array3) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array3* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array3* %0 to i8* + %6 = bitcast %struct.array3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo4(%struct.array4* noalias sret(%struct.array4) align 4 %0, %struct.array4* noundef byval(%struct.array4) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array4* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array4* %0 to i8* + %6 = bitcast %struct.array4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 4 %0, %struct.array5* noundef byval(%struct.array5) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array5* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array5* %0 to i8* + %6 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 4 %0, %struct.array6* noundef byval(%struct.array6) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array6* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array6* %0 to i8* + %6 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 4 %0, %struct.array7* noundef byval(%struct.array7) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array7* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array7* %0 to i8* + %6 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 4 %0, %struct.array8* noundef byval(%struct.array8) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array8* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array8* %0 to i8* + %6 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 4 %0, %struct.array9* noundef byval(%struct.array9) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array9* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array9* %0 to i8* + %6 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 4 %0, %struct.array10* noundef byval(%struct.array10) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array10* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array10* %0 to i8* + %6 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 4 %0, %struct.array11* noundef byval(%struct.array11) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array11* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array11* %0 to i8* + %6 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 4 %0, %struct.array12* noundef byval(%struct.array12) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array12* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array12* %0 to i8* + %6 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 4 %0, %struct.array13* noundef byval(%struct.array13) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array13* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array13* %0 to i8* + %6 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 4 %0, %struct.array14* noundef byval(%struct.array14) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array14* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array14* %0 to i8* + %6 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 4 %0, %struct.array15* noundef byval(%struct.array15) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array15* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array15* %0 to i8* + %6 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 4 %0, %struct.array16* noundef byval(%struct.array16) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array16* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array16* %0 to i8* + %6 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 4 %0, %struct.array17* noundef byval(%struct.array17) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array17* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array17* %0 to i8* + %6 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 4 %0, %struct.array18* noundef byval(%struct.array18) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array18* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array18* %0 to i8* + %6 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 4 %0, %struct.array19* noundef byval(%struct.array19) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array19* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array19* %0 to i8* + %6 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 4 %0, %struct.array20* noundef byval(%struct.array20) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array20* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array20* %0 to i8* + %6 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5} +!llvm.ident = !{!6} + +!0 = !{i32 1, !"NumRegisterParameters", i32 0} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 7, !"PIC Level", i32 2} +!3 = !{i32 7, !"PIE Level", i32 2} +!4 = !{i32 7, !"uwtable", i32 2} +!5 = !{i32 7, !"frame-pointer", i32 2} +!6 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/i386/array_float64.ll b/internal/cabi/_testdata/arch/i386/array_float64.ll new file mode 100644 index 00000000..1f453621 --- /dev/null +++ b/internal/cabi/_testdata/arch/i386/array_float64.ll @@ -0,0 +1,262 @@ +; ModuleID = '../../wrap/array_float64.c' +source_filename = "../../wrap/array_float64.c" +target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128" +target triple = "i386-unknown-linux-gnu" + +%struct.array1 = type { [1 x double] } +%struct.array2 = type { [2 x double] } +%struct.array3 = type { [3 x double] } +%struct.array4 = type { [4 x double] } +%struct.array5 = type { [5 x double] } +%struct.array6 = type { [6 x double] } +%struct.array7 = type { [7 x double] } +%struct.array8 = type { [8 x double] } +%struct.array9 = type { [9 x double] } +%struct.array10 = type { [10 x double] } +%struct.array11 = type { [11 x double] } +%struct.array12 = type { [12 x double] } +%struct.array13 = type { [13 x double] } +%struct.array14 = type { [14 x double] } +%struct.array15 = type { [15 x double] } +%struct.array16 = type { [16 x double] } +%struct.array17 = type { [17 x double] } +%struct.array18 = type { [18 x double] } +%struct.array19 = type { [19 x double] } +%struct.array20 = type { [20 x double] } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo1(%struct.array1* noalias sret(%struct.array1) align 4 %0, %struct.array1* noundef byval(%struct.array1) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array1* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array1* %0 to i8* + %6 = bitcast %struct.array1* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 8, i1 false) + ret void +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo2(%struct.array2* noalias sret(%struct.array2) align 4 %0, %struct.array2* noundef byval(%struct.array2) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array2* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array2* %0 to i8* + %6 = bitcast %struct.array2* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo3(%struct.array3* noalias sret(%struct.array3) align 4 %0, %struct.array3* noundef byval(%struct.array3) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array3* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array3* %0 to i8* + %6 = bitcast %struct.array3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo4(%struct.array4* noalias sret(%struct.array4) align 4 %0, %struct.array4* noundef byval(%struct.array4) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array4* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array4* %0 to i8* + %6 = bitcast %struct.array4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 4 %0, %struct.array5* noundef byval(%struct.array5) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array5* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array5* %0 to i8* + %6 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 4 %0, %struct.array6* noundef byval(%struct.array6) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array6* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array6* %0 to i8* + %6 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 4 %0, %struct.array7* noundef byval(%struct.array7) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array7* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array7* %0 to i8* + %6 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 4 %0, %struct.array8* noundef byval(%struct.array8) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array8* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array8* %0 to i8* + %6 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 4 %0, %struct.array9* noundef byval(%struct.array9) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array9* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array9* %0 to i8* + %6 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 4 %0, %struct.array10* noundef byval(%struct.array10) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array10* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array10* %0 to i8* + %6 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 4 %0, %struct.array11* noundef byval(%struct.array11) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array11* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array11* %0 to i8* + %6 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 4 %0, %struct.array12* noundef byval(%struct.array12) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array12* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array12* %0 to i8* + %6 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 4 %0, %struct.array13* noundef byval(%struct.array13) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array13* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array13* %0 to i8* + %6 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 4 %0, %struct.array14* noundef byval(%struct.array14) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array14* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array14* %0 to i8* + %6 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 4 %0, %struct.array15* noundef byval(%struct.array15) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array15* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array15* %0 to i8* + %6 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 4 %0, %struct.array16* noundef byval(%struct.array16) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array16* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array16* %0 to i8* + %6 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 4 %0, %struct.array17* noundef byval(%struct.array17) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array17* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array17* %0 to i8* + %6 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 4 %0, %struct.array18* noundef byval(%struct.array18) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array18* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array18* %0 to i8* + %6 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 4 %0, %struct.array19* noundef byval(%struct.array19) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array19* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array19* %0 to i8* + %6 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 4 %0, %struct.array20* noundef byval(%struct.array20) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array20* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array20* %0 to i8* + %6 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5} +!llvm.ident = !{!6} + +!0 = !{i32 1, !"NumRegisterParameters", i32 0} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 7, !"PIC Level", i32 2} +!3 = !{i32 7, !"PIE Level", i32 2} +!4 = !{i32 7, !"uwtable", i32 2} +!5 = !{i32 7, !"frame-pointer", i32 2} +!6 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/i386/array_int16.ll b/internal/cabi/_testdata/arch/i386/array_int16.ll new file mode 100644 index 00000000..c06d4bb0 --- /dev/null +++ b/internal/cabi/_testdata/arch/i386/array_int16.ll @@ -0,0 +1,262 @@ +; ModuleID = '../../wrap/array_int16.c' +source_filename = "../../wrap/array_int16.c" +target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128" +target triple = "i386-unknown-linux-gnu" + +%struct.array1 = type { [1 x i16] } +%struct.array2 = type { [2 x i16] } +%struct.array3 = type { [3 x i16] } +%struct.array4 = type { [4 x i16] } +%struct.array5 = type { [5 x i16] } +%struct.array6 = type { [6 x i16] } +%struct.array7 = type { [7 x i16] } +%struct.array8 = type { [8 x i16] } +%struct.array9 = type { [9 x i16] } +%struct.array10 = type { [10 x i16] } +%struct.array11 = type { [11 x i16] } +%struct.array12 = type { [12 x i16] } +%struct.array13 = type { [13 x i16] } +%struct.array14 = type { [14 x i16] } +%struct.array15 = type { [15 x i16] } +%struct.array16 = type { [16 x i16] } +%struct.array17 = type { [17 x i16] } +%struct.array18 = type { [18 x i16] } +%struct.array19 = type { [19 x i16] } +%struct.array20 = type { [20 x i16] } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo1(%struct.array1* noalias sret(%struct.array1) align 2 %0, %struct.array1* noundef byval(%struct.array1) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array1* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array1* %0 to i8* + %6 = bitcast %struct.array1* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 2, i1 false) + ret void +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo2(%struct.array2* noalias sret(%struct.array2) align 2 %0, %struct.array2* noundef byval(%struct.array2) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array2* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array2* %0 to i8* + %6 = bitcast %struct.array2* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 4, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo3(%struct.array3* noalias sret(%struct.array3) align 2 %0, %struct.array3* noundef byval(%struct.array3) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array3* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array3* %0 to i8* + %6 = bitcast %struct.array3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 6, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo4(%struct.array4* noalias sret(%struct.array4) align 2 %0, %struct.array4* noundef byval(%struct.array4) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array4* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array4* %0 to i8* + %6 = bitcast %struct.array4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 2 %0, %struct.array5* noundef byval(%struct.array5) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array5* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array5* %0 to i8* + %6 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 10, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 2 %0, %struct.array6* noundef byval(%struct.array6) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array6* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array6* %0 to i8* + %6 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 2 %0, %struct.array7* noundef byval(%struct.array7) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array7* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array7* %0 to i8* + %6 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 14, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 2 %0, %struct.array8* noundef byval(%struct.array8) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array8* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array8* %0 to i8* + %6 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 2 %0, %struct.array9* noundef byval(%struct.array9) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array9* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array9* %0 to i8* + %6 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 18, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 2 %0, %struct.array10* noundef byval(%struct.array10) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array10* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array10* %0 to i8* + %6 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 2 %0, %struct.array11* noundef byval(%struct.array11) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array11* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array11* %0 to i8* + %6 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 22, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 2 %0, %struct.array12* noundef byval(%struct.array12) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array12* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array12* %0 to i8* + %6 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 2 %0, %struct.array13* noundef byval(%struct.array13) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array13* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array13* %0 to i8* + %6 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 26, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 2 %0, %struct.array14* noundef byval(%struct.array14) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array14* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array14* %0 to i8* + %6 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 2 %0, %struct.array15* noundef byval(%struct.array15) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array15* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array15* %0 to i8* + %6 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 30, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 2 %0, %struct.array16* noundef byval(%struct.array16) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array16* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array16* %0 to i8* + %6 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 2 %0, %struct.array17* noundef byval(%struct.array17) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array17* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array17* %0 to i8* + %6 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 34, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 2 %0, %struct.array18* noundef byval(%struct.array18) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array18* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array18* %0 to i8* + %6 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 2 %0, %struct.array19* noundef byval(%struct.array19) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array19* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array19* %0 to i8* + %6 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 38, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 2 %0, %struct.array20* noundef byval(%struct.array20) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array20* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array20* %0 to i8* + %6 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 40, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5} +!llvm.ident = !{!6} + +!0 = !{i32 1, !"NumRegisterParameters", i32 0} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 7, !"PIC Level", i32 2} +!3 = !{i32 7, !"PIE Level", i32 2} +!4 = !{i32 7, !"uwtable", i32 2} +!5 = !{i32 7, !"frame-pointer", i32 2} +!6 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/i386/array_int32.ll b/internal/cabi/_testdata/arch/i386/array_int32.ll new file mode 100644 index 00000000..c2758d0d --- /dev/null +++ b/internal/cabi/_testdata/arch/i386/array_int32.ll @@ -0,0 +1,262 @@ +; ModuleID = '../../wrap/array_int32.c' +source_filename = "../../wrap/array_int32.c" +target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128" +target triple = "i386-unknown-linux-gnu" + +%struct.array1 = type { [1 x i32] } +%struct.array2 = type { [2 x i32] } +%struct.array3 = type { [3 x i32] } +%struct.array4 = type { [4 x i32] } +%struct.array5 = type { [5 x i32] } +%struct.array6 = type { [6 x i32] } +%struct.array7 = type { [7 x i32] } +%struct.array8 = type { [8 x i32] } +%struct.array9 = type { [9 x i32] } +%struct.array10 = type { [10 x i32] } +%struct.array11 = type { [11 x i32] } +%struct.array12 = type { [12 x i32] } +%struct.array13 = type { [13 x i32] } +%struct.array14 = type { [14 x i32] } +%struct.array15 = type { [15 x i32] } +%struct.array16 = type { [16 x i32] } +%struct.array17 = type { [17 x i32] } +%struct.array18 = type { [18 x i32] } +%struct.array19 = type { [19 x i32] } +%struct.array20 = type { [20 x i32] } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo1(%struct.array1* noalias sret(%struct.array1) align 4 %0, %struct.array1* noundef byval(%struct.array1) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array1* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array1* %0 to i8* + %6 = bitcast %struct.array1* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 4, i1 false) + ret void +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo2(%struct.array2* noalias sret(%struct.array2) align 4 %0, %struct.array2* noundef byval(%struct.array2) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array2* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array2* %0 to i8* + %6 = bitcast %struct.array2* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo3(%struct.array3* noalias sret(%struct.array3) align 4 %0, %struct.array3* noundef byval(%struct.array3) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array3* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array3* %0 to i8* + %6 = bitcast %struct.array3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo4(%struct.array4* noalias sret(%struct.array4) align 4 %0, %struct.array4* noundef byval(%struct.array4) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array4* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array4* %0 to i8* + %6 = bitcast %struct.array4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 4 %0, %struct.array5* noundef byval(%struct.array5) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array5* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array5* %0 to i8* + %6 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 4 %0, %struct.array6* noundef byval(%struct.array6) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array6* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array6* %0 to i8* + %6 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 4 %0, %struct.array7* noundef byval(%struct.array7) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array7* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array7* %0 to i8* + %6 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 4 %0, %struct.array8* noundef byval(%struct.array8) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array8* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array8* %0 to i8* + %6 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 4 %0, %struct.array9* noundef byval(%struct.array9) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array9* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array9* %0 to i8* + %6 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 4 %0, %struct.array10* noundef byval(%struct.array10) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array10* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array10* %0 to i8* + %6 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 4 %0, %struct.array11* noundef byval(%struct.array11) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array11* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array11* %0 to i8* + %6 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 4 %0, %struct.array12* noundef byval(%struct.array12) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array12* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array12* %0 to i8* + %6 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 4 %0, %struct.array13* noundef byval(%struct.array13) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array13* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array13* %0 to i8* + %6 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 4 %0, %struct.array14* noundef byval(%struct.array14) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array14* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array14* %0 to i8* + %6 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 4 %0, %struct.array15* noundef byval(%struct.array15) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array15* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array15* %0 to i8* + %6 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 4 %0, %struct.array16* noundef byval(%struct.array16) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array16* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array16* %0 to i8* + %6 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 4 %0, %struct.array17* noundef byval(%struct.array17) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array17* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array17* %0 to i8* + %6 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 4 %0, %struct.array18* noundef byval(%struct.array18) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array18* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array18* %0 to i8* + %6 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 4 %0, %struct.array19* noundef byval(%struct.array19) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array19* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array19* %0 to i8* + %6 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 4 %0, %struct.array20* noundef byval(%struct.array20) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array20* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array20* %0 to i8* + %6 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5} +!llvm.ident = !{!6} + +!0 = !{i32 1, !"NumRegisterParameters", i32 0} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 7, !"PIC Level", i32 2} +!3 = !{i32 7, !"PIE Level", i32 2} +!4 = !{i32 7, !"uwtable", i32 2} +!5 = !{i32 7, !"frame-pointer", i32 2} +!6 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/i386/array_int64.ll b/internal/cabi/_testdata/arch/i386/array_int64.ll new file mode 100644 index 00000000..f21ba43c --- /dev/null +++ b/internal/cabi/_testdata/arch/i386/array_int64.ll @@ -0,0 +1,262 @@ +; ModuleID = '../../wrap/array_int64.c' +source_filename = "../../wrap/array_int64.c" +target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128" +target triple = "i386-unknown-linux-gnu" + +%struct.array1 = type { [1 x i64] } +%struct.array2 = type { [2 x i64] } +%struct.array3 = type { [3 x i64] } +%struct.array4 = type { [4 x i64] } +%struct.array5 = type { [5 x i64] } +%struct.array6 = type { [6 x i64] } +%struct.array7 = type { [7 x i64] } +%struct.array8 = type { [8 x i64] } +%struct.array9 = type { [9 x i64] } +%struct.array10 = type { [10 x i64] } +%struct.array11 = type { [11 x i64] } +%struct.array12 = type { [12 x i64] } +%struct.array13 = type { [13 x i64] } +%struct.array14 = type { [14 x i64] } +%struct.array15 = type { [15 x i64] } +%struct.array16 = type { [16 x i64] } +%struct.array17 = type { [17 x i64] } +%struct.array18 = type { [18 x i64] } +%struct.array19 = type { [19 x i64] } +%struct.array20 = type { [20 x i64] } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo1(%struct.array1* noalias sret(%struct.array1) align 4 %0, %struct.array1* noundef byval(%struct.array1) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array1* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array1* %0 to i8* + %6 = bitcast %struct.array1* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 8, i1 false) + ret void +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo2(%struct.array2* noalias sret(%struct.array2) align 4 %0, %struct.array2* noundef byval(%struct.array2) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array2* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array2* %0 to i8* + %6 = bitcast %struct.array2* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo3(%struct.array3* noalias sret(%struct.array3) align 4 %0, %struct.array3* noundef byval(%struct.array3) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array3* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array3* %0 to i8* + %6 = bitcast %struct.array3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo4(%struct.array4* noalias sret(%struct.array4) align 4 %0, %struct.array4* noundef byval(%struct.array4) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array4* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array4* %0 to i8* + %6 = bitcast %struct.array4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 4 %0, %struct.array5* noundef byval(%struct.array5) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array5* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array5* %0 to i8* + %6 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 4 %0, %struct.array6* noundef byval(%struct.array6) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array6* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array6* %0 to i8* + %6 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 4 %0, %struct.array7* noundef byval(%struct.array7) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array7* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array7* %0 to i8* + %6 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 4 %0, %struct.array8* noundef byval(%struct.array8) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array8* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array8* %0 to i8* + %6 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 4 %0, %struct.array9* noundef byval(%struct.array9) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array9* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array9* %0 to i8* + %6 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 4 %0, %struct.array10* noundef byval(%struct.array10) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array10* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array10* %0 to i8* + %6 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 4 %0, %struct.array11* noundef byval(%struct.array11) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array11* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array11* %0 to i8* + %6 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 4 %0, %struct.array12* noundef byval(%struct.array12) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array12* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array12* %0 to i8* + %6 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 4 %0, %struct.array13* noundef byval(%struct.array13) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array13* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array13* %0 to i8* + %6 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 4 %0, %struct.array14* noundef byval(%struct.array14) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array14* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array14* %0 to i8* + %6 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 4 %0, %struct.array15* noundef byval(%struct.array15) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array15* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array15* %0 to i8* + %6 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 4 %0, %struct.array16* noundef byval(%struct.array16) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array16* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array16* %0 to i8* + %6 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 4 %0, %struct.array17* noundef byval(%struct.array17) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array17* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array17* %0 to i8* + %6 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 4 %0, %struct.array18* noundef byval(%struct.array18) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array18* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array18* %0 to i8* + %6 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 4 %0, %struct.array19* noundef byval(%struct.array19) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array19* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array19* %0 to i8* + %6 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 4 %0, %struct.array20* noundef byval(%struct.array20) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array20* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array20* %0 to i8* + %6 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5} +!llvm.ident = !{!6} + +!0 = !{i32 1, !"NumRegisterParameters", i32 0} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 7, !"PIC Level", i32 2} +!3 = !{i32 7, !"PIE Level", i32 2} +!4 = !{i32 7, !"uwtable", i32 2} +!5 = !{i32 7, !"frame-pointer", i32 2} +!6 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/i386/array_int8.ll b/internal/cabi/_testdata/arch/i386/array_int8.ll new file mode 100644 index 00000000..1912bab0 --- /dev/null +++ b/internal/cabi/_testdata/arch/i386/array_int8.ll @@ -0,0 +1,262 @@ +; ModuleID = '../../wrap/array_int8.c' +source_filename = "../../wrap/array_int8.c" +target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128" +target triple = "i386-unknown-linux-gnu" + +%struct.array1 = type { [1 x i8] } +%struct.array2 = type { [2 x i8] } +%struct.array3 = type { [3 x i8] } +%struct.array4 = type { [4 x i8] } +%struct.array5 = type { [5 x i8] } +%struct.array6 = type { [6 x i8] } +%struct.array7 = type { [7 x i8] } +%struct.array8 = type { [8 x i8] } +%struct.array9 = type { [9 x i8] } +%struct.array10 = type { [10 x i8] } +%struct.array11 = type { [11 x i8] } +%struct.array12 = type { [12 x i8] } +%struct.array13 = type { [13 x i8] } +%struct.array14 = type { [14 x i8] } +%struct.array15 = type { [15 x i8] } +%struct.array16 = type { [16 x i8] } +%struct.array17 = type { [17 x i8] } +%struct.array18 = type { [18 x i8] } +%struct.array19 = type { [19 x i8] } +%struct.array20 = type { [20 x i8] } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo1(%struct.array1* noalias sret(%struct.array1) align 1 %0, %struct.array1* noundef byval(%struct.array1) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array1* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array1* %0 to i8* + %6 = bitcast %struct.array1* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 1, i1 false) + ret void +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo2(%struct.array2* noalias sret(%struct.array2) align 1 %0, %struct.array2* noundef byval(%struct.array2) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array2* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array2* %0 to i8* + %6 = bitcast %struct.array2* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 2, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo3(%struct.array3* noalias sret(%struct.array3) align 1 %0, %struct.array3* noundef byval(%struct.array3) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array3* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array3* %0 to i8* + %6 = bitcast %struct.array3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 3, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo4(%struct.array4* noalias sret(%struct.array4) align 1 %0, %struct.array4* noundef byval(%struct.array4) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array4* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array4* %0 to i8* + %6 = bitcast %struct.array4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 4, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 1 %0, %struct.array5* noundef byval(%struct.array5) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array5* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array5* %0 to i8* + %6 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 5, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 1 %0, %struct.array6* noundef byval(%struct.array6) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array6* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array6* %0 to i8* + %6 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 6, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 1 %0, %struct.array7* noundef byval(%struct.array7) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array7* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array7* %0 to i8* + %6 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 7, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 1 %0, %struct.array8* noundef byval(%struct.array8) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array8* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array8* %0 to i8* + %6 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 1 %0, %struct.array9* noundef byval(%struct.array9) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array9* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array9* %0 to i8* + %6 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 9, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 1 %0, %struct.array10* noundef byval(%struct.array10) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array10* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array10* %0 to i8* + %6 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 10, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 1 %0, %struct.array11* noundef byval(%struct.array11) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array11* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array11* %0 to i8* + %6 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 11, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 1 %0, %struct.array12* noundef byval(%struct.array12) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array12* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array12* %0 to i8* + %6 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 1 %0, %struct.array13* noundef byval(%struct.array13) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array13* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array13* %0 to i8* + %6 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 13, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 1 %0, %struct.array14* noundef byval(%struct.array14) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array14* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array14* %0 to i8* + %6 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 14, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 1 %0, %struct.array15* noundef byval(%struct.array15) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array15* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array15* %0 to i8* + %6 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 15, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 1 %0, %struct.array16* noundef byval(%struct.array16) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array16* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array16* %0 to i8* + %6 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 1 %0, %struct.array17* noundef byval(%struct.array17) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array17* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array17* %0 to i8* + %6 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 17, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 1 %0, %struct.array18* noundef byval(%struct.array18) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array18* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array18* %0 to i8* + %6 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 18, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 1 %0, %struct.array19* noundef byval(%struct.array19) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array19* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array19* %0 to i8* + %6 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 19, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 1 %0, %struct.array20* noundef byval(%struct.array20) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array20* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array20* %0 to i8* + %6 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 20, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5} +!llvm.ident = !{!6} + +!0 = !{i32 1, !"NumRegisterParameters", i32 0} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 7, !"PIC Level", i32 2} +!3 = !{i32 7, !"PIE Level", i32 2} +!4 = !{i32 7, !"uwtable", i32 2} +!5 = !{i32 7, !"frame-pointer", i32 2} +!6 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/i386/array_pointer.ll b/internal/cabi/_testdata/arch/i386/array_pointer.ll new file mode 100644 index 00000000..6e396fd9 --- /dev/null +++ b/internal/cabi/_testdata/arch/i386/array_pointer.ll @@ -0,0 +1,262 @@ +; ModuleID = '../../wrap/array_pointer.c' +source_filename = "../../wrap/array_pointer.c" +target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128" +target triple = "i386-unknown-linux-gnu" + +%struct.array1 = type { [1 x i8*] } +%struct.array2 = type { [2 x i8*] } +%struct.array3 = type { [3 x i8*] } +%struct.array4 = type { [4 x i8*] } +%struct.array5 = type { [5 x i8*] } +%struct.array6 = type { [6 x i8*] } +%struct.array7 = type { [7 x i8*] } +%struct.array8 = type { [8 x i8*] } +%struct.array9 = type { [9 x i8*] } +%struct.array10 = type { [10 x i8*] } +%struct.array11 = type { [11 x i8*] } +%struct.array12 = type { [12 x i8*] } +%struct.array13 = type { [13 x i8*] } +%struct.array14 = type { [14 x i8*] } +%struct.array15 = type { [15 x i8*] } +%struct.array16 = type { [16 x i8*] } +%struct.array17 = type { [17 x i8*] } +%struct.array18 = type { [18 x i8*] } +%struct.array19 = type { [19 x i8*] } +%struct.array20 = type { [20 x i8*] } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo1(%struct.array1* noalias sret(%struct.array1) align 4 %0, %struct.array1* noundef byval(%struct.array1) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array1* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array1* %0 to i8* + %6 = bitcast %struct.array1* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 4, i1 false) + ret void +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo2(%struct.array2* noalias sret(%struct.array2) align 4 %0, %struct.array2* noundef byval(%struct.array2) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array2* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array2* %0 to i8* + %6 = bitcast %struct.array2* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo3(%struct.array3* noalias sret(%struct.array3) align 4 %0, %struct.array3* noundef byval(%struct.array3) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array3* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array3* %0 to i8* + %6 = bitcast %struct.array3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo4(%struct.array4* noalias sret(%struct.array4) align 4 %0, %struct.array4* noundef byval(%struct.array4) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array4* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array4* %0 to i8* + %6 = bitcast %struct.array4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 4 %0, %struct.array5* noundef byval(%struct.array5) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array5* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array5* %0 to i8* + %6 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 4 %0, %struct.array6* noundef byval(%struct.array6) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array6* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array6* %0 to i8* + %6 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 4 %0, %struct.array7* noundef byval(%struct.array7) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array7* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array7* %0 to i8* + %6 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 4 %0, %struct.array8* noundef byval(%struct.array8) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array8* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array8* %0 to i8* + %6 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 4 %0, %struct.array9* noundef byval(%struct.array9) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array9* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array9* %0 to i8* + %6 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 4 %0, %struct.array10* noundef byval(%struct.array10) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array10* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array10* %0 to i8* + %6 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 4 %0, %struct.array11* noundef byval(%struct.array11) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array11* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array11* %0 to i8* + %6 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 4 %0, %struct.array12* noundef byval(%struct.array12) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array12* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array12* %0 to i8* + %6 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 4 %0, %struct.array13* noundef byval(%struct.array13) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array13* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array13* %0 to i8* + %6 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 4 %0, %struct.array14* noundef byval(%struct.array14) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array14* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array14* %0 to i8* + %6 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 4 %0, %struct.array15* noundef byval(%struct.array15) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array15* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array15* %0 to i8* + %6 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 4 %0, %struct.array16* noundef byval(%struct.array16) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array16* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array16* %0 to i8* + %6 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 4 %0, %struct.array17* noundef byval(%struct.array17) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array17* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array17* %0 to i8* + %6 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 4 %0, %struct.array18* noundef byval(%struct.array18) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array18* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array18* %0 to i8* + %6 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 4 %0, %struct.array19* noundef byval(%struct.array19) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array19* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array19* %0 to i8* + %6 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 4 %0, %struct.array20* noundef byval(%struct.array20) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array20* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array20* %0 to i8* + %6 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5} +!llvm.ident = !{!6} + +!0 = !{i32 1, !"NumRegisterParameters", i32 0} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 7, !"PIC Level", i32 2} +!3 = !{i32 7, !"PIE Level", i32 2} +!4 = !{i32 7, !"uwtable", i32 2} +!5 = !{i32 7, !"frame-pointer", i32 2} +!6 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/i386/array_uintptr.ll b/internal/cabi/_testdata/arch/i386/array_uintptr.ll new file mode 100644 index 00000000..54b09786 --- /dev/null +++ b/internal/cabi/_testdata/arch/i386/array_uintptr.ll @@ -0,0 +1,262 @@ +; ModuleID = '../../wrap/array_uintptr.c' +source_filename = "../../wrap/array_uintptr.c" +target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128" +target triple = "i386-unknown-linux-gnu" + +%struct.array1 = type { [1 x i8*] } +%struct.array2 = type { [2 x i8*] } +%struct.array3 = type { [3 x i8*] } +%struct.array4 = type { [4 x i8*] } +%struct.array5 = type { [5 x i8*] } +%struct.array6 = type { [6 x i8*] } +%struct.array7 = type { [7 x i8*] } +%struct.array8 = type { [8 x i8*] } +%struct.array9 = type { [9 x i8*] } +%struct.array10 = type { [10 x i8*] } +%struct.array11 = type { [11 x i8*] } +%struct.array12 = type { [12 x i8*] } +%struct.array13 = type { [13 x i8*] } +%struct.array14 = type { [14 x i8*] } +%struct.array15 = type { [15 x i8*] } +%struct.array16 = type { [16 x i8*] } +%struct.array17 = type { [17 x i8*] } +%struct.array18 = type { [18 x i8*] } +%struct.array19 = type { [19 x i8*] } +%struct.array20 = type { [20 x i8*] } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo1(%struct.array1* noalias sret(%struct.array1) align 4 %0, %struct.array1* noundef byval(%struct.array1) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array1* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array1* %0 to i8* + %6 = bitcast %struct.array1* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 4, i1 false) + ret void +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo2(%struct.array2* noalias sret(%struct.array2) align 4 %0, %struct.array2* noundef byval(%struct.array2) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array2* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array2* %0 to i8* + %6 = bitcast %struct.array2* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo3(%struct.array3* noalias sret(%struct.array3) align 4 %0, %struct.array3* noundef byval(%struct.array3) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array3* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array3* %0 to i8* + %6 = bitcast %struct.array3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo4(%struct.array4* noalias sret(%struct.array4) align 4 %0, %struct.array4* noundef byval(%struct.array4) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array4* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array4* %0 to i8* + %6 = bitcast %struct.array4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 4 %0, %struct.array5* noundef byval(%struct.array5) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array5* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array5* %0 to i8* + %6 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 4 %0, %struct.array6* noundef byval(%struct.array6) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array6* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array6* %0 to i8* + %6 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 4 %0, %struct.array7* noundef byval(%struct.array7) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array7* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array7* %0 to i8* + %6 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 4 %0, %struct.array8* noundef byval(%struct.array8) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array8* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array8* %0 to i8* + %6 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 4 %0, %struct.array9* noundef byval(%struct.array9) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array9* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array9* %0 to i8* + %6 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 4 %0, %struct.array10* noundef byval(%struct.array10) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array10* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array10* %0 to i8* + %6 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 4 %0, %struct.array11* noundef byval(%struct.array11) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array11* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array11* %0 to i8* + %6 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 4 %0, %struct.array12* noundef byval(%struct.array12) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array12* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array12* %0 to i8* + %6 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 4 %0, %struct.array13* noundef byval(%struct.array13) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array13* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array13* %0 to i8* + %6 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 4 %0, %struct.array14* noundef byval(%struct.array14) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array14* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array14* %0 to i8* + %6 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 4 %0, %struct.array15* noundef byval(%struct.array15) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array15* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array15* %0 to i8* + %6 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 4 %0, %struct.array16* noundef byval(%struct.array16) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array16* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array16* %0 to i8* + %6 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 4 %0, %struct.array17* noundef byval(%struct.array17) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array17* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array17* %0 to i8* + %6 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 4 %0, %struct.array18* noundef byval(%struct.array18) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array18* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array18* %0 to i8* + %6 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 4 %0, %struct.array19* noundef byval(%struct.array19) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array19* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array19* %0 to i8* + %6 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 4 %0, %struct.array20* noundef byval(%struct.array20) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.array20* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.array20* %0 to i8* + %6 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5} +!llvm.ident = !{!6} + +!0 = !{i32 1, !"NumRegisterParameters", i32 0} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 7, !"PIC Level", i32 2} +!3 = !{i32 7, !"PIE Level", i32 2} +!4 = !{i32 7, !"uwtable", i32 2} +!5 = !{i32 7, !"frame-pointer", i32 2} +!6 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/i386/basic.ll b/internal/cabi/_testdata/arch/i386/basic.ll new file mode 100644 index 00000000..d3828d0d --- /dev/null +++ b/internal/cabi/_testdata/arch/i386/basic.ll @@ -0,0 +1,73 @@ +; ModuleID = '../../wrap/basic.c' +source_filename = "../../wrap/basic.c" +target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128" +target triple = "i386-unknown-linux-gnu" + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local signext i8 @basic_int8(i8 noundef signext %0) #0 { + %2 = alloca i8, align 1 + store i8 %0, i8* %2, align 1 + %3 = load i8, i8* %2, align 1 + ret i8 %3 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local signext i16 @basic_int16(i16 noundef signext %0) #0 { + %2 = alloca i16, align 2 + store i16 %0, i16* %2, align 2 + %3 = load i16, i16* %2, align 2 + ret i16 %3 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i32 @basic_int32(i32 noundef %0) #0 { + %2 = alloca i32, align 4 + store i32 %0, i32* %2, align 4 + %3 = load i32, i32* %2, align 4 + ret i32 %3 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i64 @basic_int64(i64 noundef %0) #0 { + %2 = alloca i64, align 8 + store i64 %0, i64* %2, align 8 + %3 = load i64, i64* %2, align 8 + ret i64 %3 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local float @basic_float32(float noundef %0) #0 { + %2 = alloca float, align 4 + store float %0, float* %2, align 4 + %3 = load float, float* %2, align 4 + ret float %3 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local double @basic_float64(double noundef %0) #0 { + %2 = alloca double, align 8 + store double %0, double* %2, align 8 + %3 = load double, double* %2, align 8 + ret double %3 +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i8* @basic_uintptr(i8* noundef %0) #0 { + %2 = alloca i8*, align 4 + store i8* %0, i8** %2, align 4 + %3 = load i8*, i8** %2, align 4 + ret i8* %3 +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5} +!llvm.ident = !{!6} + +!0 = !{i32 1, !"NumRegisterParameters", i32 0} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 7, !"PIC Level", i32 2} +!3 = !{i32 7, !"PIE Level", i32 2} +!4 = !{i32 7, !"uwtable", i32 2} +!5 = !{i32 7, !"frame-pointer", i32 2} +!6 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/i386/struct_float32.ll b/internal/cabi/_testdata/arch/i386/struct_float32.ll new file mode 100644 index 00000000..96127c03 --- /dev/null +++ b/internal/cabi/_testdata/arch/i386/struct_float32.ll @@ -0,0 +1,286 @@ +; ModuleID = '../../wrap/struct_float32.c' +source_filename = "../../wrap/struct_float32.c" +target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128" +target triple = "i386-unknown-linux-gnu" + +%struct.point1 = type { float } +%struct.point2 = type { float, float } +%struct.point3 = type { float, float, float } +%struct.point4 = type { float, float, float, float } +%struct.point5 = type { float, float, float, float, float } +%struct.point6 = type { float, float, float, float, float, float } +%struct.point7 = type { float, float, float, float, float, float, float } +%struct.point8 = type { float, float, float, float, float, float, float, float } +%struct.point9 = type { float, float, float, float, float, float, float, float, float } +%struct.point10 = type { float, float, float, float, float, float, float, float, float, float } +%struct.point11 = type { float, float, float, float, float, float, float, float, float, float, float } +%struct.point12 = type { float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point13 = type { float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point14 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point15 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point16 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point17 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point18 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point19 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point20 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo1(%struct.point1* noalias sret(%struct.point1) align 4 %0, float %1) #0 { + %3 = alloca i8*, align 4 + %4 = alloca %struct.point1, align 4 + %5 = bitcast %struct.point1* %0 to i8* + store i8* %5, i8** %3, align 4 + %6 = getelementptr inbounds %struct.point1, %struct.point1* %4, i32 0, i32 0 + store float %1, float* %6, align 4 + %7 = bitcast %struct.point1* %0 to i8* + %8 = bitcast %struct.point1* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %7, i8* align 4 %8, i32 4, i1 false) + ret void +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo2(%struct.point2* noalias sret(%struct.point2) align 4 %0, float %1, float %2) #0 { + %4 = alloca i8*, align 4 + %5 = alloca %struct.point2, align 4 + %6 = bitcast %struct.point2* %0 to i8* + store i8* %6, i8** %4, align 4 + %7 = getelementptr inbounds %struct.point2, %struct.point2* %5, i32 0, i32 0 + store float %1, float* %7, align 4 + %8 = getelementptr inbounds %struct.point2, %struct.point2* %5, i32 0, i32 1 + store float %2, float* %8, align 4 + %9 = bitcast %struct.point2* %0 to i8* + %10 = bitcast %struct.point2* %5 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %9, i8* align 4 %10, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo3(%struct.point3* noalias sret(%struct.point3) align 4 %0, float %1, float %2, float %3) #0 { + %5 = alloca i8*, align 4 + %6 = alloca %struct.point3, align 4 + %7 = bitcast %struct.point3* %0 to i8* + store i8* %7, i8** %5, align 4 + %8 = getelementptr inbounds %struct.point3, %struct.point3* %6, i32 0, i32 0 + store float %1, float* %8, align 4 + %9 = getelementptr inbounds %struct.point3, %struct.point3* %6, i32 0, i32 1 + store float %2, float* %9, align 4 + %10 = getelementptr inbounds %struct.point3, %struct.point3* %6, i32 0, i32 2 + store float %3, float* %10, align 4 + %11 = bitcast %struct.point3* %0 to i8* + %12 = bitcast %struct.point3* %6 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %11, i8* align 4 %12, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo4(%struct.point4* noalias sret(%struct.point4) align 4 %0, float %1, float %2, float %3, float %4) #0 { + %6 = alloca i8*, align 4 + %7 = alloca %struct.point4, align 4 + %8 = bitcast %struct.point4* %0 to i8* + store i8* %8, i8** %6, align 4 + %9 = getelementptr inbounds %struct.point4, %struct.point4* %7, i32 0, i32 0 + store float %1, float* %9, align 4 + %10 = getelementptr inbounds %struct.point4, %struct.point4* %7, i32 0, i32 1 + store float %2, float* %10, align 4 + %11 = getelementptr inbounds %struct.point4, %struct.point4* %7, i32 0, i32 2 + store float %3, float* %11, align 4 + %12 = getelementptr inbounds %struct.point4, %struct.point4* %7, i32 0, i32 3 + store float %4, float* %12, align 4 + %13 = bitcast %struct.point4* %0 to i8* + %14 = bitcast %struct.point4* %7 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %13, i8* align 4 %14, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.point5* noalias sret(%struct.point5) align 4 %0, %struct.point5* noundef byval(%struct.point5) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point5* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point5* %0 to i8* + %6 = bitcast %struct.point5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.point6* noalias sret(%struct.point6) align 4 %0, %struct.point6* noundef byval(%struct.point6) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point6* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point6* %0 to i8* + %6 = bitcast %struct.point6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.point7* noalias sret(%struct.point7) align 4 %0, %struct.point7* noundef byval(%struct.point7) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point7* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point7* %0 to i8* + %6 = bitcast %struct.point7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.point8* noalias sret(%struct.point8) align 4 %0, %struct.point8* noundef byval(%struct.point8) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point8* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point8* %0 to i8* + %6 = bitcast %struct.point8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 4 %0, %struct.point9* noundef byval(%struct.point9) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point9* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point9* %0 to i8* + %6 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 4 %0, %struct.point10* noundef byval(%struct.point10) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point10* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point10* %0 to i8* + %6 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 4 %0, %struct.point11* noundef byval(%struct.point11) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point11* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point11* %0 to i8* + %6 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 4 %0, %struct.point12* noundef byval(%struct.point12) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point12* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point12* %0 to i8* + %6 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 4 %0, %struct.point13* noundef byval(%struct.point13) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point13* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point13* %0 to i8* + %6 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 4 %0, %struct.point14* noundef byval(%struct.point14) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point14* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point14* %0 to i8* + %6 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 4 %0, %struct.point15* noundef byval(%struct.point15) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point15* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point15* %0 to i8* + %6 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 4 %0, %struct.point16* noundef byval(%struct.point16) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point16* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point16* %0 to i8* + %6 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 4 %0, %struct.point17* noundef byval(%struct.point17) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point17* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point17* %0 to i8* + %6 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 4 %0, %struct.point18* noundef byval(%struct.point18) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point18* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point18* %0 to i8* + %6 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 4 %0, %struct.point19* noundef byval(%struct.point19) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point19* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point19* %0 to i8* + %6 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 4 %0, %struct.point20* noundef byval(%struct.point20) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point20* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point20* %0 to i8* + %6 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5} +!llvm.ident = !{!6} + +!0 = !{i32 1, !"NumRegisterParameters", i32 0} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 7, !"PIC Level", i32 2} +!3 = !{i32 7, !"PIE Level", i32 2} +!4 = !{i32 7, !"uwtable", i32 2} +!5 = !{i32 7, !"frame-pointer", i32 2} +!6 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/i386/struct_float64.ll b/internal/cabi/_testdata/arch/i386/struct_float64.ll new file mode 100644 index 00000000..0173395b --- /dev/null +++ b/internal/cabi/_testdata/arch/i386/struct_float64.ll @@ -0,0 +1,270 @@ +; ModuleID = '../../wrap/struct_float64.c' +source_filename = "../../wrap/struct_float64.c" +target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128" +target triple = "i386-unknown-linux-gnu" + +%struct.point1 = type { double } +%struct.point2 = type { double, double } +%struct.point3 = type { double, double, double } +%struct.point4 = type { double, double, double, double } +%struct.point5 = type { double, double, double, double, double } +%struct.point6 = type { double, double, double, double, double, double } +%struct.point7 = type { double, double, double, double, double, double, double } +%struct.point8 = type { double, double, double, double, double, double, double, double } +%struct.point9 = type { double, double, double, double, double, double, double, double, double } +%struct.point10 = type { double, double, double, double, double, double, double, double, double, double } +%struct.point11 = type { double, double, double, double, double, double, double, double, double, double, double } +%struct.point12 = type { double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point13 = type { double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point14 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point15 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point16 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point17 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point18 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point19 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point20 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo1(%struct.point1* noalias sret(%struct.point1) align 4 %0, double %1) #0 { + %3 = alloca i8*, align 4 + %4 = alloca %struct.point1, align 4 + %5 = bitcast %struct.point1* %0 to i8* + store i8* %5, i8** %3, align 4 + %6 = getelementptr inbounds %struct.point1, %struct.point1* %4, i32 0, i32 0 + store double %1, double* %6, align 4 + %7 = bitcast %struct.point1* %0 to i8* + %8 = bitcast %struct.point1* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %7, i8* align 4 %8, i32 8, i1 false) + ret void +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo2(%struct.point2* noalias sret(%struct.point2) align 4 %0, double %1, double %2) #0 { + %4 = alloca i8*, align 4 + %5 = alloca %struct.point2, align 4 + %6 = bitcast %struct.point2* %0 to i8* + store i8* %6, i8** %4, align 4 + %7 = getelementptr inbounds %struct.point2, %struct.point2* %5, i32 0, i32 0 + store double %1, double* %7, align 4 + %8 = getelementptr inbounds %struct.point2, %struct.point2* %5, i32 0, i32 1 + store double %2, double* %8, align 4 + %9 = bitcast %struct.point2* %0 to i8* + %10 = bitcast %struct.point2* %5 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %9, i8* align 4 %10, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo3(%struct.point3* noalias sret(%struct.point3) align 4 %0, %struct.point3* noundef byval(%struct.point3) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point3* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point3* %0 to i8* + %6 = bitcast %struct.point3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo4(%struct.point4* noalias sret(%struct.point4) align 4 %0, %struct.point4* noundef byval(%struct.point4) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point4* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point4* %0 to i8* + %6 = bitcast %struct.point4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.point5* noalias sret(%struct.point5) align 4 %0, %struct.point5* noundef byval(%struct.point5) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point5* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point5* %0 to i8* + %6 = bitcast %struct.point5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.point6* noalias sret(%struct.point6) align 4 %0, %struct.point6* noundef byval(%struct.point6) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point6* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point6* %0 to i8* + %6 = bitcast %struct.point6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.point7* noalias sret(%struct.point7) align 4 %0, %struct.point7* noundef byval(%struct.point7) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point7* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point7* %0 to i8* + %6 = bitcast %struct.point7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.point8* noalias sret(%struct.point8) align 4 %0, %struct.point8* noundef byval(%struct.point8) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point8* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point8* %0 to i8* + %6 = bitcast %struct.point8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 4 %0, %struct.point9* noundef byval(%struct.point9) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point9* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point9* %0 to i8* + %6 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 4 %0, %struct.point10* noundef byval(%struct.point10) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point10* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point10* %0 to i8* + %6 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 4 %0, %struct.point11* noundef byval(%struct.point11) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point11* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point11* %0 to i8* + %6 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 4 %0, %struct.point12* noundef byval(%struct.point12) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point12* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point12* %0 to i8* + %6 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 4 %0, %struct.point13* noundef byval(%struct.point13) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point13* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point13* %0 to i8* + %6 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 4 %0, %struct.point14* noundef byval(%struct.point14) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point14* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point14* %0 to i8* + %6 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 4 %0, %struct.point15* noundef byval(%struct.point15) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point15* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point15* %0 to i8* + %6 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 4 %0, %struct.point16* noundef byval(%struct.point16) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point16* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point16* %0 to i8* + %6 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 4 %0, %struct.point17* noundef byval(%struct.point17) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point17* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point17* %0 to i8* + %6 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 4 %0, %struct.point18* noundef byval(%struct.point18) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point18* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point18* %0 to i8* + %6 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 4 %0, %struct.point19* noundef byval(%struct.point19) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point19* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point19* %0 to i8* + %6 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 4 %0, %struct.point20* noundef byval(%struct.point20) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point20* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point20* %0 to i8* + %6 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5} +!llvm.ident = !{!6} + +!0 = !{i32 1, !"NumRegisterParameters", i32 0} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 7, !"PIC Level", i32 2} +!3 = !{i32 7, !"PIE Level", i32 2} +!4 = !{i32 7, !"uwtable", i32 2} +!5 = !{i32 7, !"frame-pointer", i32 2} +!6 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/i386/struct_int16.ll b/internal/cabi/_testdata/arch/i386/struct_int16.ll new file mode 100644 index 00000000..9dc9dc02 --- /dev/null +++ b/internal/cabi/_testdata/arch/i386/struct_int16.ll @@ -0,0 +1,262 @@ +; ModuleID = '../../wrap/struct_int16.c' +source_filename = "../../wrap/struct_int16.c" +target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128" +target triple = "i386-unknown-linux-gnu" + +%struct.point1 = type { i16 } +%struct.point2 = type { i16, i16 } +%struct.point3 = type { i16, i16, i16 } +%struct.point4 = type { i16, i16, i16, i16 } +%struct.point5 = type { i16, i16, i16, i16, i16 } +%struct.point6 = type { i16, i16, i16, i16, i16, i16 } +%struct.point7 = type { i16, i16, i16, i16, i16, i16, i16 } +%struct.point8 = type { i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point9 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point10 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point11 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point12 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point13 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point14 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point15 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point16 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point17 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point18 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point19 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point20 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo1(%struct.point1* noalias sret(%struct.point1) align 2 %0, %struct.point1* noundef byval(%struct.point1) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point1* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point1* %0 to i8* + %6 = bitcast %struct.point1* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 2, i1 false) + ret void +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo2(%struct.point2* noalias sret(%struct.point2) align 2 %0, %struct.point2* noundef byval(%struct.point2) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point2* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point2* %0 to i8* + %6 = bitcast %struct.point2* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 4, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo3(%struct.point3* noalias sret(%struct.point3) align 2 %0, %struct.point3* noundef byval(%struct.point3) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point3* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point3* %0 to i8* + %6 = bitcast %struct.point3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 6, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo4(%struct.point4* noalias sret(%struct.point4) align 2 %0, %struct.point4* noundef byval(%struct.point4) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point4* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point4* %0 to i8* + %6 = bitcast %struct.point4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.point5* noalias sret(%struct.point5) align 2 %0, %struct.point5* noundef byval(%struct.point5) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point5* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point5* %0 to i8* + %6 = bitcast %struct.point5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 10, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.point6* noalias sret(%struct.point6) align 2 %0, %struct.point6* noundef byval(%struct.point6) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point6* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point6* %0 to i8* + %6 = bitcast %struct.point6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.point7* noalias sret(%struct.point7) align 2 %0, %struct.point7* noundef byval(%struct.point7) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point7* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point7* %0 to i8* + %6 = bitcast %struct.point7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 14, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.point8* noalias sret(%struct.point8) align 2 %0, %struct.point8* noundef byval(%struct.point8) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point8* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point8* %0 to i8* + %6 = bitcast %struct.point8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 2 %0, %struct.point9* noundef byval(%struct.point9) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point9* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point9* %0 to i8* + %6 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 18, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 2 %0, %struct.point10* noundef byval(%struct.point10) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point10* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point10* %0 to i8* + %6 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 2 %0, %struct.point11* noundef byval(%struct.point11) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point11* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point11* %0 to i8* + %6 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 22, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 2 %0, %struct.point12* noundef byval(%struct.point12) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point12* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point12* %0 to i8* + %6 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 2 %0, %struct.point13* noundef byval(%struct.point13) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point13* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point13* %0 to i8* + %6 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 26, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 2 %0, %struct.point14* noundef byval(%struct.point14) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point14* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point14* %0 to i8* + %6 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 2 %0, %struct.point15* noundef byval(%struct.point15) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point15* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point15* %0 to i8* + %6 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 30, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 2 %0, %struct.point16* noundef byval(%struct.point16) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point16* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point16* %0 to i8* + %6 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 2 %0, %struct.point17* noundef byval(%struct.point17) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point17* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point17* %0 to i8* + %6 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 34, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 2 %0, %struct.point18* noundef byval(%struct.point18) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point18* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point18* %0 to i8* + %6 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 2 %0, %struct.point19* noundef byval(%struct.point19) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point19* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point19* %0 to i8* + %6 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 38, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 2 %0, %struct.point20* noundef byval(%struct.point20) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point20* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point20* %0 to i8* + %6 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 4 %6, i32 40, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5} +!llvm.ident = !{!6} + +!0 = !{i32 1, !"NumRegisterParameters", i32 0} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 7, !"PIC Level", i32 2} +!3 = !{i32 7, !"PIE Level", i32 2} +!4 = !{i32 7, !"uwtable", i32 2} +!5 = !{i32 7, !"frame-pointer", i32 2} +!6 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/i386/struct_int32.ll b/internal/cabi/_testdata/arch/i386/struct_int32.ll new file mode 100644 index 00000000..d9d3ebbc --- /dev/null +++ b/internal/cabi/_testdata/arch/i386/struct_int32.ll @@ -0,0 +1,286 @@ +; ModuleID = '../../wrap/struct_int32.c' +source_filename = "../../wrap/struct_int32.c" +target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128" +target triple = "i386-unknown-linux-gnu" + +%struct.point1 = type { i32 } +%struct.point2 = type { i32, i32 } +%struct.point3 = type { i32, i32, i32 } +%struct.point4 = type { i32, i32, i32, i32 } +%struct.point5 = type { i32, i32, i32, i32, i32 } +%struct.point6 = type { i32, i32, i32, i32, i32, i32 } +%struct.point7 = type { i32, i32, i32, i32, i32, i32, i32 } +%struct.point8 = type { i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point9 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point10 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point11 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point12 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point13 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point14 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point15 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point16 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point17 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point18 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point19 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point20 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo1(%struct.point1* noalias sret(%struct.point1) align 4 %0, i32 %1) #0 { + %3 = alloca i8*, align 4 + %4 = alloca %struct.point1, align 4 + %5 = bitcast %struct.point1* %0 to i8* + store i8* %5, i8** %3, align 4 + %6 = getelementptr inbounds %struct.point1, %struct.point1* %4, i32 0, i32 0 + store i32 %1, i32* %6, align 4 + %7 = bitcast %struct.point1* %0 to i8* + %8 = bitcast %struct.point1* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %7, i8* align 4 %8, i32 4, i1 false) + ret void +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo2(%struct.point2* noalias sret(%struct.point2) align 4 %0, i32 %1, i32 %2) #0 { + %4 = alloca i8*, align 4 + %5 = alloca %struct.point2, align 4 + %6 = bitcast %struct.point2* %0 to i8* + store i8* %6, i8** %4, align 4 + %7 = getelementptr inbounds %struct.point2, %struct.point2* %5, i32 0, i32 0 + store i32 %1, i32* %7, align 4 + %8 = getelementptr inbounds %struct.point2, %struct.point2* %5, i32 0, i32 1 + store i32 %2, i32* %8, align 4 + %9 = bitcast %struct.point2* %0 to i8* + %10 = bitcast %struct.point2* %5 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %9, i8* align 4 %10, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo3(%struct.point3* noalias sret(%struct.point3) align 4 %0, i32 %1, i32 %2, i32 %3) #0 { + %5 = alloca i8*, align 4 + %6 = alloca %struct.point3, align 4 + %7 = bitcast %struct.point3* %0 to i8* + store i8* %7, i8** %5, align 4 + %8 = getelementptr inbounds %struct.point3, %struct.point3* %6, i32 0, i32 0 + store i32 %1, i32* %8, align 4 + %9 = getelementptr inbounds %struct.point3, %struct.point3* %6, i32 0, i32 1 + store i32 %2, i32* %9, align 4 + %10 = getelementptr inbounds %struct.point3, %struct.point3* %6, i32 0, i32 2 + store i32 %3, i32* %10, align 4 + %11 = bitcast %struct.point3* %0 to i8* + %12 = bitcast %struct.point3* %6 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %11, i8* align 4 %12, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo4(%struct.point4* noalias sret(%struct.point4) align 4 %0, i32 %1, i32 %2, i32 %3, i32 %4) #0 { + %6 = alloca i8*, align 4 + %7 = alloca %struct.point4, align 4 + %8 = bitcast %struct.point4* %0 to i8* + store i8* %8, i8** %6, align 4 + %9 = getelementptr inbounds %struct.point4, %struct.point4* %7, i32 0, i32 0 + store i32 %1, i32* %9, align 4 + %10 = getelementptr inbounds %struct.point4, %struct.point4* %7, i32 0, i32 1 + store i32 %2, i32* %10, align 4 + %11 = getelementptr inbounds %struct.point4, %struct.point4* %7, i32 0, i32 2 + store i32 %3, i32* %11, align 4 + %12 = getelementptr inbounds %struct.point4, %struct.point4* %7, i32 0, i32 3 + store i32 %4, i32* %12, align 4 + %13 = bitcast %struct.point4* %0 to i8* + %14 = bitcast %struct.point4* %7 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %13, i8* align 4 %14, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.point5* noalias sret(%struct.point5) align 4 %0, %struct.point5* noundef byval(%struct.point5) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point5* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point5* %0 to i8* + %6 = bitcast %struct.point5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.point6* noalias sret(%struct.point6) align 4 %0, %struct.point6* noundef byval(%struct.point6) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point6* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point6* %0 to i8* + %6 = bitcast %struct.point6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.point7* noalias sret(%struct.point7) align 4 %0, %struct.point7* noundef byval(%struct.point7) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point7* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point7* %0 to i8* + %6 = bitcast %struct.point7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.point8* noalias sret(%struct.point8) align 4 %0, %struct.point8* noundef byval(%struct.point8) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point8* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point8* %0 to i8* + %6 = bitcast %struct.point8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 4 %0, %struct.point9* noundef byval(%struct.point9) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point9* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point9* %0 to i8* + %6 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 4 %0, %struct.point10* noundef byval(%struct.point10) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point10* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point10* %0 to i8* + %6 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 4 %0, %struct.point11* noundef byval(%struct.point11) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point11* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point11* %0 to i8* + %6 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 4 %0, %struct.point12* noundef byval(%struct.point12) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point12* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point12* %0 to i8* + %6 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 4 %0, %struct.point13* noundef byval(%struct.point13) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point13* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point13* %0 to i8* + %6 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 4 %0, %struct.point14* noundef byval(%struct.point14) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point14* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point14* %0 to i8* + %6 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 4 %0, %struct.point15* noundef byval(%struct.point15) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point15* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point15* %0 to i8* + %6 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 4 %0, %struct.point16* noundef byval(%struct.point16) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point16* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point16* %0 to i8* + %6 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 4 %0, %struct.point17* noundef byval(%struct.point17) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point17* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point17* %0 to i8* + %6 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 4 %0, %struct.point18* noundef byval(%struct.point18) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point18* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point18* %0 to i8* + %6 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 4 %0, %struct.point19* noundef byval(%struct.point19) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point19* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point19* %0 to i8* + %6 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 4 %0, %struct.point20* noundef byval(%struct.point20) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point20* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point20* %0 to i8* + %6 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5} +!llvm.ident = !{!6} + +!0 = !{i32 1, !"NumRegisterParameters", i32 0} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 7, !"PIC Level", i32 2} +!3 = !{i32 7, !"PIE Level", i32 2} +!4 = !{i32 7, !"uwtable", i32 2} +!5 = !{i32 7, !"frame-pointer", i32 2} +!6 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/i386/struct_int64.ll b/internal/cabi/_testdata/arch/i386/struct_int64.ll new file mode 100644 index 00000000..6232cf2f --- /dev/null +++ b/internal/cabi/_testdata/arch/i386/struct_int64.ll @@ -0,0 +1,270 @@ +; ModuleID = '../../wrap/struct_int64.c' +source_filename = "../../wrap/struct_int64.c" +target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128" +target triple = "i386-unknown-linux-gnu" + +%struct.point1 = type { i64 } +%struct.point2 = type { i64, i64 } +%struct.point3 = type { i64, i64, i64 } +%struct.point4 = type { i64, i64, i64, i64 } +%struct.point5 = type { i64, i64, i64, i64, i64 } +%struct.point6 = type { i64, i64, i64, i64, i64, i64 } +%struct.point7 = type { i64, i64, i64, i64, i64, i64, i64 } +%struct.point8 = type { i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point9 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point10 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point11 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point12 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point13 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point14 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point15 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point16 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point17 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point18 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point19 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point20 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo1(%struct.point1* noalias sret(%struct.point1) align 4 %0, i64 %1) #0 { + %3 = alloca i8*, align 4 + %4 = alloca %struct.point1, align 4 + %5 = bitcast %struct.point1* %0 to i8* + store i8* %5, i8** %3, align 4 + %6 = getelementptr inbounds %struct.point1, %struct.point1* %4, i32 0, i32 0 + store i64 %1, i64* %6, align 4 + %7 = bitcast %struct.point1* %0 to i8* + %8 = bitcast %struct.point1* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %7, i8* align 4 %8, i32 8, i1 false) + ret void +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo2(%struct.point2* noalias sret(%struct.point2) align 4 %0, i64 %1, i64 %2) #0 { + %4 = alloca i8*, align 4 + %5 = alloca %struct.point2, align 4 + %6 = bitcast %struct.point2* %0 to i8* + store i8* %6, i8** %4, align 4 + %7 = getelementptr inbounds %struct.point2, %struct.point2* %5, i32 0, i32 0 + store i64 %1, i64* %7, align 4 + %8 = getelementptr inbounds %struct.point2, %struct.point2* %5, i32 0, i32 1 + store i64 %2, i64* %8, align 4 + %9 = bitcast %struct.point2* %0 to i8* + %10 = bitcast %struct.point2* %5 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %9, i8* align 4 %10, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo3(%struct.point3* noalias sret(%struct.point3) align 4 %0, %struct.point3* noundef byval(%struct.point3) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point3* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point3* %0 to i8* + %6 = bitcast %struct.point3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo4(%struct.point4* noalias sret(%struct.point4) align 4 %0, %struct.point4* noundef byval(%struct.point4) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point4* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point4* %0 to i8* + %6 = bitcast %struct.point4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.point5* noalias sret(%struct.point5) align 4 %0, %struct.point5* noundef byval(%struct.point5) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point5* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point5* %0 to i8* + %6 = bitcast %struct.point5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.point6* noalias sret(%struct.point6) align 4 %0, %struct.point6* noundef byval(%struct.point6) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point6* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point6* %0 to i8* + %6 = bitcast %struct.point6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.point7* noalias sret(%struct.point7) align 4 %0, %struct.point7* noundef byval(%struct.point7) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point7* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point7* %0 to i8* + %6 = bitcast %struct.point7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.point8* noalias sret(%struct.point8) align 4 %0, %struct.point8* noundef byval(%struct.point8) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point8* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point8* %0 to i8* + %6 = bitcast %struct.point8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 4 %0, %struct.point9* noundef byval(%struct.point9) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point9* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point9* %0 to i8* + %6 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 4 %0, %struct.point10* noundef byval(%struct.point10) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point10* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point10* %0 to i8* + %6 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 4 %0, %struct.point11* noundef byval(%struct.point11) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point11* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point11* %0 to i8* + %6 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 4 %0, %struct.point12* noundef byval(%struct.point12) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point12* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point12* %0 to i8* + %6 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 4 %0, %struct.point13* noundef byval(%struct.point13) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point13* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point13* %0 to i8* + %6 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 4 %0, %struct.point14* noundef byval(%struct.point14) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point14* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point14* %0 to i8* + %6 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 4 %0, %struct.point15* noundef byval(%struct.point15) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point15* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point15* %0 to i8* + %6 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 4 %0, %struct.point16* noundef byval(%struct.point16) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point16* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point16* %0 to i8* + %6 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 4 %0, %struct.point17* noundef byval(%struct.point17) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point17* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point17* %0 to i8* + %6 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 4 %0, %struct.point18* noundef byval(%struct.point18) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point18* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point18* %0 to i8* + %6 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 4 %0, %struct.point19* noundef byval(%struct.point19) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point19* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point19* %0 to i8* + %6 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 4 %0, %struct.point20* noundef byval(%struct.point20) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point20* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point20* %0 to i8* + %6 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5} +!llvm.ident = !{!6} + +!0 = !{i32 1, !"NumRegisterParameters", i32 0} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 7, !"PIC Level", i32 2} +!3 = !{i32 7, !"PIE Level", i32 2} +!4 = !{i32 7, !"uwtable", i32 2} +!5 = !{i32 7, !"frame-pointer", i32 2} +!6 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/i386/struct_int8.ll b/internal/cabi/_testdata/arch/i386/struct_int8.ll new file mode 100644 index 00000000..3be200a1 --- /dev/null +++ b/internal/cabi/_testdata/arch/i386/struct_int8.ll @@ -0,0 +1,262 @@ +; ModuleID = '../../wrap/struct_int8.c' +source_filename = "../../wrap/struct_int8.c" +target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128" +target triple = "i386-unknown-linux-gnu" + +%struct.point1 = type { i8 } +%struct.point2 = type { i8, i8 } +%struct.point3 = type { i8, i8, i8 } +%struct.point4 = type { i8, i8, i8, i8 } +%struct.point5 = type { i8, i8, i8, i8, i8 } +%struct.point6 = type { i8, i8, i8, i8, i8, i8 } +%struct.point7 = type { i8, i8, i8, i8, i8, i8, i8 } +%struct.point8 = type { i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point9 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point10 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point11 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point12 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point13 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point14 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point15 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point16 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point17 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point18 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point19 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point20 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo1(%struct.point1* noalias sret(%struct.point1) align 1 %0, %struct.point1* noundef byval(%struct.point1) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point1* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point1* %0 to i8* + %6 = bitcast %struct.point1* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 1, i1 false) + ret void +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo2(%struct.point2* noalias sret(%struct.point2) align 1 %0, %struct.point2* noundef byval(%struct.point2) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point2* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point2* %0 to i8* + %6 = bitcast %struct.point2* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 2, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo3(%struct.point3* noalias sret(%struct.point3) align 1 %0, %struct.point3* noundef byval(%struct.point3) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point3* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point3* %0 to i8* + %6 = bitcast %struct.point3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 3, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo4(%struct.point4* noalias sret(%struct.point4) align 1 %0, %struct.point4* noundef byval(%struct.point4) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point4* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point4* %0 to i8* + %6 = bitcast %struct.point4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 4, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.point5* noalias sret(%struct.point5) align 1 %0, %struct.point5* noundef byval(%struct.point5) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point5* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point5* %0 to i8* + %6 = bitcast %struct.point5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 5, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.point6* noalias sret(%struct.point6) align 1 %0, %struct.point6* noundef byval(%struct.point6) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point6* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point6* %0 to i8* + %6 = bitcast %struct.point6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 6, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.point7* noalias sret(%struct.point7) align 1 %0, %struct.point7* noundef byval(%struct.point7) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point7* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point7* %0 to i8* + %6 = bitcast %struct.point7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 7, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.point8* noalias sret(%struct.point8) align 1 %0, %struct.point8* noundef byval(%struct.point8) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point8* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point8* %0 to i8* + %6 = bitcast %struct.point8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 1 %0, %struct.point9* noundef byval(%struct.point9) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point9* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point9* %0 to i8* + %6 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 9, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 1 %0, %struct.point10* noundef byval(%struct.point10) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point10* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point10* %0 to i8* + %6 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 10, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 1 %0, %struct.point11* noundef byval(%struct.point11) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point11* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point11* %0 to i8* + %6 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 11, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 1 %0, %struct.point12* noundef byval(%struct.point12) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point12* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point12* %0 to i8* + %6 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 1 %0, %struct.point13* noundef byval(%struct.point13) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point13* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point13* %0 to i8* + %6 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 13, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 1 %0, %struct.point14* noundef byval(%struct.point14) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point14* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point14* %0 to i8* + %6 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 14, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 1 %0, %struct.point15* noundef byval(%struct.point15) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point15* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point15* %0 to i8* + %6 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 15, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 1 %0, %struct.point16* noundef byval(%struct.point16) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point16* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point16* %0 to i8* + %6 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 1 %0, %struct.point17* noundef byval(%struct.point17) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point17* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point17* %0 to i8* + %6 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 17, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 1 %0, %struct.point18* noundef byval(%struct.point18) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point18* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point18* %0 to i8* + %6 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 18, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 1 %0, %struct.point19* noundef byval(%struct.point19) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point19* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point19* %0 to i8* + %6 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 19, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 1 %0, %struct.point20* noundef byval(%struct.point20) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point20* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point20* %0 to i8* + %6 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 4 %6, i32 20, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5} +!llvm.ident = !{!6} + +!0 = !{i32 1, !"NumRegisterParameters", i32 0} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 7, !"PIC Level", i32 2} +!3 = !{i32 7, !"PIE Level", i32 2} +!4 = !{i32 7, !"uwtable", i32 2} +!5 = !{i32 7, !"frame-pointer", i32 2} +!6 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/i386/struct_uintptr.ll b/internal/cabi/_testdata/arch/i386/struct_uintptr.ll new file mode 100644 index 00000000..5cee2fc0 --- /dev/null +++ b/internal/cabi/_testdata/arch/i386/struct_uintptr.ll @@ -0,0 +1,286 @@ +; ModuleID = '../../wrap/struct_uintptr.c' +source_filename = "../../wrap/struct_uintptr.c" +target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128" +target triple = "i386-unknown-linux-gnu" + +%struct.point1 = type { i8* } +%struct.point2 = type { i8*, i8* } +%struct.point3 = type { i8*, i8*, i8* } +%struct.point4 = type { i8*, i8*, i8*, i8* } +%struct.point5 = type { i8*, i8*, i8*, i8*, i8* } +%struct.point6 = type { i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point7 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point8 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point9 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point10 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point11 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point12 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point13 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point14 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point15 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point16 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point17 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point18 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point19 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point20 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo1(%struct.point1* noalias sret(%struct.point1) align 4 %0, i8* %1) #0 { + %3 = alloca i8*, align 4 + %4 = alloca %struct.point1, align 4 + %5 = bitcast %struct.point1* %0 to i8* + store i8* %5, i8** %3, align 4 + %6 = getelementptr inbounds %struct.point1, %struct.point1* %4, i32 0, i32 0 + store i8* %1, i8** %6, align 4 + %7 = bitcast %struct.point1* %0 to i8* + %8 = bitcast %struct.point1* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %7, i8* align 4 %8, i32 4, i1 false) + ret void +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo2(%struct.point2* noalias sret(%struct.point2) align 4 %0, i8* %1, i8* %2) #0 { + %4 = alloca i8*, align 4 + %5 = alloca %struct.point2, align 4 + %6 = bitcast %struct.point2* %0 to i8* + store i8* %6, i8** %4, align 4 + %7 = getelementptr inbounds %struct.point2, %struct.point2* %5, i32 0, i32 0 + store i8* %1, i8** %7, align 4 + %8 = getelementptr inbounds %struct.point2, %struct.point2* %5, i32 0, i32 1 + store i8* %2, i8** %8, align 4 + %9 = bitcast %struct.point2* %0 to i8* + %10 = bitcast %struct.point2* %5 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %9, i8* align 4 %10, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo3(%struct.point3* noalias sret(%struct.point3) align 4 %0, i8* %1, i8* %2, i8* %3) #0 { + %5 = alloca i8*, align 4 + %6 = alloca %struct.point3, align 4 + %7 = bitcast %struct.point3* %0 to i8* + store i8* %7, i8** %5, align 4 + %8 = getelementptr inbounds %struct.point3, %struct.point3* %6, i32 0, i32 0 + store i8* %1, i8** %8, align 4 + %9 = getelementptr inbounds %struct.point3, %struct.point3* %6, i32 0, i32 1 + store i8* %2, i8** %9, align 4 + %10 = getelementptr inbounds %struct.point3, %struct.point3* %6, i32 0, i32 2 + store i8* %3, i8** %10, align 4 + %11 = bitcast %struct.point3* %0 to i8* + %12 = bitcast %struct.point3* %6 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %11, i8* align 4 %12, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo4(%struct.point4* noalias sret(%struct.point4) align 4 %0, i8* %1, i8* %2, i8* %3, i8* %4) #0 { + %6 = alloca i8*, align 4 + %7 = alloca %struct.point4, align 4 + %8 = bitcast %struct.point4* %0 to i8* + store i8* %8, i8** %6, align 4 + %9 = getelementptr inbounds %struct.point4, %struct.point4* %7, i32 0, i32 0 + store i8* %1, i8** %9, align 4 + %10 = getelementptr inbounds %struct.point4, %struct.point4* %7, i32 0, i32 1 + store i8* %2, i8** %10, align 4 + %11 = getelementptr inbounds %struct.point4, %struct.point4* %7, i32 0, i32 2 + store i8* %3, i8** %11, align 4 + %12 = getelementptr inbounds %struct.point4, %struct.point4* %7, i32 0, i32 3 + store i8* %4, i8** %12, align 4 + %13 = bitcast %struct.point4* %0 to i8* + %14 = bitcast %struct.point4* %7 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %13, i8* align 4 %14, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo5(%struct.point5* noalias sret(%struct.point5) align 4 %0, %struct.point5* noundef byval(%struct.point5) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point5* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point5* %0 to i8* + %6 = bitcast %struct.point5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo6(%struct.point6* noalias sret(%struct.point6) align 4 %0, %struct.point6* noundef byval(%struct.point6) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point6* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point6* %0 to i8* + %6 = bitcast %struct.point6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo7(%struct.point7* noalias sret(%struct.point7) align 4 %0, %struct.point7* noundef byval(%struct.point7) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point7* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point7* %0 to i8* + %6 = bitcast %struct.point7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo8(%struct.point8* noalias sret(%struct.point8) align 4 %0, %struct.point8* noundef byval(%struct.point8) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point8* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point8* %0 to i8* + %6 = bitcast %struct.point8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 4 %0, %struct.point9* noundef byval(%struct.point9) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point9* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point9* %0 to i8* + %6 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 4 %0, %struct.point10* noundef byval(%struct.point10) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point10* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point10* %0 to i8* + %6 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 4 %0, %struct.point11* noundef byval(%struct.point11) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point11* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point11* %0 to i8* + %6 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 4 %0, %struct.point12* noundef byval(%struct.point12) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point12* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point12* %0 to i8* + %6 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 4 %0, %struct.point13* noundef byval(%struct.point13) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point13* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point13* %0 to i8* + %6 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 4 %0, %struct.point14* noundef byval(%struct.point14) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point14* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point14* %0 to i8* + %6 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 4 %0, %struct.point15* noundef byval(%struct.point15) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point15* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point15* %0 to i8* + %6 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 4 %0, %struct.point16* noundef byval(%struct.point16) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point16* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point16* %0 to i8* + %6 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 4 %0, %struct.point17* noundef byval(%struct.point17) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point17* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point17* %0 to i8* + %6 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 4 %0, %struct.point18* noundef byval(%struct.point18) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point18* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point18* %0 to i8* + %6 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 4 %0, %struct.point19* noundef byval(%struct.point19) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point19* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point19* %0 to i8* + %6 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 4 %0, %struct.point20* noundef byval(%struct.point20) align 4 %1) #0 { + %3 = alloca i8*, align 4 + %4 = bitcast %struct.point20* %0 to i8* + store i8* %4, i8** %3, align 4 + %5 = bitcast %struct.point20* %0 to i8* + %6 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5} +!llvm.ident = !{!6} + +!0 = !{i32 1, !"NumRegisterParameters", i32 0} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 7, !"PIC Level", i32 2} +!3 = !{i32 7, !"PIE Level", i32 2} +!4 = !{i32 7, !"uwtable", i32 2} +!5 = !{i32 7, !"frame-pointer", i32 2} +!6 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/riscv64/array_float32.ll b/internal/cabi/_testdata/arch/riscv64/array_float32.ll new file mode 100644 index 00000000..6a797af6 --- /dev/null +++ b/internal/cabi/_testdata/arch/riscv64/array_float32.ll @@ -0,0 +1,292 @@ +; ModuleID = '../../wrap/array_float32.c' +source_filename = "../../wrap/array_float32.c" +target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" +target triple = "riscv64-unknown-unknown-elf" + +%struct.array1 = type { [1 x float] } +%struct.array2 = type { [2 x float] } +%struct.array3 = type { [3 x float] } +%struct.array4 = type { [4 x float] } +%struct.array5 = type { [5 x float] } +%struct.array6 = type { [6 x float] } +%struct.array7 = type { [7 x float] } +%struct.array8 = type { [8 x float] } +%struct.array9 = type { [9 x float] } +%struct.array10 = type { [10 x float] } +%struct.array11 = type { [11 x float] } +%struct.array12 = type { [12 x float] } +%struct.array13 = type { [13 x float] } +%struct.array14 = type { [14 x float] } +%struct.array15 = type { [15 x float] } +%struct.array16 = type { [16 x float] } +%struct.array17 = type { [17 x float] } +%struct.array18 = type { [18 x float] } +%struct.array19 = type { [19 x float] } +%struct.array20 = type { [20 x float] } + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo1(i64 %0) #0 { + %2 = alloca %struct.array1, align 4 + %3 = alloca %struct.array1, align 4 + %4 = alloca i64, align 8 + %5 = alloca i64, align 8 + %6 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + store i64 %0, i64* %4, align 8 + %7 = bitcast [1 x float]* %6 to i8* + %8 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %7, i8* align 8 %8, i64 4, i1 false) + %9 = bitcast %struct.array1* %2 to i8* + %10 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %9, i8* align 4 %10, i64 4, i1 false) + %11 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %12 = bitcast i64* %5 to i8* + %13 = bitcast [1 x float]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 4 %13, i64 4, i1 false) + %14 = load i64, i64* %5, align 8 + ret i64 %14 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo2(i64 %0) #0 { + %2 = alloca %struct.array2, align 4 + %3 = alloca %struct.array2, align 4 + %4 = getelementptr inbounds %struct.array2, %struct.array2* %3, i32 0, i32 0 + %5 = bitcast [2 x float]* %4 to i64* + store i64 %0, i64* %5, align 4 + %6 = bitcast %struct.array2* %2 to i8* + %7 = bitcast %struct.array2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %6, i8* align 4 %7, i64 8, i1 false) + %8 = getelementptr inbounds %struct.array2, %struct.array2* %2, i32 0, i32 0 + %9 = bitcast [2 x float]* %8 to i64* + %10 = load i64, i64* %9, align 4 + ret i64 %10 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo3([2 x i64] %0) #0 { + %2 = alloca %struct.array3, align 4 + %3 = alloca %struct.array3, align 4 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + %6 = getelementptr inbounds %struct.array3, %struct.array3* %3, i32 0, i32 0 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %7 = bitcast [3 x float]* %6 to i8* + %8 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %7, i8* align 8 %8, i64 12, i1 false) + %9 = bitcast %struct.array3* %2 to i8* + %10 = bitcast %struct.array3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %9, i8* align 4 %10, i64 12, i1 false) + %11 = getelementptr inbounds %struct.array3, %struct.array3* %2, i32 0, i32 0 + %12 = bitcast [2 x i64]* %5 to i8* + %13 = bitcast [3 x float]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 4 %13, i64 12, i1 false) + %14 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %14 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo4([2 x i64] %0) #0 { + %2 = alloca %struct.array4, align 4 + %3 = alloca %struct.array4, align 4 + %4 = getelementptr inbounds %struct.array4, %struct.array4* %3, i32 0, i32 0 + %5 = bitcast [4 x float]* %4 to [2 x i64]* + store [2 x i64] %0, [2 x i64]* %5, align 4 + %6 = bitcast %struct.array4* %2 to i8* + %7 = bitcast %struct.array4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %6, i8* align 4 %7, i64 16, i1 false) + %8 = getelementptr inbounds %struct.array4, %struct.array4* %2, i32 0, i32 0 + %9 = bitcast [4 x float]* %8 to [2 x i64]* + %10 = load [2 x i64], [2 x i64]* %9, align 4 + ret [2 x i64] %10 +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 4 %0, %struct.array5* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array5* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array5* %0 to i8* + %6 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 4 %0, %struct.array6* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array6* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array6* %0 to i8* + %6 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 4 %0, %struct.array7* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array7* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array7* %0 to i8* + %6 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 4 %0, %struct.array8* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array8* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array8* %0 to i8* + %6 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 4 %0, %struct.array9* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array9* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array9* %0 to i8* + %6 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 4 %0, %struct.array10* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array10* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array10* %0 to i8* + %6 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 4 %0, %struct.array11* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array11* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array11* %0 to i8* + %6 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 4 %0, %struct.array12* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array12* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array12* %0 to i8* + %6 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 4 %0, %struct.array13* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array13* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array13* %0 to i8* + %6 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 4 %0, %struct.array14* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array14* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array14* %0 to i8* + %6 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 4 %0, %struct.array15* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array15* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array15* %0 to i8* + %6 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 4 %0, %struct.array16* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array16* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array16* %0 to i8* + %6 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 4 %0, %struct.array17* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array17* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array17* %0 to i8* + %6 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 4 %0, %struct.array18* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array18* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array18* %0 to i8* + %6 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 4 %0, %struct.array19* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array19* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array19* %0 to i8* + %6 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 4 %0, %struct.array20* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array20* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array20* %0 to i8* + %6 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+m,+relax,-save-restore" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3} +!llvm.ident = !{!4} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"target-abi", !"lp64"} +!2 = !{i32 7, !"frame-pointer", i32 2} +!3 = !{i32 1, !"SmallDataLimit", i32 8} +!4 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/riscv64/array_float64.ll b/internal/cabi/_testdata/arch/riscv64/array_float64.ll new file mode 100644 index 00000000..5907c5df --- /dev/null +++ b/internal/cabi/_testdata/arch/riscv64/array_float64.ll @@ -0,0 +1,270 @@ +; ModuleID = '../../wrap/array_float64.c' +source_filename = "../../wrap/array_float64.c" +target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" +target triple = "riscv64-unknown-unknown-elf" + +%struct.array1 = type { [1 x double] } +%struct.array2 = type { [2 x double] } +%struct.array3 = type { [3 x double] } +%struct.array4 = type { [4 x double] } +%struct.array5 = type { [5 x double] } +%struct.array6 = type { [6 x double] } +%struct.array7 = type { [7 x double] } +%struct.array8 = type { [8 x double] } +%struct.array9 = type { [9 x double] } +%struct.array10 = type { [10 x double] } +%struct.array11 = type { [11 x double] } +%struct.array12 = type { [12 x double] } +%struct.array13 = type { [13 x double] } +%struct.array14 = type { [14 x double] } +%struct.array15 = type { [15 x double] } +%struct.array16 = type { [16 x double] } +%struct.array17 = type { [17 x double] } +%struct.array18 = type { [18 x double] } +%struct.array19 = type { [19 x double] } +%struct.array20 = type { [20 x double] } + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo1(i64 %0) #0 { + %2 = alloca %struct.array1, align 8 + %3 = alloca %struct.array1, align 8 + %4 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + %5 = bitcast [1 x double]* %4 to i64* + store i64 %0, i64* %5, align 8 + %6 = bitcast %struct.array1* %2 to i8* + %7 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %6, i8* align 8 %7, i64 8, i1 false) + %8 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %9 = bitcast [1 x double]* %8 to i64* + %10 = load i64, i64* %9, align 8 + ret i64 %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo2([2 x i64] %0) #0 { + %2 = alloca %struct.array2, align 8 + %3 = alloca %struct.array2, align 8 + %4 = getelementptr inbounds %struct.array2, %struct.array2* %3, i32 0, i32 0 + %5 = bitcast [2 x double]* %4 to [2 x i64]* + store [2 x i64] %0, [2 x i64]* %5, align 8 + %6 = bitcast %struct.array2* %2 to i8* + %7 = bitcast %struct.array2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %6, i8* align 8 %7, i64 16, i1 false) + %8 = getelementptr inbounds %struct.array2, %struct.array2* %2, i32 0, i32 0 + %9 = bitcast [2 x double]* %8 to [2 x i64]* + %10 = load [2 x i64], [2 x i64]* %9, align 8 + ret [2 x i64] %10 +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo3(%struct.array3* noalias sret(%struct.array3) align 8 %0, %struct.array3* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array3* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array3* %0 to i8* + %6 = bitcast %struct.array3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo4(%struct.array4* noalias sret(%struct.array4) align 8 %0, %struct.array4* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array4* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array4* %0 to i8* + %6 = bitcast %struct.array4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 8 %0, %struct.array5* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array5* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array5* %0 to i8* + %6 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 8 %0, %struct.array6* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array6* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array6* %0 to i8* + %6 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 8 %0, %struct.array7* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array7* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array7* %0 to i8* + %6 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 8 %0, %struct.array8* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array8* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array8* %0 to i8* + %6 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 8 %0, %struct.array9* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array9* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array9* %0 to i8* + %6 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 8 %0, %struct.array10* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array10* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array10* %0 to i8* + %6 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 8 %0, %struct.array11* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array11* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array11* %0 to i8* + %6 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 8 %0, %struct.array12* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array12* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array12* %0 to i8* + %6 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 8 %0, %struct.array13* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array13* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array13* %0 to i8* + %6 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 8 %0, %struct.array14* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array14* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array14* %0 to i8* + %6 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 8 %0, %struct.array15* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array15* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array15* %0 to i8* + %6 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 8 %0, %struct.array16* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array16* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array16* %0 to i8* + %6 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 8 %0, %struct.array17* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array17* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array17* %0 to i8* + %6 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 8 %0, %struct.array18* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array18* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array18* %0 to i8* + %6 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 8 %0, %struct.array19* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array19* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array19* %0 to i8* + %6 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 8 %0, %struct.array20* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array20* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array20* %0 to i8* + %6 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+m,+relax,-save-restore" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3} +!llvm.ident = !{!4} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"target-abi", !"lp64"} +!2 = !{i32 7, !"frame-pointer", i32 2} +!3 = !{i32 1, !"SmallDataLimit", i32 8} +!4 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/riscv64/array_int16.ll b/internal/cabi/_testdata/arch/riscv64/array_int16.ll new file mode 100644 index 00000000..ade46329 --- /dev/null +++ b/internal/cabi/_testdata/arch/riscv64/array_int16.ll @@ -0,0 +1,336 @@ +; ModuleID = '../../wrap/array_int16.c' +source_filename = "../../wrap/array_int16.c" +target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" +target triple = "riscv64-unknown-unknown-elf" + +%struct.array1 = type { [1 x i16] } +%struct.array2 = type { [2 x i16] } +%struct.array3 = type { [3 x i16] } +%struct.array4 = type { [4 x i16] } +%struct.array5 = type { [5 x i16] } +%struct.array6 = type { [6 x i16] } +%struct.array7 = type { [7 x i16] } +%struct.array8 = type { [8 x i16] } +%struct.array9 = type { [9 x i16] } +%struct.array10 = type { [10 x i16] } +%struct.array11 = type { [11 x i16] } +%struct.array12 = type { [12 x i16] } +%struct.array13 = type { [13 x i16] } +%struct.array14 = type { [14 x i16] } +%struct.array15 = type { [15 x i16] } +%struct.array16 = type { [16 x i16] } +%struct.array17 = type { [17 x i16] } +%struct.array18 = type { [18 x i16] } +%struct.array19 = type { [19 x i16] } +%struct.array20 = type { [20 x i16] } + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo1(i64 %0) #0 { + %2 = alloca %struct.array1, align 2 + %3 = alloca %struct.array1, align 2 + %4 = alloca i64, align 8 + %5 = alloca i64, align 8 + %6 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + store i64 %0, i64* %4, align 8 + %7 = bitcast [1 x i16]* %6 to i8* + %8 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %7, i8* align 8 %8, i64 2, i1 false) + %9 = bitcast %struct.array1* %2 to i8* + %10 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %9, i8* align 2 %10, i64 2, i1 false) + %11 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %12 = bitcast i64* %5 to i8* + %13 = bitcast [1 x i16]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 2 %13, i64 2, i1 false) + %14 = load i64, i64* %5, align 8 + ret i64 %14 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo2(i64 %0) #0 { + %2 = alloca %struct.array2, align 2 + %3 = alloca %struct.array2, align 2 + %4 = alloca i64, align 8 + %5 = alloca i64, align 8 + %6 = getelementptr inbounds %struct.array2, %struct.array2* %3, i32 0, i32 0 + store i64 %0, i64* %4, align 8 + %7 = bitcast [2 x i16]* %6 to i8* + %8 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %7, i8* align 8 %8, i64 4, i1 false) + %9 = bitcast %struct.array2* %2 to i8* + %10 = bitcast %struct.array2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %9, i8* align 2 %10, i64 4, i1 false) + %11 = getelementptr inbounds %struct.array2, %struct.array2* %2, i32 0, i32 0 + %12 = bitcast i64* %5 to i8* + %13 = bitcast [2 x i16]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 2 %13, i64 4, i1 false) + %14 = load i64, i64* %5, align 8 + ret i64 %14 +} + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo3(i64 %0) #0 { + %2 = alloca %struct.array3, align 2 + %3 = alloca %struct.array3, align 2 + %4 = alloca i64, align 8 + %5 = alloca i64, align 8 + %6 = getelementptr inbounds %struct.array3, %struct.array3* %3, i32 0, i32 0 + store i64 %0, i64* %4, align 8 + %7 = bitcast [3 x i16]* %6 to i8* + %8 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %7, i8* align 8 %8, i64 6, i1 false) + %9 = bitcast %struct.array3* %2 to i8* + %10 = bitcast %struct.array3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %9, i8* align 2 %10, i64 6, i1 false) + %11 = getelementptr inbounds %struct.array3, %struct.array3* %2, i32 0, i32 0 + %12 = bitcast i64* %5 to i8* + %13 = bitcast [3 x i16]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 2 %13, i64 6, i1 false) + %14 = load i64, i64* %5, align 8 + ret i64 %14 +} + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo4(i64 %0) #0 { + %2 = alloca %struct.array4, align 2 + %3 = alloca %struct.array4, align 2 + %4 = getelementptr inbounds %struct.array4, %struct.array4* %3, i32 0, i32 0 + %5 = bitcast [4 x i16]* %4 to i64* + store i64 %0, i64* %5, align 2 + %6 = bitcast %struct.array4* %2 to i8* + %7 = bitcast %struct.array4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %6, i8* align 2 %7, i64 8, i1 false) + %8 = getelementptr inbounds %struct.array4, %struct.array4* %2, i32 0, i32 0 + %9 = bitcast [4 x i16]* %8 to i64* + %10 = load i64, i64* %9, align 2 + ret i64 %10 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo5([2 x i64] %0) #0 { + %2 = alloca %struct.array5, align 2 + %3 = alloca %struct.array5, align 2 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + %6 = getelementptr inbounds %struct.array5, %struct.array5* %3, i32 0, i32 0 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %7 = bitcast [5 x i16]* %6 to i8* + %8 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %7, i8* align 8 %8, i64 10, i1 false) + %9 = bitcast %struct.array5* %2 to i8* + %10 = bitcast %struct.array5* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %9, i8* align 2 %10, i64 10, i1 false) + %11 = getelementptr inbounds %struct.array5, %struct.array5* %2, i32 0, i32 0 + %12 = bitcast [2 x i64]* %5 to i8* + %13 = bitcast [5 x i16]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 2 %13, i64 10, i1 false) + %14 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %14 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo6([2 x i64] %0) #0 { + %2 = alloca %struct.array6, align 2 + %3 = alloca %struct.array6, align 2 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + %6 = getelementptr inbounds %struct.array6, %struct.array6* %3, i32 0, i32 0 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %7 = bitcast [6 x i16]* %6 to i8* + %8 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %7, i8* align 8 %8, i64 12, i1 false) + %9 = bitcast %struct.array6* %2 to i8* + %10 = bitcast %struct.array6* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %9, i8* align 2 %10, i64 12, i1 false) + %11 = getelementptr inbounds %struct.array6, %struct.array6* %2, i32 0, i32 0 + %12 = bitcast [2 x i64]* %5 to i8* + %13 = bitcast [6 x i16]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 2 %13, i64 12, i1 false) + %14 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %14 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo7([2 x i64] %0) #0 { + %2 = alloca %struct.array7, align 2 + %3 = alloca %struct.array7, align 2 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + %6 = getelementptr inbounds %struct.array7, %struct.array7* %3, i32 0, i32 0 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %7 = bitcast [7 x i16]* %6 to i8* + %8 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %7, i8* align 8 %8, i64 14, i1 false) + %9 = bitcast %struct.array7* %2 to i8* + %10 = bitcast %struct.array7* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %9, i8* align 2 %10, i64 14, i1 false) + %11 = getelementptr inbounds %struct.array7, %struct.array7* %2, i32 0, i32 0 + %12 = bitcast [2 x i64]* %5 to i8* + %13 = bitcast [7 x i16]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 2 %13, i64 14, i1 false) + %14 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %14 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo8([2 x i64] %0) #0 { + %2 = alloca %struct.array8, align 2 + %3 = alloca %struct.array8, align 2 + %4 = getelementptr inbounds %struct.array8, %struct.array8* %3, i32 0, i32 0 + %5 = bitcast [8 x i16]* %4 to [2 x i64]* + store [2 x i64] %0, [2 x i64]* %5, align 2 + %6 = bitcast %struct.array8* %2 to i8* + %7 = bitcast %struct.array8* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %6, i8* align 2 %7, i64 16, i1 false) + %8 = getelementptr inbounds %struct.array8, %struct.array8* %2, i32 0, i32 0 + %9 = bitcast [8 x i16]* %8 to [2 x i64]* + %10 = load [2 x i64], [2 x i64]* %9, align 2 + ret [2 x i64] %10 +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 2 %0, %struct.array9* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array9* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array9* %0 to i8* + %6 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 18, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 2 %0, %struct.array10* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array10* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array10* %0 to i8* + %6 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 2 %0, %struct.array11* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array11* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array11* %0 to i8* + %6 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 22, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 2 %0, %struct.array12* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array12* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array12* %0 to i8* + %6 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 2 %0, %struct.array13* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array13* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array13* %0 to i8* + %6 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 26, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 2 %0, %struct.array14* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array14* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array14* %0 to i8* + %6 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 2 %0, %struct.array15* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array15* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array15* %0 to i8* + %6 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 30, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 2 %0, %struct.array16* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array16* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array16* %0 to i8* + %6 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 2 %0, %struct.array17* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array17* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array17* %0 to i8* + %6 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 34, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 2 %0, %struct.array18* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array18* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array18* %0 to i8* + %6 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 2 %0, %struct.array19* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array19* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array19* %0 to i8* + %6 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 38, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 2 %0, %struct.array20* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array20* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array20* %0 to i8* + %6 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 40, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+m,+relax,-save-restore" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3} +!llvm.ident = !{!4} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"target-abi", !"lp64"} +!2 = !{i32 7, !"frame-pointer", i32 2} +!3 = !{i32 1, !"SmallDataLimit", i32 8} +!4 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/riscv64/array_int32.ll b/internal/cabi/_testdata/arch/riscv64/array_int32.ll new file mode 100644 index 00000000..08d6f991 --- /dev/null +++ b/internal/cabi/_testdata/arch/riscv64/array_int32.ll @@ -0,0 +1,292 @@ +; ModuleID = '../../wrap/array_int32.c' +source_filename = "../../wrap/array_int32.c" +target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" +target triple = "riscv64-unknown-unknown-elf" + +%struct.array1 = type { [1 x i32] } +%struct.array2 = type { [2 x i32] } +%struct.array3 = type { [3 x i32] } +%struct.array4 = type { [4 x i32] } +%struct.array5 = type { [5 x i32] } +%struct.array6 = type { [6 x i32] } +%struct.array7 = type { [7 x i32] } +%struct.array8 = type { [8 x i32] } +%struct.array9 = type { [9 x i32] } +%struct.array10 = type { [10 x i32] } +%struct.array11 = type { [11 x i32] } +%struct.array12 = type { [12 x i32] } +%struct.array13 = type { [13 x i32] } +%struct.array14 = type { [14 x i32] } +%struct.array15 = type { [15 x i32] } +%struct.array16 = type { [16 x i32] } +%struct.array17 = type { [17 x i32] } +%struct.array18 = type { [18 x i32] } +%struct.array19 = type { [19 x i32] } +%struct.array20 = type { [20 x i32] } + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo1(i64 %0) #0 { + %2 = alloca %struct.array1, align 4 + %3 = alloca %struct.array1, align 4 + %4 = alloca i64, align 8 + %5 = alloca i64, align 8 + %6 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + store i64 %0, i64* %4, align 8 + %7 = bitcast [1 x i32]* %6 to i8* + %8 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %7, i8* align 8 %8, i64 4, i1 false) + %9 = bitcast %struct.array1* %2 to i8* + %10 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %9, i8* align 4 %10, i64 4, i1 false) + %11 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %12 = bitcast i64* %5 to i8* + %13 = bitcast [1 x i32]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 4 %13, i64 4, i1 false) + %14 = load i64, i64* %5, align 8 + ret i64 %14 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo2(i64 %0) #0 { + %2 = alloca %struct.array2, align 4 + %3 = alloca %struct.array2, align 4 + %4 = getelementptr inbounds %struct.array2, %struct.array2* %3, i32 0, i32 0 + %5 = bitcast [2 x i32]* %4 to i64* + store i64 %0, i64* %5, align 4 + %6 = bitcast %struct.array2* %2 to i8* + %7 = bitcast %struct.array2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %6, i8* align 4 %7, i64 8, i1 false) + %8 = getelementptr inbounds %struct.array2, %struct.array2* %2, i32 0, i32 0 + %9 = bitcast [2 x i32]* %8 to i64* + %10 = load i64, i64* %9, align 4 + ret i64 %10 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo3([2 x i64] %0) #0 { + %2 = alloca %struct.array3, align 4 + %3 = alloca %struct.array3, align 4 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + %6 = getelementptr inbounds %struct.array3, %struct.array3* %3, i32 0, i32 0 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %7 = bitcast [3 x i32]* %6 to i8* + %8 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %7, i8* align 8 %8, i64 12, i1 false) + %9 = bitcast %struct.array3* %2 to i8* + %10 = bitcast %struct.array3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %9, i8* align 4 %10, i64 12, i1 false) + %11 = getelementptr inbounds %struct.array3, %struct.array3* %2, i32 0, i32 0 + %12 = bitcast [2 x i64]* %5 to i8* + %13 = bitcast [3 x i32]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 4 %13, i64 12, i1 false) + %14 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %14 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo4([2 x i64] %0) #0 { + %2 = alloca %struct.array4, align 4 + %3 = alloca %struct.array4, align 4 + %4 = getelementptr inbounds %struct.array4, %struct.array4* %3, i32 0, i32 0 + %5 = bitcast [4 x i32]* %4 to [2 x i64]* + store [2 x i64] %0, [2 x i64]* %5, align 4 + %6 = bitcast %struct.array4* %2 to i8* + %7 = bitcast %struct.array4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %6, i8* align 4 %7, i64 16, i1 false) + %8 = getelementptr inbounds %struct.array4, %struct.array4* %2, i32 0, i32 0 + %9 = bitcast [4 x i32]* %8 to [2 x i64]* + %10 = load [2 x i64], [2 x i64]* %9, align 4 + ret [2 x i64] %10 +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 4 %0, %struct.array5* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array5* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array5* %0 to i8* + %6 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 4 %0, %struct.array6* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array6* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array6* %0 to i8* + %6 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 4 %0, %struct.array7* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array7* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array7* %0 to i8* + %6 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 4 %0, %struct.array8* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array8* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array8* %0 to i8* + %6 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 4 %0, %struct.array9* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array9* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array9* %0 to i8* + %6 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 4 %0, %struct.array10* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array10* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array10* %0 to i8* + %6 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 4 %0, %struct.array11* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array11* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array11* %0 to i8* + %6 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 4 %0, %struct.array12* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array12* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array12* %0 to i8* + %6 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 4 %0, %struct.array13* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array13* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array13* %0 to i8* + %6 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 4 %0, %struct.array14* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array14* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array14* %0 to i8* + %6 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 4 %0, %struct.array15* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array15* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array15* %0 to i8* + %6 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 4 %0, %struct.array16* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array16* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array16* %0 to i8* + %6 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 4 %0, %struct.array17* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array17* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array17* %0 to i8* + %6 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 4 %0, %struct.array18* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array18* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array18* %0 to i8* + %6 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 4 %0, %struct.array19* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array19* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array19* %0 to i8* + %6 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 4 %0, %struct.array20* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array20* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array20* %0 to i8* + %6 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+m,+relax,-save-restore" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3} +!llvm.ident = !{!4} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"target-abi", !"lp64"} +!2 = !{i32 7, !"frame-pointer", i32 2} +!3 = !{i32 1, !"SmallDataLimit", i32 8} +!4 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/riscv64/array_int64.ll b/internal/cabi/_testdata/arch/riscv64/array_int64.ll new file mode 100644 index 00000000..d1c6adf1 --- /dev/null +++ b/internal/cabi/_testdata/arch/riscv64/array_int64.ll @@ -0,0 +1,268 @@ +; ModuleID = '../../wrap/array_int64.c' +source_filename = "../../wrap/array_int64.c" +target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" +target triple = "riscv64-unknown-unknown-elf" + +%struct.array1 = type { [1 x i64] } +%struct.array2 = type { [2 x i64] } +%struct.array3 = type { [3 x i64] } +%struct.array4 = type { [4 x i64] } +%struct.array5 = type { [5 x i64] } +%struct.array6 = type { [6 x i64] } +%struct.array7 = type { [7 x i64] } +%struct.array8 = type { [8 x i64] } +%struct.array9 = type { [9 x i64] } +%struct.array10 = type { [10 x i64] } +%struct.array11 = type { [11 x i64] } +%struct.array12 = type { [12 x i64] } +%struct.array13 = type { [13 x i64] } +%struct.array14 = type { [14 x i64] } +%struct.array15 = type { [15 x i64] } +%struct.array16 = type { [16 x i64] } +%struct.array17 = type { [17 x i64] } +%struct.array18 = type { [18 x i64] } +%struct.array19 = type { [19 x i64] } +%struct.array20 = type { [20 x i64] } + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo1(i64 %0) #0 { + %2 = alloca %struct.array1, align 8 + %3 = alloca %struct.array1, align 8 + %4 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + %5 = bitcast [1 x i64]* %4 to i64* + store i64 %0, i64* %5, align 8 + %6 = bitcast %struct.array1* %2 to i8* + %7 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %6, i8* align 8 %7, i64 8, i1 false) + %8 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %9 = bitcast [1 x i64]* %8 to i64* + %10 = load i64, i64* %9, align 8 + ret i64 %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo2([2 x i64] %0) #0 { + %2 = alloca %struct.array2, align 8 + %3 = alloca %struct.array2, align 8 + %4 = getelementptr inbounds %struct.array2, %struct.array2* %3, i32 0, i32 0 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %5 = bitcast %struct.array2* %2 to i8* + %6 = bitcast %struct.array2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 16, i1 false) + %7 = getelementptr inbounds %struct.array2, %struct.array2* %2, i32 0, i32 0 + %8 = load [2 x i64], [2 x i64]* %7, align 8 + ret [2 x i64] %8 +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo3(%struct.array3* noalias sret(%struct.array3) align 8 %0, %struct.array3* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array3* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array3* %0 to i8* + %6 = bitcast %struct.array3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo4(%struct.array4* noalias sret(%struct.array4) align 8 %0, %struct.array4* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array4* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array4* %0 to i8* + %6 = bitcast %struct.array4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 8 %0, %struct.array5* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array5* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array5* %0 to i8* + %6 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 8 %0, %struct.array6* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array6* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array6* %0 to i8* + %6 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 8 %0, %struct.array7* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array7* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array7* %0 to i8* + %6 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 8 %0, %struct.array8* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array8* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array8* %0 to i8* + %6 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 8 %0, %struct.array9* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array9* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array9* %0 to i8* + %6 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 8 %0, %struct.array10* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array10* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array10* %0 to i8* + %6 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 8 %0, %struct.array11* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array11* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array11* %0 to i8* + %6 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 8 %0, %struct.array12* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array12* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array12* %0 to i8* + %6 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 8 %0, %struct.array13* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array13* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array13* %0 to i8* + %6 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 8 %0, %struct.array14* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array14* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array14* %0 to i8* + %6 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 8 %0, %struct.array15* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array15* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array15* %0 to i8* + %6 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 8 %0, %struct.array16* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array16* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array16* %0 to i8* + %6 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 8 %0, %struct.array17* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array17* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array17* %0 to i8* + %6 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 8 %0, %struct.array18* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array18* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array18* %0 to i8* + %6 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 8 %0, %struct.array19* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array19* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array19* %0 to i8* + %6 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 8 %0, %struct.array20* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array20* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array20* %0 to i8* + %6 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+m,+relax,-save-restore" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3} +!llvm.ident = !{!4} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"target-abi", !"lp64"} +!2 = !{i32 7, !"frame-pointer", i32 2} +!3 = !{i32 1, !"SmallDataLimit", i32 8} +!4 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/riscv64/array_int8.ll b/internal/cabi/_testdata/arch/riscv64/array_int8.ll new file mode 100644 index 00000000..29e03df4 --- /dev/null +++ b/internal/cabi/_testdata/arch/riscv64/array_int8.ll @@ -0,0 +1,424 @@ +; ModuleID = '../../wrap/array_int8.c' +source_filename = "../../wrap/array_int8.c" +target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" +target triple = "riscv64-unknown-unknown-elf" + +%struct.array1 = type { [1 x i8] } +%struct.array2 = type { [2 x i8] } +%struct.array3 = type { [3 x i8] } +%struct.array4 = type { [4 x i8] } +%struct.array5 = type { [5 x i8] } +%struct.array6 = type { [6 x i8] } +%struct.array7 = type { [7 x i8] } +%struct.array8 = type { [8 x i8] } +%struct.array9 = type { [9 x i8] } +%struct.array10 = type { [10 x i8] } +%struct.array11 = type { [11 x i8] } +%struct.array12 = type { [12 x i8] } +%struct.array13 = type { [13 x i8] } +%struct.array14 = type { [14 x i8] } +%struct.array15 = type { [15 x i8] } +%struct.array16 = type { [16 x i8] } +%struct.array17 = type { [17 x i8] } +%struct.array18 = type { [18 x i8] } +%struct.array19 = type { [19 x i8] } +%struct.array20 = type { [20 x i8] } + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo1(i64 %0) #0 { + %2 = alloca %struct.array1, align 1 + %3 = alloca %struct.array1, align 1 + %4 = alloca i64, align 8 + %5 = alloca i64, align 8 + %6 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + store i64 %0, i64* %4, align 8 + %7 = bitcast [1 x i8]* %6 to i8* + %8 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 8 %8, i64 1, i1 false) + %9 = bitcast %struct.array1* %2 to i8* + %10 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 1, i1 false) + %11 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %12 = bitcast i64* %5 to i8* + %13 = bitcast [1 x i8]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 1 %13, i64 1, i1 false) + %14 = load i64, i64* %5, align 8 + ret i64 %14 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo2(i64 %0) #0 { + %2 = alloca %struct.array2, align 1 + %3 = alloca %struct.array2, align 1 + %4 = alloca i64, align 8 + %5 = alloca i64, align 8 + %6 = getelementptr inbounds %struct.array2, %struct.array2* %3, i32 0, i32 0 + store i64 %0, i64* %4, align 8 + %7 = bitcast [2 x i8]* %6 to i8* + %8 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 8 %8, i64 2, i1 false) + %9 = bitcast %struct.array2* %2 to i8* + %10 = bitcast %struct.array2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 2, i1 false) + %11 = getelementptr inbounds %struct.array2, %struct.array2* %2, i32 0, i32 0 + %12 = bitcast i64* %5 to i8* + %13 = bitcast [2 x i8]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 1 %13, i64 2, i1 false) + %14 = load i64, i64* %5, align 8 + ret i64 %14 +} + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo3(i64 %0) #0 { + %2 = alloca %struct.array3, align 1 + %3 = alloca %struct.array3, align 1 + %4 = alloca i64, align 8 + %5 = alloca i64, align 8 + %6 = getelementptr inbounds %struct.array3, %struct.array3* %3, i32 0, i32 0 + store i64 %0, i64* %4, align 8 + %7 = bitcast [3 x i8]* %6 to i8* + %8 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 8 %8, i64 3, i1 false) + %9 = bitcast %struct.array3* %2 to i8* + %10 = bitcast %struct.array3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 3, i1 false) + %11 = getelementptr inbounds %struct.array3, %struct.array3* %2, i32 0, i32 0 + %12 = bitcast i64* %5 to i8* + %13 = bitcast [3 x i8]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 1 %13, i64 3, i1 false) + %14 = load i64, i64* %5, align 8 + ret i64 %14 +} + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo4(i64 %0) #0 { + %2 = alloca %struct.array4, align 1 + %3 = alloca %struct.array4, align 1 + %4 = alloca i64, align 8 + %5 = alloca i64, align 8 + %6 = getelementptr inbounds %struct.array4, %struct.array4* %3, i32 0, i32 0 + store i64 %0, i64* %4, align 8 + %7 = bitcast [4 x i8]* %6 to i8* + %8 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 8 %8, i64 4, i1 false) + %9 = bitcast %struct.array4* %2 to i8* + %10 = bitcast %struct.array4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 4, i1 false) + %11 = getelementptr inbounds %struct.array4, %struct.array4* %2, i32 0, i32 0 + %12 = bitcast i64* %5 to i8* + %13 = bitcast [4 x i8]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 1 %13, i64 4, i1 false) + %14 = load i64, i64* %5, align 8 + ret i64 %14 +} + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo5(i64 %0) #0 { + %2 = alloca %struct.array5, align 1 + %3 = alloca %struct.array5, align 1 + %4 = alloca i64, align 8 + %5 = alloca i64, align 8 + %6 = getelementptr inbounds %struct.array5, %struct.array5* %3, i32 0, i32 0 + store i64 %0, i64* %4, align 8 + %7 = bitcast [5 x i8]* %6 to i8* + %8 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 8 %8, i64 5, i1 false) + %9 = bitcast %struct.array5* %2 to i8* + %10 = bitcast %struct.array5* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 5, i1 false) + %11 = getelementptr inbounds %struct.array5, %struct.array5* %2, i32 0, i32 0 + %12 = bitcast i64* %5 to i8* + %13 = bitcast [5 x i8]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 1 %13, i64 5, i1 false) + %14 = load i64, i64* %5, align 8 + ret i64 %14 +} + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo6(i64 %0) #0 { + %2 = alloca %struct.array6, align 1 + %3 = alloca %struct.array6, align 1 + %4 = alloca i64, align 8 + %5 = alloca i64, align 8 + %6 = getelementptr inbounds %struct.array6, %struct.array6* %3, i32 0, i32 0 + store i64 %0, i64* %4, align 8 + %7 = bitcast [6 x i8]* %6 to i8* + %8 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 8 %8, i64 6, i1 false) + %9 = bitcast %struct.array6* %2 to i8* + %10 = bitcast %struct.array6* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 6, i1 false) + %11 = getelementptr inbounds %struct.array6, %struct.array6* %2, i32 0, i32 0 + %12 = bitcast i64* %5 to i8* + %13 = bitcast [6 x i8]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 1 %13, i64 6, i1 false) + %14 = load i64, i64* %5, align 8 + ret i64 %14 +} + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo7(i64 %0) #0 { + %2 = alloca %struct.array7, align 1 + %3 = alloca %struct.array7, align 1 + %4 = alloca i64, align 8 + %5 = alloca i64, align 8 + %6 = getelementptr inbounds %struct.array7, %struct.array7* %3, i32 0, i32 0 + store i64 %0, i64* %4, align 8 + %7 = bitcast [7 x i8]* %6 to i8* + %8 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 8 %8, i64 7, i1 false) + %9 = bitcast %struct.array7* %2 to i8* + %10 = bitcast %struct.array7* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 7, i1 false) + %11 = getelementptr inbounds %struct.array7, %struct.array7* %2, i32 0, i32 0 + %12 = bitcast i64* %5 to i8* + %13 = bitcast [7 x i8]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 1 %13, i64 7, i1 false) + %14 = load i64, i64* %5, align 8 + ret i64 %14 +} + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo8(i64 %0) #0 { + %2 = alloca %struct.array8, align 1 + %3 = alloca %struct.array8, align 1 + %4 = getelementptr inbounds %struct.array8, %struct.array8* %3, i32 0, i32 0 + %5 = bitcast [8 x i8]* %4 to i64* + store i64 %0, i64* %5, align 1 + %6 = bitcast %struct.array8* %2 to i8* + %7 = bitcast %struct.array8* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 1 %7, i64 8, i1 false) + %8 = getelementptr inbounds %struct.array8, %struct.array8* %2, i32 0, i32 0 + %9 = bitcast [8 x i8]* %8 to i64* + %10 = load i64, i64* %9, align 1 + ret i64 %10 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo9([2 x i64] %0) #0 { + %2 = alloca %struct.array9, align 1 + %3 = alloca %struct.array9, align 1 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + %6 = getelementptr inbounds %struct.array9, %struct.array9* %3, i32 0, i32 0 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %7 = bitcast [9 x i8]* %6 to i8* + %8 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 8 %8, i64 9, i1 false) + %9 = bitcast %struct.array9* %2 to i8* + %10 = bitcast %struct.array9* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 9, i1 false) + %11 = getelementptr inbounds %struct.array9, %struct.array9* %2, i32 0, i32 0 + %12 = bitcast [2 x i64]* %5 to i8* + %13 = bitcast [9 x i8]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 1 %13, i64 9, i1 false) + %14 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %14 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo10([2 x i64] %0) #0 { + %2 = alloca %struct.array10, align 1 + %3 = alloca %struct.array10, align 1 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + %6 = getelementptr inbounds %struct.array10, %struct.array10* %3, i32 0, i32 0 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %7 = bitcast [10 x i8]* %6 to i8* + %8 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 8 %8, i64 10, i1 false) + %9 = bitcast %struct.array10* %2 to i8* + %10 = bitcast %struct.array10* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 10, i1 false) + %11 = getelementptr inbounds %struct.array10, %struct.array10* %2, i32 0, i32 0 + %12 = bitcast [2 x i64]* %5 to i8* + %13 = bitcast [10 x i8]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 1 %13, i64 10, i1 false) + %14 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %14 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo11([2 x i64] %0) #0 { + %2 = alloca %struct.array11, align 1 + %3 = alloca %struct.array11, align 1 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + %6 = getelementptr inbounds %struct.array11, %struct.array11* %3, i32 0, i32 0 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %7 = bitcast [11 x i8]* %6 to i8* + %8 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 8 %8, i64 11, i1 false) + %9 = bitcast %struct.array11* %2 to i8* + %10 = bitcast %struct.array11* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 11, i1 false) + %11 = getelementptr inbounds %struct.array11, %struct.array11* %2, i32 0, i32 0 + %12 = bitcast [2 x i64]* %5 to i8* + %13 = bitcast [11 x i8]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 1 %13, i64 11, i1 false) + %14 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %14 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo12([2 x i64] %0) #0 { + %2 = alloca %struct.array12, align 1 + %3 = alloca %struct.array12, align 1 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + %6 = getelementptr inbounds %struct.array12, %struct.array12* %3, i32 0, i32 0 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %7 = bitcast [12 x i8]* %6 to i8* + %8 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 8 %8, i64 12, i1 false) + %9 = bitcast %struct.array12* %2 to i8* + %10 = bitcast %struct.array12* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 12, i1 false) + %11 = getelementptr inbounds %struct.array12, %struct.array12* %2, i32 0, i32 0 + %12 = bitcast [2 x i64]* %5 to i8* + %13 = bitcast [12 x i8]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 1 %13, i64 12, i1 false) + %14 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %14 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo13([2 x i64] %0) #0 { + %2 = alloca %struct.array13, align 1 + %3 = alloca %struct.array13, align 1 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + %6 = getelementptr inbounds %struct.array13, %struct.array13* %3, i32 0, i32 0 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %7 = bitcast [13 x i8]* %6 to i8* + %8 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 8 %8, i64 13, i1 false) + %9 = bitcast %struct.array13* %2 to i8* + %10 = bitcast %struct.array13* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 13, i1 false) + %11 = getelementptr inbounds %struct.array13, %struct.array13* %2, i32 0, i32 0 + %12 = bitcast [2 x i64]* %5 to i8* + %13 = bitcast [13 x i8]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 1 %13, i64 13, i1 false) + %14 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %14 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo14([2 x i64] %0) #0 { + %2 = alloca %struct.array14, align 1 + %3 = alloca %struct.array14, align 1 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + %6 = getelementptr inbounds %struct.array14, %struct.array14* %3, i32 0, i32 0 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %7 = bitcast [14 x i8]* %6 to i8* + %8 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 8 %8, i64 14, i1 false) + %9 = bitcast %struct.array14* %2 to i8* + %10 = bitcast %struct.array14* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 14, i1 false) + %11 = getelementptr inbounds %struct.array14, %struct.array14* %2, i32 0, i32 0 + %12 = bitcast [2 x i64]* %5 to i8* + %13 = bitcast [14 x i8]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 1 %13, i64 14, i1 false) + %14 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %14 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo15([2 x i64] %0) #0 { + %2 = alloca %struct.array15, align 1 + %3 = alloca %struct.array15, align 1 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + %6 = getelementptr inbounds %struct.array15, %struct.array15* %3, i32 0, i32 0 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %7 = bitcast [15 x i8]* %6 to i8* + %8 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %7, i8* align 8 %8, i64 15, i1 false) + %9 = bitcast %struct.array15* %2 to i8* + %10 = bitcast %struct.array15* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %9, i8* align 1 %10, i64 15, i1 false) + %11 = getelementptr inbounds %struct.array15, %struct.array15* %2, i32 0, i32 0 + %12 = bitcast [2 x i64]* %5 to i8* + %13 = bitcast [15 x i8]* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 1 %13, i64 15, i1 false) + %14 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %14 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo16([2 x i64] %0) #0 { + %2 = alloca %struct.array16, align 1 + %3 = alloca %struct.array16, align 1 + %4 = getelementptr inbounds %struct.array16, %struct.array16* %3, i32 0, i32 0 + %5 = bitcast [16 x i8]* %4 to [2 x i64]* + store [2 x i64] %0, [2 x i64]* %5, align 1 + %6 = bitcast %struct.array16* %2 to i8* + %7 = bitcast %struct.array16* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 1 %7, i64 16, i1 false) + %8 = getelementptr inbounds %struct.array16, %struct.array16* %2, i32 0, i32 0 + %9 = bitcast [16 x i8]* %8 to [2 x i64]* + %10 = load [2 x i64], [2 x i64]* %9, align 1 + ret [2 x i64] %10 +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 1 %0, %struct.array17* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array17* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array17* %0 to i8* + %6 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %5, i8* align 1 %6, i64 17, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 1 %0, %struct.array18* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array18* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array18* %0 to i8* + %6 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %5, i8* align 1 %6, i64 18, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 1 %0, %struct.array19* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array19* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array19* %0 to i8* + %6 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %5, i8* align 1 %6, i64 19, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 1 %0, %struct.array20* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array20* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array20* %0 to i8* + %6 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %5, i8* align 1 %6, i64 20, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+m,+relax,-save-restore" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3} +!llvm.ident = !{!4} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"target-abi", !"lp64"} +!2 = !{i32 7, !"frame-pointer", i32 2} +!3 = !{i32 1, !"SmallDataLimit", i32 8} +!4 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/riscv64/array_pointer.ll b/internal/cabi/_testdata/arch/riscv64/array_pointer.ll new file mode 100644 index 00000000..e1fe5422 --- /dev/null +++ b/internal/cabi/_testdata/arch/riscv64/array_pointer.ll @@ -0,0 +1,270 @@ +; ModuleID = '../../wrap/array_pointer.c' +source_filename = "../../wrap/array_pointer.c" +target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" +target triple = "riscv64-unknown-unknown-elf" + +%struct.array1 = type { [1 x i8*] } +%struct.array2 = type { [2 x i8*] } +%struct.array3 = type { [3 x i8*] } +%struct.array4 = type { [4 x i8*] } +%struct.array5 = type { [5 x i8*] } +%struct.array6 = type { [6 x i8*] } +%struct.array7 = type { [7 x i8*] } +%struct.array8 = type { [8 x i8*] } +%struct.array9 = type { [9 x i8*] } +%struct.array10 = type { [10 x i8*] } +%struct.array11 = type { [11 x i8*] } +%struct.array12 = type { [12 x i8*] } +%struct.array13 = type { [13 x i8*] } +%struct.array14 = type { [14 x i8*] } +%struct.array15 = type { [15 x i8*] } +%struct.array16 = type { [16 x i8*] } +%struct.array17 = type { [17 x i8*] } +%struct.array18 = type { [18 x i8*] } +%struct.array19 = type { [19 x i8*] } +%struct.array20 = type { [20 x i8*] } + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo1(i64 %0) #0 { + %2 = alloca %struct.array1, align 8 + %3 = alloca %struct.array1, align 8 + %4 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + %5 = bitcast [1 x i8*]* %4 to i64* + store i64 %0, i64* %5, align 8 + %6 = bitcast %struct.array1* %2 to i8* + %7 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %6, i8* align 8 %7, i64 8, i1 false) + %8 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %9 = bitcast [1 x i8*]* %8 to i64* + %10 = load i64, i64* %9, align 8 + ret i64 %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo2([2 x i64] %0) #0 { + %2 = alloca %struct.array2, align 8 + %3 = alloca %struct.array2, align 8 + %4 = getelementptr inbounds %struct.array2, %struct.array2* %3, i32 0, i32 0 + %5 = bitcast [2 x i8*]* %4 to [2 x i64]* + store [2 x i64] %0, [2 x i64]* %5, align 8 + %6 = bitcast %struct.array2* %2 to i8* + %7 = bitcast %struct.array2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %6, i8* align 8 %7, i64 16, i1 false) + %8 = getelementptr inbounds %struct.array2, %struct.array2* %2, i32 0, i32 0 + %9 = bitcast [2 x i8*]* %8 to [2 x i64]* + %10 = load [2 x i64], [2 x i64]* %9, align 8 + ret [2 x i64] %10 +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo3(%struct.array3* noalias sret(%struct.array3) align 8 %0, %struct.array3* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array3* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array3* %0 to i8* + %6 = bitcast %struct.array3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo4(%struct.array4* noalias sret(%struct.array4) align 8 %0, %struct.array4* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array4* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array4* %0 to i8* + %6 = bitcast %struct.array4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 8 %0, %struct.array5* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array5* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array5* %0 to i8* + %6 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 8 %0, %struct.array6* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array6* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array6* %0 to i8* + %6 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 8 %0, %struct.array7* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array7* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array7* %0 to i8* + %6 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 8 %0, %struct.array8* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array8* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array8* %0 to i8* + %6 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 8 %0, %struct.array9* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array9* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array9* %0 to i8* + %6 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 8 %0, %struct.array10* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array10* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array10* %0 to i8* + %6 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 8 %0, %struct.array11* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array11* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array11* %0 to i8* + %6 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 8 %0, %struct.array12* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array12* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array12* %0 to i8* + %6 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 8 %0, %struct.array13* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array13* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array13* %0 to i8* + %6 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 8 %0, %struct.array14* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array14* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array14* %0 to i8* + %6 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 8 %0, %struct.array15* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array15* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array15* %0 to i8* + %6 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 8 %0, %struct.array16* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array16* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array16* %0 to i8* + %6 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 8 %0, %struct.array17* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array17* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array17* %0 to i8* + %6 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 8 %0, %struct.array18* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array18* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array18* %0 to i8* + %6 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 8 %0, %struct.array19* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array19* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array19* %0 to i8* + %6 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 8 %0, %struct.array20* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array20* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array20* %0 to i8* + %6 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+m,+relax,-save-restore" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3} +!llvm.ident = !{!4} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"target-abi", !"lp64"} +!2 = !{i32 7, !"frame-pointer", i32 2} +!3 = !{i32 1, !"SmallDataLimit", i32 8} +!4 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/riscv64/array_uintptr.ll b/internal/cabi/_testdata/arch/riscv64/array_uintptr.ll new file mode 100644 index 00000000..38f3ec58 --- /dev/null +++ b/internal/cabi/_testdata/arch/riscv64/array_uintptr.ll @@ -0,0 +1,270 @@ +; ModuleID = '../../wrap/array_uintptr.c' +source_filename = "../../wrap/array_uintptr.c" +target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" +target triple = "riscv64-unknown-unknown-elf" + +%struct.array1 = type { [1 x i8*] } +%struct.array2 = type { [2 x i8*] } +%struct.array3 = type { [3 x i8*] } +%struct.array4 = type { [4 x i8*] } +%struct.array5 = type { [5 x i8*] } +%struct.array6 = type { [6 x i8*] } +%struct.array7 = type { [7 x i8*] } +%struct.array8 = type { [8 x i8*] } +%struct.array9 = type { [9 x i8*] } +%struct.array10 = type { [10 x i8*] } +%struct.array11 = type { [11 x i8*] } +%struct.array12 = type { [12 x i8*] } +%struct.array13 = type { [13 x i8*] } +%struct.array14 = type { [14 x i8*] } +%struct.array15 = type { [15 x i8*] } +%struct.array16 = type { [16 x i8*] } +%struct.array17 = type { [17 x i8*] } +%struct.array18 = type { [18 x i8*] } +%struct.array19 = type { [19 x i8*] } +%struct.array20 = type { [20 x i8*] } + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo1(i64 %0) #0 { + %2 = alloca %struct.array1, align 8 + %3 = alloca %struct.array1, align 8 + %4 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + %5 = bitcast [1 x i8*]* %4 to i64* + store i64 %0, i64* %5, align 8 + %6 = bitcast %struct.array1* %2 to i8* + %7 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %6, i8* align 8 %7, i64 8, i1 false) + %8 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %9 = bitcast [1 x i8*]* %8 to i64* + %10 = load i64, i64* %9, align 8 + ret i64 %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo2([2 x i64] %0) #0 { + %2 = alloca %struct.array2, align 8 + %3 = alloca %struct.array2, align 8 + %4 = getelementptr inbounds %struct.array2, %struct.array2* %3, i32 0, i32 0 + %5 = bitcast [2 x i8*]* %4 to [2 x i64]* + store [2 x i64] %0, [2 x i64]* %5, align 8 + %6 = bitcast %struct.array2* %2 to i8* + %7 = bitcast %struct.array2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %6, i8* align 8 %7, i64 16, i1 false) + %8 = getelementptr inbounds %struct.array2, %struct.array2* %2, i32 0, i32 0 + %9 = bitcast [2 x i8*]* %8 to [2 x i64]* + %10 = load [2 x i64], [2 x i64]* %9, align 8 + ret [2 x i64] %10 +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo3(%struct.array3* noalias sret(%struct.array3) align 8 %0, %struct.array3* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array3* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array3* %0 to i8* + %6 = bitcast %struct.array3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo4(%struct.array4* noalias sret(%struct.array4) align 8 %0, %struct.array4* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array4* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array4* %0 to i8* + %6 = bitcast %struct.array4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo5(%struct.array5* noalias sret(%struct.array5) align 8 %0, %struct.array5* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array5* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array5* %0 to i8* + %6 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo6(%struct.array6* noalias sret(%struct.array6) align 8 %0, %struct.array6* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array6* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array6* %0 to i8* + %6 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo7(%struct.array7* noalias sret(%struct.array7) align 8 %0, %struct.array7* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array7* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array7* %0 to i8* + %6 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo8(%struct.array8* noalias sret(%struct.array8) align 8 %0, %struct.array8* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array8* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array8* %0 to i8* + %6 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo9(%struct.array9* noalias sret(%struct.array9) align 8 %0, %struct.array9* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array9* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array9* %0 to i8* + %6 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo10(%struct.array10* noalias sret(%struct.array10) align 8 %0, %struct.array10* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array10* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array10* %0 to i8* + %6 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo11(%struct.array11* noalias sret(%struct.array11) align 8 %0, %struct.array11* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array11* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array11* %0 to i8* + %6 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo12(%struct.array12* noalias sret(%struct.array12) align 8 %0, %struct.array12* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array12* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array12* %0 to i8* + %6 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo13(%struct.array13* noalias sret(%struct.array13) align 8 %0, %struct.array13* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array13* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array13* %0 to i8* + %6 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo14(%struct.array14* noalias sret(%struct.array14) align 8 %0, %struct.array14* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array14* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array14* %0 to i8* + %6 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo15(%struct.array15* noalias sret(%struct.array15) align 8 %0, %struct.array15* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array15* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array15* %0 to i8* + %6 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo16(%struct.array16* noalias sret(%struct.array16) align 8 %0, %struct.array16* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array16* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array16* %0 to i8* + %6 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo17(%struct.array17* noalias sret(%struct.array17) align 8 %0, %struct.array17* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array17* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array17* %0 to i8* + %6 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo18(%struct.array18* noalias sret(%struct.array18) align 8 %0, %struct.array18* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array18* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array18* %0 to i8* + %6 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo19(%struct.array19* noalias sret(%struct.array19) align 8 %0, %struct.array19* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array19* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array19* %0 to i8* + %6 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo20(%struct.array20* noalias sret(%struct.array20) align 8 %0, %struct.array20* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.array20* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.array20* %0 to i8* + %6 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+m,+relax,-save-restore" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3} +!llvm.ident = !{!4} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"target-abi", !"lp64"} +!2 = !{i32 7, !"frame-pointer", i32 2} +!3 = !{i32 1, !"SmallDataLimit", i32 8} +!4 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/riscv64/basic.ll b/internal/cabi/_testdata/arch/riscv64/basic.ll new file mode 100644 index 00000000..cb3f49d2 --- /dev/null +++ b/internal/cabi/_testdata/arch/riscv64/basic.ll @@ -0,0 +1,71 @@ +; ModuleID = '../../wrap/basic.c' +source_filename = "../../wrap/basic.c" +target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" +target triple = "riscv64-unknown-unknown-elf" + +; Function Attrs: noinline nounwind optnone +define dso_local zeroext i8 @basic_int8(i8 noundef zeroext %0) #0 { + %2 = alloca i8, align 1 + store i8 %0, i8* %2, align 1 + %3 = load i8, i8* %2, align 1 + ret i8 %3 +} + +; Function Attrs: noinline nounwind optnone +define dso_local signext i16 @basic_int16(i16 noundef signext %0) #0 { + %2 = alloca i16, align 2 + store i16 %0, i16* %2, align 2 + %3 = load i16, i16* %2, align 2 + ret i16 %3 +} + +; Function Attrs: noinline nounwind optnone +define dso_local signext i32 @basic_int32(i32 noundef signext %0) #0 { + %2 = alloca i32, align 4 + store i32 %0, i32* %2, align 4 + %3 = load i32, i32* %2, align 4 + ret i32 %3 +} + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @basic_int64(i64 noundef %0) #0 { + %2 = alloca i64, align 8 + store i64 %0, i64* %2, align 8 + %3 = load i64, i64* %2, align 8 + ret i64 %3 +} + +; Function Attrs: noinline nounwind optnone +define dso_local float @basic_float32(float noundef %0) #0 { + %2 = alloca float, align 4 + store float %0, float* %2, align 4 + %3 = load float, float* %2, align 4 + ret float %3 +} + +; Function Attrs: noinline nounwind optnone +define dso_local double @basic_float64(double noundef %0) #0 { + %2 = alloca double, align 8 + store double %0, double* %2, align 8 + %3 = load double, double* %2, align 8 + ret double %3 +} + +; Function Attrs: noinline nounwind optnone +define dso_local i8* @basic_uintptr(i8* noundef %0) #0 { + %2 = alloca i8*, align 8 + store i8* %0, i8** %2, align 8 + %3 = load i8*, i8** %2, align 8 + ret i8* %3 +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+m,+relax,-save-restore" } + +!llvm.module.flags = !{!0, !1, !2, !3} +!llvm.ident = !{!4} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"target-abi", !"lp64"} +!2 = !{i32 7, !"frame-pointer", i32 2} +!3 = !{i32 1, !"SmallDataLimit", i32 8} +!4 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/riscv64/struct_float32.ll b/internal/cabi/_testdata/arch/riscv64/struct_float32.ll new file mode 100644 index 00000000..d714e387 --- /dev/null +++ b/internal/cabi/_testdata/arch/riscv64/struct_float32.ll @@ -0,0 +1,286 @@ +; ModuleID = '../../wrap/struct_float32.c' +source_filename = "../../wrap/struct_float32.c" +target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" +target triple = "riscv64-unknown-unknown-elf" + +%struct.point1 = type { float } +%struct.point2 = type { float, float } +%struct.point3 = type { float, float, float } +%struct.point4 = type { float, float, float, float } +%struct.point5 = type { float, float, float, float, float } +%struct.point6 = type { float, float, float, float, float, float } +%struct.point7 = type { float, float, float, float, float, float, float } +%struct.point8 = type { float, float, float, float, float, float, float, float } +%struct.point9 = type { float, float, float, float, float, float, float, float, float } +%struct.point10 = type { float, float, float, float, float, float, float, float, float, float } +%struct.point11 = type { float, float, float, float, float, float, float, float, float, float, float } +%struct.point12 = type { float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point13 = type { float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point14 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point15 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point16 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point17 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point18 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point19 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point20 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo1(i64 %0) #0 { + %2 = alloca %struct.point1, align 4 + %3 = alloca %struct.point1, align 4 + %4 = alloca i64, align 8 + %5 = alloca i64, align 8 + %6 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + store i64 %0, i64* %4, align 8 + %7 = bitcast float* %6 to i8* + %8 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %7, i8* align 8 %8, i64 4, i1 false) + %9 = bitcast %struct.point1* %2 to i8* + %10 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %9, i8* align 4 %10, i64 4, i1 false) + %11 = getelementptr inbounds %struct.point1, %struct.point1* %2, i32 0, i32 0 + %12 = bitcast i64* %5 to i8* + %13 = bitcast float* %11 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %12, i8* align 4 %13, i64 4, i1 false) + %14 = load i64, i64* %5, align 8 + ret i64 %14 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo2(i64 %0) #0 { + %2 = alloca %struct.point2, align 4 + %3 = alloca %struct.point2, align 4 + %4 = bitcast %struct.point2* %3 to i64* + store i64 %0, i64* %4, align 4 + %5 = bitcast %struct.point2* %2 to i8* + %6 = bitcast %struct.point2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 8, i1 false) + %7 = bitcast %struct.point2* %2 to i64* + %8 = load i64, i64* %7, align 4 + ret i64 %8 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo3([2 x i64] %0) #0 { + %2 = alloca %struct.point3, align 4 + %3 = alloca %struct.point3, align 4 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %6 = bitcast %struct.point3* %3 to i8* + %7 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %6, i8* align 8 %7, i64 12, i1 false) + %8 = bitcast %struct.point3* %2 to i8* + %9 = bitcast %struct.point3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %8, i8* align 4 %9, i64 12, i1 false) + %10 = bitcast [2 x i64]* %5 to i8* + %11 = bitcast %struct.point3* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 4 %11, i64 12, i1 false) + %12 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %12 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo4([2 x i64] %0) #0 { + %2 = alloca %struct.point4, align 4 + %3 = alloca %struct.point4, align 4 + %4 = bitcast %struct.point4* %3 to [2 x i64]* + store [2 x i64] %0, [2 x i64]* %4, align 4 + %5 = bitcast %struct.point4* %2 to i8* + %6 = bitcast %struct.point4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 16, i1 false) + %7 = bitcast %struct.point4* %2 to [2 x i64]* + %8 = load [2 x i64], [2 x i64]* %7, align 4 + ret [2 x i64] %8 +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo5(%struct.point5* noalias sret(%struct.point5) align 4 %0, %struct.point5* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point5* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point5* %0 to i8* + %6 = bitcast %struct.point5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo6(%struct.point6* noalias sret(%struct.point6) align 4 %0, %struct.point6* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point6* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point6* %0 to i8* + %6 = bitcast %struct.point6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo7(%struct.point7* noalias sret(%struct.point7) align 4 %0, %struct.point7* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point7* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point7* %0 to i8* + %6 = bitcast %struct.point7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo8(%struct.point8* noalias sret(%struct.point8) align 4 %0, %struct.point8* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point8* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point8* %0 to i8* + %6 = bitcast %struct.point8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 4 %0, %struct.point9* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point9* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point9* %0 to i8* + %6 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 4 %0, %struct.point10* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point10* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point10* %0 to i8* + %6 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 4 %0, %struct.point11* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point11* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point11* %0 to i8* + %6 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 4 %0, %struct.point12* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point12* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point12* %0 to i8* + %6 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 4 %0, %struct.point13* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point13* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point13* %0 to i8* + %6 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 4 %0, %struct.point14* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point14* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point14* %0 to i8* + %6 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 4 %0, %struct.point15* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point15* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point15* %0 to i8* + %6 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 4 %0, %struct.point16* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point16* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point16* %0 to i8* + %6 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 4 %0, %struct.point17* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point17* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point17* %0 to i8* + %6 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 4 %0, %struct.point18* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point18* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point18* %0 to i8* + %6 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 4 %0, %struct.point19* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point19* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point19* %0 to i8* + %6 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 4 %0, %struct.point20* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point20* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point20* %0 to i8* + %6 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+m,+relax,-save-restore" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3} +!llvm.ident = !{!4} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"target-abi", !"lp64"} +!2 = !{i32 7, !"frame-pointer", i32 2} +!3 = !{i32 1, !"SmallDataLimit", i32 8} +!4 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/riscv64/struct_float64.ll b/internal/cabi/_testdata/arch/riscv64/struct_float64.ll new file mode 100644 index 00000000..baecec8d --- /dev/null +++ b/internal/cabi/_testdata/arch/riscv64/struct_float64.ll @@ -0,0 +1,268 @@ +; ModuleID = '../../wrap/struct_float64.c' +source_filename = "../../wrap/struct_float64.c" +target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" +target triple = "riscv64-unknown-unknown-elf" + +%struct.point1 = type { double } +%struct.point2 = type { double, double } +%struct.point3 = type { double, double, double } +%struct.point4 = type { double, double, double, double } +%struct.point5 = type { double, double, double, double, double } +%struct.point6 = type { double, double, double, double, double, double } +%struct.point7 = type { double, double, double, double, double, double, double } +%struct.point8 = type { double, double, double, double, double, double, double, double } +%struct.point9 = type { double, double, double, double, double, double, double, double, double } +%struct.point10 = type { double, double, double, double, double, double, double, double, double, double } +%struct.point11 = type { double, double, double, double, double, double, double, double, double, double, double } +%struct.point12 = type { double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point13 = type { double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point14 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point15 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point16 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point17 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point18 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point19 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point20 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo1(i64 %0) #0 { + %2 = alloca %struct.point1, align 8 + %3 = alloca %struct.point1, align 8 + %4 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + %5 = bitcast double* %4 to i64* + store i64 %0, i64* %5, align 8 + %6 = bitcast %struct.point1* %2 to i8* + %7 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %6, i8* align 8 %7, i64 8, i1 false) + %8 = getelementptr inbounds %struct.point1, %struct.point1* %2, i32 0, i32 0 + %9 = bitcast double* %8 to i64* + %10 = load i64, i64* %9, align 8 + ret i64 %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo2([2 x i64] %0) #0 { + %2 = alloca %struct.point2, align 8 + %3 = alloca %struct.point2, align 8 + %4 = bitcast %struct.point2* %3 to [2 x i64]* + store [2 x i64] %0, [2 x i64]* %4, align 8 + %5 = bitcast %struct.point2* %2 to i8* + %6 = bitcast %struct.point2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 16, i1 false) + %7 = bitcast %struct.point2* %2 to [2 x i64]* + %8 = load [2 x i64], [2 x i64]* %7, align 8 + ret [2 x i64] %8 +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo3(%struct.point3* noalias sret(%struct.point3) align 8 %0, %struct.point3* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point3* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point3* %0 to i8* + %6 = bitcast %struct.point3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo4(%struct.point4* noalias sret(%struct.point4) align 8 %0, %struct.point4* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point4* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point4* %0 to i8* + %6 = bitcast %struct.point4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo5(%struct.point5* noalias sret(%struct.point5) align 8 %0, %struct.point5* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point5* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point5* %0 to i8* + %6 = bitcast %struct.point5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo6(%struct.point6* noalias sret(%struct.point6) align 8 %0, %struct.point6* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point6* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point6* %0 to i8* + %6 = bitcast %struct.point6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo7(%struct.point7* noalias sret(%struct.point7) align 8 %0, %struct.point7* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point7* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point7* %0 to i8* + %6 = bitcast %struct.point7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo8(%struct.point8* noalias sret(%struct.point8) align 8 %0, %struct.point8* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point8* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point8* %0 to i8* + %6 = bitcast %struct.point8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 8 %0, %struct.point9* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point9* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point9* %0 to i8* + %6 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 8 %0, %struct.point10* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point10* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point10* %0 to i8* + %6 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 8 %0, %struct.point11* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point11* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point11* %0 to i8* + %6 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 8 %0, %struct.point12* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point12* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point12* %0 to i8* + %6 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 8 %0, %struct.point13* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point13* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point13* %0 to i8* + %6 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 8 %0, %struct.point14* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point14* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point14* %0 to i8* + %6 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 8 %0, %struct.point15* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point15* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point15* %0 to i8* + %6 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 8 %0, %struct.point16* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point16* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point16* %0 to i8* + %6 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 8 %0, %struct.point17* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point17* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point17* %0 to i8* + %6 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 8 %0, %struct.point18* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point18* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point18* %0 to i8* + %6 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 8 %0, %struct.point19* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point19* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point19* %0 to i8* + %6 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 8 %0, %struct.point20* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point20* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point20* %0 to i8* + %6 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+m,+relax,-save-restore" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3} +!llvm.ident = !{!4} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"target-abi", !"lp64"} +!2 = !{i32 7, !"frame-pointer", i32 2} +!3 = !{i32 1, !"SmallDataLimit", i32 8} +!4 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/riscv64/struct_int16.ll b/internal/cabi/_testdata/arch/riscv64/struct_int16.ll new file mode 100644 index 00000000..b90054bb --- /dev/null +++ b/internal/cabi/_testdata/arch/riscv64/struct_int16.ll @@ -0,0 +1,316 @@ +; ModuleID = '../../wrap/struct_int16.c' +source_filename = "../../wrap/struct_int16.c" +target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" +target triple = "riscv64-unknown-unknown-elf" + +%struct.point1 = type { i16 } +%struct.point2 = type { i16, i16 } +%struct.point3 = type { i16, i16, i16 } +%struct.point4 = type { i16, i16, i16, i16 } +%struct.point5 = type { i16, i16, i16, i16, i16 } +%struct.point6 = type { i16, i16, i16, i16, i16, i16 } +%struct.point7 = type { i16, i16, i16, i16, i16, i16, i16 } +%struct.point8 = type { i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point9 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point10 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point11 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point12 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point13 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point14 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point15 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point16 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point17 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point18 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point19 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point20 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo1(i64 %0) #0 { + %2 = alloca %struct.point1, align 2 + %3 = alloca %struct.point1, align 2 + %4 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + %5 = trunc i64 %0 to i16 + store i16 %5, i16* %4, align 2 + %6 = bitcast %struct.point1* %2 to i8* + %7 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %6, i8* align 2 %7, i64 2, i1 false) + %8 = getelementptr inbounds %struct.point1, %struct.point1* %2, i32 0, i32 0 + %9 = load i16, i16* %8, align 2 + %10 = zext i16 %9 to i64 + ret i64 %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo2(i64 %0) #0 { + %2 = alloca %struct.point2, align 2 + %3 = alloca %struct.point2, align 2 + %4 = alloca i64, align 8 + %5 = alloca i64, align 8 + store i64 %0, i64* %4, align 8 + %6 = bitcast %struct.point2* %3 to i8* + %7 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %6, i8* align 8 %7, i64 4, i1 false) + %8 = bitcast %struct.point2* %2 to i8* + %9 = bitcast %struct.point2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %8, i8* align 2 %9, i64 4, i1 false) + %10 = bitcast i64* %5 to i8* + %11 = bitcast %struct.point2* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 2 %11, i64 4, i1 false) + %12 = load i64, i64* %5, align 8 + ret i64 %12 +} + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo3(i64 %0) #0 { + %2 = alloca %struct.point3, align 2 + %3 = alloca %struct.point3, align 2 + %4 = alloca i64, align 8 + %5 = alloca i64, align 8 + store i64 %0, i64* %4, align 8 + %6 = bitcast %struct.point3* %3 to i8* + %7 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %6, i8* align 8 %7, i64 6, i1 false) + %8 = bitcast %struct.point3* %2 to i8* + %9 = bitcast %struct.point3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %8, i8* align 2 %9, i64 6, i1 false) + %10 = bitcast i64* %5 to i8* + %11 = bitcast %struct.point3* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 2 %11, i64 6, i1 false) + %12 = load i64, i64* %5, align 8 + ret i64 %12 +} + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo4(i64 %0) #0 { + %2 = alloca %struct.point4, align 2 + %3 = alloca %struct.point4, align 2 + %4 = bitcast %struct.point4* %3 to i64* + store i64 %0, i64* %4, align 2 + %5 = bitcast %struct.point4* %2 to i8* + %6 = bitcast %struct.point4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 8, i1 false) + %7 = bitcast %struct.point4* %2 to i64* + %8 = load i64, i64* %7, align 2 + ret i64 %8 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo5([2 x i64] %0) #0 { + %2 = alloca %struct.point5, align 2 + %3 = alloca %struct.point5, align 2 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %6 = bitcast %struct.point5* %3 to i8* + %7 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %6, i8* align 8 %7, i64 10, i1 false) + %8 = bitcast %struct.point5* %2 to i8* + %9 = bitcast %struct.point5* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %8, i8* align 2 %9, i64 10, i1 false) + %10 = bitcast [2 x i64]* %5 to i8* + %11 = bitcast %struct.point5* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 2 %11, i64 10, i1 false) + %12 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %12 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo6([2 x i64] %0) #0 { + %2 = alloca %struct.point6, align 2 + %3 = alloca %struct.point6, align 2 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %6 = bitcast %struct.point6* %3 to i8* + %7 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %6, i8* align 8 %7, i64 12, i1 false) + %8 = bitcast %struct.point6* %2 to i8* + %9 = bitcast %struct.point6* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %8, i8* align 2 %9, i64 12, i1 false) + %10 = bitcast [2 x i64]* %5 to i8* + %11 = bitcast %struct.point6* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 2 %11, i64 12, i1 false) + %12 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %12 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo7([2 x i64] %0) #0 { + %2 = alloca %struct.point7, align 2 + %3 = alloca %struct.point7, align 2 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %6 = bitcast %struct.point7* %3 to i8* + %7 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %6, i8* align 8 %7, i64 14, i1 false) + %8 = bitcast %struct.point7* %2 to i8* + %9 = bitcast %struct.point7* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %8, i8* align 2 %9, i64 14, i1 false) + %10 = bitcast [2 x i64]* %5 to i8* + %11 = bitcast %struct.point7* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 2 %11, i64 14, i1 false) + %12 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %12 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo8([2 x i64] %0) #0 { + %2 = alloca %struct.point8, align 2 + %3 = alloca %struct.point8, align 2 + %4 = bitcast %struct.point8* %3 to [2 x i64]* + store [2 x i64] %0, [2 x i64]* %4, align 2 + %5 = bitcast %struct.point8* %2 to i8* + %6 = bitcast %struct.point8* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 16, i1 false) + %7 = bitcast %struct.point8* %2 to [2 x i64]* + %8 = load [2 x i64], [2 x i64]* %7, align 2 + ret [2 x i64] %8 +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 2 %0, %struct.point9* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point9* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point9* %0 to i8* + %6 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 18, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 2 %0, %struct.point10* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point10* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point10* %0 to i8* + %6 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 2 %0, %struct.point11* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point11* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point11* %0 to i8* + %6 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 22, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 2 %0, %struct.point12* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point12* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point12* %0 to i8* + %6 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 2 %0, %struct.point13* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point13* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point13* %0 to i8* + %6 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 26, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 2 %0, %struct.point14* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point14* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point14* %0 to i8* + %6 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 2 %0, %struct.point15* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point15* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point15* %0 to i8* + %6 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 30, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 2 %0, %struct.point16* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point16* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point16* %0 to i8* + %6 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 2 %0, %struct.point17* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point17* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point17* %0 to i8* + %6 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 34, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 2 %0, %struct.point18* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point18* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point18* %0 to i8* + %6 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 2 %0, %struct.point19* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point19* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point19* %0 to i8* + %6 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 38, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 2 %0, %struct.point20* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point20* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point20* %0 to i8* + %6 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 40, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+m,+relax,-save-restore" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3} +!llvm.ident = !{!4} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"target-abi", !"lp64"} +!2 = !{i32 7, !"frame-pointer", i32 2} +!3 = !{i32 1, !"SmallDataLimit", i32 8} +!4 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/riscv64/struct_int32.ll b/internal/cabi/_testdata/arch/riscv64/struct_int32.ll new file mode 100644 index 00000000..07011f89 --- /dev/null +++ b/internal/cabi/_testdata/arch/riscv64/struct_int32.ll @@ -0,0 +1,280 @@ +; ModuleID = '../../wrap/struct_int32.c' +source_filename = "../../wrap/struct_int32.c" +target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" +target triple = "riscv64-unknown-unknown-elf" + +%struct.point1 = type { i32 } +%struct.point2 = type { i32, i32 } +%struct.point3 = type { i32, i32, i32 } +%struct.point4 = type { i32, i32, i32, i32 } +%struct.point5 = type { i32, i32, i32, i32, i32 } +%struct.point6 = type { i32, i32, i32, i32, i32, i32 } +%struct.point7 = type { i32, i32, i32, i32, i32, i32, i32 } +%struct.point8 = type { i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point9 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point10 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point11 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point12 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point13 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point14 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point15 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point16 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point17 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point18 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point19 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point20 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo1(i64 %0) #0 { + %2 = alloca %struct.point1, align 4 + %3 = alloca %struct.point1, align 4 + %4 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + %5 = trunc i64 %0 to i32 + store i32 %5, i32* %4, align 4 + %6 = bitcast %struct.point1* %2 to i8* + %7 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %6, i8* align 4 %7, i64 4, i1 false) + %8 = getelementptr inbounds %struct.point1, %struct.point1* %2, i32 0, i32 0 + %9 = load i32, i32* %8, align 4 + %10 = zext i32 %9 to i64 + ret i64 %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo2(i64 %0) #0 { + %2 = alloca %struct.point2, align 4 + %3 = alloca %struct.point2, align 4 + %4 = bitcast %struct.point2* %3 to i64* + store i64 %0, i64* %4, align 4 + %5 = bitcast %struct.point2* %2 to i8* + %6 = bitcast %struct.point2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 8, i1 false) + %7 = bitcast %struct.point2* %2 to i64* + %8 = load i64, i64* %7, align 4 + ret i64 %8 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo3([2 x i64] %0) #0 { + %2 = alloca %struct.point3, align 4 + %3 = alloca %struct.point3, align 4 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %6 = bitcast %struct.point3* %3 to i8* + %7 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %6, i8* align 8 %7, i64 12, i1 false) + %8 = bitcast %struct.point3* %2 to i8* + %9 = bitcast %struct.point3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %8, i8* align 4 %9, i64 12, i1 false) + %10 = bitcast [2 x i64]* %5 to i8* + %11 = bitcast %struct.point3* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 4 %11, i64 12, i1 false) + %12 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %12 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo4([2 x i64] %0) #0 { + %2 = alloca %struct.point4, align 4 + %3 = alloca %struct.point4, align 4 + %4 = bitcast %struct.point4* %3 to [2 x i64]* + store [2 x i64] %0, [2 x i64]* %4, align 4 + %5 = bitcast %struct.point4* %2 to i8* + %6 = bitcast %struct.point4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 16, i1 false) + %7 = bitcast %struct.point4* %2 to [2 x i64]* + %8 = load [2 x i64], [2 x i64]* %7, align 4 + ret [2 x i64] %8 +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo5(%struct.point5* noalias sret(%struct.point5) align 4 %0, %struct.point5* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point5* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point5* %0 to i8* + %6 = bitcast %struct.point5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo6(%struct.point6* noalias sret(%struct.point6) align 4 %0, %struct.point6* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point6* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point6* %0 to i8* + %6 = bitcast %struct.point6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo7(%struct.point7* noalias sret(%struct.point7) align 4 %0, %struct.point7* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point7* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point7* %0 to i8* + %6 = bitcast %struct.point7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo8(%struct.point8* noalias sret(%struct.point8) align 4 %0, %struct.point8* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point8* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point8* %0 to i8* + %6 = bitcast %struct.point8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 4 %0, %struct.point9* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point9* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point9* %0 to i8* + %6 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 4 %0, %struct.point10* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point10* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point10* %0 to i8* + %6 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 4 %0, %struct.point11* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point11* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point11* %0 to i8* + %6 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 4 %0, %struct.point12* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point12* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point12* %0 to i8* + %6 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 4 %0, %struct.point13* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point13* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point13* %0 to i8* + %6 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 4 %0, %struct.point14* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point14* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point14* %0 to i8* + %6 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 4 %0, %struct.point15* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point15* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point15* %0 to i8* + %6 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 4 %0, %struct.point16* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point16* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point16* %0 to i8* + %6 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 4 %0, %struct.point17* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point17* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point17* %0 to i8* + %6 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 4 %0, %struct.point18* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point18* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point18* %0 to i8* + %6 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 4 %0, %struct.point19* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point19* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point19* %0 to i8* + %6 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 4 %0, %struct.point20* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point20* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point20* %0 to i8* + %6 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+m,+relax,-save-restore" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3} +!llvm.ident = !{!4} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"target-abi", !"lp64"} +!2 = !{i32 7, !"frame-pointer", i32 2} +!3 = !{i32 1, !"SmallDataLimit", i32 8} +!4 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/riscv64/struct_int64.ll b/internal/cabi/_testdata/arch/riscv64/struct_int64.ll new file mode 100644 index 00000000..e63988f6 --- /dev/null +++ b/internal/cabi/_testdata/arch/riscv64/struct_int64.ll @@ -0,0 +1,266 @@ +; ModuleID = '../../wrap/struct_int64.c' +source_filename = "../../wrap/struct_int64.c" +target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" +target triple = "riscv64-unknown-unknown-elf" + +%struct.point1 = type { i64 } +%struct.point2 = type { i64, i64 } +%struct.point3 = type { i64, i64, i64 } +%struct.point4 = type { i64, i64, i64, i64 } +%struct.point5 = type { i64, i64, i64, i64, i64 } +%struct.point6 = type { i64, i64, i64, i64, i64, i64 } +%struct.point7 = type { i64, i64, i64, i64, i64, i64, i64 } +%struct.point8 = type { i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point9 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point10 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point11 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point12 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point13 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point14 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point15 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point16 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point17 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point18 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point19 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point20 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo1(i64 %0) #0 { + %2 = alloca %struct.point1, align 8 + %3 = alloca %struct.point1, align 8 + %4 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + store i64 %0, i64* %4, align 8 + %5 = bitcast %struct.point1* %2 to i8* + %6 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 8, i1 false) + %7 = getelementptr inbounds %struct.point1, %struct.point1* %2, i32 0, i32 0 + %8 = load i64, i64* %7, align 8 + ret i64 %8 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo2([2 x i64] %0) #0 { + %2 = alloca %struct.point2, align 8 + %3 = alloca %struct.point2, align 8 + %4 = bitcast %struct.point2* %3 to [2 x i64]* + store [2 x i64] %0, [2 x i64]* %4, align 8 + %5 = bitcast %struct.point2* %2 to i8* + %6 = bitcast %struct.point2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 16, i1 false) + %7 = bitcast %struct.point2* %2 to [2 x i64]* + %8 = load [2 x i64], [2 x i64]* %7, align 8 + ret [2 x i64] %8 +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo3(%struct.point3* noalias sret(%struct.point3) align 8 %0, %struct.point3* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point3* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point3* %0 to i8* + %6 = bitcast %struct.point3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo4(%struct.point4* noalias sret(%struct.point4) align 8 %0, %struct.point4* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point4* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point4* %0 to i8* + %6 = bitcast %struct.point4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo5(%struct.point5* noalias sret(%struct.point5) align 8 %0, %struct.point5* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point5* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point5* %0 to i8* + %6 = bitcast %struct.point5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo6(%struct.point6* noalias sret(%struct.point6) align 8 %0, %struct.point6* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point6* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point6* %0 to i8* + %6 = bitcast %struct.point6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo7(%struct.point7* noalias sret(%struct.point7) align 8 %0, %struct.point7* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point7* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point7* %0 to i8* + %6 = bitcast %struct.point7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo8(%struct.point8* noalias sret(%struct.point8) align 8 %0, %struct.point8* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point8* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point8* %0 to i8* + %6 = bitcast %struct.point8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 8 %0, %struct.point9* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point9* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point9* %0 to i8* + %6 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 8 %0, %struct.point10* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point10* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point10* %0 to i8* + %6 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 8 %0, %struct.point11* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point11* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point11* %0 to i8* + %6 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 8 %0, %struct.point12* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point12* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point12* %0 to i8* + %6 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 8 %0, %struct.point13* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point13* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point13* %0 to i8* + %6 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 8 %0, %struct.point14* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point14* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point14* %0 to i8* + %6 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 8 %0, %struct.point15* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point15* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point15* %0 to i8* + %6 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 8 %0, %struct.point16* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point16* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point16* %0 to i8* + %6 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 8 %0, %struct.point17* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point17* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point17* %0 to i8* + %6 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 8 %0, %struct.point18* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point18* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point18* %0 to i8* + %6 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 8 %0, %struct.point19* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point19* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point19* %0 to i8* + %6 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 8 %0, %struct.point20* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point20* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point20* %0 to i8* + %6 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+m,+relax,-save-restore" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3} +!llvm.ident = !{!4} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"target-abi", !"lp64"} +!2 = !{i32 7, !"frame-pointer", i32 2} +!3 = !{i32 1, !"SmallDataLimit", i32 8} +!4 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/riscv64/struct_int8.ll b/internal/cabi/_testdata/arch/riscv64/struct_int8.ll new file mode 100644 index 00000000..3d752b42 --- /dev/null +++ b/internal/cabi/_testdata/arch/riscv64/struct_int8.ll @@ -0,0 +1,388 @@ +; ModuleID = '../../wrap/struct_int8.c' +source_filename = "../../wrap/struct_int8.c" +target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" +target triple = "riscv64-unknown-unknown-elf" + +%struct.point1 = type { i8 } +%struct.point2 = type { i8, i8 } +%struct.point3 = type { i8, i8, i8 } +%struct.point4 = type { i8, i8, i8, i8 } +%struct.point5 = type { i8, i8, i8, i8, i8 } +%struct.point6 = type { i8, i8, i8, i8, i8, i8 } +%struct.point7 = type { i8, i8, i8, i8, i8, i8, i8 } +%struct.point8 = type { i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point9 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point10 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point11 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point12 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point13 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point14 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point15 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point16 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point17 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point18 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point19 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point20 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo1(i64 %0) #0 { + %2 = alloca %struct.point1, align 1 + %3 = alloca %struct.point1, align 1 + %4 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + %5 = trunc i64 %0 to i8 + store i8 %5, i8* %4, align 1 + %6 = bitcast %struct.point1* %2 to i8* + %7 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 1 %7, i64 1, i1 false) + %8 = getelementptr inbounds %struct.point1, %struct.point1* %2, i32 0, i32 0 + %9 = load i8, i8* %8, align 1 + %10 = zext i8 %9 to i64 + ret i64 %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo2(i64 %0) #0 { + %2 = alloca %struct.point2, align 1 + %3 = alloca %struct.point2, align 1 + %4 = alloca i64, align 8 + %5 = alloca i64, align 8 + store i64 %0, i64* %4, align 8 + %6 = bitcast %struct.point2* %3 to i8* + %7 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 8 %7, i64 2, i1 false) + %8 = bitcast %struct.point2* %2 to i8* + %9 = bitcast %struct.point2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 2, i1 false) + %10 = bitcast i64* %5 to i8* + %11 = bitcast %struct.point2* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 1 %11, i64 2, i1 false) + %12 = load i64, i64* %5, align 8 + ret i64 %12 +} + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo3(i64 %0) #0 { + %2 = alloca %struct.point3, align 1 + %3 = alloca %struct.point3, align 1 + %4 = alloca i64, align 8 + %5 = alloca i64, align 8 + store i64 %0, i64* %4, align 8 + %6 = bitcast %struct.point3* %3 to i8* + %7 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 8 %7, i64 3, i1 false) + %8 = bitcast %struct.point3* %2 to i8* + %9 = bitcast %struct.point3* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 3, i1 false) + %10 = bitcast i64* %5 to i8* + %11 = bitcast %struct.point3* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 1 %11, i64 3, i1 false) + %12 = load i64, i64* %5, align 8 + ret i64 %12 +} + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo4(i64 %0) #0 { + %2 = alloca %struct.point4, align 1 + %3 = alloca %struct.point4, align 1 + %4 = alloca i64, align 8 + %5 = alloca i64, align 8 + store i64 %0, i64* %4, align 8 + %6 = bitcast %struct.point4* %3 to i8* + %7 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 8 %7, i64 4, i1 false) + %8 = bitcast %struct.point4* %2 to i8* + %9 = bitcast %struct.point4* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 4, i1 false) + %10 = bitcast i64* %5 to i8* + %11 = bitcast %struct.point4* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 1 %11, i64 4, i1 false) + %12 = load i64, i64* %5, align 8 + ret i64 %12 +} + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo5(i64 %0) #0 { + %2 = alloca %struct.point5, align 1 + %3 = alloca %struct.point5, align 1 + %4 = alloca i64, align 8 + %5 = alloca i64, align 8 + store i64 %0, i64* %4, align 8 + %6 = bitcast %struct.point5* %3 to i8* + %7 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 8 %7, i64 5, i1 false) + %8 = bitcast %struct.point5* %2 to i8* + %9 = bitcast %struct.point5* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 5, i1 false) + %10 = bitcast i64* %5 to i8* + %11 = bitcast %struct.point5* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 1 %11, i64 5, i1 false) + %12 = load i64, i64* %5, align 8 + ret i64 %12 +} + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo6(i64 %0) #0 { + %2 = alloca %struct.point6, align 1 + %3 = alloca %struct.point6, align 1 + %4 = alloca i64, align 8 + %5 = alloca i64, align 8 + store i64 %0, i64* %4, align 8 + %6 = bitcast %struct.point6* %3 to i8* + %7 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 8 %7, i64 6, i1 false) + %8 = bitcast %struct.point6* %2 to i8* + %9 = bitcast %struct.point6* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 6, i1 false) + %10 = bitcast i64* %5 to i8* + %11 = bitcast %struct.point6* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 1 %11, i64 6, i1 false) + %12 = load i64, i64* %5, align 8 + ret i64 %12 +} + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo7(i64 %0) #0 { + %2 = alloca %struct.point7, align 1 + %3 = alloca %struct.point7, align 1 + %4 = alloca i64, align 8 + %5 = alloca i64, align 8 + store i64 %0, i64* %4, align 8 + %6 = bitcast %struct.point7* %3 to i8* + %7 = bitcast i64* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 8 %7, i64 7, i1 false) + %8 = bitcast %struct.point7* %2 to i8* + %9 = bitcast %struct.point7* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 7, i1 false) + %10 = bitcast i64* %5 to i8* + %11 = bitcast %struct.point7* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 1 %11, i64 7, i1 false) + %12 = load i64, i64* %5, align 8 + ret i64 %12 +} + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo8(i64 %0) #0 { + %2 = alloca %struct.point8, align 1 + %3 = alloca %struct.point8, align 1 + %4 = bitcast %struct.point8* %3 to i64* + store i64 %0, i64* %4, align 1 + %5 = bitcast %struct.point8* %2 to i8* + %6 = bitcast %struct.point8* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %5, i8* align 1 %6, i64 8, i1 false) + %7 = bitcast %struct.point8* %2 to i64* + %8 = load i64, i64* %7, align 1 + ret i64 %8 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo9([2 x i64] %0) #0 { + %2 = alloca %struct.point9, align 1 + %3 = alloca %struct.point9, align 1 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %6 = bitcast %struct.point9* %3 to i8* + %7 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 8 %7, i64 9, i1 false) + %8 = bitcast %struct.point9* %2 to i8* + %9 = bitcast %struct.point9* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 9, i1 false) + %10 = bitcast [2 x i64]* %5 to i8* + %11 = bitcast %struct.point9* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 1 %11, i64 9, i1 false) + %12 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %12 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo10([2 x i64] %0) #0 { + %2 = alloca %struct.point10, align 1 + %3 = alloca %struct.point10, align 1 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %6 = bitcast %struct.point10* %3 to i8* + %7 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 8 %7, i64 10, i1 false) + %8 = bitcast %struct.point10* %2 to i8* + %9 = bitcast %struct.point10* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 10, i1 false) + %10 = bitcast [2 x i64]* %5 to i8* + %11 = bitcast %struct.point10* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 1 %11, i64 10, i1 false) + %12 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %12 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo11([2 x i64] %0) #0 { + %2 = alloca %struct.point11, align 1 + %3 = alloca %struct.point11, align 1 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %6 = bitcast %struct.point11* %3 to i8* + %7 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 8 %7, i64 11, i1 false) + %8 = bitcast %struct.point11* %2 to i8* + %9 = bitcast %struct.point11* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 11, i1 false) + %10 = bitcast [2 x i64]* %5 to i8* + %11 = bitcast %struct.point11* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 1 %11, i64 11, i1 false) + %12 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %12 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo12([2 x i64] %0) #0 { + %2 = alloca %struct.point12, align 1 + %3 = alloca %struct.point12, align 1 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %6 = bitcast %struct.point12* %3 to i8* + %7 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 8 %7, i64 12, i1 false) + %8 = bitcast %struct.point12* %2 to i8* + %9 = bitcast %struct.point12* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 12, i1 false) + %10 = bitcast [2 x i64]* %5 to i8* + %11 = bitcast %struct.point12* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 1 %11, i64 12, i1 false) + %12 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %12 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo13([2 x i64] %0) #0 { + %2 = alloca %struct.point13, align 1 + %3 = alloca %struct.point13, align 1 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %6 = bitcast %struct.point13* %3 to i8* + %7 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 8 %7, i64 13, i1 false) + %8 = bitcast %struct.point13* %2 to i8* + %9 = bitcast %struct.point13* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 13, i1 false) + %10 = bitcast [2 x i64]* %5 to i8* + %11 = bitcast %struct.point13* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 1 %11, i64 13, i1 false) + %12 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %12 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo14([2 x i64] %0) #0 { + %2 = alloca %struct.point14, align 1 + %3 = alloca %struct.point14, align 1 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %6 = bitcast %struct.point14* %3 to i8* + %7 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 8 %7, i64 14, i1 false) + %8 = bitcast %struct.point14* %2 to i8* + %9 = bitcast %struct.point14* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 14, i1 false) + %10 = bitcast [2 x i64]* %5 to i8* + %11 = bitcast %struct.point14* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 1 %11, i64 14, i1 false) + %12 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %12 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo15([2 x i64] %0) #0 { + %2 = alloca %struct.point15, align 1 + %3 = alloca %struct.point15, align 1 + %4 = alloca [2 x i64], align 8 + %5 = alloca [2 x i64], align 8 + store [2 x i64] %0, [2 x i64]* %4, align 8 + %6 = bitcast %struct.point15* %3 to i8* + %7 = bitcast [2 x i64]* %4 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %6, i8* align 8 %7, i64 15, i1 false) + %8 = bitcast %struct.point15* %2 to i8* + %9 = bitcast %struct.point15* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %9, i64 15, i1 false) + %10 = bitcast [2 x i64]* %5 to i8* + %11 = bitcast %struct.point15* %2 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 1 %11, i64 15, i1 false) + %12 = load [2 x i64], [2 x i64]* %5, align 8 + ret [2 x i64] %12 +} + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo16([2 x i64] %0) #0 { + %2 = alloca %struct.point16, align 1 + %3 = alloca %struct.point16, align 1 + %4 = bitcast %struct.point16* %3 to [2 x i64]* + store [2 x i64] %0, [2 x i64]* %4, align 1 + %5 = bitcast %struct.point16* %2 to i8* + %6 = bitcast %struct.point16* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %5, i8* align 1 %6, i64 16, i1 false) + %7 = bitcast %struct.point16* %2 to [2 x i64]* + %8 = load [2 x i64], [2 x i64]* %7, align 1 + ret [2 x i64] %8 +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 1 %0, %struct.point17* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point17* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point17* %0 to i8* + %6 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %5, i8* align 1 %6, i64 17, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 1 %0, %struct.point18* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point18* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point18* %0 to i8* + %6 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %5, i8* align 1 %6, i64 18, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 1 %0, %struct.point19* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point19* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point19* %0 to i8* + %6 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %5, i8* align 1 %6, i64 19, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 1 %0, %struct.point20* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point20* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point20* %0 to i8* + %6 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %5, i8* align 1 %6, i64 20, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+m,+relax,-save-restore" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3} +!llvm.ident = !{!4} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"target-abi", !"lp64"} +!2 = !{i32 7, !"frame-pointer", i32 2} +!3 = !{i32 1, !"SmallDataLimit", i32 8} +!4 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/riscv64/struct_uintptr.ll b/internal/cabi/_testdata/arch/riscv64/struct_uintptr.ll new file mode 100644 index 00000000..692bf23b --- /dev/null +++ b/internal/cabi/_testdata/arch/riscv64/struct_uintptr.ll @@ -0,0 +1,268 @@ +; ModuleID = '../../wrap/struct_uintptr.c' +source_filename = "../../wrap/struct_uintptr.c" +target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" +target triple = "riscv64-unknown-unknown-elf" + +%struct.point1 = type { i8* } +%struct.point2 = type { i8*, i8* } +%struct.point3 = type { i8*, i8*, i8* } +%struct.point4 = type { i8*, i8*, i8*, i8* } +%struct.point5 = type { i8*, i8*, i8*, i8*, i8* } +%struct.point6 = type { i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point7 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point8 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point9 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point10 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point11 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point12 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point13 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point14 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point15 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point16 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point17 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point18 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point19 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point20 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } + +; Function Attrs: noinline nounwind optnone +define dso_local i64 @demo1(i64 %0) #0 { + %2 = alloca %struct.point1, align 8 + %3 = alloca %struct.point1, align 8 + %4 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + %5 = inttoptr i64 %0 to i8* + store i8* %5, i8** %4, align 8 + %6 = bitcast %struct.point1* %2 to i8* + %7 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %6, i8* align 8 %7, i64 8, i1 false) + %8 = getelementptr inbounds %struct.point1, %struct.point1* %2, i32 0, i32 0 + %9 = load i8*, i8** %8, align 8 + %10 = ptrtoint i8* %9 to i64 + ret i64 %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define dso_local [2 x i64] @demo2([2 x i64] %0) #0 { + %2 = alloca %struct.point2, align 8 + %3 = alloca %struct.point2, align 8 + %4 = bitcast %struct.point2* %3 to [2 x i64]* + store [2 x i64] %0, [2 x i64]* %4, align 8 + %5 = bitcast %struct.point2* %2 to i8* + %6 = bitcast %struct.point2* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 16, i1 false) + %7 = bitcast %struct.point2* %2 to [2 x i64]* + %8 = load [2 x i64], [2 x i64]* %7, align 8 + ret [2 x i64] %8 +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo3(%struct.point3* noalias sret(%struct.point3) align 8 %0, %struct.point3* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point3* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point3* %0 to i8* + %6 = bitcast %struct.point3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo4(%struct.point4* noalias sret(%struct.point4) align 8 %0, %struct.point4* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point4* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point4* %0 to i8* + %6 = bitcast %struct.point4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo5(%struct.point5* noalias sret(%struct.point5) align 8 %0, %struct.point5* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point5* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point5* %0 to i8* + %6 = bitcast %struct.point5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo6(%struct.point6* noalias sret(%struct.point6) align 8 %0, %struct.point6* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point6* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point6* %0 to i8* + %6 = bitcast %struct.point6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo7(%struct.point7* noalias sret(%struct.point7) align 8 %0, %struct.point7* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point7* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point7* %0 to i8* + %6 = bitcast %struct.point7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo8(%struct.point8* noalias sret(%struct.point8) align 8 %0, %struct.point8* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point8* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point8* %0 to i8* + %6 = bitcast %struct.point8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo9(%struct.point9* noalias sret(%struct.point9) align 8 %0, %struct.point9* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point9* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point9* %0 to i8* + %6 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo10(%struct.point10* noalias sret(%struct.point10) align 8 %0, %struct.point10* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point10* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point10* %0 to i8* + %6 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo11(%struct.point11* noalias sret(%struct.point11) align 8 %0, %struct.point11* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point11* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point11* %0 to i8* + %6 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo12(%struct.point12* noalias sret(%struct.point12) align 8 %0, %struct.point12* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point12* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point12* %0 to i8* + %6 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo13(%struct.point13* noalias sret(%struct.point13) align 8 %0, %struct.point13* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point13* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point13* %0 to i8* + %6 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo14(%struct.point14* noalias sret(%struct.point14) align 8 %0, %struct.point14* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point14* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point14* %0 to i8* + %6 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo15(%struct.point15* noalias sret(%struct.point15) align 8 %0, %struct.point15* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point15* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point15* %0 to i8* + %6 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo16(%struct.point16* noalias sret(%struct.point16) align 8 %0, %struct.point16* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point16* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point16* %0 to i8* + %6 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo17(%struct.point17* noalias sret(%struct.point17) align 8 %0, %struct.point17* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point17* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point17* %0 to i8* + %6 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo18(%struct.point18* noalias sret(%struct.point18) align 8 %0, %struct.point18* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point18* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point18* %0 to i8* + %6 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo19(%struct.point19* noalias sret(%struct.point19) align 8 %0, %struct.point19* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point19* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point19* %0 to i8* + %6 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define dso_local void @demo20(%struct.point20* noalias sret(%struct.point20) align 8 %0, %struct.point20* noundef %1) #0 { + %3 = alloca i8*, align 8 + %4 = bitcast %struct.point20* %0 to i8* + store i8* %4, i8** %3, align 8 + %5 = bitcast %struct.point20* %0 to i8* + %6 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %5, i8* align 8 %6, i64 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+m,+relax,-save-restore" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3} +!llvm.ident = !{!4} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"target-abi", !"lp64"} +!2 = !{i32 7, !"frame-pointer", i32 2} +!3 = !{i32 1, !"SmallDataLimit", i32 8} +!4 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/wasm32/array_float32.ll b/internal/cabi/_testdata/arch/wasm32/array_float32.ll new file mode 100644 index 00000000..d61a6d6d --- /dev/null +++ b/internal/cabi/_testdata/arch/wasm32/array_float32.ll @@ -0,0 +1,205 @@ +; ModuleID = '../../wrap/array_float32.c' +source_filename = "../../wrap/array_float32.c" +target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20" +target triple = "wasm32-unknown-emscripten" + +%struct.array1 = type { [1 x float] } +%struct.array2 = type { [2 x float] } +%struct.array3 = type { [3 x float] } +%struct.array4 = type { [4 x float] } +%struct.array5 = type { [5 x float] } +%struct.array6 = type { [6 x float] } +%struct.array7 = type { [7 x float] } +%struct.array8 = type { [8 x float] } +%struct.array9 = type { [9 x float] } +%struct.array10 = type { [10 x float] } +%struct.array11 = type { [11 x float] } +%struct.array12 = type { [12 x float] } +%struct.array13 = type { [13 x float] } +%struct.array14 = type { [14 x float] } +%struct.array15 = type { [15 x float] } +%struct.array16 = type { [16 x float] } +%struct.array17 = type { [17 x float] } +%struct.array18 = type { [18 x float] } +%struct.array19 = type { [19 x float] } +%struct.array20 = type { [20 x float] } + +; Function Attrs: noinline nounwind optnone +define hidden float @demo1(float %0) #0 { + %2 = alloca %struct.array1, align 4 + %3 = alloca %struct.array1, align 4 + %4 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + %5 = bitcast [1 x float]* %4 to float* + store float %0, float* %5, align 4 + %6 = bitcast %struct.array1* %2 to i8* + %7 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 4, i1 false) + %8 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %9 = bitcast [1 x float]* %8 to float* + %10 = load float, float* %9, align 4 + ret float %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define hidden void @demo2(%struct.array2* noalias sret(%struct.array2) align 4 %0, %struct.array2* noundef byval(%struct.array2) align 4 %1) #0 { + %3 = bitcast %struct.array2* %0 to i8* + %4 = bitcast %struct.array2* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo3(%struct.array3* noalias sret(%struct.array3) align 4 %0, %struct.array3* noundef byval(%struct.array3) align 4 %1) #0 { + %3 = bitcast %struct.array3* %0 to i8* + %4 = bitcast %struct.array3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo4(%struct.array4* noalias sret(%struct.array4) align 4 %0, %struct.array4* noundef byval(%struct.array4) align 4 %1) #0 { + %3 = bitcast %struct.array4* %0 to i8* + %4 = bitcast %struct.array4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo5(%struct.array5* noalias sret(%struct.array5) align 4 %0, %struct.array5* noundef byval(%struct.array5) align 4 %1) #0 { + %3 = bitcast %struct.array5* %0 to i8* + %4 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo6(%struct.array6* noalias sret(%struct.array6) align 4 %0, %struct.array6* noundef byval(%struct.array6) align 4 %1) #0 { + %3 = bitcast %struct.array6* %0 to i8* + %4 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo7(%struct.array7* noalias sret(%struct.array7) align 4 %0, %struct.array7* noundef byval(%struct.array7) align 4 %1) #0 { + %3 = bitcast %struct.array7* %0 to i8* + %4 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo8(%struct.array8* noalias sret(%struct.array8) align 4 %0, %struct.array8* noundef byval(%struct.array8) align 4 %1) #0 { + %3 = bitcast %struct.array8* %0 to i8* + %4 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo9(%struct.array9* noalias sret(%struct.array9) align 4 %0, %struct.array9* noundef byval(%struct.array9) align 4 %1) #0 { + %3 = bitcast %struct.array9* %0 to i8* + %4 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo10(%struct.array10* noalias sret(%struct.array10) align 4 %0, %struct.array10* noundef byval(%struct.array10) align 4 %1) #0 { + %3 = bitcast %struct.array10* %0 to i8* + %4 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo11(%struct.array11* noalias sret(%struct.array11) align 4 %0, %struct.array11* noundef byval(%struct.array11) align 4 %1) #0 { + %3 = bitcast %struct.array11* %0 to i8* + %4 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo12(%struct.array12* noalias sret(%struct.array12) align 4 %0, %struct.array12* noundef byval(%struct.array12) align 4 %1) #0 { + %3 = bitcast %struct.array12* %0 to i8* + %4 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo13(%struct.array13* noalias sret(%struct.array13) align 4 %0, %struct.array13* noundef byval(%struct.array13) align 4 %1) #0 { + %3 = bitcast %struct.array13* %0 to i8* + %4 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo14(%struct.array14* noalias sret(%struct.array14) align 4 %0, %struct.array14* noundef byval(%struct.array14) align 4 %1) #0 { + %3 = bitcast %struct.array14* %0 to i8* + %4 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo15(%struct.array15* noalias sret(%struct.array15) align 4 %0, %struct.array15* noundef byval(%struct.array15) align 4 %1) #0 { + %3 = bitcast %struct.array15* %0 to i8* + %4 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo16(%struct.array16* noalias sret(%struct.array16) align 4 %0, %struct.array16* noundef byval(%struct.array16) align 4 %1) #0 { + %3 = bitcast %struct.array16* %0 to i8* + %4 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo17(%struct.array17* noalias sret(%struct.array17) align 4 %0, %struct.array17* noundef byval(%struct.array17) align 4 %1) #0 { + %3 = bitcast %struct.array17* %0 to i8* + %4 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo18(%struct.array18* noalias sret(%struct.array18) align 4 %0, %struct.array18* noundef byval(%struct.array18) align 4 %1) #0 { + %3 = bitcast %struct.array18* %0 to i8* + %4 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo19(%struct.array19* noalias sret(%struct.array19) align 4 %0, %struct.array19* noundef byval(%struct.array19) align 4 %1) #0 { + %3 = bitcast %struct.array19* %0 to i8* + %4 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo20(%struct.array20* noalias sret(%struct.array20) align 4 %0, %struct.array20* noundef byval(%struct.array20) align 4 %1) #0 { + %3 = bitcast %struct.array20* %0 to i8* + %4 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0} +!llvm.ident = !{!1} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/wasm32/array_float64.ll b/internal/cabi/_testdata/arch/wasm32/array_float64.ll new file mode 100644 index 00000000..cb95f083 --- /dev/null +++ b/internal/cabi/_testdata/arch/wasm32/array_float64.ll @@ -0,0 +1,205 @@ +; ModuleID = '../../wrap/array_float64.c' +source_filename = "../../wrap/array_float64.c" +target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20" +target triple = "wasm32-unknown-emscripten" + +%struct.array1 = type { [1 x double] } +%struct.array2 = type { [2 x double] } +%struct.array3 = type { [3 x double] } +%struct.array4 = type { [4 x double] } +%struct.array5 = type { [5 x double] } +%struct.array6 = type { [6 x double] } +%struct.array7 = type { [7 x double] } +%struct.array8 = type { [8 x double] } +%struct.array9 = type { [9 x double] } +%struct.array10 = type { [10 x double] } +%struct.array11 = type { [11 x double] } +%struct.array12 = type { [12 x double] } +%struct.array13 = type { [13 x double] } +%struct.array14 = type { [14 x double] } +%struct.array15 = type { [15 x double] } +%struct.array16 = type { [16 x double] } +%struct.array17 = type { [17 x double] } +%struct.array18 = type { [18 x double] } +%struct.array19 = type { [19 x double] } +%struct.array20 = type { [20 x double] } + +; Function Attrs: noinline nounwind optnone +define hidden double @demo1(double %0) #0 { + %2 = alloca %struct.array1, align 8 + %3 = alloca %struct.array1, align 8 + %4 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + %5 = bitcast [1 x double]* %4 to double* + store double %0, double* %5, align 8 + %6 = bitcast %struct.array1* %2 to i8* + %7 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %6, i8* align 8 %7, i32 8, i1 false) + %8 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %9 = bitcast [1 x double]* %8 to double* + %10 = load double, double* %9, align 8 + ret double %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define hidden void @demo2(%struct.array2* noalias sret(%struct.array2) align 8 %0, %struct.array2* noundef byval(%struct.array2) align 8 %1) #0 { + %3 = bitcast %struct.array2* %0 to i8* + %4 = bitcast %struct.array2* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo3(%struct.array3* noalias sret(%struct.array3) align 8 %0, %struct.array3* noundef byval(%struct.array3) align 8 %1) #0 { + %3 = bitcast %struct.array3* %0 to i8* + %4 = bitcast %struct.array3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo4(%struct.array4* noalias sret(%struct.array4) align 8 %0, %struct.array4* noundef byval(%struct.array4) align 8 %1) #0 { + %3 = bitcast %struct.array4* %0 to i8* + %4 = bitcast %struct.array4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo5(%struct.array5* noalias sret(%struct.array5) align 8 %0, %struct.array5* noundef byval(%struct.array5) align 8 %1) #0 { + %3 = bitcast %struct.array5* %0 to i8* + %4 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo6(%struct.array6* noalias sret(%struct.array6) align 8 %0, %struct.array6* noundef byval(%struct.array6) align 8 %1) #0 { + %3 = bitcast %struct.array6* %0 to i8* + %4 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo7(%struct.array7* noalias sret(%struct.array7) align 8 %0, %struct.array7* noundef byval(%struct.array7) align 8 %1) #0 { + %3 = bitcast %struct.array7* %0 to i8* + %4 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo8(%struct.array8* noalias sret(%struct.array8) align 8 %0, %struct.array8* noundef byval(%struct.array8) align 8 %1) #0 { + %3 = bitcast %struct.array8* %0 to i8* + %4 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo9(%struct.array9* noalias sret(%struct.array9) align 8 %0, %struct.array9* noundef byval(%struct.array9) align 8 %1) #0 { + %3 = bitcast %struct.array9* %0 to i8* + %4 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo10(%struct.array10* noalias sret(%struct.array10) align 8 %0, %struct.array10* noundef byval(%struct.array10) align 8 %1) #0 { + %3 = bitcast %struct.array10* %0 to i8* + %4 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo11(%struct.array11* noalias sret(%struct.array11) align 8 %0, %struct.array11* noundef byval(%struct.array11) align 8 %1) #0 { + %3 = bitcast %struct.array11* %0 to i8* + %4 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo12(%struct.array12* noalias sret(%struct.array12) align 8 %0, %struct.array12* noundef byval(%struct.array12) align 8 %1) #0 { + %3 = bitcast %struct.array12* %0 to i8* + %4 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo13(%struct.array13* noalias sret(%struct.array13) align 8 %0, %struct.array13* noundef byval(%struct.array13) align 8 %1) #0 { + %3 = bitcast %struct.array13* %0 to i8* + %4 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo14(%struct.array14* noalias sret(%struct.array14) align 8 %0, %struct.array14* noundef byval(%struct.array14) align 8 %1) #0 { + %3 = bitcast %struct.array14* %0 to i8* + %4 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo15(%struct.array15* noalias sret(%struct.array15) align 8 %0, %struct.array15* noundef byval(%struct.array15) align 8 %1) #0 { + %3 = bitcast %struct.array15* %0 to i8* + %4 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo16(%struct.array16* noalias sret(%struct.array16) align 8 %0, %struct.array16* noundef byval(%struct.array16) align 8 %1) #0 { + %3 = bitcast %struct.array16* %0 to i8* + %4 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo17(%struct.array17* noalias sret(%struct.array17) align 8 %0, %struct.array17* noundef byval(%struct.array17) align 8 %1) #0 { + %3 = bitcast %struct.array17* %0 to i8* + %4 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo18(%struct.array18* noalias sret(%struct.array18) align 8 %0, %struct.array18* noundef byval(%struct.array18) align 8 %1) #0 { + %3 = bitcast %struct.array18* %0 to i8* + %4 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo19(%struct.array19* noalias sret(%struct.array19) align 8 %0, %struct.array19* noundef byval(%struct.array19) align 8 %1) #0 { + %3 = bitcast %struct.array19* %0 to i8* + %4 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo20(%struct.array20* noalias sret(%struct.array20) align 8 %0, %struct.array20* noundef byval(%struct.array20) align 8 %1) #0 { + %3 = bitcast %struct.array20* %0 to i8* + %4 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0} +!llvm.ident = !{!1} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/wasm32/array_int16.ll b/internal/cabi/_testdata/arch/wasm32/array_int16.ll new file mode 100644 index 00000000..fe54b37f --- /dev/null +++ b/internal/cabi/_testdata/arch/wasm32/array_int16.ll @@ -0,0 +1,205 @@ +; ModuleID = '../../wrap/array_int16.c' +source_filename = "../../wrap/array_int16.c" +target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20" +target triple = "wasm32-unknown-emscripten" + +%struct.array1 = type { [1 x i16] } +%struct.array2 = type { [2 x i16] } +%struct.array3 = type { [3 x i16] } +%struct.array4 = type { [4 x i16] } +%struct.array5 = type { [5 x i16] } +%struct.array6 = type { [6 x i16] } +%struct.array7 = type { [7 x i16] } +%struct.array8 = type { [8 x i16] } +%struct.array9 = type { [9 x i16] } +%struct.array10 = type { [10 x i16] } +%struct.array11 = type { [11 x i16] } +%struct.array12 = type { [12 x i16] } +%struct.array13 = type { [13 x i16] } +%struct.array14 = type { [14 x i16] } +%struct.array15 = type { [15 x i16] } +%struct.array16 = type { [16 x i16] } +%struct.array17 = type { [17 x i16] } +%struct.array18 = type { [18 x i16] } +%struct.array19 = type { [19 x i16] } +%struct.array20 = type { [20 x i16] } + +; Function Attrs: noinline nounwind optnone +define hidden i16 @demo1(i16 %0) #0 { + %2 = alloca %struct.array1, align 2 + %3 = alloca %struct.array1, align 2 + %4 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + %5 = bitcast [1 x i16]* %4 to i16* + store i16 %0, i16* %5, align 2 + %6 = bitcast %struct.array1* %2 to i8* + %7 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %6, i8* align 2 %7, i32 2, i1 false) + %8 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %9 = bitcast [1 x i16]* %8 to i16* + %10 = load i16, i16* %9, align 2 + ret i16 %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define hidden void @demo2(%struct.array2* noalias sret(%struct.array2) align 2 %0, %struct.array2* noundef byval(%struct.array2) align 2 %1) #0 { + %3 = bitcast %struct.array2* %0 to i8* + %4 = bitcast %struct.array2* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 4, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo3(%struct.array3* noalias sret(%struct.array3) align 2 %0, %struct.array3* noundef byval(%struct.array3) align 2 %1) #0 { + %3 = bitcast %struct.array3* %0 to i8* + %4 = bitcast %struct.array3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 6, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo4(%struct.array4* noalias sret(%struct.array4) align 2 %0, %struct.array4* noundef byval(%struct.array4) align 2 %1) #0 { + %3 = bitcast %struct.array4* %0 to i8* + %4 = bitcast %struct.array4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo5(%struct.array5* noalias sret(%struct.array5) align 2 %0, %struct.array5* noundef byval(%struct.array5) align 2 %1) #0 { + %3 = bitcast %struct.array5* %0 to i8* + %4 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 10, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo6(%struct.array6* noalias sret(%struct.array6) align 2 %0, %struct.array6* noundef byval(%struct.array6) align 2 %1) #0 { + %3 = bitcast %struct.array6* %0 to i8* + %4 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo7(%struct.array7* noalias sret(%struct.array7) align 2 %0, %struct.array7* noundef byval(%struct.array7) align 2 %1) #0 { + %3 = bitcast %struct.array7* %0 to i8* + %4 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 14, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo8(%struct.array8* noalias sret(%struct.array8) align 2 %0, %struct.array8* noundef byval(%struct.array8) align 2 %1) #0 { + %3 = bitcast %struct.array8* %0 to i8* + %4 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo9(%struct.array9* noalias sret(%struct.array9) align 2 %0, %struct.array9* noundef byval(%struct.array9) align 2 %1) #0 { + %3 = bitcast %struct.array9* %0 to i8* + %4 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 18, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo10(%struct.array10* noalias sret(%struct.array10) align 2 %0, %struct.array10* noundef byval(%struct.array10) align 2 %1) #0 { + %3 = bitcast %struct.array10* %0 to i8* + %4 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo11(%struct.array11* noalias sret(%struct.array11) align 2 %0, %struct.array11* noundef byval(%struct.array11) align 2 %1) #0 { + %3 = bitcast %struct.array11* %0 to i8* + %4 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 22, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo12(%struct.array12* noalias sret(%struct.array12) align 2 %0, %struct.array12* noundef byval(%struct.array12) align 2 %1) #0 { + %3 = bitcast %struct.array12* %0 to i8* + %4 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo13(%struct.array13* noalias sret(%struct.array13) align 2 %0, %struct.array13* noundef byval(%struct.array13) align 2 %1) #0 { + %3 = bitcast %struct.array13* %0 to i8* + %4 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 26, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo14(%struct.array14* noalias sret(%struct.array14) align 2 %0, %struct.array14* noundef byval(%struct.array14) align 2 %1) #0 { + %3 = bitcast %struct.array14* %0 to i8* + %4 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo15(%struct.array15* noalias sret(%struct.array15) align 2 %0, %struct.array15* noundef byval(%struct.array15) align 2 %1) #0 { + %3 = bitcast %struct.array15* %0 to i8* + %4 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 30, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo16(%struct.array16* noalias sret(%struct.array16) align 2 %0, %struct.array16* noundef byval(%struct.array16) align 2 %1) #0 { + %3 = bitcast %struct.array16* %0 to i8* + %4 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo17(%struct.array17* noalias sret(%struct.array17) align 2 %0, %struct.array17* noundef byval(%struct.array17) align 2 %1) #0 { + %3 = bitcast %struct.array17* %0 to i8* + %4 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 34, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo18(%struct.array18* noalias sret(%struct.array18) align 2 %0, %struct.array18* noundef byval(%struct.array18) align 2 %1) #0 { + %3 = bitcast %struct.array18* %0 to i8* + %4 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo19(%struct.array19* noalias sret(%struct.array19) align 2 %0, %struct.array19* noundef byval(%struct.array19) align 2 %1) #0 { + %3 = bitcast %struct.array19* %0 to i8* + %4 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 38, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo20(%struct.array20* noalias sret(%struct.array20) align 2 %0, %struct.array20* noundef byval(%struct.array20) align 2 %1) #0 { + %3 = bitcast %struct.array20* %0 to i8* + %4 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 40, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0} +!llvm.ident = !{!1} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/wasm32/array_int32.ll b/internal/cabi/_testdata/arch/wasm32/array_int32.ll new file mode 100644 index 00000000..fa972ce0 --- /dev/null +++ b/internal/cabi/_testdata/arch/wasm32/array_int32.ll @@ -0,0 +1,205 @@ +; ModuleID = '../../wrap/array_int32.c' +source_filename = "../../wrap/array_int32.c" +target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20" +target triple = "wasm32-unknown-emscripten" + +%struct.array1 = type { [1 x i32] } +%struct.array2 = type { [2 x i32] } +%struct.array3 = type { [3 x i32] } +%struct.array4 = type { [4 x i32] } +%struct.array5 = type { [5 x i32] } +%struct.array6 = type { [6 x i32] } +%struct.array7 = type { [7 x i32] } +%struct.array8 = type { [8 x i32] } +%struct.array9 = type { [9 x i32] } +%struct.array10 = type { [10 x i32] } +%struct.array11 = type { [11 x i32] } +%struct.array12 = type { [12 x i32] } +%struct.array13 = type { [13 x i32] } +%struct.array14 = type { [14 x i32] } +%struct.array15 = type { [15 x i32] } +%struct.array16 = type { [16 x i32] } +%struct.array17 = type { [17 x i32] } +%struct.array18 = type { [18 x i32] } +%struct.array19 = type { [19 x i32] } +%struct.array20 = type { [20 x i32] } + +; Function Attrs: noinline nounwind optnone +define hidden i32 @demo1(i32 %0) #0 { + %2 = alloca %struct.array1, align 4 + %3 = alloca %struct.array1, align 4 + %4 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + %5 = bitcast [1 x i32]* %4 to i32* + store i32 %0, i32* %5, align 4 + %6 = bitcast %struct.array1* %2 to i8* + %7 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 4, i1 false) + %8 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %9 = bitcast [1 x i32]* %8 to i32* + %10 = load i32, i32* %9, align 4 + ret i32 %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define hidden void @demo2(%struct.array2* noalias sret(%struct.array2) align 4 %0, %struct.array2* noundef byval(%struct.array2) align 4 %1) #0 { + %3 = bitcast %struct.array2* %0 to i8* + %4 = bitcast %struct.array2* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo3(%struct.array3* noalias sret(%struct.array3) align 4 %0, %struct.array3* noundef byval(%struct.array3) align 4 %1) #0 { + %3 = bitcast %struct.array3* %0 to i8* + %4 = bitcast %struct.array3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo4(%struct.array4* noalias sret(%struct.array4) align 4 %0, %struct.array4* noundef byval(%struct.array4) align 4 %1) #0 { + %3 = bitcast %struct.array4* %0 to i8* + %4 = bitcast %struct.array4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo5(%struct.array5* noalias sret(%struct.array5) align 4 %0, %struct.array5* noundef byval(%struct.array5) align 4 %1) #0 { + %3 = bitcast %struct.array5* %0 to i8* + %4 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo6(%struct.array6* noalias sret(%struct.array6) align 4 %0, %struct.array6* noundef byval(%struct.array6) align 4 %1) #0 { + %3 = bitcast %struct.array6* %0 to i8* + %4 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo7(%struct.array7* noalias sret(%struct.array7) align 4 %0, %struct.array7* noundef byval(%struct.array7) align 4 %1) #0 { + %3 = bitcast %struct.array7* %0 to i8* + %4 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo8(%struct.array8* noalias sret(%struct.array8) align 4 %0, %struct.array8* noundef byval(%struct.array8) align 4 %1) #0 { + %3 = bitcast %struct.array8* %0 to i8* + %4 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo9(%struct.array9* noalias sret(%struct.array9) align 4 %0, %struct.array9* noundef byval(%struct.array9) align 4 %1) #0 { + %3 = bitcast %struct.array9* %0 to i8* + %4 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo10(%struct.array10* noalias sret(%struct.array10) align 4 %0, %struct.array10* noundef byval(%struct.array10) align 4 %1) #0 { + %3 = bitcast %struct.array10* %0 to i8* + %4 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo11(%struct.array11* noalias sret(%struct.array11) align 4 %0, %struct.array11* noundef byval(%struct.array11) align 4 %1) #0 { + %3 = bitcast %struct.array11* %0 to i8* + %4 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo12(%struct.array12* noalias sret(%struct.array12) align 4 %0, %struct.array12* noundef byval(%struct.array12) align 4 %1) #0 { + %3 = bitcast %struct.array12* %0 to i8* + %4 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo13(%struct.array13* noalias sret(%struct.array13) align 4 %0, %struct.array13* noundef byval(%struct.array13) align 4 %1) #0 { + %3 = bitcast %struct.array13* %0 to i8* + %4 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo14(%struct.array14* noalias sret(%struct.array14) align 4 %0, %struct.array14* noundef byval(%struct.array14) align 4 %1) #0 { + %3 = bitcast %struct.array14* %0 to i8* + %4 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo15(%struct.array15* noalias sret(%struct.array15) align 4 %0, %struct.array15* noundef byval(%struct.array15) align 4 %1) #0 { + %3 = bitcast %struct.array15* %0 to i8* + %4 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo16(%struct.array16* noalias sret(%struct.array16) align 4 %0, %struct.array16* noundef byval(%struct.array16) align 4 %1) #0 { + %3 = bitcast %struct.array16* %0 to i8* + %4 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo17(%struct.array17* noalias sret(%struct.array17) align 4 %0, %struct.array17* noundef byval(%struct.array17) align 4 %1) #0 { + %3 = bitcast %struct.array17* %0 to i8* + %4 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo18(%struct.array18* noalias sret(%struct.array18) align 4 %0, %struct.array18* noundef byval(%struct.array18) align 4 %1) #0 { + %3 = bitcast %struct.array18* %0 to i8* + %4 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo19(%struct.array19* noalias sret(%struct.array19) align 4 %0, %struct.array19* noundef byval(%struct.array19) align 4 %1) #0 { + %3 = bitcast %struct.array19* %0 to i8* + %4 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo20(%struct.array20* noalias sret(%struct.array20) align 4 %0, %struct.array20* noundef byval(%struct.array20) align 4 %1) #0 { + %3 = bitcast %struct.array20* %0 to i8* + %4 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0} +!llvm.ident = !{!1} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/wasm32/array_int64.ll b/internal/cabi/_testdata/arch/wasm32/array_int64.ll new file mode 100644 index 00000000..0f29a3de --- /dev/null +++ b/internal/cabi/_testdata/arch/wasm32/array_int64.ll @@ -0,0 +1,205 @@ +; ModuleID = '../../wrap/array_int64.c' +source_filename = "../../wrap/array_int64.c" +target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20" +target triple = "wasm32-unknown-emscripten" + +%struct.array1 = type { [1 x i64] } +%struct.array2 = type { [2 x i64] } +%struct.array3 = type { [3 x i64] } +%struct.array4 = type { [4 x i64] } +%struct.array5 = type { [5 x i64] } +%struct.array6 = type { [6 x i64] } +%struct.array7 = type { [7 x i64] } +%struct.array8 = type { [8 x i64] } +%struct.array9 = type { [9 x i64] } +%struct.array10 = type { [10 x i64] } +%struct.array11 = type { [11 x i64] } +%struct.array12 = type { [12 x i64] } +%struct.array13 = type { [13 x i64] } +%struct.array14 = type { [14 x i64] } +%struct.array15 = type { [15 x i64] } +%struct.array16 = type { [16 x i64] } +%struct.array17 = type { [17 x i64] } +%struct.array18 = type { [18 x i64] } +%struct.array19 = type { [19 x i64] } +%struct.array20 = type { [20 x i64] } + +; Function Attrs: noinline nounwind optnone +define hidden i64 @demo1(i64 %0) #0 { + %2 = alloca %struct.array1, align 8 + %3 = alloca %struct.array1, align 8 + %4 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + %5 = bitcast [1 x i64]* %4 to i64* + store i64 %0, i64* %5, align 8 + %6 = bitcast %struct.array1* %2 to i8* + %7 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %6, i8* align 8 %7, i32 8, i1 false) + %8 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %9 = bitcast [1 x i64]* %8 to i64* + %10 = load i64, i64* %9, align 8 + ret i64 %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define hidden void @demo2(%struct.array2* noalias sret(%struct.array2) align 8 %0, %struct.array2* noundef byval(%struct.array2) align 8 %1) #0 { + %3 = bitcast %struct.array2* %0 to i8* + %4 = bitcast %struct.array2* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo3(%struct.array3* noalias sret(%struct.array3) align 8 %0, %struct.array3* noundef byval(%struct.array3) align 8 %1) #0 { + %3 = bitcast %struct.array3* %0 to i8* + %4 = bitcast %struct.array3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo4(%struct.array4* noalias sret(%struct.array4) align 8 %0, %struct.array4* noundef byval(%struct.array4) align 8 %1) #0 { + %3 = bitcast %struct.array4* %0 to i8* + %4 = bitcast %struct.array4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo5(%struct.array5* noalias sret(%struct.array5) align 8 %0, %struct.array5* noundef byval(%struct.array5) align 8 %1) #0 { + %3 = bitcast %struct.array5* %0 to i8* + %4 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo6(%struct.array6* noalias sret(%struct.array6) align 8 %0, %struct.array6* noundef byval(%struct.array6) align 8 %1) #0 { + %3 = bitcast %struct.array6* %0 to i8* + %4 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo7(%struct.array7* noalias sret(%struct.array7) align 8 %0, %struct.array7* noundef byval(%struct.array7) align 8 %1) #0 { + %3 = bitcast %struct.array7* %0 to i8* + %4 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo8(%struct.array8* noalias sret(%struct.array8) align 8 %0, %struct.array8* noundef byval(%struct.array8) align 8 %1) #0 { + %3 = bitcast %struct.array8* %0 to i8* + %4 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo9(%struct.array9* noalias sret(%struct.array9) align 8 %0, %struct.array9* noundef byval(%struct.array9) align 8 %1) #0 { + %3 = bitcast %struct.array9* %0 to i8* + %4 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo10(%struct.array10* noalias sret(%struct.array10) align 8 %0, %struct.array10* noundef byval(%struct.array10) align 8 %1) #0 { + %3 = bitcast %struct.array10* %0 to i8* + %4 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo11(%struct.array11* noalias sret(%struct.array11) align 8 %0, %struct.array11* noundef byval(%struct.array11) align 8 %1) #0 { + %3 = bitcast %struct.array11* %0 to i8* + %4 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo12(%struct.array12* noalias sret(%struct.array12) align 8 %0, %struct.array12* noundef byval(%struct.array12) align 8 %1) #0 { + %3 = bitcast %struct.array12* %0 to i8* + %4 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo13(%struct.array13* noalias sret(%struct.array13) align 8 %0, %struct.array13* noundef byval(%struct.array13) align 8 %1) #0 { + %3 = bitcast %struct.array13* %0 to i8* + %4 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo14(%struct.array14* noalias sret(%struct.array14) align 8 %0, %struct.array14* noundef byval(%struct.array14) align 8 %1) #0 { + %3 = bitcast %struct.array14* %0 to i8* + %4 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo15(%struct.array15* noalias sret(%struct.array15) align 8 %0, %struct.array15* noundef byval(%struct.array15) align 8 %1) #0 { + %3 = bitcast %struct.array15* %0 to i8* + %4 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo16(%struct.array16* noalias sret(%struct.array16) align 8 %0, %struct.array16* noundef byval(%struct.array16) align 8 %1) #0 { + %3 = bitcast %struct.array16* %0 to i8* + %4 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo17(%struct.array17* noalias sret(%struct.array17) align 8 %0, %struct.array17* noundef byval(%struct.array17) align 8 %1) #0 { + %3 = bitcast %struct.array17* %0 to i8* + %4 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo18(%struct.array18* noalias sret(%struct.array18) align 8 %0, %struct.array18* noundef byval(%struct.array18) align 8 %1) #0 { + %3 = bitcast %struct.array18* %0 to i8* + %4 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo19(%struct.array19* noalias sret(%struct.array19) align 8 %0, %struct.array19* noundef byval(%struct.array19) align 8 %1) #0 { + %3 = bitcast %struct.array19* %0 to i8* + %4 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo20(%struct.array20* noalias sret(%struct.array20) align 8 %0, %struct.array20* noundef byval(%struct.array20) align 8 %1) #0 { + %3 = bitcast %struct.array20* %0 to i8* + %4 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0} +!llvm.ident = !{!1} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/wasm32/array_int8.ll b/internal/cabi/_testdata/arch/wasm32/array_int8.ll new file mode 100644 index 00000000..061f3f92 --- /dev/null +++ b/internal/cabi/_testdata/arch/wasm32/array_int8.ll @@ -0,0 +1,205 @@ +; ModuleID = '../../wrap/array_int8.c' +source_filename = "../../wrap/array_int8.c" +target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20" +target triple = "wasm32-unknown-emscripten" + +%struct.array1 = type { [1 x i8] } +%struct.array2 = type { [2 x i8] } +%struct.array3 = type { [3 x i8] } +%struct.array4 = type { [4 x i8] } +%struct.array5 = type { [5 x i8] } +%struct.array6 = type { [6 x i8] } +%struct.array7 = type { [7 x i8] } +%struct.array8 = type { [8 x i8] } +%struct.array9 = type { [9 x i8] } +%struct.array10 = type { [10 x i8] } +%struct.array11 = type { [11 x i8] } +%struct.array12 = type { [12 x i8] } +%struct.array13 = type { [13 x i8] } +%struct.array14 = type { [14 x i8] } +%struct.array15 = type { [15 x i8] } +%struct.array16 = type { [16 x i8] } +%struct.array17 = type { [17 x i8] } +%struct.array18 = type { [18 x i8] } +%struct.array19 = type { [19 x i8] } +%struct.array20 = type { [20 x i8] } + +; Function Attrs: noinline nounwind optnone +define hidden i8 @demo1(i8 %0) #0 { + %2 = alloca %struct.array1, align 1 + %3 = alloca %struct.array1, align 1 + %4 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + %5 = bitcast [1 x i8]* %4 to i8* + store i8 %0, i8* %5, align 1 + %6 = bitcast %struct.array1* %2 to i8* + %7 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %6, i8* align 1 %7, i32 1, i1 false) + %8 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %9 = bitcast [1 x i8]* %8 to i8* + %10 = load i8, i8* %9, align 1 + ret i8 %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define hidden void @demo2(%struct.array2* noalias sret(%struct.array2) align 1 %0, %struct.array2* noundef byval(%struct.array2) align 1 %1) #0 { + %3 = bitcast %struct.array2* %0 to i8* + %4 = bitcast %struct.array2* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 2, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo3(%struct.array3* noalias sret(%struct.array3) align 1 %0, %struct.array3* noundef byval(%struct.array3) align 1 %1) #0 { + %3 = bitcast %struct.array3* %0 to i8* + %4 = bitcast %struct.array3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 3, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo4(%struct.array4* noalias sret(%struct.array4) align 1 %0, %struct.array4* noundef byval(%struct.array4) align 1 %1) #0 { + %3 = bitcast %struct.array4* %0 to i8* + %4 = bitcast %struct.array4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 4, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo5(%struct.array5* noalias sret(%struct.array5) align 1 %0, %struct.array5* noundef byval(%struct.array5) align 1 %1) #0 { + %3 = bitcast %struct.array5* %0 to i8* + %4 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 5, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo6(%struct.array6* noalias sret(%struct.array6) align 1 %0, %struct.array6* noundef byval(%struct.array6) align 1 %1) #0 { + %3 = bitcast %struct.array6* %0 to i8* + %4 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 6, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo7(%struct.array7* noalias sret(%struct.array7) align 1 %0, %struct.array7* noundef byval(%struct.array7) align 1 %1) #0 { + %3 = bitcast %struct.array7* %0 to i8* + %4 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 7, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo8(%struct.array8* noalias sret(%struct.array8) align 1 %0, %struct.array8* noundef byval(%struct.array8) align 1 %1) #0 { + %3 = bitcast %struct.array8* %0 to i8* + %4 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo9(%struct.array9* noalias sret(%struct.array9) align 1 %0, %struct.array9* noundef byval(%struct.array9) align 1 %1) #0 { + %3 = bitcast %struct.array9* %0 to i8* + %4 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 9, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo10(%struct.array10* noalias sret(%struct.array10) align 1 %0, %struct.array10* noundef byval(%struct.array10) align 1 %1) #0 { + %3 = bitcast %struct.array10* %0 to i8* + %4 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 10, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo11(%struct.array11* noalias sret(%struct.array11) align 1 %0, %struct.array11* noundef byval(%struct.array11) align 1 %1) #0 { + %3 = bitcast %struct.array11* %0 to i8* + %4 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 11, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo12(%struct.array12* noalias sret(%struct.array12) align 1 %0, %struct.array12* noundef byval(%struct.array12) align 1 %1) #0 { + %3 = bitcast %struct.array12* %0 to i8* + %4 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo13(%struct.array13* noalias sret(%struct.array13) align 1 %0, %struct.array13* noundef byval(%struct.array13) align 1 %1) #0 { + %3 = bitcast %struct.array13* %0 to i8* + %4 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 13, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo14(%struct.array14* noalias sret(%struct.array14) align 1 %0, %struct.array14* noundef byval(%struct.array14) align 1 %1) #0 { + %3 = bitcast %struct.array14* %0 to i8* + %4 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 14, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo15(%struct.array15* noalias sret(%struct.array15) align 1 %0, %struct.array15* noundef byval(%struct.array15) align 1 %1) #0 { + %3 = bitcast %struct.array15* %0 to i8* + %4 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 15, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo16(%struct.array16* noalias sret(%struct.array16) align 1 %0, %struct.array16* noundef byval(%struct.array16) align 1 %1) #0 { + %3 = bitcast %struct.array16* %0 to i8* + %4 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo17(%struct.array17* noalias sret(%struct.array17) align 1 %0, %struct.array17* noundef byval(%struct.array17) align 1 %1) #0 { + %3 = bitcast %struct.array17* %0 to i8* + %4 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 17, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo18(%struct.array18* noalias sret(%struct.array18) align 1 %0, %struct.array18* noundef byval(%struct.array18) align 1 %1) #0 { + %3 = bitcast %struct.array18* %0 to i8* + %4 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 18, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo19(%struct.array19* noalias sret(%struct.array19) align 1 %0, %struct.array19* noundef byval(%struct.array19) align 1 %1) #0 { + %3 = bitcast %struct.array19* %0 to i8* + %4 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 19, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo20(%struct.array20* noalias sret(%struct.array20) align 1 %0, %struct.array20* noundef byval(%struct.array20) align 1 %1) #0 { + %3 = bitcast %struct.array20* %0 to i8* + %4 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 20, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0} +!llvm.ident = !{!1} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/wasm32/array_pointer.ll b/internal/cabi/_testdata/arch/wasm32/array_pointer.ll new file mode 100644 index 00000000..5e76b1a2 --- /dev/null +++ b/internal/cabi/_testdata/arch/wasm32/array_pointer.ll @@ -0,0 +1,205 @@ +; ModuleID = '../../wrap/array_pointer.c' +source_filename = "../../wrap/array_pointer.c" +target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20" +target triple = "wasm32-unknown-emscripten" + +%struct.array1 = type { [1 x i8*] } +%struct.array2 = type { [2 x i8*] } +%struct.array3 = type { [3 x i8*] } +%struct.array4 = type { [4 x i8*] } +%struct.array5 = type { [5 x i8*] } +%struct.array6 = type { [6 x i8*] } +%struct.array7 = type { [7 x i8*] } +%struct.array8 = type { [8 x i8*] } +%struct.array9 = type { [9 x i8*] } +%struct.array10 = type { [10 x i8*] } +%struct.array11 = type { [11 x i8*] } +%struct.array12 = type { [12 x i8*] } +%struct.array13 = type { [13 x i8*] } +%struct.array14 = type { [14 x i8*] } +%struct.array15 = type { [15 x i8*] } +%struct.array16 = type { [16 x i8*] } +%struct.array17 = type { [17 x i8*] } +%struct.array18 = type { [18 x i8*] } +%struct.array19 = type { [19 x i8*] } +%struct.array20 = type { [20 x i8*] } + +; Function Attrs: noinline nounwind optnone +define hidden i8* @demo1(i8* %0) #0 { + %2 = alloca %struct.array1, align 4 + %3 = alloca %struct.array1, align 4 + %4 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + %5 = bitcast [1 x i8*]* %4 to i8** + store i8* %0, i8** %5, align 4 + %6 = bitcast %struct.array1* %2 to i8* + %7 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 4, i1 false) + %8 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %9 = bitcast [1 x i8*]* %8 to i8** + %10 = load i8*, i8** %9, align 4 + ret i8* %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define hidden void @demo2(%struct.array2* noalias sret(%struct.array2) align 4 %0, %struct.array2* noundef byval(%struct.array2) align 4 %1) #0 { + %3 = bitcast %struct.array2* %0 to i8* + %4 = bitcast %struct.array2* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo3(%struct.array3* noalias sret(%struct.array3) align 4 %0, %struct.array3* noundef byval(%struct.array3) align 4 %1) #0 { + %3 = bitcast %struct.array3* %0 to i8* + %4 = bitcast %struct.array3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo4(%struct.array4* noalias sret(%struct.array4) align 4 %0, %struct.array4* noundef byval(%struct.array4) align 4 %1) #0 { + %3 = bitcast %struct.array4* %0 to i8* + %4 = bitcast %struct.array4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo5(%struct.array5* noalias sret(%struct.array5) align 4 %0, %struct.array5* noundef byval(%struct.array5) align 4 %1) #0 { + %3 = bitcast %struct.array5* %0 to i8* + %4 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo6(%struct.array6* noalias sret(%struct.array6) align 4 %0, %struct.array6* noundef byval(%struct.array6) align 4 %1) #0 { + %3 = bitcast %struct.array6* %0 to i8* + %4 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo7(%struct.array7* noalias sret(%struct.array7) align 4 %0, %struct.array7* noundef byval(%struct.array7) align 4 %1) #0 { + %3 = bitcast %struct.array7* %0 to i8* + %4 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo8(%struct.array8* noalias sret(%struct.array8) align 4 %0, %struct.array8* noundef byval(%struct.array8) align 4 %1) #0 { + %3 = bitcast %struct.array8* %0 to i8* + %4 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo9(%struct.array9* noalias sret(%struct.array9) align 4 %0, %struct.array9* noundef byval(%struct.array9) align 4 %1) #0 { + %3 = bitcast %struct.array9* %0 to i8* + %4 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo10(%struct.array10* noalias sret(%struct.array10) align 4 %0, %struct.array10* noundef byval(%struct.array10) align 4 %1) #0 { + %3 = bitcast %struct.array10* %0 to i8* + %4 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo11(%struct.array11* noalias sret(%struct.array11) align 4 %0, %struct.array11* noundef byval(%struct.array11) align 4 %1) #0 { + %3 = bitcast %struct.array11* %0 to i8* + %4 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo12(%struct.array12* noalias sret(%struct.array12) align 4 %0, %struct.array12* noundef byval(%struct.array12) align 4 %1) #0 { + %3 = bitcast %struct.array12* %0 to i8* + %4 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo13(%struct.array13* noalias sret(%struct.array13) align 4 %0, %struct.array13* noundef byval(%struct.array13) align 4 %1) #0 { + %3 = bitcast %struct.array13* %0 to i8* + %4 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo14(%struct.array14* noalias sret(%struct.array14) align 4 %0, %struct.array14* noundef byval(%struct.array14) align 4 %1) #0 { + %3 = bitcast %struct.array14* %0 to i8* + %4 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo15(%struct.array15* noalias sret(%struct.array15) align 4 %0, %struct.array15* noundef byval(%struct.array15) align 4 %1) #0 { + %3 = bitcast %struct.array15* %0 to i8* + %4 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo16(%struct.array16* noalias sret(%struct.array16) align 4 %0, %struct.array16* noundef byval(%struct.array16) align 4 %1) #0 { + %3 = bitcast %struct.array16* %0 to i8* + %4 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo17(%struct.array17* noalias sret(%struct.array17) align 4 %0, %struct.array17* noundef byval(%struct.array17) align 4 %1) #0 { + %3 = bitcast %struct.array17* %0 to i8* + %4 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo18(%struct.array18* noalias sret(%struct.array18) align 4 %0, %struct.array18* noundef byval(%struct.array18) align 4 %1) #0 { + %3 = bitcast %struct.array18* %0 to i8* + %4 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo19(%struct.array19* noalias sret(%struct.array19) align 4 %0, %struct.array19* noundef byval(%struct.array19) align 4 %1) #0 { + %3 = bitcast %struct.array19* %0 to i8* + %4 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo20(%struct.array20* noalias sret(%struct.array20) align 4 %0, %struct.array20* noundef byval(%struct.array20) align 4 %1) #0 { + %3 = bitcast %struct.array20* %0 to i8* + %4 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0} +!llvm.ident = !{!1} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/wasm32/array_uintptr.ll b/internal/cabi/_testdata/arch/wasm32/array_uintptr.ll new file mode 100644 index 00000000..47dc59db --- /dev/null +++ b/internal/cabi/_testdata/arch/wasm32/array_uintptr.ll @@ -0,0 +1,205 @@ +; ModuleID = '../../wrap/array_uintptr.c' +source_filename = "../../wrap/array_uintptr.c" +target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20" +target triple = "wasm32-unknown-emscripten" + +%struct.array1 = type { [1 x i8*] } +%struct.array2 = type { [2 x i8*] } +%struct.array3 = type { [3 x i8*] } +%struct.array4 = type { [4 x i8*] } +%struct.array5 = type { [5 x i8*] } +%struct.array6 = type { [6 x i8*] } +%struct.array7 = type { [7 x i8*] } +%struct.array8 = type { [8 x i8*] } +%struct.array9 = type { [9 x i8*] } +%struct.array10 = type { [10 x i8*] } +%struct.array11 = type { [11 x i8*] } +%struct.array12 = type { [12 x i8*] } +%struct.array13 = type { [13 x i8*] } +%struct.array14 = type { [14 x i8*] } +%struct.array15 = type { [15 x i8*] } +%struct.array16 = type { [16 x i8*] } +%struct.array17 = type { [17 x i8*] } +%struct.array18 = type { [18 x i8*] } +%struct.array19 = type { [19 x i8*] } +%struct.array20 = type { [20 x i8*] } + +; Function Attrs: noinline nounwind optnone +define hidden i8* @demo1(i8* %0) #0 { + %2 = alloca %struct.array1, align 4 + %3 = alloca %struct.array1, align 4 + %4 = getelementptr inbounds %struct.array1, %struct.array1* %3, i32 0, i32 0 + %5 = bitcast [1 x i8*]* %4 to i8** + store i8* %0, i8** %5, align 4 + %6 = bitcast %struct.array1* %2 to i8* + %7 = bitcast %struct.array1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 4, i1 false) + %8 = getelementptr inbounds %struct.array1, %struct.array1* %2, i32 0, i32 0 + %9 = bitcast [1 x i8*]* %8 to i8** + %10 = load i8*, i8** %9, align 4 + ret i8* %10 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define hidden void @demo2(%struct.array2* noalias sret(%struct.array2) align 4 %0, %struct.array2* noundef byval(%struct.array2) align 4 %1) #0 { + %3 = bitcast %struct.array2* %0 to i8* + %4 = bitcast %struct.array2* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo3(%struct.array3* noalias sret(%struct.array3) align 4 %0, %struct.array3* noundef byval(%struct.array3) align 4 %1) #0 { + %3 = bitcast %struct.array3* %0 to i8* + %4 = bitcast %struct.array3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo4(%struct.array4* noalias sret(%struct.array4) align 4 %0, %struct.array4* noundef byval(%struct.array4) align 4 %1) #0 { + %3 = bitcast %struct.array4* %0 to i8* + %4 = bitcast %struct.array4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo5(%struct.array5* noalias sret(%struct.array5) align 4 %0, %struct.array5* noundef byval(%struct.array5) align 4 %1) #0 { + %3 = bitcast %struct.array5* %0 to i8* + %4 = bitcast %struct.array5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo6(%struct.array6* noalias sret(%struct.array6) align 4 %0, %struct.array6* noundef byval(%struct.array6) align 4 %1) #0 { + %3 = bitcast %struct.array6* %0 to i8* + %4 = bitcast %struct.array6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo7(%struct.array7* noalias sret(%struct.array7) align 4 %0, %struct.array7* noundef byval(%struct.array7) align 4 %1) #0 { + %3 = bitcast %struct.array7* %0 to i8* + %4 = bitcast %struct.array7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo8(%struct.array8* noalias sret(%struct.array8) align 4 %0, %struct.array8* noundef byval(%struct.array8) align 4 %1) #0 { + %3 = bitcast %struct.array8* %0 to i8* + %4 = bitcast %struct.array8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo9(%struct.array9* noalias sret(%struct.array9) align 4 %0, %struct.array9* noundef byval(%struct.array9) align 4 %1) #0 { + %3 = bitcast %struct.array9* %0 to i8* + %4 = bitcast %struct.array9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo10(%struct.array10* noalias sret(%struct.array10) align 4 %0, %struct.array10* noundef byval(%struct.array10) align 4 %1) #0 { + %3 = bitcast %struct.array10* %0 to i8* + %4 = bitcast %struct.array10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo11(%struct.array11* noalias sret(%struct.array11) align 4 %0, %struct.array11* noundef byval(%struct.array11) align 4 %1) #0 { + %3 = bitcast %struct.array11* %0 to i8* + %4 = bitcast %struct.array11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo12(%struct.array12* noalias sret(%struct.array12) align 4 %0, %struct.array12* noundef byval(%struct.array12) align 4 %1) #0 { + %3 = bitcast %struct.array12* %0 to i8* + %4 = bitcast %struct.array12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo13(%struct.array13* noalias sret(%struct.array13) align 4 %0, %struct.array13* noundef byval(%struct.array13) align 4 %1) #0 { + %3 = bitcast %struct.array13* %0 to i8* + %4 = bitcast %struct.array13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo14(%struct.array14* noalias sret(%struct.array14) align 4 %0, %struct.array14* noundef byval(%struct.array14) align 4 %1) #0 { + %3 = bitcast %struct.array14* %0 to i8* + %4 = bitcast %struct.array14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo15(%struct.array15* noalias sret(%struct.array15) align 4 %0, %struct.array15* noundef byval(%struct.array15) align 4 %1) #0 { + %3 = bitcast %struct.array15* %0 to i8* + %4 = bitcast %struct.array15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo16(%struct.array16* noalias sret(%struct.array16) align 4 %0, %struct.array16* noundef byval(%struct.array16) align 4 %1) #0 { + %3 = bitcast %struct.array16* %0 to i8* + %4 = bitcast %struct.array16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo17(%struct.array17* noalias sret(%struct.array17) align 4 %0, %struct.array17* noundef byval(%struct.array17) align 4 %1) #0 { + %3 = bitcast %struct.array17* %0 to i8* + %4 = bitcast %struct.array17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo18(%struct.array18* noalias sret(%struct.array18) align 4 %0, %struct.array18* noundef byval(%struct.array18) align 4 %1) #0 { + %3 = bitcast %struct.array18* %0 to i8* + %4 = bitcast %struct.array18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo19(%struct.array19* noalias sret(%struct.array19) align 4 %0, %struct.array19* noundef byval(%struct.array19) align 4 %1) #0 { + %3 = bitcast %struct.array19* %0 to i8* + %4 = bitcast %struct.array19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo20(%struct.array20* noalias sret(%struct.array20) align 4 %0, %struct.array20* noundef byval(%struct.array20) align 4 %1) #0 { + %3 = bitcast %struct.array20* %0 to i8* + %4 = bitcast %struct.array20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0} +!llvm.ident = !{!1} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/wasm32/basic.ll b/internal/cabi/_testdata/arch/wasm32/basic.ll new file mode 100644 index 00000000..cb1fa4ef --- /dev/null +++ b/internal/cabi/_testdata/arch/wasm32/basic.ll @@ -0,0 +1,68 @@ +; ModuleID = '../../wrap/basic.c' +source_filename = "../../wrap/basic.c" +target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20" +target triple = "wasm32-unknown-emscripten" + +; Function Attrs: noinline nounwind optnone +define hidden signext i8 @basic_int8(i8 noundef signext %0) #0 { + %2 = alloca i8, align 1 + store i8 %0, i8* %2, align 1 + %3 = load i8, i8* %2, align 1 + ret i8 %3 +} + +; Function Attrs: noinline nounwind optnone +define hidden signext i16 @basic_int16(i16 noundef signext %0) #0 { + %2 = alloca i16, align 2 + store i16 %0, i16* %2, align 2 + %3 = load i16, i16* %2, align 2 + ret i16 %3 +} + +; Function Attrs: noinline nounwind optnone +define hidden i32 @basic_int32(i32 noundef %0) #0 { + %2 = alloca i32, align 4 + store i32 %0, i32* %2, align 4 + %3 = load i32, i32* %2, align 4 + ret i32 %3 +} + +; Function Attrs: noinline nounwind optnone +define hidden i64 @basic_int64(i64 noundef %0) #0 { + %2 = alloca i64, align 8 + store i64 %0, i64* %2, align 8 + %3 = load i64, i64* %2, align 8 + ret i64 %3 +} + +; Function Attrs: noinline nounwind optnone +define hidden float @basic_float32(float noundef %0) #0 { + %2 = alloca float, align 4 + store float %0, float* %2, align 4 + %3 = load float, float* %2, align 4 + ret float %3 +} + +; Function Attrs: noinline nounwind optnone +define hidden double @basic_float64(double noundef %0) #0 { + %2 = alloca double, align 8 + store double %0, double* %2, align 8 + %3 = load double, double* %2, align 8 + ret double %3 +} + +; Function Attrs: noinline nounwind optnone +define hidden i8* @basic_uintptr(i8* noundef %0) #0 { + %2 = alloca i8*, align 4 + store i8* %0, i8** %2, align 4 + %3 = load i8*, i8** %2, align 4 + ret i8* %3 +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" } + +!llvm.module.flags = !{!0} +!llvm.ident = !{!1} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/wasm32/struct_float32.ll b/internal/cabi/_testdata/arch/wasm32/struct_float32.ll new file mode 100644 index 00000000..9134559f --- /dev/null +++ b/internal/cabi/_testdata/arch/wasm32/struct_float32.ll @@ -0,0 +1,203 @@ +; ModuleID = '../../wrap/struct_float32.c' +source_filename = "../../wrap/struct_float32.c" +target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20" +target triple = "wasm32-unknown-emscripten" + +%struct.point1 = type { float } +%struct.point2 = type { float, float } +%struct.point3 = type { float, float, float } +%struct.point4 = type { float, float, float, float } +%struct.point5 = type { float, float, float, float, float } +%struct.point6 = type { float, float, float, float, float, float } +%struct.point7 = type { float, float, float, float, float, float, float } +%struct.point8 = type { float, float, float, float, float, float, float, float } +%struct.point9 = type { float, float, float, float, float, float, float, float, float } +%struct.point10 = type { float, float, float, float, float, float, float, float, float, float } +%struct.point11 = type { float, float, float, float, float, float, float, float, float, float, float } +%struct.point12 = type { float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point13 = type { float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point14 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point15 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point16 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point17 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point18 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point19 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } +%struct.point20 = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float } + +; Function Attrs: noinline nounwind optnone +define hidden float @demo1(float %0) #0 { + %2 = alloca %struct.point1, align 4 + %3 = alloca %struct.point1, align 4 + %4 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + store float %0, float* %4, align 4 + %5 = bitcast %struct.point1* %2 to i8* + %6 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 4, i1 false) + %7 = getelementptr inbounds %struct.point1, %struct.point1* %2, i32 0, i32 0 + %8 = load float, float* %7, align 4 + ret float %8 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define hidden void @demo2(%struct.point2* noalias sret(%struct.point2) align 4 %0, %struct.point2* noundef byval(%struct.point2) align 4 %1) #0 { + %3 = bitcast %struct.point2* %0 to i8* + %4 = bitcast %struct.point2* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo3(%struct.point3* noalias sret(%struct.point3) align 4 %0, %struct.point3* noundef byval(%struct.point3) align 4 %1) #0 { + %3 = bitcast %struct.point3* %0 to i8* + %4 = bitcast %struct.point3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo4(%struct.point4* noalias sret(%struct.point4) align 4 %0, %struct.point4* noundef byval(%struct.point4) align 4 %1) #0 { + %3 = bitcast %struct.point4* %0 to i8* + %4 = bitcast %struct.point4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo5(%struct.point5* noalias sret(%struct.point5) align 4 %0, %struct.point5* noundef byval(%struct.point5) align 4 %1) #0 { + %3 = bitcast %struct.point5* %0 to i8* + %4 = bitcast %struct.point5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo6(%struct.point6* noalias sret(%struct.point6) align 4 %0, %struct.point6* noundef byval(%struct.point6) align 4 %1) #0 { + %3 = bitcast %struct.point6* %0 to i8* + %4 = bitcast %struct.point6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo7(%struct.point7* noalias sret(%struct.point7) align 4 %0, %struct.point7* noundef byval(%struct.point7) align 4 %1) #0 { + %3 = bitcast %struct.point7* %0 to i8* + %4 = bitcast %struct.point7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo8(%struct.point8* noalias sret(%struct.point8) align 4 %0, %struct.point8* noundef byval(%struct.point8) align 4 %1) #0 { + %3 = bitcast %struct.point8* %0 to i8* + %4 = bitcast %struct.point8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo9(%struct.point9* noalias sret(%struct.point9) align 4 %0, %struct.point9* noundef byval(%struct.point9) align 4 %1) #0 { + %3 = bitcast %struct.point9* %0 to i8* + %4 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo10(%struct.point10* noalias sret(%struct.point10) align 4 %0, %struct.point10* noundef byval(%struct.point10) align 4 %1) #0 { + %3 = bitcast %struct.point10* %0 to i8* + %4 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo11(%struct.point11* noalias sret(%struct.point11) align 4 %0, %struct.point11* noundef byval(%struct.point11) align 4 %1) #0 { + %3 = bitcast %struct.point11* %0 to i8* + %4 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo12(%struct.point12* noalias sret(%struct.point12) align 4 %0, %struct.point12* noundef byval(%struct.point12) align 4 %1) #0 { + %3 = bitcast %struct.point12* %0 to i8* + %4 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo13(%struct.point13* noalias sret(%struct.point13) align 4 %0, %struct.point13* noundef byval(%struct.point13) align 4 %1) #0 { + %3 = bitcast %struct.point13* %0 to i8* + %4 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo14(%struct.point14* noalias sret(%struct.point14) align 4 %0, %struct.point14* noundef byval(%struct.point14) align 4 %1) #0 { + %3 = bitcast %struct.point14* %0 to i8* + %4 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo15(%struct.point15* noalias sret(%struct.point15) align 4 %0, %struct.point15* noundef byval(%struct.point15) align 4 %1) #0 { + %3 = bitcast %struct.point15* %0 to i8* + %4 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo16(%struct.point16* noalias sret(%struct.point16) align 4 %0, %struct.point16* noundef byval(%struct.point16) align 4 %1) #0 { + %3 = bitcast %struct.point16* %0 to i8* + %4 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo17(%struct.point17* noalias sret(%struct.point17) align 4 %0, %struct.point17* noundef byval(%struct.point17) align 4 %1) #0 { + %3 = bitcast %struct.point17* %0 to i8* + %4 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo18(%struct.point18* noalias sret(%struct.point18) align 4 %0, %struct.point18* noundef byval(%struct.point18) align 4 %1) #0 { + %3 = bitcast %struct.point18* %0 to i8* + %4 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo19(%struct.point19* noalias sret(%struct.point19) align 4 %0, %struct.point19* noundef byval(%struct.point19) align 4 %1) #0 { + %3 = bitcast %struct.point19* %0 to i8* + %4 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo20(%struct.point20* noalias sret(%struct.point20) align 4 %0, %struct.point20* noundef byval(%struct.point20) align 4 %1) #0 { + %3 = bitcast %struct.point20* %0 to i8* + %4 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0} +!llvm.ident = !{!1} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/wasm32/struct_float64.ll b/internal/cabi/_testdata/arch/wasm32/struct_float64.ll new file mode 100644 index 00000000..50cb1835 --- /dev/null +++ b/internal/cabi/_testdata/arch/wasm32/struct_float64.ll @@ -0,0 +1,203 @@ +; ModuleID = '../../wrap/struct_float64.c' +source_filename = "../../wrap/struct_float64.c" +target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20" +target triple = "wasm32-unknown-emscripten" + +%struct.point1 = type { double } +%struct.point2 = type { double, double } +%struct.point3 = type { double, double, double } +%struct.point4 = type { double, double, double, double } +%struct.point5 = type { double, double, double, double, double } +%struct.point6 = type { double, double, double, double, double, double } +%struct.point7 = type { double, double, double, double, double, double, double } +%struct.point8 = type { double, double, double, double, double, double, double, double } +%struct.point9 = type { double, double, double, double, double, double, double, double, double } +%struct.point10 = type { double, double, double, double, double, double, double, double, double, double } +%struct.point11 = type { double, double, double, double, double, double, double, double, double, double, double } +%struct.point12 = type { double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point13 = type { double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point14 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point15 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point16 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point17 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point18 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point19 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } +%struct.point20 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } + +; Function Attrs: noinline nounwind optnone +define hidden double @demo1(double %0) #0 { + %2 = alloca %struct.point1, align 8 + %3 = alloca %struct.point1, align 8 + %4 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + store double %0, double* %4, align 8 + %5 = bitcast %struct.point1* %2 to i8* + %6 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %5, i8* align 8 %6, i32 8, i1 false) + %7 = getelementptr inbounds %struct.point1, %struct.point1* %2, i32 0, i32 0 + %8 = load double, double* %7, align 8 + ret double %8 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define hidden void @demo2(%struct.point2* noalias sret(%struct.point2) align 8 %0, %struct.point2* noundef byval(%struct.point2) align 8 %1) #0 { + %3 = bitcast %struct.point2* %0 to i8* + %4 = bitcast %struct.point2* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo3(%struct.point3* noalias sret(%struct.point3) align 8 %0, %struct.point3* noundef byval(%struct.point3) align 8 %1) #0 { + %3 = bitcast %struct.point3* %0 to i8* + %4 = bitcast %struct.point3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo4(%struct.point4* noalias sret(%struct.point4) align 8 %0, %struct.point4* noundef byval(%struct.point4) align 8 %1) #0 { + %3 = bitcast %struct.point4* %0 to i8* + %4 = bitcast %struct.point4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo5(%struct.point5* noalias sret(%struct.point5) align 8 %0, %struct.point5* noundef byval(%struct.point5) align 8 %1) #0 { + %3 = bitcast %struct.point5* %0 to i8* + %4 = bitcast %struct.point5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo6(%struct.point6* noalias sret(%struct.point6) align 8 %0, %struct.point6* noundef byval(%struct.point6) align 8 %1) #0 { + %3 = bitcast %struct.point6* %0 to i8* + %4 = bitcast %struct.point6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo7(%struct.point7* noalias sret(%struct.point7) align 8 %0, %struct.point7* noundef byval(%struct.point7) align 8 %1) #0 { + %3 = bitcast %struct.point7* %0 to i8* + %4 = bitcast %struct.point7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo8(%struct.point8* noalias sret(%struct.point8) align 8 %0, %struct.point8* noundef byval(%struct.point8) align 8 %1) #0 { + %3 = bitcast %struct.point8* %0 to i8* + %4 = bitcast %struct.point8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo9(%struct.point9* noalias sret(%struct.point9) align 8 %0, %struct.point9* noundef byval(%struct.point9) align 8 %1) #0 { + %3 = bitcast %struct.point9* %0 to i8* + %4 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo10(%struct.point10* noalias sret(%struct.point10) align 8 %0, %struct.point10* noundef byval(%struct.point10) align 8 %1) #0 { + %3 = bitcast %struct.point10* %0 to i8* + %4 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo11(%struct.point11* noalias sret(%struct.point11) align 8 %0, %struct.point11* noundef byval(%struct.point11) align 8 %1) #0 { + %3 = bitcast %struct.point11* %0 to i8* + %4 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo12(%struct.point12* noalias sret(%struct.point12) align 8 %0, %struct.point12* noundef byval(%struct.point12) align 8 %1) #0 { + %3 = bitcast %struct.point12* %0 to i8* + %4 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo13(%struct.point13* noalias sret(%struct.point13) align 8 %0, %struct.point13* noundef byval(%struct.point13) align 8 %1) #0 { + %3 = bitcast %struct.point13* %0 to i8* + %4 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo14(%struct.point14* noalias sret(%struct.point14) align 8 %0, %struct.point14* noundef byval(%struct.point14) align 8 %1) #0 { + %3 = bitcast %struct.point14* %0 to i8* + %4 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo15(%struct.point15* noalias sret(%struct.point15) align 8 %0, %struct.point15* noundef byval(%struct.point15) align 8 %1) #0 { + %3 = bitcast %struct.point15* %0 to i8* + %4 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo16(%struct.point16* noalias sret(%struct.point16) align 8 %0, %struct.point16* noundef byval(%struct.point16) align 8 %1) #0 { + %3 = bitcast %struct.point16* %0 to i8* + %4 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo17(%struct.point17* noalias sret(%struct.point17) align 8 %0, %struct.point17* noundef byval(%struct.point17) align 8 %1) #0 { + %3 = bitcast %struct.point17* %0 to i8* + %4 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo18(%struct.point18* noalias sret(%struct.point18) align 8 %0, %struct.point18* noundef byval(%struct.point18) align 8 %1) #0 { + %3 = bitcast %struct.point18* %0 to i8* + %4 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo19(%struct.point19* noalias sret(%struct.point19) align 8 %0, %struct.point19* noundef byval(%struct.point19) align 8 %1) #0 { + %3 = bitcast %struct.point19* %0 to i8* + %4 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo20(%struct.point20* noalias sret(%struct.point20) align 8 %0, %struct.point20* noundef byval(%struct.point20) align 8 %1) #0 { + %3 = bitcast %struct.point20* %0 to i8* + %4 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0} +!llvm.ident = !{!1} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/wasm32/struct_int16.ll b/internal/cabi/_testdata/arch/wasm32/struct_int16.ll new file mode 100644 index 00000000..3330ffd1 --- /dev/null +++ b/internal/cabi/_testdata/arch/wasm32/struct_int16.ll @@ -0,0 +1,203 @@ +; ModuleID = '../../wrap/struct_int16.c' +source_filename = "../../wrap/struct_int16.c" +target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20" +target triple = "wasm32-unknown-emscripten" + +%struct.point1 = type { i16 } +%struct.point2 = type { i16, i16 } +%struct.point3 = type { i16, i16, i16 } +%struct.point4 = type { i16, i16, i16, i16 } +%struct.point5 = type { i16, i16, i16, i16, i16 } +%struct.point6 = type { i16, i16, i16, i16, i16, i16 } +%struct.point7 = type { i16, i16, i16, i16, i16, i16, i16 } +%struct.point8 = type { i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point9 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point10 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point11 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point12 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point13 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point14 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point15 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point16 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point17 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point18 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point19 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } +%struct.point20 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 } + +; Function Attrs: noinline nounwind optnone +define hidden i16 @demo1(i16 %0) #0 { + %2 = alloca %struct.point1, align 2 + %3 = alloca %struct.point1, align 2 + %4 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + store i16 %0, i16* %4, align 2 + %5 = bitcast %struct.point1* %2 to i8* + %6 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %5, i8* align 2 %6, i32 2, i1 false) + %7 = getelementptr inbounds %struct.point1, %struct.point1* %2, i32 0, i32 0 + %8 = load i16, i16* %7, align 2 + ret i16 %8 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define hidden void @demo2(%struct.point2* noalias sret(%struct.point2) align 2 %0, %struct.point2* noundef byval(%struct.point2) align 2 %1) #0 { + %3 = bitcast %struct.point2* %0 to i8* + %4 = bitcast %struct.point2* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 4, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo3(%struct.point3* noalias sret(%struct.point3) align 2 %0, %struct.point3* noundef byval(%struct.point3) align 2 %1) #0 { + %3 = bitcast %struct.point3* %0 to i8* + %4 = bitcast %struct.point3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 6, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo4(%struct.point4* noalias sret(%struct.point4) align 2 %0, %struct.point4* noundef byval(%struct.point4) align 2 %1) #0 { + %3 = bitcast %struct.point4* %0 to i8* + %4 = bitcast %struct.point4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo5(%struct.point5* noalias sret(%struct.point5) align 2 %0, %struct.point5* noundef byval(%struct.point5) align 2 %1) #0 { + %3 = bitcast %struct.point5* %0 to i8* + %4 = bitcast %struct.point5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 10, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo6(%struct.point6* noalias sret(%struct.point6) align 2 %0, %struct.point6* noundef byval(%struct.point6) align 2 %1) #0 { + %3 = bitcast %struct.point6* %0 to i8* + %4 = bitcast %struct.point6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo7(%struct.point7* noalias sret(%struct.point7) align 2 %0, %struct.point7* noundef byval(%struct.point7) align 2 %1) #0 { + %3 = bitcast %struct.point7* %0 to i8* + %4 = bitcast %struct.point7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 14, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo8(%struct.point8* noalias sret(%struct.point8) align 2 %0, %struct.point8* noundef byval(%struct.point8) align 2 %1) #0 { + %3 = bitcast %struct.point8* %0 to i8* + %4 = bitcast %struct.point8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo9(%struct.point9* noalias sret(%struct.point9) align 2 %0, %struct.point9* noundef byval(%struct.point9) align 2 %1) #0 { + %3 = bitcast %struct.point9* %0 to i8* + %4 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 18, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo10(%struct.point10* noalias sret(%struct.point10) align 2 %0, %struct.point10* noundef byval(%struct.point10) align 2 %1) #0 { + %3 = bitcast %struct.point10* %0 to i8* + %4 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo11(%struct.point11* noalias sret(%struct.point11) align 2 %0, %struct.point11* noundef byval(%struct.point11) align 2 %1) #0 { + %3 = bitcast %struct.point11* %0 to i8* + %4 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 22, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo12(%struct.point12* noalias sret(%struct.point12) align 2 %0, %struct.point12* noundef byval(%struct.point12) align 2 %1) #0 { + %3 = bitcast %struct.point12* %0 to i8* + %4 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo13(%struct.point13* noalias sret(%struct.point13) align 2 %0, %struct.point13* noundef byval(%struct.point13) align 2 %1) #0 { + %3 = bitcast %struct.point13* %0 to i8* + %4 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 26, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo14(%struct.point14* noalias sret(%struct.point14) align 2 %0, %struct.point14* noundef byval(%struct.point14) align 2 %1) #0 { + %3 = bitcast %struct.point14* %0 to i8* + %4 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo15(%struct.point15* noalias sret(%struct.point15) align 2 %0, %struct.point15* noundef byval(%struct.point15) align 2 %1) #0 { + %3 = bitcast %struct.point15* %0 to i8* + %4 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 30, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo16(%struct.point16* noalias sret(%struct.point16) align 2 %0, %struct.point16* noundef byval(%struct.point16) align 2 %1) #0 { + %3 = bitcast %struct.point16* %0 to i8* + %4 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo17(%struct.point17* noalias sret(%struct.point17) align 2 %0, %struct.point17* noundef byval(%struct.point17) align 2 %1) #0 { + %3 = bitcast %struct.point17* %0 to i8* + %4 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 34, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo18(%struct.point18* noalias sret(%struct.point18) align 2 %0, %struct.point18* noundef byval(%struct.point18) align 2 %1) #0 { + %3 = bitcast %struct.point18* %0 to i8* + %4 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo19(%struct.point19* noalias sret(%struct.point19) align 2 %0, %struct.point19* noundef byval(%struct.point19) align 2 %1) #0 { + %3 = bitcast %struct.point19* %0 to i8* + %4 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 38, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo20(%struct.point20* noalias sret(%struct.point20) align 2 %0, %struct.point20* noundef byval(%struct.point20) align 2 %1) #0 { + %3 = bitcast %struct.point20* %0 to i8* + %4 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %3, i8* align 2 %4, i32 40, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0} +!llvm.ident = !{!1} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/wasm32/struct_int32.ll b/internal/cabi/_testdata/arch/wasm32/struct_int32.ll new file mode 100644 index 00000000..433a2e71 --- /dev/null +++ b/internal/cabi/_testdata/arch/wasm32/struct_int32.ll @@ -0,0 +1,203 @@ +; ModuleID = '../../wrap/struct_int32.c' +source_filename = "../../wrap/struct_int32.c" +target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20" +target triple = "wasm32-unknown-emscripten" + +%struct.point1 = type { i32 } +%struct.point2 = type { i32, i32 } +%struct.point3 = type { i32, i32, i32 } +%struct.point4 = type { i32, i32, i32, i32 } +%struct.point5 = type { i32, i32, i32, i32, i32 } +%struct.point6 = type { i32, i32, i32, i32, i32, i32 } +%struct.point7 = type { i32, i32, i32, i32, i32, i32, i32 } +%struct.point8 = type { i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point9 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point10 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point11 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point12 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point13 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point14 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point15 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point16 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point17 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point18 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point19 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } +%struct.point20 = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } + +; Function Attrs: noinline nounwind optnone +define hidden i32 @demo1(i32 %0) #0 { + %2 = alloca %struct.point1, align 4 + %3 = alloca %struct.point1, align 4 + %4 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + store i32 %0, i32* %4, align 4 + %5 = bitcast %struct.point1* %2 to i8* + %6 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 4, i1 false) + %7 = getelementptr inbounds %struct.point1, %struct.point1* %2, i32 0, i32 0 + %8 = load i32, i32* %7, align 4 + ret i32 %8 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define hidden void @demo2(%struct.point2* noalias sret(%struct.point2) align 4 %0, %struct.point2* noundef byval(%struct.point2) align 4 %1) #0 { + %3 = bitcast %struct.point2* %0 to i8* + %4 = bitcast %struct.point2* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo3(%struct.point3* noalias sret(%struct.point3) align 4 %0, %struct.point3* noundef byval(%struct.point3) align 4 %1) #0 { + %3 = bitcast %struct.point3* %0 to i8* + %4 = bitcast %struct.point3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo4(%struct.point4* noalias sret(%struct.point4) align 4 %0, %struct.point4* noundef byval(%struct.point4) align 4 %1) #0 { + %3 = bitcast %struct.point4* %0 to i8* + %4 = bitcast %struct.point4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo5(%struct.point5* noalias sret(%struct.point5) align 4 %0, %struct.point5* noundef byval(%struct.point5) align 4 %1) #0 { + %3 = bitcast %struct.point5* %0 to i8* + %4 = bitcast %struct.point5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo6(%struct.point6* noalias sret(%struct.point6) align 4 %0, %struct.point6* noundef byval(%struct.point6) align 4 %1) #0 { + %3 = bitcast %struct.point6* %0 to i8* + %4 = bitcast %struct.point6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo7(%struct.point7* noalias sret(%struct.point7) align 4 %0, %struct.point7* noundef byval(%struct.point7) align 4 %1) #0 { + %3 = bitcast %struct.point7* %0 to i8* + %4 = bitcast %struct.point7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo8(%struct.point8* noalias sret(%struct.point8) align 4 %0, %struct.point8* noundef byval(%struct.point8) align 4 %1) #0 { + %3 = bitcast %struct.point8* %0 to i8* + %4 = bitcast %struct.point8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo9(%struct.point9* noalias sret(%struct.point9) align 4 %0, %struct.point9* noundef byval(%struct.point9) align 4 %1) #0 { + %3 = bitcast %struct.point9* %0 to i8* + %4 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo10(%struct.point10* noalias sret(%struct.point10) align 4 %0, %struct.point10* noundef byval(%struct.point10) align 4 %1) #0 { + %3 = bitcast %struct.point10* %0 to i8* + %4 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo11(%struct.point11* noalias sret(%struct.point11) align 4 %0, %struct.point11* noundef byval(%struct.point11) align 4 %1) #0 { + %3 = bitcast %struct.point11* %0 to i8* + %4 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo12(%struct.point12* noalias sret(%struct.point12) align 4 %0, %struct.point12* noundef byval(%struct.point12) align 4 %1) #0 { + %3 = bitcast %struct.point12* %0 to i8* + %4 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo13(%struct.point13* noalias sret(%struct.point13) align 4 %0, %struct.point13* noundef byval(%struct.point13) align 4 %1) #0 { + %3 = bitcast %struct.point13* %0 to i8* + %4 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo14(%struct.point14* noalias sret(%struct.point14) align 4 %0, %struct.point14* noundef byval(%struct.point14) align 4 %1) #0 { + %3 = bitcast %struct.point14* %0 to i8* + %4 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo15(%struct.point15* noalias sret(%struct.point15) align 4 %0, %struct.point15* noundef byval(%struct.point15) align 4 %1) #0 { + %3 = bitcast %struct.point15* %0 to i8* + %4 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo16(%struct.point16* noalias sret(%struct.point16) align 4 %0, %struct.point16* noundef byval(%struct.point16) align 4 %1) #0 { + %3 = bitcast %struct.point16* %0 to i8* + %4 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo17(%struct.point17* noalias sret(%struct.point17) align 4 %0, %struct.point17* noundef byval(%struct.point17) align 4 %1) #0 { + %3 = bitcast %struct.point17* %0 to i8* + %4 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo18(%struct.point18* noalias sret(%struct.point18) align 4 %0, %struct.point18* noundef byval(%struct.point18) align 4 %1) #0 { + %3 = bitcast %struct.point18* %0 to i8* + %4 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo19(%struct.point19* noalias sret(%struct.point19) align 4 %0, %struct.point19* noundef byval(%struct.point19) align 4 %1) #0 { + %3 = bitcast %struct.point19* %0 to i8* + %4 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo20(%struct.point20* noalias sret(%struct.point20) align 4 %0, %struct.point20* noundef byval(%struct.point20) align 4 %1) #0 { + %3 = bitcast %struct.point20* %0 to i8* + %4 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0} +!llvm.ident = !{!1} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/wasm32/struct_int64.ll b/internal/cabi/_testdata/arch/wasm32/struct_int64.ll new file mode 100644 index 00000000..a09a4af7 --- /dev/null +++ b/internal/cabi/_testdata/arch/wasm32/struct_int64.ll @@ -0,0 +1,203 @@ +; ModuleID = '../../wrap/struct_int64.c' +source_filename = "../../wrap/struct_int64.c" +target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20" +target triple = "wasm32-unknown-emscripten" + +%struct.point1 = type { i64 } +%struct.point2 = type { i64, i64 } +%struct.point3 = type { i64, i64, i64 } +%struct.point4 = type { i64, i64, i64, i64 } +%struct.point5 = type { i64, i64, i64, i64, i64 } +%struct.point6 = type { i64, i64, i64, i64, i64, i64 } +%struct.point7 = type { i64, i64, i64, i64, i64, i64, i64 } +%struct.point8 = type { i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point9 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point10 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point11 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point12 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point13 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point14 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point15 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point16 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point17 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point18 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point19 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } +%struct.point20 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } + +; Function Attrs: noinline nounwind optnone +define hidden i64 @demo1(i64 %0) #0 { + %2 = alloca %struct.point1, align 8 + %3 = alloca %struct.point1, align 8 + %4 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + store i64 %0, i64* %4, align 8 + %5 = bitcast %struct.point1* %2 to i8* + %6 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %5, i8* align 8 %6, i32 8, i1 false) + %7 = getelementptr inbounds %struct.point1, %struct.point1* %2, i32 0, i32 0 + %8 = load i64, i64* %7, align 8 + ret i64 %8 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define hidden void @demo2(%struct.point2* noalias sret(%struct.point2) align 8 %0, %struct.point2* noundef byval(%struct.point2) align 8 %1) #0 { + %3 = bitcast %struct.point2* %0 to i8* + %4 = bitcast %struct.point2* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo3(%struct.point3* noalias sret(%struct.point3) align 8 %0, %struct.point3* noundef byval(%struct.point3) align 8 %1) #0 { + %3 = bitcast %struct.point3* %0 to i8* + %4 = bitcast %struct.point3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo4(%struct.point4* noalias sret(%struct.point4) align 8 %0, %struct.point4* noundef byval(%struct.point4) align 8 %1) #0 { + %3 = bitcast %struct.point4* %0 to i8* + %4 = bitcast %struct.point4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo5(%struct.point5* noalias sret(%struct.point5) align 8 %0, %struct.point5* noundef byval(%struct.point5) align 8 %1) #0 { + %3 = bitcast %struct.point5* %0 to i8* + %4 = bitcast %struct.point5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo6(%struct.point6* noalias sret(%struct.point6) align 8 %0, %struct.point6* noundef byval(%struct.point6) align 8 %1) #0 { + %3 = bitcast %struct.point6* %0 to i8* + %4 = bitcast %struct.point6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo7(%struct.point7* noalias sret(%struct.point7) align 8 %0, %struct.point7* noundef byval(%struct.point7) align 8 %1) #0 { + %3 = bitcast %struct.point7* %0 to i8* + %4 = bitcast %struct.point7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo8(%struct.point8* noalias sret(%struct.point8) align 8 %0, %struct.point8* noundef byval(%struct.point8) align 8 %1) #0 { + %3 = bitcast %struct.point8* %0 to i8* + %4 = bitcast %struct.point8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo9(%struct.point9* noalias sret(%struct.point9) align 8 %0, %struct.point9* noundef byval(%struct.point9) align 8 %1) #0 { + %3 = bitcast %struct.point9* %0 to i8* + %4 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo10(%struct.point10* noalias sret(%struct.point10) align 8 %0, %struct.point10* noundef byval(%struct.point10) align 8 %1) #0 { + %3 = bitcast %struct.point10* %0 to i8* + %4 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 80, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo11(%struct.point11* noalias sret(%struct.point11) align 8 %0, %struct.point11* noundef byval(%struct.point11) align 8 %1) #0 { + %3 = bitcast %struct.point11* %0 to i8* + %4 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 88, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo12(%struct.point12* noalias sret(%struct.point12) align 8 %0, %struct.point12* noundef byval(%struct.point12) align 8 %1) #0 { + %3 = bitcast %struct.point12* %0 to i8* + %4 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 96, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo13(%struct.point13* noalias sret(%struct.point13) align 8 %0, %struct.point13* noundef byval(%struct.point13) align 8 %1) #0 { + %3 = bitcast %struct.point13* %0 to i8* + %4 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 104, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo14(%struct.point14* noalias sret(%struct.point14) align 8 %0, %struct.point14* noundef byval(%struct.point14) align 8 %1) #0 { + %3 = bitcast %struct.point14* %0 to i8* + %4 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 112, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo15(%struct.point15* noalias sret(%struct.point15) align 8 %0, %struct.point15* noundef byval(%struct.point15) align 8 %1) #0 { + %3 = bitcast %struct.point15* %0 to i8* + %4 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 120, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo16(%struct.point16* noalias sret(%struct.point16) align 8 %0, %struct.point16* noundef byval(%struct.point16) align 8 %1) #0 { + %3 = bitcast %struct.point16* %0 to i8* + %4 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 128, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo17(%struct.point17* noalias sret(%struct.point17) align 8 %0, %struct.point17* noundef byval(%struct.point17) align 8 %1) #0 { + %3 = bitcast %struct.point17* %0 to i8* + %4 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 136, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo18(%struct.point18* noalias sret(%struct.point18) align 8 %0, %struct.point18* noundef byval(%struct.point18) align 8 %1) #0 { + %3 = bitcast %struct.point18* %0 to i8* + %4 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 144, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo19(%struct.point19* noalias sret(%struct.point19) align 8 %0, %struct.point19* noundef byval(%struct.point19) align 8 %1) #0 { + %3 = bitcast %struct.point19* %0 to i8* + %4 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 152, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo20(%struct.point20* noalias sret(%struct.point20) align 8 %0, %struct.point20* noundef byval(%struct.point20) align 8 %1) #0 { + %3 = bitcast %struct.point20* %0 to i8* + %4 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 160, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0} +!llvm.ident = !{!1} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/wasm32/struct_int8.ll b/internal/cabi/_testdata/arch/wasm32/struct_int8.ll new file mode 100644 index 00000000..a5ca8a00 --- /dev/null +++ b/internal/cabi/_testdata/arch/wasm32/struct_int8.ll @@ -0,0 +1,203 @@ +; ModuleID = '../../wrap/struct_int8.c' +source_filename = "../../wrap/struct_int8.c" +target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20" +target triple = "wasm32-unknown-emscripten" + +%struct.point1 = type { i8 } +%struct.point2 = type { i8, i8 } +%struct.point3 = type { i8, i8, i8 } +%struct.point4 = type { i8, i8, i8, i8 } +%struct.point5 = type { i8, i8, i8, i8, i8 } +%struct.point6 = type { i8, i8, i8, i8, i8, i8 } +%struct.point7 = type { i8, i8, i8, i8, i8, i8, i8 } +%struct.point8 = type { i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point9 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point10 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point11 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point12 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point13 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point14 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point15 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point16 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point17 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point18 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point19 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } +%struct.point20 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 } + +; Function Attrs: noinline nounwind optnone +define hidden i8 @demo1(i8 %0) #0 { + %2 = alloca %struct.point1, align 1 + %3 = alloca %struct.point1, align 1 + %4 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + store i8 %0, i8* %4, align 1 + %5 = bitcast %struct.point1* %2 to i8* + %6 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 1 %6, i32 1, i1 false) + %7 = getelementptr inbounds %struct.point1, %struct.point1* %2, i32 0, i32 0 + %8 = load i8, i8* %7, align 1 + ret i8 %8 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define hidden void @demo2(%struct.point2* noalias sret(%struct.point2) align 1 %0, %struct.point2* noundef byval(%struct.point2) align 1 %1) #0 { + %3 = bitcast %struct.point2* %0 to i8* + %4 = bitcast %struct.point2* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 2, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo3(%struct.point3* noalias sret(%struct.point3) align 1 %0, %struct.point3* noundef byval(%struct.point3) align 1 %1) #0 { + %3 = bitcast %struct.point3* %0 to i8* + %4 = bitcast %struct.point3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 3, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo4(%struct.point4* noalias sret(%struct.point4) align 1 %0, %struct.point4* noundef byval(%struct.point4) align 1 %1) #0 { + %3 = bitcast %struct.point4* %0 to i8* + %4 = bitcast %struct.point4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 4, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo5(%struct.point5* noalias sret(%struct.point5) align 1 %0, %struct.point5* noundef byval(%struct.point5) align 1 %1) #0 { + %3 = bitcast %struct.point5* %0 to i8* + %4 = bitcast %struct.point5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 5, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo6(%struct.point6* noalias sret(%struct.point6) align 1 %0, %struct.point6* noundef byval(%struct.point6) align 1 %1) #0 { + %3 = bitcast %struct.point6* %0 to i8* + %4 = bitcast %struct.point6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 6, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo7(%struct.point7* noalias sret(%struct.point7) align 1 %0, %struct.point7* noundef byval(%struct.point7) align 1 %1) #0 { + %3 = bitcast %struct.point7* %0 to i8* + %4 = bitcast %struct.point7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 7, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo8(%struct.point8* noalias sret(%struct.point8) align 1 %0, %struct.point8* noundef byval(%struct.point8) align 1 %1) #0 { + %3 = bitcast %struct.point8* %0 to i8* + %4 = bitcast %struct.point8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo9(%struct.point9* noalias sret(%struct.point9) align 1 %0, %struct.point9* noundef byval(%struct.point9) align 1 %1) #0 { + %3 = bitcast %struct.point9* %0 to i8* + %4 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 9, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo10(%struct.point10* noalias sret(%struct.point10) align 1 %0, %struct.point10* noundef byval(%struct.point10) align 1 %1) #0 { + %3 = bitcast %struct.point10* %0 to i8* + %4 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 10, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo11(%struct.point11* noalias sret(%struct.point11) align 1 %0, %struct.point11* noundef byval(%struct.point11) align 1 %1) #0 { + %3 = bitcast %struct.point11* %0 to i8* + %4 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 11, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo12(%struct.point12* noalias sret(%struct.point12) align 1 %0, %struct.point12* noundef byval(%struct.point12) align 1 %1) #0 { + %3 = bitcast %struct.point12* %0 to i8* + %4 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo13(%struct.point13* noalias sret(%struct.point13) align 1 %0, %struct.point13* noundef byval(%struct.point13) align 1 %1) #0 { + %3 = bitcast %struct.point13* %0 to i8* + %4 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 13, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo14(%struct.point14* noalias sret(%struct.point14) align 1 %0, %struct.point14* noundef byval(%struct.point14) align 1 %1) #0 { + %3 = bitcast %struct.point14* %0 to i8* + %4 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 14, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo15(%struct.point15* noalias sret(%struct.point15) align 1 %0, %struct.point15* noundef byval(%struct.point15) align 1 %1) #0 { + %3 = bitcast %struct.point15* %0 to i8* + %4 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 15, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo16(%struct.point16* noalias sret(%struct.point16) align 1 %0, %struct.point16* noundef byval(%struct.point16) align 1 %1) #0 { + %3 = bitcast %struct.point16* %0 to i8* + %4 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo17(%struct.point17* noalias sret(%struct.point17) align 1 %0, %struct.point17* noundef byval(%struct.point17) align 1 %1) #0 { + %3 = bitcast %struct.point17* %0 to i8* + %4 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 17, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo18(%struct.point18* noalias sret(%struct.point18) align 1 %0, %struct.point18* noundef byval(%struct.point18) align 1 %1) #0 { + %3 = bitcast %struct.point18* %0 to i8* + %4 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 18, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo19(%struct.point19* noalias sret(%struct.point19) align 1 %0, %struct.point19* noundef byval(%struct.point19) align 1 %1) #0 { + %3 = bitcast %struct.point19* %0 to i8* + %4 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 19, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo20(%struct.point20* noalias sret(%struct.point20) align 1 %0, %struct.point20* noundef byval(%struct.point20) align 1 %1) #0 { + %3 = bitcast %struct.point20* %0 to i8* + %4 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %3, i8* align 1 %4, i32 20, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0} +!llvm.ident = !{!1} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/arch/wasm32/struct_uintptr.ll b/internal/cabi/_testdata/arch/wasm32/struct_uintptr.ll new file mode 100644 index 00000000..22b45609 --- /dev/null +++ b/internal/cabi/_testdata/arch/wasm32/struct_uintptr.ll @@ -0,0 +1,203 @@ +; ModuleID = '../../wrap/struct_uintptr.c' +source_filename = "../../wrap/struct_uintptr.c" +target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20" +target triple = "wasm32-unknown-emscripten" + +%struct.point1 = type { i8* } +%struct.point2 = type { i8*, i8* } +%struct.point3 = type { i8*, i8*, i8* } +%struct.point4 = type { i8*, i8*, i8*, i8* } +%struct.point5 = type { i8*, i8*, i8*, i8*, i8* } +%struct.point6 = type { i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point7 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point8 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point9 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point10 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point11 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point12 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point13 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point14 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point15 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point16 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point17 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point18 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point19 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } +%struct.point20 = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* } + +; Function Attrs: noinline nounwind optnone +define hidden i8* @demo1(i8* %0) #0 { + %2 = alloca %struct.point1, align 4 + %3 = alloca %struct.point1, align 4 + %4 = getelementptr inbounds %struct.point1, %struct.point1* %3, i32 0, i32 0 + store i8* %0, i8** %4, align 4 + %5 = bitcast %struct.point1* %2 to i8* + %6 = bitcast %struct.point1* %3 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 4, i1 false) + %7 = getelementptr inbounds %struct.point1, %struct.point1* %2, i32 0, i32 0 + %8 = load i8*, i8** %7, align 4 + ret i8* %8 +} + +; Function Attrs: argmemonly nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +; Function Attrs: noinline nounwind optnone +define hidden void @demo2(%struct.point2* noalias sret(%struct.point2) align 4 %0, %struct.point2* noundef byval(%struct.point2) align 4 %1) #0 { + %3 = bitcast %struct.point2* %0 to i8* + %4 = bitcast %struct.point2* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 8, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo3(%struct.point3* noalias sret(%struct.point3) align 4 %0, %struct.point3* noundef byval(%struct.point3) align 4 %1) #0 { + %3 = bitcast %struct.point3* %0 to i8* + %4 = bitcast %struct.point3* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 12, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo4(%struct.point4* noalias sret(%struct.point4) align 4 %0, %struct.point4* noundef byval(%struct.point4) align 4 %1) #0 { + %3 = bitcast %struct.point4* %0 to i8* + %4 = bitcast %struct.point4* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 16, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo5(%struct.point5* noalias sret(%struct.point5) align 4 %0, %struct.point5* noundef byval(%struct.point5) align 4 %1) #0 { + %3 = bitcast %struct.point5* %0 to i8* + %4 = bitcast %struct.point5* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 20, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo6(%struct.point6* noalias sret(%struct.point6) align 4 %0, %struct.point6* noundef byval(%struct.point6) align 4 %1) #0 { + %3 = bitcast %struct.point6* %0 to i8* + %4 = bitcast %struct.point6* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 24, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo7(%struct.point7* noalias sret(%struct.point7) align 4 %0, %struct.point7* noundef byval(%struct.point7) align 4 %1) #0 { + %3 = bitcast %struct.point7* %0 to i8* + %4 = bitcast %struct.point7* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 28, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo8(%struct.point8* noalias sret(%struct.point8) align 4 %0, %struct.point8* noundef byval(%struct.point8) align 4 %1) #0 { + %3 = bitcast %struct.point8* %0 to i8* + %4 = bitcast %struct.point8* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 32, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo9(%struct.point9* noalias sret(%struct.point9) align 4 %0, %struct.point9* noundef byval(%struct.point9) align 4 %1) #0 { + %3 = bitcast %struct.point9* %0 to i8* + %4 = bitcast %struct.point9* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 36, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo10(%struct.point10* noalias sret(%struct.point10) align 4 %0, %struct.point10* noundef byval(%struct.point10) align 4 %1) #0 { + %3 = bitcast %struct.point10* %0 to i8* + %4 = bitcast %struct.point10* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 40, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo11(%struct.point11* noalias sret(%struct.point11) align 4 %0, %struct.point11* noundef byval(%struct.point11) align 4 %1) #0 { + %3 = bitcast %struct.point11* %0 to i8* + %4 = bitcast %struct.point11* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 44, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo12(%struct.point12* noalias sret(%struct.point12) align 4 %0, %struct.point12* noundef byval(%struct.point12) align 4 %1) #0 { + %3 = bitcast %struct.point12* %0 to i8* + %4 = bitcast %struct.point12* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 48, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo13(%struct.point13* noalias sret(%struct.point13) align 4 %0, %struct.point13* noundef byval(%struct.point13) align 4 %1) #0 { + %3 = bitcast %struct.point13* %0 to i8* + %4 = bitcast %struct.point13* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 52, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo14(%struct.point14* noalias sret(%struct.point14) align 4 %0, %struct.point14* noundef byval(%struct.point14) align 4 %1) #0 { + %3 = bitcast %struct.point14* %0 to i8* + %4 = bitcast %struct.point14* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 56, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo15(%struct.point15* noalias sret(%struct.point15) align 4 %0, %struct.point15* noundef byval(%struct.point15) align 4 %1) #0 { + %3 = bitcast %struct.point15* %0 to i8* + %4 = bitcast %struct.point15* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 60, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo16(%struct.point16* noalias sret(%struct.point16) align 4 %0, %struct.point16* noundef byval(%struct.point16) align 4 %1) #0 { + %3 = bitcast %struct.point16* %0 to i8* + %4 = bitcast %struct.point16* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 64, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo17(%struct.point17* noalias sret(%struct.point17) align 4 %0, %struct.point17* noundef byval(%struct.point17) align 4 %1) #0 { + %3 = bitcast %struct.point17* %0 to i8* + %4 = bitcast %struct.point17* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 68, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo18(%struct.point18* noalias sret(%struct.point18) align 4 %0, %struct.point18* noundef byval(%struct.point18) align 4 %1) #0 { + %3 = bitcast %struct.point18* %0 to i8* + %4 = bitcast %struct.point18* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 72, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo19(%struct.point19* noalias sret(%struct.point19) align 4 %0, %struct.point19* noundef byval(%struct.point19) align 4 %1) #0 { + %3 = bitcast %struct.point19* %0 to i8* + %4 = bitcast %struct.point19* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 76, i1 false) + ret void +} + +; Function Attrs: noinline nounwind optnone +define hidden void @demo20(%struct.point20* noalias sret(%struct.point20) align 4 %0, %struct.point20* noundef byval(%struct.point20) align 4 %1) #0 { + %3 = bitcast %struct.point20* %0 to i8* + %4 = bitcast %struct.point20* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 80, i1 false) + ret void +} + +attributes #0 = { noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" } +attributes #1 = { argmemonly nofree nounwind willreturn } + +!llvm.module.flags = !{!0} +!llvm.ident = !{!1} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"} diff --git a/internal/cabi/_testdata/demo/array_float32.go b/internal/cabi/_testdata/demo/array_float32.go new file mode 100644 index 00000000..4d972ac6 --- /dev/null +++ b/internal/cabi/_testdata/demo/array_float32.go @@ -0,0 +1,359 @@ +package main + +import "unsafe" + +const ( + LLGoFiles = "../wrap/array_float32.c" +) + +//go:linkname printf C.printf +func printf(format *byte, __llgo_va_list ...any) int32 + +func assert(info string, b bool) { + if !b { + printf(unsafe.StringData("Assertion failed: %s\n\000"), unsafe.StringData(info)) + } +} + +func main() { +} + +type array1 struct { + x [1]float32 +} + +//go:linkname cdemo1 C.demo1 +func cdemo1(a array1) array1 + +func demo1(a array1) array1 { + return a +} + +func init() { + a := array1{x: [1]float32{1}} + assert("cdemo1\000", cdemo1(a) == a) + assert("demo1\000", demo1(a) == a) +} + +type array2 struct { + x [2]float32 +} + +//go:linkname cdemo2 C.demo2 +func cdemo2(a array2) array2 + +func demo2(a array2) array2 { + return a +} + +func init() { + a := array2{x: [2]float32{1, 2}} + assert("cdemo2\000", cdemo2(a) == a) + assert("demo2\000", demo2(a) == a) +} + +type array3 struct { + x [3]float32 +} + +//go:linkname cdemo3 C.demo3 +func cdemo3(a array3) array3 + +func demo3(a array3) array3 { + return a +} + +func init() { + a := array3{x: [3]float32{1, 2, 3}} + assert("cdemo3\000", cdemo3(a) == a) + assert("demo3\000", demo3(a) == a) +} + +type array4 struct { + x [4]float32 +} + +//go:linkname cdemo4 C.demo4 +func cdemo4(a array4) array4 + +func demo4(a array4) array4 { + return a +} + +func init() { + a := array4{x: [4]float32{1, 2, 3, 4}} + assert("cdemo4\000", cdemo4(a) == a) + assert("demo4\000", demo4(a) == a) +} + +type array5 struct { + x [5]float32 +} + +//go:linkname cdemo5 C.demo5 +func cdemo5(a array5) array5 + +func demo5(a array5) array5 { + return a +} + +func init() { + a := array5{x: [5]float32{1, 2, 3, 4, 5}} + assert("cdemo5\000", cdemo5(a) == a) + assert("demo5\000", demo5(a) == a) +} + +type array6 struct { + x [6]float32 +} + +//go:linkname cdemo6 C.demo6 +func cdemo6(a array6) array6 + +func demo6(a array6) array6 { + return a +} + +func init() { + a := array6{x: [6]float32{1, 2, 3, 4, 5, 6}} + assert("cdemo6\000", cdemo6(a) == a) + assert("demo6\000", demo6(a) == a) +} + +type array7 struct { + x [7]float32 +} + +//go:linkname cdemo7 C.demo7 +func cdemo7(a array7) array7 + +func demo7(a array7) array7 { + return a +} + +func init() { + a := array7{x: [7]float32{1, 2, 3, 4, 5, 6, 7}} + assert("cdemo7\000", cdemo7(a) == a) + assert("demo7\000", demo7(a) == a) +} + +type array8 struct { + x [8]float32 +} + +//go:linkname cdemo8 C.demo8 +func cdemo8(a array8) array8 + +func demo8(a array8) array8 { + return a +} + +func init() { + a := array8{x: [8]float32{1, 2, 3, 4, 5, 6, 7, 8}} + assert("cdemo8\000", cdemo8(a) == a) + assert("demo8\000", demo8(a) == a) +} + +type array9 struct { + x [9]float32 +} + +//go:linkname cdemo9 C.demo9 +func cdemo9(a array9) array9 + +func demo9(a array9) array9 { + return a +} + +func init() { + a := array9{x: [9]float32{1, 2, 3, 4, 5, 6, 7, 8, 9}} + assert("cdemo9\000", cdemo9(a) == a) + assert("demo9\000", demo9(a) == a) +} + +type array10 struct { + x [10]float32 +} + +//go:linkname cdemo10 C.demo10 +func cdemo10(a array10) array10 + +func demo10(a array10) array10 { + return a +} + +func init() { + a := array10{x: [10]float32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}} + assert("cdemo10\000", cdemo10(a) == a) + assert("demo10\000", demo10(a) == a) +} + +type array11 struct { + x [11]float32 +} + +//go:linkname cdemo11 C.demo11 +func cdemo11(a array11) array11 + +func demo11(a array11) array11 { + return a +} + +func init() { + a := array11{x: [11]float32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}} + assert("cdemo11\000", cdemo11(a) == a) + assert("demo11\000", demo11(a) == a) +} + +type array12 struct { + x [12]float32 +} + +//go:linkname cdemo12 C.demo12 +func cdemo12(a array12) array12 + +func demo12(a array12) array12 { + return a +} + +func init() { + a := array12{x: [12]float32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}} + assert("cdemo12\000", cdemo12(a) == a) + assert("demo12\000", demo12(a) == a) +} + +type array13 struct { + x [13]float32 +} + +//go:linkname cdemo13 C.demo13 +func cdemo13(a array13) array13 + +func demo13(a array13) array13 { + return a +} + +func init() { + a := array13{x: [13]float32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}} + assert("cdemo13\000", cdemo13(a) == a) + assert("demo13\000", demo13(a) == a) +} + +type array14 struct { + x [14]float32 +} + +//go:linkname cdemo14 C.demo14 +func cdemo14(a array14) array14 + +func demo14(a array14) array14 { + return a +} + +func init() { + a := array14{x: [14]float32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}} + assert("cdemo14\000", cdemo14(a) == a) + assert("demo14\000", demo14(a) == a) +} + +type array15 struct { + x [15]float32 +} + +//go:linkname cdemo15 C.demo15 +func cdemo15(a array15) array15 + +func demo15(a array15) array15 { + return a +} + +func init() { + a := array15{x: [15]float32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}} + assert("cdemo15\000", cdemo15(a) == a) + assert("demo15\000", demo15(a) == a) +} + +type array16 struct { + x [16]float32 +} + +//go:linkname cdemo16 C.demo16 +func cdemo16(a array16) array16 + +func demo16(a array16) array16 { + return a +} + +func init() { + a := array16{x: [16]float32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}} + assert("cdemo16\000", cdemo16(a) == a) + assert("demo16\000", demo16(a) == a) +} + +type array17 struct { + x [17]float32 +} + +//go:linkname cdemo17 C.demo17 +func cdemo17(a array17) array17 + +func demo17(a array17) array17 { + return a +} + +func init() { + a := array17{x: [17]float32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}} + assert("cdemo17\000", cdemo17(a) == a) + assert("demo17\000", demo17(a) == a) +} + +type array18 struct { + x [18]float32 +} + +//go:linkname cdemo18 C.demo18 +func cdemo18(a array18) array18 + +func demo18(a array18) array18 { + return a +} + +func init() { + a := array18{x: [18]float32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18}} + assert("cdemo18\000", cdemo18(a) == a) + assert("demo18\000", demo18(a) == a) +} + +type array19 struct { + x [19]float32 +} + +//go:linkname cdemo19 C.demo19 +func cdemo19(a array19) array19 + +func demo19(a array19) array19 { + return a +} + +func init() { + a := array19{x: [19]float32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}} + assert("cdemo19\000", cdemo19(a) == a) + assert("demo19\000", demo19(a) == a) +} + +type array20 struct { + x [20]float32 +} + +//go:linkname cdemo20 C.demo20 +func cdemo20(a array20) array20 + +func demo20(a array20) array20 { + return a +} + +func init() { + a := array20{x: [20]float32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}} + assert("cdemo20\000", cdemo20(a) == a) + assert("demo20\000", demo20(a) == a) +} diff --git a/internal/cabi/_testdata/demo/array_float64.go b/internal/cabi/_testdata/demo/array_float64.go new file mode 100644 index 00000000..36244ff1 --- /dev/null +++ b/internal/cabi/_testdata/demo/array_float64.go @@ -0,0 +1,359 @@ +package main + +import "unsafe" + +const ( + LLGoFiles = "../wrap/array_float64.c" +) + +//go:linkname printf C.printf +func printf(format *byte, __llgo_va_list ...any) int32 + +func assert(info string, b bool) { + if !b { + printf(unsafe.StringData("Assertion failed: %s\n\000"), unsafe.StringData(info)) + } +} + +func main() { +} + +type array1 struct { + x [1]float64 +} + +//go:linkname cdemo1 C.demo1 +func cdemo1(a array1) array1 + +func demo1(a array1) array1 { + return a +} + +func init() { + a := array1{x: [1]float64{1}} + assert("cdemo1\000", cdemo1(a) == a) + assert("demo1\000", demo1(a) == a) +} + +type array2 struct { + x [2]float64 +} + +//go:linkname cdemo2 C.demo2 +func cdemo2(a array2) array2 + +func demo2(a array2) array2 { + return a +} + +func init() { + a := array2{x: [2]float64{1, 2}} + assert("cdemo2\000", cdemo2(a) == a) + assert("demo2\000", demo2(a) == a) +} + +type array3 struct { + x [3]float64 +} + +//go:linkname cdemo3 C.demo3 +func cdemo3(a array3) array3 + +func demo3(a array3) array3 { + return a +} + +func init() { + a := array3{x: [3]float64{1, 2, 3}} + assert("cdemo3\000", cdemo3(a) == a) + assert("demo3\000", demo3(a) == a) +} + +type array4 struct { + x [4]float64 +} + +//go:linkname cdemo4 C.demo4 +func cdemo4(a array4) array4 + +func demo4(a array4) array4 { + return a +} + +func init() { + a := array4{x: [4]float64{1, 2, 3, 4}} + assert("cdemo4\000", cdemo4(a) == a) + assert("demo4\000", demo4(a) == a) +} + +type array5 struct { + x [5]float64 +} + +//go:linkname cdemo5 C.demo5 +func cdemo5(a array5) array5 + +func demo5(a array5) array5 { + return a +} + +func init() { + a := array5{x: [5]float64{1, 2, 3, 4, 5}} + assert("cdemo5\000", cdemo5(a) == a) + assert("demo5\000", demo5(a) == a) +} + +type array6 struct { + x [6]float64 +} + +//go:linkname cdemo6 C.demo6 +func cdemo6(a array6) array6 + +func demo6(a array6) array6 { + return a +} + +func init() { + a := array6{x: [6]float64{1, 2, 3, 4, 5, 6}} + assert("cdemo6\000", cdemo6(a) == a) + assert("demo6\000", demo6(a) == a) +} + +type array7 struct { + x [7]float64 +} + +//go:linkname cdemo7 C.demo7 +func cdemo7(a array7) array7 + +func demo7(a array7) array7 { + return a +} + +func init() { + a := array7{x: [7]float64{1, 2, 3, 4, 5, 6, 7}} + assert("cdemo7\000", cdemo7(a) == a) + assert("demo7\000", demo7(a) == a) +} + +type array8 struct { + x [8]float64 +} + +//go:linkname cdemo8 C.demo8 +func cdemo8(a array8) array8 + +func demo8(a array8) array8 { + return a +} + +func init() { + a := array8{x: [8]float64{1, 2, 3, 4, 5, 6, 7, 8}} + assert("cdemo8\000", cdemo8(a) == a) + assert("demo8\000", demo8(a) == a) +} + +type array9 struct { + x [9]float64 +} + +//go:linkname cdemo9 C.demo9 +func cdemo9(a array9) array9 + +func demo9(a array9) array9 { + return a +} + +func init() { + a := array9{x: [9]float64{1, 2, 3, 4, 5, 6, 7, 8, 9}} + assert("cdemo9\000", cdemo9(a) == a) + assert("demo9\000", demo9(a) == a) +} + +type array10 struct { + x [10]float64 +} + +//go:linkname cdemo10 C.demo10 +func cdemo10(a array10) array10 + +func demo10(a array10) array10 { + return a +} + +func init() { + a := array10{x: [10]float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}} + assert("cdemo10\000", cdemo10(a) == a) + assert("demo10\000", demo10(a) == a) +} + +type array11 struct { + x [11]float64 +} + +//go:linkname cdemo11 C.demo11 +func cdemo11(a array11) array11 + +func demo11(a array11) array11 { + return a +} + +func init() { + a := array11{x: [11]float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}} + assert("cdemo11\000", cdemo11(a) == a) + assert("demo11\000", demo11(a) == a) +} + +type array12 struct { + x [12]float64 +} + +//go:linkname cdemo12 C.demo12 +func cdemo12(a array12) array12 + +func demo12(a array12) array12 { + return a +} + +func init() { + a := array12{x: [12]float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}} + assert("cdemo12\000", cdemo12(a) == a) + assert("demo12\000", demo12(a) == a) +} + +type array13 struct { + x [13]float64 +} + +//go:linkname cdemo13 C.demo13 +func cdemo13(a array13) array13 + +func demo13(a array13) array13 { + return a +} + +func init() { + a := array13{x: [13]float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}} + assert("cdemo13\000", cdemo13(a) == a) + assert("demo13\000", demo13(a) == a) +} + +type array14 struct { + x [14]float64 +} + +//go:linkname cdemo14 C.demo14 +func cdemo14(a array14) array14 + +func demo14(a array14) array14 { + return a +} + +func init() { + a := array14{x: [14]float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}} + assert("cdemo14\000", cdemo14(a) == a) + assert("demo14\000", demo14(a) == a) +} + +type array15 struct { + x [15]float64 +} + +//go:linkname cdemo15 C.demo15 +func cdemo15(a array15) array15 + +func demo15(a array15) array15 { + return a +} + +func init() { + a := array15{x: [15]float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}} + assert("cdemo15\000", cdemo15(a) == a) + assert("demo15\000", demo15(a) == a) +} + +type array16 struct { + x [16]float64 +} + +//go:linkname cdemo16 C.demo16 +func cdemo16(a array16) array16 + +func demo16(a array16) array16 { + return a +} + +func init() { + a := array16{x: [16]float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}} + assert("cdemo16\000", cdemo16(a) == a) + assert("demo16\000", demo16(a) == a) +} + +type array17 struct { + x [17]float64 +} + +//go:linkname cdemo17 C.demo17 +func cdemo17(a array17) array17 + +func demo17(a array17) array17 { + return a +} + +func init() { + a := array17{x: [17]float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}} + assert("cdemo17\000", cdemo17(a) == a) + assert("demo17\000", demo17(a) == a) +} + +type array18 struct { + x [18]float64 +} + +//go:linkname cdemo18 C.demo18 +func cdemo18(a array18) array18 + +func demo18(a array18) array18 { + return a +} + +func init() { + a := array18{x: [18]float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18}} + assert("cdemo18\000", cdemo18(a) == a) + assert("demo18\000", demo18(a) == a) +} + +type array19 struct { + x [19]float64 +} + +//go:linkname cdemo19 C.demo19 +func cdemo19(a array19) array19 + +func demo19(a array19) array19 { + return a +} + +func init() { + a := array19{x: [19]float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}} + assert("cdemo19\000", cdemo19(a) == a) + assert("demo19\000", demo19(a) == a) +} + +type array20 struct { + x [20]float64 +} + +//go:linkname cdemo20 C.demo20 +func cdemo20(a array20) array20 + +func demo20(a array20) array20 { + return a +} + +func init() { + a := array20{x: [20]float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}} + assert("cdemo20\000", cdemo20(a) == a) + assert("demo20\000", demo20(a) == a) +} diff --git a/internal/cabi/_testdata/demo/array_int16.go b/internal/cabi/_testdata/demo/array_int16.go new file mode 100644 index 00000000..57b724ac --- /dev/null +++ b/internal/cabi/_testdata/demo/array_int16.go @@ -0,0 +1,359 @@ +package main + +import "unsafe" + +const ( + LLGoFiles = "../wrap/array_int16.c" +) + +//go:linkname printf C.printf +func printf(format *byte, __llgo_va_list ...any) int32 + +func assert(info string, b bool) { + if !b { + printf(unsafe.StringData("Assertion failed: %s\n\000"), unsafe.StringData(info)) + } +} + +func main() { +} + +type array1 struct { + x [1]int16 +} + +//go:linkname cdemo1 C.demo1 +func cdemo1(a array1) array1 + +func demo1(a array1) array1 { + return a +} + +func init() { + a := array1{x: [1]int16{1}} + assert("cdemo1\000", cdemo1(a) == a) + assert("demo1\000", demo1(a) == a) +} + +type array2 struct { + x [2]int16 +} + +//go:linkname cdemo2 C.demo2 +func cdemo2(a array2) array2 + +func demo2(a array2) array2 { + return a +} + +func init() { + a := array2{x: [2]int16{1, 2}} + assert("cdemo2\000", cdemo2(a) == a) + assert("demo2\000", demo2(a) == a) +} + +type array3 struct { + x [3]int16 +} + +//go:linkname cdemo3 C.demo3 +func cdemo3(a array3) array3 + +func demo3(a array3) array3 { + return a +} + +func init() { + a := array3{x: [3]int16{1, 2, 3}} + assert("cdemo3\000", cdemo3(a) == a) + assert("demo3\000", demo3(a) == a) +} + +type array4 struct { + x [4]int16 +} + +//go:linkname cdemo4 C.demo4 +func cdemo4(a array4) array4 + +func demo4(a array4) array4 { + return a +} + +func init() { + a := array4{x: [4]int16{1, 2, 3, 4}} + assert("cdemo4\000", cdemo4(a) == a) + assert("demo4\000", demo4(a) == a) +} + +type array5 struct { + x [5]int16 +} + +//go:linkname cdemo5 C.demo5 +func cdemo5(a array5) array5 + +func demo5(a array5) array5 { + return a +} + +func init() { + a := array5{x: [5]int16{1, 2, 3, 4, 5}} + assert("cdemo5\000", cdemo5(a) == a) + assert("demo5\000", demo5(a) == a) +} + +type array6 struct { + x [6]int16 +} + +//go:linkname cdemo6 C.demo6 +func cdemo6(a array6) array6 + +func demo6(a array6) array6 { + return a +} + +func init() { + a := array6{x: [6]int16{1, 2, 3, 4, 5, 6}} + assert("cdemo6\000", cdemo6(a) == a) + assert("demo6\000", demo6(a) == a) +} + +type array7 struct { + x [7]int16 +} + +//go:linkname cdemo7 C.demo7 +func cdemo7(a array7) array7 + +func demo7(a array7) array7 { + return a +} + +func init() { + a := array7{x: [7]int16{1, 2, 3, 4, 5, 6, 7}} + assert("cdemo7\000", cdemo7(a) == a) + assert("demo7\000", demo7(a) == a) +} + +type array8 struct { + x [8]int16 +} + +//go:linkname cdemo8 C.demo8 +func cdemo8(a array8) array8 + +func demo8(a array8) array8 { + return a +} + +func init() { + a := array8{x: [8]int16{1, 2, 3, 4, 5, 6, 7, 8}} + assert("cdemo8\000", cdemo8(a) == a) + assert("demo8\000", demo8(a) == a) +} + +type array9 struct { + x [9]int16 +} + +//go:linkname cdemo9 C.demo9 +func cdemo9(a array9) array9 + +func demo9(a array9) array9 { + return a +} + +func init() { + a := array9{x: [9]int16{1, 2, 3, 4, 5, 6, 7, 8, 9}} + assert("cdemo9\000", cdemo9(a) == a) + assert("demo9\000", demo9(a) == a) +} + +type array10 struct { + x [10]int16 +} + +//go:linkname cdemo10 C.demo10 +func cdemo10(a array10) array10 + +func demo10(a array10) array10 { + return a +} + +func init() { + a := array10{x: [10]int16{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}} + assert("cdemo10\000", cdemo10(a) == a) + assert("demo10\000", demo10(a) == a) +} + +type array11 struct { + x [11]int16 +} + +//go:linkname cdemo11 C.demo11 +func cdemo11(a array11) array11 + +func demo11(a array11) array11 { + return a +} + +func init() { + a := array11{x: [11]int16{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}} + assert("cdemo11\000", cdemo11(a) == a) + assert("demo11\000", demo11(a) == a) +} + +type array12 struct { + x [12]int16 +} + +//go:linkname cdemo12 C.demo12 +func cdemo12(a array12) array12 + +func demo12(a array12) array12 { + return a +} + +func init() { + a := array12{x: [12]int16{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}} + assert("cdemo12\000", cdemo12(a) == a) + assert("demo12\000", demo12(a) == a) +} + +type array13 struct { + x [13]int16 +} + +//go:linkname cdemo13 C.demo13 +func cdemo13(a array13) array13 + +func demo13(a array13) array13 { + return a +} + +func init() { + a := array13{x: [13]int16{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}} + assert("cdemo13\000", cdemo13(a) == a) + assert("demo13\000", demo13(a) == a) +} + +type array14 struct { + x [14]int16 +} + +//go:linkname cdemo14 C.demo14 +func cdemo14(a array14) array14 + +func demo14(a array14) array14 { + return a +} + +func init() { + a := array14{x: [14]int16{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}} + assert("cdemo14\000", cdemo14(a) == a) + assert("demo14\000", demo14(a) == a) +} + +type array15 struct { + x [15]int16 +} + +//go:linkname cdemo15 C.demo15 +func cdemo15(a array15) array15 + +func demo15(a array15) array15 { + return a +} + +func init() { + a := array15{x: [15]int16{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}} + assert("cdemo15\000", cdemo15(a) == a) + assert("demo15\000", demo15(a) == a) +} + +type array16 struct { + x [16]int16 +} + +//go:linkname cdemo16 C.demo16 +func cdemo16(a array16) array16 + +func demo16(a array16) array16 { + return a +} + +func init() { + a := array16{x: [16]int16{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}} + assert("cdemo16\000", cdemo16(a) == a) + assert("demo16\000", demo16(a) == a) +} + +type array17 struct { + x [17]int16 +} + +//go:linkname cdemo17 C.demo17 +func cdemo17(a array17) array17 + +func demo17(a array17) array17 { + return a +} + +func init() { + a := array17{x: [17]int16{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}} + assert("cdemo17\000", cdemo17(a) == a) + assert("demo17\000", demo17(a) == a) +} + +type array18 struct { + x [18]int16 +} + +//go:linkname cdemo18 C.demo18 +func cdemo18(a array18) array18 + +func demo18(a array18) array18 { + return a +} + +func init() { + a := array18{x: [18]int16{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18}} + assert("cdemo18\000", cdemo18(a) == a) + assert("demo18\000", demo18(a) == a) +} + +type array19 struct { + x [19]int16 +} + +//go:linkname cdemo19 C.demo19 +func cdemo19(a array19) array19 + +func demo19(a array19) array19 { + return a +} + +func init() { + a := array19{x: [19]int16{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}} + assert("cdemo19\000", cdemo19(a) == a) + assert("demo19\000", demo19(a) == a) +} + +type array20 struct { + x [20]int16 +} + +//go:linkname cdemo20 C.demo20 +func cdemo20(a array20) array20 + +func demo20(a array20) array20 { + return a +} + +func init() { + a := array20{x: [20]int16{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}} + assert("cdemo20\000", cdemo20(a) == a) + assert("demo20\000", demo20(a) == a) +} diff --git a/internal/cabi/_testdata/demo/array_int32.go b/internal/cabi/_testdata/demo/array_int32.go new file mode 100644 index 00000000..4826ae04 --- /dev/null +++ b/internal/cabi/_testdata/demo/array_int32.go @@ -0,0 +1,359 @@ +package main + +import "unsafe" + +const ( + LLGoFiles = "../wrap/array_int32.c" +) + +//go:linkname printf C.printf +func printf(format *byte, __llgo_va_list ...any) int32 + +func assert(info string, b bool) { + if !b { + printf(unsafe.StringData("Assertion failed: %s\n\000"), unsafe.StringData(info)) + } +} + +func main() { +} + +type array1 struct { + x [1]int32 +} + +//go:linkname cdemo1 C.demo1 +func cdemo1(a array1) array1 + +func demo1(a array1) array1 { + return a +} + +func init() { + a := array1{x: [1]int32{1}} + assert("cdemo1\000", cdemo1(a) == a) + assert("demo1\000", demo1(a) == a) +} + +type array2 struct { + x [2]int32 +} + +//go:linkname cdemo2 C.demo2 +func cdemo2(a array2) array2 + +func demo2(a array2) array2 { + return a +} + +func init() { + a := array2{x: [2]int32{1, 2}} + assert("cdemo2\000", cdemo2(a) == a) + assert("demo2\000", demo2(a) == a) +} + +type array3 struct { + x [3]int32 +} + +//go:linkname cdemo3 C.demo3 +func cdemo3(a array3) array3 + +func demo3(a array3) array3 { + return a +} + +func init() { + a := array3{x: [3]int32{1, 2, 3}} + assert("cdemo3\000", cdemo3(a) == a) + assert("demo3\000", demo3(a) == a) +} + +type array4 struct { + x [4]int32 +} + +//go:linkname cdemo4 C.demo4 +func cdemo4(a array4) array4 + +func demo4(a array4) array4 { + return a +} + +func init() { + a := array4{x: [4]int32{1, 2, 3, 4}} + assert("cdemo4\000", cdemo4(a) == a) + assert("demo4\000", demo4(a) == a) +} + +type array5 struct { + x [5]int32 +} + +//go:linkname cdemo5 C.demo5 +func cdemo5(a array5) array5 + +func demo5(a array5) array5 { + return a +} + +func init() { + a := array5{x: [5]int32{1, 2, 3, 4, 5}} + assert("cdemo5\000", cdemo5(a) == a) + assert("demo5\000", demo5(a) == a) +} + +type array6 struct { + x [6]int32 +} + +//go:linkname cdemo6 C.demo6 +func cdemo6(a array6) array6 + +func demo6(a array6) array6 { + return a +} + +func init() { + a := array6{x: [6]int32{1, 2, 3, 4, 5, 6}} + assert("cdemo6\000", cdemo6(a) == a) + assert("demo6\000", demo6(a) == a) +} + +type array7 struct { + x [7]int32 +} + +//go:linkname cdemo7 C.demo7 +func cdemo7(a array7) array7 + +func demo7(a array7) array7 { + return a +} + +func init() { + a := array7{x: [7]int32{1, 2, 3, 4, 5, 6, 7}} + assert("cdemo7\000", cdemo7(a) == a) + assert("demo7\000", demo7(a) == a) +} + +type array8 struct { + x [8]int32 +} + +//go:linkname cdemo8 C.demo8 +func cdemo8(a array8) array8 + +func demo8(a array8) array8 { + return a +} + +func init() { + a := array8{x: [8]int32{1, 2, 3, 4, 5, 6, 7, 8}} + assert("cdemo8\000", cdemo8(a) == a) + assert("demo8\000", demo8(a) == a) +} + +type array9 struct { + x [9]int32 +} + +//go:linkname cdemo9 C.demo9 +func cdemo9(a array9) array9 + +func demo9(a array9) array9 { + return a +} + +func init() { + a := array9{x: [9]int32{1, 2, 3, 4, 5, 6, 7, 8, 9}} + assert("cdemo9\000", cdemo9(a) == a) + assert("demo9\000", demo9(a) == a) +} + +type array10 struct { + x [10]int32 +} + +//go:linkname cdemo10 C.demo10 +func cdemo10(a array10) array10 + +func demo10(a array10) array10 { + return a +} + +func init() { + a := array10{x: [10]int32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}} + assert("cdemo10\000", cdemo10(a) == a) + assert("demo10\000", demo10(a) == a) +} + +type array11 struct { + x [11]int32 +} + +//go:linkname cdemo11 C.demo11 +func cdemo11(a array11) array11 + +func demo11(a array11) array11 { + return a +} + +func init() { + a := array11{x: [11]int32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}} + assert("cdemo11\000", cdemo11(a) == a) + assert("demo11\000", demo11(a) == a) +} + +type array12 struct { + x [12]int32 +} + +//go:linkname cdemo12 C.demo12 +func cdemo12(a array12) array12 + +func demo12(a array12) array12 { + return a +} + +func init() { + a := array12{x: [12]int32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}} + assert("cdemo12\000", cdemo12(a) == a) + assert("demo12\000", demo12(a) == a) +} + +type array13 struct { + x [13]int32 +} + +//go:linkname cdemo13 C.demo13 +func cdemo13(a array13) array13 + +func demo13(a array13) array13 { + return a +} + +func init() { + a := array13{x: [13]int32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}} + assert("cdemo13\000", cdemo13(a) == a) + assert("demo13\000", demo13(a) == a) +} + +type array14 struct { + x [14]int32 +} + +//go:linkname cdemo14 C.demo14 +func cdemo14(a array14) array14 + +func demo14(a array14) array14 { + return a +} + +func init() { + a := array14{x: [14]int32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}} + assert("cdemo14\000", cdemo14(a) == a) + assert("demo14\000", demo14(a) == a) +} + +type array15 struct { + x [15]int32 +} + +//go:linkname cdemo15 C.demo15 +func cdemo15(a array15) array15 + +func demo15(a array15) array15 { + return a +} + +func init() { + a := array15{x: [15]int32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}} + assert("cdemo15\000", cdemo15(a) == a) + assert("demo15\000", demo15(a) == a) +} + +type array16 struct { + x [16]int32 +} + +//go:linkname cdemo16 C.demo16 +func cdemo16(a array16) array16 + +func demo16(a array16) array16 { + return a +} + +func init() { + a := array16{x: [16]int32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}} + assert("cdemo16\000", cdemo16(a) == a) + assert("demo16\000", demo16(a) == a) +} + +type array17 struct { + x [17]int32 +} + +//go:linkname cdemo17 C.demo17 +func cdemo17(a array17) array17 + +func demo17(a array17) array17 { + return a +} + +func init() { + a := array17{x: [17]int32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}} + assert("cdemo17\000", cdemo17(a) == a) + assert("demo17\000", demo17(a) == a) +} + +type array18 struct { + x [18]int32 +} + +//go:linkname cdemo18 C.demo18 +func cdemo18(a array18) array18 + +func demo18(a array18) array18 { + return a +} + +func init() { + a := array18{x: [18]int32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18}} + assert("cdemo18\000", cdemo18(a) == a) + assert("demo18\000", demo18(a) == a) +} + +type array19 struct { + x [19]int32 +} + +//go:linkname cdemo19 C.demo19 +func cdemo19(a array19) array19 + +func demo19(a array19) array19 { + return a +} + +func init() { + a := array19{x: [19]int32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}} + assert("cdemo19\000", cdemo19(a) == a) + assert("demo19\000", demo19(a) == a) +} + +type array20 struct { + x [20]int32 +} + +//go:linkname cdemo20 C.demo20 +func cdemo20(a array20) array20 + +func demo20(a array20) array20 { + return a +} + +func init() { + a := array20{x: [20]int32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}} + assert("cdemo20\000", cdemo20(a) == a) + assert("demo20\000", demo20(a) == a) +} diff --git a/internal/cabi/_testdata/demo/array_int64.go b/internal/cabi/_testdata/demo/array_int64.go new file mode 100644 index 00000000..f6c11185 --- /dev/null +++ b/internal/cabi/_testdata/demo/array_int64.go @@ -0,0 +1,359 @@ +package main + +import "unsafe" + +const ( + LLGoFiles = "../wrap/array_int64.c" +) + +//go:linkname printf C.printf +func printf(format *byte, __llgo_va_list ...any) int32 + +func assert(info string, b bool) { + if !b { + printf(unsafe.StringData("Assertion failed: %s\n\000"), unsafe.StringData(info)) + } +} + +func main() { +} + +type array1 struct { + x [1]int64 +} + +//go:linkname cdemo1 C.demo1 +func cdemo1(a array1) array1 + +func demo1(a array1) array1 { + return a +} + +func init() { + a := array1{x: [1]int64{1}} + assert("cdemo1\000", cdemo1(a) == a) + assert("demo1\000", demo1(a) == a) +} + +type array2 struct { + x [2]int64 +} + +//go:linkname cdemo2 C.demo2 +func cdemo2(a array2) array2 + +func demo2(a array2) array2 { + return a +} + +func init() { + a := array2{x: [2]int64{1, 2}} + assert("cdemo2\000", cdemo2(a) == a) + assert("demo2\000", demo2(a) == a) +} + +type array3 struct { + x [3]int64 +} + +//go:linkname cdemo3 C.demo3 +func cdemo3(a array3) array3 + +func demo3(a array3) array3 { + return a +} + +func init() { + a := array3{x: [3]int64{1, 2, 3}} + assert("cdemo3\000", cdemo3(a) == a) + assert("demo3\000", demo3(a) == a) +} + +type array4 struct { + x [4]int64 +} + +//go:linkname cdemo4 C.demo4 +func cdemo4(a array4) array4 + +func demo4(a array4) array4 { + return a +} + +func init() { + a := array4{x: [4]int64{1, 2, 3, 4}} + assert("cdemo4\000", cdemo4(a) == a) + assert("demo4\000", demo4(a) == a) +} + +type array5 struct { + x [5]int64 +} + +//go:linkname cdemo5 C.demo5 +func cdemo5(a array5) array5 + +func demo5(a array5) array5 { + return a +} + +func init() { + a := array5{x: [5]int64{1, 2, 3, 4, 5}} + assert("cdemo5\000", cdemo5(a) == a) + assert("demo5\000", demo5(a) == a) +} + +type array6 struct { + x [6]int64 +} + +//go:linkname cdemo6 C.demo6 +func cdemo6(a array6) array6 + +func demo6(a array6) array6 { + return a +} + +func init() { + a := array6{x: [6]int64{1, 2, 3, 4, 5, 6}} + assert("cdemo6\000", cdemo6(a) == a) + assert("demo6\000", demo6(a) == a) +} + +type array7 struct { + x [7]int64 +} + +//go:linkname cdemo7 C.demo7 +func cdemo7(a array7) array7 + +func demo7(a array7) array7 { + return a +} + +func init() { + a := array7{x: [7]int64{1, 2, 3, 4, 5, 6, 7}} + assert("cdemo7\000", cdemo7(a) == a) + assert("demo7\000", demo7(a) == a) +} + +type array8 struct { + x [8]int64 +} + +//go:linkname cdemo8 C.demo8 +func cdemo8(a array8) array8 + +func demo8(a array8) array8 { + return a +} + +func init() { + a := array8{x: [8]int64{1, 2, 3, 4, 5, 6, 7, 8}} + assert("cdemo8\000", cdemo8(a) == a) + assert("demo8\000", demo8(a) == a) +} + +type array9 struct { + x [9]int64 +} + +//go:linkname cdemo9 C.demo9 +func cdemo9(a array9) array9 + +func demo9(a array9) array9 { + return a +} + +func init() { + a := array9{x: [9]int64{1, 2, 3, 4, 5, 6, 7, 8, 9}} + assert("cdemo9\000", cdemo9(a) == a) + assert("demo9\000", demo9(a) == a) +} + +type array10 struct { + x [10]int64 +} + +//go:linkname cdemo10 C.demo10 +func cdemo10(a array10) array10 + +func demo10(a array10) array10 { + return a +} + +func init() { + a := array10{x: [10]int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}} + assert("cdemo10\000", cdemo10(a) == a) + assert("demo10\000", demo10(a) == a) +} + +type array11 struct { + x [11]int64 +} + +//go:linkname cdemo11 C.demo11 +func cdemo11(a array11) array11 + +func demo11(a array11) array11 { + return a +} + +func init() { + a := array11{x: [11]int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}} + assert("cdemo11\000", cdemo11(a) == a) + assert("demo11\000", demo11(a) == a) +} + +type array12 struct { + x [12]int64 +} + +//go:linkname cdemo12 C.demo12 +func cdemo12(a array12) array12 + +func demo12(a array12) array12 { + return a +} + +func init() { + a := array12{x: [12]int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}} + assert("cdemo12\000", cdemo12(a) == a) + assert("demo12\000", demo12(a) == a) +} + +type array13 struct { + x [13]int64 +} + +//go:linkname cdemo13 C.demo13 +func cdemo13(a array13) array13 + +func demo13(a array13) array13 { + return a +} + +func init() { + a := array13{x: [13]int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}} + assert("cdemo13\000", cdemo13(a) == a) + assert("demo13\000", demo13(a) == a) +} + +type array14 struct { + x [14]int64 +} + +//go:linkname cdemo14 C.demo14 +func cdemo14(a array14) array14 + +func demo14(a array14) array14 { + return a +} + +func init() { + a := array14{x: [14]int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}} + assert("cdemo14\000", cdemo14(a) == a) + assert("demo14\000", demo14(a) == a) +} + +type array15 struct { + x [15]int64 +} + +//go:linkname cdemo15 C.demo15 +func cdemo15(a array15) array15 + +func demo15(a array15) array15 { + return a +} + +func init() { + a := array15{x: [15]int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}} + assert("cdemo15\000", cdemo15(a) == a) + assert("demo15\000", demo15(a) == a) +} + +type array16 struct { + x [16]int64 +} + +//go:linkname cdemo16 C.demo16 +func cdemo16(a array16) array16 + +func demo16(a array16) array16 { + return a +} + +func init() { + a := array16{x: [16]int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}} + assert("cdemo16\000", cdemo16(a) == a) + assert("demo16\000", demo16(a) == a) +} + +type array17 struct { + x [17]int64 +} + +//go:linkname cdemo17 C.demo17 +func cdemo17(a array17) array17 + +func demo17(a array17) array17 { + return a +} + +func init() { + a := array17{x: [17]int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}} + assert("cdemo17\000", cdemo17(a) == a) + assert("demo17\000", demo17(a) == a) +} + +type array18 struct { + x [18]int64 +} + +//go:linkname cdemo18 C.demo18 +func cdemo18(a array18) array18 + +func demo18(a array18) array18 { + return a +} + +func init() { + a := array18{x: [18]int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18}} + assert("cdemo18\000", cdemo18(a) == a) + assert("demo18\000", demo18(a) == a) +} + +type array19 struct { + x [19]int64 +} + +//go:linkname cdemo19 C.demo19 +func cdemo19(a array19) array19 + +func demo19(a array19) array19 { + return a +} + +func init() { + a := array19{x: [19]int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}} + assert("cdemo19\000", cdemo19(a) == a) + assert("demo19\000", demo19(a) == a) +} + +type array20 struct { + x [20]int64 +} + +//go:linkname cdemo20 C.demo20 +func cdemo20(a array20) array20 + +func demo20(a array20) array20 { + return a +} + +func init() { + a := array20{x: [20]int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}} + assert("cdemo20\000", cdemo20(a) == a) + assert("demo20\000", demo20(a) == a) +} diff --git a/internal/cabi/_testdata/demo/array_int8.go b/internal/cabi/_testdata/demo/array_int8.go new file mode 100644 index 00000000..2d4e8a3e --- /dev/null +++ b/internal/cabi/_testdata/demo/array_int8.go @@ -0,0 +1,359 @@ +package main + +import "unsafe" + +const ( + LLGoFiles = "../wrap/array_int8.c" +) + +//go:linkname printf C.printf +func printf(format *byte, __llgo_va_list ...any) int32 + +func assert(info string, b bool) { + if !b { + printf(unsafe.StringData("Assertion failed: %s\n\000"), unsafe.StringData(info)) + } +} + +func main() { +} + +type array1 struct { + x [1]int8 +} + +//go:linkname cdemo1 C.demo1 +func cdemo1(a array1) array1 + +func demo1(a array1) array1 { + return a +} + +func init() { + a := array1{x: [1]int8{1}} + assert("cdemo1\000", cdemo1(a) == a) + assert("demo1\000", demo1(a) == a) +} + +type array2 struct { + x [2]int8 +} + +//go:linkname cdemo2 C.demo2 +func cdemo2(a array2) array2 + +func demo2(a array2) array2 { + return a +} + +func init() { + a := array2{x: [2]int8{1, 2}} + assert("cdemo2\000", cdemo2(a) == a) + assert("demo2\000", demo2(a) == a) +} + +type array3 struct { + x [3]int8 +} + +//go:linkname cdemo3 C.demo3 +func cdemo3(a array3) array3 + +func demo3(a array3) array3 { + return a +} + +func init() { + a := array3{x: [3]int8{1, 2, 3}} + assert("cdemo3\000", cdemo3(a) == a) + assert("demo3\000", demo3(a) == a) +} + +type array4 struct { + x [4]int8 +} + +//go:linkname cdemo4 C.demo4 +func cdemo4(a array4) array4 + +func demo4(a array4) array4 { + return a +} + +func init() { + a := array4{x: [4]int8{1, 2, 3, 4}} + assert("cdemo4\000", cdemo4(a) == a) + assert("demo4\000", demo4(a) == a) +} + +type array5 struct { + x [5]int8 +} + +//go:linkname cdemo5 C.demo5 +func cdemo5(a array5) array5 + +func demo5(a array5) array5 { + return a +} + +func init() { + a := array5{x: [5]int8{1, 2, 3, 4, 5}} + assert("cdemo5\000", cdemo5(a) == a) + assert("demo5\000", demo5(a) == a) +} + +type array6 struct { + x [6]int8 +} + +//go:linkname cdemo6 C.demo6 +func cdemo6(a array6) array6 + +func demo6(a array6) array6 { + return a +} + +func init() { + a := array6{x: [6]int8{1, 2, 3, 4, 5, 6}} + assert("cdemo6\000", cdemo6(a) == a) + assert("demo6\000", demo6(a) == a) +} + +type array7 struct { + x [7]int8 +} + +//go:linkname cdemo7 C.demo7 +func cdemo7(a array7) array7 + +func demo7(a array7) array7 { + return a +} + +func init() { + a := array7{x: [7]int8{1, 2, 3, 4, 5, 6, 7}} + assert("cdemo7\000", cdemo7(a) == a) + assert("demo7\000", demo7(a) == a) +} + +type array8 struct { + x [8]int8 +} + +//go:linkname cdemo8 C.demo8 +func cdemo8(a array8) array8 + +func demo8(a array8) array8 { + return a +} + +func init() { + a := array8{x: [8]int8{1, 2, 3, 4, 5, 6, 7, 8}} + assert("cdemo8\000", cdemo8(a) == a) + assert("demo8\000", demo8(a) == a) +} + +type array9 struct { + x [9]int8 +} + +//go:linkname cdemo9 C.demo9 +func cdemo9(a array9) array9 + +func demo9(a array9) array9 { + return a +} + +func init() { + a := array9{x: [9]int8{1, 2, 3, 4, 5, 6, 7, 8, 9}} + assert("cdemo9\000", cdemo9(a) == a) + assert("demo9\000", demo9(a) == a) +} + +type array10 struct { + x [10]int8 +} + +//go:linkname cdemo10 C.demo10 +func cdemo10(a array10) array10 + +func demo10(a array10) array10 { + return a +} + +func init() { + a := array10{x: [10]int8{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}} + assert("cdemo10\000", cdemo10(a) == a) + assert("demo10\000", demo10(a) == a) +} + +type array11 struct { + x [11]int8 +} + +//go:linkname cdemo11 C.demo11 +func cdemo11(a array11) array11 + +func demo11(a array11) array11 { + return a +} + +func init() { + a := array11{x: [11]int8{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}} + assert("cdemo11\000", cdemo11(a) == a) + assert("demo11\000", demo11(a) == a) +} + +type array12 struct { + x [12]int8 +} + +//go:linkname cdemo12 C.demo12 +func cdemo12(a array12) array12 + +func demo12(a array12) array12 { + return a +} + +func init() { + a := array12{x: [12]int8{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}} + assert("cdemo12\000", cdemo12(a) == a) + assert("demo12\000", demo12(a) == a) +} + +type array13 struct { + x [13]int8 +} + +//go:linkname cdemo13 C.demo13 +func cdemo13(a array13) array13 + +func demo13(a array13) array13 { + return a +} + +func init() { + a := array13{x: [13]int8{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}} + assert("cdemo13\000", cdemo13(a) == a) + assert("demo13\000", demo13(a) == a) +} + +type array14 struct { + x [14]int8 +} + +//go:linkname cdemo14 C.demo14 +func cdemo14(a array14) array14 + +func demo14(a array14) array14 { + return a +} + +func init() { + a := array14{x: [14]int8{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}} + assert("cdemo14\000", cdemo14(a) == a) + assert("demo14\000", demo14(a) == a) +} + +type array15 struct { + x [15]int8 +} + +//go:linkname cdemo15 C.demo15 +func cdemo15(a array15) array15 + +func demo15(a array15) array15 { + return a +} + +func init() { + a := array15{x: [15]int8{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}} + assert("cdemo15\000", cdemo15(a) == a) + assert("demo15\000", demo15(a) == a) +} + +type array16 struct { + x [16]int8 +} + +//go:linkname cdemo16 C.demo16 +func cdemo16(a array16) array16 + +func demo16(a array16) array16 { + return a +} + +func init() { + a := array16{x: [16]int8{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}} + assert("cdemo16\000", cdemo16(a) == a) + assert("demo16\000", demo16(a) == a) +} + +type array17 struct { + x [17]int8 +} + +//go:linkname cdemo17 C.demo17 +func cdemo17(a array17) array17 + +func demo17(a array17) array17 { + return a +} + +func init() { + a := array17{x: [17]int8{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}} + assert("cdemo17\000", cdemo17(a) == a) + assert("demo17\000", demo17(a) == a) +} + +type array18 struct { + x [18]int8 +} + +//go:linkname cdemo18 C.demo18 +func cdemo18(a array18) array18 + +func demo18(a array18) array18 { + return a +} + +func init() { + a := array18{x: [18]int8{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18}} + assert("cdemo18\000", cdemo18(a) == a) + assert("demo18\000", demo18(a) == a) +} + +type array19 struct { + x [19]int8 +} + +//go:linkname cdemo19 C.demo19 +func cdemo19(a array19) array19 + +func demo19(a array19) array19 { + return a +} + +func init() { + a := array19{x: [19]int8{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}} + assert("cdemo19\000", cdemo19(a) == a) + assert("demo19\000", demo19(a) == a) +} + +type array20 struct { + x [20]int8 +} + +//go:linkname cdemo20 C.demo20 +func cdemo20(a array20) array20 + +func demo20(a array20) array20 { + return a +} + +func init() { + a := array20{x: [20]int8{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}} + assert("cdemo20\000", cdemo20(a) == a) + assert("demo20\000", demo20(a) == a) +} diff --git a/internal/cabi/_testdata/demo/array_uintptr.go b/internal/cabi/_testdata/demo/array_uintptr.go new file mode 100644 index 00000000..ecc02853 --- /dev/null +++ b/internal/cabi/_testdata/demo/array_uintptr.go @@ -0,0 +1,359 @@ +package main + +import "unsafe" + +const ( + LLGoFiles = "../wrap/array_uintptr.c" +) + +//go:linkname printf C.printf +func printf(format *byte, __llgo_va_list ...any) int32 + +func assert(info string, b bool) { + if !b { + printf(unsafe.StringData("Assertion failed: %s\n\000"), unsafe.StringData(info)) + } +} + +func main() { +} + +type array1 struct { + x [1]uintptr +} + +//go:linkname cdemo1 C.demo1 +func cdemo1(a array1) array1 + +func demo1(a array1) array1 { + return a +} + +func init() { + a := array1{x: [1]uintptr{1}} + assert("cdemo1\000", cdemo1(a) == a) + assert("demo1\000", demo1(a) == a) +} + +type array2 struct { + x [2]uintptr +} + +//go:linkname cdemo2 C.demo2 +func cdemo2(a array2) array2 + +func demo2(a array2) array2 { + return a +} + +func init() { + a := array2{x: [2]uintptr{1, 2}} + assert("cdemo2\000", cdemo2(a) == a) + assert("demo2\000", demo2(a) == a) +} + +type array3 struct { + x [3]uintptr +} + +//go:linkname cdemo3 C.demo3 +func cdemo3(a array3) array3 + +func demo3(a array3) array3 { + return a +} + +func init() { + a := array3{x: [3]uintptr{1, 2, 3}} + assert("cdemo3\000", cdemo3(a) == a) + assert("demo3\000", demo3(a) == a) +} + +type array4 struct { + x [4]uintptr +} + +//go:linkname cdemo4 C.demo4 +func cdemo4(a array4) array4 + +func demo4(a array4) array4 { + return a +} + +func init() { + a := array4{x: [4]uintptr{1, 2, 3, 4}} + assert("cdemo4\000", cdemo4(a) == a) + assert("demo4\000", demo4(a) == a) +} + +type array5 struct { + x [5]uintptr +} + +//go:linkname cdemo5 C.demo5 +func cdemo5(a array5) array5 + +func demo5(a array5) array5 { + return a +} + +func init() { + a := array5{x: [5]uintptr{1, 2, 3, 4, 5}} + assert("cdemo5\000", cdemo5(a) == a) + assert("demo5\000", demo5(a) == a) +} + +type array6 struct { + x [6]uintptr +} + +//go:linkname cdemo6 C.demo6 +func cdemo6(a array6) array6 + +func demo6(a array6) array6 { + return a +} + +func init() { + a := array6{x: [6]uintptr{1, 2, 3, 4, 5, 6}} + assert("cdemo6\000", cdemo6(a) == a) + assert("demo6\000", demo6(a) == a) +} + +type array7 struct { + x [7]uintptr +} + +//go:linkname cdemo7 C.demo7 +func cdemo7(a array7) array7 + +func demo7(a array7) array7 { + return a +} + +func init() { + a := array7{x: [7]uintptr{1, 2, 3, 4, 5, 6, 7}} + assert("cdemo7\000", cdemo7(a) == a) + assert("demo7\000", demo7(a) == a) +} + +type array8 struct { + x [8]uintptr +} + +//go:linkname cdemo8 C.demo8 +func cdemo8(a array8) array8 + +func demo8(a array8) array8 { + return a +} + +func init() { + a := array8{x: [8]uintptr{1, 2, 3, 4, 5, 6, 7, 8}} + assert("cdemo8\000", cdemo8(a) == a) + assert("demo8\000", demo8(a) == a) +} + +type array9 struct { + x [9]uintptr +} + +//go:linkname cdemo9 C.demo9 +func cdemo9(a array9) array9 + +func demo9(a array9) array9 { + return a +} + +func init() { + a := array9{x: [9]uintptr{1, 2, 3, 4, 5, 6, 7, 8, 9}} + assert("cdemo9\000", cdemo9(a) == a) + assert("demo9\000", demo9(a) == a) +} + +type array10 struct { + x [10]uintptr +} + +//go:linkname cdemo10 C.demo10 +func cdemo10(a array10) array10 + +func demo10(a array10) array10 { + return a +} + +func init() { + a := array10{x: [10]uintptr{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}} + assert("cdemo10\000", cdemo10(a) == a) + assert("demo10\000", demo10(a) == a) +} + +type array11 struct { + x [11]uintptr +} + +//go:linkname cdemo11 C.demo11 +func cdemo11(a array11) array11 + +func demo11(a array11) array11 { + return a +} + +func init() { + a := array11{x: [11]uintptr{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}} + assert("cdemo11\000", cdemo11(a) == a) + assert("demo11\000", demo11(a) == a) +} + +type array12 struct { + x [12]uintptr +} + +//go:linkname cdemo12 C.demo12 +func cdemo12(a array12) array12 + +func demo12(a array12) array12 { + return a +} + +func init() { + a := array12{x: [12]uintptr{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}} + assert("cdemo12\000", cdemo12(a) == a) + assert("demo12\000", demo12(a) == a) +} + +type array13 struct { + x [13]uintptr +} + +//go:linkname cdemo13 C.demo13 +func cdemo13(a array13) array13 + +func demo13(a array13) array13 { + return a +} + +func init() { + a := array13{x: [13]uintptr{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}} + assert("cdemo13\000", cdemo13(a) == a) + assert("demo13\000", demo13(a) == a) +} + +type array14 struct { + x [14]uintptr +} + +//go:linkname cdemo14 C.demo14 +func cdemo14(a array14) array14 + +func demo14(a array14) array14 { + return a +} + +func init() { + a := array14{x: [14]uintptr{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}} + assert("cdemo14\000", cdemo14(a) == a) + assert("demo14\000", demo14(a) == a) +} + +type array15 struct { + x [15]uintptr +} + +//go:linkname cdemo15 C.demo15 +func cdemo15(a array15) array15 + +func demo15(a array15) array15 { + return a +} + +func init() { + a := array15{x: [15]uintptr{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}} + assert("cdemo15\000", cdemo15(a) == a) + assert("demo15\000", demo15(a) == a) +} + +type array16 struct { + x [16]uintptr +} + +//go:linkname cdemo16 C.demo16 +func cdemo16(a array16) array16 + +func demo16(a array16) array16 { + return a +} + +func init() { + a := array16{x: [16]uintptr{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}} + assert("cdemo16\000", cdemo16(a) == a) + assert("demo16\000", demo16(a) == a) +} + +type array17 struct { + x [17]uintptr +} + +//go:linkname cdemo17 C.demo17 +func cdemo17(a array17) array17 + +func demo17(a array17) array17 { + return a +} + +func init() { + a := array17{x: [17]uintptr{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}} + assert("cdemo17\000", cdemo17(a) == a) + assert("demo17\000", demo17(a) == a) +} + +type array18 struct { + x [18]uintptr +} + +//go:linkname cdemo18 C.demo18 +func cdemo18(a array18) array18 + +func demo18(a array18) array18 { + return a +} + +func init() { + a := array18{x: [18]uintptr{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18}} + assert("cdemo18\000", cdemo18(a) == a) + assert("demo18\000", demo18(a) == a) +} + +type array19 struct { + x [19]uintptr +} + +//go:linkname cdemo19 C.demo19 +func cdemo19(a array19) array19 + +func demo19(a array19) array19 { + return a +} + +func init() { + a := array19{x: [19]uintptr{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}} + assert("cdemo19\000", cdemo19(a) == a) + assert("demo19\000", demo19(a) == a) +} + +type array20 struct { + x [20]uintptr +} + +//go:linkname cdemo20 C.demo20 +func cdemo20(a array20) array20 + +func demo20(a array20) array20 { + return a +} + +func init() { + a := array20{x: [20]uintptr{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}} + assert("cdemo20\000", cdemo20(a) == a) + assert("demo20\000", demo20(a) == a) +} diff --git a/internal/cabi/_testdata/demo/basic.go b/internal/cabi/_testdata/demo/basic.go new file mode 100644 index 00000000..d115d281 --- /dev/null +++ b/internal/cabi/_testdata/demo/basic.go @@ -0,0 +1,103 @@ +package main + +import "unsafe" + +const ( + LLGoFiles = "../wrap/basic.c" +) + +//go:linkname printf C.printf +func printf(format *byte, __llgo_va_list ...any) int32 + +func assert(info string, b bool) { + if !b { + printf(unsafe.StringData("Assertion failed: %s\n\000"), unsafe.StringData(info)) + } +} + +func main() { +} + +//go:linkname cbasic_int8 C.basic_int8 +func cbasic_int8(a int8) int8 + +func basic_int8(a int8) int8 { + return a +} + +func init() { + assert("cbasic_int8\000", cbasic_int8(100) == 100) + assert("basic_int8\000", basic_int8(100) == 100) +} + +//go:linkname cbasic_int16 C.basic_int16 +func cbasic_int16(a int16) int16 + +func basic_int16(a int16) int16 { + return a +} + +func init() { + assert("cbasic_int16\000", cbasic_int16(100) == 100) + assert("basic_int16\000", basic_int16(100) == 100) +} + +//go:linkname cbasic_int32 C.basic_int32 +func cbasic_int32(a int32) int32 + +func basic_int32(a int32) int32 { + return a +} + +func init() { + assert("cbasic_int32\000", cbasic_int32(100) == 100) + assert("basic_int32\000", basic_int32(100) == 100) +} + +//go:linkname cbasic_int64 C.basic_int64 +func cbasic_int64(a int64) int64 + +func basic_int64(a int64) int64 { + return a +} + +func init() { + assert("cbasic_int64\000", cbasic_int64(100) == 100) + assert("basic_int64\000", basic_int64(100) == 100) +} + +//go:linkname cbasic_float32 C.basic_float32 +func cbasic_float32(a float32) float32 + +func basic_float32(a float32) float32 { + return a +} + +func init() { + assert("cbasic_float32\000", cbasic_float32(100) == 100) + assert("basic_float32\000", basic_float32(100) == 100) +} + +//go:linkname cbasic_float64 C.basic_float64 +func cbasic_float64(a float64) float64 + +func basic_float64(a float64) float64 { + return a +} + +func init() { + assert("cbasic_float64\000", cbasic_float64(100) == 100) + assert("basic_float64\000", basic_float64(100) == 100) +} + +//go:linkname cbasic_uintptr C.basic_uintptr +func cbasic_uintptr(a uintptr) uintptr + +func basic_uintptr(a uintptr) uintptr { + return a +} + +func init() { + assert("cbasic_uintptr\000", cbasic_uintptr(100) == 100) + assert("basic_uintptr\000", basic_uintptr(100) == 100) +} diff --git a/internal/cabi/_testdata/demo/demo.go b/internal/cabi/_testdata/demo/demo.go new file mode 100644 index 00000000..307868a2 --- /dev/null +++ b/internal/cabi/_testdata/demo/demo.go @@ -0,0 +1,25 @@ +package main + +import ( + _ "unsafe" +) + +const ( + LLGoFiles = "../wrap/demo.c" +) + +type st1 struct { + x int32 + y int32 +} + +//go:linkname cfn1 C.fn1 +func cfn1(v st1) st1 + +func fn1(v st1) st1 { + return v +} + +func main() { + cfn1(st1{}) +} diff --git a/internal/cabi/_testdata/demo/struct_float32.go b/internal/cabi/_testdata/demo/struct_float32.go new file mode 100644 index 00000000..baaf4d0e --- /dev/null +++ b/internal/cabi/_testdata/demo/struct_float32.go @@ -0,0 +1,549 @@ +package main + +import "unsafe" + +const ( + LLGoFiles = "../wrap/struct_float32.c" +) + +//go:linkname printf C.printf +func printf(format *byte, __llgo_va_list ...any) int32 + +func assert(info string, b bool) { + if !b { + printf(unsafe.StringData("Assertion failed: %s\n\000"), unsafe.StringData(info)) + } +} + +func main() { +} + +type point1 struct { + x0 float32 +} + +//go:linkname cdemo1 C.demo1 +func cdemo1(a point1) point1 + +func demo1(a point1) point1 { + return a +} + +func init() { + a := point1{1} + assert("cdemo1\000", cdemo1(a) == a) + assert("demo1\000", demo1(a) == a) +} + +type point2 struct { + x0 float32 + x1 float32 +} + +//go:linkname cdemo2 C.demo2 +func cdemo2(a point2) point2 + +func demo2(a point2) point2 { + return a +} + +func init() { + a := point2{1, 2} + assert("cdemo2\000", cdemo2(a) == a) + assert("demo2\000", demo2(a) == a) +} + +type point3 struct { + x0 float32 + x1 float32 + x2 float32 +} + +//go:linkname cdemo3 C.demo3 +func cdemo3(a point3) point3 + +func demo3(a point3) point3 { + return a +} + +func init() { + a := point3{1, 2, 3} + assert("cdemo3\000", cdemo3(a) == a) + assert("demo3\000", demo3(a) == a) +} + +type point4 struct { + x0 float32 + x1 float32 + x2 float32 + x3 float32 +} + +//go:linkname cdemo4 C.demo4 +func cdemo4(a point4) point4 + +func demo4(a point4) point4 { + return a +} + +func init() { + a := point4{1, 2, 3, 4} + assert("cdemo4\000", cdemo4(a) == a) + assert("demo4\000", demo4(a) == a) +} + +type point5 struct { + x0 float32 + x1 float32 + x2 float32 + x3 float32 + x4 float32 +} + +//go:linkname cdemo5 C.demo5 +func cdemo5(a point5) point5 + +func demo5(a point5) point5 { + return a +} + +func init() { + a := point5{1, 2, 3, 4, 5} + assert("cdemo5\000", cdemo5(a) == a) + assert("demo5\000", demo5(a) == a) +} + +type point6 struct { + x0 float32 + x1 float32 + x2 float32 + x3 float32 + x4 float32 + x5 float32 +} + +//go:linkname cdemo6 C.demo6 +func cdemo6(a point6) point6 + +func demo6(a point6) point6 { + return a +} + +func init() { + a := point6{1, 2, 3, 4, 5, 6} + assert("cdemo6\000", cdemo6(a) == a) + assert("demo6\000", demo6(a) == a) +} + +type point7 struct { + x0 float32 + x1 float32 + x2 float32 + x3 float32 + x4 float32 + x5 float32 + x6 float32 +} + +//go:linkname cdemo7 C.demo7 +func cdemo7(a point7) point7 + +func demo7(a point7) point7 { + return a +} + +func init() { + a := point7{1, 2, 3, 4, 5, 6, 7} + assert("cdemo7\000", cdemo7(a) == a) + assert("demo7\000", demo7(a) == a) +} + +type point8 struct { + x0 float32 + x1 float32 + x2 float32 + x3 float32 + x4 float32 + x5 float32 + x6 float32 + x7 float32 +} + +//go:linkname cdemo8 C.demo8 +func cdemo8(a point8) point8 + +func demo8(a point8) point8 { + return a +} + +func init() { + a := point8{1, 2, 3, 4, 5, 6, 7, 8} + assert("cdemo8\000", cdemo8(a) == a) + assert("demo8\000", demo8(a) == a) +} + +type point9 struct { + x0 float32 + x1 float32 + x2 float32 + x3 float32 + x4 float32 + x5 float32 + x6 float32 + x7 float32 + x8 float32 +} + +//go:linkname cdemo9 C.demo9 +func cdemo9(a point9) point9 + +func demo9(a point9) point9 { + return a +} + +func init() { + a := point9{1, 2, 3, 4, 5, 6, 7, 8, 9} + assert("cdemo9\000", cdemo9(a) == a) + assert("demo9\000", demo9(a) == a) +} + +type point10 struct { + x0 float32 + x1 float32 + x2 float32 + x3 float32 + x4 float32 + x5 float32 + x6 float32 + x7 float32 + x8 float32 + x9 float32 +} + +//go:linkname cdemo10 C.demo10 +func cdemo10(a point10) point10 + +func demo10(a point10) point10 { + return a +} + +func init() { + a := point10{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} + assert("cdemo10\000", cdemo10(a) == a) + assert("demo10\000", demo10(a) == a) +} + +type point11 struct { + x0 float32 + x1 float32 + x2 float32 + x3 float32 + x4 float32 + x5 float32 + x6 float32 + x7 float32 + x8 float32 + x9 float32 + x10 float32 +} + +//go:linkname cdemo11 C.demo11 +func cdemo11(a point11) point11 + +func demo11(a point11) point11 { + return a +} + +func init() { + a := point11{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} + assert("cdemo11\000", cdemo11(a) == a) + assert("demo11\000", demo11(a) == a) +} + +type point12 struct { + x0 float32 + x1 float32 + x2 float32 + x3 float32 + x4 float32 + x5 float32 + x6 float32 + x7 float32 + x8 float32 + x9 float32 + x10 float32 + x11 float32 +} + +//go:linkname cdemo12 C.demo12 +func cdemo12(a point12) point12 + +func demo12(a point12) point12 { + return a +} + +func init() { + a := point12{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} + assert("cdemo12\000", cdemo12(a) == a) + assert("demo12\000", demo12(a) == a) +} + +type point13 struct { + x0 float32 + x1 float32 + x2 float32 + x3 float32 + x4 float32 + x5 float32 + x6 float32 + x7 float32 + x8 float32 + x9 float32 + x10 float32 + x11 float32 + x12 float32 +} + +//go:linkname cdemo13 C.demo13 +func cdemo13(a point13) point13 + +func demo13(a point13) point13 { + return a +} + +func init() { + a := point13{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13} + assert("cdemo13\000", cdemo13(a) == a) + assert("demo13\000", demo13(a) == a) +} + +type point14 struct { + x0 float32 + x1 float32 + x2 float32 + x3 float32 + x4 float32 + x5 float32 + x6 float32 + x7 float32 + x8 float32 + x9 float32 + x10 float32 + x11 float32 + x12 float32 + x13 float32 +} + +//go:linkname cdemo14 C.demo14 +func cdemo14(a point14) point14 + +func demo14(a point14) point14 { + return a +} + +func init() { + a := point14{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14} + assert("cdemo14\000", cdemo14(a) == a) + assert("demo14\000", demo14(a) == a) +} + +type point15 struct { + x0 float32 + x1 float32 + x2 float32 + x3 float32 + x4 float32 + x5 float32 + x6 float32 + x7 float32 + x8 float32 + x9 float32 + x10 float32 + x11 float32 + x12 float32 + x13 float32 + x14 float32 +} + +//go:linkname cdemo15 C.demo15 +func cdemo15(a point15) point15 + +func demo15(a point15) point15 { + return a +} + +func init() { + a := point15{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} + assert("cdemo15\000", cdemo15(a) == a) + assert("demo15\000", demo15(a) == a) +} + +type point16 struct { + x0 float32 + x1 float32 + x2 float32 + x3 float32 + x4 float32 + x5 float32 + x6 float32 + x7 float32 + x8 float32 + x9 float32 + x10 float32 + x11 float32 + x12 float32 + x13 float32 + x14 float32 + x15 float32 +} + +//go:linkname cdemo16 C.demo16 +func cdemo16(a point16) point16 + +func demo16(a point16) point16 { + return a +} + +func init() { + a := point16{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16} + assert("cdemo16\000", cdemo16(a) == a) + assert("demo16\000", demo16(a) == a) +} + +type point17 struct { + x0 float32 + x1 float32 + x2 float32 + x3 float32 + x4 float32 + x5 float32 + x6 float32 + x7 float32 + x8 float32 + x9 float32 + x10 float32 + x11 float32 + x12 float32 + x13 float32 + x14 float32 + x15 float32 + x16 float32 +} + +//go:linkname cdemo17 C.demo17 +func cdemo17(a point17) point17 + +func demo17(a point17) point17 { + return a +} + +func init() { + a := point17{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17} + assert("cdemo17\000", cdemo17(a) == a) + assert("demo17\000", demo17(a) == a) +} + +type point18 struct { + x0 float32 + x1 float32 + x2 float32 + x3 float32 + x4 float32 + x5 float32 + x6 float32 + x7 float32 + x8 float32 + x9 float32 + x10 float32 + x11 float32 + x12 float32 + x13 float32 + x14 float32 + x15 float32 + x16 float32 + x17 float32 +} + +//go:linkname cdemo18 C.demo18 +func cdemo18(a point18) point18 + +func demo18(a point18) point18 { + return a +} + +func init() { + a := point18{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18} + assert("cdemo18\000", cdemo18(a) == a) + assert("demo18\000", demo18(a) == a) +} + +type point19 struct { + x0 float32 + x1 float32 + x2 float32 + x3 float32 + x4 float32 + x5 float32 + x6 float32 + x7 float32 + x8 float32 + x9 float32 + x10 float32 + x11 float32 + x12 float32 + x13 float32 + x14 float32 + x15 float32 + x16 float32 + x17 float32 + x18 float32 +} + +//go:linkname cdemo19 C.demo19 +func cdemo19(a point19) point19 + +func demo19(a point19) point19 { + return a +} + +func init() { + a := point19{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19} + assert("cdemo19\000", cdemo19(a) == a) + assert("demo19\000", demo19(a) == a) +} + +type point20 struct { + x0 float32 + x1 float32 + x2 float32 + x3 float32 + x4 float32 + x5 float32 + x6 float32 + x7 float32 + x8 float32 + x9 float32 + x10 float32 + x11 float32 + x12 float32 + x13 float32 + x14 float32 + x15 float32 + x16 float32 + x17 float32 + x18 float32 + x19 float32 +} + +//go:linkname cdemo20 C.demo20 +func cdemo20(a point20) point20 + +func demo20(a point20) point20 { + return a +} + +func init() { + a := point20{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20} + assert("cdemo20\000", cdemo20(a) == a) + assert("demo20\000", demo20(a) == a) +} diff --git a/internal/cabi/_testdata/demo/struct_float64.go b/internal/cabi/_testdata/demo/struct_float64.go new file mode 100644 index 00000000..408419a8 --- /dev/null +++ b/internal/cabi/_testdata/demo/struct_float64.go @@ -0,0 +1,549 @@ +package main + +import "unsafe" + +const ( + LLGoFiles = "../wrap/struct_float64.c" +) + +//go:linkname printf C.printf +func printf(format *byte, __llgo_va_list ...any) int32 + +func assert(info string, b bool) { + if !b { + printf(unsafe.StringData("Assertion failed: %s\n\000"), unsafe.StringData(info)) + } +} + +func main() { +} + +type point1 struct { + x0 float64 +} + +//go:linkname cdemo1 C.demo1 +func cdemo1(a point1) point1 + +func demo1(a point1) point1 { + return a +} + +func init() { + a := point1{1} + assert("cdemo1\000", cdemo1(a) == a) + assert("demo1\000", demo1(a) == a) +} + +type point2 struct { + x0 float64 + x1 float64 +} + +//go:linkname cdemo2 C.demo2 +func cdemo2(a point2) point2 + +func demo2(a point2) point2 { + return a +} + +func init() { + a := point2{1, 2} + assert("cdemo2\000", cdemo2(a) == a) + assert("demo2\000", demo2(a) == a) +} + +type point3 struct { + x0 float64 + x1 float64 + x2 float64 +} + +//go:linkname cdemo3 C.demo3 +func cdemo3(a point3) point3 + +func demo3(a point3) point3 { + return a +} + +func init() { + a := point3{1, 2, 3} + assert("cdemo3\000", cdemo3(a) == a) + assert("demo3\000", demo3(a) == a) +} + +type point4 struct { + x0 float64 + x1 float64 + x2 float64 + x3 float64 +} + +//go:linkname cdemo4 C.demo4 +func cdemo4(a point4) point4 + +func demo4(a point4) point4 { + return a +} + +func init() { + a := point4{1, 2, 3, 4} + assert("cdemo4\000", cdemo4(a) == a) + assert("demo4\000", demo4(a) == a) +} + +type point5 struct { + x0 float64 + x1 float64 + x2 float64 + x3 float64 + x4 float64 +} + +//go:linkname cdemo5 C.demo5 +func cdemo5(a point5) point5 + +func demo5(a point5) point5 { + return a +} + +func init() { + a := point5{1, 2, 3, 4, 5} + assert("cdemo5\000", cdemo5(a) == a) + assert("demo5\000", demo5(a) == a) +} + +type point6 struct { + x0 float64 + x1 float64 + x2 float64 + x3 float64 + x4 float64 + x5 float64 +} + +//go:linkname cdemo6 C.demo6 +func cdemo6(a point6) point6 + +func demo6(a point6) point6 { + return a +} + +func init() { + a := point6{1, 2, 3, 4, 5, 6} + assert("cdemo6\000", cdemo6(a) == a) + assert("demo6\000", demo6(a) == a) +} + +type point7 struct { + x0 float64 + x1 float64 + x2 float64 + x3 float64 + x4 float64 + x5 float64 + x6 float64 +} + +//go:linkname cdemo7 C.demo7 +func cdemo7(a point7) point7 + +func demo7(a point7) point7 { + return a +} + +func init() { + a := point7{1, 2, 3, 4, 5, 6, 7} + assert("cdemo7\000", cdemo7(a) == a) + assert("demo7\000", demo7(a) == a) +} + +type point8 struct { + x0 float64 + x1 float64 + x2 float64 + x3 float64 + x4 float64 + x5 float64 + x6 float64 + x7 float64 +} + +//go:linkname cdemo8 C.demo8 +func cdemo8(a point8) point8 + +func demo8(a point8) point8 { + return a +} + +func init() { + a := point8{1, 2, 3, 4, 5, 6, 7, 8} + assert("cdemo8\000", cdemo8(a) == a) + assert("demo8\000", demo8(a) == a) +} + +type point9 struct { + x0 float64 + x1 float64 + x2 float64 + x3 float64 + x4 float64 + x5 float64 + x6 float64 + x7 float64 + x8 float64 +} + +//go:linkname cdemo9 C.demo9 +func cdemo9(a point9) point9 + +func demo9(a point9) point9 { + return a +} + +func init() { + a := point9{1, 2, 3, 4, 5, 6, 7, 8, 9} + assert("cdemo9\000", cdemo9(a) == a) + assert("demo9\000", demo9(a) == a) +} + +type point10 struct { + x0 float64 + x1 float64 + x2 float64 + x3 float64 + x4 float64 + x5 float64 + x6 float64 + x7 float64 + x8 float64 + x9 float64 +} + +//go:linkname cdemo10 C.demo10 +func cdemo10(a point10) point10 + +func demo10(a point10) point10 { + return a +} + +func init() { + a := point10{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} + assert("cdemo10\000", cdemo10(a) == a) + assert("demo10\000", demo10(a) == a) +} + +type point11 struct { + x0 float64 + x1 float64 + x2 float64 + x3 float64 + x4 float64 + x5 float64 + x6 float64 + x7 float64 + x8 float64 + x9 float64 + x10 float64 +} + +//go:linkname cdemo11 C.demo11 +func cdemo11(a point11) point11 + +func demo11(a point11) point11 { + return a +} + +func init() { + a := point11{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} + assert("cdemo11\000", cdemo11(a) == a) + assert("demo11\000", demo11(a) == a) +} + +type point12 struct { + x0 float64 + x1 float64 + x2 float64 + x3 float64 + x4 float64 + x5 float64 + x6 float64 + x7 float64 + x8 float64 + x9 float64 + x10 float64 + x11 float64 +} + +//go:linkname cdemo12 C.demo12 +func cdemo12(a point12) point12 + +func demo12(a point12) point12 { + return a +} + +func init() { + a := point12{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} + assert("cdemo12\000", cdemo12(a) == a) + assert("demo12\000", demo12(a) == a) +} + +type point13 struct { + x0 float64 + x1 float64 + x2 float64 + x3 float64 + x4 float64 + x5 float64 + x6 float64 + x7 float64 + x8 float64 + x9 float64 + x10 float64 + x11 float64 + x12 float64 +} + +//go:linkname cdemo13 C.demo13 +func cdemo13(a point13) point13 + +func demo13(a point13) point13 { + return a +} + +func init() { + a := point13{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13} + assert("cdemo13\000", cdemo13(a) == a) + assert("demo13\000", demo13(a) == a) +} + +type point14 struct { + x0 float64 + x1 float64 + x2 float64 + x3 float64 + x4 float64 + x5 float64 + x6 float64 + x7 float64 + x8 float64 + x9 float64 + x10 float64 + x11 float64 + x12 float64 + x13 float64 +} + +//go:linkname cdemo14 C.demo14 +func cdemo14(a point14) point14 + +func demo14(a point14) point14 { + return a +} + +func init() { + a := point14{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14} + assert("cdemo14\000", cdemo14(a) == a) + assert("demo14\000", demo14(a) == a) +} + +type point15 struct { + x0 float64 + x1 float64 + x2 float64 + x3 float64 + x4 float64 + x5 float64 + x6 float64 + x7 float64 + x8 float64 + x9 float64 + x10 float64 + x11 float64 + x12 float64 + x13 float64 + x14 float64 +} + +//go:linkname cdemo15 C.demo15 +func cdemo15(a point15) point15 + +func demo15(a point15) point15 { + return a +} + +func init() { + a := point15{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} + assert("cdemo15\000", cdemo15(a) == a) + assert("demo15\000", demo15(a) == a) +} + +type point16 struct { + x0 float64 + x1 float64 + x2 float64 + x3 float64 + x4 float64 + x5 float64 + x6 float64 + x7 float64 + x8 float64 + x9 float64 + x10 float64 + x11 float64 + x12 float64 + x13 float64 + x14 float64 + x15 float64 +} + +//go:linkname cdemo16 C.demo16 +func cdemo16(a point16) point16 + +func demo16(a point16) point16 { + return a +} + +func init() { + a := point16{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16} + assert("cdemo16\000", cdemo16(a) == a) + assert("demo16\000", demo16(a) == a) +} + +type point17 struct { + x0 float64 + x1 float64 + x2 float64 + x3 float64 + x4 float64 + x5 float64 + x6 float64 + x7 float64 + x8 float64 + x9 float64 + x10 float64 + x11 float64 + x12 float64 + x13 float64 + x14 float64 + x15 float64 + x16 float64 +} + +//go:linkname cdemo17 C.demo17 +func cdemo17(a point17) point17 + +func demo17(a point17) point17 { + return a +} + +func init() { + a := point17{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17} + assert("cdemo17\000", cdemo17(a) == a) + assert("demo17\000", demo17(a) == a) +} + +type point18 struct { + x0 float64 + x1 float64 + x2 float64 + x3 float64 + x4 float64 + x5 float64 + x6 float64 + x7 float64 + x8 float64 + x9 float64 + x10 float64 + x11 float64 + x12 float64 + x13 float64 + x14 float64 + x15 float64 + x16 float64 + x17 float64 +} + +//go:linkname cdemo18 C.demo18 +func cdemo18(a point18) point18 + +func demo18(a point18) point18 { + return a +} + +func init() { + a := point18{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18} + assert("cdemo18\000", cdemo18(a) == a) + assert("demo18\000", demo18(a) == a) +} + +type point19 struct { + x0 float64 + x1 float64 + x2 float64 + x3 float64 + x4 float64 + x5 float64 + x6 float64 + x7 float64 + x8 float64 + x9 float64 + x10 float64 + x11 float64 + x12 float64 + x13 float64 + x14 float64 + x15 float64 + x16 float64 + x17 float64 + x18 float64 +} + +//go:linkname cdemo19 C.demo19 +func cdemo19(a point19) point19 + +func demo19(a point19) point19 { + return a +} + +func init() { + a := point19{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19} + assert("cdemo19\000", cdemo19(a) == a) + assert("demo19\000", demo19(a) == a) +} + +type point20 struct { + x0 float64 + x1 float64 + x2 float64 + x3 float64 + x4 float64 + x5 float64 + x6 float64 + x7 float64 + x8 float64 + x9 float64 + x10 float64 + x11 float64 + x12 float64 + x13 float64 + x14 float64 + x15 float64 + x16 float64 + x17 float64 + x18 float64 + x19 float64 +} + +//go:linkname cdemo20 C.demo20 +func cdemo20(a point20) point20 + +func demo20(a point20) point20 { + return a +} + +func init() { + a := point20{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20} + assert("cdemo20\000", cdemo20(a) == a) + assert("demo20\000", demo20(a) == a) +} diff --git a/internal/cabi/_testdata/demo/struct_int16.go b/internal/cabi/_testdata/demo/struct_int16.go new file mode 100644 index 00000000..66e386d1 --- /dev/null +++ b/internal/cabi/_testdata/demo/struct_int16.go @@ -0,0 +1,549 @@ +package main + +import "unsafe" + +const ( + LLGoFiles = "../wrap/struct_int16.c" +) + +//go:linkname printf C.printf +func printf(format *byte, __llgo_va_list ...any) int32 + +func assert(info string, b bool) { + if !b { + printf(unsafe.StringData("Assertion failed: %s\n\000"), unsafe.StringData(info)) + } +} + +func main() { +} + +type point1 struct { + x0 int16 +} + +//go:linkname cdemo1 C.demo1 +func cdemo1(a point1) point1 + +func demo1(a point1) point1 { + return a +} + +func init() { + a := point1{1} + assert("cdemo1\000", cdemo1(a) == a) + assert("demo1\000", demo1(a) == a) +} + +type point2 struct { + x0 int16 + x1 int16 +} + +//go:linkname cdemo2 C.demo2 +func cdemo2(a point2) point2 + +func demo2(a point2) point2 { + return a +} + +func init() { + a := point2{1, 2} + assert("cdemo2\000", cdemo2(a) == a) + assert("demo2\000", demo2(a) == a) +} + +type point3 struct { + x0 int16 + x1 int16 + x2 int16 +} + +//go:linkname cdemo3 C.demo3 +func cdemo3(a point3) point3 + +func demo3(a point3) point3 { + return a +} + +func init() { + a := point3{1, 2, 3} + assert("cdemo3\000", cdemo3(a) == a) + assert("demo3\000", demo3(a) == a) +} + +type point4 struct { + x0 int16 + x1 int16 + x2 int16 + x3 int16 +} + +//go:linkname cdemo4 C.demo4 +func cdemo4(a point4) point4 + +func demo4(a point4) point4 { + return a +} + +func init() { + a := point4{1, 2, 3, 4} + assert("cdemo4\000", cdemo4(a) == a) + assert("demo4\000", demo4(a) == a) +} + +type point5 struct { + x0 int16 + x1 int16 + x2 int16 + x3 int16 + x4 int16 +} + +//go:linkname cdemo5 C.demo5 +func cdemo5(a point5) point5 + +func demo5(a point5) point5 { + return a +} + +func init() { + a := point5{1, 2, 3, 4, 5} + assert("cdemo5\000", cdemo5(a) == a) + assert("demo5\000", demo5(a) == a) +} + +type point6 struct { + x0 int16 + x1 int16 + x2 int16 + x3 int16 + x4 int16 + x5 int16 +} + +//go:linkname cdemo6 C.demo6 +func cdemo6(a point6) point6 + +func demo6(a point6) point6 { + return a +} + +func init() { + a := point6{1, 2, 3, 4, 5, 6} + assert("cdemo6\000", cdemo6(a) == a) + assert("demo6\000", demo6(a) == a) +} + +type point7 struct { + x0 int16 + x1 int16 + x2 int16 + x3 int16 + x4 int16 + x5 int16 + x6 int16 +} + +//go:linkname cdemo7 C.demo7 +func cdemo7(a point7) point7 + +func demo7(a point7) point7 { + return a +} + +func init() { + a := point7{1, 2, 3, 4, 5, 6, 7} + assert("cdemo7\000", cdemo7(a) == a) + assert("demo7\000", demo7(a) == a) +} + +type point8 struct { + x0 int16 + x1 int16 + x2 int16 + x3 int16 + x4 int16 + x5 int16 + x6 int16 + x7 int16 +} + +//go:linkname cdemo8 C.demo8 +func cdemo8(a point8) point8 + +func demo8(a point8) point8 { + return a +} + +func init() { + a := point8{1, 2, 3, 4, 5, 6, 7, 8} + assert("cdemo8\000", cdemo8(a) == a) + assert("demo8\000", demo8(a) == a) +} + +type point9 struct { + x0 int16 + x1 int16 + x2 int16 + x3 int16 + x4 int16 + x5 int16 + x6 int16 + x7 int16 + x8 int16 +} + +//go:linkname cdemo9 C.demo9 +func cdemo9(a point9) point9 + +func demo9(a point9) point9 { + return a +} + +func init() { + a := point9{1, 2, 3, 4, 5, 6, 7, 8, 9} + assert("cdemo9\000", cdemo9(a) == a) + assert("demo9\000", demo9(a) == a) +} + +type point10 struct { + x0 int16 + x1 int16 + x2 int16 + x3 int16 + x4 int16 + x5 int16 + x6 int16 + x7 int16 + x8 int16 + x9 int16 +} + +//go:linkname cdemo10 C.demo10 +func cdemo10(a point10) point10 + +func demo10(a point10) point10 { + return a +} + +func init() { + a := point10{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} + assert("cdemo10\000", cdemo10(a) == a) + assert("demo10\000", demo10(a) == a) +} + +type point11 struct { + x0 int16 + x1 int16 + x2 int16 + x3 int16 + x4 int16 + x5 int16 + x6 int16 + x7 int16 + x8 int16 + x9 int16 + x10 int16 +} + +//go:linkname cdemo11 C.demo11 +func cdemo11(a point11) point11 + +func demo11(a point11) point11 { + return a +} + +func init() { + a := point11{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} + assert("cdemo11\000", cdemo11(a) == a) + assert("demo11\000", demo11(a) == a) +} + +type point12 struct { + x0 int16 + x1 int16 + x2 int16 + x3 int16 + x4 int16 + x5 int16 + x6 int16 + x7 int16 + x8 int16 + x9 int16 + x10 int16 + x11 int16 +} + +//go:linkname cdemo12 C.demo12 +func cdemo12(a point12) point12 + +func demo12(a point12) point12 { + return a +} + +func init() { + a := point12{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} + assert("cdemo12\000", cdemo12(a) == a) + assert("demo12\000", demo12(a) == a) +} + +type point13 struct { + x0 int16 + x1 int16 + x2 int16 + x3 int16 + x4 int16 + x5 int16 + x6 int16 + x7 int16 + x8 int16 + x9 int16 + x10 int16 + x11 int16 + x12 int16 +} + +//go:linkname cdemo13 C.demo13 +func cdemo13(a point13) point13 + +func demo13(a point13) point13 { + return a +} + +func init() { + a := point13{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13} + assert("cdemo13\000", cdemo13(a) == a) + assert("demo13\000", demo13(a) == a) +} + +type point14 struct { + x0 int16 + x1 int16 + x2 int16 + x3 int16 + x4 int16 + x5 int16 + x6 int16 + x7 int16 + x8 int16 + x9 int16 + x10 int16 + x11 int16 + x12 int16 + x13 int16 +} + +//go:linkname cdemo14 C.demo14 +func cdemo14(a point14) point14 + +func demo14(a point14) point14 { + return a +} + +func init() { + a := point14{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14} + assert("cdemo14\000", cdemo14(a) == a) + assert("demo14\000", demo14(a) == a) +} + +type point15 struct { + x0 int16 + x1 int16 + x2 int16 + x3 int16 + x4 int16 + x5 int16 + x6 int16 + x7 int16 + x8 int16 + x9 int16 + x10 int16 + x11 int16 + x12 int16 + x13 int16 + x14 int16 +} + +//go:linkname cdemo15 C.demo15 +func cdemo15(a point15) point15 + +func demo15(a point15) point15 { + return a +} + +func init() { + a := point15{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} + assert("cdemo15\000", cdemo15(a) == a) + assert("demo15\000", demo15(a) == a) +} + +type point16 struct { + x0 int16 + x1 int16 + x2 int16 + x3 int16 + x4 int16 + x5 int16 + x6 int16 + x7 int16 + x8 int16 + x9 int16 + x10 int16 + x11 int16 + x12 int16 + x13 int16 + x14 int16 + x15 int16 +} + +//go:linkname cdemo16 C.demo16 +func cdemo16(a point16) point16 + +func demo16(a point16) point16 { + return a +} + +func init() { + a := point16{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16} + assert("cdemo16\000", cdemo16(a) == a) + assert("demo16\000", demo16(a) == a) +} + +type point17 struct { + x0 int16 + x1 int16 + x2 int16 + x3 int16 + x4 int16 + x5 int16 + x6 int16 + x7 int16 + x8 int16 + x9 int16 + x10 int16 + x11 int16 + x12 int16 + x13 int16 + x14 int16 + x15 int16 + x16 int16 +} + +//go:linkname cdemo17 C.demo17 +func cdemo17(a point17) point17 + +func demo17(a point17) point17 { + return a +} + +func init() { + a := point17{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17} + assert("cdemo17\000", cdemo17(a) == a) + assert("demo17\000", demo17(a) == a) +} + +type point18 struct { + x0 int16 + x1 int16 + x2 int16 + x3 int16 + x4 int16 + x5 int16 + x6 int16 + x7 int16 + x8 int16 + x9 int16 + x10 int16 + x11 int16 + x12 int16 + x13 int16 + x14 int16 + x15 int16 + x16 int16 + x17 int16 +} + +//go:linkname cdemo18 C.demo18 +func cdemo18(a point18) point18 + +func demo18(a point18) point18 { + return a +} + +func init() { + a := point18{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18} + assert("cdemo18\000", cdemo18(a) == a) + assert("demo18\000", demo18(a) == a) +} + +type point19 struct { + x0 int16 + x1 int16 + x2 int16 + x3 int16 + x4 int16 + x5 int16 + x6 int16 + x7 int16 + x8 int16 + x9 int16 + x10 int16 + x11 int16 + x12 int16 + x13 int16 + x14 int16 + x15 int16 + x16 int16 + x17 int16 + x18 int16 +} + +//go:linkname cdemo19 C.demo19 +func cdemo19(a point19) point19 + +func demo19(a point19) point19 { + return a +} + +func init() { + a := point19{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19} + assert("cdemo19\000", cdemo19(a) == a) + assert("demo19\000", demo19(a) == a) +} + +type point20 struct { + x0 int16 + x1 int16 + x2 int16 + x3 int16 + x4 int16 + x5 int16 + x6 int16 + x7 int16 + x8 int16 + x9 int16 + x10 int16 + x11 int16 + x12 int16 + x13 int16 + x14 int16 + x15 int16 + x16 int16 + x17 int16 + x18 int16 + x19 int16 +} + +//go:linkname cdemo20 C.demo20 +func cdemo20(a point20) point20 + +func demo20(a point20) point20 { + return a +} + +func init() { + a := point20{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20} + assert("cdemo20\000", cdemo20(a) == a) + assert("demo20\000", demo20(a) == a) +} diff --git a/internal/cabi/_testdata/demo/struct_int32.go b/internal/cabi/_testdata/demo/struct_int32.go new file mode 100644 index 00000000..2fb70225 --- /dev/null +++ b/internal/cabi/_testdata/demo/struct_int32.go @@ -0,0 +1,549 @@ +package main + +import "unsafe" + +const ( + LLGoFiles = "../wrap/struct_int32.c" +) + +//go:linkname printf C.printf +func printf(format *byte, __llgo_va_list ...any) int32 + +func assert(info string, b bool) { + if !b { + printf(unsafe.StringData("Assertion failed: %s\n\000"), unsafe.StringData(info)) + } +} + +func main() { +} + +type point1 struct { + x0 int32 +} + +//go:linkname cdemo1 C.demo1 +func cdemo1(a point1) point1 + +func demo1(a point1) point1 { + return a +} + +func init() { + a := point1{1} + assert("cdemo1\000", cdemo1(a) == a) + assert("demo1\000", demo1(a) == a) +} + +type point2 struct { + x0 int32 + x1 int32 +} + +//go:linkname cdemo2 C.demo2 +func cdemo2(a point2) point2 + +func demo2(a point2) point2 { + return a +} + +func init() { + a := point2{1, 2} + assert("cdemo2\000", cdemo2(a) == a) + assert("demo2\000", demo2(a) == a) +} + +type point3 struct { + x0 int32 + x1 int32 + x2 int32 +} + +//go:linkname cdemo3 C.demo3 +func cdemo3(a point3) point3 + +func demo3(a point3) point3 { + return a +} + +func init() { + a := point3{1, 2, 3} + assert("cdemo3\000", cdemo3(a) == a) + assert("demo3\000", demo3(a) == a) +} + +type point4 struct { + x0 int32 + x1 int32 + x2 int32 + x3 int32 +} + +//go:linkname cdemo4 C.demo4 +func cdemo4(a point4) point4 + +func demo4(a point4) point4 { + return a +} + +func init() { + a := point4{1, 2, 3, 4} + assert("cdemo4\000", cdemo4(a) == a) + assert("demo4\000", demo4(a) == a) +} + +type point5 struct { + x0 int32 + x1 int32 + x2 int32 + x3 int32 + x4 int32 +} + +//go:linkname cdemo5 C.demo5 +func cdemo5(a point5) point5 + +func demo5(a point5) point5 { + return a +} + +func init() { + a := point5{1, 2, 3, 4, 5} + assert("cdemo5\000", cdemo5(a) == a) + assert("demo5\000", demo5(a) == a) +} + +type point6 struct { + x0 int32 + x1 int32 + x2 int32 + x3 int32 + x4 int32 + x5 int32 +} + +//go:linkname cdemo6 C.demo6 +func cdemo6(a point6) point6 + +func demo6(a point6) point6 { + return a +} + +func init() { + a := point6{1, 2, 3, 4, 5, 6} + assert("cdemo6\000", cdemo6(a) == a) + assert("demo6\000", demo6(a) == a) +} + +type point7 struct { + x0 int32 + x1 int32 + x2 int32 + x3 int32 + x4 int32 + x5 int32 + x6 int32 +} + +//go:linkname cdemo7 C.demo7 +func cdemo7(a point7) point7 + +func demo7(a point7) point7 { + return a +} + +func init() { + a := point7{1, 2, 3, 4, 5, 6, 7} + assert("cdemo7\000", cdemo7(a) == a) + assert("demo7\000", demo7(a) == a) +} + +type point8 struct { + x0 int32 + x1 int32 + x2 int32 + x3 int32 + x4 int32 + x5 int32 + x6 int32 + x7 int32 +} + +//go:linkname cdemo8 C.demo8 +func cdemo8(a point8) point8 + +func demo8(a point8) point8 { + return a +} + +func init() { + a := point8{1, 2, 3, 4, 5, 6, 7, 8} + assert("cdemo8\000", cdemo8(a) == a) + assert("demo8\000", demo8(a) == a) +} + +type point9 struct { + x0 int32 + x1 int32 + x2 int32 + x3 int32 + x4 int32 + x5 int32 + x6 int32 + x7 int32 + x8 int32 +} + +//go:linkname cdemo9 C.demo9 +func cdemo9(a point9) point9 + +func demo9(a point9) point9 { + return a +} + +func init() { + a := point9{1, 2, 3, 4, 5, 6, 7, 8, 9} + assert("cdemo9\000", cdemo9(a) == a) + assert("demo9\000", demo9(a) == a) +} + +type point10 struct { + x0 int32 + x1 int32 + x2 int32 + x3 int32 + x4 int32 + x5 int32 + x6 int32 + x7 int32 + x8 int32 + x9 int32 +} + +//go:linkname cdemo10 C.demo10 +func cdemo10(a point10) point10 + +func demo10(a point10) point10 { + return a +} + +func init() { + a := point10{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} + assert("cdemo10\000", cdemo10(a) == a) + assert("demo10\000", demo10(a) == a) +} + +type point11 struct { + x0 int32 + x1 int32 + x2 int32 + x3 int32 + x4 int32 + x5 int32 + x6 int32 + x7 int32 + x8 int32 + x9 int32 + x10 int32 +} + +//go:linkname cdemo11 C.demo11 +func cdemo11(a point11) point11 + +func demo11(a point11) point11 { + return a +} + +func init() { + a := point11{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} + assert("cdemo11\000", cdemo11(a) == a) + assert("demo11\000", demo11(a) == a) +} + +type point12 struct { + x0 int32 + x1 int32 + x2 int32 + x3 int32 + x4 int32 + x5 int32 + x6 int32 + x7 int32 + x8 int32 + x9 int32 + x10 int32 + x11 int32 +} + +//go:linkname cdemo12 C.demo12 +func cdemo12(a point12) point12 + +func demo12(a point12) point12 { + return a +} + +func init() { + a := point12{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} + assert("cdemo12\000", cdemo12(a) == a) + assert("demo12\000", demo12(a) == a) +} + +type point13 struct { + x0 int32 + x1 int32 + x2 int32 + x3 int32 + x4 int32 + x5 int32 + x6 int32 + x7 int32 + x8 int32 + x9 int32 + x10 int32 + x11 int32 + x12 int32 +} + +//go:linkname cdemo13 C.demo13 +func cdemo13(a point13) point13 + +func demo13(a point13) point13 { + return a +} + +func init() { + a := point13{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13} + assert("cdemo13\000", cdemo13(a) == a) + assert("demo13\000", demo13(a) == a) +} + +type point14 struct { + x0 int32 + x1 int32 + x2 int32 + x3 int32 + x4 int32 + x5 int32 + x6 int32 + x7 int32 + x8 int32 + x9 int32 + x10 int32 + x11 int32 + x12 int32 + x13 int32 +} + +//go:linkname cdemo14 C.demo14 +func cdemo14(a point14) point14 + +func demo14(a point14) point14 { + return a +} + +func init() { + a := point14{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14} + assert("cdemo14\000", cdemo14(a) == a) + assert("demo14\000", demo14(a) == a) +} + +type point15 struct { + x0 int32 + x1 int32 + x2 int32 + x3 int32 + x4 int32 + x5 int32 + x6 int32 + x7 int32 + x8 int32 + x9 int32 + x10 int32 + x11 int32 + x12 int32 + x13 int32 + x14 int32 +} + +//go:linkname cdemo15 C.demo15 +func cdemo15(a point15) point15 + +func demo15(a point15) point15 { + return a +} + +func init() { + a := point15{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} + assert("cdemo15\000", cdemo15(a) == a) + assert("demo15\000", demo15(a) == a) +} + +type point16 struct { + x0 int32 + x1 int32 + x2 int32 + x3 int32 + x4 int32 + x5 int32 + x6 int32 + x7 int32 + x8 int32 + x9 int32 + x10 int32 + x11 int32 + x12 int32 + x13 int32 + x14 int32 + x15 int32 +} + +//go:linkname cdemo16 C.demo16 +func cdemo16(a point16) point16 + +func demo16(a point16) point16 { + return a +} + +func init() { + a := point16{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16} + assert("cdemo16\000", cdemo16(a) == a) + assert("demo16\000", demo16(a) == a) +} + +type point17 struct { + x0 int32 + x1 int32 + x2 int32 + x3 int32 + x4 int32 + x5 int32 + x6 int32 + x7 int32 + x8 int32 + x9 int32 + x10 int32 + x11 int32 + x12 int32 + x13 int32 + x14 int32 + x15 int32 + x16 int32 +} + +//go:linkname cdemo17 C.demo17 +func cdemo17(a point17) point17 + +func demo17(a point17) point17 { + return a +} + +func init() { + a := point17{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17} + assert("cdemo17\000", cdemo17(a) == a) + assert("demo17\000", demo17(a) == a) +} + +type point18 struct { + x0 int32 + x1 int32 + x2 int32 + x3 int32 + x4 int32 + x5 int32 + x6 int32 + x7 int32 + x8 int32 + x9 int32 + x10 int32 + x11 int32 + x12 int32 + x13 int32 + x14 int32 + x15 int32 + x16 int32 + x17 int32 +} + +//go:linkname cdemo18 C.demo18 +func cdemo18(a point18) point18 + +func demo18(a point18) point18 { + return a +} + +func init() { + a := point18{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18} + assert("cdemo18\000", cdemo18(a) == a) + assert("demo18\000", demo18(a) == a) +} + +type point19 struct { + x0 int32 + x1 int32 + x2 int32 + x3 int32 + x4 int32 + x5 int32 + x6 int32 + x7 int32 + x8 int32 + x9 int32 + x10 int32 + x11 int32 + x12 int32 + x13 int32 + x14 int32 + x15 int32 + x16 int32 + x17 int32 + x18 int32 +} + +//go:linkname cdemo19 C.demo19 +func cdemo19(a point19) point19 + +func demo19(a point19) point19 { + return a +} + +func init() { + a := point19{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19} + assert("cdemo19\000", cdemo19(a) == a) + assert("demo19\000", demo19(a) == a) +} + +type point20 struct { + x0 int32 + x1 int32 + x2 int32 + x3 int32 + x4 int32 + x5 int32 + x6 int32 + x7 int32 + x8 int32 + x9 int32 + x10 int32 + x11 int32 + x12 int32 + x13 int32 + x14 int32 + x15 int32 + x16 int32 + x17 int32 + x18 int32 + x19 int32 +} + +//go:linkname cdemo20 C.demo20 +func cdemo20(a point20) point20 + +func demo20(a point20) point20 { + return a +} + +func init() { + a := point20{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20} + assert("cdemo20\000", cdemo20(a) == a) + assert("demo20\000", demo20(a) == a) +} diff --git a/internal/cabi/_testdata/demo/struct_int64.go b/internal/cabi/_testdata/demo/struct_int64.go new file mode 100644 index 00000000..78741a12 --- /dev/null +++ b/internal/cabi/_testdata/demo/struct_int64.go @@ -0,0 +1,549 @@ +package main + +import "unsafe" + +const ( + LLGoFiles = "../wrap/struct_int64.c" +) + +//go:linkname printf C.printf +func printf(format *byte, __llgo_va_list ...any) int32 + +func assert(info string, b bool) { + if !b { + printf(unsafe.StringData("Assertion failed: %s\n\000"), unsafe.StringData(info)) + } +} + +func main() { +} + +type point1 struct { + x0 int64 +} + +//go:linkname cdemo1 C.demo1 +func cdemo1(a point1) point1 + +func demo1(a point1) point1 { + return a +} + +func init() { + a := point1{1} + assert("cdemo1\000", cdemo1(a) == a) + assert("demo1\000", demo1(a) == a) +} + +type point2 struct { + x0 int64 + x1 int64 +} + +//go:linkname cdemo2 C.demo2 +func cdemo2(a point2) point2 + +func demo2(a point2) point2 { + return a +} + +func init() { + a := point2{1, 2} + assert("cdemo2\000", cdemo2(a) == a) + assert("demo2\000", demo2(a) == a) +} + +type point3 struct { + x0 int64 + x1 int64 + x2 int64 +} + +//go:linkname cdemo3 C.demo3 +func cdemo3(a point3) point3 + +func demo3(a point3) point3 { + return a +} + +func init() { + a := point3{1, 2, 3} + assert("cdemo3\000", cdemo3(a) == a) + assert("demo3\000", demo3(a) == a) +} + +type point4 struct { + x0 int64 + x1 int64 + x2 int64 + x3 int64 +} + +//go:linkname cdemo4 C.demo4 +func cdemo4(a point4) point4 + +func demo4(a point4) point4 { + return a +} + +func init() { + a := point4{1, 2, 3, 4} + assert("cdemo4\000", cdemo4(a) == a) + assert("demo4\000", demo4(a) == a) +} + +type point5 struct { + x0 int64 + x1 int64 + x2 int64 + x3 int64 + x4 int64 +} + +//go:linkname cdemo5 C.demo5 +func cdemo5(a point5) point5 + +func demo5(a point5) point5 { + return a +} + +func init() { + a := point5{1, 2, 3, 4, 5} + assert("cdemo5\000", cdemo5(a) == a) + assert("demo5\000", demo5(a) == a) +} + +type point6 struct { + x0 int64 + x1 int64 + x2 int64 + x3 int64 + x4 int64 + x5 int64 +} + +//go:linkname cdemo6 C.demo6 +func cdemo6(a point6) point6 + +func demo6(a point6) point6 { + return a +} + +func init() { + a := point6{1, 2, 3, 4, 5, 6} + assert("cdemo6\000", cdemo6(a) == a) + assert("demo6\000", demo6(a) == a) +} + +type point7 struct { + x0 int64 + x1 int64 + x2 int64 + x3 int64 + x4 int64 + x5 int64 + x6 int64 +} + +//go:linkname cdemo7 C.demo7 +func cdemo7(a point7) point7 + +func demo7(a point7) point7 { + return a +} + +func init() { + a := point7{1, 2, 3, 4, 5, 6, 7} + assert("cdemo7\000", cdemo7(a) == a) + assert("demo7\000", demo7(a) == a) +} + +type point8 struct { + x0 int64 + x1 int64 + x2 int64 + x3 int64 + x4 int64 + x5 int64 + x6 int64 + x7 int64 +} + +//go:linkname cdemo8 C.demo8 +func cdemo8(a point8) point8 + +func demo8(a point8) point8 { + return a +} + +func init() { + a := point8{1, 2, 3, 4, 5, 6, 7, 8} + assert("cdemo8\000", cdemo8(a) == a) + assert("demo8\000", demo8(a) == a) +} + +type point9 struct { + x0 int64 + x1 int64 + x2 int64 + x3 int64 + x4 int64 + x5 int64 + x6 int64 + x7 int64 + x8 int64 +} + +//go:linkname cdemo9 C.demo9 +func cdemo9(a point9) point9 + +func demo9(a point9) point9 { + return a +} + +func init() { + a := point9{1, 2, 3, 4, 5, 6, 7, 8, 9} + assert("cdemo9\000", cdemo9(a) == a) + assert("demo9\000", demo9(a) == a) +} + +type point10 struct { + x0 int64 + x1 int64 + x2 int64 + x3 int64 + x4 int64 + x5 int64 + x6 int64 + x7 int64 + x8 int64 + x9 int64 +} + +//go:linkname cdemo10 C.demo10 +func cdemo10(a point10) point10 + +func demo10(a point10) point10 { + return a +} + +func init() { + a := point10{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} + assert("cdemo10\000", cdemo10(a) == a) + assert("demo10\000", demo10(a) == a) +} + +type point11 struct { + x0 int64 + x1 int64 + x2 int64 + x3 int64 + x4 int64 + x5 int64 + x6 int64 + x7 int64 + x8 int64 + x9 int64 + x10 int64 +} + +//go:linkname cdemo11 C.demo11 +func cdemo11(a point11) point11 + +func demo11(a point11) point11 { + return a +} + +func init() { + a := point11{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} + assert("cdemo11\000", cdemo11(a) == a) + assert("demo11\000", demo11(a) == a) +} + +type point12 struct { + x0 int64 + x1 int64 + x2 int64 + x3 int64 + x4 int64 + x5 int64 + x6 int64 + x7 int64 + x8 int64 + x9 int64 + x10 int64 + x11 int64 +} + +//go:linkname cdemo12 C.demo12 +func cdemo12(a point12) point12 + +func demo12(a point12) point12 { + return a +} + +func init() { + a := point12{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} + assert("cdemo12\000", cdemo12(a) == a) + assert("demo12\000", demo12(a) == a) +} + +type point13 struct { + x0 int64 + x1 int64 + x2 int64 + x3 int64 + x4 int64 + x5 int64 + x6 int64 + x7 int64 + x8 int64 + x9 int64 + x10 int64 + x11 int64 + x12 int64 +} + +//go:linkname cdemo13 C.demo13 +func cdemo13(a point13) point13 + +func demo13(a point13) point13 { + return a +} + +func init() { + a := point13{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13} + assert("cdemo13\000", cdemo13(a) == a) + assert("demo13\000", demo13(a) == a) +} + +type point14 struct { + x0 int64 + x1 int64 + x2 int64 + x3 int64 + x4 int64 + x5 int64 + x6 int64 + x7 int64 + x8 int64 + x9 int64 + x10 int64 + x11 int64 + x12 int64 + x13 int64 +} + +//go:linkname cdemo14 C.demo14 +func cdemo14(a point14) point14 + +func demo14(a point14) point14 { + return a +} + +func init() { + a := point14{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14} + assert("cdemo14\000", cdemo14(a) == a) + assert("demo14\000", demo14(a) == a) +} + +type point15 struct { + x0 int64 + x1 int64 + x2 int64 + x3 int64 + x4 int64 + x5 int64 + x6 int64 + x7 int64 + x8 int64 + x9 int64 + x10 int64 + x11 int64 + x12 int64 + x13 int64 + x14 int64 +} + +//go:linkname cdemo15 C.demo15 +func cdemo15(a point15) point15 + +func demo15(a point15) point15 { + return a +} + +func init() { + a := point15{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} + assert("cdemo15\000", cdemo15(a) == a) + assert("demo15\000", demo15(a) == a) +} + +type point16 struct { + x0 int64 + x1 int64 + x2 int64 + x3 int64 + x4 int64 + x5 int64 + x6 int64 + x7 int64 + x8 int64 + x9 int64 + x10 int64 + x11 int64 + x12 int64 + x13 int64 + x14 int64 + x15 int64 +} + +//go:linkname cdemo16 C.demo16 +func cdemo16(a point16) point16 + +func demo16(a point16) point16 { + return a +} + +func init() { + a := point16{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16} + assert("cdemo16\000", cdemo16(a) == a) + assert("demo16\000", demo16(a) == a) +} + +type point17 struct { + x0 int64 + x1 int64 + x2 int64 + x3 int64 + x4 int64 + x5 int64 + x6 int64 + x7 int64 + x8 int64 + x9 int64 + x10 int64 + x11 int64 + x12 int64 + x13 int64 + x14 int64 + x15 int64 + x16 int64 +} + +//go:linkname cdemo17 C.demo17 +func cdemo17(a point17) point17 + +func demo17(a point17) point17 { + return a +} + +func init() { + a := point17{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17} + assert("cdemo17\000", cdemo17(a) == a) + assert("demo17\000", demo17(a) == a) +} + +type point18 struct { + x0 int64 + x1 int64 + x2 int64 + x3 int64 + x4 int64 + x5 int64 + x6 int64 + x7 int64 + x8 int64 + x9 int64 + x10 int64 + x11 int64 + x12 int64 + x13 int64 + x14 int64 + x15 int64 + x16 int64 + x17 int64 +} + +//go:linkname cdemo18 C.demo18 +func cdemo18(a point18) point18 + +func demo18(a point18) point18 { + return a +} + +func init() { + a := point18{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18} + assert("cdemo18\000", cdemo18(a) == a) + assert("demo18\000", demo18(a) == a) +} + +type point19 struct { + x0 int64 + x1 int64 + x2 int64 + x3 int64 + x4 int64 + x5 int64 + x6 int64 + x7 int64 + x8 int64 + x9 int64 + x10 int64 + x11 int64 + x12 int64 + x13 int64 + x14 int64 + x15 int64 + x16 int64 + x17 int64 + x18 int64 +} + +//go:linkname cdemo19 C.demo19 +func cdemo19(a point19) point19 + +func demo19(a point19) point19 { + return a +} + +func init() { + a := point19{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19} + assert("cdemo19\000", cdemo19(a) == a) + assert("demo19\000", demo19(a) == a) +} + +type point20 struct { + x0 int64 + x1 int64 + x2 int64 + x3 int64 + x4 int64 + x5 int64 + x6 int64 + x7 int64 + x8 int64 + x9 int64 + x10 int64 + x11 int64 + x12 int64 + x13 int64 + x14 int64 + x15 int64 + x16 int64 + x17 int64 + x18 int64 + x19 int64 +} + +//go:linkname cdemo20 C.demo20 +func cdemo20(a point20) point20 + +func demo20(a point20) point20 { + return a +} + +func init() { + a := point20{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20} + assert("cdemo20\000", cdemo20(a) == a) + assert("demo20\000", demo20(a) == a) +} diff --git a/internal/cabi/_testdata/demo/struct_int8.go b/internal/cabi/_testdata/demo/struct_int8.go new file mode 100644 index 00000000..47ef72a5 --- /dev/null +++ b/internal/cabi/_testdata/demo/struct_int8.go @@ -0,0 +1,549 @@ +package main + +import "unsafe" + +const ( + LLGoFiles = "../wrap/struct_int8.c" +) + +//go:linkname printf C.printf +func printf(format *byte, __llgo_va_list ...any) int32 + +func assert(info string, b bool) { + if !b { + printf(unsafe.StringData("Assertion failed: %s\n\000"), unsafe.StringData(info)) + } +} + +func main() { +} + +type point1 struct { + x0 int8 +} + +//go:linkname cdemo1 C.demo1 +func cdemo1(a point1) point1 + +func demo1(a point1) point1 { + return a +} + +func init() { + a := point1{1} + assert("cdemo1\000", cdemo1(a) == a) + assert("demo1\000", demo1(a) == a) +} + +type point2 struct { + x0 int8 + x1 int8 +} + +//go:linkname cdemo2 C.demo2 +func cdemo2(a point2) point2 + +func demo2(a point2) point2 { + return a +} + +func init() { + a := point2{1, 2} + assert("cdemo2\000", cdemo2(a) == a) + assert("demo2\000", demo2(a) == a) +} + +type point3 struct { + x0 int8 + x1 int8 + x2 int8 +} + +//go:linkname cdemo3 C.demo3 +func cdemo3(a point3) point3 + +func demo3(a point3) point3 { + return a +} + +func init() { + a := point3{1, 2, 3} + assert("cdemo3\000", cdemo3(a) == a) + assert("demo3\000", demo3(a) == a) +} + +type point4 struct { + x0 int8 + x1 int8 + x2 int8 + x3 int8 +} + +//go:linkname cdemo4 C.demo4 +func cdemo4(a point4) point4 + +func demo4(a point4) point4 { + return a +} + +func init() { + a := point4{1, 2, 3, 4} + assert("cdemo4\000", cdemo4(a) == a) + assert("demo4\000", demo4(a) == a) +} + +type point5 struct { + x0 int8 + x1 int8 + x2 int8 + x3 int8 + x4 int8 +} + +//go:linkname cdemo5 C.demo5 +func cdemo5(a point5) point5 + +func demo5(a point5) point5 { + return a +} + +func init() { + a := point5{1, 2, 3, 4, 5} + assert("cdemo5\000", cdemo5(a) == a) + assert("demo5\000", demo5(a) == a) +} + +type point6 struct { + x0 int8 + x1 int8 + x2 int8 + x3 int8 + x4 int8 + x5 int8 +} + +//go:linkname cdemo6 C.demo6 +func cdemo6(a point6) point6 + +func demo6(a point6) point6 { + return a +} + +func init() { + a := point6{1, 2, 3, 4, 5, 6} + assert("cdemo6\000", cdemo6(a) == a) + assert("demo6\000", demo6(a) == a) +} + +type point7 struct { + x0 int8 + x1 int8 + x2 int8 + x3 int8 + x4 int8 + x5 int8 + x6 int8 +} + +//go:linkname cdemo7 C.demo7 +func cdemo7(a point7) point7 + +func demo7(a point7) point7 { + return a +} + +func init() { + a := point7{1, 2, 3, 4, 5, 6, 7} + assert("cdemo7\000", cdemo7(a) == a) + assert("demo7\000", demo7(a) == a) +} + +type point8 struct { + x0 int8 + x1 int8 + x2 int8 + x3 int8 + x4 int8 + x5 int8 + x6 int8 + x7 int8 +} + +//go:linkname cdemo8 C.demo8 +func cdemo8(a point8) point8 + +func demo8(a point8) point8 { + return a +} + +func init() { + a := point8{1, 2, 3, 4, 5, 6, 7, 8} + assert("cdemo8\000", cdemo8(a) == a) + assert("demo8\000", demo8(a) == a) +} + +type point9 struct { + x0 int8 + x1 int8 + x2 int8 + x3 int8 + x4 int8 + x5 int8 + x6 int8 + x7 int8 + x8 int8 +} + +//go:linkname cdemo9 C.demo9 +func cdemo9(a point9) point9 + +func demo9(a point9) point9 { + return a +} + +func init() { + a := point9{1, 2, 3, 4, 5, 6, 7, 8, 9} + assert("cdemo9\000", cdemo9(a) == a) + assert("demo9\000", demo9(a) == a) +} + +type point10 struct { + x0 int8 + x1 int8 + x2 int8 + x3 int8 + x4 int8 + x5 int8 + x6 int8 + x7 int8 + x8 int8 + x9 int8 +} + +//go:linkname cdemo10 C.demo10 +func cdemo10(a point10) point10 + +func demo10(a point10) point10 { + return a +} + +func init() { + a := point10{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} + assert("cdemo10\000", cdemo10(a) == a) + assert("demo10\000", demo10(a) == a) +} + +type point11 struct { + x0 int8 + x1 int8 + x2 int8 + x3 int8 + x4 int8 + x5 int8 + x6 int8 + x7 int8 + x8 int8 + x9 int8 + x10 int8 +} + +//go:linkname cdemo11 C.demo11 +func cdemo11(a point11) point11 + +func demo11(a point11) point11 { + return a +} + +func init() { + a := point11{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} + assert("cdemo11\000", cdemo11(a) == a) + assert("demo11\000", demo11(a) == a) +} + +type point12 struct { + x0 int8 + x1 int8 + x2 int8 + x3 int8 + x4 int8 + x5 int8 + x6 int8 + x7 int8 + x8 int8 + x9 int8 + x10 int8 + x11 int8 +} + +//go:linkname cdemo12 C.demo12 +func cdemo12(a point12) point12 + +func demo12(a point12) point12 { + return a +} + +func init() { + a := point12{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} + assert("cdemo12\000", cdemo12(a) == a) + assert("demo12\000", demo12(a) == a) +} + +type point13 struct { + x0 int8 + x1 int8 + x2 int8 + x3 int8 + x4 int8 + x5 int8 + x6 int8 + x7 int8 + x8 int8 + x9 int8 + x10 int8 + x11 int8 + x12 int8 +} + +//go:linkname cdemo13 C.demo13 +func cdemo13(a point13) point13 + +func demo13(a point13) point13 { + return a +} + +func init() { + a := point13{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13} + assert("cdemo13\000", cdemo13(a) == a) + assert("demo13\000", demo13(a) == a) +} + +type point14 struct { + x0 int8 + x1 int8 + x2 int8 + x3 int8 + x4 int8 + x5 int8 + x6 int8 + x7 int8 + x8 int8 + x9 int8 + x10 int8 + x11 int8 + x12 int8 + x13 int8 +} + +//go:linkname cdemo14 C.demo14 +func cdemo14(a point14) point14 + +func demo14(a point14) point14 { + return a +} + +func init() { + a := point14{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14} + assert("cdemo14\000", cdemo14(a) == a) + assert("demo14\000", demo14(a) == a) +} + +type point15 struct { + x0 int8 + x1 int8 + x2 int8 + x3 int8 + x4 int8 + x5 int8 + x6 int8 + x7 int8 + x8 int8 + x9 int8 + x10 int8 + x11 int8 + x12 int8 + x13 int8 + x14 int8 +} + +//go:linkname cdemo15 C.demo15 +func cdemo15(a point15) point15 + +func demo15(a point15) point15 { + return a +} + +func init() { + a := point15{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} + assert("cdemo15\000", cdemo15(a) == a) + assert("demo15\000", demo15(a) == a) +} + +type point16 struct { + x0 int8 + x1 int8 + x2 int8 + x3 int8 + x4 int8 + x5 int8 + x6 int8 + x7 int8 + x8 int8 + x9 int8 + x10 int8 + x11 int8 + x12 int8 + x13 int8 + x14 int8 + x15 int8 +} + +//go:linkname cdemo16 C.demo16 +func cdemo16(a point16) point16 + +func demo16(a point16) point16 { + return a +} + +func init() { + a := point16{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16} + assert("cdemo16\000", cdemo16(a) == a) + assert("demo16\000", demo16(a) == a) +} + +type point17 struct { + x0 int8 + x1 int8 + x2 int8 + x3 int8 + x4 int8 + x5 int8 + x6 int8 + x7 int8 + x8 int8 + x9 int8 + x10 int8 + x11 int8 + x12 int8 + x13 int8 + x14 int8 + x15 int8 + x16 int8 +} + +//go:linkname cdemo17 C.demo17 +func cdemo17(a point17) point17 + +func demo17(a point17) point17 { + return a +} + +func init() { + a := point17{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17} + assert("cdemo17\000", cdemo17(a) == a) + assert("demo17\000", demo17(a) == a) +} + +type point18 struct { + x0 int8 + x1 int8 + x2 int8 + x3 int8 + x4 int8 + x5 int8 + x6 int8 + x7 int8 + x8 int8 + x9 int8 + x10 int8 + x11 int8 + x12 int8 + x13 int8 + x14 int8 + x15 int8 + x16 int8 + x17 int8 +} + +//go:linkname cdemo18 C.demo18 +func cdemo18(a point18) point18 + +func demo18(a point18) point18 { + return a +} + +func init() { + a := point18{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18} + assert("cdemo18\000", cdemo18(a) == a) + assert("demo18\000", demo18(a) == a) +} + +type point19 struct { + x0 int8 + x1 int8 + x2 int8 + x3 int8 + x4 int8 + x5 int8 + x6 int8 + x7 int8 + x8 int8 + x9 int8 + x10 int8 + x11 int8 + x12 int8 + x13 int8 + x14 int8 + x15 int8 + x16 int8 + x17 int8 + x18 int8 +} + +//go:linkname cdemo19 C.demo19 +func cdemo19(a point19) point19 + +func demo19(a point19) point19 { + return a +} + +func init() { + a := point19{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19} + assert("cdemo19\000", cdemo19(a) == a) + assert("demo19\000", demo19(a) == a) +} + +type point20 struct { + x0 int8 + x1 int8 + x2 int8 + x3 int8 + x4 int8 + x5 int8 + x6 int8 + x7 int8 + x8 int8 + x9 int8 + x10 int8 + x11 int8 + x12 int8 + x13 int8 + x14 int8 + x15 int8 + x16 int8 + x17 int8 + x18 int8 + x19 int8 +} + +//go:linkname cdemo20 C.demo20 +func cdemo20(a point20) point20 + +func demo20(a point20) point20 { + return a +} + +func init() { + a := point20{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20} + assert("cdemo20\000", cdemo20(a) == a) + assert("demo20\000", demo20(a) == a) +} diff --git a/internal/cabi/_testdata/demo/struct_uintptr.go b/internal/cabi/_testdata/demo/struct_uintptr.go new file mode 100644 index 00000000..9ff375fb --- /dev/null +++ b/internal/cabi/_testdata/demo/struct_uintptr.go @@ -0,0 +1,549 @@ +package main + +import "unsafe" + +const ( + LLGoFiles = "../wrap/struct_uintptr.c" +) + +//go:linkname printf C.printf +func printf(format *byte, __llgo_va_list ...any) int32 + +func assert(info string, b bool) { + if !b { + printf(unsafe.StringData("Assertion failed: %s\n\000"), unsafe.StringData(info)) + } +} + +func main() { +} + +type point1 struct { + x0 uintptr +} + +//go:linkname cdemo1 C.demo1 +func cdemo1(a point1) point1 + +func demo1(a point1) point1 { + return a +} + +func init() { + a := point1{1} + assert("cdemo1\000", cdemo1(a) == a) + assert("demo1\000", demo1(a) == a) +} + +type point2 struct { + x0 uintptr + x1 uintptr +} + +//go:linkname cdemo2 C.demo2 +func cdemo2(a point2) point2 + +func demo2(a point2) point2 { + return a +} + +func init() { + a := point2{1, 2} + assert("cdemo2\000", cdemo2(a) == a) + assert("demo2\000", demo2(a) == a) +} + +type point3 struct { + x0 uintptr + x1 uintptr + x2 uintptr +} + +//go:linkname cdemo3 C.demo3 +func cdemo3(a point3) point3 + +func demo3(a point3) point3 { + return a +} + +func init() { + a := point3{1, 2, 3} + assert("cdemo3\000", cdemo3(a) == a) + assert("demo3\000", demo3(a) == a) +} + +type point4 struct { + x0 uintptr + x1 uintptr + x2 uintptr + x3 uintptr +} + +//go:linkname cdemo4 C.demo4 +func cdemo4(a point4) point4 + +func demo4(a point4) point4 { + return a +} + +func init() { + a := point4{1, 2, 3, 4} + assert("cdemo4\000", cdemo4(a) == a) + assert("demo4\000", demo4(a) == a) +} + +type point5 struct { + x0 uintptr + x1 uintptr + x2 uintptr + x3 uintptr + x4 uintptr +} + +//go:linkname cdemo5 C.demo5 +func cdemo5(a point5) point5 + +func demo5(a point5) point5 { + return a +} + +func init() { + a := point5{1, 2, 3, 4, 5} + assert("cdemo5\000", cdemo5(a) == a) + assert("demo5\000", demo5(a) == a) +} + +type point6 struct { + x0 uintptr + x1 uintptr + x2 uintptr + x3 uintptr + x4 uintptr + x5 uintptr +} + +//go:linkname cdemo6 C.demo6 +func cdemo6(a point6) point6 + +func demo6(a point6) point6 { + return a +} + +func init() { + a := point6{1, 2, 3, 4, 5, 6} + assert("cdemo6\000", cdemo6(a) == a) + assert("demo6\000", demo6(a) == a) +} + +type point7 struct { + x0 uintptr + x1 uintptr + x2 uintptr + x3 uintptr + x4 uintptr + x5 uintptr + x6 uintptr +} + +//go:linkname cdemo7 C.demo7 +func cdemo7(a point7) point7 + +func demo7(a point7) point7 { + return a +} + +func init() { + a := point7{1, 2, 3, 4, 5, 6, 7} + assert("cdemo7\000", cdemo7(a) == a) + assert("demo7\000", demo7(a) == a) +} + +type point8 struct { + x0 uintptr + x1 uintptr + x2 uintptr + x3 uintptr + x4 uintptr + x5 uintptr + x6 uintptr + x7 uintptr +} + +//go:linkname cdemo8 C.demo8 +func cdemo8(a point8) point8 + +func demo8(a point8) point8 { + return a +} + +func init() { + a := point8{1, 2, 3, 4, 5, 6, 7, 8} + assert("cdemo8\000", cdemo8(a) == a) + assert("demo8\000", demo8(a) == a) +} + +type point9 struct { + x0 uintptr + x1 uintptr + x2 uintptr + x3 uintptr + x4 uintptr + x5 uintptr + x6 uintptr + x7 uintptr + x8 uintptr +} + +//go:linkname cdemo9 C.demo9 +func cdemo9(a point9) point9 + +func demo9(a point9) point9 { + return a +} + +func init() { + a := point9{1, 2, 3, 4, 5, 6, 7, 8, 9} + assert("cdemo9\000", cdemo9(a) == a) + assert("demo9\000", demo9(a) == a) +} + +type point10 struct { + x0 uintptr + x1 uintptr + x2 uintptr + x3 uintptr + x4 uintptr + x5 uintptr + x6 uintptr + x7 uintptr + x8 uintptr + x9 uintptr +} + +//go:linkname cdemo10 C.demo10 +func cdemo10(a point10) point10 + +func demo10(a point10) point10 { + return a +} + +func init() { + a := point10{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} + assert("cdemo10\000", cdemo10(a) == a) + assert("demo10\000", demo10(a) == a) +} + +type point11 struct { + x0 uintptr + x1 uintptr + x2 uintptr + x3 uintptr + x4 uintptr + x5 uintptr + x6 uintptr + x7 uintptr + x8 uintptr + x9 uintptr + x10 uintptr +} + +//go:linkname cdemo11 C.demo11 +func cdemo11(a point11) point11 + +func demo11(a point11) point11 { + return a +} + +func init() { + a := point11{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} + assert("cdemo11\000", cdemo11(a) == a) + assert("demo11\000", demo11(a) == a) +} + +type point12 struct { + x0 uintptr + x1 uintptr + x2 uintptr + x3 uintptr + x4 uintptr + x5 uintptr + x6 uintptr + x7 uintptr + x8 uintptr + x9 uintptr + x10 uintptr + x11 uintptr +} + +//go:linkname cdemo12 C.demo12 +func cdemo12(a point12) point12 + +func demo12(a point12) point12 { + return a +} + +func init() { + a := point12{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} + assert("cdemo12\000", cdemo12(a) == a) + assert("demo12\000", demo12(a) == a) +} + +type point13 struct { + x0 uintptr + x1 uintptr + x2 uintptr + x3 uintptr + x4 uintptr + x5 uintptr + x6 uintptr + x7 uintptr + x8 uintptr + x9 uintptr + x10 uintptr + x11 uintptr + x12 uintptr +} + +//go:linkname cdemo13 C.demo13 +func cdemo13(a point13) point13 + +func demo13(a point13) point13 { + return a +} + +func init() { + a := point13{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13} + assert("cdemo13\000", cdemo13(a) == a) + assert("demo13\000", demo13(a) == a) +} + +type point14 struct { + x0 uintptr + x1 uintptr + x2 uintptr + x3 uintptr + x4 uintptr + x5 uintptr + x6 uintptr + x7 uintptr + x8 uintptr + x9 uintptr + x10 uintptr + x11 uintptr + x12 uintptr + x13 uintptr +} + +//go:linkname cdemo14 C.demo14 +func cdemo14(a point14) point14 + +func demo14(a point14) point14 { + return a +} + +func init() { + a := point14{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14} + assert("cdemo14\000", cdemo14(a) == a) + assert("demo14\000", demo14(a) == a) +} + +type point15 struct { + x0 uintptr + x1 uintptr + x2 uintptr + x3 uintptr + x4 uintptr + x5 uintptr + x6 uintptr + x7 uintptr + x8 uintptr + x9 uintptr + x10 uintptr + x11 uintptr + x12 uintptr + x13 uintptr + x14 uintptr +} + +//go:linkname cdemo15 C.demo15 +func cdemo15(a point15) point15 + +func demo15(a point15) point15 { + return a +} + +func init() { + a := point15{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} + assert("cdemo15\000", cdemo15(a) == a) + assert("demo15\000", demo15(a) == a) +} + +type point16 struct { + x0 uintptr + x1 uintptr + x2 uintptr + x3 uintptr + x4 uintptr + x5 uintptr + x6 uintptr + x7 uintptr + x8 uintptr + x9 uintptr + x10 uintptr + x11 uintptr + x12 uintptr + x13 uintptr + x14 uintptr + x15 uintptr +} + +//go:linkname cdemo16 C.demo16 +func cdemo16(a point16) point16 + +func demo16(a point16) point16 { + return a +} + +func init() { + a := point16{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16} + assert("cdemo16\000", cdemo16(a) == a) + assert("demo16\000", demo16(a) == a) +} + +type point17 struct { + x0 uintptr + x1 uintptr + x2 uintptr + x3 uintptr + x4 uintptr + x5 uintptr + x6 uintptr + x7 uintptr + x8 uintptr + x9 uintptr + x10 uintptr + x11 uintptr + x12 uintptr + x13 uintptr + x14 uintptr + x15 uintptr + x16 uintptr +} + +//go:linkname cdemo17 C.demo17 +func cdemo17(a point17) point17 + +func demo17(a point17) point17 { + return a +} + +func init() { + a := point17{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17} + assert("cdemo17\000", cdemo17(a) == a) + assert("demo17\000", demo17(a) == a) +} + +type point18 struct { + x0 uintptr + x1 uintptr + x2 uintptr + x3 uintptr + x4 uintptr + x5 uintptr + x6 uintptr + x7 uintptr + x8 uintptr + x9 uintptr + x10 uintptr + x11 uintptr + x12 uintptr + x13 uintptr + x14 uintptr + x15 uintptr + x16 uintptr + x17 uintptr +} + +//go:linkname cdemo18 C.demo18 +func cdemo18(a point18) point18 + +func demo18(a point18) point18 { + return a +} + +func init() { + a := point18{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18} + assert("cdemo18\000", cdemo18(a) == a) + assert("demo18\000", demo18(a) == a) +} + +type point19 struct { + x0 uintptr + x1 uintptr + x2 uintptr + x3 uintptr + x4 uintptr + x5 uintptr + x6 uintptr + x7 uintptr + x8 uintptr + x9 uintptr + x10 uintptr + x11 uintptr + x12 uintptr + x13 uintptr + x14 uintptr + x15 uintptr + x16 uintptr + x17 uintptr + x18 uintptr +} + +//go:linkname cdemo19 C.demo19 +func cdemo19(a point19) point19 + +func demo19(a point19) point19 { + return a +} + +func init() { + a := point19{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19} + assert("cdemo19\000", cdemo19(a) == a) + assert("demo19\000", demo19(a) == a) +} + +type point20 struct { + x0 uintptr + x1 uintptr + x2 uintptr + x3 uintptr + x4 uintptr + x5 uintptr + x6 uintptr + x7 uintptr + x8 uintptr + x9 uintptr + x10 uintptr + x11 uintptr + x12 uintptr + x13 uintptr + x14 uintptr + x15 uintptr + x16 uintptr + x17 uintptr + x18 uintptr + x19 uintptr +} + +//go:linkname cdemo20 C.demo20 +func cdemo20(a point20) point20 + +func demo20(a point20) point20 { + return a +} + +func init() { + a := point20{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20} + assert("cdemo20\000", cdemo20(a) == a) + assert("demo20\000", demo20(a) == a) +} diff --git a/internal/cabi/_testdata/make.go b/internal/cabi/_testdata/make.go new file mode 100644 index 00000000..0f63205c --- /dev/null +++ b/internal/cabi/_testdata/make.go @@ -0,0 +1,209 @@ +//go:build ignore +// +build ignore + +package main + +import ( + "bytes" + "os" + "path/filepath" + "strconv" + "strings" +) + +var ghead_basic = `package main + +import "unsafe" + +const ( + LLGoFiles = "../wrap/basic.c" +) + +//go:linkname printf C.printf +func printf(format *byte, __llgo_va_list ...any) int32 + +func assert(info string, b bool) { + if !b { + printf(unsafe.StringData("Assertion failed: %s\n\000"), unsafe.StringData(info)) + } +} + +func main() { +} +` + +var gbasic = ` +//go:linkname cbasic C.basic +func cbasic(a int) int + +func basic(a int) int { + return a +} + +func init() { + assert("cbasic\000", cbasic(100) == 100) + assert("basic\000", basic(100) == 100) +} +` + +var garray = ` +type array struct { + x [N]int +} + +//go:linkname cdemo C.demo +func cdemo(a array) array + +func demo(a array) array { + return a +} + +func init() { + a := array{x: [N]int{M}} + assert("cdemo\000", cdemo(a) == a) + assert("demo\000", demo(a) == a) +} +` + +var gstruct = ` +type point struct { + x int +} + +//go:linkname cdemo C.demo +func cdemo(a point) point + +func demo(a point) point { + return a +} + +func init() { + a := point{M} + assert("cdemo\000", cdemo(a) == a) + assert("demo\000", demo(a) == a) +} +` + +var cbasic = ` +int basic(int a) { + return a; +} +` + +var carray = ` +struct array { + int x[N]; +}; + +struct array demo(struct array a) { + return a; +} +` + +var cstruct = ` +struct point { + int x; +}; + +struct point demo(struct point a) { + return a; +} +` + +func main() { + // char + // short + // int + // int* + // float + // double + // 1 2 3 4 5 6 7 8 + + types := []string{"char", "short", "int", "long long", "float", "double", "void*"} + ids := []string{"int8", "int16", "int32", "int64", "float32", "float64", "uintptr"} + + // write cbasic + var cbuf bytes.Buffer + for nid, id := range ids { + data := strings.NewReplacer("int", types[nid], "basic", "basic_"+id).Replace(cbasic) + cbuf.WriteString(data) + } + os.WriteFile("./wrap/basic.c", cbuf.Bytes(), 0666) + // write basic + var buf bytes.Buffer + buf.WriteString(ghead_basic) + for _, id := range ids { + data := strings.NewReplacer("int", id, "basic", "basic_"+id).Replace(gbasic) + buf.WriteString(data) + } + os.WriteFile("./demo/basic.go", buf.Bytes(), 0666) + + for nid, id := range ids { + f := filepath.Join("./wrap/array_" + id + ".c") + var buf bytes.Buffer + for i := 0; i < 20; i++ { + N := strconv.Itoa(i + 1) + data := strings.NewReplacer("int", types[nid], "N", N, + "array", "array"+N, "demo", "demo"+N).Replace(carray) + buf.WriteString(data) + } + os.WriteFile(f, buf.Bytes(), 0666) + } + + // write struct + for nid, id := range ids { + f := filepath.Join("./wrap/struct_" + id + ".c") + var buf bytes.Buffer + for i := 0; i < 20; i++ { + N := strconv.Itoa(i + 1) + ar := make([]string, i+1) + for j := 0; j < i+1; j++ { + ar[j] = types[nid] + " x" + strconv.Itoa(j) + ";" + } + data := strings.NewReplacer("int x;", strings.Join(ar, "\n\t"), "N", N, + "point", "point"+N, "demo", "demo"+N).Replace(cstruct) + buf.WriteString(data) + } + os.WriteFile(f, buf.Bytes(), 0666) + } + + // write go demo array + for _, id := range ids { + f := filepath.Join("./demo/array_" + id + ".go") + var buf bytes.Buffer + buf.WriteString(strings.Replace(ghead_basic, "basic", "array_"+id, -1)) + for i := 0; i < 20; i++ { + N := strconv.Itoa(i + 1) + M := make([]string, i+1) + for j := 0; j < i+1; j++ { + M[j] = strconv.Itoa(j + 1) + } + data := strings.NewReplacer("int", id, "N", N, "M", strings.Join(M, ", "), + "array", "array"+N, "demo", "demo"+N).Replace(garray) + buf.WriteString(data) + } + os.WriteFile(f, buf.Bytes(), 0666) + } + + // write go demo struct + for _, id := range ids { + f := filepath.Join("./demo/struct_" + id + ".go") + var buf bytes.Buffer + buf.WriteString(strings.Replace(ghead_basic, "basic", "struct_"+id, -1)) + for i := 0; i < 20; i++ { + N := strconv.Itoa(i + 1) + M := make([]string, i+1) + for j := 0; j < i+1; j++ { + M[j] = strconv.Itoa(j + 1) + } + ar := make([]string, i+1) + for j := 0; j < i+1; j++ { + ar[j] = "x" + strconv.Itoa(j) + " " + id + } + data := strings.NewReplacer("x int", strings.Join(ar, "\n\t"), "N", N, "M", strings.Join(M, ", "), + "point", "point"+N, "demo", "demo"+N).Replace(gstruct) + buf.WriteString(data) + } + os.WriteFile(f, buf.Bytes(), 0666) + } +} diff --git a/internal/cabi/_testdata/wrap/array_float32.c b/internal/cabi/_testdata/wrap/array_float32.c new file mode 100644 index 00000000..8a656a90 --- /dev/null +++ b/internal/cabi/_testdata/wrap/array_float32.c @@ -0,0 +1,160 @@ + +struct array1 { + float x[1]; +}; + +struct array1 demo1(struct array1 a) { + return a; +} + +struct array2 { + float x[2]; +}; + +struct array2 demo2(struct array2 a) { + return a; +} + +struct array3 { + float x[3]; +}; + +struct array3 demo3(struct array3 a) { + return a; +} + +struct array4 { + float x[4]; +}; + +struct array4 demo4(struct array4 a) { + return a; +} + +struct array5 { + float x[5]; +}; + +struct array5 demo5(struct array5 a) { + return a; +} + +struct array6 { + float x[6]; +}; + +struct array6 demo6(struct array6 a) { + return a; +} + +struct array7 { + float x[7]; +}; + +struct array7 demo7(struct array7 a) { + return a; +} + +struct array8 { + float x[8]; +}; + +struct array8 demo8(struct array8 a) { + return a; +} + +struct array9 { + float x[9]; +}; + +struct array9 demo9(struct array9 a) { + return a; +} + +struct array10 { + float x[10]; +}; + +struct array10 demo10(struct array10 a) { + return a; +} + +struct array11 { + float x[11]; +}; + +struct array11 demo11(struct array11 a) { + return a; +} + +struct array12 { + float x[12]; +}; + +struct array12 demo12(struct array12 a) { + return a; +} + +struct array13 { + float x[13]; +}; + +struct array13 demo13(struct array13 a) { + return a; +} + +struct array14 { + float x[14]; +}; + +struct array14 demo14(struct array14 a) { + return a; +} + +struct array15 { + float x[15]; +}; + +struct array15 demo15(struct array15 a) { + return a; +} + +struct array16 { + float x[16]; +}; + +struct array16 demo16(struct array16 a) { + return a; +} + +struct array17 { + float x[17]; +}; + +struct array17 demo17(struct array17 a) { + return a; +} + +struct array18 { + float x[18]; +}; + +struct array18 demo18(struct array18 a) { + return a; +} + +struct array19 { + float x[19]; +}; + +struct array19 demo19(struct array19 a) { + return a; +} + +struct array20 { + float x[20]; +}; + +struct array20 demo20(struct array20 a) { + return a; +} diff --git a/internal/cabi/_testdata/wrap/array_float64.c b/internal/cabi/_testdata/wrap/array_float64.c new file mode 100644 index 00000000..76d99d2f --- /dev/null +++ b/internal/cabi/_testdata/wrap/array_float64.c @@ -0,0 +1,160 @@ + +struct array1 { + double x[1]; +}; + +struct array1 demo1(struct array1 a) { + return a; +} + +struct array2 { + double x[2]; +}; + +struct array2 demo2(struct array2 a) { + return a; +} + +struct array3 { + double x[3]; +}; + +struct array3 demo3(struct array3 a) { + return a; +} + +struct array4 { + double x[4]; +}; + +struct array4 demo4(struct array4 a) { + return a; +} + +struct array5 { + double x[5]; +}; + +struct array5 demo5(struct array5 a) { + return a; +} + +struct array6 { + double x[6]; +}; + +struct array6 demo6(struct array6 a) { + return a; +} + +struct array7 { + double x[7]; +}; + +struct array7 demo7(struct array7 a) { + return a; +} + +struct array8 { + double x[8]; +}; + +struct array8 demo8(struct array8 a) { + return a; +} + +struct array9 { + double x[9]; +}; + +struct array9 demo9(struct array9 a) { + return a; +} + +struct array10 { + double x[10]; +}; + +struct array10 demo10(struct array10 a) { + return a; +} + +struct array11 { + double x[11]; +}; + +struct array11 demo11(struct array11 a) { + return a; +} + +struct array12 { + double x[12]; +}; + +struct array12 demo12(struct array12 a) { + return a; +} + +struct array13 { + double x[13]; +}; + +struct array13 demo13(struct array13 a) { + return a; +} + +struct array14 { + double x[14]; +}; + +struct array14 demo14(struct array14 a) { + return a; +} + +struct array15 { + double x[15]; +}; + +struct array15 demo15(struct array15 a) { + return a; +} + +struct array16 { + double x[16]; +}; + +struct array16 demo16(struct array16 a) { + return a; +} + +struct array17 { + double x[17]; +}; + +struct array17 demo17(struct array17 a) { + return a; +} + +struct array18 { + double x[18]; +}; + +struct array18 demo18(struct array18 a) { + return a; +} + +struct array19 { + double x[19]; +}; + +struct array19 demo19(struct array19 a) { + return a; +} + +struct array20 { + double x[20]; +}; + +struct array20 demo20(struct array20 a) { + return a; +} diff --git a/internal/cabi/_testdata/wrap/array_int16.c b/internal/cabi/_testdata/wrap/array_int16.c new file mode 100644 index 00000000..e2de634d --- /dev/null +++ b/internal/cabi/_testdata/wrap/array_int16.c @@ -0,0 +1,160 @@ + +struct array1 { + short x[1]; +}; + +struct array1 demo1(struct array1 a) { + return a; +} + +struct array2 { + short x[2]; +}; + +struct array2 demo2(struct array2 a) { + return a; +} + +struct array3 { + short x[3]; +}; + +struct array3 demo3(struct array3 a) { + return a; +} + +struct array4 { + short x[4]; +}; + +struct array4 demo4(struct array4 a) { + return a; +} + +struct array5 { + short x[5]; +}; + +struct array5 demo5(struct array5 a) { + return a; +} + +struct array6 { + short x[6]; +}; + +struct array6 demo6(struct array6 a) { + return a; +} + +struct array7 { + short x[7]; +}; + +struct array7 demo7(struct array7 a) { + return a; +} + +struct array8 { + short x[8]; +}; + +struct array8 demo8(struct array8 a) { + return a; +} + +struct array9 { + short x[9]; +}; + +struct array9 demo9(struct array9 a) { + return a; +} + +struct array10 { + short x[10]; +}; + +struct array10 demo10(struct array10 a) { + return a; +} + +struct array11 { + short x[11]; +}; + +struct array11 demo11(struct array11 a) { + return a; +} + +struct array12 { + short x[12]; +}; + +struct array12 demo12(struct array12 a) { + return a; +} + +struct array13 { + short x[13]; +}; + +struct array13 demo13(struct array13 a) { + return a; +} + +struct array14 { + short x[14]; +}; + +struct array14 demo14(struct array14 a) { + return a; +} + +struct array15 { + short x[15]; +}; + +struct array15 demo15(struct array15 a) { + return a; +} + +struct array16 { + short x[16]; +}; + +struct array16 demo16(struct array16 a) { + return a; +} + +struct array17 { + short x[17]; +}; + +struct array17 demo17(struct array17 a) { + return a; +} + +struct array18 { + short x[18]; +}; + +struct array18 demo18(struct array18 a) { + return a; +} + +struct array19 { + short x[19]; +}; + +struct array19 demo19(struct array19 a) { + return a; +} + +struct array20 { + short x[20]; +}; + +struct array20 demo20(struct array20 a) { + return a; +} diff --git a/internal/cabi/_testdata/wrap/array_int32.c b/internal/cabi/_testdata/wrap/array_int32.c new file mode 100644 index 00000000..fb95725b --- /dev/null +++ b/internal/cabi/_testdata/wrap/array_int32.c @@ -0,0 +1,160 @@ + +struct array1 { + int x[1]; +}; + +struct array1 demo1(struct array1 a) { + return a; +} + +struct array2 { + int x[2]; +}; + +struct array2 demo2(struct array2 a) { + return a; +} + +struct array3 { + int x[3]; +}; + +struct array3 demo3(struct array3 a) { + return a; +} + +struct array4 { + int x[4]; +}; + +struct array4 demo4(struct array4 a) { + return a; +} + +struct array5 { + int x[5]; +}; + +struct array5 demo5(struct array5 a) { + return a; +} + +struct array6 { + int x[6]; +}; + +struct array6 demo6(struct array6 a) { + return a; +} + +struct array7 { + int x[7]; +}; + +struct array7 demo7(struct array7 a) { + return a; +} + +struct array8 { + int x[8]; +}; + +struct array8 demo8(struct array8 a) { + return a; +} + +struct array9 { + int x[9]; +}; + +struct array9 demo9(struct array9 a) { + return a; +} + +struct array10 { + int x[10]; +}; + +struct array10 demo10(struct array10 a) { + return a; +} + +struct array11 { + int x[11]; +}; + +struct array11 demo11(struct array11 a) { + return a; +} + +struct array12 { + int x[12]; +}; + +struct array12 demo12(struct array12 a) { + return a; +} + +struct array13 { + int x[13]; +}; + +struct array13 demo13(struct array13 a) { + return a; +} + +struct array14 { + int x[14]; +}; + +struct array14 demo14(struct array14 a) { + return a; +} + +struct array15 { + int x[15]; +}; + +struct array15 demo15(struct array15 a) { + return a; +} + +struct array16 { + int x[16]; +}; + +struct array16 demo16(struct array16 a) { + return a; +} + +struct array17 { + int x[17]; +}; + +struct array17 demo17(struct array17 a) { + return a; +} + +struct array18 { + int x[18]; +}; + +struct array18 demo18(struct array18 a) { + return a; +} + +struct array19 { + int x[19]; +}; + +struct array19 demo19(struct array19 a) { + return a; +} + +struct array20 { + int x[20]; +}; + +struct array20 demo20(struct array20 a) { + return a; +} diff --git a/internal/cabi/_testdata/wrap/array_int64.c b/internal/cabi/_testdata/wrap/array_int64.c new file mode 100644 index 00000000..b3d19305 --- /dev/null +++ b/internal/cabi/_testdata/wrap/array_int64.c @@ -0,0 +1,160 @@ + +struct array1 { + long long x[1]; +}; + +struct array1 demo1(struct array1 a) { + return a; +} + +struct array2 { + long long x[2]; +}; + +struct array2 demo2(struct array2 a) { + return a; +} + +struct array3 { + long long x[3]; +}; + +struct array3 demo3(struct array3 a) { + return a; +} + +struct array4 { + long long x[4]; +}; + +struct array4 demo4(struct array4 a) { + return a; +} + +struct array5 { + long long x[5]; +}; + +struct array5 demo5(struct array5 a) { + return a; +} + +struct array6 { + long long x[6]; +}; + +struct array6 demo6(struct array6 a) { + return a; +} + +struct array7 { + long long x[7]; +}; + +struct array7 demo7(struct array7 a) { + return a; +} + +struct array8 { + long long x[8]; +}; + +struct array8 demo8(struct array8 a) { + return a; +} + +struct array9 { + long long x[9]; +}; + +struct array9 demo9(struct array9 a) { + return a; +} + +struct array10 { + long long x[10]; +}; + +struct array10 demo10(struct array10 a) { + return a; +} + +struct array11 { + long long x[11]; +}; + +struct array11 demo11(struct array11 a) { + return a; +} + +struct array12 { + long long x[12]; +}; + +struct array12 demo12(struct array12 a) { + return a; +} + +struct array13 { + long long x[13]; +}; + +struct array13 demo13(struct array13 a) { + return a; +} + +struct array14 { + long long x[14]; +}; + +struct array14 demo14(struct array14 a) { + return a; +} + +struct array15 { + long long x[15]; +}; + +struct array15 demo15(struct array15 a) { + return a; +} + +struct array16 { + long long x[16]; +}; + +struct array16 demo16(struct array16 a) { + return a; +} + +struct array17 { + long long x[17]; +}; + +struct array17 demo17(struct array17 a) { + return a; +} + +struct array18 { + long long x[18]; +}; + +struct array18 demo18(struct array18 a) { + return a; +} + +struct array19 { + long long x[19]; +}; + +struct array19 demo19(struct array19 a) { + return a; +} + +struct array20 { + long long x[20]; +}; + +struct array20 demo20(struct array20 a) { + return a; +} diff --git a/internal/cabi/_testdata/wrap/array_int8.c b/internal/cabi/_testdata/wrap/array_int8.c new file mode 100644 index 00000000..317703dc --- /dev/null +++ b/internal/cabi/_testdata/wrap/array_int8.c @@ -0,0 +1,160 @@ + +struct array1 { + char x[1]; +}; + +struct array1 demo1(struct array1 a) { + return a; +} + +struct array2 { + char x[2]; +}; + +struct array2 demo2(struct array2 a) { + return a; +} + +struct array3 { + char x[3]; +}; + +struct array3 demo3(struct array3 a) { + return a; +} + +struct array4 { + char x[4]; +}; + +struct array4 demo4(struct array4 a) { + return a; +} + +struct array5 { + char x[5]; +}; + +struct array5 demo5(struct array5 a) { + return a; +} + +struct array6 { + char x[6]; +}; + +struct array6 demo6(struct array6 a) { + return a; +} + +struct array7 { + char x[7]; +}; + +struct array7 demo7(struct array7 a) { + return a; +} + +struct array8 { + char x[8]; +}; + +struct array8 demo8(struct array8 a) { + return a; +} + +struct array9 { + char x[9]; +}; + +struct array9 demo9(struct array9 a) { + return a; +} + +struct array10 { + char x[10]; +}; + +struct array10 demo10(struct array10 a) { + return a; +} + +struct array11 { + char x[11]; +}; + +struct array11 demo11(struct array11 a) { + return a; +} + +struct array12 { + char x[12]; +}; + +struct array12 demo12(struct array12 a) { + return a; +} + +struct array13 { + char x[13]; +}; + +struct array13 demo13(struct array13 a) { + return a; +} + +struct array14 { + char x[14]; +}; + +struct array14 demo14(struct array14 a) { + return a; +} + +struct array15 { + char x[15]; +}; + +struct array15 demo15(struct array15 a) { + return a; +} + +struct array16 { + char x[16]; +}; + +struct array16 demo16(struct array16 a) { + return a; +} + +struct array17 { + char x[17]; +}; + +struct array17 demo17(struct array17 a) { + return a; +} + +struct array18 { + char x[18]; +}; + +struct array18 demo18(struct array18 a) { + return a; +} + +struct array19 { + char x[19]; +}; + +struct array19 demo19(struct array19 a) { + return a; +} + +struct array20 { + char x[20]; +}; + +struct array20 demo20(struct array20 a) { + return a; +} diff --git a/internal/cabi/_testdata/wrap/array_pointer.c b/internal/cabi/_testdata/wrap/array_pointer.c new file mode 100644 index 00000000..5e915f62 --- /dev/null +++ b/internal/cabi/_testdata/wrap/array_pointer.c @@ -0,0 +1,160 @@ + +struct array1 { + void* x[1]; +}; + +struct array1 demo1(struct array1 a) { + return a; +} + +struct array2 { + void* x[2]; +}; + +struct array2 demo2(struct array2 a) { + return a; +} + +struct array3 { + void* x[3]; +}; + +struct array3 demo3(struct array3 a) { + return a; +} + +struct array4 { + void* x[4]; +}; + +struct array4 demo4(struct array4 a) { + return a; +} + +struct array5 { + void* x[5]; +}; + +struct array5 demo5(struct array5 a) { + return a; +} + +struct array6 { + void* x[6]; +}; + +struct array6 demo6(struct array6 a) { + return a; +} + +struct array7 { + void* x[7]; +}; + +struct array7 demo7(struct array7 a) { + return a; +} + +struct array8 { + void* x[8]; +}; + +struct array8 demo8(struct array8 a) { + return a; +} + +struct array9 { + void* x[9]; +}; + +struct array9 demo9(struct array9 a) { + return a; +} + +struct array10 { + void* x[10]; +}; + +struct array10 demo10(struct array10 a) { + return a; +} + +struct array11 { + void* x[11]; +}; + +struct array11 demo11(struct array11 a) { + return a; +} + +struct array12 { + void* x[12]; +}; + +struct array12 demo12(struct array12 a) { + return a; +} + +struct array13 { + void* x[13]; +}; + +struct array13 demo13(struct array13 a) { + return a; +} + +struct array14 { + void* x[14]; +}; + +struct array14 demo14(struct array14 a) { + return a; +} + +struct array15 { + void* x[15]; +}; + +struct array15 demo15(struct array15 a) { + return a; +} + +struct array16 { + void* x[16]; +}; + +struct array16 demo16(struct array16 a) { + return a; +} + +struct array17 { + void* x[17]; +}; + +struct array17 demo17(struct array17 a) { + return a; +} + +struct array18 { + void* x[18]; +}; + +struct array18 demo18(struct array18 a) { + return a; +} + +struct array19 { + void* x[19]; +}; + +struct array19 demo19(struct array19 a) { + return a; +} + +struct array20 { + void* x[20]; +}; + +struct array20 demo20(struct array20 a) { + return a; +} diff --git a/internal/cabi/_testdata/wrap/array_uintptr.c b/internal/cabi/_testdata/wrap/array_uintptr.c new file mode 100644 index 00000000..5e915f62 --- /dev/null +++ b/internal/cabi/_testdata/wrap/array_uintptr.c @@ -0,0 +1,160 @@ + +struct array1 { + void* x[1]; +}; + +struct array1 demo1(struct array1 a) { + return a; +} + +struct array2 { + void* x[2]; +}; + +struct array2 demo2(struct array2 a) { + return a; +} + +struct array3 { + void* x[3]; +}; + +struct array3 demo3(struct array3 a) { + return a; +} + +struct array4 { + void* x[4]; +}; + +struct array4 demo4(struct array4 a) { + return a; +} + +struct array5 { + void* x[5]; +}; + +struct array5 demo5(struct array5 a) { + return a; +} + +struct array6 { + void* x[6]; +}; + +struct array6 demo6(struct array6 a) { + return a; +} + +struct array7 { + void* x[7]; +}; + +struct array7 demo7(struct array7 a) { + return a; +} + +struct array8 { + void* x[8]; +}; + +struct array8 demo8(struct array8 a) { + return a; +} + +struct array9 { + void* x[9]; +}; + +struct array9 demo9(struct array9 a) { + return a; +} + +struct array10 { + void* x[10]; +}; + +struct array10 demo10(struct array10 a) { + return a; +} + +struct array11 { + void* x[11]; +}; + +struct array11 demo11(struct array11 a) { + return a; +} + +struct array12 { + void* x[12]; +}; + +struct array12 demo12(struct array12 a) { + return a; +} + +struct array13 { + void* x[13]; +}; + +struct array13 demo13(struct array13 a) { + return a; +} + +struct array14 { + void* x[14]; +}; + +struct array14 demo14(struct array14 a) { + return a; +} + +struct array15 { + void* x[15]; +}; + +struct array15 demo15(struct array15 a) { + return a; +} + +struct array16 { + void* x[16]; +}; + +struct array16 demo16(struct array16 a) { + return a; +} + +struct array17 { + void* x[17]; +}; + +struct array17 demo17(struct array17 a) { + return a; +} + +struct array18 { + void* x[18]; +}; + +struct array18 demo18(struct array18 a) { + return a; +} + +struct array19 { + void* x[19]; +}; + +struct array19 demo19(struct array19 a) { + return a; +} + +struct array20 { + void* x[20]; +}; + +struct array20 demo20(struct array20 a) { + return a; +} diff --git a/internal/cabi/_testdata/wrap/basic.c b/internal/cabi/_testdata/wrap/basic.c new file mode 100644 index 00000000..56781acd --- /dev/null +++ b/internal/cabi/_testdata/wrap/basic.c @@ -0,0 +1,28 @@ + +char basic_int8(char a) { + return a; +} + +short basic_int16(short a) { + return a; +} + +int basic_int32(int a) { + return a; +} + +long long basic_int64(long long a) { + return a; +} + +float basic_float32(float a) { + return a; +} + +double basic_float64(double a) { + return a; +} + +void* basic_uintptr(void* a) { + return a; +} diff --git a/internal/cabi/_testdata/wrap/demo.c b/internal/cabi/_testdata/wrap/demo.c new file mode 100644 index 00000000..b46eedc6 --- /dev/null +++ b/internal/cabi/_testdata/wrap/demo.c @@ -0,0 +1,8 @@ +typedef struct { + int x; + int y; +} st1; + +st1 fn1(st1 v) { + return v; +} \ No newline at end of file diff --git a/internal/cabi/_testdata/wrap/struct_float32.c b/internal/cabi/_testdata/wrap/struct_float32.c new file mode 100644 index 00000000..af1427d9 --- /dev/null +++ b/internal/cabi/_testdata/wrap/struct_float32.c @@ -0,0 +1,350 @@ + +struct point1 { + float x0; +}; + +struct point1 demo1(struct point1 a) { + return a; +} + +struct point2 { + float x0; + float x1; +}; + +struct point2 demo2(struct point2 a) { + return a; +} + +struct point3 { + float x0; + float x1; + float x2; +}; + +struct point3 demo3(struct point3 a) { + return a; +} + +struct point4 { + float x0; + float x1; + float x2; + float x3; +}; + +struct point4 demo4(struct point4 a) { + return a; +} + +struct point5 { + float x0; + float x1; + float x2; + float x3; + float x4; +}; + +struct point5 demo5(struct point5 a) { + return a; +} + +struct point6 { + float x0; + float x1; + float x2; + float x3; + float x4; + float x5; +}; + +struct point6 demo6(struct point6 a) { + return a; +} + +struct point7 { + float x0; + float x1; + float x2; + float x3; + float x4; + float x5; + float x6; +}; + +struct point7 demo7(struct point7 a) { + return a; +} + +struct point8 { + float x0; + float x1; + float x2; + float x3; + float x4; + float x5; + float x6; + float x7; +}; + +struct point8 demo8(struct point8 a) { + return a; +} + +struct point9 { + float x0; + float x1; + float x2; + float x3; + float x4; + float x5; + float x6; + float x7; + float x8; +}; + +struct point9 demo9(struct point9 a) { + return a; +} + +struct point10 { + float x0; + float x1; + float x2; + float x3; + float x4; + float x5; + float x6; + float x7; + float x8; + float x9; +}; + +struct point10 demo10(struct point10 a) { + return a; +} + +struct point11 { + float x0; + float x1; + float x2; + float x3; + float x4; + float x5; + float x6; + float x7; + float x8; + float x9; + float x10; +}; + +struct point11 demo11(struct point11 a) { + return a; +} + +struct point12 { + float x0; + float x1; + float x2; + float x3; + float x4; + float x5; + float x6; + float x7; + float x8; + float x9; + float x10; + float x11; +}; + +struct point12 demo12(struct point12 a) { + return a; +} + +struct point13 { + float x0; + float x1; + float x2; + float x3; + float x4; + float x5; + float x6; + float x7; + float x8; + float x9; + float x10; + float x11; + float x12; +}; + +struct point13 demo13(struct point13 a) { + return a; +} + +struct point14 { + float x0; + float x1; + float x2; + float x3; + float x4; + float x5; + float x6; + float x7; + float x8; + float x9; + float x10; + float x11; + float x12; + float x13; +}; + +struct point14 demo14(struct point14 a) { + return a; +} + +struct point15 { + float x0; + float x1; + float x2; + float x3; + float x4; + float x5; + float x6; + float x7; + float x8; + float x9; + float x10; + float x11; + float x12; + float x13; + float x14; +}; + +struct point15 demo15(struct point15 a) { + return a; +} + +struct point16 { + float x0; + float x1; + float x2; + float x3; + float x4; + float x5; + float x6; + float x7; + float x8; + float x9; + float x10; + float x11; + float x12; + float x13; + float x14; + float x15; +}; + +struct point16 demo16(struct point16 a) { + return a; +} + +struct point17 { + float x0; + float x1; + float x2; + float x3; + float x4; + float x5; + float x6; + float x7; + float x8; + float x9; + float x10; + float x11; + float x12; + float x13; + float x14; + float x15; + float x16; +}; + +struct point17 demo17(struct point17 a) { + return a; +} + +struct point18 { + float x0; + float x1; + float x2; + float x3; + float x4; + float x5; + float x6; + float x7; + float x8; + float x9; + float x10; + float x11; + float x12; + float x13; + float x14; + float x15; + float x16; + float x17; +}; + +struct point18 demo18(struct point18 a) { + return a; +} + +struct point19 { + float x0; + float x1; + float x2; + float x3; + float x4; + float x5; + float x6; + float x7; + float x8; + float x9; + float x10; + float x11; + float x12; + float x13; + float x14; + float x15; + float x16; + float x17; + float x18; +}; + +struct point19 demo19(struct point19 a) { + return a; +} + +struct point20 { + float x0; + float x1; + float x2; + float x3; + float x4; + float x5; + float x6; + float x7; + float x8; + float x9; + float x10; + float x11; + float x12; + float x13; + float x14; + float x15; + float x16; + float x17; + float x18; + float x19; +}; + +struct point20 demo20(struct point20 a) { + return a; +} diff --git a/internal/cabi/_testdata/wrap/struct_float64.c b/internal/cabi/_testdata/wrap/struct_float64.c new file mode 100644 index 00000000..bf5c9ae7 --- /dev/null +++ b/internal/cabi/_testdata/wrap/struct_float64.c @@ -0,0 +1,350 @@ + +struct point1 { + double x0; +}; + +struct point1 demo1(struct point1 a) { + return a; +} + +struct point2 { + double x0; + double x1; +}; + +struct point2 demo2(struct point2 a) { + return a; +} + +struct point3 { + double x0; + double x1; + double x2; +}; + +struct point3 demo3(struct point3 a) { + return a; +} + +struct point4 { + double x0; + double x1; + double x2; + double x3; +}; + +struct point4 demo4(struct point4 a) { + return a; +} + +struct point5 { + double x0; + double x1; + double x2; + double x3; + double x4; +}; + +struct point5 demo5(struct point5 a) { + return a; +} + +struct point6 { + double x0; + double x1; + double x2; + double x3; + double x4; + double x5; +}; + +struct point6 demo6(struct point6 a) { + return a; +} + +struct point7 { + double x0; + double x1; + double x2; + double x3; + double x4; + double x5; + double x6; +}; + +struct point7 demo7(struct point7 a) { + return a; +} + +struct point8 { + double x0; + double x1; + double x2; + double x3; + double x4; + double x5; + double x6; + double x7; +}; + +struct point8 demo8(struct point8 a) { + return a; +} + +struct point9 { + double x0; + double x1; + double x2; + double x3; + double x4; + double x5; + double x6; + double x7; + double x8; +}; + +struct point9 demo9(struct point9 a) { + return a; +} + +struct point10 { + double x0; + double x1; + double x2; + double x3; + double x4; + double x5; + double x6; + double x7; + double x8; + double x9; +}; + +struct point10 demo10(struct point10 a) { + return a; +} + +struct point11 { + double x0; + double x1; + double x2; + double x3; + double x4; + double x5; + double x6; + double x7; + double x8; + double x9; + double x10; +}; + +struct point11 demo11(struct point11 a) { + return a; +} + +struct point12 { + double x0; + double x1; + double x2; + double x3; + double x4; + double x5; + double x6; + double x7; + double x8; + double x9; + double x10; + double x11; +}; + +struct point12 demo12(struct point12 a) { + return a; +} + +struct point13 { + double x0; + double x1; + double x2; + double x3; + double x4; + double x5; + double x6; + double x7; + double x8; + double x9; + double x10; + double x11; + double x12; +}; + +struct point13 demo13(struct point13 a) { + return a; +} + +struct point14 { + double x0; + double x1; + double x2; + double x3; + double x4; + double x5; + double x6; + double x7; + double x8; + double x9; + double x10; + double x11; + double x12; + double x13; +}; + +struct point14 demo14(struct point14 a) { + return a; +} + +struct point15 { + double x0; + double x1; + double x2; + double x3; + double x4; + double x5; + double x6; + double x7; + double x8; + double x9; + double x10; + double x11; + double x12; + double x13; + double x14; +}; + +struct point15 demo15(struct point15 a) { + return a; +} + +struct point16 { + double x0; + double x1; + double x2; + double x3; + double x4; + double x5; + double x6; + double x7; + double x8; + double x9; + double x10; + double x11; + double x12; + double x13; + double x14; + double x15; +}; + +struct point16 demo16(struct point16 a) { + return a; +} + +struct point17 { + double x0; + double x1; + double x2; + double x3; + double x4; + double x5; + double x6; + double x7; + double x8; + double x9; + double x10; + double x11; + double x12; + double x13; + double x14; + double x15; + double x16; +}; + +struct point17 demo17(struct point17 a) { + return a; +} + +struct point18 { + double x0; + double x1; + double x2; + double x3; + double x4; + double x5; + double x6; + double x7; + double x8; + double x9; + double x10; + double x11; + double x12; + double x13; + double x14; + double x15; + double x16; + double x17; +}; + +struct point18 demo18(struct point18 a) { + return a; +} + +struct point19 { + double x0; + double x1; + double x2; + double x3; + double x4; + double x5; + double x6; + double x7; + double x8; + double x9; + double x10; + double x11; + double x12; + double x13; + double x14; + double x15; + double x16; + double x17; + double x18; +}; + +struct point19 demo19(struct point19 a) { + return a; +} + +struct point20 { + double x0; + double x1; + double x2; + double x3; + double x4; + double x5; + double x6; + double x7; + double x8; + double x9; + double x10; + double x11; + double x12; + double x13; + double x14; + double x15; + double x16; + double x17; + double x18; + double x19; +}; + +struct point20 demo20(struct point20 a) { + return a; +} diff --git a/internal/cabi/_testdata/wrap/struct_int16.c b/internal/cabi/_testdata/wrap/struct_int16.c new file mode 100644 index 00000000..3238405b --- /dev/null +++ b/internal/cabi/_testdata/wrap/struct_int16.c @@ -0,0 +1,350 @@ + +struct point1 { + short x0; +}; + +struct point1 demo1(struct point1 a) { + return a; +} + +struct point2 { + short x0; + short x1; +}; + +struct point2 demo2(struct point2 a) { + return a; +} + +struct point3 { + short x0; + short x1; + short x2; +}; + +struct point3 demo3(struct point3 a) { + return a; +} + +struct point4 { + short x0; + short x1; + short x2; + short x3; +}; + +struct point4 demo4(struct point4 a) { + return a; +} + +struct point5 { + short x0; + short x1; + short x2; + short x3; + short x4; +}; + +struct point5 demo5(struct point5 a) { + return a; +} + +struct point6 { + short x0; + short x1; + short x2; + short x3; + short x4; + short x5; +}; + +struct point6 demo6(struct point6 a) { + return a; +} + +struct point7 { + short x0; + short x1; + short x2; + short x3; + short x4; + short x5; + short x6; +}; + +struct point7 demo7(struct point7 a) { + return a; +} + +struct point8 { + short x0; + short x1; + short x2; + short x3; + short x4; + short x5; + short x6; + short x7; +}; + +struct point8 demo8(struct point8 a) { + return a; +} + +struct point9 { + short x0; + short x1; + short x2; + short x3; + short x4; + short x5; + short x6; + short x7; + short x8; +}; + +struct point9 demo9(struct point9 a) { + return a; +} + +struct point10 { + short x0; + short x1; + short x2; + short x3; + short x4; + short x5; + short x6; + short x7; + short x8; + short x9; +}; + +struct point10 demo10(struct point10 a) { + return a; +} + +struct point11 { + short x0; + short x1; + short x2; + short x3; + short x4; + short x5; + short x6; + short x7; + short x8; + short x9; + short x10; +}; + +struct point11 demo11(struct point11 a) { + return a; +} + +struct point12 { + short x0; + short x1; + short x2; + short x3; + short x4; + short x5; + short x6; + short x7; + short x8; + short x9; + short x10; + short x11; +}; + +struct point12 demo12(struct point12 a) { + return a; +} + +struct point13 { + short x0; + short x1; + short x2; + short x3; + short x4; + short x5; + short x6; + short x7; + short x8; + short x9; + short x10; + short x11; + short x12; +}; + +struct point13 demo13(struct point13 a) { + return a; +} + +struct point14 { + short x0; + short x1; + short x2; + short x3; + short x4; + short x5; + short x6; + short x7; + short x8; + short x9; + short x10; + short x11; + short x12; + short x13; +}; + +struct point14 demo14(struct point14 a) { + return a; +} + +struct point15 { + short x0; + short x1; + short x2; + short x3; + short x4; + short x5; + short x6; + short x7; + short x8; + short x9; + short x10; + short x11; + short x12; + short x13; + short x14; +}; + +struct point15 demo15(struct point15 a) { + return a; +} + +struct point16 { + short x0; + short x1; + short x2; + short x3; + short x4; + short x5; + short x6; + short x7; + short x8; + short x9; + short x10; + short x11; + short x12; + short x13; + short x14; + short x15; +}; + +struct point16 demo16(struct point16 a) { + return a; +} + +struct point17 { + short x0; + short x1; + short x2; + short x3; + short x4; + short x5; + short x6; + short x7; + short x8; + short x9; + short x10; + short x11; + short x12; + short x13; + short x14; + short x15; + short x16; +}; + +struct point17 demo17(struct point17 a) { + return a; +} + +struct point18 { + short x0; + short x1; + short x2; + short x3; + short x4; + short x5; + short x6; + short x7; + short x8; + short x9; + short x10; + short x11; + short x12; + short x13; + short x14; + short x15; + short x16; + short x17; +}; + +struct point18 demo18(struct point18 a) { + return a; +} + +struct point19 { + short x0; + short x1; + short x2; + short x3; + short x4; + short x5; + short x6; + short x7; + short x8; + short x9; + short x10; + short x11; + short x12; + short x13; + short x14; + short x15; + short x16; + short x17; + short x18; +}; + +struct point19 demo19(struct point19 a) { + return a; +} + +struct point20 { + short x0; + short x1; + short x2; + short x3; + short x4; + short x5; + short x6; + short x7; + short x8; + short x9; + short x10; + short x11; + short x12; + short x13; + short x14; + short x15; + short x16; + short x17; + short x18; + short x19; +}; + +struct point20 demo20(struct point20 a) { + return a; +} diff --git a/internal/cabi/_testdata/wrap/struct_int32.c b/internal/cabi/_testdata/wrap/struct_int32.c new file mode 100644 index 00000000..1c7c24b7 --- /dev/null +++ b/internal/cabi/_testdata/wrap/struct_int32.c @@ -0,0 +1,350 @@ + +struct point1 { + int x0; +}; + +struct point1 demo1(struct point1 a) { + return a; +} + +struct point2 { + int x0; + int x1; +}; + +struct point2 demo2(struct point2 a) { + return a; +} + +struct point3 { + int x0; + int x1; + int x2; +}; + +struct point3 demo3(struct point3 a) { + return a; +} + +struct point4 { + int x0; + int x1; + int x2; + int x3; +}; + +struct point4 demo4(struct point4 a) { + return a; +} + +struct point5 { + int x0; + int x1; + int x2; + int x3; + int x4; +}; + +struct point5 demo5(struct point5 a) { + return a; +} + +struct point6 { + int x0; + int x1; + int x2; + int x3; + int x4; + int x5; +}; + +struct point6 demo6(struct point6 a) { + return a; +} + +struct point7 { + int x0; + int x1; + int x2; + int x3; + int x4; + int x5; + int x6; +}; + +struct point7 demo7(struct point7 a) { + return a; +} + +struct point8 { + int x0; + int x1; + int x2; + int x3; + int x4; + int x5; + int x6; + int x7; +}; + +struct point8 demo8(struct point8 a) { + return a; +} + +struct point9 { + int x0; + int x1; + int x2; + int x3; + int x4; + int x5; + int x6; + int x7; + int x8; +}; + +struct point9 demo9(struct point9 a) { + return a; +} + +struct point10 { + int x0; + int x1; + int x2; + int x3; + int x4; + int x5; + int x6; + int x7; + int x8; + int x9; +}; + +struct point10 demo10(struct point10 a) { + return a; +} + +struct point11 { + int x0; + int x1; + int x2; + int x3; + int x4; + int x5; + int x6; + int x7; + int x8; + int x9; + int x10; +}; + +struct point11 demo11(struct point11 a) { + return a; +} + +struct point12 { + int x0; + int x1; + int x2; + int x3; + int x4; + int x5; + int x6; + int x7; + int x8; + int x9; + int x10; + int x11; +}; + +struct point12 demo12(struct point12 a) { + return a; +} + +struct point13 { + int x0; + int x1; + int x2; + int x3; + int x4; + int x5; + int x6; + int x7; + int x8; + int x9; + int x10; + int x11; + int x12; +}; + +struct point13 demo13(struct point13 a) { + return a; +} + +struct point14 { + int x0; + int x1; + int x2; + int x3; + int x4; + int x5; + int x6; + int x7; + int x8; + int x9; + int x10; + int x11; + int x12; + int x13; +}; + +struct point14 demo14(struct point14 a) { + return a; +} + +struct point15 { + int x0; + int x1; + int x2; + int x3; + int x4; + int x5; + int x6; + int x7; + int x8; + int x9; + int x10; + int x11; + int x12; + int x13; + int x14; +}; + +struct point15 demo15(struct point15 a) { + return a; +} + +struct point16 { + int x0; + int x1; + int x2; + int x3; + int x4; + int x5; + int x6; + int x7; + int x8; + int x9; + int x10; + int x11; + int x12; + int x13; + int x14; + int x15; +}; + +struct point16 demo16(struct point16 a) { + return a; +} + +struct point17 { + int x0; + int x1; + int x2; + int x3; + int x4; + int x5; + int x6; + int x7; + int x8; + int x9; + int x10; + int x11; + int x12; + int x13; + int x14; + int x15; + int x16; +}; + +struct point17 demo17(struct point17 a) { + return a; +} + +struct point18 { + int x0; + int x1; + int x2; + int x3; + int x4; + int x5; + int x6; + int x7; + int x8; + int x9; + int x10; + int x11; + int x12; + int x13; + int x14; + int x15; + int x16; + int x17; +}; + +struct point18 demo18(struct point18 a) { + return a; +} + +struct point19 { + int x0; + int x1; + int x2; + int x3; + int x4; + int x5; + int x6; + int x7; + int x8; + int x9; + int x10; + int x11; + int x12; + int x13; + int x14; + int x15; + int x16; + int x17; + int x18; +}; + +struct point19 demo19(struct point19 a) { + return a; +} + +struct point20 { + int x0; + int x1; + int x2; + int x3; + int x4; + int x5; + int x6; + int x7; + int x8; + int x9; + int x10; + int x11; + int x12; + int x13; + int x14; + int x15; + int x16; + int x17; + int x18; + int x19; +}; + +struct point20 demo20(struct point20 a) { + return a; +} diff --git a/internal/cabi/_testdata/wrap/struct_int64.c b/internal/cabi/_testdata/wrap/struct_int64.c new file mode 100644 index 00000000..1b2afc09 --- /dev/null +++ b/internal/cabi/_testdata/wrap/struct_int64.c @@ -0,0 +1,350 @@ + +struct point1 { + long long x0; +}; + +struct point1 demo1(struct point1 a) { + return a; +} + +struct point2 { + long long x0; + long long x1; +}; + +struct point2 demo2(struct point2 a) { + return a; +} + +struct point3 { + long long x0; + long long x1; + long long x2; +}; + +struct point3 demo3(struct point3 a) { + return a; +} + +struct point4 { + long long x0; + long long x1; + long long x2; + long long x3; +}; + +struct point4 demo4(struct point4 a) { + return a; +} + +struct point5 { + long long x0; + long long x1; + long long x2; + long long x3; + long long x4; +}; + +struct point5 demo5(struct point5 a) { + return a; +} + +struct point6 { + long long x0; + long long x1; + long long x2; + long long x3; + long long x4; + long long x5; +}; + +struct point6 demo6(struct point6 a) { + return a; +} + +struct point7 { + long long x0; + long long x1; + long long x2; + long long x3; + long long x4; + long long x5; + long long x6; +}; + +struct point7 demo7(struct point7 a) { + return a; +} + +struct point8 { + long long x0; + long long x1; + long long x2; + long long x3; + long long x4; + long long x5; + long long x6; + long long x7; +}; + +struct point8 demo8(struct point8 a) { + return a; +} + +struct point9 { + long long x0; + long long x1; + long long x2; + long long x3; + long long x4; + long long x5; + long long x6; + long long x7; + long long x8; +}; + +struct point9 demo9(struct point9 a) { + return a; +} + +struct point10 { + long long x0; + long long x1; + long long x2; + long long x3; + long long x4; + long long x5; + long long x6; + long long x7; + long long x8; + long long x9; +}; + +struct point10 demo10(struct point10 a) { + return a; +} + +struct point11 { + long long x0; + long long x1; + long long x2; + long long x3; + long long x4; + long long x5; + long long x6; + long long x7; + long long x8; + long long x9; + long long x10; +}; + +struct point11 demo11(struct point11 a) { + return a; +} + +struct point12 { + long long x0; + long long x1; + long long x2; + long long x3; + long long x4; + long long x5; + long long x6; + long long x7; + long long x8; + long long x9; + long long x10; + long long x11; +}; + +struct point12 demo12(struct point12 a) { + return a; +} + +struct point13 { + long long x0; + long long x1; + long long x2; + long long x3; + long long x4; + long long x5; + long long x6; + long long x7; + long long x8; + long long x9; + long long x10; + long long x11; + long long x12; +}; + +struct point13 demo13(struct point13 a) { + return a; +} + +struct point14 { + long long x0; + long long x1; + long long x2; + long long x3; + long long x4; + long long x5; + long long x6; + long long x7; + long long x8; + long long x9; + long long x10; + long long x11; + long long x12; + long long x13; +}; + +struct point14 demo14(struct point14 a) { + return a; +} + +struct point15 { + long long x0; + long long x1; + long long x2; + long long x3; + long long x4; + long long x5; + long long x6; + long long x7; + long long x8; + long long x9; + long long x10; + long long x11; + long long x12; + long long x13; + long long x14; +}; + +struct point15 demo15(struct point15 a) { + return a; +} + +struct point16 { + long long x0; + long long x1; + long long x2; + long long x3; + long long x4; + long long x5; + long long x6; + long long x7; + long long x8; + long long x9; + long long x10; + long long x11; + long long x12; + long long x13; + long long x14; + long long x15; +}; + +struct point16 demo16(struct point16 a) { + return a; +} + +struct point17 { + long long x0; + long long x1; + long long x2; + long long x3; + long long x4; + long long x5; + long long x6; + long long x7; + long long x8; + long long x9; + long long x10; + long long x11; + long long x12; + long long x13; + long long x14; + long long x15; + long long x16; +}; + +struct point17 demo17(struct point17 a) { + return a; +} + +struct point18 { + long long x0; + long long x1; + long long x2; + long long x3; + long long x4; + long long x5; + long long x6; + long long x7; + long long x8; + long long x9; + long long x10; + long long x11; + long long x12; + long long x13; + long long x14; + long long x15; + long long x16; + long long x17; +}; + +struct point18 demo18(struct point18 a) { + return a; +} + +struct point19 { + long long x0; + long long x1; + long long x2; + long long x3; + long long x4; + long long x5; + long long x6; + long long x7; + long long x8; + long long x9; + long long x10; + long long x11; + long long x12; + long long x13; + long long x14; + long long x15; + long long x16; + long long x17; + long long x18; +}; + +struct point19 demo19(struct point19 a) { + return a; +} + +struct point20 { + long long x0; + long long x1; + long long x2; + long long x3; + long long x4; + long long x5; + long long x6; + long long x7; + long long x8; + long long x9; + long long x10; + long long x11; + long long x12; + long long x13; + long long x14; + long long x15; + long long x16; + long long x17; + long long x18; + long long x19; +}; + +struct point20 demo20(struct point20 a) { + return a; +} diff --git a/internal/cabi/_testdata/wrap/struct_int8.c b/internal/cabi/_testdata/wrap/struct_int8.c new file mode 100644 index 00000000..51712131 --- /dev/null +++ b/internal/cabi/_testdata/wrap/struct_int8.c @@ -0,0 +1,350 @@ + +struct point1 { + char x0; +}; + +struct point1 demo1(struct point1 a) { + return a; +} + +struct point2 { + char x0; + char x1; +}; + +struct point2 demo2(struct point2 a) { + return a; +} + +struct point3 { + char x0; + char x1; + char x2; +}; + +struct point3 demo3(struct point3 a) { + return a; +} + +struct point4 { + char x0; + char x1; + char x2; + char x3; +}; + +struct point4 demo4(struct point4 a) { + return a; +} + +struct point5 { + char x0; + char x1; + char x2; + char x3; + char x4; +}; + +struct point5 demo5(struct point5 a) { + return a; +} + +struct point6 { + char x0; + char x1; + char x2; + char x3; + char x4; + char x5; +}; + +struct point6 demo6(struct point6 a) { + return a; +} + +struct point7 { + char x0; + char x1; + char x2; + char x3; + char x4; + char x5; + char x6; +}; + +struct point7 demo7(struct point7 a) { + return a; +} + +struct point8 { + char x0; + char x1; + char x2; + char x3; + char x4; + char x5; + char x6; + char x7; +}; + +struct point8 demo8(struct point8 a) { + return a; +} + +struct point9 { + char x0; + char x1; + char x2; + char x3; + char x4; + char x5; + char x6; + char x7; + char x8; +}; + +struct point9 demo9(struct point9 a) { + return a; +} + +struct point10 { + char x0; + char x1; + char x2; + char x3; + char x4; + char x5; + char x6; + char x7; + char x8; + char x9; +}; + +struct point10 demo10(struct point10 a) { + return a; +} + +struct point11 { + char x0; + char x1; + char x2; + char x3; + char x4; + char x5; + char x6; + char x7; + char x8; + char x9; + char x10; +}; + +struct point11 demo11(struct point11 a) { + return a; +} + +struct point12 { + char x0; + char x1; + char x2; + char x3; + char x4; + char x5; + char x6; + char x7; + char x8; + char x9; + char x10; + char x11; +}; + +struct point12 demo12(struct point12 a) { + return a; +} + +struct point13 { + char x0; + char x1; + char x2; + char x3; + char x4; + char x5; + char x6; + char x7; + char x8; + char x9; + char x10; + char x11; + char x12; +}; + +struct point13 demo13(struct point13 a) { + return a; +} + +struct point14 { + char x0; + char x1; + char x2; + char x3; + char x4; + char x5; + char x6; + char x7; + char x8; + char x9; + char x10; + char x11; + char x12; + char x13; +}; + +struct point14 demo14(struct point14 a) { + return a; +} + +struct point15 { + char x0; + char x1; + char x2; + char x3; + char x4; + char x5; + char x6; + char x7; + char x8; + char x9; + char x10; + char x11; + char x12; + char x13; + char x14; +}; + +struct point15 demo15(struct point15 a) { + return a; +} + +struct point16 { + char x0; + char x1; + char x2; + char x3; + char x4; + char x5; + char x6; + char x7; + char x8; + char x9; + char x10; + char x11; + char x12; + char x13; + char x14; + char x15; +}; + +struct point16 demo16(struct point16 a) { + return a; +} + +struct point17 { + char x0; + char x1; + char x2; + char x3; + char x4; + char x5; + char x6; + char x7; + char x8; + char x9; + char x10; + char x11; + char x12; + char x13; + char x14; + char x15; + char x16; +}; + +struct point17 demo17(struct point17 a) { + return a; +} + +struct point18 { + char x0; + char x1; + char x2; + char x3; + char x4; + char x5; + char x6; + char x7; + char x8; + char x9; + char x10; + char x11; + char x12; + char x13; + char x14; + char x15; + char x16; + char x17; +}; + +struct point18 demo18(struct point18 a) { + return a; +} + +struct point19 { + char x0; + char x1; + char x2; + char x3; + char x4; + char x5; + char x6; + char x7; + char x8; + char x9; + char x10; + char x11; + char x12; + char x13; + char x14; + char x15; + char x16; + char x17; + char x18; +}; + +struct point19 demo19(struct point19 a) { + return a; +} + +struct point20 { + char x0; + char x1; + char x2; + char x3; + char x4; + char x5; + char x6; + char x7; + char x8; + char x9; + char x10; + char x11; + char x12; + char x13; + char x14; + char x15; + char x16; + char x17; + char x18; + char x19; +}; + +struct point20 demo20(struct point20 a) { + return a; +} diff --git a/internal/cabi/_testdata/wrap/struct_uintptr.c b/internal/cabi/_testdata/wrap/struct_uintptr.c new file mode 100644 index 00000000..ab8e3ded --- /dev/null +++ b/internal/cabi/_testdata/wrap/struct_uintptr.c @@ -0,0 +1,350 @@ + +struct point1 { + void* x0; +}; + +struct point1 demo1(struct point1 a) { + return a; +} + +struct point2 { + void* x0; + void* x1; +}; + +struct point2 demo2(struct point2 a) { + return a; +} + +struct point3 { + void* x0; + void* x1; + void* x2; +}; + +struct point3 demo3(struct point3 a) { + return a; +} + +struct point4 { + void* x0; + void* x1; + void* x2; + void* x3; +}; + +struct point4 demo4(struct point4 a) { + return a; +} + +struct point5 { + void* x0; + void* x1; + void* x2; + void* x3; + void* x4; +}; + +struct point5 demo5(struct point5 a) { + return a; +} + +struct point6 { + void* x0; + void* x1; + void* x2; + void* x3; + void* x4; + void* x5; +}; + +struct point6 demo6(struct point6 a) { + return a; +} + +struct point7 { + void* x0; + void* x1; + void* x2; + void* x3; + void* x4; + void* x5; + void* x6; +}; + +struct point7 demo7(struct point7 a) { + return a; +} + +struct point8 { + void* x0; + void* x1; + void* x2; + void* x3; + void* x4; + void* x5; + void* x6; + void* x7; +}; + +struct point8 demo8(struct point8 a) { + return a; +} + +struct point9 { + void* x0; + void* x1; + void* x2; + void* x3; + void* x4; + void* x5; + void* x6; + void* x7; + void* x8; +}; + +struct point9 demo9(struct point9 a) { + return a; +} + +struct point10 { + void* x0; + void* x1; + void* x2; + void* x3; + void* x4; + void* x5; + void* x6; + void* x7; + void* x8; + void* x9; +}; + +struct point10 demo10(struct point10 a) { + return a; +} + +struct point11 { + void* x0; + void* x1; + void* x2; + void* x3; + void* x4; + void* x5; + void* x6; + void* x7; + void* x8; + void* x9; + void* x10; +}; + +struct point11 demo11(struct point11 a) { + return a; +} + +struct point12 { + void* x0; + void* x1; + void* x2; + void* x3; + void* x4; + void* x5; + void* x6; + void* x7; + void* x8; + void* x9; + void* x10; + void* x11; +}; + +struct point12 demo12(struct point12 a) { + return a; +} + +struct point13 { + void* x0; + void* x1; + void* x2; + void* x3; + void* x4; + void* x5; + void* x6; + void* x7; + void* x8; + void* x9; + void* x10; + void* x11; + void* x12; +}; + +struct point13 demo13(struct point13 a) { + return a; +} + +struct point14 { + void* x0; + void* x1; + void* x2; + void* x3; + void* x4; + void* x5; + void* x6; + void* x7; + void* x8; + void* x9; + void* x10; + void* x11; + void* x12; + void* x13; +}; + +struct point14 demo14(struct point14 a) { + return a; +} + +struct point15 { + void* x0; + void* x1; + void* x2; + void* x3; + void* x4; + void* x5; + void* x6; + void* x7; + void* x8; + void* x9; + void* x10; + void* x11; + void* x12; + void* x13; + void* x14; +}; + +struct point15 demo15(struct point15 a) { + return a; +} + +struct point16 { + void* x0; + void* x1; + void* x2; + void* x3; + void* x4; + void* x5; + void* x6; + void* x7; + void* x8; + void* x9; + void* x10; + void* x11; + void* x12; + void* x13; + void* x14; + void* x15; +}; + +struct point16 demo16(struct point16 a) { + return a; +} + +struct point17 { + void* x0; + void* x1; + void* x2; + void* x3; + void* x4; + void* x5; + void* x6; + void* x7; + void* x8; + void* x9; + void* x10; + void* x11; + void* x12; + void* x13; + void* x14; + void* x15; + void* x16; +}; + +struct point17 demo17(struct point17 a) { + return a; +} + +struct point18 { + void* x0; + void* x1; + void* x2; + void* x3; + void* x4; + void* x5; + void* x6; + void* x7; + void* x8; + void* x9; + void* x10; + void* x11; + void* x12; + void* x13; + void* x14; + void* x15; + void* x16; + void* x17; +}; + +struct point18 demo18(struct point18 a) { + return a; +} + +struct point19 { + void* x0; + void* x1; + void* x2; + void* x3; + void* x4; + void* x5; + void* x6; + void* x7; + void* x8; + void* x9; + void* x10; + void* x11; + void* x12; + void* x13; + void* x14; + void* x15; + void* x16; + void* x17; + void* x18; +}; + +struct point19 demo19(struct point19 a) { + return a; +} + +struct point20 { + void* x0; + void* x1; + void* x2; + void* x3; + void* x4; + void* x5; + void* x6; + void* x7; + void* x8; + void* x9; + void* x10; + void* x11; + void* x12; + void* x13; + void* x14; + void* x15; + void* x16; + void* x17; + void* x18; + void* x19; +}; + +struct point20 demo20(struct point20 a) { + return a; +} diff --git a/internal/cabi/arch.go b/internal/cabi/arch.go index c8d0d913..7e0b4733 100644 --- a/internal/cabi/arch.go +++ b/internal/cabi/arch.go @@ -272,19 +272,19 @@ func (p *TypeInfoArm) GetTypeInfo(ctx llvm.Context, typ llvm.Type, bret bool) *T return info } -type TypeInfo32 struct { +type TypeInfoWasm struct { *Transformer } -func (p *TypeInfo32) SupportByVal() bool { +func (p *TypeInfoWasm) SupportByVal() bool { return true } -func (p *TypeInfo32) IsWrapType(ctx llvm.Context, typ llvm.Type, bret bool) bool { +func (p *TypeInfoWasm) IsWrapType(ctx llvm.Context, typ llvm.Type, bret bool) bool { return elementTypesCount(typ) >= 2 } -func (p *TypeInfo32) GetTypeInfo(ctx llvm.Context, typ llvm.Type, bret bool) *TypeInfo { +func (p *TypeInfoWasm) GetTypeInfo(ctx llvm.Context, typ llvm.Type, bret bool) *TypeInfo { info := &TypeInfo{} info.Type = typ info.Type1 = typ diff --git a/internal/cabi/cabi.go b/internal/cabi/cabi.go index e741012f..b0691e08 100644 --- a/internal/cabi/cabi.go +++ b/internal/cabi/cabi.go @@ -31,8 +31,8 @@ func NewTransformer(prog ssa.Program, mode Mode) *Transformer { tr.sys = &TypeInfoArm64{tr} case "arm": tr.sys = &TypeInfoArm{tr} - case "wasm", "i386": - tr.sys = &TypeInfo32{tr} + case "wasm": + tr.sys = &TypeInfoWasm{tr} case "riscv64": tr.sys = &TypeInfoRiscv64{tr} } diff --git a/internal/cabi/cabi_test.go b/internal/cabi/cabi_test.go new file mode 100644 index 00000000..c28f5fa5 --- /dev/null +++ b/internal/cabi/cabi_test.go @@ -0,0 +1,186 @@ +//go:build !llgo +// +build !llgo + +package cabi_test + +import ( + "os" + "path/filepath" + "strings" + "testing" + + "github.com/goplus/llvm" + + "github.com/goplus/llgo/internal/build" + "github.com/goplus/llgo/internal/cabi" +) + +var ( + modes = []cabi.Mode{cabi.ModeNone, cabi.ModeCFunc, cabi.ModeAllFunc} + archs = []string{"amd64", "arm64", "riscv64", "arm"} + archDir = []string{"amd64", "arm64", "riscv64", "armv6"} +) + +func TestBuild(t *testing.T) { + for _, mode := range modes { + for _, arch := range archs { + conf := build.NewDefaultConf(build.ModeGen) + conf.AbiMode = mode + conf.Goarch = arch + conf.Goos = "linux" + _, err := build.Do([]string{"./_testdata/demo/main.go"}, conf) + if err != nil { + t.Fatalf("build error: %v-%v %v", arch, mode, err) + } + } + } +} + +func TestABI(t *testing.T) { + dirs, err := os.ReadDir("./_testdata/demo") + if err != nil { + t.Fatal(err) + } + var files []string + for _, f := range dirs { + if !f.IsDir() && strings.HasSuffix(f.Name(), ".go") { + files = append(files, f.Name()) + } + } + for i, arch := range archs { + t.Run(arch, func(t *testing.T) { + t.Parallel() + testArch(t, arch, archDir[i], files) + }) + } +} + +func testArch(t *testing.T, arch string, archDir string, files []string) { + conf := build.NewDefaultConf(build.ModeGen) + conf.AbiMode = cabi.ModeAllFunc + conf.Goarch = arch + conf.Goos = "linux" + for _, file := range files { + pkgs, err := build.Do([]string{filepath.Join("./_testdata/demo", file)}, conf) + if err != nil { + t.Fatalf("build error: %v %v", arch, err) + } + ctx := llvm.NewContext() + llfile := filepath.Join("./_testdata/arch", archDir, file[:len(file)-3]+".ll") + buf, err := llvm.NewMemoryBufferFromFile(llfile) + if err != nil { + t.Fatalf("bad file: %v %v", llfile, err) + } + m, err := ctx.ParseIR(buf) + if err != nil { + t.Fatalf("parser IR error %v", arch) + } + pkg := pkgs[0].LPkg + testModule(t, context{arch: arch, file: file}, pkg.Prog.TargetData(), pkg.Module(), m) + } +} + +type context struct { + arch string + file string +} + +func testModule(t *testing.T, ctx context, td llvm.TargetData, m llvm.Module, c llvm.Module) { + var fns []llvm.Value + fn := c.FirstFunction() + for !fn.IsNil() { + if !fn.IsDeclaration() { + fns = append(fns, fn) + } + fn = llvm.NextFunction(fn) + } + for _, fn := range fns { + testFunc(t, ctx, td, m.NamedFunction(fn.Name()), fn) + } +} + +func testFunc(t *testing.T, ctx context, td llvm.TargetData, fn llvm.Value, cfn llvm.Value) { + ft := fn.GlobalValueType() + cft := cfn.GlobalValueType() + pts := ft.ParamTypes() + cpts := cft.ParamTypes() + if len(pts) != len(cpts) { + t.Fatalf("%v %v: bad param types count %v != %v", ctx, fn.Name(), len(pts), len(cpts)) + } + for i, pt := range pts { + if !checkType(td, pt, cpts[i]) { + t.Fatalf("%v %v: bad param type %v != %v", ctx, fn.Name(), pt, cpts[i]) + } + if i == 0 { + if fn.GetStringAttributeAtIndex(1, "sret") != cfn.GetStringAttributeAtIndex(1, "sret") { + t.Fatalf("%v %v: bad sret attr", ctx, fn.Name()) + } + } + if fn.GetStringAttributeAtIndex(1, "byval") != cfn.GetStringAttributeAtIndex(1, "byval") { + t.Fatalf("%v %v: bad byval attr %v", ctx, fn.Name(), i) + } + } + if !checkType(td, ft.ReturnType(), cft.ReturnType()) { + t.Fatalf("%v %v: bad return type %v != %v", ctx, fn.Name(), ft.ReturnType(), cft.ReturnType()) + } +} + +func checkType(td llvm.TargetData, ft llvm.Type, cft llvm.Type) bool { + if ft == cft { + return true + } + if ft.TypeKind() == llvm.VoidTypeKind && cft.TypeKind() == llvm.VoidTypeKind { + return true + } else if ft.TypeKind() == llvm.VoidTypeKind || cft.TypeKind() == llvm.VoidTypeKind { + return false + } + if td.ABITypeAlignment(ft) != td.ABITypeAlignment(cft) { + return false + } + if td.TypeAllocSize(ft) != td.TypeAllocSize(cft) { + return false + } + et := elementTypes(td, ft) + cet := elementTypes(td, cft) + if len(et) != len(cet) { + return false + } + if len(et) == 1 { + return true + } + for i, t := range et { + if !checkType(td, t, cet[i]) { + return false + } + } + return true +} + +func elementTypes(td llvm.TargetData, typ llvm.Type) (types []llvm.Type) { + switch typ.TypeKind() { + case llvm.VoidTypeKind: + case llvm.StructTypeKind: + for _, t := range typ.StructElementTypes() { + types = append(types, elementTypes(td, t)...) + } + case llvm.ArrayTypeKind: + sub := elementTypes(td, typ.ElementType()) + n := typ.ArrayLength() + for i := 0; i < n; i++ { + types = append(types, sub...) + } + default: + types = append(types, typ) + } + return +} + +func byvalAttribute(ctx llvm.Context, typ llvm.Type) llvm.Attribute { + id := llvm.AttributeKindID("byval") + return ctx.CreateTypeAttribute(id, typ) +} + +func sretAttribute(ctx llvm.Context, typ llvm.Type) llvm.Attribute { + id := llvm.AttributeKindID("sret") + return ctx.CreateTypeAttribute(id, typ) +}