[llvm] [AA] A conservative fix for atomic store instruction. (PR #155032)
Jin Huang via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 3 23:53:28 PDT 2025
jinhuang1102 wrote:
Hi, I am back from vacation and have just pushed some updates to address the feedback from the previous review. The main functional change is in `llvm/lib/Analysis/AliasAnalysis.cpp` to refine the logic for atomic load instructions see below.
```
// Be conservative in the face of atomic.
if (isStrongerThan(L->getOrdering(), AtomicOrdering::Monotonic))
return ModRefInfo::ModRef;
// For Monotonic and unordered loads, we only need to be more conservative
// when the locations are MustAlias to prevent unsafe reordering of accesses
// to the same memory. For MayAlias, we can treat it as a normal read.
if (L->isAtomic()) {
if (Loc.Ptr &&
alias(MemoryLocation::get(L), Loc, AAQI, L) == AliasResult::MustAlias)
return ModRefInfo::ModRef;
}
```
Two new tests (`MonotonicAtomicLoadIsModRefOnlyForMustAlias` and `MonotonicAtomicStoreAliasBehavior`) are also added to `AliasAnalysisTest.cpp`.
The only functional changes are in these two files; other modifications are NFC (No Functional Change) from `clang-format`.
https://github.com/llvm/llvm-project/pull/155032
More information about the llvm-commits
mailing list