diff options
| author | Mehdi Amini <mehdi.amini@apple.com> | 2016-04-27 01:46:48 +0000 |
|---|---|---|
| committer | Mehdi Amini <mehdi.amini@apple.com> | 2016-04-27 01:46:48 +0000 |
| commit | e2a65fe5ec93ab4c9671c9655768275973ff3b30 (patch) | |
| tree | 1478a26814c8427a705d216355b0f9fd86fa50d5 | |
| parent | 91929f643e6ec498e5968674f630dff589a83986 (diff) | |
| download | bcm5719-llvm-e2a65fe5ec93ab4c9671c9655768275973ff3b30.tar.gz bcm5719-llvm-e2a65fe5ec93ab4c9671c9655768275973ff3b30.zip | |
Support "preserving" the summary information when using setModule() API in LTOCodeGenerator
From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 267655
| -rw-r--r-- | llvm/include/llvm/LTO/LTOCodeGenerator.h | 1 | ||||
| -rw-r--r-- | llvm/lib/LTO/LTOCodeGenerator.cpp | 9 |
2 files changed, 9 insertions, 1 deletions
diff --git a/llvm/include/llvm/LTO/LTOCodeGenerator.h b/llvm/include/llvm/LTO/LTOCodeGenerator.h index 4f78d27b10d..91b034cd905 100644 --- a/llvm/include/llvm/LTO/LTOCodeGenerator.h +++ b/llvm/include/llvm/LTO/LTOCodeGenerator.h @@ -201,6 +201,7 @@ private: LLVMContext &Context; std::unique_ptr<Module> MergedModule; + bool MainModuleHasSummary = false; std::unique_ptr<Linker> TheLinker; std::unique_ptr<TargetMachine> TargetMach; bool EmitDwarfDebugInfo = false; diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp index 01304641598..8497114f64f 100644 --- a/llvm/lib/LTO/LTOCodeGenerator.cpp +++ b/llvm/lib/LTO/LTOCodeGenerator.cpp @@ -18,6 +18,7 @@ #include "llvm/ADT/Statistic.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Analysis/Passes.h" +#include "llvm/Analysis/ModuleSummaryAnalysis.h" #include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/Analysis/TargetTransformInfo.h" #include "llvm/Bitcode/ReaderWriter.h" @@ -145,6 +146,7 @@ void LTOCodeGenerator::setModule(std::unique_ptr<LTOModule> Mod) { MergedModule = Mod->takeModule(); TheLinker = make_unique<Linker>(*MergedModule); + MainModuleHasSummary = Mod->isThinLTO(); const std::vector<const char*> &Undefs = Mod->getAsmUndefinedRefs(); for (int I = 0, E = Undefs.size(); I != E; ++I) @@ -209,8 +211,13 @@ bool LTOCodeGenerator::writeMergedModules(const char *Path) { return false; } + std::unique_ptr<ModuleSummaryIndex> Index; + if (MainModuleHasSummary) + Index = ModuleSummaryIndexBuilder(MergedModule.get()).takeIndex(); + // write bitcode to it - WriteBitcodeToFile(MergedModule.get(), Out.os(), ShouldEmbedUselists); + WriteBitcodeToFile(MergedModule.get(), Out.os(), ShouldEmbedUselists, + Index.get()); Out.os().close(); if (Out.os().has_error()) { |

