}
}
-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))
[] 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> {
}
}
- /// 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(..) |
/// 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;
- }
-
- if !did.is_local() && !self.is_item_mir_available(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
}
-
- Some(self.item_mir(did))
}
/// Get the attributes of a definition.
})
}
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);
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()
}
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))),
predicates: Some(self.encode_predicates(def_id)),
ast: None,
- mir: self.encode_mir(def_id),
+ mir: self.encode_optimized_mir(def_id),
}
}
predicates: Some(self.encode_predicates(def_id)),
ast: None,
- mir: self.encode_mir(def_id),
+ mir: self.encode_optimized_mir(def_id),
}
}
} else {
None
},
- mir: self.encode_mir(def_id),
+ mir: self.encode_optimized_mir(def_id),
}
}
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 },
}
}
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
},
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
}
predicates: None,
ast: None,
- mir: self.encode_mir(def_id),
+ mir: self.encode_optimized_mir(def_id),
}
}
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),
}
}
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)
}
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;
}
{
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)?;
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;
// 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);
// 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