LLVM 23.0.0git
llvm::InformationCache Struct Reference

Data structure to hold cached (LLVM-IR) information. More...

#include "llvm/Transforms/IPO/Attributor.h"

Public Types

using InstructionVectorTy = SmallVector<Instruction *, 8>
 A vector type to hold instructions.
using OpcodeInstMapTy = DenseMap<unsigned, InstructionVectorTy *>
 A map type from opcodes to instructions with this opcode.

Public Member Functions

 InformationCache (const Module &M, AnalysisGetter &AG, BumpPtrAllocator &Allocator, SetVector< Function * > *CGSCC, bool UseExplorer=true)
virtual ~InformationCache ()
OpcodeInstMapTygetOpcodeInstMapForFunction (const Function &F)
 Return the map that relates "interesting" opcodes with all instructions with that opcode in F.
InstructionVectorTygetReadOrWriteInstsForFunction (const Function &F)
 Return the instructions in F that may read or write memory.
MustBeExecutedContextExplorergetMustBeExecutedContextExplorer ()
 Return MustBeExecutedContextExplorer.
TargetLibraryInfogetTargetLibraryInfoForFunction (const Function &F)
 Return TargetLibraryInfo for function F.
bool isKernel (const Function &F)
 Return true if F has the "kernel" function attribute.
bool isInvolvedInMustTailCall (const Argument &Arg)
 Return true if Arg is involved in a must-tail call, thus the argument of the caller or callee.
bool isOnlyUsedByAssume (const Instruction &I) const
void invalidateAnalyses ()
 Invalidates the cached analyses.
template<typename AP>
AP::Result * getAnalysisResultForFunction (const Function &F, bool CachedOnly=false)
 Return the analysis result from a pass AP for function F.
const ModulegetModule () const
const DataLayoutgetDL () const
 Return datalayout used in the module.
const RetainedKnowledgeMapgetKnowledgeMap () const
 Return the map conaining all the knowledge we have from llvm.assumes.
const AA::InstExclusionSetTygetOrCreateUniqueBlockExecutionSet (const AA::InstExclusionSetTy *BES)
 Given BES, return a uniqued version.
bool stackIsAccessibleByOtherThreads ()
 Return true if the stack (llvm::Alloca) can be accessed by other threads.
bool IsTargetGPU () const
 Return true if the target is a GPU.
LLVM_ABI ArrayRef< Function * > getIndirectlyCallableFunctions (Attributor &A) const
 Return all functions that might be called indirectly, only valid for closed world modules (see isClosedWorldModule).
LLVM_ABI std::optional< unsignedgetFlatAddressSpace () const
 Return the flat address space if the associated target has.
virtual unsigned getMaxAddrSpace () const

Static Public Member Functions

template<typename CBTy>
static void foreachUse (Function &F, CBTy CB, bool LookThroughConstantExprUses=true)
 Apply CB to all uses of F.

Public Attributes

const SetVector< Function * > *const CGSCC = nullptr
 The CG-SCC the pass is run on, or nullptr if it is a module pass.

Friends

struct Attributor
 Give the Attributor access to the members so Attributor::identifyDefaultAbstractAttributes(...) can initialize them.

Detailed Description

Data structure to hold cached (LLVM-IR) information.

All attributes are given an InformationCache object at creation time to avoid inspection of the IR by all of them individually. This default InformationCache will hold information required by 'default' attributes, thus the ones deduced when Attributor::identifyDefaultAbstractAttributes(..) is called.

If custom abstract attributes, registered manually through Attributor::registerAA(...), need more information, especially if it is not reusable, it is advised to inherit from the InformationCache and cast the instance down in the abstract attributes.

Definition at line 1207 of file Attributor.h.

Member Typedef Documentation

◆ InstructionVectorTy

A vector type to hold instructions.

Definition at line 1268 of file Attributor.h.

◆ OpcodeInstMapTy

A map type from opcodes to instructions with this opcode.

Definition at line 1271 of file Attributor.h.

Constructor & Destructor Documentation

◆ InformationCache()

llvm::InformationCache::InformationCache ( const Module & M,
AnalysisGetter & AG,
BumpPtrAllocator & Allocator,
SetVector< Function * > * CGSCC,
bool UseExplorer = true )
inline

Definition at line 1208 of file Attributor.h.

References CGSCC, and F.

◆ ~InformationCache()

virtual llvm::InformationCache::~InformationCache ( )
inlinevirtual

Definition at line 1229 of file Attributor.h.

Member Function Documentation

◆ foreachUse()

template<typename CBTy>
void llvm::InformationCache::foreachUse ( Function & F,
CBTy CB,
bool LookThroughConstantExprUses = true )
inlinestatic

Apply CB to all uses of F.

If LookThroughConstantExprUses is true, constant expression users are not given to CB but their uses are traversed transitively.

Definition at line 1246 of file Attributor.h.

References llvm::cast(), F, llvm::isa(), llvm::make_pointer_range(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::SmallVectorTemplateCommon< T, typename >::size().

◆ getAnalysisResultForFunction()

template<typename AP>
AP::Result * llvm::InformationCache::getAnalysisResultForFunction ( const Function & F,
bool CachedOnly = false )
inline

Return the analysis result from a pass AP for function F.

Definition at line 1317 of file Attributor.h.

References F.

Referenced by llvm::AANonNull::isImpliedByIR(), and llvm::AA::isValidAtPosition().

◆ getDL()

const DataLayout & llvm::InformationCache::getDL ( ) const
inline

Return datalayout used in the module.

Definition at line 1325 of file Attributor.h.

◆ getFlatAddressSpace()

std::optional< unsigned > InformationCache::getFlatAddressSpace ( ) const

Return the flat address space if the associated target has.

Definition at line 3363 of file Attributor.cpp.

References IsTargetGPU().

◆ getIndirectlyCallableFunctions()

ArrayRef< Function * > InformationCache::getIndirectlyCallableFunctions ( Attributor & A) const

Return all functions that might be called indirectly, only valid for closed world modules (see isClosedWorldModule).

Definition at line 3358 of file Attributor.cpp.

References A(), assert(), and Attributor.

◆ getKnowledgeMap()

const RetainedKnowledgeMap & llvm::InformationCache::getKnowledgeMap ( ) const
inline

Return the map conaining all the knowledge we have from llvm.assumes.

Definition at line 1328 of file Attributor.h.

Referenced by llvm::Attributor::getAttrsFromAssumes().

◆ getMaxAddrSpace()

virtual unsigned llvm::InformationCache::getMaxAddrSpace ( ) const
inlinevirtual

Definition at line 1357 of file Attributor.h.

◆ getModule()

const Module & llvm::InformationCache::getModule ( ) const
inline

Definition at line 1322 of file Attributor.h.

◆ getMustBeExecutedContextExplorer()

MustBeExecutedContextExplorer * llvm::InformationCache::getMustBeExecutedContextExplorer ( )
inline

Return MustBeExecutedContextExplorer.

Definition at line 1285 of file Attributor.h.

Referenced by llvm::Attributor::getAttrsFromAssumes().

◆ getOpcodeInstMapForFunction()

OpcodeInstMapTy & llvm::InformationCache::getOpcodeInstMapForFunction ( const Function & F)
inline

Return the map that relates "interesting" opcodes with all instructions with that opcode in F.

Definition at line 1275 of file Attributor.h.

References F.

◆ getOrCreateUniqueBlockExecutionSet()

const AA::InstExclusionSetTy * llvm::InformationCache::getOrCreateUniqueBlockExecutionSet ( const AA::InstExclusionSetTy * BES)
inline

Given BES, return a uniqued version.

Definition at line 1332 of file Attributor.h.

References assert(), llvm::SmallPtrSetImpl< PtrType >::find(), and llvm::Success.

◆ getReadOrWriteInstsForFunction()

InstructionVectorTy & llvm::InformationCache::getReadOrWriteInstsForFunction ( const Function & F)
inline

Return the instructions in F that may read or write memory.

Definition at line 1280 of file Attributor.h.

References F.

◆ getTargetLibraryInfoForFunction()

TargetLibraryInfo * llvm::InformationCache::getTargetLibraryInfoForFunction ( const Function & F)
inline

Return TargetLibraryInfo for function F.

Definition at line 1290 of file Attributor.h.

References F.

◆ invalidateAnalyses()

void llvm::InformationCache::invalidateAnalyses ( )
inline

Invalidates the cached analyses.

Valid only when using the new pass manager.

Definition at line 1313 of file Attributor.h.

◆ isInvolvedInMustTailCall()

bool llvm::InformationCache::isInvolvedInMustTailCall ( const Argument & Arg)
inline

Return true if Arg is involved in a must-tail call, thus the argument of the caller or callee.

Definition at line 1302 of file Attributor.h.

References llvm::Argument::getParent().

◆ isKernel()

bool llvm::InformationCache::isKernel ( const Function & F)
inline

Return true if F has the "kernel" function attribute.

Definition at line 1295 of file Attributor.h.

References F.

◆ isOnlyUsedByAssume()

bool llvm::InformationCache::isOnlyUsedByAssume ( const Instruction & I) const
inline

Definition at line 1307 of file Attributor.h.

References I.

◆ IsTargetGPU()

bool llvm::InformationCache::IsTargetGPU ( ) const
inline

Return true if the target is a GPU.

Definition at line 1347 of file Attributor.h.

Referenced by getFlatAddressSpace(), and stackIsAccessibleByOtherThreads().

◆ stackIsAccessibleByOtherThreads()

bool llvm::InformationCache::stackIsAccessibleByOtherThreads ( )
inline

Return true if the stack (llvm::Alloca) can be accessed by other threads.

Definition at line 1344 of file Attributor.h.

References IsTargetGPU().

Referenced by llvm::AA::isAssumedThreadLocalObject().

◆ Attributor

friend struct Attributor
friend

Give the Attributor access to the members so Attributor::identifyDefaultAbstractAttributes(...) can initialize them.

Definition at line 1430 of file Attributor.h.

References Attributor.

Referenced by Attributor, and getIndirectlyCallableFunctions().

Member Data Documentation

◆ CGSCC

const SetVector<Function *>* const llvm::InformationCache::CGSCC = nullptr

The CG-SCC the pass is run on, or nullptr if it is a module pass.

Definition at line 1265 of file Attributor.h.

Referenced by InformationCache().


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