Skip to content

Commit a3cbb15

Browse files
committed
[LinkerWrapper] Tweak save-temps output name
Summary: A previous patch added the Task to the output filename when doing `save-temps` the majority of cases there is only a single task so we only add the task explicitly to differentiate it from the first one.
1 parent b93119a commit a3cbb15

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -812,13 +812,14 @@ std::unique_ptr<lto::LTO> createLTO(
812812
Conf.PTO.SLPVectorization = Conf.OptLevel > 1;
813813

814814
if (SaveTemps) {
815-
std::string TempName = (sys::path::filename(ExecutableName) + "-" +
815+
std::string TempName = (sys::path::filename(ExecutableName) + "-device-" +
816816
Triple.getTriple() + "-" + Arch)
817817
.str();
818818
Conf.PostInternalizeModuleHook = [=](size_t Task, const Module &M) {
819-
std::string Output = TempName + "." + std::to_string(Task) + ".bc";
819+
std::string File = !Task ? TempName + ".bc"
820+
: TempName + "." + std::to_string(Task) + ".bc";
820821
error_code EC;
821-
raw_fd_ostream LinkedBitcode(Output, EC, sys::fs::OF_None);
822+
raw_fd_ostream LinkedBitcode(File, EC, sys::fs::OF_None);
822823
if (EC)
823824
reportError(errorCodeToError(EC));
824825
WriteBitcodeToFile(M, LinkedBitcode);
@@ -897,7 +898,7 @@ Error linkBitcodeFiles(SmallVectorImpl<OffloadFile> &InputFiles,
897898

898899
// LTO Module hook to output bitcode without running the backend.
899900
SmallVector<StringRef, 4> BitcodeOutput;
900-
auto OutputBitcode = [&](size_t Task, const Module &M) {
901+
auto OutputBitcode = [&](size_t, const Module &M) {
901902
auto TempFileOrErr = createOutputFile(sys::path::filename(ExecutableName) +
902903
"-jit-" + Triple.getTriple(),
903904
"bc");
@@ -991,9 +992,10 @@ Error linkBitcodeFiles(SmallVectorImpl<OffloadFile> &InputFiles,
991992
int FD = -1;
992993
auto &TempFile = Files[Task];
993994
StringRef Extension = (Triple.isNVPTX()) ? "s" : "o";
995+
std::string TaskStr = Task ? "." + std::to_string(Task) : "";
994996
auto TempFileOrErr =
995997
createOutputFile(sys::path::filename(ExecutableName) + "-device-" +
996-
Triple.getTriple() + "." + std::to_string(Task),
998+
Triple.getTriple() + TaskStr,
997999
Extension);
9981000
if (!TempFileOrErr)
9991001
reportError(TempFileOrErr.takeError());

0 commit comments

Comments
 (0)