aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/LoopPeel.cpp
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2025-05-27 10:46:27 +0100
committerFlorian Hahn <flo@fhahn.com>2025-05-27 10:46:28 +0100
commitac9a466e39bf97ffeab127982aa7c405cb257551 (patch)
treec9f160a672ff836ca4a1572a413f6219e82703dd /llvm/lib/Transforms/Utils/LoopPeel.cpp
parent6da8f3bd5df2bb860f8cc32e9cfc739baf102295 (diff)
downloadllvm-ac9a466e39bf97ffeab127982aa7c405cb257551.zip
llvm-ac9a466e39bf97ffeab127982aa7c405cb257551.tar.gz
llvm-ac9a466e39bf97ffeab127982aa7c405cb257551.tar.bz2
[LoopPeel] Insert new phis before first non-PHI when peeling last iter.
Make sure the new phis are inserted before any non-phi instructions. This fixes a crash when dbg_value instructions are present in the original exit block.
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopPeel.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/LoopPeel.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopPeel.cpp b/llvm/lib/Transforms/Utils/LoopPeel.cpp
index e1dc052..4d43c6a 100644
--- a/llvm/lib/Transforms/Utils/LoopPeel.cpp
+++ b/llvm/lib/Transforms/Utils/LoopPeel.cpp
@@ -922,7 +922,7 @@ static void cloneLoopBlocks(
// InsertTop, using the incoming value from the preheader for the original
// preheader (when skipping the main loop) and the incoming value from the
// latch for the latch (when continuing from the main loop).
- IRBuilder<> B(InsertTop->getTerminator());
+ IRBuilder<> B(InsertTop, InsertTop->getFirstNonPHIIt());
for (BasicBlock::iterator I = Header->begin(); isa<PHINode>(I); ++I) {
PHINode *NewPHI = cast<PHINode>(VMap[&*I]);
PHINode *PN = B.CreatePHI(NewPHI->getType(), 2);