Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions llvm/lib/CodeGen/TailDuplicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,14 @@ void TailDuplicator::processPHI(
if (!Remove)
return;

// Remove PredBB from the PHI node.
MI->removeOperand(SrcOpIdx + 1);
MI->removeOperand(SrcOpIdx);
// MI might have multiple entries for PredBB. Need to remove them all.
for (unsigned N = MI->getNumOperands(); N > 2; N -= 2) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought there was a helper for this somewhere? The IR has one, and isn't there one used in the MachineBasicBlock CFG helpers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've run grep by getMBB() and seems like there is no helper. PHI input removal code is seems to be re-implemented from scratch each time (or copy-pasted)

if (MI->getOperand(N - 1).getMBB() == PredBB) {
MI->removeOperand(N - 1);
MI->removeOperand(N - 2);
}
}

if (MI->getNumOperands() == 1 && !TailBB->hasAddressTaken())
MI->eraseFromParent();
else if (MI->getNumOperands() == 1)
Expand Down