Skip to content

aarch64-linux: Default to FramePointer::NonLeaf #140832

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rustc_abi::Endian;

use crate::spec::{StackProbeType, Target, TargetMetadata, TargetOptions, base};
use crate::spec::{FramePointer, StackProbeType, Target, TargetMetadata, TargetOptions, base};

pub(crate) fn target() -> Target {
Target {
Expand All @@ -16,6 +16,10 @@ pub(crate) fn target() -> Target {
arch: "aarch64".into(),
options: TargetOptions {
features: "+v8a,+outline-atomics".into(),
// the AAPCS64 expects use of non-leaf frame pointers per
// https://github.com/ARM-software/abi-aa/blob/4492d1570eb70c8fd146623e0db65b2d241f12e7/aapcs64/aapcs64.rst#the-frame-pointer
// and we tend to encounter interesting bugs in AArch64 unwinding code if we do not
frame_pointer: FramePointer::NonLeaf,
max_atomic_width: Some(128),
stack_probes: StackProbeType::Inline,
mcount: "\u{1}_mcount".into(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rustc_abi::Endian;

use crate::spec::{StackProbeType, Target, TargetMetadata, TargetOptions, base};
use crate::spec::{FramePointer, StackProbeType, Target, TargetMetadata, TargetOptions, base};

pub(crate) fn target() -> Target {
let mut base = base::linux_gnu::opts();
Expand All @@ -20,6 +20,10 @@ pub(crate) fn target() -> Target {
options: TargetOptions {
abi: "ilp32".into(),
features: "+v8a,+outline-atomics".into(),
// the AAPCS64 expects use of non-leaf frame pointers per
// https://github.com/ARM-software/abi-aa/blob/4492d1570eb70c8fd146623e0db65b2d241f12e7/aapcs64/aapcs64.rst#the-frame-pointer
// and we tend to encounter interesting bugs in AArch64 unwinding code if we do not
frame_pointer: FramePointer::NonLeaf,
stack_probes: StackProbeType::Inline,
mcount: "\u{1}_mcount".into(),
endian: Endian::Big,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use crate::spec::{SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, base};
use crate::spec::{
FramePointer, SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, base,
};

// See https://developer.android.com/ndk/guides/abis.html#arm64-v8a
// for target ABI requirements.
Expand All @@ -20,6 +22,10 @@ pub(crate) fn target() -> Target {
// As documented in https://developer.android.com/ndk/guides/cpu-features.html
// the neon (ASIMD) and FP must exist on all android aarch64 targets.
features: "+v8a,+neon,+fp-armv8".into(),
// the AAPCS64 expects use of non-leaf frame pointers per
// https://github.com/ARM-software/abi-aa/blob/4492d1570eb70c8fd146623e0db65b2d241f12e7/aapcs64/aapcs64.rst#the-frame-pointer
// and we tend to encounter interesting bugs in AArch64 unwinding code if we do not
frame_pointer: FramePointer::NonLeaf,
stack_probes: StackProbeType::Inline,
supported_sanitizers: SanitizerSet::CFI
| SanitizerSet::HWADDRESS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use crate::spec::{SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, base};
use crate::spec::{
FramePointer, SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, base,
};

pub(crate) fn target() -> Target {
Target {
Expand All @@ -14,6 +16,10 @@ pub(crate) fn target() -> Target {
arch: "aarch64".into(),
options: TargetOptions {
features: "+v8a,+outline-atomics".into(),
// the AAPCS64 expects use of non-leaf frame pointers per
// https://github.com/ARM-software/abi-aa/blob/4492d1570eb70c8fd146623e0db65b2d241f12e7/aapcs64/aapcs64.rst#the-frame-pointer
// and we tend to encounter interesting bugs in AArch64 unwinding code if we do not
frame_pointer: FramePointer::NonLeaf,
mcount: "\u{1}_mcount".into(),
max_atomic_width: Some(128),
stack_probes: StackProbeType::Inline,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{StackProbeType, Target, TargetMetadata, TargetOptions, base};
use crate::spec::{FramePointer, StackProbeType, Target, TargetMetadata, TargetOptions, base};

pub(crate) fn target() -> Target {
Target {
Expand All @@ -15,6 +15,10 @@ pub(crate) fn target() -> Target {
options: TargetOptions {
abi: "ilp32".into(),
features: "+v8a,+outline-atomics".into(),
// the AAPCS64 expects use of non-leaf frame pointers per
// https://github.com/ARM-software/abi-aa/blob/4492d1570eb70c8fd146623e0db65b2d241f12e7/aapcs64/aapcs64.rst#the-frame-pointer
// and we tend to encounter interesting bugs in AArch64 unwinding code if we do not
frame_pointer: FramePointer::NonLeaf,
max_atomic_width: Some(128),
stack_probes: StackProbeType::Inline,
mcount: "\u{1}_mcount".into(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use crate::spec::{SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, base};
use crate::spec::{
FramePointer, SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, base,
};

pub(crate) fn target() -> Target {
let mut base = base::linux_musl::opts();
Expand Down Expand Up @@ -26,6 +28,12 @@ pub(crate) fn target() -> Target {
pointer_width: 64,
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(),
arch: "aarch64".into(),
options: TargetOptions { mcount: "\u{1}_mcount".into(), ..base },
options: TargetOptions {
// the AAPCS64 expects use of non-leaf frame pointers per
// https://github.com/ARM-software/abi-aa/blob/4492d1570eb70c8fd146623e0db65b2d241f12e7/aapcs64/aapcs64.rst#the-frame-pointer
// and we tend to encounter interesting bugs in AArch64 unwinding code if we do not
frame_pointer: FramePointer::NonLeaf,
mcount: "\u{1}_mcount".into(), ..base
},
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use crate::spec::{SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, base};
use crate::spec::{
FramePointer, SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, base,
};

pub(crate) fn target() -> Target {
let mut base = base::linux_ohos::opts();
Expand All @@ -16,6 +18,10 @@ pub(crate) fn target() -> Target {
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(),
arch: "aarch64".into(),
options: TargetOptions {
// the AAPCS64 expects use of non-leaf frame pointers per
// https://github.com/ARM-software/abi-aa/blob/4492d1570eb70c8fd146623e0db65b2d241f12e7/aapcs64/aapcs64.rst#the-frame-pointer
// and we tend to encounter interesting bugs in AArch64 unwinding code if we do not
frame_pointer: FramePointer::NonLeaf,
mcount: "\u{1}_mcount".into(),
stack_probes: StackProbeType::Inline,
supported_sanitizers: SanitizerSet::ADDRESS
Expand Down
5 changes: 3 additions & 2 deletions tests/assembly/asm/aarch64-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ pub unsafe fn sym_static() {

// Regression test for #75761
// CHECK-LABEL: {{("#)?}}issue_75761{{"?}}
// CHECK: str {{.*}}x30
// x29 holds the frame pointer, right next to x30, so ldp/stp happens sometimes
// CHECK: st[[MAY_PAIR:(r|p).*]]x30
// CHECK: //APP
// CHECK: //NO_APP
// CHECK: ldr {{.*}}x30
// CHECK: ld[[MAY_PAIR]]x30
#[no_mangle]
pub unsafe fn issue_75761() {
asm!("", out("v0") _, out("x30") _);
Expand Down
4 changes: 3 additions & 1 deletion tests/codegen/frame-pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ pub fn peach(x: u32) -> u32 {

// CHECK: attributes [[PEACH_ATTRS]] = {
// x64-linux-NOT: {{.*}}"frame-pointer"{{.*}}
// aarch64-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: }
Loading