diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp index 06e5cf843da0ae..f0509b68ee0b37 100644 --- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp +++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp @@ -525,17 +525,15 @@ fatbinary(ArrayRef> InputFiles, if (!TempFileOrErr) return TempFileOrErr.takeError(); - BumpPtrAllocator Alloc; - StringSaver Saver(Alloc); - SmallVector CmdArgs; CmdArgs.push_back(*FatBinaryPath); CmdArgs.push_back(Triple.isArch64Bit() ? "-64" : "-32"); CmdArgs.push_back("--create"); CmdArgs.push_back(*TempFileOrErr); for (const auto &FileAndArch : InputFiles) - CmdArgs.push_back(Saver.save("--image=profile=" + std::get<1>(FileAndArch) + - ",file=" + std::get<0>(FileAndArch))); + CmdArgs.push_back( + Args.MakeArgString("--image=profile=" + std::get<1>(FileAndArch) + + ",file=" + std::get<0>(FileAndArch))); if (Error Err = executeCommands(*FatBinaryPath, CmdArgs)) return std::move(Err); @@ -808,6 +806,8 @@ Error linkBitcodeFiles(SmallVectorImpl &InputFiles, SmallVector BitcodeInputFiles; DenseSet UsedInRegularObj; DenseSet UsedInSharedLib; + BumpPtrAllocator Alloc; + StringSaver Saver(Alloc); // Search for bitcode files in the input and create an LTO input file. If it // is not a bitcode file, scan its symbol table for symbols we need to save. @@ -844,9 +844,9 @@ Error linkBitcodeFiles(SmallVectorImpl &InputFiles, // Record if we've seen these symbols in any object or shared libraries. if ((*ObjFile)->isRelocatableObject()) - UsedInRegularObj.insert(*Name); + UsedInRegularObj.insert(Saver.save(*Name)); else - UsedInSharedLib.insert(*Name); + UsedInSharedLib.insert(Saver.save(*Name)); } continue; } @@ -908,7 +908,8 @@ Error linkBitcodeFiles(SmallVectorImpl &InputFiles, // We will use this as the prevailing symbol definition in LTO unless // it is undefined or another definition has already been used. Res.Prevailing = - !Sym.isUndefined() && PrevailingSymbols.insert(Sym.getName()).second; + !Sym.isUndefined() && + PrevailingSymbols.insert(Saver.save(Sym.getName())).second; // We need LTO to preseve the following global symbols: // 1) Symbols used in regular objects. @@ -1193,8 +1194,6 @@ linkAndWrapDeviceFiles(SmallVectorImpl &LinkerInputFiles, InputsForTarget[File].emplace_back(std::move(File)); LinkerInputFiles.clear(); - BumpPtrAllocator Alloc; - UniqueStringSaver Saver(Alloc); DenseMap> Images; for (auto &InputForTarget : InputsForTarget) { SmallVector &Input = InputForTarget.getSecond(); @@ -1395,6 +1394,7 @@ int main(int Argc, char **Argv) { auto FileOrErr = getInputBitcodeLibrary(Library); if (!FileOrErr) reportError(FileOrErr.takeError()); + InputFiles.push_back(std::move(*FileOrErr)); } DenseSet IsTargetUsed;