[llvm] r268643 - llvm-lto: add a -thinlto-module-id that enables to force the Module identifier.

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Thu May 5 09:33:52 PDT 2016


Author: mehdi_amini
Date: Thu May  5 11:33:51 2016
New Revision: 268643

URL: http://llvm.org/viewvc/llvm-project?rev=268643&view=rev
Log:
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 <mehdi.amini at apple.com>

Modified:
    llvm/trunk/tools/llvm-lto/llvm-lto.cpp

Modified: llvm/trunk/tools/llvm-lto/llvm-lto.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-lto/llvm-lto.cpp?rev=268643&r1=268642&r2=268643&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-lto/llvm-lto.cpp (original)
+++ llvm/trunk/tools/llvm-lto/llvm-lto.cpp Thu May  5 11:33:51 2016
@@ -101,6 +101,11 @@ static cl::opt<std::string>
                  cl::desc("Provide the index produced by a ThinLink, required "
                           "to perform the promotion and/or importing."));
 
+static cl::opt<std::string> 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<bool>
     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<Module> loadModul
     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;
 }
 




More information about the llvm-commits mailing list