LLVM  10.0.0svn
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
llvm::IRPosition Struct Reference

} More...

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

Inheritance diagram for llvm::IRPosition:
Inheritance graph
[legend]
Collaboration diagram for llvm::IRPosition:
Collaboration graph
[legend]

Public Types

enum  Kind : int {
  IRP_INVALID = -6, IRP_FLOAT = -5, IRP_RETURNED = -4, IRP_CALL_SITE_RETURNED = -3,
  IRP_FUNCTION = -2, IRP_CALL_SITE = -1, IRP_ARGUMENT = 0, IRP_CALL_SITE_ARGUMENT = 1
}
 The positions we distinguish in the IR. More...
 

Public Member Functions

virtual ~IRPosition ()
 
 IRPosition ()
 Default constructor available to create invalid positions implicitly. More...
 
bool operator== (const IRPosition &RHS) const
 
bool operator!= (const IRPosition &RHS) const
 
ValuegetAnchorValue ()
 Return the value this abstract attribute is anchored with. More...
 
const ValuegetAnchorValue () const
 
FunctiongetAssociatedFunction ()
 } More...
 
const FunctiongetAssociatedFunction () const
 
ArgumentgetAssociatedArgument ()
 } More...
 
const ArgumentgetAssociatedArgument () const
 
bool isFnInterfaceKind () const
 } More...
 
FunctiongetAnchorScope ()
 Return the Function surrounding the anchor value. More...
 
const FunctiongetAnchorScope () const
 
InstructiongetCtxI ()
 } More...
 
const InstructiongetCtxI () const
 
ValuegetAssociatedValue ()
 } More...
 
const ValuegetAssociatedValue () const
 
int getArgNo () const
 } More...
 
unsigned getAttrIdx () const
 Return the index in the attribute list for this position. More...
 
Kind getPositionKind () const
 Return the associated position kind. More...
 
bool hasAttr (ArrayRef< Attribute::AttrKind > AKs) const
 TODO: Figure out if the attribute related helper functions should live here or somewhere else. More...
 
void getAttrs (ArrayRef< Attribute::AttrKind > AKs, SmallVectorImpl< Attribute > &Attrs) const
 Return the attributes of any kind in AKs existing in the IR at a position that will affect this one. More...
 
Attribute getAttr (Attribute::AttrKind AK) const
 Return the attribute of kind AK existing in the IR at this position. More...
 
bool isAnyCallSitePosition () const
 

Static Public Member Functions

static const IRPosition value (const Value &V)
 Create a position describing the value of V. More...
 
static const IRPosition function (const Function &F)
 Create a position describing the function scope of F. More...
 
static const IRPosition returned (const Function &F)
 Create a position describing the returned value of F. More...
 
static const IRPosition argument (const Argument &Arg)
 Create a position describing the argument Arg. More...
 
static const IRPosition callsite_function (const CallBase &CB)
 Create a position describing the function scope of CB. More...
 
static const IRPosition callsite_returned (const CallBase &CB)
 Create a position describing the returned value of CB. More...
 
static const IRPosition callsite_argument (const CallBase &CB, unsigned ArgNo)
 Create a position describing the argument of CB at position ArgNo. More...
 
static const IRPosition callsite_function (ImmutableCallSite ICS)
 Create a position describing the function scope of ICS. More...
 
static const IRPosition callsite_returned (ImmutableCallSite ICS)
 Create a position describing the returned value of ICS. More...
 
static const IRPosition callsite_argument (ImmutableCallSite ICS, unsigned ArgNo)
 Create a position describing the argument of ICS at position ArgNo. More...
 
static const IRPosition function_scope (const IRPosition &IRP)
 Create a position with function scope matching the "context" of IRP. More...
 

Static Public Attributes

static const IRPosition EmptyKey
 Special DenseMap key values. More...
 
static const IRPosition TombstoneKey
 

Detailed Description

}

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 134 of file Attributor.h.

Member Enumeration Documentation

◆ Kind

The positions we distinguish in the IR.

The values are chosen such that the KindOrArgNo member has a value >= 1 if it is an argument or call site argument while a value < 1 indicates the respective kind of that value.

Enumerator
IRP_INVALID 

An invalid position.

IRP_FLOAT 

A position that is not associated with a spot suitable for attributes.

This could be any value or instruction.

IRP_RETURNED 

An attribute for the function return value.

IRP_CALL_SITE_RETURNED 

An attribute for a call site return value.

IRP_FUNCTION 

An attribute for a function (scope).

IRP_CALL_SITE 

An attribute for a call site (function scope).

IRP_ARGUMENT 

An attribute for a function argument.

IRP_CALL_SITE_ARGUMENT 

An attribute for a call site argument.

Definition at line 142 of file Attributor.h.

Constructor & Destructor Documentation

◆ ~IRPosition()

virtual llvm::IRPosition::~IRPosition ( )
inlinevirtual

Definition at line 135 of file Attributor.h.

◆ IRPosition()

llvm::IRPosition::IRPosition ( )
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 157 of file Attributor.h.

References llvm::verify().

Member Function Documentation

◆ argument()

static const IRPosition llvm::IRPosition::argument ( const Argument Arg)
inlinestatic

◆ callsite_argument() [1/2]

static const IRPosition llvm::IRPosition::callsite_argument ( const CallBase CB,
unsigned  ArgNo 
)
inlinestatic

Create a position describing the argument of CB at position ArgNo.

Definition at line 194 of file Attributor.h.

Referenced by callsite_argument(), AACaptureUseTracker::captured(), clampCallSiteArgumentStates(), llvm::Attributor::identifyDefaultAbstractAttributes(), and AAHeapToStackImpl::updateImpl().

◆ callsite_argument() [2/2]

static const IRPosition llvm::IRPosition::callsite_argument ( ImmutableCallSite  ICS,
unsigned  ArgNo 
)
inlinestatic

Create a position describing the argument of ICS at position ArgNo.

Definition at line 210 of file Attributor.h.

References callsite_argument(), and llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getInstruction().

◆ callsite_function() [1/2]

static const IRPosition llvm::IRPosition::callsite_function ( const CallBase CB)
inlinestatic

◆ callsite_function() [2/2]

static const IRPosition llvm::IRPosition::callsite_function ( ImmutableCallSite  ICS)
inlinestatic

Create a position describing the function scope of ICS.

Definition at line 200 of file Attributor.h.

References callsite_function(), and llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getInstruction().

◆ callsite_returned() [1/2]

static const IRPosition llvm::IRPosition::callsite_returned ( const CallBase CB)
inlinestatic

Create a position describing the returned value of CB.

Definition at line 189 of file Attributor.h.

Referenced by callsite_returned(), and value().

◆ callsite_returned() [2/2]

static const IRPosition llvm::IRPosition::callsite_returned ( ImmutableCallSite  ICS)
inlinestatic

Create a position describing the returned value of ICS.

Definition at line 205 of file Attributor.h.

References callsite_returned(), and llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getInstruction().

◆ function()

static const IRPosition llvm::IRPosition::function ( const Function F)
inlinestatic

◆ function_scope()

static const IRPosition llvm::IRPosition::function_scope ( const IRPosition IRP)
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 220 of file Attributor.h.

References assert(), callsite_function(), function(), getAnchorValue(), getAssociatedFunction(), and isAnyCallSitePosition().

◆ getAnchorScope() [1/2]

Function* llvm::IRPosition::getAnchorScope ( )
inline

◆ getAnchorScope() [2/2]

const Function* llvm::IRPosition::getAnchorScope ( ) const
inline

Definition at line 319 of file Attributor.h.

◆ getAnchorValue() [1/2]

Value& llvm::IRPosition::getAnchorValue ( )
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 242 of file Attributor.h.

References assert().

Referenced by function_scope(), llvm::DenseMapInfo< IRPosition >::getHashValue(), AAAlignImpl::manifest(), llvm::IRAttributeManifest::manifestAttrs(), llvm::operator<<(), and llvm::SubsumingPositionIterator::SubsumingPositionIterator().

◆ getAnchorValue() [2/2]

const Value& llvm::IRPosition::getAnchorValue ( ) const
inline

Definition at line 247 of file Attributor.h.

◆ getArgNo()

int llvm::IRPosition::getArgNo ( ) const
inline

}

Return the argument number of the associated value if it is an argument or call site argument, otherwise a negative value.

Definition at line 362 of file Attributor.h.

Referenced by llvm::DenseMapInfo< IRPosition >::getHashValue(), llvm::operator<<(), and llvm::SubsumingPositionIterator::SubsumingPositionIterator().

◆ getAssociatedArgument() [1/2]

Argument* llvm::IRPosition::getAssociatedArgument ( )
inline

}

Return the associated argument, if any.

{

Definition at line 277 of file Attributor.h.

References Arg, llvm::Function::arg_begin(), and llvm::Function::arg_size().

Referenced by AANoCaptureImpl::updateImpl().

◆ getAssociatedArgument() [2/2]

const Argument* llvm::IRPosition::getAssociatedArgument ( ) const
inline

Definition at line 288 of file Attributor.h.

◆ getAssociatedFunction() [1/2]

Function* llvm::IRPosition::getAssociatedFunction ( )
inline

◆ getAssociatedFunction() [2/2]

const Function* llvm::IRPosition::getAssociatedFunction ( ) const
inline

Definition at line 269 of file Attributor.h.

◆ getAssociatedValue() [1/2]

Value& llvm::IRPosition::getAssociatedValue ( )
inline

}

Return the value this abstract attribute is associated with.

{

Definition at line 347 of file Attributor.h.

References assert().

Referenced by genericValueTraversal(), AANonNullFloating::initialize(), llvm::operator<<(), llvm::SubsumingPositionIterator::SubsumingPositionIterator(), and AANoCaptureImpl::updateImpl().

◆ getAssociatedValue() [2/2]

const Value& llvm::IRPosition::getAssociatedValue ( ) const
inline

Definition at line 355 of file Attributor.h.

◆ getAttr()

Attribute llvm::IRPosition::getAttr ( Attribute::AttrKind  AK) const
inline

Return the attribute of kind AK existing in the IR at this position.

Definition at line 419 of file Attributor.h.

References llvm::Attribute, llvm::AttributeList::getAttribute(), llvm::AttributeList::getAttributes(), and llvm::AttributeList::hasAttribute().

◆ getAttrIdx()

unsigned llvm::IRPosition::getAttrIdx ( ) const
inline

◆ getAttrs()

void IRPosition::getAttrs ( ArrayRef< Attribute::AttrKind AKs,
SmallVectorImpl< Attribute > &  Attrs 
) const

Return the attributes of any kind in AKs existing in the IR at a position that will affect this one.

While each position can only have a single attribute of any kind in AKs, there are "subsuming" positions that could have an attribute as well. This method returns all attributes found in Attrs.

Definition at line 429 of file Attributor.cpp.

References assert(), clampStateAndIndicateChange(), llvm::Attribute::getKindAsEnum(), and llvm::SmallVectorTemplateBase< T >::push_back().

◆ getCtxI() [1/2]

Instruction* llvm::IRPosition::getCtxI ( )
inline

}

Return the context instruction, if any.

{

Definition at line 327 of file Attributor.h.

References Arg, F(), and I.

Referenced by AANonNullFloating::initialize(), and llvm::Attributor::isAssumedDead().

◆ getCtxI() [2/2]

const Instruction* llvm::IRPosition::getCtxI ( ) const
inline

Definition at line 339 of file Attributor.h.

◆ getPositionKind()

Kind llvm::IRPosition::getPositionKind ( ) const
inline

◆ hasAttr()

bool IRPosition::hasAttr ( ArrayRef< Attribute::AttrKind AKs) const

TODO: Figure out if the attribute related helper functions should live here or somewhere else.

Return true if any kind in AKs existing in the IR at a position that will affect this one. See also getAttrs(...).

Definition at line 421 of file Attributor.cpp.

◆ isAnyCallSitePosition()

bool llvm::IRPosition::isAnyCallSitePosition ( ) const
inline

Definition at line 434 of file Attributor.h.

References IRP_CALL_SITE, IRP_CALL_SITE_ARGUMENT, and IRP_CALL_SITE_RETURNED.

Referenced by function_scope().

◆ isFnInterfaceKind()

bool llvm::IRPosition::isFnInterfaceKind ( ) const
inline

}

Return true if the position refers to a function interface, that is the function scope, the function return, or an argumnt.

Definition at line 295 of file Attributor.h.

References IRP_ARGUMENT, IRP_FUNCTION, and IRP_RETURNED.

Referenced by llvm::IRAttribute< Attribute::Returned, AbstractAttribute >::initialize(), and AAAlignImpl::initialize().

◆ operator!=()

bool llvm::IRPosition::operator!= ( const IRPosition RHS) const
inline

Definition at line 232 of file Attributor.h.

◆ operator==()

bool llvm::IRPosition::operator== ( const IRPosition RHS) const
inline

Definition at line 229 of file Attributor.h.

◆ returned()

static const IRPosition llvm::IRPosition::returned ( const Function F)
inlinestatic

◆ value()

static const IRPosition llvm::IRPosition::value ( const Value V)
inlinestatic

Member Data Documentation

◆ EmptyKey

const IRPosition IRPosition::EmptyKey
static

Special DenseMap key values.

{

Definition at line 448 of file Attributor.h.

Referenced by llvm::DenseMapInfo< IRPosition >::getEmptyKey(), and llvm::IRAttributeManifest::manifestAttrs().

◆ TombstoneKey

const IRPosition IRPosition::TombstoneKey
static

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