[lld] r331657 - Parse --thinlto-prefix-replace early so that we don't need to parse it later. NFC.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Mon May 7 10:59:43 PDT 2018


Author: ruiu
Date: Mon May  7 10:59:43 2018
New Revision: 331657

URL: http://llvm.org/viewvc/llvm-project?rev=331657&view=rev
Log:
Parse --thinlto-prefix-replace early so that we don't need to parse it later. NFC.

Modified:
    lld/trunk/ELF/Config.h
    lld/trunk/ELF/Driver.cpp
    lld/trunk/ELF/LTO.cpp

Modified: lld/trunk/ELF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Config.h?rev=331657&r1=331656&r2=331657&view=diff
==============================================================================
--- lld/trunk/ELF/Config.h (original)
+++ lld/trunk/ELF/Config.h Mon May  7 10:59:43 2018
@@ -95,7 +95,7 @@ struct Configuration {
   llvm::StringRef Sysroot;
   llvm::StringRef ThinLTOCacheDir;
   llvm::StringRef ThinLTOIndexOnlyObjectsFile;
-  llvm::StringRef ThinLTOPrefixReplace;
+  std::pair<llvm::StringRef, llvm::StringRef> ThinLTOPrefixReplace;
   std::string Rpath;
   std::vector<VersionDefinition> VersionDefinitions;
   std::vector<llvm::StringRef> AuxiliaryList;

Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=331657&r1=331656&r2=331657&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Mon May  7 10:59:43 2018
@@ -802,8 +802,9 @@ void LinkerDriver::readConfigs(opt::Inpu
       Config->ThinLTOIndexOnly = true;
       Config->ThinLTOIndexOnlyObjectsFile = S.substr(19);
     } else if (S.startswith("thinlto-prefix-replace=")) {
-      Config->ThinLTOPrefixReplace = S.substr(23);
-      if (!Config->ThinLTOPrefixReplace.contains(';'))
+      std::tie(Config->ThinLTOPrefixReplace.first,
+               Config->ThinLTOPrefixReplace.second) = S.substr(23).split(';');
+      if (Config->ThinLTOPrefixReplace.second.empty())
         error("thinlto-prefix-replace expects 'old;new' format");
     } else if (!S.startswith("/") && !S.startswith("-fresolution=") &&
                !S.startswith("-pass-through=") && !S.startswith("thinlto")) {

Modified: lld/trunk/ELF/LTO.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LTO.cpp?rev=331657&r1=331656&r2=331657&view=diff
==============================================================================
--- lld/trunk/ELF/LTO.cpp (original)
+++ lld/trunk/ELF/LTO.cpp Mon May  7 10:59:43 2018
@@ -155,13 +155,10 @@ void BitcodeCompiler::init() {
     Backend = lto::createInProcessThinBackend(Config->ThinLTOJobs);
 
   if (Config->ThinLTOIndexOnly) {
-    std::string OldPrefix;
-    std::string NewPrefix;
-    std::tie(OldPrefix, NewPrefix) = Config->ThinLTOPrefixReplace.split(';');
-
     IndexFile = openFile(Config->ThinLTOIndexOnlyObjectsFile);
-    Backend = lto::createWriteIndexesThinBackend(OldPrefix, NewPrefix, true,
-                                                 IndexFile.get(), nullptr);
+    Backend = lto::createWriteIndexesThinBackend(
+        Config->ThinLTOPrefixReplace.first, Config->ThinLTOPrefixReplace.second,
+        true, IndexFile.get(), nullptr);
   }
 
   Conf.SampleProfile = Config->LTOSampleProfile;
@@ -193,13 +190,11 @@ static void undefine(Symbol *S) {
 void BitcodeCompiler::add(BitcodeFile &F) {
   lto::InputFile &Obj = *F.Obj;
 
-  std::string OldPrefix, NewPrefix;
-  std::tie(OldPrefix, NewPrefix) = Config->ThinLTOPrefixReplace.split(';');
-
   // Create the empty files which, if indexed, will be overwritten later.
   if (Config->ThinLTOIndexOnly)
-    writeEmptyDistributedBuildOutputs(Obj.getName(), OldPrefix, NewPrefix,
-                                      false);
+    writeEmptyDistributedBuildOutputs(
+        Obj.getName(), Config->ThinLTOPrefixReplace.first,
+        Config->ThinLTOPrefixReplace.second, false);
 
   unsigned SymNum = 0;
   std::vector<Symbol *> Syms = F.getSymbols();
@@ -313,9 +308,8 @@ std::vector<InputFile *> BitcodeCompiler
 
 // For lazy object files not added to link, adds empty index files
 void BitcodeCompiler::addLazyObjFile(LazyObjFile *File) {
-  StringRef Identifier = File->getBuffer().getBufferIdentifier();
-  std::string OldPrefix, NewPrefix;
-  std::tie(OldPrefix, NewPrefix) = Config->ThinLTOPrefixReplace.split(';');
-  writeEmptyDistributedBuildOutputs(Identifier, OldPrefix, NewPrefix,
-                                    /* SkipModule */ true);
+  writeEmptyDistributedBuildOutputs(File->getBuffer().getBufferIdentifier(),
+                                    Config->ThinLTOPrefixReplace.first,
+                                    Config->ThinLTOPrefixReplace.second,
+                                    /*SkipModule=*/true);
 }




More information about the llvm-commits mailing list