about summary refs log tree commit diff
path: root/src/librustc/mir
diff options
context:
space:
mode:
authorEduard Burtescu <edy.burt@gmail.com>2016-10-28 13:55:49 +0300
committerEduard Burtescu <edy.burt@gmail.com>2016-10-28 13:55:49 +0300
commite34792b181ab6af0221c0fb35940b1cc5dc476e1 (patch)
treef30ff4e3b3a569749726c45e2322169ee4ea3cdc /src/librustc/mir
parent36340ba994a8e5b12df70f0889eeb7d58e2705fe (diff)
downloadrust-e34792b181ab6af0221c0fb35940b1cc5dc476e1.tar.gz
rust-e34792b181ab6af0221c0fb35940b1cc5dc476e1.zip
rustc: move the MIR map into TyCtxt.
Diffstat (limited to 'src/librustc/mir')
-rw-r--r--src/librustc/mir/mir_map.rs38
-rw-r--r--src/librustc/mir/mod.rs1
-rw-r--r--src/librustc/mir/transform.rs19
3 files changed, 11 insertions, 47 deletions
diff --git a/src/librustc/mir/mir_map.rs b/src/librustc/mir/mir_map.rs
deleted file mode 100644
index 56355941b57..00000000000
--- a/src/librustc/mir/mir_map.rs
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use dep_graph::{DepGraph, DepNode, DepTrackingMap, DepTrackingMapConfig};
-use hir::def_id::DefId;
-use mir::Mir;
-use std::marker::PhantomData;
-
-pub struct MirMap<'tcx> {
-    pub map: DepTrackingMap<MirMapConfig<'tcx>>,
-}
-
-impl<'tcx> MirMap<'tcx> {
-    pub fn new(graph: DepGraph) -> Self {
-        MirMap {
-            map: DepTrackingMap::new(graph)
-        }
-    }
-}
-
-pub struct MirMapConfig<'tcx> {
-    data: PhantomData<&'tcx ()>
-}
-
-impl<'tcx> DepTrackingMapConfig for MirMapConfig<'tcx> {
-    type Key = DefId;
-    type Value = Mir<'tcx>;
-    fn to_dep_node(key: &DefId) -> DepNode<DefId> {
-        DepNode::Mir(*key)
-    }
-}
diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs
index cda71ac225c..994316d05ec 100644
--- a/src/librustc/mir/mod.rs
+++ b/src/librustc/mir/mod.rs
@@ -37,7 +37,6 @@ pub mod tcx;
 pub mod visit;
 pub mod transform;
 pub mod traversal;
-pub mod mir_map;
 
 macro_rules! newtype_index {
     ($name:ident, $debug_name:expr) => (
diff --git a/src/librustc/mir/transform.rs b/src/librustc/mir/transform.rs
index c6a719abe54..3576ae662a0 100644
--- a/src/librustc/mir/transform.rs
+++ b/src/librustc/mir/transform.rs
@@ -11,7 +11,6 @@
 use dep_graph::DepNode;
 use hir;
 use hir::map::DefPathData;
-use mir::mir_map::MirMap;
 use mir::{Mir, Promoted};
 use ty::TyCtxt;
 use syntax::ast::NodeId;
@@ -85,12 +84,11 @@ pub trait Pass {
     fn disambiguator<'a>(&'a self) -> Option<Box<fmt::Display+'a>> { None }
 }
 
-/// A pass which inspects the whole MirMap.
+/// A pass which inspects the whole Mir map.
 pub trait MirMapPass<'tcx>: Pass {
     fn run_pass<'a>(
         &mut self,
         tcx: TyCtxt<'a, 'tcx, 'tcx>,
-        map: &mut MirMap<'tcx>,
         hooks: &mut [Box<for<'s> MirPassHook<'s>>]);
 }
 
@@ -114,13 +112,18 @@ pub trait MirPass<'tcx>: Pass {
 impl<'tcx, T: MirPass<'tcx>> MirMapPass<'tcx> for T {
     fn run_pass<'a>(&mut self,
                     tcx: TyCtxt<'a, 'tcx, 'tcx>,
-                    map: &mut MirMap<'tcx>,
                     hooks: &mut [Box<for<'s> MirPassHook<'s>>])
     {
-        let def_ids = map.map.keys();
+        let def_ids = tcx.mir_map.borrow().keys();
         for def_id in def_ids {
+            if !def_id.is_local() {
+                continue;
+            }
+
             let _task = tcx.dep_graph.in_task(DepNode::Mir(def_id));
-            let mir = map.map.get_mut(&def_id).unwrap();
+            let mir = &mut tcx.mir_map.borrow()[&def_id].borrow_mut();
+            tcx.dep_graph.write(DepNode::Mir(def_id));
+
             let id = tcx.map.as_local_node_id(def_id).unwrap();
             let src = MirSource::from_node(tcx, id);
 
@@ -163,11 +166,11 @@ impl<'a, 'tcx> Passes {
         passes
     }
 
-    pub fn run_passes(&mut self, tcx: TyCtxt<'a, 'tcx, 'tcx>, map: &mut MirMap<'tcx>) {
+    pub fn run_passes(&mut self, tcx: TyCtxt<'a, 'tcx, 'tcx>) {
         let Passes { ref mut passes, ref mut plugin_passes, ref mut pass_hooks } = *self;
         for pass in plugin_passes.iter_mut().chain(passes.iter_mut()) {
             time(tcx.sess.time_passes(), &*pass.name(),
-                 || pass.run_pass(tcx, map, pass_hooks));
+                 || pass.run_pass(tcx, pass_hooks));
         }
     }