[llvm] 1253e53 - [RemoveDIs] Use iterators for moving PHIs in loop-unroll-and-jam (#83003)

via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 26 07:20:59 PST 2024


Author: Jeremy Morse
Date: 2024-02-26T15:20:55Z
New Revision: 1253e535bd421b955cce1c67ed4304f2ae9bcdfd

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

LOG: [RemoveDIs] Use iterators for moving PHIs in loop-unroll-and-jam (#83003)

With no debug intrinsics, correctly identifying the start of a block
with iterators becomes important. We need to use the iterator-returning
methods here in loop-unroll-and-jam where we're shifting PHIs around.
Otherwise they can be inserted after debug-info records, leading to
debug-info attached to PHIs, which is ill formed.

Fixes #83000

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp b/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp
index 3c06a6e47a3035..26b8c790f2a062 100644
--- a/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp
@@ -473,9 +473,9 @@ llvm::UnrollAndJamLoop(Loop *L, unsigned Count, unsigned TripCount,
   };
   // Move all the phis from Src into Dest
   auto movePHIs = [](BasicBlock *Src, BasicBlock *Dest) {
-    Instruction *insertPoint = Dest->getFirstNonPHI();
+    BasicBlock::iterator insertPoint = Dest->getFirstNonPHIIt();
     while (PHINode *Phi = dyn_cast<PHINode>(Src->begin()))
-      Phi->moveBefore(insertPoint);
+      Phi->moveBefore(*Dest, insertPoint);
   };
 
   // Update the PHI values outside the loop to point to the last block


        


More information about the llvm-commits mailing list