about summary refs log tree commit diff
path: root/tests/codegen/frame-pointer-cli-control.rs
diff options
context:
space:
mode:
authorJubilee Young <workingjubilee@gmail.com>2024-05-15 21:51:32 -0700
committerJubilee Young <workingjubilee@gmail.com>2025-06-04 14:51:51 -0700
commitf27ed880531867fa548c9780144558cecb6fbe71 (patch)
tree195ef8ba04176edf8ad4310ceb62eb69510138d3 /tests/codegen/frame-pointer-cli-control.rs
parentdf8102fe5f24f28a918660b0cd918d7331c3896e (diff)
downloadrust-f27ed880531867fa548c9780144558cecb6fbe71.tar.gz
rust-f27ed880531867fa548c9780144558cecb6fbe71.zip
codegen: test frame pointer attr prefers CLI opt
This test only makes sense if you send it back in time and run it with
a now-old Rust commit, e.g. 50e0cc59ffcacda5b48f4edb95e5a5c353624fb0
However, if you do go back that far in time, you will see it pass.
Diffstat (limited to 'tests/codegen/frame-pointer-cli-control.rs')
-rw-r--r--tests/codegen/frame-pointer-cli-control.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/codegen/frame-pointer-cli-control.rs b/tests/codegen/frame-pointer-cli-control.rs
new file mode 100644
index 00000000000..12282eea8f4
--- /dev/null
+++ b/tests/codegen/frame-pointer-cli-control.rs
@@ -0,0 +1,35 @@
+// compile-flags: --crate-type=rlib -Copt-level=0
+// revisions: force-on aarch64-apple aarch64-apple-off
+// [force-on] compile-flags: -Cforce-frame-pointers=on
+// [aarch64-apple] needs-llvm-components: aarch64
+// [aarch64-apple] compile-flags: --target=aarch64-apple-darwin
+// [aarch64-apple-off] needs-llvm-components: aarch64
+// [aarch64-apple-off] compile-flags: --target=aarch64-apple-darwin -Cforce-frame-pointers=off
+/*
+Tests that the frame pointers can be controlled by the CLI. We find aarch64-apple-darwin useful
+because of its icy-clear policy regarding frame pointers (software SHALL be compiled with them),
+e.g. https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms says:
+
+* The frame pointer register (x29) must always address a valid frame record. Some functions —
+  such as leaf functions or tail calls — may opt not to create an entry in this list.
+  As a result, stack traces are always meaningful, even without debug information.
+*/
+#![feature(no_core, lang_items)]
+#![no_core]
+#[lang = "sized"]
+trait Sized {}
+#[lang = "copy"]
+trait Copy {}
+impl Copy for u32 {}
+
+// CHECK: define i32 @peach{{.*}}[[PEACH_ATTRS:\#[0-9]+]] {
+#[no_mangle]
+pub fn peach(x: u32) -> u32 {
+    x
+}
+
+// CHECK: attributes [[PEACH_ATTRS]] = {
+// force-on-SAME: {{.*}}"frame-pointer"="all"
+// aarch64-apple-SAME: {{.*}}"frame-pointer"="all"
+// aarch64-apple-off-NOT: {{.*}}"frame-pointer"{{.*}}
+// CHECK-SAME: }