]> git.lizzy.rs Git - rust.git/commitdiff
Don't force-enable frame pointers when generating debug info
authorBjörn Steinbrink <bsteinbr@gmail.com>
Wed, 3 Jan 2018 09:29:27 +0000 (10:29 +0100)
committerSimonas Kazlauskas <git@kazlauskas.me>
Tue, 1 May 2018 07:44:44 +0000 (10:44 +0300)
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 #11906

src/librustc/session/config.rs
src/librustc/session/mod.rs
src/librustc_trans/attributes.rs
src/test/codegen/force-frame-pointers.rs [new file with mode: 0644]

index 06922d986b3ce48df83cb732820e7b87d31f9310..023be78922207dacf9c6d19769c1cbc61e677d0d 100644 (file)
@@ -1053,6 +1053,8 @@ fn parse_lto(slot: &mut Lto, v: Option<&str>) -> bool {
          2 = full debug info with variable and type information"),
     opt_level: Option<String> = (None, parse_opt_string, [TRACKED],
         "optimize with possible levels 0-3, s, or z"),
+    force_frame_pointers: bool = (false, parse_bool, [TRACKED],
+        "force frame pointers to be used"),
     debug_assertions: Option<bool> = (None, parse_opt_bool, [TRACKED],
         "explicitly enable the cfg(debug_assertions) directive"),
     inline_threshold: Option<usize> = (None, parse_opt_uint, [TRACKED],
@@ -2965,6 +2967,10 @@ fn test_codegen_options_tracking_hash() {
         opts.cg.debuginfo = Some(0xba5eba11);
         assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
 
+        opts = reference.clone();
+        opts.cg.force_frame_pointers = true;
+        assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
+
         opts = reference.clone();
         opts.cg.debug_assertions = Some(true);
         assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
index 37a6b2e79f7dbd0c97a0b6fda514c8aa52484ff9..45b7e2d17404a28d454f3b20b41332ce7f300c65 100644 (file)
@@ -20,7 +20,7 @@
 use middle::allocator::AllocatorKind;
 use middle::dependency_format;
 use session::search_paths::PathKind;
-use session::config::{DebugInfoLevel, OutputType};
+use session::config::{OutputType};
 use ty::tls;
 use util::nodemap::{FxHashSet};
 use util::common::{duration_to_secs_str, ErrorReported};
index f455c19cc0bbef36b947226ff48e4cbd8e9c272f..5baed57092d0f3c243605d666bce3a650281dbf6 100644 (file)
@@ -69,8 +69,6 @@ pub fn naked(val: ValueRef, is_naked: bool) {
 }
 
 pub fn set_frame_pointer_elimination(cx: &CodegenCx, llfn: ValueRef) {
-    // FIXME: #11906: Omitting frame pointers breaks retrieving the value of a
-    // parameter.
     if cx.sess().must_not_eliminate_frame_pointers() {
         llvm::AddFunctionAttrStringValue(
             llfn, llvm::AttributePlace::Function,
diff --git a/src/test/codegen/force-frame-pointers.rs b/src/test/codegen/force-frame-pointers.rs
new file mode 100644 (file)
index 0000000..d40406a
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+//
+// compile-flags: -C no-prepopulate-passes -C force-frame-pointers
+
+#![crate_type="lib"]
+
+// CHECK: attributes #{{.*}} "no-frame-pointer-elim"="true"
+pub fn foo() {}