[llvm] [AA] A conservative fix for atomic store instruction. (PR #155032)

Jin Huang via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 22 14:32:45 PDT 2025


https://github.com/jinhuang1102 created https://github.com/llvm/llvm-project/pull/155032

The current atomic store check in function `AAResults::getModRefInfo` would compare to the `AtomicOrdering::Unordered` that mean any atomic store instruction will return `ModRefInfo::ModRef` without performing any further analysis on the memory location itself.

This PR raises the comparison form `Unordered` to `Monotonic`.


>From a74bb07bf260a4ab7758bb8c38340e9d9e8cf9fd Mon Sep 17 00:00:00 2001
From: Jin Huang <jingold at google.com>
Date: Fri, 22 Aug 2025 21:27:27 +0000
Subject: [PATCH] [AA] A conservative fix for atomic store instruction. The
 current atomic store check return all atomic store as a modify instruciton
 without any memory check. This pr will raise from unordered to Monotonic.

---
 llvm/lib/Analysis/AliasAnalysis.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp
index 3ec009ca4adde..b18ef88509b5c 100644
--- a/llvm/lib/Analysis/AliasAnalysis.cpp
+++ b/llvm/lib/Analysis/AliasAnalysis.cpp
@@ -439,7 +439,7 @@ ModRefInfo AAResults::getModRefInfo(const StoreInst *S,
                                     const MemoryLocation &Loc,
                                     AAQueryInfo &AAQI) {
   // Be conservative in the face of atomic.
-  if (isStrongerThan(S->getOrdering(), AtomicOrdering::Unordered))
+  if (isStrongerThan(S->getOrdering(), AtomicOrdering::Monotonic))
     return ModRefInfo::ModRef;
 
   if (Loc.Ptr) {



More information about the llvm-commits mailing list