From a08e609d2eac7737bfc14cd4ee35b2cabe1238b6 Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Sun, 21 Feb 2021 10:10:47 -0800 Subject: [PATCH] [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 --- llvm/include/llvm/CodeGen/WasmEHFuncInfo.h | 26 +++++++++++----------- .../CodeGen/SelectionDAG/FunctionLoweringInfo.cpp | 4 ++-- llvm/lib/CodeGen/WasmEHPrepare.cpp | 4 ++-- .../Target/WebAssembly/WebAssemblyCFGStackify.cpp | 8 +++---- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/llvm/include/llvm/CodeGen/WasmEHFuncInfo.h b/llvm/include/llvm/CodeGen/WasmEHFuncInfo.h index 54e8c40..adcd16a 100644 --- a/llvm/include/llvm/CodeGen/WasmEHFuncInfo.h +++ b/llvm/include/llvm/CodeGen/WasmEHFuncInfo.h @@ -31,27 +31,27 @@ using BBOrMBB = PointerUnion; struct WasmEHFuncInfo { // When there is an entry , if an exception is not caught by A, it // should next unwind to the EH pad B. - DenseMap EHPadUnwindMap; + DenseMap SrcToUnwindDest; // Helper functions - const BasicBlock *getEHPadUnwindDest(const BasicBlock *BB) const { - return EHPadUnwindMap.lookup(BB).get(); + const BasicBlock *getUnwindDest(const BasicBlock *BB) const { + return SrcToUnwindDest.lookup(BB).get(); } - 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 *getUnwindDest(MachineBasicBlock *MBB) const { + return SrcToUnwindDest.lookup(MBB).get(); } - 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 32a4f60..b5f2c15 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 NewMap; - for (auto &KV : EHInfo.EHPadUnwindMap) { + for (auto &KV : EHInfo.SrcToUnwindDest) { const auto *Src = KV.first.get(); const auto *Dst = KV.second.get(); 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 5342455..e21131c 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(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 7035f74..1870979 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 = " -- 2.7.4