[llvm] [PGO] Implement PGO counter promotion for atomic updates (PR #202487)

Wael Yehia via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 12 11:03:06 PDT 2026


================
@@ -524,6 +556,20 @@ class PGOCounterPromoter {
   }
 
   bool run(int64_t *NumPromoted) {
+    // In this function we examine loop L and other parameters to decide what
+    // candidates are promotable. Once we've promoted what we can, we convert
+    // all remaining candidates to use atomics. This requires that promoted
+    // candidates are set to nullptr in the LoopToCandidates[&L] array.
+    llvm::scope_exit Cleanup([&]() {
----------------
w2yehia wrote:

ok, I see. We would still need a way to tell if a candidate have been promoted, so we either mark him null like I do now, or erase from the SmallVector (cleaner but more work). Also I prefer to have the cleanup as part of the run method and not add another wrapper from a readability prespective.

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


More information about the llvm-commits mailing list