diff options
Diffstat (limited to 'lib/Analysis/AssumptionCache.cpp')
-rw-r--r-- | lib/Analysis/AssumptionCache.cpp | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/lib/Analysis/AssumptionCache.cpp b/lib/Analysis/AssumptionCache.cpp index 8bfd24ccf77b..cf2f845dee0a 100644 --- a/lib/Analysis/AssumptionCache.cpp +++ b/lib/Analysis/AssumptionCache.cpp @@ -1,9 +1,8 @@ //===- AssumptionCache.cpp - Cache finding @llvm.assume calls -------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -54,11 +53,11 @@ AssumptionCache::getOrInsertAffectedValues(Value *V) { return AVIP.first->second; } -void AssumptionCache::updateAffectedValues(CallInst *CI) { +static void findAffectedValues(CallInst *CI, + SmallVectorImpl<Value *> &Affected) { // Note: This code must be kept in-sync with the code in // computeKnownBitsFromAssume in ValueTracking. - SmallVector<Value *, 16> Affected; auto AddAffected = [&Affected](Value *V) { if (isa<Argument>(V)) { Affected.push_back(V); @@ -109,6 +108,11 @@ void AssumptionCache::updateAffectedValues(CallInst *CI) { AddAffectedFromEq(B); } } +} + +void AssumptionCache::updateAffectedValues(CallInst *CI) { + SmallVector<Value *, 16> Affected; + findAffectedValues(CI, Affected); for (auto &AV : Affected) { auto &AVV = getOrInsertAffectedValues(AV); @@ -117,6 +121,18 @@ void AssumptionCache::updateAffectedValues(CallInst *CI) { } } +void AssumptionCache::unregisterAssumption(CallInst *CI) { + SmallVector<Value *, 16> Affected; + findAffectedValues(CI, Affected); + + for (auto &AV : Affected) { + auto AVI = AffectedValues.find_as(AV); + if (AVI != AffectedValues.end()) + AffectedValues.erase(AVI); + } + remove_if(AssumeHandles, [CI](WeakTrackingVH &VH) { return CI == VH; }); +} + void AssumptionCache::AffectedValueCallbackVH::deleted() { auto AVI = AC->AffectedValues.find(getValPtr()); if (AVI != AC->AffectedValues.end()) @@ -241,6 +257,13 @@ AssumptionCache &AssumptionCacheTracker::getAssumptionCache(Function &F) { return *IP.first->second; } +AssumptionCache *AssumptionCacheTracker::lookupAssumptionCache(Function &F) { + auto I = AssumptionCaches.find_as(&F); + if (I != AssumptionCaches.end()) + return I->second.get(); + return nullptr; +} + void AssumptionCacheTracker::verifyAnalysis() const { // 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 |