-
-
Notifications
You must be signed in to change notification settings - Fork 15.6k
update bpf abi to match Clang 23 #161076
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
update bpf abi to match Clang 23 #161076
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // Checks that results larger than one register are returned indirectly | ||
| //@ add-minicore | ||
| //@ revisions: bpfel bpfeb | ||
| //@[bpfel] compile-flags: --target=bpfel-unknown-none | ||
| //@[bpfeb] compile-flags: --target=bpfeb-unknown-none | ||
| //@ needs-llvm-components: bpf | ||
| //@ compile-flags: -Copt-level=3 | ||
| #![crate_type = "lib"] | ||
| #![feature(no_core)] | ||
| #![no_core] | ||
|
|
||
| extern crate minicore; | ||
|
|
||
| struct Big { | ||
| a: [u16; 32], | ||
| b: u64, | ||
| } | ||
|
|
||
| // CHECK-LABEL: define{{.*}} @inner_big_rust( | ||
| // CHECK-SAME: ptr{{[^,]*}}, | ||
| // CHECK-SAME: i64{{[^)]*}} | ||
| #[unsafe(no_mangle)] | ||
| fn inner_big_rust(a: u64) -> Big { | ||
| Big { a: [a as u16; 32], b: 42 } | ||
| } | ||
|
|
||
| // CHECK-LABEL: define{{.*}} @inner_big_c( | ||
| // CHECK-SAME: ptr{{[^,]*}}, | ||
| // CHECK-SAME: i64{{[^)]*}} | ||
| #[unsafe(no_mangle)] | ||
| extern "C" fn inner_big_c(a: u64) -> Big { | ||
| Big { a: [a as u16; 32], b: 42 } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| //@ add-minicore | ||
| //@ revisions: bpfel bpfeb | ||
| //@[bpfel] compile-flags: --target=bpfel-unknown-none | ||
| //@[bpfeb] compile-flags: --target=bpfeb-unknown-none | ||
| //@ needs-llvm-components: bpf | ||
| //@ compile-flags: -Copt-level=3 -Cno-prepopulate-passes | ||
| //@ min-llvm-version: 23 | ||
| #![feature(no_core)] | ||
| #![no_core] | ||
| #![crate_type = "lib"] | ||
|
|
||
| extern crate minicore; | ||
| use minicore::*; | ||
|
|
||
| #[repr(C)] | ||
| struct Foo0 { | ||
| a: i8, | ||
| } | ||
|
|
||
| #[repr(C)] | ||
| struct Foo1 { | ||
| a: i32, | ||
| } | ||
|
|
||
| #[repr(C)] | ||
| struct Foo2 { | ||
| a: i32, | ||
| b: i64, | ||
| } | ||
|
|
||
| #[repr(C)] | ||
| struct Foo3 { | ||
| a: i32, | ||
| b: i32, | ||
| c: i64, | ||
| } | ||
|
|
||
| impl Copy for Foo0 {} | ||
| impl Copy for Foo1 {} | ||
| impl Copy for Foo2 {} | ||
| impl Copy for Foo3 {} | ||
|
|
||
| // CHECK-LABEL: define{{.*}} i8 @bar0( | ||
| // CHECK: ret i8 | ||
| #[no_mangle] | ||
| extern "C" fn bar0(a: i8) -> Foo0 { | ||
| Foo0 { a } | ||
| } | ||
|
|
||
| // CHECK-LABEL: define{{.*}} i32 @bar1( | ||
| // CHECK: ret i32 | ||
| #[no_mangle] | ||
| extern "C" fn bar1(a: i32) -> Foo1 { | ||
| Foo1 { a } | ||
| } | ||
|
|
||
| // CHECK-LABEL: define{{.*}} [2 x i64] @bar2( | ||
| // CHECK: ret [2 x i64] | ||
| #[no_mangle] | ||
| extern "C" fn bar2(a: i32, b: i32) -> Foo2 { | ||
| Foo2 { a, b: b as i64 } | ||
| } | ||
|
|
||
| // CHECK-LABEL: define{{.*}} [2 x i64] @bar3( | ||
| // CHECK: ret [2 x i64] | ||
| #[no_mangle] | ||
| extern "C" fn bar3(a: i32, b: i32, c: i32) -> Foo3 { | ||
| Foo3 { a, b, c: c as i64 } | ||
| } | ||
|
|
||
| // CHECK-LABEL: define{{.*}} i8 @check0( | ||
| // CHECK: %[[C1:.*]] = call i8 @bar0( | ||
| // CHECK: store i8 %[[C1]] | ||
| #[no_mangle] | ||
| extern "C" fn check0(a: i8) -> i8 { | ||
| let v = bar0(a); | ||
| v.a | ||
| } | ||
|
|
||
| // CHECK-LABEL: define{{.*}} i32 @check1( | ||
| // CHECK: %[[C1:.*]] = call i32 @bar1( | ||
| // CHECK: store i32 %[[C1]] | ||
| #[no_mangle] | ||
| extern "C" fn check1(a: i32) -> i32 { | ||
| let v = bar1(a); | ||
| v.a | ||
| } | ||
|
|
||
| // CHECK-LABEL: define{{.*}} i32 @check2( | ||
| // CHECK: %[[C2:.*]] = call [2 x i64] @bar2( | ||
| // CHECK: store [2 x i64] %[[C2]] | ||
| #[no_mangle] | ||
| extern "C" fn check2(a: i32, b: i32) -> i32 { | ||
| let v = bar2(a, b); | ||
| hint::black_box(v); | ||
| v.a | ||
| } | ||
|
|
||
| // CHECK-LABEL: define{{.*}} i32 @check3( | ||
| // CHECK: %[[C3:.*]] = call [2 x i64] @bar3( | ||
| // CHECK: store [2 x i64] %[[C3]] | ||
| #[no_mangle] | ||
| extern "C" fn check3(a: i32, b: i32, c: i32) -> i32 { | ||
| let v = bar3(a, b, c); | ||
| hint::black_box(v); | ||
| v.a | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| //@ add-minicore | ||
| //@ revisions: bpfel bpfeb | ||
| //@[bpfel] compile-flags: --target=bpfel-unknown-none | ||
| //@[bpfeb] compile-flags: --target=bpfeb-unknown-none | ||
| //@ needs-llvm-components: bpf | ||
| //@ compile-flags: -Copt-level=3 -Cno-prepopulate-passes | ||
| //@ min-llvm-version: 23 | ||
| #![feature(no_core)] | ||
| #![no_core] | ||
| #![crate_type = "lib"] | ||
|
|
||
| extern crate minicore; | ||
| use minicore::*; | ||
|
|
||
| #[repr(C)] | ||
| struct T1 {} | ||
|
|
||
| #[repr(C)] | ||
| struct T2 { | ||
| a: i32, | ||
| } | ||
| impl Copy for T2 {} | ||
|
|
||
| #[repr(C)] | ||
| struct T3 { | ||
| a: i32, | ||
| b: i64, | ||
| } | ||
|
|
||
| #[repr(C)] | ||
| struct T4 { | ||
| a: i64, | ||
| b: i64, | ||
| c: i64, | ||
| } | ||
|
|
||
| #[repr(C)] | ||
| struct T5 { | ||
| a: i8, | ||
| } | ||
|
|
||
| #[repr(C)] | ||
| union U1 { | ||
| a: i32, | ||
| b: i64, | ||
| } | ||
|
|
||
| // CHECK: define{{.*}} void @foo1() | ||
| #[no_mangle] | ||
| extern "C" fn foo1() -> T1 { | ||
| T1 {} | ||
| } | ||
|
|
||
| // CHECK: define{{.*}} i32 @foo2() | ||
| #[no_mangle] | ||
| extern "C" fn foo2() -> T2 { | ||
| T2 { a: 0 } | ||
| } | ||
|
|
||
| // CHECK: define{{.*}} [2 x i64] @foo3() | ||
| #[no_mangle] | ||
| extern "C" fn foo3() -> T3 { | ||
| T3 { a: 0, b: 0 } | ||
| } | ||
|
|
||
| // CHECK: define{{.*}} void @foo4(ptr{{.*}}sret([24 x i8]){{.*}}align 8 | ||
| #[no_mangle] | ||
| extern "C" fn foo4() -> T4 { | ||
| T4 { a: 0, b: 0, c: 0 } | ||
| } | ||
|
|
||
| // CHECK: define{{.*}} i8 @foo5() | ||
| #[no_mangle] | ||
| extern "C" fn foo5() -> T5 { | ||
| T5 { a: 0 } | ||
| } | ||
|
|
||
| // CHECK: define{{.*}} i64 @foou() | ||
| #[no_mangle] | ||
| extern "C" fn foou() -> U1 { | ||
| U1 { b: 0 } | ||
| } | ||
|
|
||
| // CHECK-LABEL: define{{.*}} i32 @bar() | ||
| // CHECK: %[[C2:.*]] = call i32 @foo2() | ||
| // CHECK: store i32 %[[C2]] | ||
| // CHECK: %[[C3:.*]] = call [2 x i64] @foo3() | ||
| // CHECK: store [2 x i64] %[[C3]] | ||
| #[no_mangle] | ||
| extern "C" fn bar() -> i32 { | ||
| let a = foo2(); | ||
| let b = foo3(); | ||
| hint::black_box((a, b)); | ||
| a.a | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for BE this is a bit surprising to me, in many targets this would instead pass an
i32ori64on BE so that the 8 actual bits are in the right spot. But, this is consistent with clanghttps://godbolt.org/z/PvMj78bWs