diff options
| author | bors <bors@rust-lang.org> | 2018-09-03 13:59:57 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-09-03 13:59:57 +0000 |
| commit | ee73f80dc963707df3b3da82976556d64cac5752 (patch) | |
| tree | 95b4ebd6c5b993d4c4c4ab8d3ce4b2c3913fad84 /src/librustc | |
| parent | 591a17d3d90d6cab51200a0e696f0d8ca63c2f87 (diff) | |
| parent | 21d05f64aa10fd15208bd6d96599275b044a0636 (diff) | |
| download | rust-ee73f80dc963707df3b3da82976556d64cac5752.tar.gz rust-ee73f80dc963707df3b3da82976556d64cac5752.zip | |
Auto merge of #53673 - michaelwoerister:incr-thinlto-2000, r=alexcrichton
Enable ThinLTO with incremental compilation. This is an updated version of #52309. This PR allows `rustc` to use (local) ThinLTO and incremental compilation at the same time. In theory this should allow for getting compile-time improvements for small changes while keeping the runtime performance of the generated code roughly the same as when compiling non-incrementally. The difference to #52309 is that this version also caches the pre-LTO version of LLVM bitcode. This allows for another layer of caching: 1. if the module itself has changed, we have to re-codegen and re-optimize. 2. if the module itself has not changed, but a module it imported from during ThinLTO has, we don't need to re-codegen and don't need to re-run the first optimization phase. Only the second (i.e. ThinLTO-) optimization phase is re-run. 3. if neither the module itself nor any of its imports have changed then we can re-use the final, post-ThinLTO version of the module. (We might have to load its pre-ThinLTO version though so it's available for other modules to import from)
Diffstat (limited to 'src/librustc')
| -rw-r--r-- | src/librustc/dep_graph/graph.rs | 2 | ||||
| -rw-r--r-- | src/librustc/session/config.rs | 2 | ||||
| -rw-r--r-- | src/librustc/session/mod.rs | 19 | ||||
| -rw-r--r-- | src/librustc/ty/query/config.rs | 6 | ||||
| -rw-r--r-- | src/librustc/ty/query/mod.rs | 3 |
5 files changed, 15 insertions, 17 deletions
diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs index a2853996571..4df0fc443a2 100644 --- a/src/librustc/dep_graph/graph.rs +++ b/src/librustc/dep_graph/graph.rs @@ -878,7 +878,7 @@ pub struct WorkProduct { pub saved_files: Vec<(WorkProductFileKind, String)>, } -#[derive(Clone, Copy, Debug, RustcEncodable, RustcDecodable)] +#[derive(Clone, Copy, Debug, RustcEncodable, RustcDecodable, PartialEq)] pub enum WorkProductFileKind { Object, Bytecode, diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index ee683e37648..ee3fabc58d5 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -68,7 +68,7 @@ pub enum OptLevel { SizeMin, // -Oz } -#[derive(Clone, Copy, PartialEq, Hash)] +#[derive(Clone, Copy, PartialEq, Hash, Debug)] pub enum Lto { /// Don't do any LTO whatsoever No, diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 00c5369e064..778c388c7de 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -580,11 +580,6 @@ impl Session { return config::Lto::No; } - // Right now ThinLTO isn't compatible with incremental compilation. - if self.opts.incremental.is_some() { - return config::Lto::No; - } - // Now we're in "defaults" territory. By default we enable ThinLTO for // optimized compiles (anything greater than O0). match self.opts.optimize { @@ -1177,8 +1172,18 @@ pub fn build_session_( // commandline argument, you can do so here. fn validate_commandline_args_with_session_available(sess: &Session) { - if sess.lto() != Lto::No && sess.opts.incremental.is_some() { - sess.err("can't perform LTO when compiling incrementally"); + if sess.opts.incremental.is_some() { + match sess.lto() { + Lto::Yes | + Lto::Thin | + Lto::Fat => { + sess.err("can't perform LTO when compiling incrementally"); + } + Lto::ThinLocal | + Lto::No => { + // This is fine + } + } } // Since we don't know if code in an rlib will be linked to statically or diff --git a/src/librustc/ty/query/config.rs b/src/librustc/ty/query/config.rs index d32580181f8..837354bfcaf 100644 --- a/src/librustc/ty/query/config.rs +++ b/src/librustc/ty/query/config.rs @@ -716,12 +716,6 @@ impl<'tcx> QueryDescription<'tcx> for queries::codegen_unit<'tcx> { } } -impl<'tcx> QueryDescription<'tcx> for queries::compile_codegen_unit<'tcx> { - fn describe(_tcx: TyCtxt, _: InternedString) -> String { - "compile_codegen_unit".to_string() - } -} - impl<'tcx> QueryDescription<'tcx> for queries::output_filenames<'tcx> { fn describe(_tcx: TyCtxt, _: CrateNum) -> String { "output_filenames".to_string() diff --git a/src/librustc/ty/query/mod.rs b/src/librustc/ty/query/mod.rs index 88f599971c7..993ba2fd13d 100644 --- a/src/librustc/ty/query/mod.rs +++ b/src/librustc/ty/query/mod.rs @@ -28,7 +28,7 @@ use middle::lib_features::LibFeatures; use middle::lang_items::{LanguageItems, LangItem}; use middle::exported_symbols::{SymbolExportLevel, ExportedSymbol}; use mir::interpret::ConstEvalResult; -use mir::mono::{CodegenUnit, Stats}; +use mir::mono::CodegenUnit; use mir; use mir::interpret::GlobalId; use session::{CompileResult, CrateDisambiguator}; @@ -525,7 +525,6 @@ define_queries! { <'tcx> -> (Arc<DefIdSet>, Arc<Vec<Arc<CodegenUnit<'tcx>>>>), [] fn is_codegened_item: IsCodegenedItem(DefId) -> bool, [] fn codegen_unit: CodegenUnit(InternedString) -> Arc<CodegenUnit<'tcx>>, - [] fn compile_codegen_unit: CompileCodegenUnit(InternedString) -> Stats, }, Other { |
