diff options
Diffstat (limited to 'llvm/lib/Transforms/Scalar/NewGVN.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/NewGVN.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp b/llvm/lib/Transforms/Scalar/NewGVN.cpp index b7914ba54bd..6c4ee6eafb8 100644 --- a/llvm/lib/Transforms/Scalar/NewGVN.cpp +++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp @@ -76,6 +76,7 @@ #include "llvm/Support/Allocator.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/DebugCounter.h" #include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Scalar/GVNExpression.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" @@ -103,7 +104,8 @@ STATISTIC(NumGVNAvoidedSortedLeaderChanges, STATISTIC(NumGVNNotMostDominatingLeader, "Number of times a member dominated it's new classes' leader"); STATISTIC(NumGVNDeadStores, "Number of redundant/dead stores eliminated"); - +DEBUG_COUNTER(VNCounter, "newgvn-vn", + "Controls which instructions are value numbered") //===----------------------------------------------------------------------===// // GVN Pass //===----------------------------------------------------------------------===// @@ -287,6 +289,8 @@ class NewGVN : public FunctionPass { // Deletion info. SmallPtrSet<Instruction *, 8> InstructionsToErase; + // The set of things we gave unknown expressions to due to debug counting. + SmallPtrSet<Instruction *, 8> DebugUnknownExprs; public: static char ID; // Pass identification, replacement for typeid. NewGVN() : FunctionPass(ID) { @@ -1708,13 +1712,13 @@ void NewGVN::cleanupTables() { #endif InstrDFS.clear(); InstructionsToErase.clear(); - DFSToInstr.clear(); BlockInstRange.clear(); TouchedInstructions.clear(); DominatedInstRange.clear(); MemoryAccessToClass.clear(); PredicateToUsers.clear(); + DebugUnknownExprs.clear(); } std::pair<unsigned, unsigned> NewGVN::assignDFSNumbers(BasicBlock *B, @@ -1796,7 +1800,6 @@ void NewGVN::valueNumberMemoryPhi(MemoryPhi *MP) { // congruence finding, and updating mappings. void NewGVN::valueNumberInstruction(Instruction *I) { DEBUG(dbgs() << "Processing instruction " << *I << "\n"); - // There's no need to call isInstructionTriviallyDead more than once on // an instruction. Therefore, once we know that an instruction is dead // we change its DFS number so that it doesn't get numbered again. @@ -1807,7 +1810,14 @@ void NewGVN::valueNumberInstruction(Instruction *I) { return; } if (!I->isTerminator()) { - const auto *Symbolized = performSymbolicEvaluation(I); + const Expression *Symbolized = nullptr; + if (DebugCounter::shouldExecute(VNCounter)) { + Symbolized = performSymbolicEvaluation(I); + } else { + // Used to track which we marked unknown so we can skip verification of + // comparisons. + DebugUnknownExprs.insert(I); + } // If we couldn't come up with a symbolic expression, use the unknown // expression if (Symbolized == nullptr) @@ -1923,7 +1933,7 @@ void NewGVN::verifyComparisons(Function &F) { if (!ReachableBlocks.count(&BB)) continue; for (auto &I : BB) { - if (InstructionsToErase.count(&I)) + if (InstructionsToErase.count(&I) || DebugUnknownExprs.count(&I)) continue; if (isa<CmpInst>(&I)) { auto *CurrentVal = ValueToClass.lookup(&I); |