Skip to content

Commit f3f0d99

Browse files
committed
Revert "[WebAssembly] Fix phi handling for Wasm SjLj (#99730)"
This reverts commit 2bf71b8. This broke the builbot at https://lab.llvm.org/buildbot/#/builders/110/builds/474.
1 parent 73ac953 commit f3f0d99

File tree

2 files changed

+0
-176
lines changed

2 files changed

+0
-176
lines changed

llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -777,8 +777,6 @@ void WebAssemblyLowerEmscriptenEHSjLj::rebuildSSA(Function &F) {
777777
SSAUpdaterBulk SSA;
778778
for (BasicBlock &BB : F) {
779779
for (Instruction &I : BB) {
780-
if (I.getType()->isVoidTy())
781-
continue;
782780
unsigned VarID = SSA.AddVariable(I.getName(), I.getType());
783781
// If a value is defined by an invoke instruction, it is only available in
784782
// its normal destination and not in its unwind destination.
@@ -1689,8 +1687,6 @@ void WebAssemblyLowerEmscriptenEHSjLj::handleLongjmpableCallsForWasmSjLj(
16891687
}
16901688
}
16911689

1692-
SmallDenseMap<BasicBlock *, SmallPtrSet<BasicBlock *, 4>, 4>
1693-
UnwindDestToNewPreds;
16941690
for (auto *CI : LongjmpableCalls) {
16951691
// Even if the callee function has attribute 'nounwind', which is true for
16961692
// all C functions, it can longjmp, which means it can throw a Wasm
@@ -1728,11 +1724,6 @@ void WebAssemblyLowerEmscriptenEHSjLj::handleLongjmpableCallsForWasmSjLj(
17281724
}
17291725
if (!UnwindDest)
17301726
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());
17361727
changeToInvokeAndSplitBasicBlock(CI, UnwindDest);
17371728
}
17381729

@@ -1761,45 +1752,4 @@ void WebAssemblyLowerEmscriptenEHSjLj::handleLongjmpableCallsForWasmSjLj(
17611752

17621753
for (Instruction *I : ToErase)
17631754
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-
}
18051755
}

llvm/test/CodeGen/WebAssembly/lower-wasm-ehsjlj-phi.ll

Lines changed: 0 additions & 126 deletions
This file was deleted.

0 commit comments

Comments
 (0)