rust/tests/codegen/frame-pointer.rs
Jubilee Young 0c157b51d3 aarch64-linux: Default to FramePointer::NonLeaf
For aarch64-apple and aarch64-windows, platform docs state that code
must use frame pointers correctly. This is because the AAPCS64 mandates
that a platform specify its frame pointer conformance requirements:
- Apple: https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms#Respect-the-purpose-of-specific-CPU-registers
- Windows: https://learn.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=msvc-170#integer-registers
- AAPCS64: 4492d1570e/aapcs64/aapcs64.rst (the-frame-pointer)

Unwinding code either requires unwind tables or frame pointers, and
on aarch64 the expectation is that one can use frame pointers for this.
Most Linux targets represent a motley variety of possible distributions,
so it is unclear who to defer to on conformance, other than perhaps Arm.
In the absence of a specific edict for a given aarch64-linux target,
Rust will assume aarch64-linux targets use non-leaf frame pointers.
This reflects what compilers like clang do.
2025-05-17 06:42:46 +02:00

36 lines
1.2 KiB
Rust

//@ add-core-stubs
//@ compile-flags: --crate-type=rlib -Copt-level=0
//@ revisions: aarch64-apple aarch64-linux force x64-apple x64-linux
//@ [aarch64-apple] needs-llvm-components: aarch64
//@ [aarch64-apple] compile-flags: --target=aarch64-apple-darwin
//@ [aarch64-linux] needs-llvm-components: aarch64
//@ [aarch64-linux] compile-flags: --target=aarch64-unknown-linux-gnu
//@ [force] needs-llvm-components: x86
//@ [force] compile-flags: --target=x86_64-unknown-linux-gnu -Cforce-frame-pointers=yes
//@ [x64-apple] needs-llvm-components: x86
//@ [x64-apple] compile-flags: --target=x86_64-apple-darwin
//@ [x64-linux] needs-llvm-components: x86
//@ [x64-linux] compile-flags: --target=x86_64-unknown-linux-gnu
#![feature(no_core, lang_items)]
#![no_core]
extern crate minicore;
use minicore::*;
// CHECK: define i32 @peach{{.*}}[[PEACH_ATTRS:\#[0-9]+]] {
#[no_mangle]
pub fn peach(x: u32) -> u32 {
x
}
// CHECK: attributes [[PEACH_ATTRS]] = {
// x64-linux-NOT: {{.*}}"frame-pointer"{{.*}}
// x64-apple-SAME: {{.*}}"frame-pointer"="all"
// force-SAME: {{.*}}"frame-pointer"="all"
//
// AAPCS64 demands frame pointers:
// aarch64-linux-SAME: {{.*}}"frame-pointer"="non-leaf"
// aarch64-apple-SAME: {{.*}}"frame-pointer"="non-leaf"
// CHECK-SAME: }