diff options
| author | Simonas Kazlauskas <git@kazlauskas.me> | 2021-06-26 23:53:35 +0300 |
|---|---|---|
| committer | Simonas Kazlauskas <git@kazlauskas.me> | 2021-06-30 19:45:17 +0300 |
| commit | 9b67cba4f6294e0db900397cdf5c59c1dc901ade (patch) | |
| tree | 5f9e9ce96b1e1c32d448d8daa1ba0c9f18bb947e /src/test/codegen/frame-pointer.rs | |
| parent | 3ddb78a34608848a60f6ca5b6ccfde8340302372 (diff) | |
| download | rust-9b67cba4f6294e0db900397cdf5c59c1dc901ade.tar.gz rust-9b67cba4f6294e0db900397cdf5c59c1dc901ade.zip | |
Add support for leaf fn frame pointer elimination
This PR adds ability for the target specifications to specify frame pointer emission type that's not just “always” or “whatever cg decides”. In particular there's a new mode that allows omission of the frame pointer for leaf functions (those that don't call any other functions). We then set this new mode for Aarch64-based Apple targets. Fixes #86196
Diffstat (limited to 'src/test/codegen/frame-pointer.rs')
| -rw-r--r-- | src/test/codegen/frame-pointer.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/test/codegen/frame-pointer.rs b/src/test/codegen/frame-pointer.rs new file mode 100644 index 00000000000..367591dcb96 --- /dev/null +++ b/src/test/codegen/frame-pointer.rs @@ -0,0 +1,35 @@ +// compile-flags: --crate-type=rlib +// 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] +#[lang="sized"] +trait Sized { } +#[lang="copy"] +trait Copy { } + + + +// 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"{{.*}} +// aarch64-linux-NOT: {{.*}}"frame-pointer"{{.*}} +// x64-apple-SAME: {{.*}}"frame-pointer"="all" +// force-SAME: {{.*}}"frame-pointer"="all" +// aarch64-apple-SAME: {{.*}}"frame-pointer"="non-leaf" +// CHECK-SAME: } |
