1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 19:42:54 +02:00

[GVNHoist] computeInsertionPoints() miscalculates IDF

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.

Differential Revision: https://reviews.llvm.org/D51980

llvm-svn: 342055
This commit is contained in:
Alexandros Lamprineas 2018-09-12 14:28:23 +00:00
parent 0cada6afe9
commit 67a00b872a

View File

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