Skip to content

Commit f55e92b

Browse files
Aatcheddyb
authored andcommitted
Add dep-graph tasks where needed
1 parent 71d0d92 commit f55e92b

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

src/librustc_mir/transform/inline.rs

+10-16
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use rustc::util::nodemap::{DefIdSet};
2727

2828
use super::simplify::{remove_dead_blocks, CfgSimplifier};
2929

30-
use syntax::attr;
30+
use syntax::{attr};
3131
use syntax::abi::Abi;
3232

3333
use callgraph;
@@ -184,6 +184,9 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
184184
let callsite = callsites[csi];
185185
csi += 1;
186186

187+
let _task = self.tcx.dep_graph.in_task(DepNode::Mir(callsite.caller));
188+
self.tcx.dep_graph.write(DepNode::Mir(callsite.caller));
189+
187190
let callee_mir = {
188191
if let Some(callee_mir) = self.tcx.maybe_item_mir(callsite.callee) {
189192
if !self.should_inline(callsite, &callee_mir) {
@@ -232,7 +235,6 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
232235
}
233236
}
234237

235-
236238
csi -= 1;
237239
if scc.len() == 1 {
238240
callsites.swap_remove(csi);
@@ -251,6 +253,9 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
251253

252254
// Simplify functions we inlined into.
253255
for def_id in inlined_into {
256+
let _task = self.tcx.dep_graph.in_task(DepNode::Mir(def_id));
257+
self.tcx.dep_graph.write(DepNode::Mir(def_id));
258+
254259
let mut caller_mir = {
255260
let map = self.tcx.maps.mir.borrow();
256261
let mir = map.get(&def_id).unwrap();
@@ -275,11 +280,6 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
275280
return false;
276281
}
277282

278-
// Don't inline calls to trait methods
279-
// FIXME: Should try to resolve it to a concrete method, and
280-
// only bail if that isn't possible
281-
let trait_def = tcx.trait_of_item(callsite.callee);
282-
if trait_def.is_some() { return false; }
283283

284284
let attrs = tcx.get_attrs(callsite.callee);
285285
let hint = attr::find_inline_attr(None, &attrs[..]);
@@ -294,19 +294,13 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
294294
attr::InlineAttr::None => false,
295295
};
296296

297-
// Only inline local functions if they would be eligible for
298-
// cross-crate inlining. This ensures that any symbols they
299-
// use are reachable cross-crate
300-
// FIXME(#36594): This shouldn't be necessary, and is more conservative
301-
// than it could be, but trans should generate the reachable set from
302-
// the MIR anyway, making any check obsolete.
297+
// Only inline local functions if they would be eligible for cross-crate
298+
// inlining. This is to ensure that the final crate doesn't have MIR that
299+
// reference unexported symbols
303300
if callsite.callee.is_local() {
304-
// No type substs and no inline hint means this function
305-
// wouldn't be eligible for cross-crate inlining
306301
if callsite.substs.types().count() == 0 && !hinted {
307302
return false;
308303
}
309-
310304
}
311305

312306
let mut threshold = if hinted {

0 commit comments

Comments
 (0)