[llvm] 5cd9fa5 - Fix computation of MadeChange bit in AtomicExpandPass.

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 18 13:47:29 PDT 2022


Author: Eli Friedman
Date: 2022-03-18T13:47:11-07:00
New Revision: 5cd9fa551e4f22de63351bda44113428fe53fcdb

URL: https://github.com/llvm/llvm-project/commit/5cd9fa551e4f22de63351bda44113428fe53fcdb
DIFF: https://github.com/llvm/llvm-project/commit/5cd9fa551e4f22de63351bda44113428fe53fcdb.diff

LOG: Fix computation of MadeChange bit in AtomicExpandPass.

Fixes llvm-clang-x86_64-expensive-checks-debian failure with 2f497ec3.

expandAtomicStore always modifies the function, so make sure we set
MadeChange unconditionally. Not sure how nobody else has stumbled over
this before.

Added: 
    

Modified: 
    llvm/lib/CodeGen/AtomicExpandPass.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/AtomicExpandPass.cpp b/llvm/lib/CodeGen/AtomicExpandPass.cpp
index 1f7f7839bdfc0..45b41ce7a5082 100644
--- a/llvm/lib/CodeGen/AtomicExpandPass.cpp
+++ b/llvm/lib/CodeGen/AtomicExpandPass.cpp
@@ -77,7 +77,7 @@ class AtomicExpand : public FunctionPass {
   bool expandAtomicLoadToLL(LoadInst *LI);
   bool expandAtomicLoadToCmpXchg(LoadInst *LI);
   StoreInst *convertAtomicStoreToIntegerType(StoreInst *SI);
-  bool expandAtomicStore(StoreInst *SI);
+  void expandAtomicStore(StoreInst *SI);
   bool tryExpandAtomicRMW(AtomicRMWInst *AI);
   AtomicRMWInst *convertAtomicXchgToIntegerType(AtomicRMWInst *RMWI);
   Value *
@@ -271,8 +271,10 @@ bool AtomicExpand::runOnFunction(Function &F) {
         MadeChange = true;
       }
 
-      if (TLI->shouldExpandAtomicStoreInIR(SI))
-        MadeChange |= expandAtomicStore(SI);
+      if (TLI->shouldExpandAtomicStoreInIR(SI)) {
+        expandAtomicStore(SI);
+        MadeChange = true;
+      }
     } else if (RMWI) {
       // There are two 
diff erent ways of expanding RMW instructions:
       // - into a load if it is idempotent
@@ -481,7 +483,7 @@ StoreInst *AtomicExpand::convertAtomicStoreToIntegerType(StoreInst *SI) {
   return NewSI;
 }
 
-bool AtomicExpand::expandAtomicStore(StoreInst *SI) {
+void AtomicExpand::expandAtomicStore(StoreInst *SI) {
   // This function is only called on atomic stores that are too large to be
   // atomic if implemented as a native store. So we replace them by an
   // atomic swap, that can be implemented for example as a ldrex/strex on ARM
@@ -495,7 +497,7 @@ bool AtomicExpand::expandAtomicStore(StoreInst *SI) {
   SI->eraseFromParent();
 
   // Now we have an appropriate swap instruction, lower it as usual.
-  return tryExpandAtomicRMW(AI);
+  tryExpandAtomicRMW(AI);
 }
 
 static void createCmpXchgInstFun(IRBuilder<> &Builder, Value *Addr,


        


More information about the llvm-commits mailing list