[PATCH] D59454: [WebAssembly] Small improvements in FixIrreducibleControlFlow (NFC)

Heejin Ahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 18 22:26:28 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL356440: [WebAssembly] Small improvements in FixIrreducibleControlFlow (NFC) (authored by aheejin, committed by ).

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59454/new/

https://reviews.llvm.org/D59454

Files:
  llvm/trunk/lib/Target/WebAssembly/WebAssemblyFixIrreducibleControlFlow.cpp


Index: llvm/trunk/lib/Target/WebAssembly/WebAssemblyFixIrreducibleControlFlow.cpp
===================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyFixIrreducibleControlFlow.cpp
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyFixIrreducibleControlFlow.cpp
@@ -52,19 +52,8 @@
 
 #include "MCTargetDesc/WebAssemblyMCTargetDesc.h"
 #include "WebAssembly.h"
-#include "WebAssemblyMachineFunctionInfo.h"
 #include "WebAssemblySubtarget.h"
-#include "llvm/ADT/PriorityQueue.h"
-#include "llvm/ADT/SCCIterator.h"
-#include "llvm/ADT/SetVector.h"
-#include "llvm/CodeGen/MachineDominators.h"
-#include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineInstrBuilder.h"
-#include "llvm/CodeGen/MachineLoopInfo.h"
-#include "llvm/CodeGen/MachineRegisterInfo.h"
-#include "llvm/CodeGen/Passes.h"
-#include "llvm/Support/Debug.h"
-#include "llvm/Support/raw_ostream.h"
 using namespace llvm;
 
 #define DEBUG_TYPE "wasm-fix-irreducible-control-flow"
@@ -94,22 +83,27 @@
     calculate();
   }
 
-  bool canReach(MachineBasicBlock *From, MachineBasicBlock *To) {
+  bool canReach(MachineBasicBlock *From, MachineBasicBlock *To) const {
     assert(inRegion(From) && inRegion(To));
-    return Reachable[From].count(To);
+    auto I = Reachable.find(From);
+    if (I == Reachable.end())
+      return false;
+    return I->second.count(To);
   }
 
   // "Loopers" are blocks that are in a loop. We detect these by finding blocks
   // that can reach themselves.
-  const BlockSet &getLoopers() { return Loopers; }
+  const BlockSet &getLoopers() const { return Loopers; }
 
   // Get all blocks that are loop entries.
-  const BlockSet &getLoopEntries() { return LoopEntries; }
+  const BlockSet &getLoopEntries() const { return LoopEntries; }
 
   // Get all blocks that enter a particular loop from outside.
-  const BlockSet &getLoopEnterers(MachineBasicBlock *LoopEntry) {
+  const BlockSet &getLoopEnterers(MachineBasicBlock *LoopEntry) const {
     assert(inRegion(LoopEntry));
-    return LoopEnterers[LoopEntry];
+    auto I = LoopEnterers.find(LoopEntry);
+    assert(I != LoopEnterers.end());
+    return I->second;
   }
 
 private:
@@ -119,7 +113,7 @@
   BlockSet Loopers, LoopEntries;
   DenseMap<MachineBasicBlock *, BlockSet> LoopEnterers;
 
-  bool inRegion(MachineBasicBlock *MBB) { return Blocks.count(MBB); }
+  bool inRegion(MachineBasicBlock *MBB) const { return Blocks.count(MBB); }
 
   // Maps a block to all the other blocks it can reach.
   DenseMap<MachineBasicBlock *, BlockSet> Reachable;
@@ -353,8 +347,8 @@
 
   // Add the jump table.
   const auto &TII = *MF.getSubtarget<WebAssemblySubtarget>().getInstrInfo();
-  MachineInstrBuilder MIB = BuildMI(*Dispatch, Dispatch->end(), DebugLoc(),
-                                    TII.get(WebAssembly::BR_TABLE_I32));
+  MachineInstrBuilder MIB =
+      BuildMI(Dispatch, DebugLoc(), TII.get(WebAssembly::BR_TABLE_I32));
 
   // Add the register which will be used to tell the jump table which block to
   // jump to.
@@ -406,11 +400,9 @@
 
       // Set the jump table's register of the index of the block we wish to
       // jump to, and jump to the jump table.
-      BuildMI(*Split, Split->end(), DebugLoc(), TII.get(WebAssembly::CONST_I32),
-              Reg)
+      BuildMI(Split, DebugLoc(), TII.get(WebAssembly::CONST_I32), Reg)
           .addImm(Indices[Entry]);
-      BuildMI(*Split, Split->end(), DebugLoc(), TII.get(WebAssembly::BR))
-          .addMBB(Dispatch);
+      BuildMI(Split, DebugLoc(), TII.get(WebAssembly::BR)).addMBB(Dispatch);
       Split->addSuccessor(Dispatch);
       Map[Entry] = Split;
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59454.191246.patch
Type: text/x-patch
Size: 3658 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190319/1444db8a/attachment.bin>


More information about the llvm-commits mailing list