Skip to content

[WebAssembly] Simplify a switch-case in CFGStackify (NFC) #107360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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;
}
}
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/WebAssembly/WebAssemblyInstrControl.td
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drive-by fix

// The depth argument will be computed in CFGStackify. We set it to 0 here for
// now.
def : Pat<(int_wasm_rethrow), (RETHROW 0)>;
Expand Down
Loading