[clang] [clang-sycl-linker] Keep AOT .out temp files under -save-temps (PR #224502)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 17 20:16:27 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Wenju He (wenju-he)
<details>
<summary>Changes</summary>
runSYCLLink's AOT path built .out with a fixed deterministic name but never registered it with TempFiles, so it was deleted unconditionally at end-of-run, unlike every other intermediate in the pipeline.
Add registerTempFile() to record an already-named path into TempFiles without generating createTempFile's own random suffix, which would otherwise break callers relying on the deterministic "<stem>_<index>.out" name.
---
Full diff: https://github.com/llvm/llvm-project/pull/224502.diff
1 Files Affected:
- (modified) clang/tools/clang-sycl-linker/ClangSYCLLinker.cpp (+9-1)
``````````diff
diff --git a/clang/tools/clang-sycl-linker/ClangSYCLLinker.cpp b/clang/tools/clang-sycl-linker/ClangSYCLLinker.cpp
index 70afc6d6c4cea..5690ee7788d64 100644
--- a/clang/tools/clang-sycl-linker/ClangSYCLLinker.cpp
+++ b/clang/tools/clang-sycl-linker/ClangSYCLLinker.cpp
@@ -156,6 +156,13 @@ createTempFile(const ArgList &Args, const Twine &Prefix, StringRef Extension) {
return TempFiles.back();
}
+/// Registers an already fixed-named path for the same end-of-run cleanup
+/// createTempFile above provides, without its random suffix.
+static StringRef registerTempFile(std::string Path) {
+ TempFiles.emplace_back(Path);
+ return TempFiles.back();
+}
+
static Expected<std::string> findProgram(const ArgList &Args, StringRef Name,
ArrayRef<StringRef> Paths) {
if (DryRun)
@@ -1001,7 +1008,8 @@ static Error runSYCLLink(ArrayRef<std::unique_ptr<MemoryBuffer>> Inputs,
SplitModules[I].ModuleFilePath = CodeGenFile;
if (IsAOTCompileNeeded) {
- std::string AOTFile = (Stem + "_" + Twine(I) + ".out").str();
+ StringRef AOTFile =
+ registerTempFile((Stem + "_" + Twine(I) + ".out").str());
if (Error Err = runAOTCompile(CodeGenFile, AOTFile, Args))
return Err;
SplitModules[I].ModuleFilePath = AOTFile;
``````````
</details>
https://github.com/llvm/llvm-project/pull/224502
More information about the cfe-commits
mailing list