summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2016-12-01 05:52:32 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2016-12-01 05:52:32 +0000
commitdac43b49bd941f4ef44ee2f5284d3e9f61b0db13 (patch)
tree529edb0d6cf53d46ce7f0f62879c148529fb2c41 /llvm/lib
parentcf2750a501da4bc44d89a606c6be4fe23f0b115d (diff)
downloadbcm5719-llvm-dac43b49bd941f4ef44ee2f5284d3e9f61b0db13.tar.gz
bcm5719-llvm-dac43b49bd941f4ef44ee2f5284d3e9f61b0db13.zip
LTO: Remove ModuleLoader, make loadModuleFromBuffer static and move into its only client, ThinLTOCodeGenerator.
This is no longer the recommended way to load modules for importing, so it should not be public API. Differential Revision: https://reviews.llvm.org/D27292 llvm-svn: 288316
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/LTO/LTO.cpp20
-rw-r--r--llvm/lib/LTO/ThinLTOCodeGenerator.cpp25
2 files changed, 24 insertions, 21 deletions
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp
index 4256704f906..c8587465e4b 100644
--- a/llvm/lib/LTO/LTO.cpp
+++ b/llvm/lib/LTO/LTO.cpp
@@ -99,26 +99,6 @@ static void computeCacheKey(
Key = toHex(Hasher.result());
}
-// Simple helper to load a module from bitcode
-std::unique_ptr<Module>
-llvm::loadModuleFromBuffer(const MemoryBufferRef &Buffer, LLVMContext &Context,
- bool Lazy) {
- SMDiagnostic Err;
- Expected<std::unique_ptr<Module>> ModuleOrErr =
- Lazy ? getLazyBitcodeModule(Buffer, Context,
- /* ShouldLazyLoadMetadata */ true)
- : parseBitcodeFile(Buffer, Context);
- if (!ModuleOrErr) {
- handleAllErrors(ModuleOrErr.takeError(), [&](ErrorInfoBase &EIB) {
- SMDiagnostic Err = SMDiagnostic(Buffer.getBufferIdentifier(),
- SourceMgr::DK_Error, EIB.message());
- Err.print("ThinLTO", errs());
- });
- report_fatal_error("Can't load module, abort.");
- }
- return std::move(ModuleOrErr.get());
-}
-
static void thinLTOResolveWeakForLinkerGUID(
GlobalValueSummaryList &GVSummaryList, GlobalValue::GUID GUID,
DenseSet<GlobalValueSummary *> &GlobalInvolvedWithAlias,
diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
index fdb54ee3eb8..2a75b8bbef7 100644
--- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
@@ -162,11 +162,34 @@ static void promoteModule(Module &TheModule, const ModuleSummaryIndex &Index) {
report_fatal_error("renameModuleForThinLTO failed");
}
+static std::unique_ptr<Module>
+loadModuleFromBuffer(const MemoryBufferRef &Buffer, LLVMContext &Context,
+ bool Lazy) {
+ SMDiagnostic Err;
+ Expected<std::unique_ptr<Module>> ModuleOrErr =
+ Lazy ? getLazyBitcodeModule(Buffer, Context,
+ /* ShouldLazyLoadMetadata */ true)
+ : parseBitcodeFile(Buffer, Context);
+ if (!ModuleOrErr) {
+ handleAllErrors(ModuleOrErr.takeError(), [&](ErrorInfoBase &EIB) {
+ SMDiagnostic Err = SMDiagnostic(Buffer.getBufferIdentifier(),
+ SourceMgr::DK_Error, EIB.message());
+ Err.print("ThinLTO", errs());
+ });
+ report_fatal_error("Can't load module, abort.");
+ }
+ return std::move(ModuleOrErr.get());
+}
+
static void
crossImportIntoModule(Module &TheModule, const ModuleSummaryIndex &Index,
StringMap<MemoryBufferRef> &ModuleMap,
const FunctionImporter::ImportMapTy &ImportList) {
- ModuleLoader Loader(TheModule.getContext(), ModuleMap);
+ auto Loader = [&](StringRef Identifier) {
+ return loadModuleFromBuffer(ModuleMap[Identifier], TheModule.getContext(),
+ /*Lazy=*/true);
+ };
+
FunctionImporter Importer(Index, Loader);
if (!Importer.importFunctions(TheModule, ImportList))
report_fatal_error("importFunctions failed");
OpenPOWER on IntegriCloud