rust/tests/assembly-llvm/x86_64-indirect-branch-cs-prefix.rs
Miguel Ojeda 1a29d9c23f Add -Zindirect-branch-cs-prefix option
This is intended to be used for Linux kernel RETPOLINE builds.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2025-08-17 16:51:42 +02:00

28 lines
877 B
Rust

// Test that the `cs` prefix is (not) added into a `call` and a `jmp` to the
// indirect thunk when the `-Zindirect-branch-cs-prefix` flag is (not) set.
//@ revisions: unset set
//@ assembly-output: emit-asm
//@ compile-flags: -Copt-level=3 -Cunsafe-allow-abi-mismatch=retpoline,retpoline-external-thunk,indirect-branch-cs-prefix -Zretpoline-external-thunk
//@ [set] compile-flags: -Zindirect-branch-cs-prefix
//@ only-x86_64
//@ ignore-apple Symbol is called `___x86_indirect_thunk` (Darwin's extra underscore)
#![crate_type = "lib"]
// CHECK-LABEL: foo:
#[no_mangle]
pub fn foo(g: fn()) {
// unset-NOT: cs
// unset: callq {{__x86_indirect_thunk.*}}
// set: cs
// set-NEXT: callq {{__x86_indirect_thunk.*}}
g();
// unset-NOT: cs
// unset: jmp {{__x86_indirect_thunk.*}}
// set: cs
// set-NEXT: jmp {{__x86_indirect_thunk.*}}
g();
}