LLVM  14.0.0git
Classes | Public Types | Public Member Functions | List of all members
llvm::AssumptionCache Class Reference

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)
 Construct an AssumptionCache from a function by scanning all of its instructions. More...
 
bool invalidate (Function &, const PreservedAnalyses &, FunctionAnalysisManager::Invalidator &)
 This cache is designed to be self-updating and so it should never be invalidated. More...
 
void registerAssumption (AssumeInst *CI)
 Add an @llvm.assume intrinsic to this function's cache. More...
 
void unregisterAssumption (AssumeInst *CI)
 Remove an @llvm.assume intrinsic from this function's cache if it has been added to the cache earlier. More...
 
void updateAffectedValues (AssumeInst *CI)
 Update the cache of values being affected by this assumption (i.e. More...
 
void clear ()
 Clear the cache of @llvm.assume intrinsics for a function. More...
 
MutableArrayRef< ResultElemassumptions ()
 Access the list of assumption handles currently tracked for this function. More...
 
MutableArrayRef< ResultElemassumptionsFor (const Value *V)
 Access the list of assumptions which affect this value. More...
 

Detailed Description

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 41 of file AssumptionCache.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum : unsigned

Value of ResultElem::Index indicating that the argument to the call of the llvm.assume.

Enumerator
ExprResultIdx 

Definition at line 45 of file AssumptionCache.h.

Constructor & Destructor Documentation

◆ AssumptionCache()

llvm::AssumptionCache::AssumptionCache ( Function F)
inline

Construct an AssumptionCache from a function by scanning all of its instructions.

Definition at line 106 of file AssumptionCache.h.

References F.

Member Function Documentation

◆ assumptions()

MutableArrayRef<ResultElem> llvm::AssumptionCache::assumptions ( )
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 146 of file AssumptionCache.h.

Referenced by llvm::ScalarEvolution::applyLoopGuards(), llvm::CodeMetrics::collectEphemeralValues(), llvm::ScalarEvolution::isBasicBlockEntryGuardedByCond(), llvm::ScalarEvolution::isLoopBackedgeGuardedByCond(), llvm::AssumptionPrinterPass::run(), llvm::AlignmentFromAssumptionsPass::runImpl(), and llvm::CodeExtractor::verifyAssumptionCache().

◆ assumptionsFor()

MutableArrayRef<ResultElem> llvm::AssumptionCache::assumptionsFor ( const Value V)
inline

Access the list of assumptions which affect this value.

Definition at line 153 of file AssumptionCache.h.

Referenced by llvm::computeConstantRange(), llvm::getKnowledgeForValue(), simplifyICmpWithDominatingAssume(), and llvm::CodeExtractor::verifyAssumptionCache().

◆ clear()

void llvm::AssumptionCache::clear ( )
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 132 of file AssumptionCache.h.

References llvm::SmallVectorImpl< T >::clear().

◆ invalidate()

bool llvm::AssumptionCache::invalidate ( Function ,
const PreservedAnalyses ,
FunctionAnalysisManager::Invalidator  
)
inline

This cache is designed to be self-updating and so it should never be invalidated.

Definition at line 110 of file AssumptionCache.h.

◆ registerAssumption()

void AssumptionCache::registerAssumption ( AssumeInst CI)

◆ unregisterAssumption()

void AssumptionCache::unregisterAssumption ( AssumeInst CI)

◆ updateAffectedValues()

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 129 of file AssumptionCache.cpp.

References llvm::find_if(), and findAffectedValues().

Referenced by registerAssumption().


The documentation for this class was generated from the following files: