Skip to content

Commit

Permalink
Move call site of dep_graph_future().
Browse files Browse the repository at this point in the history
`Compiler::register_plugins()` calls `passes::register_plugins()`, which
calls `Compiler::dep_graph_future()`. This is the only way in which a
`passes` function calls a `Compiler` function.

This commit moves the `dep_graph_future()` call out of
`passes::register_plugins()` and into `Compiler::register_plugins()`,
which is a more sensible spot for it. This will delay the loading of the
dep graph slightly -- from the middle of plugin registration to the end
of plugin registration -- but plugin registration is fast enough
(especially compared to expansion) that the impact should be neglible.
  • Loading branch information
nnethercote committed Sep 11, 2019
1 parent cd0c21b commit d264a56
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 0 additions & 4 deletions src/librustc_interface/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ pub struct PluginInfo {
}

pub fn register_plugins<'a>(
compiler: &Compiler,
sess: &'a Session,
cstore: &'a CStore,
mut krate: ast::Crate,
Expand Down Expand Up @@ -261,9 +260,6 @@ pub fn register_plugins<'a>(
});
}

// If necessary, compute the dependency graph (in the background).
compiler.dep_graph_future().ok();

time(sess, "recursion limit", || {
middle::recursion_limit::update_limits(sess, &krate);
});
Expand Down
14 changes: 11 additions & 3 deletions src/librustc_interface/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,21 @@ impl Compiler {
let crate_name = self.crate_name()?.peek().clone();
let krate = self.parse()?.take();

passes::register_plugins(
self,
let result = passes::register_plugins(
self.session(),
self.cstore(),
krate,
&crate_name,
)
);

// Compute the dependency graph (in the background). We want to do
// this as early as possible, to give the DepGraph maximum time to
// load before dep_graph() is called, but it also can't happen
// until after rustc_incremental::prepare_session_directory() is
// called, which happens within passes::register_plugins().
self.dep_graph_future().ok();

result
})
}

Expand Down

0 comments on commit d264a56

Please sign in to comment.