[clang] [llvm] [PGO] Implement PGO counter promotion for atomic updates (PR #202487)
David Li via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 18 09:40:27 PDT 2026
================
@@ -870,10 +909,29 @@ bool InstrLowerer::isSamplingEnabled() const {
bool InstrLowerer::isCounterPromotionEnabled() const {
if (DoCounterPromotion.getNumOccurrences() > 0)
return DoCounterPromotion;
-
return Options.DoCounterPromotion;
}
+bool InstrLowerer::isAtomic() const {
+ return Options.Atomic || AtomicCounterUpdateAll;
+}
+
+static void doAtomicPromotionCheck(Function *F) {
+ for (const llvm::Instruction &I : llvm::instructions(F)) {
+ const Value *Addr = nullptr;
+ if (const LoadInst *LI = dyn_cast<LoadInst>(&I))
+ Addr = LI->getOperand(0);
+ else if (const StoreInst *LI = dyn_cast<StoreInst>(&I))
+ Addr = LI->getOperand(1);
+
+ if (Addr && Addr->stripInBoundsOffsets()->getName().starts_with(
+ getInstrProfCountersVarPrefix())) {
+ LLVM_DEBUG(dbgs() << "Missed candidate: "; I.dump());
----------------
david-xl wrote:
Make the debug message clearer: "Expect atomic update: "
https://github.com/llvm/llvm-project/pull/202487
More information about the cfe-commits
mailing list