]> granicus.if.org Git - llvm/commitdiff
llvm-lto: add a -thinlto-module-id that enables to force the Module identifier.
authorMehdi Amini <mehdi.amini@apple.com>
Thu, 5 May 2016 16:33:51 +0000 (16:33 +0000)
committerMehdi Amini <mehdi.amini@apple.com>
Thu, 5 May 2016 16:33:51 +0000 (16:33 +0000)
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@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268643 91177308-0d34-0410-b5e6-96231b3b80d8

tools/llvm-lto/llvm-lto.cpp

index 3a9ff812e42f23fc1f93c93ba173eb72e4a8acc2..395988c0ebfdbfd1e48396f4b948ee1598ab6c82 100644 (file)
@@ -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> 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;
 }