Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 2f64673

Browse files
committed
queue phi changes for all parts of legalizing switches, as they may not be ready yet; fixes emscripten#2539
1 parent 0304158 commit 2f64673

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/Target/JSBackend/ExpandI64.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -895,17 +895,22 @@ bool ExpandI64::splitInst(Instruction *I) {
895895
HighSI->addCase(cast<ConstantInt>(ConstantInt::get(i32, V[i].first)), BB);
896896
// fix phis, we used to go SwitchBB->BB, but now go SwitchBB->NewBB->BB, so we look like we arrived from NewBB. Replace the phi from the
897897
// now unneeded SwitchBB to the new BB
898+
// We cannot do this here right now, as phis we encounter may be in the middle of processing (empty), so we queue these.
898899
for (BasicBlock::iterator I = BB->begin(); I != BB->end(); ++I) {
899900
PHINode *Phi = dyn_cast<PHINode>(I);
900901
if (!Phi) break;
901-
Phi->setIncomingBlock(Phi->getBasicBlockIndex(SwitchBB), NewBB);
902+
PhiBlockChange Change;
903+
Change.DD = BB;
904+
Change.SwitchBB = SwitchBB;
905+
Change.NewBB = NewBB;
906+
PhiBlockChanges.push_back(Change);
907+
break; // we saw a phi on this BB, and pushed a Change
902908
}
903909
}
904910

905911
// We used to go SwitchBB->DD, but now go SwitchBB->NewBB->DD, fix that like with BB above. However here we do not replace,
906912
// as the switch BB is still possible to arrive from - we can arrive at the default if either the lower bits were wrong (we
907913
// arrive from the switchBB) or from the NewBB if the high bits were wrong.
908-
// We cannot do this here right now, as phis we encounter may be in the middle of processing (empty), so we queue these.
909914
PhiBlockChange Change;
910915
Change.DD = DD;
911916
Change.SwitchBB = SwitchBB;

0 commit comments

Comments
 (0)