[flang-commits] [flang] [flang][cmake] Order flang profdata generation after clang's (PR #206023)

Madhur Amilkanthwar via flang-commits flang-commits at lists.llvm.org
Fri Jun 26 03:13:23 PDT 2026


https://github.com/madhur13490 created https://github.com/llvm/llvm-project/pull/206023

The clang and flang PGO pipelines clean and regenerate the same shared profraw directories, so running them concurrently can truncate a profraw while the other merge has it mmap'd. Add an ordering edge so flang's pipeline runs after clang's.

Fixes issues introduced by https://github.com/llvm/llvm-project/pull/198863

>From 0a21526f35af3bbdabc3a836160aac0607c4f150 Mon Sep 17 00:00:00 2001
From: Madhur Amilkanthwar <madhura at nvidia.com>
Date: Thu, 25 Jun 2026 22:55:44 -0700
Subject: [PATCH] [flang][cmake] Order flang profdata generation after clang's

The clang and flang PGO pipelines clean and regenerate the same shared
profraw directories, so running them concurrently can truncate a profraw
while the other merge has it mmap'd. Add an ordering edge so flang's
pipeline runs after clang's.
---
 flang/test/CMakeLists.txt | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/flang/test/CMakeLists.txt b/flang/test/CMakeLists.txt
index 538432c05e14b..4c4dab9e7bf87 100644
--- a/flang/test/CMakeLists.txt
+++ b/flang/test/CMakeLists.txt
@@ -281,6 +281,14 @@ if(LLVM_BUILD_INSTRUMENTED)
     )
     add_custom_target(generate-flang-profdata DEPENDS "${PROFDATA}")
 
+    # The clang and flang profdata pipelines clean and regenerate the same
+    # shared profraw directories (profiles/ and clang/utils/perf-training).
+    # Order flang after clang so flang's clean/regenerate never races clang's
+    # merge while it has a profraw mmap'd.
+    if(TARGET generate-profdata)
+      add_dependencies(generate-flang-profdata generate-profdata)
+    endif()
+
     if(FLANG_PGO_TRAINING_CLANG_COUPLING)
       string(TOUPPER "${LLVM_BUILD_INSTRUMENTED}" LLVM_BUILD_UPPER_INSTRUMENTED)
       if (LLVM_BUILD_UPPER_INSTRUMENTED STREQUAL "CSSPGO")



More information about the flang-commits mailing list