|
LLVM 24.0.0git
|
A cache of @llvm.assume calls within a function. More...
#include "llvm/Analysis/AssumptionCache.h"
Classes | |
| struct | ResultElem |
Public Types | |
| enum | : unsigned { ExprResultIdx = std::numeric_limits<unsigned>::max() } |
| Value of ResultElem::Index indicating that the argument to the call of the llvm.assume. More... | |
Public Member Functions | |
| AssumptionCache (Function &F, TargetTransformInfo *TTI=nullptr) | |
| Construct an AssumptionCache from a function by scanning all of its instructions. | |
| bool | invalidate (Function &, const PreservedAnalyses &, FunctionAnalysisManager::Invalidator &) |
| This cache is designed to be self-updating and so it should never be invalidated. | |
| LLVM_ABI void | registerAssumption (AssumeInst *CI) |
| Add an @llvm.assume intrinsic to this function's cache. | |
| LLVM_ABI void | unregisterAssumption (AssumeInst *CI) |
| Remove an @llvm.assume intrinsic from this function's cache if it has been added to the cache earlier. | |
| LLVM_ABI void | replaceAssumption (WeakVH &Handle, AssumeInst *New) |
Replace the assumption referenced by Handle (must be a valid handle for a registered assumption) with New. | |
| LLVM_ABI void | updateAffectedValues (AssumeInst *CI) |
| Update the cache of values being affected by this assumption (i.e. | |
| void | clear () |
| Clear the cache of @llvm.assume intrinsics for a function. | |
| MutableArrayRef< WeakVH > | assumptions () |
| Access the list of assumption handles currently tracked for this function. | |
| MutableArrayRef< ResultElem > | assumptionsFor (const Value *V) |
| Access the list of assumptions which affect this value. | |
| MutableArrayRef< ResultElem > | allAssumptionsFor (const Value *V) |
| Access the list of assumptions which affect this value, ignoring the -max-assumes-per-value limit. | |
Static Public Member Functions | |
| static LLVM_ABI void | findValuesAffectedByOperandBundle (OperandBundleUse Bundle, function_ref< void(Value *)> InsertAffected) |
| Determine which values are affected by this assume operand bundle. | |
A cache of @llvm.assume calls within a function.
This cache provides fast lookup of assumptions within a function by caching them and amortizing the cost of scanning for them across all queries. Passes that create new assumptions are required to call registerAssumption() to register any new @llvm.assume calls that they create. Deletions of @llvm.assume calls do not require special handling.
Definition at line 47 of file AssumptionCache.h.
| anonymous enum : unsigned |
Value of ResultElem::Index indicating that the argument to the call of the llvm.assume.
| Enumerator | |
|---|---|
| ExprResultIdx | |
Definition at line 51 of file AssumptionCache.h.
|
inline |
Construct an AssumptionCache from a function by scanning all of its instructions.
Definition at line 117 of file AssumptionCache.h.
Referenced by llvm::AssumptionAnalysis::run().
|
inline |
Access the list of assumptions which affect this value, ignoring the -max-assumes-per-value limit.
Only for callers which must observe every assumption, such as cache verification. Analyses should use assumptionsFor().
Definition at line 181 of file AssumptionCache.h.
References llvm::MutableArrayRef().
Referenced by assumptionsFor().
|
inline |
Access the list of assumption handles currently tracked for this function.
Note that these produce weak handles that may be null. The caller must handle that case. FIXME: We should replace this with pointee_iterator<filter_iterator<...>> when we can write that to filter out the null values. Then caller code will become simpler.
Definition at line 162 of file AssumptionCache.h.
Referenced by llvm::CodeMetrics::collectEphemeralValues(), llvm::CodeMetrics::collectEphemeralValues(), llvm::AssumptionPrinterPass::run(), llvm::DropUnnecessaryAssumesPass::run(), and llvm::AlignmentFromAssumptionsPass::runImpl().
|
inline |
Access the list of assumptions which affect this value.
Callers inspect every assumption returned, so this returns only the first -max-assumes-per-value of them.
Definition at line 172 of file AssumptionCache.h.
References allAssumptionsFor(), and llvm::MaxAssumesPerValue.
Referenced by llvm::computeConstantRange(), llvm::computeKnownBitsFromContext(), computeKnownFPClassFromContext(), llvm::getKnowledgeForValue(), isKnownNonEqualFromContext(), isKnownNonZeroFromAssume(), llvm::isKnownToBeAPowerOfTwo(), and simplifyICmpWithDominatingAssume().
|
inline |
Clear the cache of @llvm.assume intrinsics for a function.
It will be re-scanned the next time it is requested.
Definition at line 148 of file AssumptionCache.h.
|
static |
Determine which values are affected by this assume operand bundle.
Definition at line 66 of file AssumptionCache.cpp.
References llvm::ABA_WasOn, assert(), llvm::OperandBundleUse::getTagName(), llvm::getUnderlyingObject(), llvm::IgnoreBundleTag, llvm::OperandBundleUse::Inputs, and llvm::isa().
Referenced by findAffectedValues(), and llvm::DropUnnecessaryAssumesPass::run().
|
inline |
This cache is designed to be self-updating and so it should never be invalidated.
Definition at line 122 of file AssumptionCache.h.
| void AssumptionCache::registerAssumption | ( | AssumeInst * | CI | ) |
Add an @llvm.assume intrinsic to this function's cache.
The call passed in must be an instruction within this function and must not already be in the cache.
Definition at line 242 of file AssumptionCache.cpp.
References assert(), findCacheViolation(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm_unreachable, and updateAffectedValues().
Referenced by AddAlignmentAssumptions(), addAssumeNonNull(), buildClonedLoopBlocks(), ConnectEpilog(), foldCondBranchOnValueKnownInPredecessorImpl(), removeUndefIntroducingPredecessor(), llvm::salvageKnowledge(), llvm::UnrollAndJamLoop(), and llvm::UnrollLoop().
| void AssumptionCache::replaceAssumption | ( | WeakVH & | Handle, |
| AssumeInst * | New ) |
Replace the assumption referenced by Handle (must be a valid handle for a registered assumption) with New.
Definition at line 167 of file AssumptionCache.cpp.
References llvm::cast(), and updateAffectedValues().
Referenced by llvm::DropUnnecessaryAssumesPass::run().
| void AssumptionCache::unregisterAssumption | ( | AssumeInst * | CI | ) |
Remove an @llvm.assume intrinsic from this function's cache if it has been added to the cache earlier.
Definition at line 162 of file AssumptionCache.cpp.
References llvm::erase().
| void AssumptionCache::updateAffectedValues | ( | AssumeInst * | CI | ) |
Update the cache of values being affected by this assumption (i.e.
the values about which this assumption provides information).
Definition at line 116 of file AssumptionCache.cpp.
References llvm::AssumptionCache::ResultElem::Assume, findAffectedValues(), llvm::AssumptionCache::ResultElem::Index, and llvm::none_of().
Referenced by registerAssumption(), and replaceAssumption().