Skip to content

Commit 40579d1

Browse files
authored
Rollup merge of rust-lang#67748 - MaskRay:frame-pointer, r=rkruppe
Use function attribute "frame-pointer" instead of "no-frame-pointer-elim" LLVM 8 ([D56351](http://reviews.llvm.org/D56351)) introduced "frame-pointer". In LLVM 10 (D71863), "no-frame-pointer-elim"/"no-frame-pointer-elim-non-leaf" will be ignored. ----- In the LLVM monorepo, run `git show origin/release/8.x:llvm/lib/CodeGen/TargetOptionsImpl.cpp` to see that `"frame-pointer"` is available since LLVM 8.
2 parents 3cca3c6 + b40dc30 commit 40579d1

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

src/librustc_codegen_llvm/attributes.rs

+15-6
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,21 @@ fn naked(val: &'ll Value, is_naked: bool) {
6666

6767
pub fn set_frame_pointer_elimination(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
6868
if cx.sess().must_not_eliminate_frame_pointers() {
69-
llvm::AddFunctionAttrStringValue(
70-
llfn,
71-
llvm::AttributePlace::Function,
72-
const_cstr!("no-frame-pointer-elim"),
73-
const_cstr!("true"),
74-
);
69+
if llvm_util::get_major_version() >= 8 {
70+
llvm::AddFunctionAttrStringValue(
71+
llfn,
72+
llvm::AttributePlace::Function,
73+
const_cstr!("frame-pointer"),
74+
const_cstr!("all"),
75+
);
76+
} else {
77+
llvm::AddFunctionAttrStringValue(
78+
llfn,
79+
llvm::AttributePlace::Function,
80+
const_cstr!("no-frame-pointer-elim"),
81+
const_cstr!("true"),
82+
);
83+
}
7584
}
7685
}
7786

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
//
1+
// min-llvm-version 8.0
22
// compile-flags: -C no-prepopulate-passes -C force-frame-pointers=y
33

44
#![crate_type="lib"]
55

6-
// CHECK: attributes #{{.*}} "no-frame-pointer-elim"="true"
6+
// CHECK: attributes #{{.*}} "frame-pointer"="all"
77
pub fn foo() {}

src/test/codegen/instrument-mcount.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
// min-llvm-version 8.0
12
// ignore-tidy-linelength
23
// compile-flags: -Z instrument-mcount
34

45
#![crate_type = "lib"]
56

6-
// CHECK: attributes #{{.*}} "instrument-function-entry-inlined"="{{.*}}mcount{{.*}}" "no-frame-pointer-elim"="true"
7+
// CHECK: attributes #{{.*}} "frame-pointer"="all" "instrument-function-entry-inlined"="{{.*}}mcount{{.*}}"
78
pub fn foo() {}

0 commit comments

Comments
 (0)