Skip to content

Commit 3d60bca

Browse files
fhahnmahesh-attarde
authored andcommitted
[VPlan] Remove VPIRPhis in exit blocks when deleting scalar loop BBs.
DeleteDeadBlocks will remove single-entry phis. Remove them from the exit VPIRBBs in VPlan as well, otherwise we would retain references to deleted IR instructions. Fixes MSan failures after 8907b6d https://lab.llvm.org/buildbot/#/builders/164/builds/14013
1 parent 563d6d0 commit 3d60bca

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

llvm/lib/Transforms/Vectorize/VPlan.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,16 @@ void VPlan::execute(VPTransformState *State) {
978978

979979
// If the original loop is unreachable, delete it and all its blocks.
980980
if (!ScalarPhVPBB->hasPredecessors()) {
981+
// DeleteDeadBlocks will remove single-entry phis. Remove them from the exit
982+
// VPIRBBs in VPlan as well, otherwise we would retain references to deleted
983+
// IR instructions.
984+
for (VPIRBasicBlock *EB : getExitBlocks()) {
985+
for (VPRecipeBase &R : make_early_inc_range(EB->phis())) {
986+
if (R.getNumOperands() == 1)
987+
R.eraseFromParent();
988+
}
989+
}
990+
981991
Loop *OrigLoop =
982992
State->LI->getLoopFor(getScalarHeader()->getIRBasicBlock());
983993
auto Blocks = OrigLoop->getBlocksVector();

0 commit comments

Comments
 (0)