diff options
author | Alexandros Lamprineas <alexandros.lamprineas@arm.com> | 2018-08-28 11:07:54 +0000 |
---|---|---|
committer | Alexandros Lamprineas <alexandros.lamprineas@arm.com> | 2018-08-28 11:07:54 +0000 |
commit | 484bd13e2d40c780ddba2362ca5b43f65de7fa3f (patch) | |
tree | bf2194169fa4a49d8415eaabbd00b4524d14a0af /llvm/lib/Transforms | |
parent | 99fc18c387a9c4bc0abd1567c31e08278c7b8613 (diff) | |
download | bcm5719-llvm-484bd13e2d40c780ddba2362ca5b43f65de7fa3f.tar.gz bcm5719-llvm-484bd13e2d40c780ddba2362ca5b43f65de7fa3f.zip |
[GVNHoist] Prune out useless CHI insertions
Fix for the out-of-memory error when compiling SemaChecking.cpp
with GVNHoist and ubsan enabled. I've used a cache for inserted
CHIs to avoid excessive memory usage.
Differential Revision: https://reviews.llvm.org/D50323
llvm-svn: 340818
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/GVNHoist.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/GVNHoist.cpp b/llvm/lib/Transforms/Scalar/GVNHoist.cpp index ca19576e8b1..10cdcd59e42 100644 --- a/llvm/lib/Transforms/Scalar/GVNHoist.cpp +++ b/llvm/lib/Transforms/Scalar/GVNHoist.cpp @@ -155,6 +155,7 @@ struct CHIArg { 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>>; @@ -766,6 +767,7 @@ private: ReverseIDFCalculator IDFs(*PDT); OutValuesType OutValue; InValuesType InValue; + CHICache CachedCHIs; for (const auto &R : Ranks) { const SmallVecInsn &V = Map.lookup(R); if (V.size() < 2) @@ -792,11 +794,12 @@ private: } // Insert empty CHI node for this VN. This is used to factor out // basic blocks where the ANTIC can potentially change. - for (auto IDFB : IDFBlocks) { // TODO: Prune out useless CHI insertions. + for (auto IDFB : IDFBlocks) { for (unsigned i = 0; i < V.size(); ++i) { CHIArg C = {VN, nullptr, nullptr}; // Ignore spurious PDFs. - if (DT->properlyDominates(IDFB, V[i]->getParent())) { + if (DT->properlyDominates(IDFB, V[i]->getParent()) && + CachedCHIs[IDFB].insert(V[i]).second) { OutValue[IDFB].push_back(C); LLVM_DEBUG(dbgs() << "\nInsertion a CHI for BB: " << IDFB->getName() << ", for Insn: " << *V[i]); |