rustc_mir: track inlined callees in SourceScopeData.
This commit is contained in:
parent
708fc0b692
commit
6bc5eafbce
41 changed files with 124 additions and 74 deletions
|
@ -161,7 +161,7 @@ pub struct Body<'tcx> {
|
|||
|
||||
/// A list of source scopes; these are referenced by statements
|
||||
/// and used for debuginfo. Indexed by a `SourceScope`.
|
||||
pub source_scopes: IndexVec<SourceScope, SourceScopeData>,
|
||||
pub source_scopes: IndexVec<SourceScope, SourceScopeData<'tcx>>,
|
||||
|
||||
/// The yield type of the function, if it is a generator.
|
||||
pub yield_ty: Option<Ty<'tcx>>,
|
||||
|
@ -244,7 +244,7 @@ impl<'tcx> Body<'tcx> {
|
|||
pub fn new(
|
||||
source: MirSource<'tcx>,
|
||||
basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>,
|
||||
source_scopes: IndexVec<SourceScope, SourceScopeData>,
|
||||
source_scopes: IndexVec<SourceScope, SourceScopeData<'tcx>>,
|
||||
local_decls: LocalDecls<'tcx>,
|
||||
user_type_annotations: ty::CanonicalUserTypeAnnotations<'tcx>,
|
||||
arg_count: usize,
|
||||
|
@ -1868,11 +1868,16 @@ rustc_index::newtype_index! {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable)]
|
||||
pub struct SourceScopeData {
|
||||
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable)]
|
||||
pub struct SourceScopeData<'tcx> {
|
||||
pub span: Span,
|
||||
pub parent_scope: Option<SourceScope>,
|
||||
|
||||
/// Whether this scope is the root of a scope tree of another body,
|
||||
/// inlined into this body by the MIR inliner.
|
||||
/// `ty::Instance` is the callee, and the `Span` is the call site.
|
||||
pub inlined: Option<(ty::Instance<'tcx>, Span)>,
|
||||
|
||||
/// Crate-local information for this source scope, that can't (and
|
||||
/// needn't) be tracked across crates.
|
||||
pub local_data: ClearCrossCrate<SourceScopeLocalData>,
|
||||
|
|
|
@ -10,7 +10,6 @@ CloneTypeFoldableAndLiftImpls! {
|
|||
FakeReadCause,
|
||||
RetagKind,
|
||||
SourceScope,
|
||||
SourceScopeData,
|
||||
SourceScopeLocalData,
|
||||
UserTypeAnnotationIndex,
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ macro_rules! make_mir_visitor {
|
|||
}
|
||||
|
||||
fn visit_source_scope_data(&mut self,
|
||||
scope_data: & $($mutability)? SourceScopeData) {
|
||||
scope_data: & $($mutability)? SourceScopeData<'tcx>) {
|
||||
self.super_source_scope_data(scope_data);
|
||||
}
|
||||
|
||||
|
@ -317,10 +317,14 @@ macro_rules! make_mir_visitor {
|
|||
}
|
||||
}
|
||||
|
||||
fn super_source_scope_data(&mut self, scope_data: & $($mutability)? SourceScopeData) {
|
||||
fn super_source_scope_data(
|
||||
&mut self,
|
||||
scope_data: & $($mutability)? SourceScopeData<'tcx>,
|
||||
) {
|
||||
let SourceScopeData {
|
||||
span,
|
||||
parent_scope,
|
||||
inlined,
|
||||
local_data: _,
|
||||
} = scope_data;
|
||||
|
||||
|
@ -328,6 +332,31 @@ macro_rules! make_mir_visitor {
|
|||
if let Some(parent_scope) = parent_scope {
|
||||
self.visit_source_scope(parent_scope);
|
||||
}
|
||||
if let Some((callee, callsite_span)) = inlined {
|
||||
let location = START_BLOCK.start_location();
|
||||
|
||||
self.visit_span(callsite_span);
|
||||
|
||||
let ty::Instance { def: callee_def, substs: callee_substs } = callee;
|
||||
match callee_def {
|
||||
ty::InstanceDef::Item(_def_id) => {}
|
||||
|
||||
ty::InstanceDef::Intrinsic(_def_id) |
|
||||
ty::InstanceDef::VtableShim(_def_id) |
|
||||
ty::InstanceDef::ReifyShim(_def_id) |
|
||||
ty::InstanceDef::Virtual(_def_id, _) |
|
||||
ty::InstanceDef::ClosureOnceShim { call_once: _def_id } |
|
||||
ty::InstanceDef::DropGlue(_def_id, None) => {}
|
||||
|
||||
ty::InstanceDef::FnPtrShim(_def_id, ty) |
|
||||
ty::InstanceDef::DropGlue(_def_id, Some(ty)) |
|
||||
ty::InstanceDef::CloneShim(_def_id, ty) => {
|
||||
// FIXME(eddyb) use a better `TyContext` here.
|
||||
self.visit_ty(ty, TyContext::Location(location));
|
||||
}
|
||||
}
|
||||
self.visit_substs(callee_substs, location);
|
||||
}
|
||||
}
|
||||
|
||||
fn super_statement(&mut self,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue