From 85631d8b509a18be718353aefd969d45ca4efb27 Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Fri, 22 Feb 2019 07:19:30 +0000 Subject: [PATCH] [WebAssembly] Remove getBottom function from CFGStackify (NFC) Summary: This removes `getBottom` function and the bookeeping map of . Reviewers: dschuff Subscribers: sunfish, sbc100, jgravelle-google, jdoerfert, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D58319 llvm-svn: 354657 --- .../WebAssembly/WebAssemblyCFGStackify.cpp | 31 +++---------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp index 49057ded0a684..02cb48d742fb1 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp @@ -75,8 +75,6 @@ class WebAssemblyCFGStackify final : public MachineFunctionPass { DenseMap TryToEHPad; // map DenseMap EHPadToTry; - // map - DenseMap BeginToBottom; // Helper functions to register scope information created by marker // instructions. @@ -84,8 +82,6 @@ class WebAssemblyCFGStackify final : public MachineFunctionPass { 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) {} @@ -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(); - const auto &WEI = getAnalysis(); - 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. @@ -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 @@ -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');