diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2025-01-31 12:28:17 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-31 12:28:17 +0100 |
| commit | 12a7f06e3c9207fd6b7b66fd51b995bb879514bc (patch) | |
| tree | 903f8711a95fc274e637902f0e5f7f8b87f771ed /tests/codegen | |
| parent | f818842ce2454ce9eea3df49cf6a822a2364a2f0 (diff) | |
| parent | e586382febf7d03ac330595dcf578184fccbd971 (diff) | |
| download | rust-12a7f06e3c9207fd6b7b66fd51b995bb879514bc.tar.gz rust-12a7f06e3c9207fd6b7b66fd51b995bb879514bc.zip | |
Rollup merge of #136194 - taiki-e:bpf-clobber-abi, r=amanieu
Support clobber_abi in BPF inline assembly This supports [`clobber_abi`](https://doc.rust-lang.org/nightly/reference/inline-assembly.html#abi-clobbers) which is one of the requirements of stabilization mentioned in the tracking Issue for `asm_experimental_arch` (#93335). Refs: [Section 1.1 "Registers and calling convention" in BPF ABI Recommended Conventions and Guidelines v1.0](https://github.com/torvalds/linux/blob/v6.13/Documentation/bpf/standardization/abi.rst#11registers-and-calling-convention) > R0 - R5 are scratch registers and BPF programs needs to spill/fill them if necessary across calls. cc `@alessandrod` `@dave-tucker` `@tamird` `@vadorovsky` (target maintainers mentioned in platform support document which will be added by https://github.com/rust-lang/rust/pull/135107) r? `@Amanieu` `@rustbot` label +O-eBPF +A-inline-assembly
Diffstat (limited to 'tests/codegen')
| -rw-r--r-- | tests/codegen/asm/bpf-clobbers.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/codegen/asm/bpf-clobbers.rs b/tests/codegen/asm/bpf-clobbers.rs new file mode 100644 index 00000000000..1117549b1ec --- /dev/null +++ b/tests/codegen/asm/bpf-clobbers.rs @@ -0,0 +1,31 @@ +//@ add-core-stubs +//@ compile-flags: --target bpfel-unknown-none +//@ needs-llvm-components: bpf + +#![crate_type = "rlib"] +#![feature(no_core, asm_experimental_arch)] +#![no_core] + +extern crate minicore; +use minicore::*; + +// CHECK-LABEL: @flags_clobber +// CHECK: call void asm sideeffect "", ""() +#[no_mangle] +pub unsafe fn flags_clobber() { + asm!("", options(nostack, nomem)); +} + +// CHECK-LABEL: @no_clobber +// CHECK: call void asm sideeffect "", ""() +#[no_mangle] +pub unsafe fn no_clobber() { + asm!("", options(nostack, nomem, preserves_flags)); +} + +// CHECK-LABEL: @clobber_abi +// CHECK: asm sideeffect "", "={r0},={r1},={r2},={r3},={r4},={r5}"() +#[no_mangle] +pub unsafe fn clobber_abi() { + asm!("", clobber_abi("C"), options(nostack, nomem, preserves_flags)); +} |
