diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2023-12-14 11:55:35 +1100 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2023-12-15 10:59:32 +1100 |
| commit | bf424c28d2fd9aa7480479c48b6414d6b07c8ebc (patch) | |
| tree | 4e128d14f11bc21e61ad215d332edbf93864e589 /compiler/rustc_mir_transform/src | |
| parent | 3d5d5b7ef89da99bebb976f14cba226246f10306 (diff) | |
| download | rust-bf424c28d2fd9aa7480479c48b6414d6b07c8ebc.tar.gz rust-bf424c28d2fd9aa7480479c48b6414d6b07c8ebc.zip | |
coverage: Don't bother storing the source file in `Instrumentor`
We can just as easily look it up again from the source map and body span when needed.
Diffstat (limited to 'compiler/rustc_mir_transform/src')
| -rw-r--r-- | compiler/rustc_mir_transform/src/coverage/mod.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/compiler/rustc_mir_transform/src/coverage/mod.rs b/compiler/rustc_mir_transform/src/coverage/mod.rs index 75e3f40689c..6c1dc243dea 100644 --- a/compiler/rustc_mir_transform/src/coverage/mod.rs +++ b/compiler/rustc_mir_transform/src/coverage/mod.rs @@ -24,7 +24,7 @@ use rustc_middle::mir::{ use rustc_middle::ty::TyCtxt; use rustc_span::def_id::{DefId, LocalDefId}; use rustc_span::source_map::SourceMap; -use rustc_span::{ExpnKind, SourceFile, Span, Symbol}; +use rustc_span::{ExpnKind, Span, Symbol}; /// Inserts `StatementKind::Coverage` statements that either instrument the binary with injected /// counters, via intrinsic `llvm.instrprof.increment`, and/or inject metadata used during codegen @@ -69,7 +69,6 @@ impl<'tcx> MirPass<'tcx> for InstrumentCoverage { struct Instrumentor<'a, 'tcx> { tcx: TyCtxt<'tcx>, mir_body: &'a mut mir::Body<'tcx>, - source_file: Lrc<SourceFile>, fn_sig_span: Span, body_span: Span, function_source_hash: u64, @@ -109,7 +108,6 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> { Self { tcx, mir_body, - source_file, fn_sig_span, body_span, function_source_hash, @@ -160,9 +158,10 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> { let source_map = self.tcx.sess.source_map(); let body_span = self.body_span; + let source_file = source_map.lookup_source_file(body_span.lo()); use rustc_session::RemapFileNameExt; let file_name = - Symbol::intern(&self.source_file.name.for_codegen(self.tcx.sess).to_string_lossy()); + Symbol::intern(&source_file.name.for_codegen(self.tcx.sess).to_string_lossy()); let mut mappings = Vec::new(); |
