struct IRPosition

Declaration

struct IRPosition { /* full declaration omitted */ };

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.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:427

Member Variables

private PointerIntPair<void*, NumEncodingBits, char> Enc
The pointer with the encoding bits.
private const llvm::IRPosition::CallBaseContext* CBContext = nullptr
Call base context. Used for callsite specific analysis.
public static const llvm::IRPosition EmptyKey
{
public static const llvm::IRPosition TombstoneKey
private static const int NumEncodingBits = PointerLikeTypeTraits<void *>::NumLowBitsAvailable

Method Overview

  • private IRPosition(void * Ptr, const llvm::IRPosition::CallBaseContext * CBContext = nullptr)
  • private IRPosition(llvm::Value & AnchorVal, llvm::IRPosition::Kind PK, const llvm::IRPosition::CallBaseContext * CBContext = nullptr)
  • private IRPosition(llvm::Use & U, llvm::IRPosition::Kind PK)
  • public IRPosition()
  • public static const llvm::IRPosition argument(const llvm::Argument & Arg, const llvm::IRPosition::CallBaseContext * CBContext = nullptr)
  • public static const llvm::IRPosition callsite_argument(llvm::AbstractCallSite ACS, unsigned int ArgNo)
  • public static const llvm::IRPosition callsite_argument(const llvm::CallBase & CB, unsigned int ArgNo)
  • public static const llvm::IRPosition callsite_function(const llvm::CallBase & CB)
  • public static const llvm::IRPosition callsite_returned(const llvm::CallBase & CB)
  • public static const llvm::IRPosition function(const llvm::Function & F, const llvm::IRPosition::CallBaseContext * CBContext = nullptr)
  • public static const llvm::IRPosition function_scope(const llvm::IRPosition & IRP, const llvm::IRPosition::CallBaseContext * CBContext = nullptr)
  • public llvm::Function * getAnchorScope() const
  • public llvm::Value & getAnchorValue() const
  • private int getArgNo(bool CallbackCalleeArgIfApplicable) const
  • private llvm::Use * getAsUsePtr() const
  • private llvm::Value * getAsValuePtr() const
  • public llvm::Argument * getAssociatedArgument() const
  • public llvm::Function * getAssociatedFunction() const
  • public llvm::Type * getAssociatedType() const
  • public llvm::Value & getAssociatedValue() const
  • public unsigned int getAttrIdx() const
  • public void getAttrs(ArrayRef<Attribute::AttrKind> AKs, SmallVectorImpl<llvm::Attribute> & Attrs, bool IgnoreSubsumingPositions = false, llvm::Attributor * A = nullptr) const
  • private bool getAttrsFromAssumes(Attribute::AttrKind AK, SmallVectorImpl<llvm::Attribute> & Attrs, llvm::Attributor & A) const
  • private bool getAttrsFromIRAttr(Attribute::AttrKind AK, SmallVectorImpl<llvm::Attribute> & Attrs) const
  • public const llvm::IRPosition::CallBaseContext * getCallBaseContext() const
  • public int getCallSiteArgNo() const
  • public int getCalleeArgNo() const
  • public llvm::Instruction * getCtxI() const
  • private char getEncodingBits() const
  • public llvm::IRPosition::Kind getPositionKind() const
  • public bool hasAttr(ArrayRef<Attribute::AttrKind> AKs, bool IgnoreSubsumingPositions = false, llvm::Attributor * A = nullptr) const
  • public bool hasCallBaseContext() const
  • public static const llvm::IRPosition inst(const llvm::Instruction & I, const llvm::IRPosition::CallBaseContext * CBContext = nullptr)
  • public bool isAnyCallSitePosition() const
  • public bool isArgumentPosition() const
  • public bool isFnInterfaceKind() const
  • private static bool isReturnPosition(char EncodingBits)
  • private bool isReturnPosition() const
  • public void * operator void *() const
  • public void removeAttrs(ArrayRef<Attribute::AttrKind> AKs) const
  • public static const llvm::IRPosition returned(const llvm::Function & F, const llvm::IRPosition::CallBaseContext * CBContext = nullptr)
  • public llvm::IRPosition stripCallBaseContext() const
  • public static const llvm::IRPosition value(const llvm::Value & V, const llvm::IRPosition::CallBaseContext * CBContext = nullptr)
  • private void verify()

Methods

IRPosition(
    void* Ptr,
    const llvm::IRPosition::CallBaseContext*
        CBContext = nullptr)

Description

Private constructor for special values only!

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:781

Parameters

void* Ptr
const llvm::IRPosition::CallBaseContext* CBContext = nullptr

IRPosition(
    llvm::Value& AnchorVal,
    llvm::IRPosition::Kind PK,
    const llvm::IRPosition::CallBaseContext*
        CBContext = nullptr)

Description

IRPosition anchored at \p AnchorVal with kind/argument numbet \p PK.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:787

Parameters

llvm::Value& AnchorVal
llvm::IRPosition::Kind PK
const llvm::IRPosition::CallBaseContext* CBContext = nullptr

IRPosition(llvm::Use& U,
           llvm::IRPosition::Kind PK)

Description

IRPosition for the use \p U. The position kind \p PK needs to be IRP_CALL_SITE_ARGUMENT, the anchor value is the user, the associated value the used value.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:842

Parameters

llvm::Use& U
llvm::IRPosition::Kind PK

IRPosition()

Description

Default constructor available to create invalid positions implicitly. All other positions need to be created explicitly through the appropriate static member function.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:448

static const llvm::IRPosition argument(
    const llvm::Argument& Arg,
    const llvm::IRPosition::CallBaseContext*
        CBContext = nullptr)

Description

Create a position describing the argument \p Arg. \p CBContext is used for call base specific analysis.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:484

Parameters

const llvm::Argument& Arg
const llvm::IRPosition::CallBaseContext* CBContext = nullptr

static const llvm::IRPosition callsite_argument(
    llvm::AbstractCallSite ACS,
    unsigned int ArgNo)

Description

Create a position describing the argument of \p ACS at position \p ArgNo.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:507

Parameters

llvm::AbstractCallSite ACS
unsigned int ArgNo

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

Description

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

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:500

Parameters

const llvm::CallBase& CB
unsigned int ArgNo

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

Description

Create a position describing the function scope of \p CB.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:490

Parameters

const llvm::CallBase& CB

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

Description

Create a position describing the returned value of \p CB.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:495

Parameters

const llvm::CallBase& CB

static const llvm::IRPosition function(
    const llvm::Function& F,
    const llvm::IRPosition::CallBaseContext*
        CBContext = nullptr)

Description

Create a position describing the function scope of \p F. \p CBContext is used for call base specific analysis.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:470

Parameters

const llvm::Function& F
const llvm::IRPosition::CallBaseContext* CBContext = nullptr

static const llvm::IRPosition function_scope(
    const llvm::IRPosition& IRP,
    const llvm::IRPosition::CallBaseContext*
        CBContext = nullptr)

Description

Create a position with function scope matching the "context" of \p IRP. If \p IRP is a call site (see isAnyCallSitePosition()) then the result will be a call site position, otherwise the function position of the associated function.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:523

Parameters

const llvm::IRPosition& IRP
const llvm::IRPosition::CallBaseContext* CBContext = nullptr

llvm::Function* getAnchorScope() const

Description

Return the Function surrounding the anchor value.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:587

llvm::Value& getAnchorValue() const

Description

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.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:544

int getArgNo(
    bool CallbackCalleeArgIfApplicable) const

Description

Return the callee argument number of the associated value if it is an argument or call site argument. See also `getCalleeArgNo` and `getCallSiteArgNo`.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:823

Parameters

bool CallbackCalleeArgIfApplicable

llvm::Use* getAsUsePtr() const

Description

Return the underlying pointer as Use *, valid only for IRP_CALL_SITE_ARGUMENT positions.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:872

llvm::Value* getAsValuePtr() const

Description

Return the underlying pointer as Value *, valid for all positions but IRP_CALL_SITE_ARGUMENT.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:864

llvm::Argument* getAssociatedArgument() const

Description

Return the associated argument, if any.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:571

llvm::Function* getAssociatedFunction() const

Description

Return the associated function, if any.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:558

llvm::Type* getAssociatedType() const

Description

Return the type this abstract attribute is associated with.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:622

llvm::Value& getAssociatedValue() const

Description

Return the value this abstract attribute is associated with.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:613

unsigned int getAttrIdx() const

Description

Return the index in the attribute list for this position.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:647

void getAttrs(
    ArrayRef<Attribute::AttrKind> AKs,
    SmallVectorImpl<llvm::Attribute>& Attrs,
    bool IgnoreSubsumingPositions = false,
    llvm::Attributor* A = nullptr) const

Description

Return the attributes of any kind in \p 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 \p AKs, there are "subsuming" positions that could have an attribute as well. This method returns all attributes found in \p Attrs.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:707

Parameters

ArrayRef<Attribute::AttrKind> AKs
SmallVectorImpl<llvm::Attribute>& Attrs
bool IgnoreSubsumingPositions = false
Flag to determine if subsuming positions, e.g., the function position if this is an argument position, should be ignored.
llvm::Attributor* A = nullptr

bool getAttrsFromAssumes(
    Attribute::AttrKind AK,
    SmallVectorImpl<llvm::Attribute>& Attrs,
    llvm::Attributor& A) const

Description

Return the attributes of kind \p AK existing in the IR as operand bundles of an llvm.assume.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:858

Parameters

Attribute::AttrKind AK
SmallVectorImpl<llvm::Attribute>& Attrs
llvm::Attributor& A

bool getAttrsFromIRAttr(
    Attribute::AttrKind AK,
    SmallVectorImpl<llvm::Attribute>& Attrs) const

Description

Return the attributes of kind \p AK existing in the IR as attribute.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:853

Parameters

Attribute::AttrKind AK
SmallVectorImpl<llvm::Attribute>& Attrs

const llvm::IRPosition::CallBaseContext*
getCallBaseContext() const

Description

Get the call base context from the position.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:764

int getCallSiteArgNo() const

Description

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.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:642

int getCalleeArgNo() const

Description

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.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:633

llvm::Instruction* getCtxI() const

Description

Return the context instruction, if any.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:599

char getEncodingBits() const

Description

Return the encoding bits.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:915

llvm::IRPosition::Kind getPositionKind() const

Description

Return the associated position kind.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:667

bool hasAttr(
    ArrayRef<Attribute::AttrKind> AKs,
    bool IgnoreSubsumingPositions = false,
    llvm::Attributor* A = nullptr) const

Description

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

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:695

Parameters

ArrayRef<Attribute::AttrKind> AKs
bool IgnoreSubsumingPositions = false
Flag to determine if subsuming positions, e.g., the function position if this is an argument position, should be ignored.
llvm::Attributor* A = nullptr

bool hasCallBaseContext() const

Description

Check if the position has any call base context.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:767

static const llvm::IRPosition inst(
    const llvm::Instruction& I,
    const llvm::IRPosition::CallBaseContext*
        CBContext = nullptr)

Description

Create a position describing the instruction \p I. This is different from the value version because call sites are treated as intrusctions rather than their return value in this function.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:463

Parameters

const llvm::Instruction& I
const llvm::IRPosition::CallBaseContext* CBContext = nullptr

bool isAnyCallSitePosition() const

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:734

bool isArgumentPosition() const

Description

Return true if the position is an argument or call site argument.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:746

bool isFnInterfaceKind() const

Description

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

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:575

static bool isReturnPosition(char EncodingBits)

Description

Return true if \p EncodingBits describe a returned or call site returned position.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:880

Parameters

char EncodingBits

bool isReturnPosition() const

Description

Return true if the encoding bits describe a returned or call site returned position.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:886

void* operator void*() const

Description

Conversion into a void * to allow reuse of pointer hashing.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:777

void removeAttrs(
    ArrayRef<Attribute::AttrKind> AKs) const

Description

Remove the attribute of kind \p AKs existing in the IR at this position.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:713

Parameters

ArrayRef<Attribute::AttrKind> AKs

static const llvm::IRPosition returned(
    const llvm::Function& F,
    const llvm::IRPosition::CallBaseContext*
        CBContext = nullptr)

Description

Create a position describing the returned value of \p F. \p CBContext is used for call base specific analysis.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:477

Parameters

const llvm::Function& F
const llvm::IRPosition::CallBaseContext* CBContext = nullptr

llvm::IRPosition stripCallBaseContext() const

Description

Return the same position without the call base context.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:757

static const llvm::IRPosition value(
    const llvm::Value& V,
    const llvm::IRPosition::CallBaseContext*
        CBContext = nullptr)

Description

Create a position describing the value of \p V.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:451

Parameters

const llvm::Value& V
const llvm::IRPosition::CallBaseContext* CBContext = nullptr

void verify()

Description

Verify internal invariants.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:850