LLVM 20.0.0git
|
Helper to describe and deal with positions in the LLVM-IR. More...
#include "llvm/Transforms/IPO/Attributor.h"
Public Types | |
enum | Kind : char { IRP_INVALID , IRP_FLOAT , IRP_RETURNED , IRP_CALL_SITE_RETURNED , IRP_FUNCTION , IRP_CALL_SITE , IRP_ARGUMENT , IRP_CALL_SITE_ARGUMENT } |
The positions we distinguish in the IR. More... | |
using | CallBaseContext = CallBase |
Public Member Functions | |
IRPosition () | |
Default constructor available to create invalid positions implicitly. | |
bool | operator== (const IRPosition &RHS) const |
bool | operator!= (const IRPosition &RHS) const |
Value & | getAnchorValue () const |
Return the value this abstract attribute is anchored with. | |
Function * | getAssociatedFunction () const |
Return the associated function, if any. | |
Argument * | getAssociatedArgument () const |
Return the associated argument, if any. | |
bool | isFnInterfaceKind () const |
Return true if the position refers to a function interface, that is the function scope, the function return, or an argument. | |
bool | isFunctionScope () const |
Return true if this is a function or call site position. | |
Function * | getAnchorScope () const |
Return the Function surrounding the anchor value. | |
Instruction * | getCtxI () const |
Return the context instruction, if any. | |
Value & | getAssociatedValue () const |
Return the value this abstract attribute is associated with. | |
Type * | getAssociatedType () const |
Return the type this abstract attribute is associated with. | |
int | getCalleeArgNo () const |
Return the callee argument number of the associated value if it is an argument or call site argument, otherwise a negative value. | |
int | getCallSiteArgNo () const |
Return the call site argument number of the associated value if it is an argument or call site argument, otherwise a negative value. | |
unsigned | getAttrIdx () const |
Return the index in the attribute list for this position. | |
Value * | getAttrListAnchor () const |
Return the value attributes are attached to. | |
AttributeList | getAttrList () const |
Return the attributes associated with this function or call site scope. | |
void | setAttrList (const AttributeList &AttrList) const |
Update the attributes associated with this function or call site scope. | |
unsigned | getNumArgs () const |
Return the number of arguments associated with this function or call site scope. | |
Value * | getArg (unsigned ArgNo) const |
Return theargument ArgNo associated with this function or call site scope. | |
Kind | getPositionKind () const |
Return the associated position kind. | |
bool | isAnyCallSitePosition () const |
bool | isArgumentPosition () const |
Return true if the position is an argument or call site argument. | |
IRPosition | stripCallBaseContext () const |
Return the same position without the call base context. | |
const CallBaseContext * | getCallBaseContext () const |
Get the call base context from the position. | |
bool | hasCallBaseContext () const |
Check if the position has any call base context. | |
operator void * () const | |
} | |
Static Public Member Functions | |
static const IRPosition | value (const Value &V, const CallBaseContext *CBContext=nullptr) |
Create a position describing the value of V . | |
static const IRPosition | inst (const Instruction &I, const CallBaseContext *CBContext=nullptr) |
Create a position describing the instruction I . | |
static const IRPosition | function (const Function &F, const CallBaseContext *CBContext=nullptr) |
Create a position describing the function scope of F . | |
static const IRPosition | returned (const Function &F, const CallBaseContext *CBContext=nullptr) |
Create a position describing the returned value of F . | |
static const IRPosition | argument (const Argument &Arg, const CallBaseContext *CBContext=nullptr) |
Create a position describing the argument Arg . | |
static const IRPosition | callsite_function (const CallBase &CB) |
Create a position describing the function scope of CB . | |
static const IRPosition | callsite_returned (const CallBase &CB) |
Create a position describing the returned value of CB . | |
static const IRPosition | callsite_argument (const CallBase &CB, unsigned ArgNo) |
Create a position describing the argument of CB at position ArgNo . | |
static const IRPosition | callsite_argument (AbstractCallSite ACS, unsigned ArgNo) |
Create a position describing the argument of ACS at position ArgNo . | |
static const IRPosition | function_scope (const IRPosition &IRP, const CallBaseContext *CBContext=nullptr) |
Create a position with function scope matching the "context" of IRP . | |
Static Public Attributes | |
static const IRPosition | EmptyKey |
Special DenseMap key values. | |
static const IRPosition | TombstoneKey |
Helper to describe and deal with positions in the LLVM-IR.
A position in the IR is described by an anchor value and an "offset" that could be the argument number, for call sites and arguments, or an indicator of the "position kind". The kinds, specified in the Kind enum below, include the locations in the attribute list, i.a., function scope and return value, as well as a distinction between call sites and functions. Finally, there are floating values that do not have a corresponding attribute list position.
Definition at line 586 of file Attributor.h.
Definition at line 589 of file Attributor.h.
enum llvm::IRPosition::Kind : char |
The positions we distinguish in the IR.
Definition at line 592 of file Attributor.h.
|
inline |
Default constructor available to create invalid positions implicitly.
All other positions need to be created explicitly through the appropriate static member function.
Definition at line 607 of file Attributor.h.
Referenced by argument(), callsite_argument(), callsite_function(), callsite_returned(), function(), inst(), returned(), and value().
|
inlinestatic |
Create a position describing the argument Arg
.
CBContext
is used for call base specific analysis.
Definition at line 643 of file Attributor.h.
References IRP_ARGUMENT, and IRPosition().
Referenced by llvm::Attributor::identifyDefaultAbstractAttributes(), llvm::AANoCapture::isImpliedByIR(), llvm::SubsumingPositionIterator::SubsumingPositionIterator(), and value().
|
inlinestatic |
Create a position describing the argument of ACS
at position ArgNo
.
Definition at line 666 of file Attributor.h.
References callsite_argument(), llvm::AbstractCallSite::getCallArgOperandNo(), llvm::AbstractCallSite::getInstruction(), llvm::AbstractCallSite::getNumArgOperands(), and IRPosition().
|
inlinestatic |
Create a position describing the argument of CB
at position ArgNo
.
Definition at line 659 of file Attributor.h.
References llvm::CallBase::getArgOperandUse(), IRP_CALL_SITE_ARGUMENT, and IRPosition().
Referenced by callsite_argument(), llvm::Attributor::identifyDefaultAbstractAttributes(), llvm::Attributor::isAssumedDead(), llvm::SubsumingPositionIterator::SubsumingPositionIterator(), and llvm::Attributor::translateArgumentToCallSiteContent().
|
inlinestatic |
Create a position describing the function scope of CB
.
Definition at line 649 of file Attributor.h.
References IRP_CALL_SITE, and IRPosition().
Referenced by llvm::Attributor::checkForAllCallees(), function_scope(), llvm::Attributor::identifyDefaultAbstractAttributes(), llvm::AA::isNoSyncInst(), and llvm::SubsumingPositionIterator::SubsumingPositionIterator().
|
inlinestatic |
Create a position describing the returned value of CB
.
Definition at line 654 of file Attributor.h.
References IRP_CALL_SITE_RETURNED, and IRPosition().
Referenced by llvm::Attributor::identifyDefaultAbstractAttributes(), llvm::Attributor::isAssumedDead(), and value().
|
inlinestatic |
Create a position describing the function scope of F
.
CBContext
is used for call base specific analysis.
Definition at line 629 of file Attributor.h.
References F, IRP_FUNCTION, and IRPosition().
Referenced by llvm::Attributor::checkForAllInstructions(), llvm::Attributor::checkForAllReadWriteInstructions(), llvm::Attributor::checkForAllUses(), function_scope(), llvm::Attributor::identifyDefaultAbstractAttributes(), llvm::Attributor::isAssumedDead(), isPotentiallyReachable(), llvm::AACallEdgeIterator::operator*(), and llvm::SubsumingPositionIterator::SubsumingPositionIterator().
|
inlinestatic |
Create a position with function scope matching the "context" of IRP
.
If IRP
is a call site (see isAnyCallSitePosition()) then the result will be a call site position, otherwise the function position of the associated function.
Definition at line 682 of file Attributor.h.
References assert(), callsite_function(), function(), getAnchorValue(), getAssociatedFunction(), and isAnyCallSitePosition().
|
inline |
Return the Function surrounding the anchor value.
Definition at line 758 of file Attributor.h.
References getAnchorValue().
Referenced by llvm::AAInterFnReachability::canReach(), llvm::Attributor::checkForAllUses(), getAssociatedFunction(), llvm::Attributor::getAssumedSimplifiedValues(), llvm::Attributor::isAssumedDead(), llvm::AANonNull::isImpliedByIR(), llvm::AANoAlias::isImpliedByIR(), llvm::Attributor::shouldInitialize(), llvm::Attributor::shouldUpdateAA(), and llvm::SubsumingPositionIterator::SubsumingPositionIterator().
|
inline |
Return the value this abstract attribute is anchored with.
The anchor value might not be the associated value if the latter is not sufficient to determine where arguments will be manifested. This is, so far, only the case for call site arguments as the value is not sufficient to pinpoint them. Instead, we can use the call site as an anchor.
Definition at line 703 of file Attributor.h.
References llvm_unreachable.
Referenced by function_scope(), getAnchorScope(), getArg(), getAssociatedArgument(), getAssociatedFunction(), getAssociatedValue(), getAttrList(), getAttrListAnchor(), getCtxI(), getNumArgs(), llvm::Attributor::hasAttr(), llvm::AAWillReturn::isImpliedByIR(), llvm::AAIsDead::isValidIRPositionForInit(), llvm::AAGlobalValueInfo::isValidIRPositionForInit(), llvm::Attributor::manifestAttrs(), llvm::operator<<(), setAttrList(), llvm::Attributor::shouldUpdateAA(), and llvm::SubsumingPositionIterator::SubsumingPositionIterator().
Return theargument ArgNo
associated with this function or call site scope.
Definition at line 872 of file Attributor.h.
References assert(), getAnchorValue(), llvm::Function::getArg(), getAssociatedFunction(), getPositionKind(), IRP_CALL_SITE, and IRP_FUNCTION.
Argument * IRPosition::getAssociatedArgument | ( | ) | const |
Return the associated argument, if any.
Definition at line 995 of file Attributor.cpp.
References llvm::Function::arg_size(), assert(), getAnchorValue(), llvm::Function::getArg(), llvm::AbstractCallSite::getCallArgOperandNo(), llvm::AbstractCallSite::getCallbackUses(), llvm::AbstractCallSite::getCalledFunction(), getCallSiteArgNo(), llvm::AbstractCallSite::getNumArgOperands(), getPositionKind(), IRP_ARGUMENT, and llvm::AbstractCallSite::isCallbackCall().
Referenced by getAssociatedFunction(), llvm::AANoCapture::isImpliedByIR(), and llvm::SubsumingPositionIterator::SubsumingPositionIterator().
|
inline |
Return the associated function, if any.
Definition at line 717 of file Attributor.h.
References getAnchorScope(), getAnchorValue(), getAssociatedArgument(), and llvm::GlobalValue::getParent().
Referenced by llvm::Attributor::checkForAllCallSites(), llvm::Attributor::checkForAllInstructions(), llvm::Attributor::checkForAllReadWriteInstructions(), llvm::Attributor::checkForAllReturnedValues(), function_scope(), getArg(), getAssociatedType(), getAttrList(), getAttrListAnchor(), llvm::DOTGraphTraits< AttributorCallGraph * >::getNodeLabel(), getNumArgs(), llvm::AANoSync::isImpliedByIR(), llvm::AANonNull::isImpliedByIR(), llvm::AANoCapture::isImpliedByIR(), llvm::AAIsDead::isLiveInstSet(), llvm::AbstractAttribute::isValidIRPositionForUpdate(), setAttrList(), and llvm::Attributor::shouldUpdateAA().
|
inline |
Return the type this abstract attribute is associated with.
Definition at line 793 of file Attributor.h.
References getAssociatedFunction(), getAssociatedValue(), getPositionKind(), llvm::Function::getReturnType(), llvm::Value::getType(), and IRP_RETURNED.
Referenced by llvm::AAPotentialValues::getSingleValue(), llvm::AANonNull::isImpliedByIR(), llvm::AANoSync::isValidIRPositionForInit(), llvm::AANonNull::isValidIRPositionForInit(), llvm::AANoAlias::isValidIRPositionForInit(), llvm::AANoFree::isValidIRPositionForInit(), llvm::AADereferenceable::isValidIRPositionForInit(), llvm::AAAlign::isValidIRPositionForInit(), llvm::AANoCapture::isValidIRPositionForInit(), llvm::AAPrivatizablePtr::isValidIRPositionForInit(), llvm::AAMemoryBehavior::isValidIRPositionForInit(), llvm::AAMemoryLocation::isValidIRPositionForInit(), llvm::AAValueConstantRange::isValidIRPositionForInit(), llvm::AAPotentialConstantValues::isValidIRPositionForInit(), llvm::AANoFPClass::isValidIRPositionForInit(), llvm::AAPointerInfo::isValidIRPositionForInit(), llvm::AAUnderlyingObjects::isValidIRPositionForInit(), llvm::AAAddressSpace::isValidIRPositionForInit(), and llvm::AAAllocationInfo::isValidIRPositionForInit().
|
inline |
Return the value this abstract attribute is associated with.
Definition at line 784 of file Attributor.h.
References assert(), getAnchorValue(), and getCallSiteArgNo().
Referenced by llvm::Attributor::changeAfterManifest(), getAssociatedType(), llvm::AAValueConstantRange::getAssumedConstant(), llvm::AAPotentialConstantValues::getAssumedConstant(), llvm::Attributor::getAssumedConstant(), llvm::Attributor::getAssumedSimplified(), llvm::Attributor::getAssumedSimplifiedValues(), llvm::Attributor::getAttrsFromAssumes(), llvm::Attributor::isAssumedDead(), llvm::AANonNull::isImpliedByIR(), llvm::AANoAlias::isImpliedByIR(), llvm::AANoCapture::isImpliedByIR(), llvm::AANoUndef::isImpliedByIR(), llvm::IRAttribute< AK, BaseType, AAType >::isImpliedByIR(), llvm::operator<<(), and llvm::SubsumingPositionIterator::SubsumingPositionIterator().
|
inline |
Return the index in the attribute list for this position.
Definition at line 818 of file Attributor.h.
References llvm::AttributeList::FirstArgIndex, llvm::AttributeList::FunctionIndex, getCalleeArgNo(), getCallSiteArgNo(), getPositionKind(), IRP_ARGUMENT, IRP_CALL_SITE, IRP_CALL_SITE_ARGUMENT, IRP_CALL_SITE_RETURNED, IRP_FLOAT, IRP_FUNCTION, IRP_INVALID, IRP_RETURNED, llvm_unreachable, and llvm::AttributeList::ReturnIndex.
|
inline |
Return the attributes associated with this function or call site scope.
Definition at line 846 of file Attributor.h.
References getAnchorValue(), getAssociatedFunction(), llvm::Function::getAttributes(), and llvm::AttributeList::getAttributes().
Referenced by llvm::Attributor::identifyDefaultAbstractAttributes().
|
inline |
Return the value attributes are attached to.
Definition at line 839 of file Attributor.h.
References getAnchorValue(), and getAssociatedFunction().
|
inline |
Get the call base context from the position.
Definition at line 932 of file Attributor.h.
Referenced by llvm::DenseMapInfo< IRPosition >::getHashValue(), llvm::Attributor::isAssumedDead(), and llvm::operator<<().
|
inline |
Return the callee argument number of the associated value if it is an argument or call site argument, otherwise a negative value.
In contrast to getCallSiteArgNo
this method will always return the "argument number" from the perspective of the callee. This may not the same as the call site if this is a callback call.
Definition at line 804 of file Attributor.h.
Referenced by llvm::AANoCapture::determineFunctionCaptureCapabilities(), and getAttrIdx().
|
inline |
Return the call site argument number of the associated value if it is an argument or call site argument, otherwise a negative value.
In contrast to getCalleArgNo
this method will always return the "operand number" from the perspective of the call site. This may not the same as the callee perspective if this is a callback call.
Definition at line 813 of file Attributor.h.
Referenced by llvm::Attributor::changeAfterManifest(), getAssociatedArgument(), getAssociatedValue(), getAttrIdx(), and llvm::operator<<().
|
inline |
Return the context instruction, if any.
Definition at line 770 of file Attributor.h.
References F, getAnchorValue(), and I.
Referenced by llvm::Attributor::changeAfterManifest(), llvm::Attributor::getAssumedSimplifiedValues(), llvm::Attributor::getAttrsFromAssumes(), llvm::Attributor::isAssumedDead(), llvm::AANonNull::isImpliedByIR(), llvm::AAIndirectCallInfo::isValidIRPositionForInit(), and llvm::AbstractAttribute::print().
|
inline |
Return the number of arguments associated with this function or call site scope.
Definition at line 861 of file Attributor.h.
References llvm::Function::arg_size(), assert(), getAnchorValue(), getAssociatedFunction(), getPositionKind(), IRP_CALL_SITE, and IRP_FUNCTION.
|
inline |
Return the associated position kind.
Definition at line 882 of file Attributor.h.
References IRP_ARGUMENT, IRP_CALL_SITE, IRP_CALL_SITE_ARGUMENT, IRP_CALL_SITE_RETURNED, IRP_FLOAT, IRP_FUNCTION, IRP_INVALID, and IRP_RETURNED.
Referenced by llvm::Attributor::changeAfterManifest(), llvm::AAExecutionDomain::createForPosition(), getArg(), getAssociatedArgument(), getAssociatedType(), llvm::Attributor::getAssumedSimplified(), llvm::Attributor::getAssumedSimplifiedValues(), getAttrIdx(), llvm::Attributor::getAttrsFromAssumes(), getNumArgs(), isAnyCallSitePosition(), isArgumentPosition(), llvm::Attributor::isAssumedDead(), isAssumedReadOnlyOrReadNone(), isFnInterfaceKind(), isFunctionScope(), llvm::AANonNull::isImpliedByIR(), llvm::AANoAlias::isImpliedByIR(), llvm::AANoCapture::isImpliedByIR(), llvm::AANoUndef::isImpliedByIR(), llvm::AAIsDead::isValidIRPositionForInit(), llvm::AAGlobalValueInfo::isValidIRPositionForInit(), llvm::AAIndirectCallInfo::isValidIRPositionForInit(), llvm::operator<<(), llvm::Attributor::shouldUpdateAA(), and llvm::SubsumingPositionIterator::SubsumingPositionIterator().
|
inline |
Check if the position has any call base context.
Definition at line 935 of file Attributor.h.
Referenced by llvm::operator<<().
|
inlinestatic |
Create a position describing the instruction I
.
This is different from the value version because call sites are treated as intrusctions rather than their return value in this function.
Definition at line 622 of file Attributor.h.
References I, IRP_FLOAT, and IRPosition().
Referenced by checkForAllInstructionsImpl(), llvm::Attributor::checkForAllReadWriteInstructions(), llvm::Attributor::identifyDefaultAbstractAttributes(), and llvm::Attributor::isAssumedDead().
|
inline |
Definition at line 902 of file Attributor.h.
References getPositionKind(), IRP_CALL_SITE, IRP_CALL_SITE_ARGUMENT, and IRP_CALL_SITE_RETURNED.
Referenced by function_scope(), and llvm::Attributor::shouldUpdateAA().
|
inline |
Return true if the position is an argument or call site argument.
Definition at line 914 of file Attributor.h.
References getPositionKind(), IRP_ARGUMENT, and IRP_CALL_SITE_ARGUMENT.
Referenced by llvm::AANoCapture::isImpliedByIR().
|
inline |
Return true if the position refers to a function interface, that is the function scope, the function return, or an argument.
Definition at line 735 of file Attributor.h.
References getPositionKind(), IRP_ARGUMENT, IRP_FUNCTION, and IRP_RETURNED.
Referenced by llvm::AbstractAttribute::isValidIRPositionForUpdate().
|
inline |
Return true if this is a function or call site position.
Definition at line 747 of file Attributor.h.
References getPositionKind(), IRP_CALL_SITE, and IRP_FUNCTION.
Referenced by llvm::AANoSync::isValidIRPositionForInit(), llvm::AANoFree::isValidIRPositionForInit(), llvm::AAMemoryBehavior::isValidIRPositionForInit(), and llvm::AAMemoryLocation::isValidIRPositionForInit().
|
inline |
}
Conversion into a void * to allow reuse of pointer hashing.
Definition at line 945 of file Attributor.h.
References llvm::PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info >::getOpaqueValue().
|
inline |
Definition at line 695 of file Attributor.h.
References RHS.
|
inline |
Definition at line 692 of file Attributor.h.
References RHS.
|
inlinestatic |
Create a position describing the returned value of F
.
CBContext
is used for call base specific analysis.
Definition at line 636 of file Attributor.h.
References F, IRP_RETURNED, and IRPosition().
Referenced by llvm::Attributor::checkForAllReturnedValues(), llvm::Attributor::identifyDefaultAbstractAttributes(), llvm::Attributor::isAssumedDead(), and llvm::SubsumingPositionIterator::SubsumingPositionIterator().
|
inline |
Update the attributes associated with this function or call site scope.
Definition at line 853 of file Attributor.h.
References getAnchorValue(), getAssociatedFunction(), and llvm::Function::setAttributes().
|
inline |
Return the same position without the call base context.
Definition at line 925 of file Attributor.h.
Referenced by llvm::Attributor::getOrCreateAAFor().
|
inlinestatic |
Create a position describing the value of V
.
Definition at line 610 of file Attributor.h.
References argument(), callsite_returned(), IRP_FLOAT, and IRPosition().
Referenced by clampReturnedValueStates(), llvm::Attributor::getAssumedConstant(), llvm::Attributor::getAssumedSimplified(), llvm::Attributor::getAssumedSimplifiedValues(), getPotentialCopiesOfMemoryValue(), llvm::Attributor::identifyDefaultAbstractAttributes(), llvm::Attributor::isAssumedDead(), llvm::AA::isAssumedThreadLocalObject(), llvm::AA::isDynamicallyUnique(), llvm::AA::isPotentiallyAffectedByBarrier(), stripAndAccumulateOffsets(), and llvm::SubsumingPositionIterator::SubsumingPositionIterator().
|
static |
Special DenseMap key values.
{
Definition at line 940 of file Attributor.h.
Referenced by llvm::DenseMapInfo< IRPosition >::getEmptyKey().
|
static |
Definition at line 941 of file Attributor.h.
Referenced by llvm::DenseMapInfo< IRPosition >::getTombstoneKey().