]> git.lizzy.rs Git - rust.git/commitdiff
Add dep-graph tasks where needed
authorJames Miller <james@aatch.net>
Wed, 8 Feb 2017 17:31:47 +0000 (06:31 +1300)
committerEduard-Mihai Burtescu <edy.burt@gmail.com>
Fri, 10 Mar 2017 01:54:38 +0000 (03:54 +0200)
src/librustc_mir/transform/inline.rs

index 4b8e2bf49b9ee5f790b99496a1037c34210469e7..4b4bd44230163d56e97174c88f292ac9572b58da 100644 (file)
@@ -27,7 +27,7 @@
 
 use super::simplify::{remove_dead_blocks, CfgSimplifier};
 
-use syntax::attr;
+use syntax::{attr};
 use syntax::abi::Abi;
 
 use callgraph;
@@ -184,6 +184,9 @@ fn inline_scc(&mut self, callgraph: &callgraph::CallGraph, scc: &[graph::NodeInd
                 let callsite = callsites[csi];
                 csi += 1;
 
+                let _task = self.tcx.dep_graph.in_task(DepNode::Mir(callsite.caller));
+                self.tcx.dep_graph.write(DepNode::Mir(callsite.caller));
+
                 let callee_mir = {
                     if let Some(callee_mir) = self.tcx.maybe_item_mir(callsite.callee) {
                         if !self.should_inline(callsite, &callee_mir) {
@@ -232,7 +235,6 @@ fn inline_scc(&mut self, callgraph: &callgraph::CallGraph, scc: &[graph::NodeInd
                     }
                 }
 
-
                 csi -= 1;
                 if scc.len() == 1 {
                     callsites.swap_remove(csi);
@@ -251,6 +253,9 @@ fn inline_scc(&mut self, callgraph: &callgraph::CallGraph, scc: &[graph::NodeInd
 
         // Simplify functions we inlined into.
         for def_id in inlined_into {
+            let _task = self.tcx.dep_graph.in_task(DepNode::Mir(def_id));
+            self.tcx.dep_graph.write(DepNode::Mir(def_id));
+
             let mut caller_mir = {
                 let map = self.tcx.maps.mir.borrow();
                 let mir = map.get(&def_id).unwrap();
@@ -275,11 +280,6 @@ fn should_inline(&self, callsite: CallSite<'tcx>,
             return false;
         }
 
-        // Don't inline calls to trait methods
-        // FIXME: Should try to resolve it to a concrete method, and
-        // only bail if that isn't possible
-        let trait_def = tcx.trait_of_item(callsite.callee);
-        if trait_def.is_some() { return false; }
 
         let attrs = tcx.get_attrs(callsite.callee);
         let hint = attr::find_inline_attr(None, &attrs[..]);
@@ -294,19 +294,13 @@ fn should_inline(&self, callsite: CallSite<'tcx>,
             attr::InlineAttr::None => false,
         };
 
-        // Only inline local functions if they would be eligible for
-        // cross-crate inlining. This ensures that any symbols they
-        // use are reachable cross-crate
-        // FIXME(#36594): This shouldn't be necessary, and is more conservative
-        // than it could be, but trans should generate the reachable set from
-        // the MIR anyway, making any check obsolete.
+        // Only inline local functions if they would be eligible for cross-crate
+        // inlining. This is to ensure that the final crate doesn't have MIR that
+        // reference unexported symbols
         if callsite.callee.is_local() {
-            // No type substs and no inline hint means this function
-            // wouldn't be eligible for cross-crate inlining
             if callsite.substs.types().count() == 0 && !hinted {
                 return false;
             }
-
         }
 
         let mut threshold = if hinted {