[llvm] d2e9532 - [DemoteRegToStack] Use correct variable for branch instructions in DemoteRegToStack (#113798)

via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 27 02:09:42 PDT 2024


Author: Eirik Byrkjeflot Anonsen
Date: 2024-10-27T17:09:39+08:00
New Revision: d2e9532fe12dc2568f40c2648ff4bb3730141aed

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

LOG: [DemoteRegToStack] Use correct variable for branch instructions in DemoteRegToStack (#113798)

I happened to see this code, and it seems "obviously" wrong to me. So
here's what I think this code is supposed to look like.

Added: 
    

Modified: 
    llvm/lib/Transforms/Utils/DemoteRegToStack.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/DemoteRegToStack.cpp b/llvm/lib/Transforms/Utils/DemoteRegToStack.cpp
index 3a33b591d35582..6337913cdbbeb7 100644
--- a/llvm/lib/Transforms/Utils/DemoteRegToStack.cpp
+++ b/llvm/lib/Transforms/Utils/DemoteRegToStack.cpp
@@ -55,8 +55,8 @@ AllocaInst *llvm::DemoteRegToStack(Instruction &I, bool VolatileLoads,
     for (unsigned i = 0; i < CBI->getNumSuccessors(); i++) {
       auto *Succ = CBI->getSuccessor(i);
       if (!Succ->getSinglePredecessor()) {
-        assert(isCriticalEdge(II, i) && "Expected a critical edge!");
-        [[maybe_unused]] BasicBlock *BB = SplitCriticalEdge(II, i);
+        assert(isCriticalEdge(CBI, i) && "Expected a critical edge!");
+        [[maybe_unused]] BasicBlock *BB = SplitCriticalEdge(CBI, i);
         assert(BB && "Unable to split critical edge.");
       }
     }


        


More information about the llvm-commits mailing list