Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion internal/cabi/_testdata/arch/amd64/empty.ll
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ target triple = "amd64-unknown-linux-gnu"
%struct.empty = type {}

; Function Attrs: noinline nounwind optnone uwtable
define dso_local void @demo1() #0 {
define dso_local void @demo0() #0 {
%1 = alloca %struct.empty, align 1
%2 = alloca %struct.empty, align 1
%3 = bitcast %struct.empty* %1 to i8*
Expand All @@ -18,6 +18,18 @@ define dso_local void @demo1() #0 {
; 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 void @demo1(i32 noundef %0) #0 {
%2 = alloca %struct.empty, align 1
%3 = alloca %struct.empty, align 1
%4 = alloca i32, align 4
store i32 %0, i32* %4, align 4
%5 = bitcast %struct.empty* %2 to i8*
%6 = bitcast %struct.empty* %3 to i8*
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %5, i8* align 1 %6, i64 0, i1 false)
ret void
}

; Function Attrs: noinline nounwind optnone uwtable
define dso_local i32 @demo2(i32 noundef %0) #0 {
%2 = alloca %struct.empty, align 1
Expand Down
14 changes: 13 additions & 1 deletion internal/cabi/_testdata/arch/arm64/empty.ll
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ target triple = "aarch64-unknown-linux-gnu"
%struct.empty = type {}

; Function Attrs: noinline nounwind optnone uwtable
define dso_local void @demo1() #0 {
define dso_local void @demo0() #0 {
%1 = alloca %struct.empty, align 1
%2 = alloca %struct.empty, align 1
%3 = bitcast %struct.empty* %1 to i8*
Expand All @@ -18,6 +18,18 @@ define dso_local void @demo1() #0 {
; 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 void @demo1(i32 noundef %0) #0 {
%2 = alloca %struct.empty, align 1
%3 = alloca %struct.empty, align 1
%4 = alloca i32, align 4
store i32 %0, i32* %4, align 4
%5 = bitcast %struct.empty* %2 to i8*
%6 = bitcast %struct.empty* %3 to i8*
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %5, i8* align 1 %6, i64 0, i1 false)
ret void
}

; Function Attrs: noinline nounwind optnone uwtable
define dso_local i32 @demo2(i32 noundef %0) #0 {
%2 = alloca %struct.empty, align 1
Expand Down
14 changes: 13 additions & 1 deletion internal/cabi/_testdata/arch/armv6/empty.ll
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ target triple = "armv6kz-unknown-linux-gnueabihf"
%struct.empty = type {}

; Function Attrs: noinline nounwind optnone
define dso_local void @demo1() #0 {
define dso_local void @demo0() #0 {
%1 = alloca %struct.empty, align 1
%2 = alloca %struct.empty, align 1
%3 = bitcast %struct.empty* %1 to i8*
Expand All @@ -18,6 +18,18 @@ define dso_local void @demo1() #0 {
; 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 @demo1(i32 noundef %0) #0 {
%2 = alloca %struct.empty, align 1
%3 = alloca %struct.empty, align 1
%4 = alloca i32, align 4
store i32 %0, i32* %4, align 4
%5 = bitcast %struct.empty* %2 to i8*
%6 = bitcast %struct.empty* %3 to i8*
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 1 %6, i32 0, i1 false)
ret void
}

; Function Attrs: noinline nounwind optnone
define dso_local i32 @demo2(i32 noundef %0) #0 {
%2 = alloca %struct.empty, align 1
Expand Down
16 changes: 15 additions & 1 deletion internal/cabi/_testdata/arch/i386/empty.ll
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ target triple = "i386-unknown-linux-gnu"
%struct.empty = type {}

; Function Attrs: noinline nounwind optnone uwtable
define dso_local void @demo1(%struct.empty* noalias sret(%struct.empty) align 1 %0) #0 {
define dso_local void @demo0(%struct.empty* noalias sret(%struct.empty) align 1 %0) #0 {
%2 = alloca i8*, align 4
%3 = alloca %struct.empty, align 1
%4 = bitcast %struct.empty* %0 to i8*
Expand All @@ -20,6 +20,20 @@ define dso_local void @demo1(%struct.empty* noalias sret(%struct.empty) align 1
; 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 @demo1(%struct.empty* noalias sret(%struct.empty) align 1 %0, i32 noundef %1) #0 {
%3 = alloca i8*, align 4
%4 = alloca %struct.empty, align 1
%5 = alloca i32, align 4
%6 = bitcast %struct.empty* %0 to i8*
store i8* %6, i8** %3, align 4
store i32 %1, i32* %5, align 4
%7 = bitcast %struct.empty* %0 to i8*
%8 = bitcast %struct.empty* %4 to i8*
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %7, i8* align 1 %8, i32 0, i1 false)
ret void
}

; Function Attrs: noinline nounwind optnone uwtable
define dso_local i32 @demo2(i32 noundef %0) #0 {
%2 = alloca %struct.empty, align 1
Expand Down
14 changes: 13 additions & 1 deletion internal/cabi/_testdata/arch/riscv64/empty.ll
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ target triple = "riscv64-unknown-unknown-elf"
%struct.empty = type {}

; Function Attrs: noinline nounwind optnone
define dso_local void @demo1() #0 {
define dso_local void @demo0() #0 {
%1 = alloca %struct.empty, align 1
%2 = alloca %struct.empty, align 1
%3 = bitcast %struct.empty* %1 to i8*
Expand All @@ -18,6 +18,18 @@ define dso_local void @demo1() #0 {
; 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 void @demo1(i32 noundef signext %0) #0 {
%2 = alloca %struct.empty, align 1
%3 = alloca %struct.empty, align 1
%4 = alloca i32, align 4
store i32 %0, i32* %4, align 4
%5 = bitcast %struct.empty* %2 to i8*
%6 = bitcast %struct.empty* %3 to i8*
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %5, i8* align 1 %6, i64 0, i1 false)
ret void
}

; Function Attrs: noinline nounwind optnone
define dso_local signext i32 @demo2(i32 noundef signext %0) #0 {
%2 = alloca %struct.empty, align 1
Expand Down
14 changes: 13 additions & 1 deletion internal/cabi/_testdata/arch/wasm32/empty.ll
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ target triple = "wasm32-unknown-emscripten"
%struct.empty = type {}

; Function Attrs: noinline nounwind optnone
define hidden void @demo1() #0 {
define hidden void @demo0() #0 {
%1 = alloca %struct.empty, align 1
%2 = alloca %struct.empty, align 1
%3 = bitcast %struct.empty* %1 to i8*
Expand All @@ -18,6 +18,18 @@ define hidden void @demo1() #0 {
; 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 @demo1(i32 noundef %0) #0 {
%2 = alloca %struct.empty, align 1
%3 = alloca %struct.empty, align 1
%4 = alloca i32, align 4
store i32 %0, i32* %4, align 4
%5 = bitcast %struct.empty* %2 to i8*
%6 = bitcast %struct.empty* %3 to i8*
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %5, i8* align 1 %6, i32 0, i1 false)
ret void
}

; Function Attrs: noinline nounwind optnone
define hidden i32 @demo2(i32 noundef %0) #0 {
%2 = alloca %struct.empty, align 1
Expand Down
20 changes: 16 additions & 4 deletions internal/cabi/_testdata/demo/empty.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,28 @@ func main() {}
type empty struct {
}

//go:linkname cdemo0 C.demo0
func cdemo0(empty) empty

func demo0(a empty) empty {
return a
}

func init() {
assert("cdemo0", cdemo0(empty{}) == empty{})
assert("demo0", demo0(empty{}) == empty{})
}

//go:linkname cdemo1 C.demo1
func cdemo1(empty) empty
func cdemo1(empty, int32) empty

func demo1(a empty) empty {
func demo1(a empty, b int32) empty {
return a
}

func init() {
assert("cdemo1", cdemo1(empty{}) == empty{})
assert("demo1", demo1(empty{}) == empty{})
assert("cdemo1", cdemo1(empty{}, 1) == empty{})
assert("demo1", demo1(empty{}, 2) == empty{})
}

//go:linkname cdemo2 C.demo2
Expand Down
6 changes: 5 additions & 1 deletion internal/cabi/_testdata/wrap/empty.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
struct empty {
};

struct empty demo1(struct empty a) {
struct empty demo0(struct empty a) {
return a;
}

struct empty demo1(struct empty a, int v) {
return a;
}

Expand Down
Loading
Loading