[llvm] a08e609 - [WebAssembly] Rename methods in WasmEHFuncInfo (NFC)
Heejin Ahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 22 12:16:27 PST 2021
Author: Heejin Ahn
Date: 2021-02-22T12:16:11-08:00
New Revision: a08e609d2eac7737bfc14cd4ee35b2cabe1238b6
URL: https://github.com/llvm/llvm-project/commit/a08e609d2eac7737bfc14cd4ee35b2cabe1238b6
DIFF: https://github.com/llvm/llvm-project/commit/a08e609d2eac7737bfc14cd4ee35b2cabe1238b6.diff
LOG: [WebAssembly] Rename methods in WasmEHFuncInfo (NFC)
This renames variable and method names in `WasmEHFuncInfo` class to be
simpler and clearer. For example, unwind destinations are EH pads by
definition so it doesn't necessarily need to be included in every method
name. Also I am planning to add the reverse mapping in a later CL,
something like `UnwindDestToSrc`, so this renaming will make meanings
clearer.
Reviewed By: dschuff
Differential Revision: https://reviews.llvm.org/D97173
Added:
Modified:
llvm/include/llvm/CodeGen/WasmEHFuncInfo.h
llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
llvm/lib/CodeGen/WasmEHPrepare.cpp
llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/WasmEHFuncInfo.h b/llvm/include/llvm/CodeGen/WasmEHFuncInfo.h
index 54e8c40a9e72..adcd16a5003f 100644
--- a/llvm/include/llvm/CodeGen/WasmEHFuncInfo.h
+++ b/llvm/include/llvm/CodeGen/WasmEHFuncInfo.h
@@ -31,27 +31,27 @@ 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> EHPadUnwindMap;
+ DenseMap<BBOrMBB, BBOrMBB> SrcToUnwindDest;
// Helper functions
- const BasicBlock *getEHPadUnwindDest(const BasicBlock *BB) const {
- return EHPadUnwindMap.lookup(BB).get<const BasicBlock *>();
+ const BasicBlock *getUnwindDest(const BasicBlock *BB) const {
+ return SrcToUnwindDest.lookup(BB).get<const BasicBlock *>();
}
- void setEHPadUnwindDest(const BasicBlock *BB, const BasicBlock *Dest) {
- EHPadUnwindMap[BB] = Dest;
+ void setUnwindDest(const BasicBlock *BB, const BasicBlock *Dest) {
+ SrcToUnwindDest[BB] = Dest;
}
- bool hasEHPadUnwindDest(const BasicBlock *BB) const {
- return EHPadUnwindMap.count(BB);
+ bool hasUnwindDest(const BasicBlock *BB) const {
+ return SrcToUnwindDest.count(BB);
}
- MachineBasicBlock *getEHPadUnwindDest(MachineBasicBlock *MBB) const {
- return EHPadUnwindMap.lookup(MBB).get<MachineBasicBlock *>();
+ MachineBasicBlock *getUnwindDest(MachineBasicBlock *MBB) const {
+ return SrcToUnwindDest.lookup(MBB).get<MachineBasicBlock *>();
}
- void setEHPadUnwindDest(MachineBasicBlock *MBB, MachineBasicBlock *Dest) {
- EHPadUnwindMap[MBB] = Dest;
+ void setUnwindDest(MachineBasicBlock *MBB, MachineBasicBlock *Dest) {
+ SrcToUnwindDest[MBB] = Dest;
}
- bool hasEHPadUnwindDest(MachineBasicBlock *MBB) const {
- return EHPadUnwindMap.count(MBB);
+ bool hasUnwindDest(MachineBasicBlock *MBB) const {
+ return SrcToUnwindDest.count(MBB);
}
};
diff --git a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
index 32a4f60df097..b5f2c1545827 100644
--- a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
@@ -335,12 +335,12 @@ void FunctionLoweringInfo::set(const Function &fn, MachineFunction &mf,
WasmEHFuncInfo &EHInfo = *MF->getWasmEHFuncInfo();
// Map all BB references in the WinEH data to MBBs.
DenseMap<BBOrMBB, BBOrMBB> NewMap;
- for (auto &KV : EHInfo.EHPadUnwindMap) {
+ for (auto &KV : EHInfo.SrcToUnwindDest) {
const auto *Src = KV.first.get<const BasicBlock *>();
const auto *Dst = KV.second.get<const BasicBlock *>();
NewMap[MBBMap[Src]] = MBBMap[Dst];
}
- EHInfo.EHPadUnwindMap = std::move(NewMap);
+ EHInfo.SrcToUnwindDest = std::move(NewMap);
}
}
diff --git a/llvm/lib/CodeGen/WasmEHPrepare.cpp b/llvm/lib/CodeGen/WasmEHPrepare.cpp
index 53424556682d..e21131cbf771 100644
--- a/llvm/lib/CodeGen/WasmEHPrepare.cpp
+++ b/llvm/lib/CodeGen/WasmEHPrepare.cpp
@@ -436,9 +436,9 @@ void llvm::calculateWasmEHInfo(const Function *F, WasmEHFuncInfo &EHInfo) {
const Instruction *UnwindPad = UnwindBB->getFirstNonPHI();
if (const auto *CatchSwitch = dyn_cast<CatchSwitchInst>(UnwindPad))
// Currently there should be only one handler per a catchswitch.
- EHInfo.setEHPadUnwindDest(&BB, *CatchSwitch->handlers().begin());
+ EHInfo.setUnwindDest(&BB, *CatchSwitch->handlers().begin());
else // cleanuppad
- EHInfo.setEHPadUnwindDest(&BB, UnwindBB);
+ EHInfo.setUnwindDest(&BB, UnwindBB);
}
}
}
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
index 7035f741d74f..1870979e9e3f 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
@@ -1330,7 +1330,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->hasEHPadUnwindDest(EHPad)) {
+ else if (EHPadStack.empty() && EHInfo->hasUnwindDest(EHPad)) {
LLVM_DEBUG(dbgs() << "EHPad (" << EHPad->getName()
<< "'s unwind destination does not exist anymore"
<< "\n\n");
@@ -1338,7 +1338,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() && !EHInfo->hasEHPadUnwindDest(EHPad)) {
+ else if (!EHPadStack.empty() && !EHInfo->hasUnwindDest(EHPad)) {
EHPadToUnwindDest[EHPad] = getFakeCallerBlock(MF);
LLVM_DEBUG(dbgs()
<< "- Catch unwind mismatch:\nEHPad = " << EHPad->getName()
@@ -1348,8 +1348,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->hasEHPadUnwindDest(EHPad)) {
- auto *UnwindDest = EHInfo->getEHPadUnwindDest(EHPad);
+ else if (!EHPadStack.empty() && EHInfo->hasUnwindDest(EHPad)) {
+ auto *UnwindDest = EHInfo->getUnwindDest(EHPad);
if (EHPadStack.back() != UnwindDest) {
EHPadToUnwindDest[EHPad] = UnwindDest;
LLVM_DEBUG(dbgs() << "- Catch unwind mismatch:\nEHPad = "
More information about the llvm-commits
mailing list