Skip to content

Commit

Permalink
Rework force-frame-pointer
Browse files Browse the repository at this point in the history
This reworks the force-frame-pointer PR to explicitly only consider the
value of the flag if it is provided, and use a target default otherwise.

Something that was tried but not kept was renaming the flag to
`frame-pointer`, because for flag `frame-pointer=no`, there is no
guarante, that LLVM will elide *all* the frame pointers; oposite of what
the literal reading of the flag would suggest.
  • Loading branch information
nagisa committed Mar 15, 2018
1 parent 935070a commit 7188f41
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1064,8 +1064,8 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
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"),
force_frame_pointers: Option<bool> = (None, parse_opt_bool, [TRACKED],
"force use of the frame pointers"),
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],
Expand Down Expand Up @@ -2893,7 +2893,7 @@ mod tests {
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());

opts = reference.clone();
opts.cg.force_frame_pointers = true;
opts.cg.force_frame_pointers = Some(false);
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());

opts = reference.clone();
Expand Down
7 changes: 5 additions & 2 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,8 +676,11 @@ impl Session {
}

pub fn must_not_eliminate_frame_pointers(&self) -> bool {
self.opts.debuginfo != DebugInfoLevel::NoDebugInfo
|| !self.target.target.options.eliminate_frame_pointer
if let Some(x) = self.opts.cg.force_frame_pointers {
x
} else {
!self.target.target.options.eliminate_frame_pointer
}
}

/// Returns the symbol name for the registrar function,
Expand Down
2 changes: 1 addition & 1 deletion src/test/codegen/force-frame-pointers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// 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
// compile-flags: -C no-prepopulate-passes -C force-frame-pointers=y

#![crate_type="lib"]

Expand Down

0 comments on commit 7188f41

Please sign in to comment.