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

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 3 22:36:09 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- llvm/lib/Analysis/AliasAnalysis.cpp llvm/unittests/Analysis/AliasAnalysisTest.cpp
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp
index ed46079ca..3f828f483 100644
--- a/llvm/lib/Analysis/AliasAnalysis.cpp
+++ b/llvm/lib/Analysis/AliasAnalysis.cpp
@@ -427,10 +427,10 @@ ModRefInfo AAResults::getModRefInfo(const LoadInst *L,
   // 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;
+  if (L->isAtomic()) {
+    if (Loc.Ptr &&
+        alias(MemoryLocation::get(L), Loc, AAQI, L) == AliasResult::MustAlias)
+      return ModRefInfo::ModRef;
   }
 
   // If the load address doesn't alias the given address, it doesn't read
diff --git a/llvm/unittests/Analysis/AliasAnalysisTest.cpp b/llvm/unittests/Analysis/AliasAnalysisTest.cpp
index 780fc966a..c4ce08cc3 100644
--- a/llvm/unittests/Analysis/AliasAnalysisTest.cpp
+++ b/llvm/unittests/Analysis/AliasAnalysisTest.cpp
@@ -436,7 +436,8 @@ TEST_F(AliasAnalysisTest, MonotonicAtomicLoadIsModRefOnlyForMustAlias) {
       %val = load atomic i8, i8* %p1 monotonic, align 1
       ret void
     }
-  )", Err, C);
+  )",
+                                                  Err, C);
 
   ASSERT_TRUE(M);
 
@@ -472,7 +473,8 @@ TEST_F(AliasAnalysisTest, MonotonicAtomicStoreAliasBehavior) {
       store atomic i8 0, i8* %p1 release, align 1
       ret void
     }
-  )", Err, C);
+  )",
+                                                  Err, C);
 
   ASSERT_TRUE(M);
 
@@ -487,11 +489,11 @@ TEST_F(AliasAnalysisTest, MonotonicAtomicStoreAliasBehavior) {
   auto &AA = getAAResults(*F);
 
   // 1. Test the Monotonic store.
-  // With the change, the Monotonic store should go through the 
+  // With the change, the Monotonic store should go through the
   // isStrongerThan() check. Since %p1 and %p2 are noalias, the alias check
   // should return NoAlias, resulting in NoModRef.
   EXPECT_EQ(ModRefInfo::NoModRef, AA.getModRefInfo(MonotonicStore, Ptr2Loc));
- 
+
   // 2. Test the Relase (stronger) store.
   // The release atomic store should be caught by the isStrongerThan() check.
   // return ModRef without performing an alias check.

``````````

</details>


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


More information about the llvm-commits mailing list