Skip to content

Commit

Permalink
[WebAssembly] Remove getBottom function from CFGStackify (NFC)
Browse files Browse the repository at this point in the history
Summary:
This removes `getBottom` function and the bookeeping map of <begin
marker instruction, bottom BB>.

Reviewers: dschuff

Subscribers: sunfish, sbc100, jgravelle-google, jdoerfert, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D58319

llvm-svn: 354657
  • Loading branch information
aheejin committed Feb 22, 2019
1 parent 90d2e3a commit 85631d8
Showing 1 changed file with 4 additions and 27 deletions.
31 changes: 4 additions & 27 deletions llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
Expand Up @@ -75,17 +75,13 @@ class WebAssemblyCFGStackify final : public MachineFunctionPass {
DenseMap<const MachineInstr *, MachineBasicBlock *> TryToEHPad;
// <EH pad, TRY marker> map
DenseMap<const MachineBasicBlock *, MachineInstr *> EHPadToTry;
// <LOOP|TRY marker, Loop/exception bottom BB> map
DenseMap<const MachineInstr *, MachineBasicBlock *> BeginToBottom;

// Helper functions to register scope information created by marker
// instructions.
void registerScope(MachineInstr *Begin, MachineInstr *End);
void registerTryScope(MachineInstr *Begin, MachineInstr *End,
MachineBasicBlock *EHPad);

MachineBasicBlock *getBottom(const MachineInstr *Begin);

public:
static char ID; // Pass identification, replacement for typeid
WebAssemblyCFGStackify() : MachineFunctionPass(ID) {}
Expand Down Expand Up @@ -179,27 +175,6 @@ void WebAssemblyCFGStackify::registerTryScope(MachineInstr *Begin,
EHPadToTry[EHPad] = Begin;
}

// Given a LOOP/TRY marker, returns its bottom BB. Use cached information if any
// to prevent recomputation.
MachineBasicBlock *
WebAssemblyCFGStackify::getBottom(const MachineInstr *Begin) {
const auto &MLI = getAnalysis<MachineLoopInfo>();
const auto &WEI = getAnalysis<WebAssemblyExceptionInfo>();
if (BeginToBottom.count(Begin))
return BeginToBottom[Begin];
if (Begin->getOpcode() == WebAssembly::LOOP) {
MachineLoop *L = MLI.getLoopFor(Begin->getParent());
assert(L);
BeginToBottom[Begin] = WebAssembly::getBottom(L);
} else if (Begin->getOpcode() == WebAssembly::TRY) {
WebAssemblyException *WE = WEI.getExceptionFor(TryToEHPad[Begin]);
assert(WE);
BeginToBottom[Begin] = WebAssembly::getBottom(WE);
} else
assert(false);
return BeginToBottom[Begin];
}

/// Insert a BLOCK marker for branches to MBB (if needed).
void WebAssemblyCFGStackify::placeBlockMarker(MachineBasicBlock &MBB) {
// This should have been handled in placeTryMarker.
Expand Down Expand Up @@ -268,7 +243,9 @@ void WebAssemblyCFGStackify::placeBlockMarker(MachineBasicBlock &MBB) {
// the BLOCK.
if (MI.getOpcode() == WebAssembly::LOOP ||
MI.getOpcode() == WebAssembly::TRY) {
if (MBB.getNumber() > getBottom(&MI)->getNumber())
auto *BottomBB =
&*std::prev(MachineFunction::iterator(BeginToEnd[&MI]->getParent()));
if (MBB.getNumber() > BottomBB->getNumber())
AfterSet.insert(&MI);
#ifndef NDEBUG
else
Expand Down Expand Up @@ -770,10 +747,10 @@ void WebAssemblyCFGStackify::releaseMemory() {
EndToBegin.clear();
TryToEHPad.clear();
EHPadToTry.clear();
BeginToBottom.clear();
}

bool WebAssemblyCFGStackify::runOnMachineFunction(MachineFunction &MF) {
errs() << "Function: " << MF.getName() << "\n";
LLVM_DEBUG(dbgs() << "********** CFG Stackifying **********\n"
"********** Function: "
<< MF.getName() << '\n');
Expand Down

0 comments on commit 85631d8

Please sign in to comment.