[PATCH] D112482: [DomTree][NFC] Clean up nits in DomTree code

Jakub Kuderski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 25 13:06:05 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG763ae1d2c6a4: [DomTree][NFC] Clean up nits in DomTree code (authored by kuhar).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112482

Files:
  llvm/include/llvm/Support/GenericDomTreeConstruction.h
  llvm/unittests/IR/DominatorTreeBatchUpdatesTest.cpp


Index: llvm/unittests/IR/DominatorTreeBatchUpdatesTest.cpp
===================================================================
--- llvm/unittests/IR/DominatorTreeBatchUpdatesTest.cpp
+++ llvm/unittests/IR/DominatorTreeBatchUpdatesTest.cpp
@@ -6,12 +6,12 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include <random>
 #include "CFGBuilder.h"
-#include "gtest/gtest.h"
 #include "llvm/Analysis/PostDominators.h"
 #include "llvm/IR/Dominators.h"
 #include "llvm/Support/GenericDomTreeConstruction.h"
+#include "gtest/gtest.h"
+#include <random>
 
 #define DEBUG_TYPE "batch-update-tests"
 
@@ -21,7 +21,6 @@
 const auto CFGInsert = CFGBuilder::ActionKind::Insert;
 const auto CFGDelete = CFGBuilder::ActionKind::Delete;
 
-
 using DomUpdate = DominatorTree::UpdateType;
 static_assert(
     std::is_same<DomUpdate, PostDominatorTree::UpdateType>::value,
@@ -62,9 +61,9 @@
   LLVM_DEBUG(for (auto &U : Legalized) { U.dump(); dbgs() << ", "; });
   LLVM_DEBUG(dbgs() << "\n");
   EXPECT_EQ(Legalized.size(), 3UL);
-  EXPECT_NE(llvm::find(Legalized, DomUpdate{Insert, B, C}), Legalized.end());
-  EXPECT_NE(llvm::find(Legalized, DomUpdate{Insert, B, D}), Legalized.end());
-  EXPECT_NE(llvm::find(Legalized, DomUpdate{Delete, A, B}), Legalized.end());
+  EXPECT_TRUE(llvm::is_contained(Legalized, DomUpdate{Insert, B, C}));
+  EXPECT_TRUE(llvm::is_contained(Legalized, DomUpdate{Insert, B, D}));
+  EXPECT_TRUE(llvm::is_contained(Legalized, DomUpdate{Delete, A, B}));
 }
 
 TEST(DominatorTreeBatchUpdates, LegalizePostDomUpdates) {
@@ -85,9 +84,9 @@
   LLVM_DEBUG(for (auto &U : Legalized) { U.dump(); dbgs() << ", "; });
   LLVM_DEBUG(dbgs() << "\n");
   EXPECT_EQ(Legalized.size(), 3UL);
-  EXPECT_NE(llvm::find(Legalized, DomUpdate{Insert, C, B}), Legalized.end());
-  EXPECT_NE(llvm::find(Legalized, DomUpdate{Insert, D, B}), Legalized.end());
-  EXPECT_NE(llvm::find(Legalized, DomUpdate{Delete, B, A}), Legalized.end());
+  EXPECT_TRUE(llvm::is_contained(Legalized, DomUpdate{Insert, C, B}));
+  EXPECT_TRUE(llvm::is_contained(Legalized, DomUpdate{Insert, D, B}));
+  EXPECT_TRUE(llvm::is_contained(Legalized, DomUpdate{Delete, B, A}));
 }
 
 TEST(DominatorTreeBatchUpdates, SingleInsertion) {
Index: llvm/include/llvm/Support/GenericDomTreeConstruction.h
===================================================================
--- llvm/include/llvm/Support/GenericDomTreeConstruction.h
+++ llvm/include/llvm/Support/GenericDomTreeConstruction.h
@@ -78,7 +78,7 @@
   using UpdateT = typename DomTreeT::UpdateType;
   using UpdateKind = typename DomTreeT::UpdateKind;
   struct BatchUpdateInfo {
-    // Note: Updates inside PreViewCFG are aleady legalized.
+    // Note: Updates inside PreViewCFG are already legalized.
     BatchUpdateInfo(GraphDiffT &PreViewCFG, GraphDiffT *PostViewCFG = nullptr)
         : PreViewCFG(PreViewCFG), PostViewCFG(PostViewCFG),
           NumLegalized(PreViewCFG.getNumLegalizedUpdates()) {}
@@ -430,7 +430,6 @@
       // is unreachable. This is because we are still going to only visit each
       // unreachable node once, we may just visit it in two directions,
       // depending on how lucky we get.
-      SmallPtrSet<NodePtr, 4> ConnectToExitBlock;
       for (const NodePtr I : nodes(DT.Parent)) {
         if (SNCA.NodeToInfo.count(I) == 0) {
           LLVM_DEBUG(dbgs()
@@ -457,7 +456,6 @@
           LLVM_DEBUG(dbgs() << "\t\t\tFound a new furthest away node "
                             << "(non-trivial root): "
                             << BlockNamePrinter(FurthestAway) << "\n");
-          ConnectToExitBlock.insert(FurthestAway);
           Roots.push_back(FurthestAway);
           LLVM_DEBUG(dbgs() << "\t\t\tPrev DFSNum: " << Num << ", new DFSNum: "
                             << NewNum << "\n\t\t\tRemoving DFS info\n");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112482.382097.patch
Type: text/x-patch
Size: 3828 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211025/9deb7b76/attachment.bin>


More information about the llvm-commits mailing list