rename from item_mir to optimized_mir

This commit is contained in:
Niko Matsakis
2017-05-02 06:08:13 -04:00
parent c7023d1c2f
commit 393fa4f1b7
11 changed files with 33 additions and 42 deletions
+2 -2
View File
@@ -333,7 +333,7 @@ fn describe(tcx: TyCtxt, def_id: DefId) -> String {
}
}
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 @@ fn default() -> Self {
[] 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> {
+6 -15
View File
@@ -2324,18 +2324,13 @@ pub fn item_name(self, id: DefId) -> ast::Name {
}
}
/// 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 @@ pub fn instance_mir(self, instance: ty::InstanceDef<'gcx>)
/// 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.
+3 -3
View File
@@ -95,8 +95,8 @@ pub fn provide<$lt>(providers: &mut Providers<$lt>) {
})
}
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 @@ pub fn provide<$lt>(providers: &mut Providers<$lt>) {
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()
}
+4 -4
View File
@@ -779,10 +779,10 @@ pub fn item_body_tables(&self,
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))),
+11 -11
View File
@@ -295,7 +295,7 @@ fn encode_enum_variant_info(&mut self,
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 @@ fn encode_struct_ctor(&mut self, (adt_def_id, def_id): (DefId, DefId)) -> Entry<
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 @@ fn encode_info_for_trait_item(&mut self, def_id: DefId) -> Entry<'tcx> {
} else {
None
},
mir: self.encode_mir(def_id),
mir: self.encode_optimized_mir(def_id),
}
}
@@ -598,7 +598,7 @@ fn encode_info_for_impl_item(&mut self, def_id: DefId) -> Entry<'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 @@ fn encode_fn_arg_names(&mut self, names: &[Spanned<ast::Name>])
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 @@ fn encode_info_for_item(&mut self, (def_id, item): (DefId, &'tcx hir::Item)) ->
},
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 @@ fn encode_info_for_closure(&mut self, def_id: DefId) -> Entry<'tcx> {
predicates: None,
ast: None,
mir: self.encode_mir(def_id),
mir: self.encode_optimized_mir(def_id),
}
}
@@ -1192,7 +1192,7 @@ fn encode_info_for_embedded_const(&mut self, def_id: DefId) -> Entry<'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),
}
}
+2 -2
View File
@@ -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)
}
+1 -1
View File
@@ -104,7 +104,7 @@ fn run_pass(&self, caller_mir: &mut Mir<'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;
}
+1 -1
View File
@@ -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)?;
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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);
+1 -1
View File
@@ -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