@@ -500,15 +500,32 @@ fn thin_lto(
500
500
let module_name = module_name_to_str ( module_name) ;
501
501
502
502
// 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.
508
508
//
509
509
// (Note that globally, the export set is just the inverse of the
510
510
// import set.)
511
511
//
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
+ //
512
529
// This strategy means we can always save the computed imports as
513
530
// canon: when we reuse the post-ThinLTO version, condition (3.)
514
531
// ensures that the current import set is the same as the previous
@@ -531,13 +548,8 @@ fn thin_lto(
531
548
let imports_all_green = curr_imports
532
549
. iter ( )
533
550
. 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
-
538
551
if imports_all_green
539
552
&& equivalent_as_sets ( prev_imports, curr_imports)
540
- && exports_all_green
541
553
&& equivalent_as_sets ( prev_exports, curr_exports)
542
554
{
543
555
let work_product = green_modules[ module_name] . clone ( ) ;
0 commit comments