[llvm] [WebAssembly] Remove per-invoke EH_LABEL handling (PR #226053)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 24 00:53:39 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-webassembly
Author: Heejin Ahn (aheejin)
<details>
<summary>Changes</summary>
Per-invoke `EH_LABEL`s are no longer emitted after #<!-- -->225903. This removes code that handles them and mir tests that have them.
---
Full diff: https://github.com/llvm/llvm-project/pull/226053.diff
3 Files Affected:
- (modified) llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp (+7-31)
- (modified) llvm/test/CodeGen/WebAssembly/cfg-stackify-eh-legacy.mir (-6)
- (modified) llvm/test/CodeGen/WebAssembly/exception-legacy.mir (+2-9)
``````````diff
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
index 3c1cfe9ec571d..385aaf0c068ce 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
@@ -608,13 +608,6 @@ void WebAssemblyCFGStackifyImpl::placeTryMarker(MachineBasicBlock &MBB) {
if (MI.isCall()) {
AfterSet.insert(&MI);
ThrowingCall = &MI;
- // Possibly throwing calls are usually wrapped by EH_LABEL
- // instructions. We don't want to split them and the call.
- if (MI.getIterator() != Header->begin() &&
- std::prev(MI.getIterator())->isEHLabel()) {
- AfterSet.insert(&*std::prev(MI.getIterator()));
- ThrowingCall = &*std::prev(MI.getIterator());
- }
break;
}
}
@@ -624,9 +617,9 @@ void WebAssemblyCFGStackifyImpl::placeTryMarker(MachineBasicBlock &MBB) {
// Local expression tree should go after the TRY.
// For BLOCK placement, we start the search from the previous instruction of a
// BB's terminator, but in TRY's case, we should start from the previous
- // instruction of a call that can throw, or a EH_LABEL that precedes the call,
- // because the return values of the call's previous instructions can be
- // stackified and consumed by the throwing call.
+ // instruction of a call that can throw, because the return values of the
+ // call's previous instructions can be stackified and consumed by the throwing
+ // call.
auto SearchStartPt = ThrowingCall ? MachineBasicBlock::iterator(ThrowingCall)
: Header->getFirstTerminator();
for (auto I = SearchStartPt, E = Header->begin(); I != E; --I) {
@@ -798,13 +791,6 @@ void WebAssemblyCFGStackifyImpl::placeTryTableMarker(MachineBasicBlock &MBB) {
if (MI.isCall()) {
AfterSet.insert(&MI);
ThrowingCall = &MI;
- // Possibly throwing calls are usually wrapped by EH_LABEL
- // instructions. We don't want to split them and the call.
- if (MI.getIterator() != Header->begin() &&
- std::prev(MI.getIterator())->isEHLabel()) {
- AfterSet.insert(&*std::prev(MI.getIterator()));
- ThrowingCall = &*std::prev(MI.getIterator());
- }
break;
}
}
@@ -814,9 +800,9 @@ void WebAssemblyCFGStackifyImpl::placeTryTableMarker(MachineBasicBlock &MBB) {
// Local expression tree should go after the TRY_TABLE.
// For BLOCK placement, we start the search from the previous instruction of a
// BB's terminator, but in TRY_TABLE's case, we should start from the previous
- // instruction of a call that can throw, or a EH_LABEL that precedes the call,
- // because the return values of the call's previous instructions can be
- // stackified and consumed by the throwing call.
+ // instruction of a call that can throw, because the return values of the
+ // call's previous instructions can be stackified and consumed by the throwing
+ // call.
auto SearchStartPt = ThrowingCall ? MachineBasicBlock::iterator(ThrowingCall)
: Header->getFirstTerminator();
for (auto I = SearchStartPt, E = Header->begin(); I != E; --I) {
@@ -1926,18 +1912,8 @@ bool WebAssemblyCFGStackifyImpl::fixCallUnwindMismatches(MachineFunction &MF) {
if (EHPadStack.back() == UnwindDest)
continue;
- // Include EH_LABELs in the range before and after the invoke
- MachineInstr *RangeBegin = &MI, *RangeEnd = &MI;
- if (RangeBegin->getIterator() != MBB.begin() &&
- std::prev(RangeBegin->getIterator())->isEHLabel())
- RangeBegin = &*std::prev(RangeBegin->getIterator());
- if (std::next(RangeEnd->getIterator()) != MBB.end() &&
- std::next(RangeEnd->getIterator())->isEHLabel())
- RangeEnd = &*std::next(RangeEnd->getIterator());
-
// If not, record the range.
- UnwindDestToTryRanges[UnwindDest].push_back(
- TryRange(RangeBegin, RangeEnd));
+ UnwindDestToTryRanges[UnwindDest].push_back(TryRange(&MI, &MI));
LLVM_DEBUG(dbgs() << "- Call unwind mismatch: MBB = " << getBBName(&MBB)
<< "\nCall = " << MI
<< "\nOriginal dest = " << getBBName(UnwindDest)
diff --git a/llvm/test/CodeGen/WebAssembly/cfg-stackify-eh-legacy.mir b/llvm/test/CodeGen/WebAssembly/cfg-stackify-eh-legacy.mir
index 18ee0bdf69b9a..8181d77332e74 100644
--- a/llvm/test/CodeGen/WebAssembly/cfg-stackify-eh-legacy.mir
+++ b/llvm/test/CodeGen/WebAssembly/cfg-stackify-eh-legacy.mir
@@ -23,9 +23,7 @@ body: |
successors: %bb.1, %bb.3
; CHECK: bb.0:
; CHECK: TRY
- EH_LABEL <mcsymbol .Ltmp0>
CALL @foo, implicit-def dead $arguments, implicit $sp32, implicit $sp64
- EH_LABEL <mcsymbol .Ltmp1>
BR %bb.3, implicit-def dead $arguments
bb.1 (landing-pad):
@@ -89,15 +87,11 @@ body: |
; CHECK: END_TRY
bb.0:
successors: %bb.1, %bb.3, %bb.4
- EH_LABEL <mcsymbol .Ltmp0>
CALL @foo, implicit-def dead $arguments, implicit $sp32, implicit $sp64
- EH_LABEL <mcsymbol .Ltmp1>
bb.1:
successors: %bb.2, %bb.4
- EH_LABEL <mcsymbol .Ltmp2>
CALL @foo, implicit-def dead $arguments, implicit $sp32, implicit $sp64
- EH_LABEL <mcsymbol .Ltmp3>
bb.2:
%0:i32 = CONST_I32 3, implicit-def dead $arguments
diff --git a/llvm/test/CodeGen/WebAssembly/exception-legacy.mir b/llvm/test/CodeGen/WebAssembly/exception-legacy.mir
index 339a49c15ef6e..bb889a0cf1021 100644
--- a/llvm/test/CodeGen/WebAssembly/exception-legacy.mir
+++ b/llvm/test/CodeGen/WebAssembly/exception-legacy.mir
@@ -17,8 +17,8 @@
...
---
-# This tests 'try' and 'catch' instructions are correctly placed with respect to
-# EH_LABEL instructions.
+# This tests 'catch' instructions are correctly placed with respect to
+# EH_LABEL instructions in the beginning of an EH pad.
# CHECK-LABEL: name: eh_label_test
name: eh_label_test
liveins:
@@ -27,16 +27,11 @@ frameInfo:
hasCalls: true
body: |
bb.0:
- ; TRY should be before EH_LABEL wrappers of throwing calls
; CHECK: bb.0
; CHECK: TRY
- ; CHECK-NEXT: EH_LABEL
; CHECK-NEXT: CALL @foo
- ; CHECK-NEXT: EH_LABEL
successors: %bb.1, %bb.2
- EH_LABEL <mcsymbol .Ltmp0>
CALL @foo, implicit-def dead $arguments, implicit $sp32, implicit $sp64
- EH_LABEL <mcsymbol .Ltmp1>
BR %bb.2, implicit-def dead $arguments
bb.1 (landing-pad):
@@ -94,9 +89,7 @@ liveins:
body: |
bb.0:
successors: %bb.1, %bb.3
- EH_LABEL <mcsymbol .Ltmp0>
CALL @foo, implicit-def dead $arguments, implicit $sp32, implicit $sp64
- EH_LABEL <mcsymbol .Ltmp1>
BR %bb.3, implicit-def dead $arguments
;; Empty cleanuppad
``````````
</details>
https://github.com/llvm/llvm-project/pull/226053
More information about the llvm-commits
mailing list