diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp | 14 | ||||
| -rw-r--r-- | tools/llvm-link/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | tools/llvm-link/LLVMBuild.txt | 2 | ||||
| -rw-r--r-- | tools/llvm-link/llvm-link.cpp | 51 |
4 files changed, 27 insertions, 41 deletions
diff --git a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp index f97a18448f0aa..b84c4a83dee45 100644 --- a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp +++ b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp @@ -322,16 +322,15 @@ static const char *GetCodeName(unsigned CodeID, unsigned BlockID, switch(CodeID) { default:return nullptr; STRINGIFY_CODE(METADATA, STRING_OLD) - STRINGIFY_CODE(METADATA, STRINGS) + STRINGIFY_CODE(METADATA, VALUE) + STRINGIFY_CODE(METADATA, NODE) STRINGIFY_CODE(METADATA, NAME) + STRINGIFY_CODE(METADATA, DISTINCT_NODE) STRINGIFY_CODE(METADATA, KIND) // Older bitcode has it in a MODULE_BLOCK - STRINGIFY_CODE(METADATA, NODE) - STRINGIFY_CODE(METADATA, VALUE) + STRINGIFY_CODE(METADATA, LOCATION) STRINGIFY_CODE(METADATA, OLD_NODE) STRINGIFY_CODE(METADATA, OLD_FN_NODE) STRINGIFY_CODE(METADATA, NAMED_NODE) - STRINGIFY_CODE(METADATA, DISTINCT_NODE) - STRINGIFY_CODE(METADATA, LOCATION) STRINGIFY_CODE(METADATA, GENERIC_DEBUG) STRINGIFY_CODE(METADATA, SUBRANGE) STRINGIFY_CODE(METADATA, ENUMERATOR) @@ -353,6 +352,11 @@ static const char *GetCodeName(unsigned CodeID, unsigned BlockID, STRINGIFY_CODE(METADATA, OBJC_PROPERTY) STRINGIFY_CODE(METADATA, IMPORTED_ENTITY) STRINGIFY_CODE(METADATA, MODULE) + STRINGIFY_CODE(METADATA, MACRO) + STRINGIFY_CODE(METADATA, MACRO_FILE) + STRINGIFY_CODE(METADATA, STRINGS) + STRINGIFY_CODE(METADATA, GLOBAL_DECL_ATTACHMENT) + STRINGIFY_CODE(METADATA, GLOBAL_VAR_EXPR) STRINGIFY_CODE(METADATA, INDEX_OFFSET) STRINGIFY_CODE(METADATA, INDEX) } diff --git a/tools/llvm-link/CMakeLists.txt b/tools/llvm-link/CMakeLists.txt index 5aae69b4ca0b1..7317792232483 100644 --- a/tools/llvm-link/CMakeLists.txt +++ b/tools/llvm-link/CMakeLists.txt @@ -6,6 +6,7 @@ set(LLVM_LINK_COMPONENTS Object Support TransformUtils + IPO ) add_llvm_tool(llvm-link diff --git a/tools/llvm-link/LLVMBuild.txt b/tools/llvm-link/LLVMBuild.txt index 1dba5c0adb3f0..c7476043164a7 100644 --- a/tools/llvm-link/LLVMBuild.txt +++ b/tools/llvm-link/LLVMBuild.txt @@ -19,4 +19,4 @@ type = Tool name = llvm-link parent = Tools -required_libraries = AsmParser BitReader BitWriter IRReader Linker Object TransformUtils +required_libraries = AsmParser BitReader BitWriter IRReader Linker Object TransformUtils IPO diff --git a/tools/llvm-link/llvm-link.cpp b/tools/llvm-link/llvm-link.cpp index 43431ac3398ae..e89696e7e7c24 100644 --- a/tools/llvm-link/llvm-link.cpp +++ b/tools/llvm-link/llvm-link.cpp @@ -33,6 +33,7 @@ #include "llvm/Support/SourceMgr.h" #include "llvm/Support/SystemUtils.h" #include "llvm/Support/ToolOutputFile.h" +#include "llvm/Transforms/IPO/FunctionImport.h" #include "llvm/Transforms/Utils/FunctionImportUtils.h" #include <memory> @@ -202,19 +203,20 @@ static void diagnosticHandler(const DiagnosticInfo &DI, void *C) { } /// Import any functions requested via the -import option. -static bool importFunctions(const char *argv0, LLVMContext &Context, - Linker &L) { +static bool importFunctions(const char *argv0, Module &DestModule) { if (SummaryIndex.empty()) return true; std::unique_ptr<ModuleSummaryIndex> Index = ExitOnErr(llvm::getModuleSummaryIndexForFile(SummaryIndex)); // Map of Module -> List of globals to import from the Module - std::map<StringRef, DenseSet<const GlobalValue *>> ModuleToGlobalsToImportMap; - auto ModuleLoader = [&Context](const char *argv0, - const std::string &Identifier) { - return loadFile(argv0, Identifier, Context, false); + FunctionImporter::ImportMapTy ImportList; + + auto ModuleLoader = [&DestModule](const char *argv0, + const std::string &Identifier) { + return loadFile(argv0, Identifier, DestModule.getContext(), false); }; + ModuleLazyLoaderCache ModuleLoaderCache(ModuleLoader); for (const auto &Import : Imports) { // Identify the requested function and its bitcode source file. @@ -253,35 +255,14 @@ static bool importFunctions(const char *argv0, LLVMContext &Context, if (Verbose) errs() << "Importing " << FunctionName << " from " << FileName << "\n"; - auto &Entry = ModuleToGlobalsToImportMap[SrcModule.getModuleIdentifier()]; - Entry.insert(F); - - ExitOnErr(F->materialize()); - } - - // Do the actual import of globals now, one Module at a time - for (auto &GlobalsToImportPerModule : ModuleToGlobalsToImportMap) { - // Get the module for the import - auto &GlobalsToImport = GlobalsToImportPerModule.second; - std::unique_ptr<Module> SrcModule = - ModuleLoaderCache.takeModule(GlobalsToImportPerModule.first); - assert(&Context == &SrcModule->getContext() && "Context mismatch"); - - // If modules were created with lazy metadata loading, materialize it - // now, before linking it (otherwise this will be a noop). - ExitOnErr(SrcModule->materializeMetadata()); - UpgradeDebugInfo(*SrcModule); - - // Linkage Promotion and renaming - if (renameModuleForThinLTO(*SrcModule, *Index, &GlobalsToImport)) - return true; - - // Instruct the linker to not automatically import linkonce defintion. - unsigned Flags = Linker::Flags::DontForceLinkLinkonceODR; - - if (L.linkInModule(std::move(SrcModule), Flags, &GlobalsToImport)) - return false; + auto &Entry = ImportList[FileName]; + Entry.insert(std::make_pair(F->getGUID(), /* (Unused) threshold */ 1.0)); } + auto CachedModuleLoader = [&](StringRef Identifier) { + return ModuleLoaderCache.takeModule(Identifier); + }; + FunctionImporter Importer(*Index, CachedModuleLoader); + ExitOnErr(Importer.importFunctions(DestModule, ImportList)); return true; } @@ -374,7 +355,7 @@ int main(int argc, char **argv) { return 1; // Import any functions requested via -import - if (!importFunctions(argv[0], Context, L)) + if (!importFunctions(argv[0], *Composite)) return 1; if (DumpAsm) errs() << "Here's the assembly:\n" << *Composite; |
