Skip to content

Commit 0eb68b7

Browse files
committed
Auto merge of #48786 - nagisa:fp, r=nikomatsakis
Add force-frame-pointer flag to allow control of frame pointer ommision Rebase of #47152 plus some changes suggested by #48785. Fixes #11906 r? @nikomatsakis
2 parents 491512b + 7ec0452 commit 0eb68b7

File tree

7 files changed

+31
-5
lines changed

7 files changed

+31
-5
lines changed

Diff for: src/librustc/session/config.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,8 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
10531053
2 = full debug info with variable and type information"),
10541054
opt_level: Option<String> = (None, parse_opt_string, [TRACKED],
10551055
"optimize with possible levels 0-3, s, or z"),
1056+
force_frame_pointers: Option<bool> = (None, parse_opt_bool, [TRACKED],
1057+
"force use of the frame pointers"),
10561058
debug_assertions: Option<bool> = (None, parse_opt_bool, [TRACKED],
10571059
"explicitly enable the cfg(debug_assertions) directive"),
10581060
inline_threshold: Option<usize> = (None, parse_opt_uint, [TRACKED],
@@ -2965,6 +2967,10 @@ mod tests {
29652967
opts.cg.debuginfo = Some(0xba5eba11);
29662968
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
29672969

2970+
opts = reference.clone();
2971+
opts.cg.force_frame_pointers = Some(false);
2972+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
2973+
29682974
opts = reference.clone();
29692975
opts.cg.debug_assertions = Some(true);
29702976
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());

Diff for: src/librustc/session/mod.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use lint::builtin::BuiltinLintDiagnostics;
2020
use middle::allocator::AllocatorKind;
2121
use middle::dependency_format;
2222
use session::search_paths::PathKind;
23-
use session::config::{DebugInfoLevel, OutputType};
23+
use session::config::{OutputType};
2424
use ty::tls;
2525
use util::nodemap::{FxHashSet};
2626
use util::common::{duration_to_secs_str, ErrorReported};
@@ -658,8 +658,11 @@ impl Session {
658658
}
659659

660660
pub fn must_not_eliminate_frame_pointers(&self) -> bool {
661-
self.opts.debuginfo != DebugInfoLevel::NoDebugInfo
662-
|| !self.target.target.options.eliminate_frame_pointer
661+
if let Some(x) = self.opts.cg.force_frame_pointers {
662+
x
663+
} else {
664+
!self.target.target.options.eliminate_frame_pointer
665+
}
663666
}
664667

665668
/// Returns the symbol name for the registrar function,

Diff for: src/librustc_target/spec/apple_ios_base.rs

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ pub fn opts(arch: Arch) -> Result<TargetOptions, String> {
9898
executables: true,
9999
pre_link_args,
100100
has_elf_tls: false,
101+
eliminate_frame_pointer: false,
101102
// The following line is a workaround for jemalloc 4.5 being broken on
102103
// ios. jemalloc 5.0 is supposed to fix this.
103104
// see https://github.com/rust-lang/rust/issues/45262

Diff for: src/librustc_target/spec/i686_apple_darwin.rs

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub fn target() -> TargetResult {
1616
base.max_atomic_width = Some(64);
1717
base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-m32".to_string()]);
1818
base.stack_probes = true;
19+
base.eliminate_frame_pointer = false;
1920

2021
Ok(Target {
2122
llvm_target: "i686-apple-darwin".to_string(),

Diff for: src/librustc_trans/attributes.rs

-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ pub fn naked(val: ValueRef, is_naked: bool) {
6969
}
7070

7171
pub fn set_frame_pointer_elimination(cx: &CodegenCx, llfn: ValueRef) {
72-
// FIXME: #11906: Omitting frame pointers breaks retrieving the value of a
73-
// parameter.
7472
if cx.sess().must_not_eliminate_frame_pointers() {
7573
llvm::AddFunctionAttrStringValue(
7674
llfn, llvm::AttributePlace::Function,

Diff for: src/test/codegen/force-frame-pointers.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
//
11+
// compile-flags: -C no-prepopulate-passes -C force-frame-pointers=y
12+
13+
#![crate_type="lib"]
14+
15+
// CHECK: attributes #{{.*}} "no-frame-pointer-elim"="true"
16+
pub fn foo() {}

Diff for: src/test/run-pass/backtrace-debuginfo.rs

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// "enable" to 0 instead.
1717

1818
// compile-flags:-g -Cllvm-args=-enable-tail-merge=0 -Cllvm-args=-opt-bisect-limit=0
19+
// compile-flags:-Cforce-frame-pointers=yes
1920
// ignore-pretty issue #37195
2021
// ignore-cloudabi spawning processes is not supported
2122
// ignore-emscripten spawning processes is not supported

0 commit comments

Comments
 (0)