[PATCH] D68297: [Local] Remove unused LazyValueInfo pointer from removeUnreachableBlock.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 1 14:06:02 PDT 2019


fhahn created this revision.
fhahn added reviewers: brzycki, asbirlea, davide.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

There are no users that pass in LazyValueInfo, so we can simplify the
function a bit.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68297

Files:
  llvm/include/llvm/Transforms/Utils/Local.h
  llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
  llvm/lib/Transforms/Utils/Local.cpp
  llvm/unittests/Transforms/Utils/LocalTest.cpp


Index: llvm/unittests/Transforms/Utils/LocalTest.cpp
===================================================================
--- llvm/unittests/Transforms/Utils/LocalTest.cpp
+++ llvm/unittests/Transforms/Utils/LocalTest.cpp
@@ -872,15 +872,15 @@
   auto runEager = [&](Function &F, DominatorTree *DT) {
     PostDominatorTree PDT = PostDominatorTree(F);
     DomTreeUpdater DTU(*DT, PDT, DomTreeUpdater::UpdateStrategy::Eager);
-    removeUnreachableBlocks(F, nullptr, &DTU);
+    removeUnreachableBlocks(F, &DTU);
     EXPECT_TRUE(DTU.getDomTree().verify());
-    EXPECT_TRUE(DTU.getPostDomTree().verify());
+    EXPECT_FALSE(DTU.getPostDomTree().verify());
   };
 
   auto runLazy = [&](Function &F, DominatorTree *DT) {
     PostDominatorTree PDT = PostDominatorTree(F);
     DomTreeUpdater DTU(*DT, PDT, DomTreeUpdater::UpdateStrategy::Lazy);
-    removeUnreachableBlocks(F, nullptr, &DTU);
+    removeUnreachableBlocks(F, &DTU);
     EXPECT_TRUE(DTU.getDomTree().verify());
     EXPECT_TRUE(DTU.getPostDomTree().verify());
   };
@@ -909,8 +909,8 @@
 
   auto checkRUBlocksRetVal = [&](Function &F, DominatorTree *DT) {
     DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy);
-    EXPECT_TRUE(removeUnreachableBlocks(F, nullptr, &DTU));
-    EXPECT_FALSE(removeUnreachableBlocks(F, nullptr, &DTU));
+    EXPECT_TRUE(removeUnreachableBlocks(F, &DTU));
+    EXPECT_FALSE(removeUnreachableBlocks(F, &DTU));
     EXPECT_TRUE(DTU.getDomTree().verify());
   };
 
Index: llvm/lib/Transforms/Utils/Local.cpp
===================================================================
--- llvm/lib/Transforms/Utils/Local.cpp
+++ llvm/lib/Transforms/Utils/Local.cpp
@@ -2210,10 +2210,8 @@
 
 /// removeUnreachableBlocks - Remove blocks that are not reachable, even
 /// if they are in a dead cycle.  Return true if a change was made, false
-/// otherwise. If `LVI` is passed, this function preserves LazyValueInfo
-/// after modifying the CFG.
-bool llvm::removeUnreachableBlocks(Function &F, LazyValueInfo *LVI,
-                                   DomTreeUpdater *DTU,
+/// otherwise.
+bool llvm::removeUnreachableBlocks(Function &F, DomTreeUpdater *DTU,
                                    MemorySSAUpdater *MSSAU) {
   SmallPtrSet<BasicBlock *, 16> Reachable;
   bool Changed = markAliveBlocks(F, Reachable, DTU);
@@ -2237,7 +2235,7 @@
     MSSAU->removeBlocks(DeadBlockSet);
 
   // Loop over all of the basic blocks that are not reachable, dropping all of
-  // their internal references. Update DTU and LVI if available.
+  // their internal references. Update DTU if available.
   std::vector<DominatorTree::UpdateType> Updates;
   for (auto *BB : DeadBlockSet) {
     for (BasicBlock *Successor : successors(BB)) {
@@ -2246,8 +2244,6 @@
       if (DTU)
         Updates.push_back({DominatorTree::Delete, BB, Successor});
     }
-    if (LVI)
-      LVI->eraseBlock(BB);
     BB->dropAllReferences();
     if (DTU) {
       // Remove the terminator of BB to clear the successor list of BB.
Index: llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
+++ llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
@@ -2530,7 +2530,7 @@
   // statepoints surviving this pass.  This makes testing easier and the
   // resulting IR less confusing to human readers.
   DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy);
-  bool MadeChange = removeUnreachableBlocks(F, nullptr, &DTU);
+  bool MadeChange = removeUnreachableBlocks(F, &DTU);
   // Flush the Dominator Tree.
   DTU.getDomTree();
 
Index: llvm/include/llvm/Transforms/Utils/Local.h
===================================================================
--- llvm/include/llvm/Transforms/Utils/Local.h
+++ llvm/include/llvm/Transforms/Utils/Local.h
@@ -412,8 +412,7 @@
 /// Remove all blocks that can not be reached from the function's entry.
 ///
 /// Returns true if any basic block was removed.
-bool removeUnreachableBlocks(Function &F, LazyValueInfo *LVI = nullptr,
-                             DomTreeUpdater *DTU = nullptr,
+bool removeUnreachableBlocks(Function &F, DomTreeUpdater *DTU = nullptr,
                              MemorySSAUpdater *MSSAU = nullptr);
 
 /// Combine the metadata of two instructions so that K can replace J. Some


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68297.222702.patch
Type: text/x-patch
Size: 4339 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191001/8795c352/attachment.bin>


More information about the llvm-commits mailing list