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

Paul Osmialowski via flang-commits flang-commits at lists.llvm.org
Sat Jun 27 01:30:23 PDT 2026


================
@@ -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)
----------------
pawosm-arm wrote:

IMO this dependency enforces something that is already being enforced:

```
      COMMAND "${Python3_EXECUTABLE}" "${PERF_HELPER}" merge "${LLVM_PROFDATA}" "${PROFDATA}" ${PROFRAW_DIRS}
      COMMENT "Merging flang profdata"
      DEPENDS ${PROFRAW_DEPS} ${FLANG_PGO_TRAINING_DEPS} clear-flang-profraw
```
The dependenices for the `merge` command are given in the `FLANG_PGO_TRAINING_DEPS` list:

```
    if(FLANG_PGO_TRAINING_CLANG_COUPLING)
      list(APPEND PROFRAW_TARGETS generate-clang-profraw)
    ....
    list(APPEND PROFRAW_TARGETS generate-flang-profraw)
```
With that dependency list, the `.profraw` files generation for both flang and clang will be happening in parallel. The fact that it creates the tons of processes is a bit worrying and may be a good reason for creating a dependency sequence here, but this is not the problem that you wanted to address in this PR which is to ensure that merging happens no sooner that the last `.profraw` file is completed, and this is what is actually happening.


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


More information about the flang-commits mailing list