diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2017-03-22 18:22:59 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2017-03-22 18:22:59 +0000 |
commit | f7691d8b410dc4ccb4eacb4bf9151f3ee91fd7fe (patch) | |
tree | dc407941b6c9b1227aa5c03741f871bcf6ed7d01 /llvm/lib/LTO/LTOBackend.cpp | |
parent | bdc8bc047d48b7f2e9bfc7eb057df99056e95391 (diff) | |
download | bcm5719-llvm-f7691d8b410dc4ccb4eacb4bf9151f3ee91fd7fe.tar.gz bcm5719-llvm-f7691d8b410dc4ccb4eacb4bf9151f3ee91fd7fe.zip |
IPO: Const correctness for summaries passed into passes.
Pass const qualified summaries into importers and unqualified summaries into
exporters. This lets us const-qualify the summary argument to thinBackend.
Differential Revision: https://reviews.llvm.org/D31230
llvm-svn: 298534
Diffstat (limited to 'llvm/lib/LTO/LTOBackend.cpp')
-rw-r--r-- | llvm/lib/LTO/LTOBackend.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp index 605a32d7331..dcf48e9837b 100644 --- a/llvm/lib/LTO/LTOBackend.cpp +++ b/llvm/lib/LTO/LTOBackend.cpp @@ -223,14 +223,16 @@ static void runNewPMCustomPasses(Module &Mod, TargetMachine *TM, } static void runOldPMPasses(Config &Conf, Module &Mod, TargetMachine *TM, - bool IsThinLTO, ModuleSummaryIndex &CombinedIndex) { + bool IsThinLTO, ModuleSummaryIndex *ExportSummary, + const ModuleSummaryIndex *ImportSummary) { legacy::PassManager passes; passes.add(createTargetTransformInfoWrapperPass(TM->getTargetIRAnalysis())); PassManagerBuilder PMB; PMB.LibraryInfo = new TargetLibraryInfoImpl(Triple(TM->getTargetTriple())); PMB.Inliner = createFunctionInliningPass(); - PMB.Summary = &CombinedIndex; + PMB.ExportSummary = ExportSummary; + PMB.ImportSummary = ImportSummary; // Unconditionally verify input since it is not verified before this // point and has unknown origin. PMB.VerifyInput = true; @@ -247,7 +249,8 @@ static void runOldPMPasses(Config &Conf, Module &Mod, TargetMachine *TM, } bool opt(Config &Conf, TargetMachine *TM, unsigned Task, Module &Mod, - bool IsThinLTO, ModuleSummaryIndex &CombinedIndex) { + bool IsThinLTO, ModuleSummaryIndex *ExportSummary, + const ModuleSummaryIndex *ImportSummary) { // There's still no ThinLTO pipeline hooked up in the new pass manager, // once there is one, we can just remove this. if (LTOUseNewPM && IsThinLTO) @@ -260,7 +263,7 @@ bool opt(Config &Conf, TargetMachine *TM, unsigned Task, Module &Mod, else if (LTOUseNewPM) runNewPMPasses(Mod, TM, Conf.OptLevel); else - runOldPMPasses(Conf, Mod, TM, IsThinLTO, CombinedIndex); + runOldPMPasses(Conf, Mod, TM, IsThinLTO, ExportSummary, ImportSummary); return !Conf.PostOptModuleHook || Conf.PostOptModuleHook(Task, Mod); } @@ -383,7 +386,8 @@ Error lto::backend(Config &C, AddStreamFn AddStream, auto DiagnosticOutputFile = std::move(*DiagFileOrErr); if (!C.CodeGenOnly) { - if (!opt(C, TM.get(), 0, *Mod, /*IsThinLTO=*/false, CombinedIndex)) { + if (!opt(C, TM.get(), 0, *Mod, /*IsThinLTO=*/false, + /*ExportSummary=*/&CombinedIndex, /*ImportSummary=*/nullptr)) { finalizeOptimizationRemarks(std::move(DiagnosticOutputFile)); return Error::success(); } @@ -400,7 +404,7 @@ Error lto::backend(Config &C, AddStreamFn AddStream, } Error lto::thinBackend(Config &Conf, unsigned Task, AddStreamFn AddStream, - Module &Mod, ModuleSummaryIndex &CombinedIndex, + Module &Mod, const ModuleSummaryIndex &CombinedIndex, const FunctionImporter::ImportMapTy &ImportList, const GVSummaryMapTy &DefinedGlobals, MapVector<StringRef, BitcodeModule> &ModuleMap) { @@ -452,7 +456,8 @@ Error lto::thinBackend(Config &Conf, unsigned Task, AddStreamFn AddStream, if (Conf.PostImportModuleHook && !Conf.PostImportModuleHook(Task, Mod)) return Error::success(); - if (!opt(Conf, TM.get(), Task, Mod, /*IsThinLTO=*/true, CombinedIndex)) + if (!opt(Conf, TM.get(), Task, Mod, /*IsThinLTO=*/true, + /*ExportSummary=*/nullptr, /*ImportSummary=*/&CombinedIndex)) return Error::success(); codegen(Conf, TM.get(), AddStream, Task, Mod); |