[llvm] 6cad48a - [WebAssembly] Remove WasmEHFuncInfo (NFC) (#194972)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 29 16:51:35 PDT 2026
Author: Heejin Ahn
Date: 2026-04-29T16:51:30-07:00
New Revision: 6cad48ae72fbf344aab52cf28d51cb874dc30e20
URL: https://github.com/llvm/llvm-project/commit/6cad48ae72fbf344aab52cf28d51cb874dc30e20
DIFF: https://github.com/llvm/llvm-project/commit/6cad48ae72fbf344aab52cf28d51cb874dc30e20.diff
LOG: [WebAssembly] Remove WasmEHFuncInfo (NFC) (#194972)
This removes `WasmEHFuncInfo` class.
This class was created to maintain the information of, "If an exception
is not caught by EHPad A, what is its next unwind destination?". Turns
out this information is already in the CFG.
After #130374, we use the common `findUnwindDestination`:
https://github.com/llvm/llvm-project/blob/113479d119a997e4c4c3eae63e087588c9662121/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp#L2107-L2164
Note that in case of `catchswitch`, we follow its unwind destination
chain and add all of them to the invoke BB's successors until it meets a
`cleanuppad`, which always catches an exception. And the order of the
successor is the order of the unwind destination chain. So an invoke
BB's successor list would be like: [normal destination, unwind EHPad 1,
unwind EHPad 2, unwind EHPad 3, ...] where EHPad 2 is the next unwind
destination if EHPad 1 does not catch an exception and so on. So if we
want to know what the current EHPad's next unwind destination is, we can
examine the EHPad's predecessor (invoke BB)'s successor list, and find
the next successor of EHPad. If there is no further next unwind
destination, the list should end with that EHPad.
How we do this is in the added lambda functions in CFGStackify, which
replaces `WasmEHFuncInfo`'s `hasUnwindDest`/`getUnwindDest`.
This depends on the order of successors of a CFG, which someone can
argue may be not guaranteed, in case someone messes up the successor
order in later passes. But I think in practice this should be fine. Also
maintaining `WasmEHFuncInfo` has more risks, because if other passes
change EH-related CFGs, they have to make sure `WasmEHFuncInfo` stays
synced. I haven't personally found (so far) those passes and haven't had
to any adjustments to other passes, but it was always an inherent risk
when you maintain a separate data structure.
I wasn't able to completely delete `WasmEHFuncInfo.h` because it
contains the `Tag` enum. I renamed it to `WasmEHInfo.h`, because we
dont' have `WasmEHFuncInfo` class anymore.
Added:
llvm/include/llvm/CodeGen/WasmEHInfo.h
Modified:
llvm/include/llvm/CodeGen/MachineFunction.h
llvm/lib/CodeGen/MachineFunction.cpp
llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
llvm/lib/CodeGen/WasmEHPrepare.cpp
llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp
llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.h
llvm/test/CodeGen/WebAssembly/cfg-stackify-eh-legacy.mir
llvm/test/CodeGen/WebAssembly/function-info.mir
llvm/test/CodeGen/WebAssembly/multivalue-dont-move-def-past-use.mir
Removed:
llvm/include/llvm/CodeGen/WasmEHFuncInfo.h
################################################################################
diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h
index 61ce18da409d8..d620ae5137eba 100644
--- a/llvm/include/llvm/CodeGen/MachineFunction.h
+++ b/llvm/include/llvm/CodeGen/MachineFunction.h
@@ -72,7 +72,6 @@ class SlotIndexes;
class StringRef;
class TargetRegisterClass;
class TargetSubtargetInfo;
-struct WasmEHFuncInfo;
struct WinEHFuncInfo;
template <> struct ilist_alloc_traits<MachineBasicBlock> {
@@ -317,11 +316,6 @@ class LLVM_ABI MachineFunction {
// Keep track of the function section.
MCSection *Section = nullptr;
- // Catchpad unwind destination info for wasm EH.
- // Keeps track of Wasm exception handling related data. This will be null for
- // functions that aren't using a wasm EH personality.
- WasmEHFuncInfo *WasmEHInfo = nullptr;
-
// Keeps track of Windows exception handling related data. This will be null
// for functions that aren't using a funclet-based EH personality.
WinEHFuncInfo *WinEHInfo = nullptr;
@@ -826,12 +820,6 @@ class LLVM_ABI MachineFunction {
MachineConstantPool *getConstantPool() { return ConstantPool; }
const MachineConstantPool *getConstantPool() const { return ConstantPool; }
- /// getWasmEHFuncInfo - Return information about how the current function uses
- /// Wasm exception handling. Returns null for functions that don't use wasm
- /// exception handling.
- const WasmEHFuncInfo *getWasmEHFuncInfo() const { return WasmEHInfo; }
- WasmEHFuncInfo *getWasmEHFuncInfo() { return WasmEHInfo; }
-
/// getWinEHFuncInfo - Return information about how the current function uses
/// Windows exception handling. Returns null for functions that don't use
/// funclets for exception handling.
diff --git a/llvm/include/llvm/CodeGen/WasmEHFuncInfo.h b/llvm/include/llvm/CodeGen/WasmEHFuncInfo.h
deleted file mode 100644
index 3cfe7d1c79ea8..0000000000000
--- a/llvm/include/llvm/CodeGen/WasmEHFuncInfo.h
+++ /dev/null
@@ -1,65 +0,0 @@
-//===--- llvm/CodeGen/WasmEHFuncInfo.h --------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// Data structures for Wasm exception handling schemes.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CODEGEN_WASMEHFUNCINFO_H
-#define LLVM_CODEGEN_WASMEHFUNCINFO_H
-
-#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/PointerUnion.h"
-
-namespace llvm {
-
-class BasicBlock;
-class Function;
-class MachineBasicBlock;
-
-namespace WebAssembly {
-enum Tag { CPP_EXCEPTION = 0, C_LONGJMP = 1 };
-} // namespace WebAssembly
-
-using BBOrMBB = PointerUnion<const BasicBlock *, MachineBasicBlock *>;
-
-struct WasmEHFuncInfo {
- // When there is an entry <A, B>, if an exception is not caught by A, it
- // should next unwind to the EH pad B.
- DenseMap<BBOrMBB, BBOrMBB> SrcToUnwindDest;
-
- // Helper functions
- const BasicBlock *getUnwindDest(const BasicBlock *BB) const {
- assert(hasUnwindDest(BB));
- return cast<const BasicBlock *>(SrcToUnwindDest.lookup(BB));
- }
- void setUnwindDest(const BasicBlock *BB, const BasicBlock *Dest) {
- SrcToUnwindDest[BB] = Dest;
- }
- bool hasUnwindDest(const BasicBlock *BB) const {
- return SrcToUnwindDest.count(BB);
- }
-
- MachineBasicBlock *getUnwindDest(MachineBasicBlock *MBB) const {
- assert(hasUnwindDest(MBB));
- return cast<MachineBasicBlock *>(SrcToUnwindDest.lookup(MBB));
- }
- void setUnwindDest(MachineBasicBlock *MBB, MachineBasicBlock *Dest) {
- SrcToUnwindDest[MBB] = Dest;
- }
- bool hasUnwindDest(MachineBasicBlock *MBB) const {
- return SrcToUnwindDest.count(MBB);
- }
-};
-
-// Analyze the IR in the given function to build WasmEHFuncInfo.
-void calculateWasmEHInfo(const Function *F, WasmEHFuncInfo &EHInfo);
-
-} // namespace llvm
-
-#endif // LLVM_CODEGEN_WASMEHFUNCINFO_H
diff --git a/llvm/include/llvm/CodeGen/WasmEHInfo.h b/llvm/include/llvm/CodeGen/WasmEHInfo.h
new file mode 100644
index 0000000000000..9102f399e04ff
--- /dev/null
+++ b/llvm/include/llvm/CodeGen/WasmEHInfo.h
@@ -0,0 +1,24 @@
+//===--- llvm/CodeGen/WasmEHInfo.h ------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Data for Wasm exception handling schemes.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CODEGEN_WASMEHINFO_H
+#define LLVM_CODEGEN_WASMEHINFO_H
+
+namespace llvm {
+
+namespace WebAssembly {
+enum Tag { CPP_EXCEPTION = 0, C_LONGJMP = 1 };
+} // namespace WebAssembly
+
+} // namespace llvm
+
+#endif // LLVM_CODEGEN_WASMEHINFO_H
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp
index d56bca5b5a13f..edf448aee6922 100644
--- a/llvm/lib/CodeGen/MachineFunction.cpp
+++ b/llvm/lib/CodeGen/MachineFunction.cpp
@@ -39,7 +39,6 @@
#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
-#include "llvm/CodeGen/WasmEHFuncInfo.h"
#include "llvm/CodeGen/WinEHFuncInfo.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/IR/Attributes.h"
@@ -247,11 +246,6 @@ void MachineFunction::init() {
WinEHInfo = new (Allocator) WinEHFuncInfo();
}
- if (isScopedEHPersonality(classifyEHPersonality(
- F.hasPersonalityFn() ? F.getPersonalityFn() : nullptr))) {
- WasmEHInfo = new (Allocator) WasmEHFuncInfo();
- }
-
if (!Target.isCompatibleDataLayout(getDataLayout())) {
report_fatal_error(
formatv("Can't create a MachineFunction using a Module with a "
@@ -317,11 +311,6 @@ void MachineFunction::clear() {
WinEHInfo->~WinEHFuncInfo();
Allocator.Deallocate(WinEHInfo);
}
-
- if (WasmEHInfo) {
- WasmEHInfo->~WasmEHFuncInfo();
- Allocator.Deallocate(WasmEHInfo);
- }
}
const DataLayout &MachineFunction::getDataLayout() const {
diff --git a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
index e39e830449c8e..5edb992e68f4c 100644
--- a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
@@ -24,7 +24,6 @@
#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
-#include "llvm/CodeGen/WasmEHFuncInfo.h"
#include "llvm/CodeGen/WinEHFuncInfo.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
@@ -332,18 +331,6 @@ void FunctionLoweringInfo::set(const Function &fn, MachineFunction &mf,
UME.Handler = getMBB(cast<const BasicBlock *>(UME.Handler));
for (ClrEHUnwindMapEntry &CME : EHInfo.ClrEHUnwindMap)
CME.Handler = getMBB(cast<const BasicBlock *>(CME.Handler));
- } else if (Personality == EHPersonality::Wasm_CXX) {
- WasmEHFuncInfo &EHInfo = *MF->getWasmEHFuncInfo();
- calculateWasmEHInfo(&fn, EHInfo);
-
- // Map all BB references in the Wasm EH data to MBBs.
- DenseMap<BBOrMBB, BBOrMBB> SrcToUnwindDest;
- for (auto &KV : EHInfo.SrcToUnwindDest) {
- const auto *Src = cast<const BasicBlock *>(KV.first);
- const auto *Dest = cast<const BasicBlock *>(KV.second);
- SrcToUnwindDest[getMBB(Src)] = getMBB(Dest);
- }
- EHInfo.SrcToUnwindDest = std::move(SrcToUnwindDest);
}
}
diff --git a/llvm/lib/CodeGen/WasmEHPrepare.cpp b/llvm/lib/CodeGen/WasmEHPrepare.cpp
index 2f54578da5113..b83bcf67716f9 100644
--- a/llvm/lib/CodeGen/WasmEHPrepare.cpp
+++ b/llvm/lib/CodeGen/WasmEHPrepare.cpp
@@ -80,7 +80,7 @@
#include "llvm/CodeGen/WasmEHPrepare.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/Passes.h"
-#include "llvm/CodeGen/WasmEHFuncInfo.h"
+#include "llvm/CodeGen/WasmEHInfo.h"
#include "llvm/IR/EHPersonalities.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/IntrinsicsWebAssembly.h"
@@ -382,27 +382,3 @@ void WasmEHPrepareImpl::prepareEHPad(BasicBlock *BB, bool NeedPersonality,
GetSelectorCI->replaceAllUsesWith(Selector);
GetSelectorCI->eraseFromParent();
}
-
-void llvm::calculateWasmEHInfo(const Function *F, WasmEHFuncInfo &EHInfo) {
- // If an exception is not caught by a catchpad (i.e., it is a foreign
- // exception), it will unwind to its parent catchswitch's unwind destination.
- // We don't record an unwind destination for cleanuppads because every
- // exception should be caught by it.
- for (const auto &BB : *F) {
- if (!BB.isEHPad())
- continue;
- const Instruction *Pad = &*BB.getFirstNonPHIIt();
-
- if (const auto *CatchPad = dyn_cast<CatchPadInst>(Pad)) {
- const auto *UnwindBB = CatchPad->getCatchSwitch()->getUnwindDest();
- if (!UnwindBB)
- continue;
- const Instruction *UnwindPad = &*UnwindBB->getFirstNonPHIIt();
- if (const auto *CatchSwitch = dyn_cast<CatchSwitchInst>(UnwindPad))
- // Currently there should be only one handler per a catchswitch.
- EHInfo.setUnwindDest(&BB, *CatchSwitch->handlers().begin());
- else // cleanuppad
- EHInfo.setUnwindDest(&BB, UnwindBB);
- }
- }
-}
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
index 71d4effcd4d67..7d39e1074b026 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
@@ -34,7 +34,6 @@
#include "llvm/CodeGen/MachineDominators.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineLoopInfo.h"
-#include "llvm/CodeGen/WasmEHFuncInfo.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/Target/TargetMachine.h"
using namespace llvm;
@@ -2173,8 +2172,34 @@ bool WebAssemblyCFGStackify::fixCatchUnwindMismatches(MachineFunction &MF) {
// The right destination may be another EH pad or the caller. (The example
// here shows the case it is the caller.)
- const auto *EHInfo = MF.getWasmEHFuncInfo();
- assert(EHInfo);
+ // Returns whether the next unwind destination exists when an exception is not
+ // caught by the given EHPad. It is guaranteed that the next successor of the
+ // given EHPad's predecessor is the next unwind destination, due to the order
+ // we add successors in findUnwindDestinations in SelectionDAGBuilder.
+ auto HasUnwindDest = [&](const MachineBasicBlock *EHPad) {
+ assert(!EHPad->pred_empty() && "EHPad has no predecessors");
+ auto *InvokeBB = *EHPad->pred_begin();
+ for (auto I = InvokeBB->succ_begin(), E = InvokeBB->succ_end(); I != E; ++I)
+ if (*I == EHPad)
+ return std::next(I) != E;
+ llvm_unreachable("EHPad not found in its predecessor's successors");
+ };
+
+ // Returns the next unwind destination when an exception is not caught by the
+ // given EHPad. Returns nullptr when it doesn't exist.
+ auto GetUnwindDest = [&](const MachineBasicBlock *EHPad) {
+ assert(!EHPad->pred_empty() && "EHPad has no predecessors");
+ auto *InvokeBB = *EHPad->pred_begin();
+ for (auto I = InvokeBB->succ_begin(), E = InvokeBB->succ_end(); I != E;
+ ++I) {
+ if (*I == EHPad) {
+ auto *Next = std::next(I);
+ return Next == E ? nullptr : *Next;
+ }
+ }
+ llvm_unreachable("EHPad not found in its predecessor's successors");
+ };
+
SmallVector<const MachineBasicBlock *, 8> EHPadStack;
// For EH pads that have catch unwind mismatches, a map of <EH pad, its
// correct unwind destination>.
@@ -2196,7 +2221,7 @@ bool WebAssemblyCFGStackify::fixCatchUnwindMismatches(MachineFunction &MF) {
// This can happen when the unwind dest was removed during the
// optimization, e.g. because it was unreachable.
- else if (EHPadStack.empty() && EHInfo->hasUnwindDest(EHPad)) {
+ else if (EHPadStack.empty() && HasUnwindDest(EHPad)) {
LLVM_DEBUG(dbgs() << "EHPad (" << getBBName(EHPad)
<< "'s unwind destination does not exist anymore"
<< "\n\n");
@@ -2205,7 +2230,7 @@ bool WebAssemblyCFGStackify::fixCatchUnwindMismatches(MachineFunction &MF) {
// The EHPad's next unwind destination is the caller, but we incorrectly
// unwind to another EH pad.
else if (!EHPadStack.empty() && EHPadStack.back() != FakeCallerBB &&
- !EHInfo->hasUnwindDest(EHPad)) {
+ !HasUnwindDest(EHPad)) {
EHPadToUnwindDest[EHPad] = getFakeCallerBlock(MF);
LLVM_DEBUG(dbgs()
<< "- Catch unwind mismatch:\nEHPad = " << getBBName(EHPad)
@@ -2215,8 +2240,8 @@ bool WebAssemblyCFGStackify::fixCatchUnwindMismatches(MachineFunction &MF) {
// The EHPad's next unwind destination is an EH pad, whereas we
// incorrectly unwind to another EH pad.
- else if (!EHPadStack.empty() && EHInfo->hasUnwindDest(EHPad)) {
- auto *UnwindDest = EHInfo->getUnwindDest(EHPad);
+ else if (!EHPadStack.empty() && HasUnwindDest(EHPad)) {
+ auto *UnwindDest = GetUnwindDest(EHPad);
if (EHPadStack.back() != UnwindDest) {
EHPadToUnwindDest[EHPad] = UnwindDest;
LLVM_DEBUG(dbgs() << "- Catch unwind mismatch:\nEHPad = "
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
index 4a63be7ce9e34..510be1ca64fa8 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
@@ -19,7 +19,7 @@
#include "llvm/BinaryFormat/Wasm.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/SelectionDAGISel.h"
-#include "llvm/CodeGen/WasmEHFuncInfo.h"
+#include "llvm/CodeGen/WasmEHInfo.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/Function.h" // To access function attributes.
#include "llvm/IR/IntrinsicsWebAssembly.h"
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
index 8082ded8a5a14..664f0f2e25ffc 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
@@ -18,7 +18,6 @@
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
-#include "llvm/CodeGen/WasmEHFuncInfo.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/Support/Debug.h"
#include "llvm/Target/TargetMachine.h"
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
index 0afad4eed59d9..51b71ba646b42 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
@@ -265,7 +265,7 @@
#include "WebAssemblyTargetMachine.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/CodeGen/TargetPassConfig.h"
-#include "llvm/CodeGen/WasmEHFuncInfo.h"
+#include "llvm/CodeGen/WasmEHInfo.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/IRBuilder.h"
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp
index d1f4894c4a5af..696a9529e432d 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp
@@ -18,7 +18,6 @@
#include "WebAssemblySubtarget.h"
#include "WebAssemblyUtilities.h"
#include "llvm/CodeGen/Analysis.h"
-#include "llvm/CodeGen/WasmEHFuncInfo.h"
#include "llvm/Target/TargetMachine.h"
using namespace llvm;
@@ -28,8 +27,6 @@ MachineFunctionInfo *WebAssemblyFunctionInfo::clone(
BumpPtrAllocator &Allocator, MachineFunction &DestMF,
const DenseMap<MachineBasicBlock *, MachineBasicBlock *> &Src2DstMBB)
const {
- // TODO: Implement cloning for WasmEHFuncInfo. This will have invalid block
- // references.
return DestMF.cloneInfo<WebAssemblyFunctionInfo>(*this);
}
@@ -134,24 +131,6 @@ yaml::WebAssemblyFunctionInfo::WebAssemblyFunctionInfo(
Params.push_back(EVT(VT).getEVTString());
for (auto VT : MFI.getResults())
Results.push_back(EVT(VT).getEVTString());
-
- // MFI.getWasmEHFuncInfo() is non-null only for functions with the
- // personality function.
-
- if (auto *EHInfo = MF.getWasmEHFuncInfo()) {
- // SrcToUnwindDest can contain stale mappings in case BBs are removed in
- // optimizations, in case, for example, they are unreachable. We should not
- // include their info.
- SmallPtrSet<const MachineBasicBlock *, 16> MBBs;
- for (const auto &MBB : MF)
- MBBs.insert(&MBB);
- for (auto KV : EHInfo->SrcToUnwindDest) {
- auto *SrcBB = cast<MachineBasicBlock *>(KV.first);
- auto *DestBB = cast<MachineBasicBlock *>(KV.second);
- if (MBBs.count(SrcBB) && MBBs.count(DestBB))
- SrcToUnwindDest[SrcBB->getNumber()] = DestBB->getNumber();
- }
- }
}
void yaml::WebAssemblyFunctionInfo::mappingImpl(yaml::IO &YamlIO) {
@@ -165,13 +144,4 @@ void WebAssemblyFunctionInfo::initializeBaseYamlFields(
addParam(WebAssembly::parseMVT(VT.Value));
for (auto VT : YamlMFI.Results)
addResult(WebAssembly::parseMVT(VT.Value));
-
- // FIXME: WasmEHInfo is defined in the MachineFunction, but serialized
- // here. Either WasmEHInfo should be moved out of MachineFunction, or the
- // serialization handling should be moved to MachineFunction.
- if (WasmEHFuncInfo *WasmEHInfo = MF.getWasmEHFuncInfo()) {
- for (auto KV : YamlMFI.SrcToUnwindDest)
- WasmEHInfo->setUnwindDest(MF.getBlockNumbered(KV.first),
- MF.getBlockNumbered(KV.second));
- }
}
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.h b/llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.h
index 0e913fb1ee669..3d1c2a08fb00a 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.h
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.h
@@ -23,8 +23,6 @@
namespace llvm {
class WebAssemblyTargetLowering;
-struct WasmEHFuncInfo;
-
namespace yaml {
struct WebAssemblyFunctionInfo;
}
@@ -183,9 +181,6 @@ struct WebAssemblyFunctionInfo final : public yaml::MachineFunctionInfo {
std::vector<FlowStringValue> Params;
std::vector<FlowStringValue> Results;
bool CFGStackified = false;
- // The same as WasmEHFuncInfo's SrcToUnwindDest, but stored in the mapping of
- // BB numbers
- BBNumberMap SrcToUnwindDest;
WebAssemblyFunctionInfo() = default;
WebAssemblyFunctionInfo(const llvm::MachineFunction &MF,
@@ -200,19 +195,6 @@ template <> struct MappingTraits<WebAssemblyFunctionInfo> {
YamlIO.mapOptional("params", MFI.Params, std::vector<FlowStringValue>());
YamlIO.mapOptional("results", MFI.Results, std::vector<FlowStringValue>());
YamlIO.mapOptional("isCFGStackified", MFI.CFGStackified, false);
- YamlIO.mapOptional("wasmEHFuncInfo", MFI.SrcToUnwindDest);
- }
-};
-
-template <> struct CustomMappingTraits<BBNumberMap> {
- static void inputOne(IO &YamlIO, StringRef Key,
- BBNumberMap &SrcToUnwindDest) {
- YamlIO.mapRequired(Key, SrcToUnwindDest[std::atoi(Key.str().c_str())]);
- }
-
- static void output(IO &YamlIO, BBNumberMap &SrcToUnwindDest) {
- for (auto [Src, Dest] : SrcToUnwindDest)
- YamlIO.mapRequired(std::to_string(Src), Dest);
}
};
diff --git a/llvm/test/CodeGen/WebAssembly/cfg-stackify-eh-legacy.mir b/llvm/test/CodeGen/WebAssembly/cfg-stackify-eh-legacy.mir
index d5fbf41d39031..324dd29f2295e 100644
--- a/llvm/test/CodeGen/WebAssembly/cfg-stackify-eh-legacy.mir
+++ b/llvm/test/CodeGen/WebAssembly/cfg-stackify-eh-legacy.mir
@@ -70,8 +70,6 @@ liveins:
machineFunctionInfo:
params: [ ]
results: [ i32 ]
- wasmEHFuncInfo:
- 3: 4
body: |
; CHECK: TRY 127
; CHECK: TRY 127
@@ -90,7 +88,7 @@ body: |
; CHECK: RETHROW
; CHECK: END_TRY
bb.0:
- successors: %bb.1, %bb.3
+ 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>
diff --git a/llvm/test/CodeGen/WebAssembly/function-info.mir b/llvm/test/CodeGen/WebAssembly/function-info.mir
index 0a8740927834e..b81cdffde819f 100644
--- a/llvm/test/CodeGen/WebAssembly/function-info.mir
+++ b/llvm/test/CodeGen/WebAssembly/function-info.mir
@@ -8,9 +8,6 @@
define void @function_property_test() {
ret void
}
- define void @wasm_eh_info_test() personality ptr @__gxx_wasm_personality_v0 {
- ret void
- }
;; Param / results tests
define i32 @i32__i64(i64) {
@@ -39,37 +36,6 @@ body: |
RETURN implicit-def dead $arguments
...
----
-# CHECK-LABEL: name: wasm_eh_info_test
-# CHECK: machineFunctionInfo:
-name: wasm_eh_info_test
-liveins:
- - { reg: '$arguments' }
-# CHECK: wasmEHFuncInfo:
-# bb.2 becomes bb.1 and bb.3 becomes bb.2 after CFGSort.
-# CHECK-NEXT: 1: 2
-machineFunctionInfo:
- wasmEHFuncInfo:
- 2: 3
-body: |
- bb.0:
- successors: %bb.1, %bb.2, %bb.3
- CALL @foo, implicit-def dead $arguments, implicit $sp32, implicit $sp64, implicit-def dead $arguments, implicit $sp32, implicit $sp64
-
- bb.1:
- RETURN implicit-def dead $arguments
-
- bb.2 (landing-pad):
- successors: %bb.1, %bb.3
- %0:i32 = CATCH_LEGACY &__cpp_exception, implicit-def dead $arguments
- CALL @foo, implicit-def dead $arguments, implicit $sp32, implicit $sp64, implicit-def dead $arguments, implicit $sp32, implicit $sp64
- BR %bb.1, implicit-def $arguments
-
- bb.3 (landing-pad):
- CATCH_ALL_LEGACY implicit-def $arguments
- RETHROW 0, implicit-def $arguments
-...
-
# Param / results tests
---
# CHECK-LABEL: name: i32__i64
diff --git a/llvm/test/CodeGen/WebAssembly/multivalue-dont-move-def-past-use.mir b/llvm/test/CodeGen/WebAssembly/multivalue-dont-move-def-past-use.mir
index 7e928a559613b..ad5dff7bc7a4b 100644
--- a/llvm/test/CodeGen/WebAssembly/multivalue-dont-move-def-past-use.mir
+++ b/llvm/test/CodeGen/WebAssembly/multivalue-dont-move-def-past-use.mir
@@ -84,7 +84,6 @@ machineFunctionInfo:
params: [ ]
results: [ i32 ]
isCFGStackified: false
- wasmEHFuncInfo: {}
body: |
bb.0.entry:
liveins: $arguments
More information about the llvm-commits
mailing list