diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2017-02-15 21:10:09 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2017-02-15 21:10:09 +0000 |
commit | 9421c2dc54df150f1430a9b16ef1d24acbc3146d (patch) | |
tree | 1569cb82845a53db0ff9570ba3d108ec5c267de9 /llvm/lib | |
parent | 5b4c30fb32146b868dee3723bd878edba395358f (diff) | |
download | bcm5719-llvm-9421c2dc54df150f1430a9b16ef1d24acbc3146d.tar.gz bcm5719-llvm-9421c2dc54df150f1430a9b16ef1d24acbc3146d.zip |
AssumptionCache: Disable the verifier by default, move it behind a hidden cl::opt and verify from releaseMemory().
This is a short term solution to the problem that many passes currently fail
to update the assumption cache. In the long term the verifier should not
be controllable with a flag. We should either fix all passes to correctly
update the assumption cache and enable the verifier unconditionally or
somehow arrange for the assumption list to be updated automatically by passes.
Differential Revision: https://reviews.llvm.org/D30003
llvm-svn: 295236
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Analysis/AssumptionCache.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/llvm/lib/Analysis/AssumptionCache.cpp b/llvm/lib/Analysis/AssumptionCache.cpp index 4e287e5f6bc..1fae9472448 100644 --- a/llvm/lib/Analysis/AssumptionCache.cpp +++ b/llvm/lib/Analysis/AssumptionCache.cpp @@ -24,6 +24,11 @@ using namespace llvm; using namespace llvm::PatternMatch; +static cl::opt<bool> + VerifyAssumptionCache("verify-assumption-cache", cl::Hidden, + cl::desc("Enable verification of assumption cache"), + cl::init(false)); + SmallVector<WeakVH, 1> &AssumptionCache::getOrInsertAffectedValues(Value *V) { // Try using find_as first to avoid creating extra value handles just for the // purpose of doing the lookup. @@ -231,7 +236,13 @@ AssumptionCache &AssumptionCacheTracker::getAssumptionCache(Function &F) { } void AssumptionCacheTracker::verifyAnalysis() const { -#ifndef NDEBUG + // FIXME: In the long term the verifier should not be controllable with a + // flag. We should either fix all passes to correctly update the assumption + // cache and enable the verifier unconditionally or somehow arrange for the + // assumption list to be updated automatically by passes. + if (!VerifyAssumptionCache) + return; + SmallPtrSet<const CallInst *, 4> AssumptionSet; for (const auto &I : AssumptionCaches) { for (auto &VH : I.second->assumptions()) @@ -240,11 +251,10 @@ void AssumptionCacheTracker::verifyAnalysis() const { for (const BasicBlock &B : cast<Function>(*I.first)) for (const Instruction &II : B) - if (match(&II, m_Intrinsic<Intrinsic::assume>())) - assert(AssumptionSet.count(cast<CallInst>(&II)) && - "Assumption in scanned function not in cache"); + if (match(&II, m_Intrinsic<Intrinsic::assume>()) && + !AssumptionSet.count(cast<CallInst>(&II))) + report_fatal_error("Assumption in scanned function not in cache"); } -#endif } AssumptionCacheTracker::AssumptionCacheTracker() : ImmutablePass(ID) { |