[clang] [perf-training][merge-fdata] Clean up input fdata files (PR #245890)

via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 24 22:20:32 PST 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Amir Ayupov (aaupov)

<details>
<summary>Changes</summary>

Reland #<!-- -->139650 (reverted in #<!-- -->240375) with two fixes.

The BOLT AArch64 worker runs out of disk space because the clang-bolt build leaves the per-process fdata files behind. Delete the inputs after merge-fdata has merged them.

Fixes over #<!-- -->139650:
- Pass the inputs as separate arguments. #<!-- -->139650 passed the list as one argv element, so subprocess raised TypeError and broke every clang-bolt build.
- Keep the output out of the inputs. clang's BOLT_FDATA (prof.fdata) lives in the perf-training directory that merge_fdata scans, so when bolt-optimize runs again after clang is relinked, the previous prof.fdata would be merged into itself and then deleted, and the following BOLT step would fail on the missing profile.

The inputs are only deleted after merge-fdata succeeds.

---
Full diff: https://github.com/llvm/llvm-project/pull/245890.diff


1 Files Affected:

- (modified) clang/utils/perf-training/perf-helper.py (+13-3) 


``````````diff
diff --git a/clang/utils/perf-training/perf-helper.py b/clang/utils/perf-training/perf-helper.py
index e28920f3e0c43c..d9a35b8e9ea136 100644
--- a/clang/utils/perf-training/perf-helper.py
+++ b/clang/utils/perf-training/perf-helper.py
@@ -73,9 +73,19 @@ def merge_fdata(args):
             + "\tMerges all fdata files from path into output."
         )
         return 1
-    cmd = [args[0], "-o", args[1]]
-    cmd.extend(findFilesWithExtension(args[2], "fdata"))
-    subprocess.check_call(cmd)
+    merge_fdata_bin, output, path = args
+    # The output may live under path (e.g. prof.fdata in the perf-training
+    # dir), so keep a previous output out of the inputs.
+    output_path = os.path.realpath(output)
+    inputs = [
+        filename
+        for filename in findFilesWithExtension(path, "fdata")
+        if os.path.realpath(filename) != output_path
+    ]
+    subprocess.check_call([merge_fdata_bin, "-o", output, *inputs])
+    # Remove merged input fdata files to save space.
+    for filename in inputs:
+        os.remove(filename)
     return 0
 
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/245890


More information about the cfe-commits mailing list