Skip to content

Commit 25f070d

Browse files
committedApr 21, 2020
Auto merge of #71267 - pnkfelix:issue-71248-dont-need-exports-all-green, r=nagisa
attempt to recover perf by removing `exports_all_green` attempt to recover perf by removing `exports_all_green` flag. cc #71248 (My hypothesis is that my use of this flag was an overly conservative generalization of PR #67020.)
2 parents 073744f + 19e5a65 commit 25f070d

File tree

1 file changed

+22
-10
lines changed
  • src/librustc_codegen_llvm/back

1 file changed

+22
-10
lines changed
 

‎src/librustc_codegen_llvm/back/lto.rs

+22-10
Original file line numberDiff line numberDiff line change
@@ -500,15 +500,32 @@ fn thin_lto(
500500
let module_name = module_name_to_str(module_name);
501501

502502
// If (1.) the module hasn't changed, and (2.) none of the modules
503-
// it imports from nor exports to have changed, *and* (3.) the
504-
// import and export sets themselves have not changed from the
505-
// previous compile when it was last ThinLTO'ed, then we can re-use
506-
// the post-ThinLTO version of the module. Otherwise, freshly
507-
// perform LTO optimization.
503+
// it imports from have changed, *and* (3.) the import and export
504+
// sets themselves have not changed from the previous compile when
505+
// it was last ThinLTO'ed, then we can re-use the post-ThinLTO
506+
// version of the module. Otherwise, freshly perform LTO
507+
// optimization.
508508
//
509509
// (Note that globally, the export set is just the inverse of the
510510
// import set.)
511511
//
512+
// For further justification of why the above is necessary and sufficient,
513+
// see the LLVM blog post on ThinLTO:
514+
//
515+
// http://blog.llvm.org/2016/06/thinlto-scalable-and-incremental-lto.html
516+
//
517+
// which states the following:
518+
//
519+
// ```quote
520+
// any particular ThinLTO backend must be redone iff:
521+
//
522+
// 1. The corresponding (primary) module’s bitcode changed
523+
// 2. The list of imports into or exports from the module changed
524+
// 3. The bitcode for any module being imported from has changed
525+
// 4. Any global analysis result affecting either the primary module
526+
// or anything it imports has changed.
527+
// ```
528+
//
512529
// This strategy means we can always save the computed imports as
513530
// canon: when we reuse the post-ThinLTO version, condition (3.)
514531
// ensures that the current import set is the same as the previous
@@ -531,13 +548,8 @@ fn thin_lto(
531548
let imports_all_green = curr_imports
532549
.iter()
533550
.all(|imported_module| green_modules.contains_key(imported_module));
534-
let exports_all_green = curr_exports
535-
.iter()
536-
.all(|exported_module| green_modules.contains_key(exported_module));
537-
538551
if imports_all_green
539552
&& equivalent_as_sets(prev_imports, curr_imports)
540-
&& exports_all_green
541553
&& equivalent_as_sets(prev_exports, curr_exports)
542554
{
543555
let work_product = green_modules[module_name].clone();

0 commit comments

Comments
 (0)
Please sign in to comment.