Rollup merge of #105955 - Nilstrieb:no-trivial-opt-wrappers-we-have-field-accesses-for-that, r=cjgillot
Remove wrapper functions for some unstable options They are trivial and just forward to the option. Like most other options, we can just access it directly.
This commit is contained in:
commit
6689d2df08
8 changed files with 10 additions and 40 deletions
|
@ -102,10 +102,10 @@ pub fn uwtable_attr(llcx: &llvm::Context) -> &Attribute {
|
||||||
|
|
||||||
pub fn frame_pointer_type_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> {
|
pub fn frame_pointer_type_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> {
|
||||||
let mut fp = cx.sess().target.frame_pointer;
|
let mut fp = cx.sess().target.frame_pointer;
|
||||||
|
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 cx.sess().instrument_mcount() || matches!(cx.sess().opts.cg.force_frame_pointers, Some(true))
|
if opts.unstable_opts.instrument_mcount || matches!(opts.cg.force_frame_pointers, Some(true)) {
|
||||||
{
|
|
||||||
fp = FramePointer::Always;
|
fp = FramePointer::Always;
|
||||||
}
|
}
|
||||||
let attr_value = match fp {
|
let attr_value = match fp {
|
||||||
|
@ -119,7 +119,7 @@ pub fn frame_pointer_type_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attr
|
||||||
/// Tell LLVM what instrument function to insert.
|
/// Tell LLVM what instrument function to insert.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn instrument_function_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> {
|
fn instrument_function_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> {
|
||||||
if cx.sess().instrument_mcount() {
|
if cx.sess().opts.unstable_opts.instrument_mcount {
|
||||||
// Similar to `clang -pg` behavior. Handled by the
|
// Similar to `clang -pg` behavior. Handled by the
|
||||||
// `post-inline-ee-instrument` LLVM pass.
|
// `post-inline-ee-instrument` LLVM pass.
|
||||||
|
|
||||||
|
|
|
@ -203,7 +203,7 @@ pub fn target_machine_factory(
|
||||||
sess.opts.unstable_opts.trap_unreachable.unwrap_or(sess.target.trap_unreachable);
|
sess.opts.unstable_opts.trap_unreachable.unwrap_or(sess.target.trap_unreachable);
|
||||||
let emit_stack_size_section = sess.opts.unstable_opts.emit_stack_sizes;
|
let emit_stack_size_section = sess.opts.unstable_opts.emit_stack_sizes;
|
||||||
|
|
||||||
let asm_comments = sess.asm_comments();
|
let asm_comments = sess.opts.unstable_opts.asm_comments;
|
||||||
let relax_elf_relocations =
|
let relax_elf_relocations =
|
||||||
sess.opts.unstable_opts.relax_elf_relocations.unwrap_or(sess.target.relax_elf_relocations);
|
sess.opts.unstable_opts.relax_elf_relocations.unwrap_or(sess.target.relax_elf_relocations);
|
||||||
|
|
||||||
|
|
|
@ -81,10 +81,10 @@ unsafe fn configure_llvm(sess: &Session) {
|
||||||
};
|
};
|
||||||
// Set the llvm "program name" to make usage and invalid argument messages more clear.
|
// Set the llvm "program name" to make usage and invalid argument messages more clear.
|
||||||
add("rustc -Cllvm-args=\"...\" with", true);
|
add("rustc -Cllvm-args=\"...\" with", true);
|
||||||
if sess.time_llvm_passes() {
|
if sess.opts.unstable_opts.time_llvm_passes {
|
||||||
add("-time-passes", false);
|
add("-time-passes", false);
|
||||||
}
|
}
|
||||||
if sess.print_llvm_passes() {
|
if sess.opts.unstable_opts.print_llvm_passes {
|
||||||
add("-debug-pass=Structure", false);
|
add("-debug-pass=Structure", false);
|
||||||
}
|
}
|
||||||
if sess.target.generate_arange_section
|
if sess.target.generate_arange_section
|
||||||
|
|
|
@ -1899,7 +1899,7 @@ impl<B: ExtraBackendMethods> OngoingCodegen<B> {
|
||||||
|
|
||||||
// FIXME: time_llvm_passes support - does this use a global context or
|
// FIXME: time_llvm_passes support - does this use a global context or
|
||||||
// something?
|
// something?
|
||||||
if sess.codegen_units() == 1 && sess.time_llvm_passes() {
|
if sess.codegen_units() == 1 && sess.opts.unstable_opts.time_llvm_passes {
|
||||||
self.backend.print_pass_timings()
|
self.backend.print_pass_timings()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -681,7 +681,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut total_codegen_time = Duration::new(0, 0);
|
let mut total_codegen_time = Duration::new(0, 0);
|
||||||
let start_rss = tcx.sess.time_passes().then(|| get_resident_set_size());
|
let start_rss = tcx.sess.opts.unstable_opts.time_passes.then(|| get_resident_set_size());
|
||||||
|
|
||||||
// The non-parallel compiler can only translate codegen units to LLVM IR
|
// The non-parallel compiler can only translate codegen units to LLVM IR
|
||||||
// on a single thread, leading to a staircase effect where the N LLVM
|
// on a single thread, leading to a staircase effect where the N LLVM
|
||||||
|
@ -781,7 +781,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
|
||||||
|
|
||||||
// Since the main thread is sometimes blocked during codegen, we keep track
|
// Since the main thread is sometimes blocked during codegen, we keep track
|
||||||
// -Ztime-passes output manually.
|
// -Ztime-passes output manually.
|
||||||
if tcx.sess.time_passes() {
|
if tcx.sess.opts.unstable_opts.time_passes {
|
||||||
let end_rss = get_resident_set_size();
|
let end_rss = get_resident_set_size();
|
||||||
|
|
||||||
print_time_passes_entry(
|
print_time_passes_entry(
|
||||||
|
|
|
@ -713,7 +713,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
let computed_total_bytes: usize = stats.iter().map(|(_, size)| size).sum();
|
let computed_total_bytes: usize = stats.iter().map(|(_, size)| size).sum();
|
||||||
assert_eq!(total_bytes, computed_total_bytes);
|
assert_eq!(total_bytes, computed_total_bytes);
|
||||||
|
|
||||||
if tcx.sess.meta_stats() {
|
if tcx.sess.opts.unstable_opts.meta_stats {
|
||||||
self.opaque.flush();
|
self.opaque.flush();
|
||||||
|
|
||||||
// Rewind and re-read all the metadata to count the zero bytes we wrote.
|
// Rewind and re-read all the metadata to count the zero bytes we wrote.
|
||||||
|
|
|
@ -1214,7 +1214,6 @@ options! {
|
||||||
"only allow the listed language features to be enabled in code (space separated)"),
|
"only allow the listed language features to be enabled in code (space separated)"),
|
||||||
always_encode_mir: bool = (false, parse_bool, [TRACKED],
|
always_encode_mir: bool = (false, parse_bool, [TRACKED],
|
||||||
"encode MIR of all functions into the crate metadata (default: no)"),
|
"encode MIR of all functions into the crate metadata (default: no)"),
|
||||||
#[rustc_lint_opt_deny_field_access("use `Session::asm_comments` instead of this field")]
|
|
||||||
asm_comments: bool = (false, parse_bool, [TRACKED],
|
asm_comments: bool = (false, parse_bool, [TRACKED],
|
||||||
"generate comments into the assembly (may change behavior) (default: no)"),
|
"generate comments into the assembly (may change behavior) (default: no)"),
|
||||||
assert_incr_state: Option<String> = (None, parse_opt_string, [UNTRACKED],
|
assert_incr_state: Option<String> = (None, parse_opt_string, [UNTRACKED],
|
||||||
|
@ -1363,7 +1362,6 @@ options! {
|
||||||
`=except-unused-generics`
|
`=except-unused-generics`
|
||||||
`=except-unused-functions`
|
`=except-unused-functions`
|
||||||
`=off` (default)"),
|
`=off` (default)"),
|
||||||
#[rustc_lint_opt_deny_field_access("use `Session::instrument_mcount` instead of this field")]
|
|
||||||
instrument_mcount: bool = (false, parse_bool, [TRACKED],
|
instrument_mcount: bool = (false, parse_bool, [TRACKED],
|
||||||
"insert function instrument code for mcount-based tracing (default: no)"),
|
"insert function instrument code for mcount-based tracing (default: no)"),
|
||||||
keep_hygiene_data: bool = (false, parse_bool, [UNTRACKED],
|
keep_hygiene_data: bool = (false, parse_bool, [UNTRACKED],
|
||||||
|
@ -1392,7 +1390,6 @@ options! {
|
||||||
merge_functions: Option<MergeFunctions> = (None, parse_merge_functions, [TRACKED],
|
merge_functions: Option<MergeFunctions> = (None, parse_merge_functions, [TRACKED],
|
||||||
"control the operation of the MergeFunctions LLVM pass, taking \
|
"control the operation of the MergeFunctions LLVM pass, taking \
|
||||||
the same values as the target option of the same name"),
|
the same values as the target option of the same name"),
|
||||||
#[rustc_lint_opt_deny_field_access("use `Session::meta_stats` instead of this field")]
|
|
||||||
meta_stats: bool = (false, parse_bool, [UNTRACKED],
|
meta_stats: bool = (false, parse_bool, [UNTRACKED],
|
||||||
"gather metadata statistics (default: no)"),
|
"gather metadata statistics (default: no)"),
|
||||||
mir_emit_retag: bool = (false, parse_bool, [TRACKED],
|
mir_emit_retag: bool = (false, parse_bool, [TRACKED],
|
||||||
|
@ -1469,7 +1466,6 @@ options! {
|
||||||
See #77382 and #74551."),
|
See #77382 and #74551."),
|
||||||
print_fuel: Option<String> = (None, parse_opt_string, [TRACKED],
|
print_fuel: Option<String> = (None, parse_opt_string, [TRACKED],
|
||||||
"make rustc print the total optimization fuel used by a crate"),
|
"make rustc print the total optimization fuel used by a crate"),
|
||||||
#[rustc_lint_opt_deny_field_access("use `Session::print_llvm_passes` instead of this field")]
|
|
||||||
print_llvm_passes: bool = (false, parse_bool, [UNTRACKED],
|
print_llvm_passes: bool = (false, parse_bool, [UNTRACKED],
|
||||||
"print the LLVM optimization passes being run (default: no)"),
|
"print the LLVM optimization passes being run (default: no)"),
|
||||||
print_mono_items: Option<String> = (None, parse_opt_string, [UNTRACKED],
|
print_mono_items: Option<String> = (None, parse_opt_string, [UNTRACKED],
|
||||||
|
@ -1583,10 +1579,8 @@ options! {
|
||||||
#[rustc_lint_opt_deny_field_access("use `Session::threads` instead of this field")]
|
#[rustc_lint_opt_deny_field_access("use `Session::threads` instead of this field")]
|
||||||
threads: usize = (1, parse_threads, [UNTRACKED],
|
threads: usize = (1, parse_threads, [UNTRACKED],
|
||||||
"use a thread pool with N threads"),
|
"use a thread pool with N threads"),
|
||||||
#[rustc_lint_opt_deny_field_access("use `Session::time_llvm_passes` instead of this field")]
|
|
||||||
time_llvm_passes: bool = (false, parse_bool, [UNTRACKED],
|
time_llvm_passes: bool = (false, parse_bool, [UNTRACKED],
|
||||||
"measure time of each LLVM pass (default: no)"),
|
"measure time of each LLVM pass (default: no)"),
|
||||||
#[rustc_lint_opt_deny_field_access("use `Session::time_passes` instead of this field")]
|
|
||||||
time_passes: bool = (false, parse_bool, [UNTRACKED],
|
time_passes: bool = (false, parse_bool, [UNTRACKED],
|
||||||
"measure time of each rustc pass (default: no)"),
|
"measure time of each rustc pass (default: no)"),
|
||||||
#[rustc_lint_opt_deny_field_access("use `Session::tls_model` instead of this field")]
|
#[rustc_lint_opt_deny_field_access("use `Session::tls_model` instead of this field")]
|
||||||
|
|
|
@ -976,34 +976,10 @@ impl Session {
|
||||||
self.opts.unstable_opts.verbose
|
self.opts.unstable_opts.verbose
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn instrument_mcount(&self) -> bool {
|
|
||||||
self.opts.unstable_opts.instrument_mcount
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn time_passes(&self) -> bool {
|
|
||||||
self.opts.unstable_opts.time_passes
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn time_llvm_passes(&self) -> bool {
|
|
||||||
self.opts.unstable_opts.time_llvm_passes
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn meta_stats(&self) -> bool {
|
|
||||||
self.opts.unstable_opts.meta_stats
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn asm_comments(&self) -> bool {
|
|
||||||
self.opts.unstable_opts.asm_comments
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn verify_llvm_ir(&self) -> bool {
|
pub fn verify_llvm_ir(&self) -> bool {
|
||||||
self.opts.unstable_opts.verify_llvm_ir || option_env!("RUSTC_VERIFY_LLVM_IR").is_some()
|
self.opts.unstable_opts.verify_llvm_ir || option_env!("RUSTC_VERIFY_LLVM_IR").is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_llvm_passes(&self) -> bool {
|
|
||||||
self.opts.unstable_opts.print_llvm_passes
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn binary_dep_depinfo(&self) -> bool {
|
pub fn binary_dep_depinfo(&self) -> bool {
|
||||||
self.opts.unstable_opts.binary_dep_depinfo
|
self.opts.unstable_opts.binary_dep_depinfo
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue