[PATCH] D51980: [GVNHoist] computeInsertionPoints() miscalculates the Iterated Dominance Frontiers

Alexandros Lamprineas via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 12 05:52:18 PDT 2018


labrinea created this revision.
labrinea added reviewers: llvm-commits, sebpop.

Fix for https://bugs.llvm.org/show_bug.cgi?id=38912. In GVNHoist::computeInsertionPoints() we iterate over the Value Numbers and calculate the Iterated Dominance Frontiers without clearing the IDFBlocks vector first. IDFBlocks ends up accumulating an insane number of basic blocks, which bloats the compilation time of SemaChecking.cpp with ubsan enabled.


https://reviews.llvm.org/D51980

Files:
  lib/Transforms/Scalar/GVNHoist.cpp


Index: lib/Transforms/Scalar/GVNHoist.cpp
===================================================================
--- lib/Transforms/Scalar/GVNHoist.cpp
+++ lib/Transforms/Scalar/GVNHoist.cpp
@@ -155,7 +155,6 @@
 
 using CHIIt = SmallVectorImpl<CHIArg>::iterator;
 using CHIArgs = iterator_range<CHIIt>;
-using CHICache = DenseMap<BasicBlock *, SmallPtrSet<Instruction *, 4>>;
 using OutValuesType = DenseMap<BasicBlock *, SmallVector<CHIArg, 2>>;
 using InValuesType =
     DenseMap<BasicBlock *, SmallVector<std::pair<VNType, Instruction *>, 2>>;
@@ -767,7 +766,6 @@
     ReverseIDFCalculator IDFs(*PDT);
     OutValuesType OutValue;
     InValuesType InValue;
-    CHICache CachedCHIs;
     for (const auto &R : Ranks) {
       const SmallVecInsn &V = Map.lookup(R);
       if (V.size() < 2)
@@ -786,6 +784,7 @@
       // which currently have dead terminators that are control
       // dependence sources of a block which is in NewLiveBlocks.
       IDFs.setDefiningBlocks(VNBlocks);
+      IDFBlocks.clear();
       IDFs.calculate(IDFBlocks);
 
       // Make a map of BB vs instructions to be hoisted.
@@ -798,8 +797,7 @@
         for (unsigned i = 0; i < V.size(); ++i) {
           CHIArg C = {VN, nullptr, nullptr};
            // Ignore spurious PDFs.
-          if (DT->properlyDominates(IDFB, V[i]->getParent()) &&
-              CachedCHIs[IDFB].insert(V[i]).second) {
+          if (DT->properlyDominates(IDFB, V[i]->getParent())) {
             OutValue[IDFB].push_back(C);
             LLVM_DEBUG(dbgs() << "\nInsertion a CHI for BB: " << IDFB->getName()
                               << ", for Insn: " << *V[i]);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51980.165071.patch
Type: text/x-patch
Size: 1627 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180912/fec8f93b/attachment.bin>


More information about the llvm-commits mailing list