Skip to content

Commit b3a1975

Browse files
compiler(nfc): -Cforce-frame-pointers is a FramePointer
1 parent 7c0b5cf commit b3a1975

File tree

4 files changed

+26
-14
lines changed

4 files changed

+26
-14
lines changed

compiler/rustc_codegen_llvm/src/attributes.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,10 @@ pub fn frame_pointer_type_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attr
108108
let opts = &cx.sess().opts;
109109
// "mcount" function relies on stack pointer.
110110
// See <https://sourceware.org/binutils/docs/gprof/Implementation.html>.
111-
if opts.unstable_opts.instrument_mcount || matches!(opts.cg.force_frame_pointers, Some(true)) {
112-
fp = FramePointer::Always;
111+
if opts.unstable_opts.instrument_mcount {
112+
fp.ratchet(FramePointer::Always);
113113
}
114+
fp.ratchet(opts.cg.force_frame_pointers);
114115
let attr_value = match fp {
115116
FramePointer::Always => "all",
116117
FramePointer::NonLeaf => "non-leaf",

compiler/rustc_interface/src/tests.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ use rustc_span::source_map::{RealFileLoader, SourceMapInputs};
2020
use rustc_span::symbol::sym;
2121
use rustc_span::{FileName, SourceFileHashAlgorithm};
2222
use rustc_target::spec::{
23-
CodeModel, LinkerFlavorCli, MergeFunctions, OnBrokenPipe, PanicStrategy, RelocModel, WasmCAbi,
23+
CodeModel, FramePointer, LinkerFlavorCli, MergeFunctions, OnBrokenPipe, PanicStrategy,
24+
RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TlsModel, WasmCAbi,
2425
};
25-
use rustc_target::spec::{RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TlsModel};
2626
use std::collections::{BTreeMap, BTreeSet};
2727
use std::num::NonZero;
2828
use std::path::{Path, PathBuf};
@@ -605,7 +605,7 @@ fn test_codegen_options_tracking_hash() {
605605
tracked!(debug_assertions, Some(true));
606606
tracked!(debuginfo, DebugInfo::Limited);
607607
tracked!(embed_bitcode, false);
608-
tracked!(force_frame_pointers, Some(false));
608+
tracked!(force_frame_pointers, FramePointer::Always);
609609
tracked!(force_unwind_tables, Some(true));
610610
tracked!(inline_threshold, Some(0xf007ba11));
611611
tracked!(instrument_coverage, InstrumentCoverage::Yes);

compiler/rustc_session/src/config.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -2966,10 +2966,8 @@ pub(crate) mod dep_tracking {
29662966
use rustc_span::edition::Edition;
29672967
use rustc_span::RealFileName;
29682968
use rustc_target::spec::{
2969-
CodeModel, MergeFunctions, OnBrokenPipe, PanicStrategy, RelocModel, WasmCAbi,
2970-
};
2971-
use rustc_target::spec::{
2972-
RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TargetTriple, TlsModel,
2969+
CodeModel, FramePointer, MergeFunctions, OnBrokenPipe, PanicStrategy, RelocModel,
2970+
RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TargetTriple, TlsModel, WasmCAbi,
29732971
};
29742972
use std::collections::BTreeMap;
29752973
use std::hash::{DefaultHasher, Hash};
@@ -3023,6 +3021,7 @@ pub(crate) mod dep_tracking {
30233021
lint::Level,
30243022
WasiExecModel,
30253023
u32,
3024+
FramePointer,
30263025
RelocModel,
30273026
CodeModel,
30283027
TlsModel,

compiler/rustc_session/src/options.rs

+17-5
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ use rustc_span::edition::Edition;
1212
use rustc_span::RealFileName;
1313
use rustc_span::SourceFileHashAlgorithm;
1414
use rustc_target::spec::{
15-
CodeModel, LinkerFlavorCli, MergeFunctions, OnBrokenPipe, PanicStrategy, SanitizerSet, WasmCAbi,
16-
};
17-
use rustc_target::spec::{
18-
RelocModel, RelroLevel, SplitDebuginfo, StackProtector, TargetTriple, TlsModel,
15+
CodeModel, FramePointer, LinkerFlavorCli, MergeFunctions, OnBrokenPipe, PanicStrategy,
16+
RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TargetTriple, TlsModel,
17+
WasmCAbi,
1918
};
2019
use std::collections::BTreeMap;
2120
use std::hash::{DefaultHasher, Hasher};
@@ -374,6 +373,7 @@ mod desc {
374373
pub const parse_opt_comma_list: &str = parse_comma_list;
375374
pub const parse_number: &str = "a number";
376375
pub const parse_opt_number: &str = parse_number;
376+
pub const parse_frame_pointer: &str = parse_bool;
377377
pub const parse_threads: &str = parse_number;
378378
pub const parse_time_passes_format: &str = "`text` (default) or `json`";
379379
pub const parse_passes: &str = "a space-separated list of passes, or `all`";
@@ -672,6 +672,18 @@ mod parse {
672672
}
673673
}
674674

675+
pub(crate) fn parse_frame_pointer(slot: &mut FramePointer, v: Option<&str>) -> bool {
676+
let mut boolish = false;
677+
let mut is_parsed = parse_bool(&mut boolish, v);
678+
if boolish & is_parsed {
679+
*slot = FramePointer::Always;
680+
} else if false {
681+
/* TODO: add NonLeaf as an unstable opt */
682+
is_parsed = true;
683+
};
684+
is_parsed
685+
}
686+
675687
pub(crate) fn parse_passes(slot: &mut Passes, v: Option<&str>) -> bool {
676688
match v {
677689
Some("all") => {
@@ -1479,7 +1491,7 @@ options! {
14791491
"emit bitcode in rlibs (default: yes)"),
14801492
extra_filename: String = (String::new(), parse_string, [UNTRACKED],
14811493
"extra data to put in each output filename"),
1482-
force_frame_pointers: Option<bool> = (None, parse_opt_bool, [TRACKED],
1494+
force_frame_pointers: FramePointer = (FramePointer::MayOmit, parse_frame_pointer, [TRACKED],
14831495
"force use of the frame pointers"),
14841496
#[rustc_lint_opt_deny_field_access("use `Session::must_emit_unwind_tables` instead of this field")]
14851497
force_unwind_tables: Option<bool> = (None, parse_opt_bool, [TRACKED],

0 commit comments

Comments
 (0)