[PATCH] D58319: [WebAssembly] Remove getBottom function from CFGStackify (NFC)

Heejin Ahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 15 20:03:38 PST 2019


aheejin created this revision.
aheejin added reviewers: dschuff, sunfish.
Herald added subscribers: llvm-commits, jdoerfert, jgravelle-google, sbc100.
Herald added a project: LLVM.

This removes `getBottom` function and the bookeeping map of <begin
marker instruction, bottom BB>.


Repository:
  rL LLVM

https://reviews.llvm.org/D58319

Files:
  lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp


Index: lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
===================================================================
--- lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
+++ lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
@@ -75,8 +75,6 @@
   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.
@@ -84,8 +82,6 @@
   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 @@
   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.
@@ -268,7 +243,9 @@
     // 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 @@
   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');


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58319.187127.patch
Type: text/x-patch
Size: 2852 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190216/a56df17b/attachment.bin>


More information about the llvm-commits mailing list