@@ -777,8 +777,6 @@ void WebAssemblyLowerEmscriptenEHSjLj::rebuildSSA(Function &F) {
777
777
SSAUpdaterBulk SSA;
778
778
for (BasicBlock &BB : F) {
779
779
for (Instruction &I : BB) {
780
- if (I.getType ()->isVoidTy ())
781
- continue ;
782
780
unsigned VarID = SSA.AddVariable (I.getName (), I.getType ());
783
781
// If a value is defined by an invoke instruction, it is only available in
784
782
// its normal destination and not in its unwind destination.
@@ -1689,8 +1687,6 @@ void WebAssemblyLowerEmscriptenEHSjLj::handleLongjmpableCallsForWasmSjLj(
1689
1687
}
1690
1688
}
1691
1689
1692
- SmallDenseMap<BasicBlock *, SmallPtrSet<BasicBlock *, 4 >, 4 >
1693
- UnwindDestToNewPreds;
1694
1690
for (auto *CI : LongjmpableCalls) {
1695
1691
// Even if the callee function has attribute 'nounwind', which is true for
1696
1692
// all C functions, it can longjmp, which means it can throw a Wasm
@@ -1728,11 +1724,6 @@ void WebAssemblyLowerEmscriptenEHSjLj::handleLongjmpableCallsForWasmSjLj(
1728
1724
}
1729
1725
if (!UnwindDest)
1730
1726
UnwindDest = CatchDispatchLongjmpBB;
1731
- // Because we are changing a longjmpable call to an invoke, its unwind
1732
- // destination can be an existing EH pad that already have phis, and the BB
1733
- // with the newly created invoke will become a new predecessor of that EH
1734
- // pad. In this case we need to add the new predecessor to those phis.
1735
- UnwindDestToNewPreds[UnwindDest].insert (CI->getParent ());
1736
1727
changeToInvokeAndSplitBasicBlock (CI, UnwindDest);
1737
1728
}
1738
1729
@@ -1761,45 +1752,4 @@ void WebAssemblyLowerEmscriptenEHSjLj::handleLongjmpableCallsForWasmSjLj(
1761
1752
1762
1753
for (Instruction *I : ToErase)
1763
1754
I->eraseFromParent ();
1764
-
1765
- // Add entries for new predecessors to phis in unwind destinations. We use
1766
- // 'undef' as a placeholder value. We should make sure the phis have a valid
1767
- // set of predecessors before running SSAUpdater, because SSAUpdater
1768
- // internally can use existing phis to gather predecessor info rather than
1769
- // scanning the actual CFG (See FindPredecessorBlocks in SSAUpdater.cpp for
1770
- // details).
1771
- for (auto &[UnwindDest, NewPreds] : UnwindDestToNewPreds) {
1772
- for (PHINode &PN : UnwindDest->phis ()) {
1773
- for (auto *NewPred : NewPreds) {
1774
- assert (PN.getBasicBlockIndex (NewPred) == -1 );
1775
- PN.addIncoming (UndefValue::get (PN.getType ()), NewPred);
1776
- }
1777
- }
1778
- }
1779
-
1780
- // For unwind destinations for newly added invokes to longjmpable functions,
1781
- // calculate incoming values for the newly added predecessors using
1782
- // SSAUpdater. We add existing values in the phis to SSAUpdater as available
1783
- // values and let it calculate what the value should be at the end of new
1784
- // incoming blocks.
1785
- for (auto &[UnwindDest, NewPreds] : UnwindDestToNewPreds) {
1786
- for (PHINode &PN : UnwindDest->phis ()) {
1787
- SSAUpdater SSA;
1788
- SSA.Initialize (PN.getType (), PN.getName ());
1789
- for (unsigned Idx = 0 , E = PN.getNumIncomingValues (); Idx != E; ++Idx) {
1790
- if (NewPreds.contains (PN.getIncomingBlock (Idx)))
1791
- continue ;
1792
- Value *V = PN.getIncomingValue (Idx);
1793
- if (auto *II = dyn_cast<InvokeInst>(V))
1794
- SSA.AddAvailableValue (II->getNormalDest (), II);
1795
- else if (auto *I = dyn_cast<Instruction>(V))
1796
- SSA.AddAvailableValue (I->getParent (), I);
1797
- else
1798
- SSA.AddAvailableValue (PN.getIncomingBlock (Idx), V);
1799
- }
1800
- for (auto *NewPred : NewPreds)
1801
- PN.setIncomingValueForBlock (NewPred, SSA.GetValueAtEndOfBlock (NewPred));
1802
- assert (PN.isComplete ());
1803
- }
1804
- }
1805
1755
}
0 commit comments