diff --git a/src/librustc_codegen_llvm/attributes.rs b/src/librustc_codegen_llvm/attributes.rs index 816f5baddcbeeff75baf7937df4654537d623255..942ba9f868c60c9677c06300cb6005a2055c410d 100644 --- a/src/librustc_codegen_llvm/attributes.rs +++ b/src/librustc_codegen_llvm/attributes.rs @@ -66,12 +66,21 @@ fn naked(val: &'ll Value, is_naked: bool) { pub fn set_frame_pointer_elimination(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) { if cx.sess().must_not_eliminate_frame_pointers() { - llvm::AddFunctionAttrStringValue( - llfn, - llvm::AttributePlace::Function, - const_cstr!("no-frame-pointer-elim"), - const_cstr!("true"), - ); + if llvm_util::get_major_version() >= 8 { + llvm::AddFunctionAttrStringValue( + llfn, + llvm::AttributePlace::Function, + const_cstr!("frame-pointer"), + const_cstr!("all"), + ); + } else { + llvm::AddFunctionAttrStringValue( + llfn, + llvm::AttributePlace::Function, + const_cstr!("no-frame-pointer-elim"), + const_cstr!("true"), + ); + } } } diff --git a/src/test/codegen/force-frame-pointers.rs b/src/test/codegen/force-frame-pointers.rs index c6c1da2c1b05eca83a49c4ab7c77ec2edfb29875..4c94a601f33fd960cf3fd7e82c6e461a9f1908bf 100644 --- a/src/test/codegen/force-frame-pointers.rs +++ b/src/test/codegen/force-frame-pointers.rs @@ -1,7 +1,7 @@ -// +// min-llvm-version 8.0 // compile-flags: -C no-prepopulate-passes -C force-frame-pointers=y #![crate_type="lib"] -// CHECK: attributes #{{.*}} "no-frame-pointer-elim"="true" +// CHECK: attributes #{{.*}} "frame-pointer"="all" pub fn foo() {} diff --git a/src/test/codegen/instrument-mcount.rs b/src/test/codegen/instrument-mcount.rs index c72d09f7a03d2931f78ce0f01e6a0d44a2eeab2c..e4e6d5ca2b850d69d86a2880857a1f5bdc06674a 100644 --- a/src/test/codegen/instrument-mcount.rs +++ b/src/test/codegen/instrument-mcount.rs @@ -1,7 +1,8 @@ +// min-llvm-version 8.0 // ignore-tidy-linelength // compile-flags: -Z instrument-mcount #![crate_type = "lib"] -// CHECK: attributes #{{.*}} "instrument-function-entry-inlined"="{{.*}}mcount{{.*}}" "no-frame-pointer-elim"="true" +// CHECK: attributes #{{.*}} "frame-pointer"="all" "instrument-function-entry-inlined"="{{.*}}mcount{{.*}}" pub fn foo() {}