forked from OSchip/llvm-project
[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
This commit is contained in:
parent
e64fcdf8d5
commit
a08e609d2e
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 = "
|
||||
|
|
Loading…
Reference in New Issue