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.
This commit is contained in:
parent
3d5d5b7ef8
commit
bf424c28d2
@ -24,7 +24,7 @@
|
|||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
use rustc_span::def_id::{DefId, LocalDefId};
|
use rustc_span::def_id::{DefId, LocalDefId};
|
||||||
use rustc_span::source_map::SourceMap;
|
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
|
/// Inserts `StatementKind::Coverage` statements that either instrument the binary with injected
|
||||||
/// counters, via intrinsic `llvm.instrprof.increment`, and/or inject metadata used during codegen
|
/// counters, via intrinsic `llvm.instrprof.increment`, and/or inject metadata used during codegen
|
||||||
@ -69,7 +69,6 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, mir_body: &mut mir::Body<'tcx>) {
|
|||||||
struct Instrumentor<'a, 'tcx> {
|
struct Instrumentor<'a, 'tcx> {
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
mir_body: &'a mut mir::Body<'tcx>,
|
mir_body: &'a mut mir::Body<'tcx>,
|
||||||
source_file: Lrc<SourceFile>,
|
|
||||||
fn_sig_span: Span,
|
fn_sig_span: Span,
|
||||||
body_span: Span,
|
body_span: Span,
|
||||||
function_source_hash: u64,
|
function_source_hash: u64,
|
||||||
@ -109,7 +108,6 @@ fn new(tcx: TyCtxt<'tcx>, mir_body: &'a mut mir::Body<'tcx>) -> Self {
|
|||||||
Self {
|
Self {
|
||||||
tcx,
|
tcx,
|
||||||
mir_body,
|
mir_body,
|
||||||
source_file,
|
|
||||||
fn_sig_span,
|
fn_sig_span,
|
||||||
body_span,
|
body_span,
|
||||||
function_source_hash,
|
function_source_hash,
|
||||||
@ -160,9 +158,10 @@ fn create_mappings_and_inject_coverage_statements(
|
|||||||
let source_map = self.tcx.sess.source_map();
|
let source_map = self.tcx.sess.source_map();
|
||||||
let body_span = self.body_span;
|
let body_span = self.body_span;
|
||||||
|
|
||||||
|
let source_file = source_map.lookup_source_file(body_span.lo());
|
||||||
use rustc_session::RemapFileNameExt;
|
use rustc_session::RemapFileNameExt;
|
||||||
let file_name =
|
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();
|
let mut mappings = Vec::new();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user