From: Mehdi Amini Date: Thu, 5 May 2016 16:33:51 +0000 (+0000) Subject: llvm-lto: add a -thinlto-module-id that enables to force the Module identifier. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3d13068cfd3743a7374d8148c01e0042bdca6d94;p=llvm llvm-lto: add a -thinlto-module-id that enables to force the Module identifier. ThinLTO is using the Module Identifier to find the corresponding entry in the index. However when reproducing part of the flow from temporary files generated from the linker, you'd like to process a file and force llvm-lto to use another module identifier than the current filename. The alternative would be to tweak the index, which would be more involved. From: Mehdi Amini git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268643 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/llvm-lto/llvm-lto.cpp b/tools/llvm-lto/llvm-lto.cpp index 3a9ff812e42..395988c0ebf 100644 --- a/tools/llvm-lto/llvm-lto.cpp +++ b/tools/llvm-lto/llvm-lto.cpp @@ -101,6 +101,11 @@ static cl::opt cl::desc("Provide the index produced by a ThinLink, required " "to perform the promotion and/or importing.")); +static cl::opt ThinLTOModuleId( + "thinlto-module-id", + cl::desc("For the module ID for the file to process, useful to " + "match what is in the index.")); + static cl::opt SaveModuleFile("save-merged-module", cl::init(false), cl::desc("Write merged LTO module to file before CodeGen")); @@ -318,6 +323,12 @@ static std::unique_ptr loadModule(StringRef Filename, report_fatal_error("Can't load module for file " + Filename); } maybeVerifyModule(*M); + + if (ThinLTOModuleId.getNumOccurrences()) { + if (InputFilenames.size() != 1) + report_fatal_error("Can't override the module id for multiple files"); + M->setModuleIdentifier(ThinLTOModuleId); + } return M; }