Skip to content

Commit b44c7b2

Browse files
committed
Don't force-enable frame pointers when generating debug info
We apparently used to generate bad/incomplete debug info causing debuggers not to find symbols of stack allocated variables. This was somehow worked around by having frame pointers. With the current codegen, this seems no longer necessary, so we can remove the code that force-enables frame pointers whenever debug info is requested. Since certain situations, like profiling code profit from having frame pointers, we add a -Cforce-frame-pointers flag to always enable frame pointers. Fixes rust-lang#11906
1 parent 932c736 commit b44c7b2

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

src/librustc/session/config.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,8 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
10941094
2 = full debug info with variable and type information"),
10951095
opt_level: Option<String> = (None, parse_opt_string, [TRACKED],
10961096
"optimize with possible levels 0-3, s, or z"),
1097+
force_frame_pointers: bool = (false, parse_bool, [TRACKED],
1098+
"force frame pointers to be used"),
10971099
debug_assertions: Option<bool> = (None, parse_opt_bool, [TRACKED],
10981100
"explicitly enable the cfg(debug_assertions) directive"),
10991101
inline_threshold: Option<usize> = (None, parse_opt_uint, [TRACKED],
@@ -2790,6 +2792,10 @@ mod tests {
27902792
opts.cg.debuginfo = Some(0xba5eba11);
27912793
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
27922794

2795+
opts = reference.clone();
2796+
opts.cg.force_frame_pointers = true;
2797+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
2798+
27932799
opts = reference.clone();
27942800
opts.cg.debug_assertions = Some(true);
27952801
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());

src/librustc/session/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use lint;
1919
use middle::allocator::AllocatorKind;
2020
use middle::dependency_format;
2121
use session::search_paths::PathKind;
22-
use session::config::{BorrowckMode, DebugInfoLevel, OutputType, Epoch};
22+
use session::config::{BorrowckMode, OutputType, Epoch};
2323
use ty::tls;
2424
use util::nodemap::{FxHashMap, FxHashSet};
2525
use util::common::{duration_to_secs_str, ErrorReported};
@@ -613,8 +613,8 @@ impl Session {
613613
}
614614

615615
pub fn must_not_eliminate_frame_pointers(&self) -> bool {
616-
self.opts.debuginfo != DebugInfoLevel::NoDebugInfo ||
617-
!self.target.target.options.eliminate_frame_pointer
616+
self.opts.cg.force_frame_pointers ||
617+
!self.target.target.options.eliminate_frame_pointer
618618
}
619619

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

src/librustc_trans/attributes.rs

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

7070
pub fn set_frame_pointer_elimination(cx: &CodegenCx, llfn: ValueRef) {
71-
// FIXME: #11906: Omitting frame pointers breaks retrieving the value of a
72-
// parameter.
7371
if cx.sess().must_not_eliminate_frame_pointers() {
7472
llvm::AddFunctionAttrStringValue(
7573
llfn, llvm::AttributePlace::Function,
+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
12+
13+
#![crate_type="lib"]
14+
15+
// CHECK: attributes #{{.*}} "no-frame-pointer-elim"="true"
16+
pub fn foo() {}

0 commit comments

Comments
 (0)