coverageinfo
query needs to use the same MIR as codegen
I ran into an error trying to fix dead block coverage and realized the `coverageinfo` query is getting a different MIR compared to the codegenned MIR, which can sometimes be a problem during mapgen. I changed that query to use the `InstandeDef` (which includes the generic parameter substitutions, prosibly specific to const params) instead of the `DefId` (without unknown/default const substitutions).
This commit is contained in:
parent
31f523ff94
commit
aed8ef5a4d
5 changed files with 8 additions and 19 deletions
|
@ -49,9 +49,9 @@ impl<'tcx> FunctionCoverage<'tcx> {
|
|||
}
|
||||
|
||||
fn create(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>, is_used: bool) -> Self {
|
||||
let coverageinfo = tcx.coverageinfo(instance.def_id());
|
||||
let coverageinfo = tcx.coverageinfo(instance.def);
|
||||
debug!(
|
||||
"FunctionCoverage::new(instance={:?}) has coverageinfo={:?}. is_used={}",
|
||||
"FunctionCoverage::create(instance={:?}) has coverageinfo={:?}. is_used={}",
|
||||
instance, coverageinfo, is_used
|
||||
);
|
||||
Self {
|
||||
|
|
|
@ -31,7 +31,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
bx.add_coverage_counter(instance, id, code_region);
|
||||
}
|
||||
|
||||
let coverageinfo = bx.tcx().coverageinfo(instance.def_id());
|
||||
let coverageinfo = bx.tcx().coverageinfo(instance.def);
|
||||
|
||||
let fn_name = bx.get_pgo_func_name_var(instance);
|
||||
let hash = bx.const_u64(function_source_hash);
|
||||
|
|
|
@ -335,10 +335,9 @@ rustc_queries! {
|
|||
|
||||
/// Returns coverage summary info for a function, after executing the `InstrumentCoverage`
|
||||
/// MIR pass (assuming the -Zinstrument-coverage option is enabled).
|
||||
query coverageinfo(key: DefId) -> mir::CoverageInfo {
|
||||
desc { |tcx| "retrieving coverage info from MIR for `{}`", tcx.def_path_str(key) }
|
||||
query coverageinfo(key: ty::InstanceDef<'tcx>) -> mir::CoverageInfo {
|
||||
desc { |tcx| "retrieving coverage info from MIR for `{}`", tcx.def_path_str(key.def_id()) }
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
cache_on_disk_if { key.is_local() }
|
||||
}
|
||||
|
||||
/// Returns the name of the file that contains the function body, if instrumented for coverage.
|
||||
|
|
|
@ -156,16 +156,6 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> {
|
|||
let fn_sig_span = self.fn_sig_span;
|
||||
let body_span = self.body_span;
|
||||
|
||||
<<<<<<< HEAD
|
||||
debug!(
|
||||
"instrumenting {:?}, fn sig span: {}, body span: {}",
|
||||
def_id,
|
||||
source_map.span_to_diagnostic_string(fn_sig_span),
|
||||
source_map.span_to_diagnostic_string(body_span)
|
||||
);
|
||||
|
||||
=======
|
||||
>>>>>>> 476104d0f54 (Simplified body_span and filtered span code)
|
||||
let mut graphviz_data = debug::GraphvizData::new();
|
||||
let mut debug_used_expressions = debug::UsedExpressions::new();
|
||||
|
||||
|
@ -572,7 +562,7 @@ fn get_body_span<'tcx>(
|
|||
if expn_data.is_root() {
|
||||
break;
|
||||
}
|
||||
if let ExpnKind::Macro{..} = expn_data.kind {
|
||||
if let ExpnKind::Macro { .. } = expn_data.kind {
|
||||
body_span = expn_data.call_site;
|
||||
} else {
|
||||
break;
|
||||
|
|
|
@ -120,8 +120,8 @@ impl CoverageVisitor {
|
|||
}
|
||||
}
|
||||
|
||||
fn coverageinfo<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> CoverageInfo {
|
||||
let mir_body = mir_body(tcx, def_id);
|
||||
fn coverageinfo<'tcx>(tcx: TyCtxt<'tcx>, instance_def: ty::InstanceDef<'tcx>) -> CoverageInfo {
|
||||
let mir_body = tcx.instance_mir(instance_def);
|
||||
|
||||
let mut coverage_visitor = CoverageVisitor {
|
||||
// num_counters always has at least the `ZERO` counter.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue