mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-12 13:38:21 +00:00
[SwitchLowering] Handle destinations on multiple phi instructions
Follow up from r222926. Also handle multiple destinations from merged cases on multiple and subsequent phi instructions. rdar://problem/19106978 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223135 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -149,6 +149,7 @@ static void fixPhis(BasicBlock *SuccBB, BasicBlock *OrigBB, BasicBlock *NewBB,
|
||||
|
||||
// Only update the first occurence.
|
||||
unsigned Idx = 0, E = PN->getNumIncomingValues();
|
||||
unsigned LocalNumMergedCases = NumMergedCases;
|
||||
for (; Idx != E; ++Idx) {
|
||||
if (PN->getIncomingBlock(Idx) == OrigBB) {
|
||||
PN->setIncomingBlock(Idx, NewBB);
|
||||
@ -158,10 +159,10 @@ static void fixPhis(BasicBlock *SuccBB, BasicBlock *OrigBB, BasicBlock *NewBB,
|
||||
|
||||
// Remove additional occurences coming from condensed cases and keep the
|
||||
// number of incoming values equal to the number of branches to SuccBB.
|
||||
for (++Idx; NumMergedCases > 0 && Idx != E; ++Idx)
|
||||
for (++Idx; LocalNumMergedCases > 0 && Idx < E; ++Idx)
|
||||
if (PN->getIncomingBlock(Idx) == OrigBB) {
|
||||
PN->removeIncomingValue(Idx);
|
||||
NumMergedCases--;
|
||||
LocalNumMergedCases--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user