Skip to content

Commit 0818c28

Browse files
authored
[WebAssembly] Simplify a switch-case in CFGStackify (NFC) (#107360)
This merges some `case`s using `[[fallthrough]]`, and make `DELEGATE` as a separate `case`. (Previously the reason we didn't do that was not to duplicate the code in `RewriteOperands`. But now that we've extracted it into a lambda function in #107182 we can do it.
1 parent 5edede2 commit 0818c28

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,18 +1681,14 @@ void WebAssemblyCFGStackify::rewriteDepthImmediates(MachineFunction &MF) {
16811681
Stack.pop_back();
16821682
break;
16831683

1684-
case WebAssembly::END_BLOCK:
1685-
Stack.push_back(std::make_pair(&MBB, &MI));
1686-
break;
1687-
16881684
case WebAssembly::END_TRY: {
1689-
// We handle DELEGATE in the default level, because DELEGATE has
1690-
// immediate operands to rewrite.
1691-
Stack.push_back(std::make_pair(&MBB, &MI));
16921685
auto *EHPad = TryToEHPad[EndToBegin[&MI]];
16931686
EHPadStack.push_back(EHPad);
1694-
break;
1687+
[[fallthrough]];
16951688
}
1689+
case WebAssembly::END_BLOCK:
1690+
Stack.push_back(std::make_pair(&MBB, &MI));
1691+
break;
16961692

16971693
case WebAssembly::END_LOOP:
16981694
Stack.push_back(std::make_pair(EndToBegin[&MI]->getParent(), &MI));
@@ -1707,12 +1703,14 @@ void WebAssemblyCFGStackify::rewriteDepthImmediates(MachineFunction &MF) {
17071703
MI.getOperand(0).setImm(getRethrowDepth(Stack, EHPadStack));
17081704
break;
17091705

1706+
case WebAssembly::DELEGATE:
1707+
RewriteOperands(MI);
1708+
Stack.push_back(std::make_pair(&MBB, &MI));
1709+
break;
1710+
17101711
default:
17111712
if (MI.isTerminator())
17121713
RewriteOperands(MI);
1713-
1714-
if (MI.getOpcode() == WebAssembly::DELEGATE)
1715-
Stack.push_back(std::make_pair(&MBB, &MI));
17161714
break;
17171715
}
17181716
}

llvm/lib/Target/WebAssembly/WebAssemblyInstrControl.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ let isTerminator = 1, hasSideEffects = 1, isBarrier = 1, hasCtrlDep = 1,
147147
// usage gets low enough.
148148

149149
// Rethrowing an exception: rethrow
150-
let isTerminator = 1, hasCtrlDep = 1, isBarrier = 1 in {
150+
let isTerminator = 1, hasCtrlDep = 1, isBarrier = 1 in
151151
defm RETHROW : NRI<(outs), (ins i32imm:$depth), [], "rethrow \t$depth", 0x09>;
152-
} // isTerminator = 1, hasCtrlDep = 1, isBarrier = 1
152+
// isTerminator = 1, hasCtrlDep = 1, isBarrier = 1
153153
// The depth argument will be computed in CFGStackify. We set it to 0 here for
154154
// now.
155155
def : Pat<(int_wasm_rethrow), (RETHROW 0)>;

0 commit comments

Comments
 (0)