rename from item_mir to optimized_mir
This commit is contained in:
parent
c7023d1c2f
commit
393fa4f1b7
11 changed files with 33 additions and 42 deletions
|
|
@ -333,7 +333,7 @@ impl<'tcx> QueryDescription for queries::const_is_rvalue_promotable_to_static<'t
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> QueryDescription for queries::is_item_mir_available<'tcx> {
|
||||
impl<'tcx> QueryDescription for queries::is_mir_available<'tcx> {
|
||||
fn describe(tcx: TyCtxt, def_id: DefId) -> String {
|
||||
format!("checking if item is mir available: `{}`",
|
||||
tcx.item_path_str(def_id))
|
||||
|
|
@ -770,7 +770,7 @@ define_maps! { <'tcx>
|
|||
|
||||
[] item_body_nested_bodies: metadata_dep_node(DefId) -> Rc<BTreeMap<hir::BodyId, hir::Body>>,
|
||||
[] const_is_rvalue_promotable_to_static: metadata_dep_node(DefId) -> bool,
|
||||
[] is_item_mir_available: metadata_dep_node(DefId) -> bool,
|
||||
[] is_mir_available: metadata_dep_node(DefId) -> bool,
|
||||
}
|
||||
|
||||
fn coherent_trait_dep_node((_, def_id): (CrateNum, DefId)) -> DepNode<DefId> {
|
||||
|
|
|
|||
|
|
@ -2324,18 +2324,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Given the did of an item, returns its (optimized) MIR, borrowed immutably.
|
||||
pub fn item_mir(self, did: DefId) -> &'gcx Mir<'gcx> {
|
||||
self.optimized_mir(did)
|
||||
}
|
||||
|
||||
/// Return the possibly-auto-generated MIR of a (DefId, Subst) pair.
|
||||
pub fn instance_mir(self, instance: ty::InstanceDef<'gcx>)
|
||||
-> &'gcx Mir<'gcx>
|
||||
{
|
||||
match instance {
|
||||
ty::InstanceDef::Item(did) => {
|
||||
self.item_mir(did)
|
||||
self.optimized_mir(did)
|
||||
}
|
||||
ty::InstanceDef::Intrinsic(..) |
|
||||
ty::InstanceDef::FnPtrShim(..) |
|
||||
|
|
@ -2349,16 +2344,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
|
||||
/// Given the DefId of an item, returns its MIR, borrowed immutably.
|
||||
/// Returns None if there is no MIR for the DefId
|
||||
pub fn maybe_item_mir(self, did: DefId) -> Option<&'gcx Mir<'gcx>> {
|
||||
if did.is_local() && !self.mir_keys(LOCAL_CRATE).contains(&did) {
|
||||
return None;
|
||||
pub fn maybe_optimized_mir(self, did: DefId) -> Option<&'gcx Mir<'gcx>> {
|
||||
if self.is_mir_available(did) {
|
||||
Some(self.optimized_mir(did))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
||||
if !did.is_local() && !self.is_item_mir_available(did) {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(self.item_mir(did))
|
||||
}
|
||||
|
||||
/// Get the attributes of a definition.
|
||||
|
|
|
|||
|
|
@ -95,8 +95,8 @@ provide! { <'tcx> tcx, def_id, cdata
|
|||
})
|
||||
}
|
||||
optimized_mir => {
|
||||
let mir = cdata.maybe_get_item_mir(tcx, def_id.index).unwrap_or_else(|| {
|
||||
bug!("get_item_mir: missing MIR for `{:?}`", def_id)
|
||||
let mir = cdata.maybe_get_optimized_mir(tcx, def_id.index).unwrap_or_else(|| {
|
||||
bug!("get_optimized_mir: missing MIR for `{:?}`", def_id)
|
||||
});
|
||||
|
||||
let mir = tcx.alloc_mir(mir);
|
||||
|
|
@ -122,7 +122,7 @@ provide! { <'tcx> tcx, def_id, cdata
|
|||
cdata.entry(def_id.index).ast.expect("const item missing `ast`")
|
||||
.decode(cdata).rvalue_promotable_to_static
|
||||
}
|
||||
is_item_mir_available => {
|
||||
is_mir_available => {
|
||||
!cdata.is_proc_macro(def_id.index) &&
|
||||
cdata.maybe_entry(def_id.index).and_then(|item| item.decode(cdata).mir).is_some()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -779,10 +779,10 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
tcx.alloc_tables(ast.tables.decode((self, tcx)))
|
||||
}
|
||||
|
||||
pub fn maybe_get_item_mir(&self,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
id: DefIndex)
|
||||
-> Option<Mir<'tcx>> {
|
||||
pub fn maybe_get_optimized_mir(&self,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
id: DefIndex)
|
||||
-> Option<Mir<'tcx>> {
|
||||
match self.is_proc_macro(id) {
|
||||
true => None,
|
||||
false => self.entry(id).mir.map(|mir| mir.decode((self, tcx))),
|
||||
|
|
|
|||
|
|
@ -295,7 +295,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
|
|||
predicates: Some(self.encode_predicates(def_id)),
|
||||
|
||||
ast: None,
|
||||
mir: self.encode_mir(def_id),
|
||||
mir: self.encode_optimized_mir(def_id),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -433,7 +433,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
|
|||
predicates: Some(self.encode_predicates(def_id)),
|
||||
|
||||
ast: None,
|
||||
mir: self.encode_mir(def_id),
|
||||
mir: self.encode_optimized_mir(def_id),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -528,7 +528,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
|
|||
} else {
|
||||
None
|
||||
},
|
||||
mir: self.encode_mir(def_id),
|
||||
mir: self.encode_optimized_mir(def_id),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -598,7 +598,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
|
|||
predicates: Some(self.encode_predicates(def_id)),
|
||||
|
||||
ast: ast.map(|body| self.encode_body(body)),
|
||||
mir: if mir { self.encode_mir(def_id) } else { None },
|
||||
mir: if mir { self.encode_optimized_mir(def_id) } else { None },
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -619,10 +619,10 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
|
|||
self.lazy_seq(names.iter().map(|name| name.node))
|
||||
}
|
||||
|
||||
fn encode_mir(&mut self, def_id: DefId) -> Option<Lazy<mir::Mir<'tcx>>> {
|
||||
fn encode_optimized_mir(&mut self, def_id: DefId) -> Option<Lazy<mir::Mir<'tcx>>> {
|
||||
debug!("EntryBuilder::encode_mir({:?})", def_id);
|
||||
if self.tcx.mir_keys(LOCAL_CRATE).contains(&def_id) {
|
||||
let mir = self.tcx.item_mir(def_id);
|
||||
let mir = self.tcx.optimized_mir(def_id);
|
||||
Some(self.lazy(&mir))
|
||||
} else {
|
||||
None
|
||||
|
|
@ -861,15 +861,15 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
|
|||
},
|
||||
mir: match item.node {
|
||||
hir::ItemStatic(..) if self.tcx.sess.opts.debugging_opts.always_encode_mir => {
|
||||
self.encode_mir(def_id)
|
||||
self.encode_optimized_mir(def_id)
|
||||
}
|
||||
hir::ItemConst(..) => self.encode_mir(def_id),
|
||||
hir::ItemConst(..) => self.encode_optimized_mir(def_id),
|
||||
hir::ItemFn(_, _, constness, _, ref generics, _) => {
|
||||
let tps_len = generics.ty_params.len();
|
||||
let needs_inline = tps_len > 0 || attr::requests_inline(&item.attrs);
|
||||
let always_encode_mir = self.tcx.sess.opts.debugging_opts.always_encode_mir;
|
||||
if needs_inline || constness == hir::Constness::Const || always_encode_mir {
|
||||
self.encode_mir(def_id)
|
||||
self.encode_optimized_mir(def_id)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
|
@ -1166,7 +1166,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
|
|||
predicates: None,
|
||||
|
||||
ast: None,
|
||||
mir: self.encode_mir(def_id),
|
||||
mir: self.encode_optimized_mir(def_id),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1192,7 +1192,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
|
|||
predicates: Some(self.encode_predicates(def_id)),
|
||||
|
||||
ast: Some(self.encode_body(body)),
|
||||
mir: self.encode_mir(def_id),
|
||||
mir: self.encode_optimized_mir(def_id),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,12 +38,12 @@ pub fn provide(providers: &mut Providers) {
|
|||
mir_const,
|
||||
mir_validated,
|
||||
optimized_mir,
|
||||
is_item_mir_available,
|
||||
is_mir_available,
|
||||
..*providers
|
||||
};
|
||||
}
|
||||
|
||||
fn is_item_mir_available<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> bool {
|
||||
fn is_mir_available<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> bool {
|
||||
tcx.mir_keys(def_id.krate).contains(&def_id)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
|
|||
loop {
|
||||
local_change = false;
|
||||
while let Some(callsite) = callsites.pop_front() {
|
||||
if !self.tcx.is_item_mir_available(callsite.callee) {
|
||||
if !self.tcx.is_mir_available(callsite.callee) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ pub fn write_mir_graphviz<'a, 'tcx, W>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
{
|
||||
for def_id in dump_mir_def_ids(tcx, single) {
|
||||
let nodeid = tcx.hir.as_local_node_id(def_id).unwrap();
|
||||
let mir = &tcx.item_mir(def_id);
|
||||
let mir = &tcx.optimized_mir(def_id);
|
||||
|
||||
writeln!(w, "digraph Mir_{} {{", nodeid)?;
|
||||
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ pub fn write_mir_pretty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
|
||||
let mut first = true;
|
||||
for def_id in dump_mir_def_ids(tcx, single) {
|
||||
let mir = &tcx.item_mir(def_id);
|
||||
let mir = &tcx.optimized_mir(def_id);
|
||||
|
||||
if first {
|
||||
first = false;
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ pub fn print_mir_stats<'tcx, 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, title: &str) {
|
|||
// about maintaining the dep graph.
|
||||
let _ignore = tcx.dep_graph.in_ignore();
|
||||
for &def_id in tcx.mir_keys(LOCAL_CRATE).iter() {
|
||||
let mir = tcx.item_mir(def_id);
|
||||
let mir = tcx.optimized_mir(def_id);
|
||||
collector.visit_mir(&mir);
|
||||
}
|
||||
collector.print(title);
|
||||
|
|
|
|||
|
|
@ -659,7 +659,7 @@ fn should_trans_locally<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: &Instan
|
|||
// in this crate
|
||||
false
|
||||
} else {
|
||||
if !tcx.is_item_mir_available(def_id) {
|
||||
if !tcx.is_mir_available(def_id) {
|
||||
bug!("Cannot create local trans-item for {:?}", def_id)
|
||||
}
|
||||
true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue