[PATCH] D97414: [ThinLTO] Clean up dead code under -O0
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 24 13:40:26 PST 2021
aeubanks created this revision.
Herald added subscribers: hiraditya, inglorion.
aeubanks requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
We're running into undefined references using ThinLTO with -O0 on
Windows/Chrome. This fixes that.
This matches the legacy PM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D97414
Files:
llvm/lib/Passes/PassBuilder.cpp
llvm/test/Other/new-pm-O0-defaults.ll
Index: llvm/test/Other/new-pm-O0-defaults.ll
===================================================================
--- llvm/test/Other/new-pm-O0-defaults.ll
+++ llvm/test/Other/new-pm-O0-defaults.ll
@@ -35,6 +35,8 @@
; CHECK-PRE-LINK-NEXT: Running pass: CanonicalizeAliasesPass
; CHECK-PRE-LINK-NEXT: Running pass: NameAnonGlobalPass
; CHECK-THINLTO-NEXT: Running pass: Annotation2MetadataPass
+; CHECK-THINLTO-NEXT: Running pass: EliminateAvailableExternallyPass
+; CHECK-THINLTO-NEXT: Running pass: GlobalDCEPass
; CHECK-LTO-NEXT: Running pass: Annotation2MetadataPass
; CHECK-LTO-NEXT: Running pass: WholeProgramDevirtPass
; CHECK-LTO-NEXT: Running analysis: InnerAnalysisManagerProxy
Index: llvm/lib/Passes/PassBuilder.cpp
===================================================================
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -1539,8 +1539,14 @@
MPM.addPass(LowerTypeTestsPass(nullptr, ImportSummary));
}
- if (Level == OptimizationLevel::O0)
+ if (Level == OptimizationLevel::O0) {
+ // Drop available_externally and unreferenced globals. This is necessary
+ // with ThinLTO in order to avoid leaving undefined references to dead
+ // globals in the object file.
+ MPM.addPass(EliminateAvailableExternallyPass());
+ MPM.addPass(GlobalDCEPass());
return MPM;
+ }
// Force any function attributes we want the rest of the pipeline to observe.
MPM.addPass(ForceFunctionAttrsPass());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97414.326193.patch
Type: text/x-patch
Size: 1469 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210224/15619e3e/attachment.bin>
More information about the llvm-commits
mailing list