[PATCH] D43216: [Dominators] Ensure that every PostDomTree root is connected to the virtual node

Jakub Kuderski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 12 16:39:26 PST 2018


kuhar created this revision.
kuhar added reviewers: dmgreen, davide, brzycki, grosser, dberlin.

This patch teaches .verifyRoots to check if all roots are connected to the virtual root.


Repository:
  rL LLVM

https://reviews.llvm.org/D43216

Files:
  include/llvm/Support/GenericDomTreeConstruction.h


Index: include/llvm/Support/GenericDomTreeConstruction.h
===================================================================
--- include/llvm/Support/GenericDomTreeConstruction.h
+++ include/llvm/Support/GenericDomTreeConstruction.h
@@ -1297,9 +1297,12 @@
         errs().flush();
         return false;
       }
+
+      return true;
     }
 
-    RootsT ComputedRoots = FindRoots(DT, nullptr);
+    // Check PostDomTree roots.
+    const RootsT ComputedRoots = FindRoots(DT, nullptr);
     if (DT.Roots.size() != ComputedRoots.size() ||
         !std::is_permutation(DT.Roots.begin(), DT.Roots.end(),
                              ComputedRoots.begin())) {
@@ -1314,6 +1317,21 @@
       return false;
     }
 
+    for (const NodePtr Root : ComputedRoots) {
+      const TreeNodePtr TN = DT.getNode(Root);
+      if (!TN) {
+        errs() << "Computed root: " << BlockNamePrinter(Root)
+               << " not found in the PostDomTree!\n";
+        return false;
+      }
+
+      if (!DT.isVirtualRoot(TN->getIDom())) {
+        errs() << "Computed root: " << BlockNamePrinter(TN)
+               << " is not connected to the virtual root!\n";
+        return false;
+      }
+    }
+
     return true;
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43216.133959.patch
Type: text/x-patch
Size: 1215 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180213/1bfe361b/attachment.bin>


More information about the llvm-commits mailing list