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

Henry Jiang via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 11 20:09:34 PDT 2026


================
@@ -567,6 +612,7 @@ class PGOCounterPromoter {
                                         L.getLoopPreheader(), ExitBlocks,
                                         InsertPts, LoopToCandidates, LI);
       Promoter.run(SmallVector<Instruction *, 2>({Cand.first, Cand.second}));
+      Cand = {nullptr, nullptr};
----------------
mustartt wrote:

https://github.com/llvm/llvm-project/blob/8433cf6d6ccc49a0fd99ed86c7d94a1fbb2fd1be/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp#L482

When `PGOCounterPromoterHelper::run` it can requeue additional loops, causing the `DenseMap<Loop *, SmallVector<LoadStorePair, 8>> &LoopToCands` to rehash and invalidate the reference to `Cand`. 

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


More information about the llvm-commits mailing list