diff --git a/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp b/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp index 8ec1f722fa8a..b4b376fe0d11 100644 --- a/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp +++ b/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp @@ -236,9 +236,8 @@ void printCommands(ArrayRef CmdArgs) { if (CmdArgs.empty()) return; - llvm::errs() << " \"" << CmdArgs.front() << "\" "; - llvm::errs() << llvm::join(std::next(CmdArgs.begin()), CmdArgs.end(), " ") - << "\n"; + errs() << " \"" << CmdArgs.front() << "\" "; + errs() << join(std::next(CmdArgs.begin()), CmdArgs.end(), " ") << "\n"; } /// A minimum symbol interface that provides the necessary information to @@ -329,12 +328,12 @@ Expected> createLTO(const ArgList &Args) { lto::ThinBackend Backend; unsigned Jobs = 0; if (auto *Arg = Args.getLastArg(OPT_jobs)) - if (!llvm::to_integer(Arg->getValue(), Jobs) || Jobs == 0) + if (!to_integer(Arg->getValue(), Jobs) || Jobs == 0) reportError(createStringError("%s: expected a positive integer, got '%s'", Arg->getSpelling().data(), Arg->getValue())); - Backend = lto::createInProcessThinBackend( - llvm::heavyweight_hardware_concurrency(Jobs)); + Backend = + lto::createInProcessThinBackend(heavyweight_hardware_concurrency(Jobs)); Conf.CPU = Args.getLastArgValue(OPT_arch); Conf.Options = codegen::InitTargetOptionsFromCodeGenFlags(Triple); @@ -378,7 +377,7 @@ Expected> createLTO(const ArgList &Args) { unsigned Partitions = 1; if (auto *Arg = Args.getLastArg(OPT_lto_partitions)) - if (!llvm::to_integer(Arg->getValue(), Partitions) || Partitions == 0) + if (!to_integer(Arg->getValue(), Partitions) || Partitions == 0) reportError(createStringError("%s: expected a positive integer, got '%s'", Arg->getSpelling().data(), Arg->getValue())); @@ -510,7 +509,7 @@ Expected> getInput(const ArgList &Args) { InputFiles.emplace_back(std::move(*BufferOrErr), /*IsLazy=*/false); break; case file_magic::archive: { - Expected> LibFile = + Expected> LibFile = object::Archive::create(Buffer); if (!LibFile) return LibFile.takeError(); @@ -563,7 +562,7 @@ Expected> getInput(const ArgList &Args) { for (auto &Input : LinkerInput) if (identify_magic(Input->getBuffer()) == file_magic::bitcode) BitcodeFiles.emplace_back(std::move(Input)); - llvm::erase_if(LinkerInput, [](const auto &F) { return !F; }); + erase_if(LinkerInput, [](const auto &F) { return !F; }); // Run the LTO pipeline on the extracted inputs. SmallVector Files; @@ -574,7 +573,7 @@ Expected> getInput(const ArgList &Args) { lto::LTO <OBackend = **LTOBackendOrErr; for (auto &BitcodeFile : BitcodeFiles) { Expected> BitcodeFileOrErr = - llvm::lto::InputFile::create(*BitcodeFile); + lto::InputFile::create(*BitcodeFile); if (!BitcodeFileOrErr) return BitcodeFileOrErr.takeError(); @@ -638,7 +637,7 @@ Expected> getInput(const ArgList &Args) { if (std::error_code EC = sys::fs::openFileForWrite(TempFile, FD)) reportError(errorCodeToError(EC)); return std::make_unique( - std::make_unique(FD, true)); + std::make_unique(FD, true)); }; if (Error Err = LTOBackend.run(AddStream)) @@ -655,11 +654,11 @@ Expected> getInput(const ArgList &Args) { } } - // Create a link for each file to a new file ending in `.cubin`. The 'nvlink' + // Create a copy for each file to a new file ending in `.cubin`. The 'nvlink' // linker requires all NVPTX inputs to have this extension for some reason. - // Windows cannot create symbolic links so we just copy the whole file. + // We don't use a symbolic link because it's not supported on Windows and some + // of this input files could be extracted from an archive. for (auto &Input : LinkerInput) { -#ifdef _WIN32 auto TempFileOrErr = createTempFile( Args, sys::path::stem(Input->getBufferIdentifier()), "cubin"); if (!TempFileOrErr) @@ -669,22 +668,10 @@ Expected> getInput(const ArgList &Args) { if (!OutputOrErr) return OutputOrErr.takeError(); std::unique_ptr Output = std::move(*OutputOrErr); - llvm::copy(Input->getBuffer(), Output->getBufferStart()); + copy(Input->getBuffer(), Output->getBufferStart()); if (Error E = Output->commit()) return E; Files.emplace_back(Args.MakeArgString(*TempFileOrErr)); -#else - SmallString<128> TempFile; - if (std::error_code EC = sys::fs::getPotentiallyUniqueTempFileName( - sys::path::stem(Input->getBufferIdentifier()), "cubin", TempFile)) - reportError(createFileError(TempFile, EC)); - if (std::error_code EC = - sys::fs::create_link(Input->getBufferIdentifier(), TempFile)) { - reportError(createFileError(TempFile, EC)); - } - Files.emplace_back(Args.MakeArgString(TempFile)); - TempFiles.emplace_back(std::move(TempFile)); -#endif } return Files; @@ -718,8 +705,8 @@ Error runNVLink(ArrayRef Files, const ArgList &Args) { Arg->render(Args, NewLinkerArgs); } - llvm::transform(Files, std::back_inserter(NewLinkerArgs), - [&](StringRef Arg) { return Args.MakeArgString(Arg); }); + transform(Files, std::back_inserter(NewLinkerArgs), + [&](StringRef Arg) { return Args.MakeArgString(Arg); }); SmallVector LinkerArgs({*NVLinkPath}); if (!Args.hasArg(OPT_o))