[llvm] 0818c28 - [WebAssembly] Simplify a switch-case in CFGStackify (NFC) (#107360)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 5 09:47:29 PDT 2024
Author: Heejin Ahn
Date: 2024-09-05T09:47:26-07:00
New Revision: 0818c2801ecc5cb07b680bb77e24df90f35c74b9
URL: https://github.com/llvm/llvm-project/commit/0818c2801ecc5cb07b680bb77e24df90f35c74b9
DIFF: https://github.com/llvm/llvm-project/commit/0818c2801ecc5cb07b680bb77e24df90f35c74b9.diff
LOG: [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.
Added:
Modified:
llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
llvm/lib/Target/WebAssembly/WebAssemblyInstrControl.td
Removed:
################################################################################
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
index 3362ea5316e452..3cccc57e629fd7 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
@@ -1681,18 +1681,14 @@ void WebAssemblyCFGStackify::rewriteDepthImmediates(MachineFunction &MF) {
Stack.pop_back();
break;
- case WebAssembly::END_BLOCK:
- Stack.push_back(std::make_pair(&MBB, &MI));
- break;
-
case WebAssembly::END_TRY: {
- // We handle DELEGATE in the default level, because DELEGATE has
- // immediate operands to rewrite.
- Stack.push_back(std::make_pair(&MBB, &MI));
auto *EHPad = TryToEHPad[EndToBegin[&MI]];
EHPadStack.push_back(EHPad);
- break;
+ [[fallthrough]];
}
+ case WebAssembly::END_BLOCK:
+ Stack.push_back(std::make_pair(&MBB, &MI));
+ break;
case WebAssembly::END_LOOP:
Stack.push_back(std::make_pair(EndToBegin[&MI]->getParent(), &MI));
@@ -1707,12 +1703,14 @@ void WebAssemblyCFGStackify::rewriteDepthImmediates(MachineFunction &MF) {
MI.getOperand(0).setImm(getRethrowDepth(Stack, EHPadStack));
break;
+ case WebAssembly::DELEGATE:
+ RewriteOperands(MI);
+ Stack.push_back(std::make_pair(&MBB, &MI));
+ break;
+
default:
if (MI.isTerminator())
RewriteOperands(MI);
-
- if (MI.getOpcode() == WebAssembly::DELEGATE)
- Stack.push_back(std::make_pair(&MBB, &MI));
break;
}
}
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrControl.td b/llvm/lib/Target/WebAssembly/WebAssemblyInstrControl.td
index dd40015577fd75..05880b89d1fbc6 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrControl.td
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrControl.td
@@ -147,9 +147,9 @@ let isTerminator = 1, hasSideEffects = 1, isBarrier = 1, hasCtrlDep = 1,
// usage gets low enough.
// Rethrowing an exception: rethrow
-let isTerminator = 1, hasCtrlDep = 1, isBarrier = 1 in {
+let isTerminator = 1, hasCtrlDep = 1, isBarrier = 1 in
defm RETHROW : NRI<(outs), (ins i32imm:$depth), [], "rethrow \t$depth", 0x09>;
-} // isTerminator = 1, hasCtrlDep = 1, isBarrier = 1
+// isTerminator = 1, hasCtrlDep = 1, isBarrier = 1
// The depth argument will be computed in CFGStackify. We set it to 0 here for
// now.
def : Pat<(int_wasm_rethrow), (RETHROW 0)>;
More information about the llvm-commits
mailing list