compiler(nfc): -Cforce-frame-pointers is a FramePointer

This commit is contained in:
Jubilee Young 2024-05-04 16:19:42 -07:00
parent 7c0b5cf99f
commit b3a1975cdc
4 changed files with 26 additions and 14 deletions

View File

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

View File

@ -20,9 +20,9 @@
use rustc_span::symbol::sym; use rustc_span::symbol::sym;
use rustc_span::{FileName, SourceFileHashAlgorithm}; use rustc_span::{FileName, SourceFileHashAlgorithm};
use rustc_target::spec::{ use rustc_target::spec::{
CodeModel, LinkerFlavorCli, MergeFunctions, OnBrokenPipe, PanicStrategy, RelocModel, WasmCAbi, CodeModel, FramePointer, LinkerFlavorCli, MergeFunctions, OnBrokenPipe, PanicStrategy,
RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TlsModel, WasmCAbi,
}; };
use rustc_target::spec::{RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TlsModel};
use std::collections::{BTreeMap, BTreeSet}; use std::collections::{BTreeMap, BTreeSet};
use std::num::NonZero; use std::num::NonZero;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
@ -605,7 +605,7 @@ macro_rules! tracked {
tracked!(debug_assertions, Some(true)); tracked!(debug_assertions, Some(true));
tracked!(debuginfo, DebugInfo::Limited); tracked!(debuginfo, DebugInfo::Limited);
tracked!(embed_bitcode, false); tracked!(embed_bitcode, false);
tracked!(force_frame_pointers, Some(false)); tracked!(force_frame_pointers, FramePointer::Always);
tracked!(force_unwind_tables, Some(true)); tracked!(force_unwind_tables, Some(true));
tracked!(inline_threshold, Some(0xf007ba11)); tracked!(inline_threshold, Some(0xf007ba11));
tracked!(instrument_coverage, InstrumentCoverage::Yes); tracked!(instrument_coverage, InstrumentCoverage::Yes);

View File

@ -2966,10 +2966,8 @@ pub(crate) mod dep_tracking {
use rustc_span::edition::Edition; use rustc_span::edition::Edition;
use rustc_span::RealFileName; use rustc_span::RealFileName;
use rustc_target::spec::{ use rustc_target::spec::{
CodeModel, MergeFunctions, OnBrokenPipe, PanicStrategy, RelocModel, WasmCAbi, CodeModel, FramePointer, MergeFunctions, OnBrokenPipe, PanicStrategy, RelocModel,
}; RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TargetTriple, TlsModel, WasmCAbi,
use rustc_target::spec::{
RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TargetTriple, TlsModel,
}; };
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::hash::{DefaultHasher, Hash}; use std::hash::{DefaultHasher, Hash};
@ -3023,6 +3021,7 @@ fn hash(
lint::Level, lint::Level,
WasiExecModel, WasiExecModel,
u32, u32,
FramePointer,
RelocModel, RelocModel,
CodeModel, CodeModel,
TlsModel, TlsModel,

View File

@ -12,10 +12,9 @@
use rustc_span::RealFileName; use rustc_span::RealFileName;
use rustc_span::SourceFileHashAlgorithm; use rustc_span::SourceFileHashAlgorithm;
use rustc_target::spec::{ use rustc_target::spec::{
CodeModel, LinkerFlavorCli, MergeFunctions, OnBrokenPipe, PanicStrategy, SanitizerSet, WasmCAbi, CodeModel, FramePointer, LinkerFlavorCli, MergeFunctions, OnBrokenPipe, PanicStrategy,
}; RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TargetTriple, TlsModel,
use rustc_target::spec::{ WasmCAbi,
RelocModel, RelroLevel, SplitDebuginfo, StackProtector, TargetTriple, TlsModel,
}; };
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::hash::{DefaultHasher, Hasher}; use std::hash::{DefaultHasher, Hasher};
@ -374,6 +373,7 @@ mod desc {
pub const parse_opt_comma_list: &str = parse_comma_list; pub const parse_opt_comma_list: &str = parse_comma_list;
pub const parse_number: &str = "a number"; pub const parse_number: &str = "a number";
pub const parse_opt_number: &str = parse_number; pub const parse_opt_number: &str = parse_number;
pub const parse_frame_pointer: &str = parse_bool;
pub const parse_threads: &str = parse_number; pub const parse_threads: &str = parse_number;
pub const parse_time_passes_format: &str = "`text` (default) or `json`"; pub const parse_time_passes_format: &str = "`text` (default) or `json`";
pub const parse_passes: &str = "a space-separated list of passes, or `all`"; pub const parse_passes: &str = "a space-separated list of passes, or `all`";
@ -672,6 +672,18 @@ pub(crate) fn parse_opt_number<T: Copy + FromStr>(
} }
} }
pub(crate) fn parse_frame_pointer(slot: &mut FramePointer, v: Option<&str>) -> bool {
let mut boolish = false;
let mut is_parsed = parse_bool(&mut boolish, v);
if boolish & is_parsed {
*slot = FramePointer::Always;
} else if false {
/* TODO: add NonLeaf as an unstable opt */
is_parsed = true;
};
is_parsed
}
pub(crate) fn parse_passes(slot: &mut Passes, v: Option<&str>) -> bool { pub(crate) fn parse_passes(slot: &mut Passes, v: Option<&str>) -> bool {
match v { match v {
Some("all") => { Some("all") => {
@ -1479,7 +1491,7 @@ pub(crate) fn parse_wasm_c_abi(slot: &mut WasmCAbi, v: Option<&str>) -> bool {
"emit bitcode in rlibs (default: yes)"), "emit bitcode in rlibs (default: yes)"),
extra_filename: String = (String::new(), parse_string, [UNTRACKED], extra_filename: String = (String::new(), parse_string, [UNTRACKED],
"extra data to put in each output filename"), "extra data to put in each output filename"),
force_frame_pointers: Option<bool> = (None, parse_opt_bool, [TRACKED], force_frame_pointers: FramePointer = (FramePointer::MayOmit, parse_frame_pointer, [TRACKED],
"force use of the frame pointers"), "force use of the frame pointers"),
#[rustc_lint_opt_deny_field_access("use `Session::must_emit_unwind_tables` instead of this field")] #[rustc_lint_opt_deny_field_access("use `Session::must_emit_unwind_tables` instead of this field")]
force_unwind_tables: Option<bool> = (None, parse_opt_bool, [TRACKED], force_unwind_tables: Option<bool> = (None, parse_opt_bool, [TRACKED],