diff options
| author | Teresa Johnson <tejohnson@google.com> | 2019-04-23 18:56:19 +0000 |
|---|---|---|
| committer | Teresa Johnson <tejohnson@google.com> | 2019-04-23 18:56:19 +0000 |
| commit | 867bc3951bff977f930ca2451e9d1d3548587522 (patch) | |
| tree | b1bba0daf98be6c9cb2b85dd9e9fa1070fe903a1 /llvm/lib/Passes/PassBuilder.cpp | |
| parent | 6967da8ffafe094507b153a93c607b95f2ab22a6 (diff) | |
| download | bcm5719-llvm-867bc3951bff977f930ca2451e9d1d3548587522.tar.gz bcm5719-llvm-867bc3951bff977f930ca2451e9d1d3548587522.zip | |
[ThinLTO] Pass down opt level to LTO backend and handle -O0 LTO in new PM
Summary:
The opt level was not being passed down to the ThinLTO backend when
invoked via clang (for distributed ThinLTO).
This exposed an issue where the new PM was asserting if the Thin or
regular LTO backend pipelines were invoked with -O0 (not a new issue,
could be provoked by invoking in-process *LTO backends via linker using
new PM and -O0). Fix this similar to the old PM where -O0 only does the
necessary lowering of type metadata (WPD and LowerTypeTest passes) and
then quits, rather than asserting.
Reviewers: xur
Subscribers: mehdi_amini, inglorion, eraman, hiraditya, steven_wu, dexonsmith, cfe-commits, llvm-commits, pcc
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D61022
llvm-svn: 359025
Diffstat (limited to 'llvm/lib/Passes/PassBuilder.cpp')
| -rw-r--r-- | llvm/lib/Passes/PassBuilder.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp index 32e31cbc0f4..1b4bffc0752 100644 --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -1046,10 +1046,16 @@ ModulePassManager PassBuilder::buildThinLTODefaultPipeline( // // Also, WPD has access to more precise information than ICP and can // devirtualize more effectively, so it should operate on the IR first. + // + // The WPD and LowerTypeTest passes need to run at -O0 to lower type + // metadata and intrinsics. MPM.addPass(WholeProgramDevirtPass(nullptr, ImportSummary)); MPM.addPass(LowerTypeTestsPass(nullptr, ImportSummary)); } + if (Level == O0) + return MPM; + // Force any function attributes we want the rest of the pipeline to observe. MPM.addPass(ForceFunctionAttrsPass()); @@ -1075,9 +1081,16 @@ PassBuilder::buildLTOPreLinkDefaultPipeline(OptimizationLevel Level, ModulePassManager PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level, bool DebugLogging, ModuleSummaryIndex *ExportSummary) { - assert(Level != O0 && "Must request optimizations for the default pipeline!"); ModulePassManager MPM(DebugLogging); + if (Level == O0) { + // The WPD and LowerTypeTest passes need to run at -O0 to lower type + // metadata and intrinsics. + MPM.addPass(WholeProgramDevirtPass(ExportSummary, nullptr)); + MPM.addPass(LowerTypeTestsPass(ExportSummary, nullptr)); + return MPM; + } + if (PGOOpt && PGOOpt->Action == PGOOptions::SampleUse) { // Load sample profile before running the LTO optimization pipeline. MPM.addPass(SampleProfileLoaderPass(PGOOpt->ProfileFile, |

