Skip to content

Commit fb79e44

Browse files
committed
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.
1 parent eb9e5e7 commit fb79e44

File tree

8 files changed

+10
-40
lines changed

8 files changed

+10
-40
lines changed

compiler/rustc_codegen_llvm/src/attributes.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ pub fn uwtable_attr(llcx: &llvm::Context) -> &Attribute {
102102

103103
pub fn frame_pointer_type_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> {
104104
let mut fp = cx.sess().target.frame_pointer;
105+
let opts = &cx.sess().opts;
105106
// "mcount" function relies on stack pointer.
106107
// See <https://sourceware.org/binutils/docs/gprof/Implementation.html>.
107-
if cx.sess().instrument_mcount() || matches!(cx.sess().opts.cg.force_frame_pointers, Some(true))
108-
{
108+
if opts.unstable_opts.instrument_mcount || matches!(opts.cg.force_frame_pointers, Some(true)) {
109109
fp = FramePointer::Always;
110110
}
111111
let attr_value = match fp {
@@ -119,7 +119,7 @@ pub fn frame_pointer_type_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attr
119119
/// Tell LLVM what instrument function to insert.
120120
#[inline]
121121
fn instrument_function_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> {
122-
if cx.sess().instrument_mcount() {
122+
if cx.sess().opts.unstable_opts.instrument_mcount {
123123
// Similar to `clang -pg` behavior. Handled by the
124124
// `post-inline-ee-instrument` LLVM pass.
125125

compiler/rustc_codegen_llvm/src/back/write.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ pub fn target_machine_factory(
203203
sess.opts.unstable_opts.trap_unreachable.unwrap_or(sess.target.trap_unreachable);
204204
let emit_stack_size_section = sess.opts.unstable_opts.emit_stack_sizes;
205205

206-
let asm_comments = sess.asm_comments();
206+
let asm_comments = sess.opts.unstable_opts.asm_comments;
207207
let relax_elf_relocations =
208208
sess.opts.unstable_opts.relax_elf_relocations.unwrap_or(sess.target.relax_elf_relocations);
209209

compiler/rustc_codegen_llvm/src/llvm_util.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ unsafe fn configure_llvm(sess: &Session) {
8181
};
8282
// Set the llvm "program name" to make usage and invalid argument messages more clear.
8383
add("rustc -Cllvm-args=\"...\" with", true);
84-
if sess.time_llvm_passes() {
84+
if sess.opts.unstable_opts.time_llvm_passes {
8585
add("-time-passes", false);
8686
}
87-
if sess.print_llvm_passes() {
87+
if sess.opts.unstable_opts.print_llvm_passes {
8888
add("-debug-pass=Structure", false);
8989
}
9090
if sess.target.generate_arange_section

compiler/rustc_codegen_ssa/src/back/write.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1899,7 +1899,7 @@ impl<B: ExtraBackendMethods> OngoingCodegen<B> {
18991899

19001900
// FIXME: time_llvm_passes support - does this use a global context or
19011901
// something?
1902-
if sess.codegen_units() == 1 && sess.time_llvm_passes() {
1902+
if sess.codegen_units() == 1 && sess.opts.unstable_opts.time_llvm_passes {
19031903
self.backend.print_pass_timings()
19041904
}
19051905

compiler/rustc_codegen_ssa/src/base.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
681681
});
682682

683683
let mut total_codegen_time = Duration::new(0, 0);
684-
let start_rss = tcx.sess.time_passes().then(|| get_resident_set_size());
684+
let start_rss = tcx.sess.opts.unstable_opts.time_passes.then(|| get_resident_set_size());
685685

686686
// The non-parallel compiler can only translate codegen units to LLVM IR
687687
// on a single thread, leading to a staircase effect where the N LLVM
@@ -781,7 +781,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
781781

782782
// Since the main thread is sometimes blocked during codegen, we keep track
783783
// -Ztime-passes output manually.
784-
if tcx.sess.time_passes() {
784+
if tcx.sess.opts.unstable_opts.time_passes {
785785
let end_rss = get_resident_set_size();
786786

787787
print_time_passes_entry(

compiler/rustc_metadata/src/rmeta/encoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
713713
let computed_total_bytes: usize = stats.iter().map(|(_, size)| size).sum();
714714
assert_eq!(total_bytes, computed_total_bytes);
715715

716-
if tcx.sess.meta_stats() {
716+
if tcx.sess.opts.unstable_opts.meta_stats {
717717
self.opaque.flush();
718718

719719
// Rewind and re-read all the metadata to count the zero bytes we wrote.

compiler/rustc_session/src/options.rs

-6
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,6 @@ options! {
12141214
"only allow the listed language features to be enabled in code (space separated)"),
12151215
always_encode_mir: bool = (false, parse_bool, [TRACKED],
12161216
"encode MIR of all functions into the crate metadata (default: no)"),
1217-
#[rustc_lint_opt_deny_field_access("use `Session::asm_comments` instead of this field")]
12181217
asm_comments: bool = (false, parse_bool, [TRACKED],
12191218
"generate comments into the assembly (may change behavior) (default: no)"),
12201219
assert_incr_state: Option<String> = (None, parse_opt_string, [UNTRACKED],
@@ -1363,7 +1362,6 @@ options! {
13631362
`=except-unused-generics`
13641363
`=except-unused-functions`
13651364
`=off` (default)"),
1366-
#[rustc_lint_opt_deny_field_access("use `Session::instrument_mcount` instead of this field")]
13671365
instrument_mcount: bool = (false, parse_bool, [TRACKED],
13681366
"insert function instrument code for mcount-based tracing (default: no)"),
13691367
keep_hygiene_data: bool = (false, parse_bool, [UNTRACKED],
@@ -1392,7 +1390,6 @@ options! {
13921390
merge_functions: Option<MergeFunctions> = (None, parse_merge_functions, [TRACKED],
13931391
"control the operation of the MergeFunctions LLVM pass, taking \
13941392
the same values as the target option of the same name"),
1395-
#[rustc_lint_opt_deny_field_access("use `Session::meta_stats` instead of this field")]
13961393
meta_stats: bool = (false, parse_bool, [UNTRACKED],
13971394
"gather metadata statistics (default: no)"),
13981395
mir_emit_retag: bool = (false, parse_bool, [TRACKED],
@@ -1467,7 +1464,6 @@ options! {
14671464
See #77382 and #74551."),
14681465
print_fuel: Option<String> = (None, parse_opt_string, [TRACKED],
14691466
"make rustc print the total optimization fuel used by a crate"),
1470-
#[rustc_lint_opt_deny_field_access("use `Session::print_llvm_passes` instead of this field")]
14711467
print_llvm_passes: bool = (false, parse_bool, [UNTRACKED],
14721468
"print the LLVM optimization passes being run (default: no)"),
14731469
print_mono_items: Option<String> = (None, parse_opt_string, [UNTRACKED],
@@ -1581,10 +1577,8 @@ options! {
15811577
#[rustc_lint_opt_deny_field_access("use `Session::threads` instead of this field")]
15821578
threads: usize = (1, parse_threads, [UNTRACKED],
15831579
"use a thread pool with N threads"),
1584-
#[rustc_lint_opt_deny_field_access("use `Session::time_llvm_passes` instead of this field")]
15851580
time_llvm_passes: bool = (false, parse_bool, [UNTRACKED],
15861581
"measure time of each LLVM pass (default: no)"),
1587-
#[rustc_lint_opt_deny_field_access("use `Session::time_passes` instead of this field")]
15881582
time_passes: bool = (false, parse_bool, [UNTRACKED],
15891583
"measure time of each rustc pass (default: no)"),
15901584
#[rustc_lint_opt_deny_field_access("use `Session::tls_model` instead of this field")]

compiler/rustc_session/src/session.rs

-24
Original file line numberDiff line numberDiff line change
@@ -976,34 +976,10 @@ impl Session {
976976
self.opts.unstable_opts.verbose
977977
}
978978

979-
pub fn instrument_mcount(&self) -> bool {
980-
self.opts.unstable_opts.instrument_mcount
981-
}
982-
983-
pub fn time_passes(&self) -> bool {
984-
self.opts.unstable_opts.time_passes
985-
}
986-
987-
pub fn time_llvm_passes(&self) -> bool {
988-
self.opts.unstable_opts.time_llvm_passes
989-
}
990-
991-
pub fn meta_stats(&self) -> bool {
992-
self.opts.unstable_opts.meta_stats
993-
}
994-
995-
pub fn asm_comments(&self) -> bool {
996-
self.opts.unstable_opts.asm_comments
997-
}
998-
999979
pub fn verify_llvm_ir(&self) -> bool {
1000980
self.opts.unstable_opts.verify_llvm_ir || option_env!("RUSTC_VERIFY_LLVM_IR").is_some()
1001981
}
1002982

1003-
pub fn print_llvm_passes(&self) -> bool {
1004-
self.opts.unstable_opts.print_llvm_passes
1005-
}
1006-
1007983
pub fn binary_dep_depinfo(&self) -> bool {
1008984
self.opts.unstable_opts.binary_dep_depinfo
1009985
}

0 commit comments

Comments
 (0)