Skip to content

Commit 907f4fd

Browse files
authored
Rollup merge of #61297 - eddyb:forsaken-stats, r=nagisa
Remove LLVM instruction stats and other (obsolete) codegen stats. Both `-Z count_llvm_insns` and `-Z codegen-stats` are removed, as (AFAIK) they have been of little use in the last few years, especially after the transition to MIR->LLVM codegen. Other than for the LLVM instruction counts, `-Z codegen-stats` has long been obsoleted anyway. r? @nagisa cc @rust-lang/compiler
2 parents 3013c0b + 7fa97c0 commit 907f4fd

File tree

10 files changed

+23
-282
lines changed

10 files changed

+23
-282
lines changed

src/librustc/mir/mono.rs

-43
Original file line numberDiff line numberDiff line change
@@ -188,49 +188,6 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for CodegenUnit<'tcx> {
188188
}
189189
}
190190

191-
#[derive(Clone, Default)]
192-
pub struct Stats {
193-
pub n_glues_created: usize,
194-
pub n_null_glues: usize,
195-
pub n_real_glues: usize,
196-
pub n_fns: usize,
197-
pub n_inlines: usize,
198-
pub n_closures: usize,
199-
pub n_llvm_insns: usize,
200-
pub llvm_insns: FxHashMap<String, usize>,
201-
// (ident, llvm-instructions)
202-
pub fn_stats: Vec<(String, usize)>,
203-
}
204-
205-
impl_stable_hash_for!(struct self::Stats {
206-
n_glues_created,
207-
n_null_glues,
208-
n_real_glues,
209-
n_fns,
210-
n_inlines,
211-
n_closures,
212-
n_llvm_insns,
213-
llvm_insns,
214-
fn_stats
215-
});
216-
217-
impl Stats {
218-
pub fn extend(&mut self, stats: Stats) {
219-
self.n_glues_created += stats.n_glues_created;
220-
self.n_null_glues += stats.n_null_glues;
221-
self.n_real_glues += stats.n_real_glues;
222-
self.n_fns += stats.n_fns;
223-
self.n_inlines += stats.n_inlines;
224-
self.n_closures += stats.n_closures;
225-
self.n_llvm_insns += stats.n_llvm_insns;
226-
227-
for (k, v) in stats.llvm_insns {
228-
*self.llvm_insns.entry(k).or_insert(0) += v;
229-
}
230-
self.fn_stats.extend(stats.fn_stats);
231-
}
232-
}
233-
234191
pub struct CodegenUnitNameBuilder<'a, 'gcx: 'tcx, 'tcx: 'a> {
235192
tcx: TyCtxt<'a, 'gcx, 'tcx>,
236193
cache: FxHashMap<CrateNum, String>,

src/librustc/session/config.rs

-13
Original file line numberDiff line numberDiff line change
@@ -1216,21 +1216,12 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
12161216
"measure time of each rustc pass"),
12171217
time: bool = (false, parse_bool, [UNTRACKED],
12181218
"measure time of rustc processes"),
1219-
count_llvm_insns: bool = (false, parse_bool,
1220-
[UNTRACKED_WITH_WARNING(true,
1221-
"The output generated by `-Z count_llvm_insns` might not be reliable \
1222-
when used with incremental compilation")],
1223-
"count where LLVM instrs originate"),
12241219
time_llvm_passes: bool = (false, parse_bool, [UNTRACKED_WITH_WARNING(true,
12251220
"The output of `-Z time-llvm-passes` will only reflect timings of \
12261221
re-codegened modules when used with incremental compilation" )],
12271222
"measure time of each LLVM pass"),
12281223
input_stats: bool = (false, parse_bool, [UNTRACKED],
12291224
"gather statistics about the input"),
1230-
codegen_stats: bool = (false, parse_bool, [UNTRACKED_WITH_WARNING(true,
1231-
"The output of `-Z codegen-stats` might not be accurate when incremental \
1232-
compilation is enabled")],
1233-
"gather codegen statistics"),
12341225
asm_comments: bool = (false, parse_bool, [TRACKED],
12351226
"generate comments into the assembly (may change behavior)"),
12361227
verify_llvm_ir: bool = (false, parse_bool, [TRACKED],
@@ -3259,14 +3250,10 @@ mod tests {
32593250
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
32603251
opts.debugging_opts.time_passes = true;
32613252
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
3262-
opts.debugging_opts.count_llvm_insns = true;
3263-
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
32643253
opts.debugging_opts.time_llvm_passes = true;
32653254
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
32663255
opts.debugging_opts.input_stats = true;
32673256
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
3268-
opts.debugging_opts.codegen_stats = true;
3269-
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
32703257
opts.debugging_opts.borrowck_stats = true;
32713258
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
32723259
opts.debugging_opts.meta_stats = true;

src/librustc/session/mod.rs

-6
Original file line numberDiff line numberDiff line change
@@ -519,15 +519,9 @@ impl Session {
519519
pub fn instrument_mcount(&self) -> bool {
520520
self.opts.debugging_opts.instrument_mcount
521521
}
522-
pub fn count_llvm_insns(&self) -> bool {
523-
self.opts.debugging_opts.count_llvm_insns
524-
}
525522
pub fn time_llvm_passes(&self) -> bool {
526523
self.opts.debugging_opts.time_llvm_passes
527524
}
528-
pub fn codegen_stats(&self) -> bool {
529-
self.opts.debugging_opts.codegen_stats
530-
}
531525
pub fn meta_stats(&self) -> bool {
532526
self.opts.debugging_opts.meta_stats
533527
}

src/librustc_codegen_llvm/base.rs

+15-19
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use crate::common;
2424
use crate::context::CodegenCx;
2525
use crate::monomorphize::partitioning::CodegenUnitExt;
2626
use rustc::dep_graph;
27-
use rustc::mir::mono::{Linkage, Visibility, Stats};
27+
use rustc::mir::mono::{Linkage, Visibility};
2828
use rustc::middle::cstore::{EncodedMetadata};
2929
use rustc::ty::TyCtxt;
3030
use rustc::middle::exported_symbols;
@@ -104,17 +104,17 @@ pub fn iter_globals(llmod: &'ll llvm::Module) -> ValueIter<'ll> {
104104
}
105105
}
106106

107-
pub fn compile_codegen_unit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
108-
cgu_name: InternedString)
109-
-> Stats {
107+
pub fn compile_codegen_unit(tcx: TyCtxt<'a, 'tcx, 'tcx>, cgu_name: InternedString) {
110108
let start_time = Instant::now();
111109

112110
let dep_node = tcx.codegen_unit(cgu_name).codegen_dep_node(tcx);
113-
let ((stats, module), _) = tcx.dep_graph.with_task(dep_node,
114-
tcx,
115-
cgu_name,
116-
module_codegen,
117-
dep_graph::hash_result);
111+
let (module, _) = tcx.dep_graph.with_task(
112+
dep_node,
113+
tcx,
114+
cgu_name,
115+
module_codegen,
116+
dep_graph::hash_result,
117+
);
118118
let time_to_codegen = start_time.elapsed();
119119

120120
// We assume that the cost to run LLVM on a CGU is proportional to
@@ -123,17 +123,15 @@ pub fn compile_codegen_unit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
123123
time_to_codegen.subsec_nanos() as u64;
124124

125125
submit_codegened_module_to_llvm(&LlvmCodegenBackend(()), tcx, module, cost);
126-
return stats;
127126

128127
fn module_codegen<'ll, 'tcx>(
129128
tcx: TyCtxt<'ll, 'tcx, 'tcx>,
130-
cgu_name: InternedString)
131-
-> (Stats, ModuleCodegen<ModuleLlvm>)
132-
{
129+
cgu_name: InternedString,
130+
) -> ModuleCodegen<ModuleLlvm> {
133131
let cgu = tcx.codegen_unit(cgu_name);
134132
// Instantiate monomorphizations without filling out definitions yet...
135133
let llvm_module = ModuleLlvm::new(tcx, &cgu_name.as_str());
136-
let stats = {
134+
{
137135
let cx = CodegenCx::new(tcx, cgu, &llvm_module);
138136
let mono_items = cx.codegen_unit
139137
.items_in_deterministic_order(cx.tcx);
@@ -169,15 +167,13 @@ pub fn compile_codegen_unit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
169167
if cx.sess().opts.debuginfo != DebugInfo::None {
170168
cx.debuginfo_finalize();
171169
}
170+
}
172171

173-
cx.consume_stats().into_inner()
174-
};
175-
176-
(stats, ModuleCodegen {
172+
ModuleCodegen {
177173
name: cgu_name.to_string(),
178174
module_llvm: llvm_module,
179175
kind: ModuleKind::Regular,
180-
})
176+
}
181177
}
182178
}
183179

0 commit comments

Comments
 (0)