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

llvm-svn: 331657
This commit is contained in:
Rui Ueyama 2018-05-07 17:59:43 +00:00
parent e4ba06eda6
commit 4454b3d1eb
3 changed files with 14 additions and 19 deletions

View File

@ -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;

View File

@ -802,8 +802,9 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) {
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")) {

View File

@ -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::compile() {
// 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);
}