LLVM: llvm::AbstractCallSite Class Reference (original) (raw)

AbstractCallSite. More...

#include "[llvm/IR/AbstractCallSite.h](AbstractCallSite%5F8h%5Fsource.html)"

Classes
struct CallbackInfo
The encoding of a callback with regards to the underlying instruction. More...
Public Member Functions
LLVM_ABI AbstractCallSite (const Use *U)
Sole constructor for abstract call sites (ACS).
operator bool () const
Conversion operator to conveniently check for a valid/initialized ACS.
CallBase * getInstruction () const
Return the underlying instruction.
bool isDirectCall () const
Return true if this ACS represents a direct call.
bool isIndirectCall () const
Return true if this ACS represents an indirect call.
bool isCallbackCall () const
Return true if this ACS represents a callback call.
bool isCallee (Value::const_user_iterator UI) const
Return true if UI is the use that defines the callee of this ACS.
bool isCallee (const Use *U) const
Return true if U is the use that defines the callee of this ACS.
unsigned getNumArgOperands () const
Return the number of parameters of the callee.
int getCallArgOperandNo (Argument &Arg) const
Return the operand index of the underlying instruction associated with Arg.
int getCallArgOperandNo (unsigned ArgNo) const
Return the operand index of the underlying instruction associated with the function parameter number ArgNo or -1 if there is none.
Value * getCallArgOperand (Argument &Arg) const
Return the operand of the underlying instruction associated with Arg.
Value * getCallArgOperand (unsigned ArgNo) const
Return the operand of the underlying instruction associated with the function parameter number ArgNo or nullptr if there is none.
int getCallArgOperandNoForCallee () const
Return the operand index of the underlying instruction associated with the callee of this ACS.
const Use & getCalleeUseForCallback () const
Return the use of the callee value in the underlying instruction.
Value * getCalledOperand () const
Return the pointer to function that is being called.
Function * getCalledFunction () const
Return the function being called if this is a direct call, otherwise return null (if it's an indirect call).

AbstractCallSite.

An abstract call site is a wrapper that allows to treat direct, indirect, and callback calls the same. If an abstract call site represents a direct or indirect call site it behaves like a stripped down version of a normal call site object. The abstract call site can also represent a callback call, thus the fact that the initially called function (=broker) may invoke a third one (=callback callee). In this case, the abstract call site hides the middle man, hence the broker function. The result is a representation of the callback call, inside the broker, but in the context of the original call to the broker.

There are up to three functions involved when we talk about callback call sites. The caller (1), which invokes the broker function. The broker function (2), that will invoke the callee zero or more times. And finally the callee (3), which is the target of the callback call.

The abstract call site will handle the mapping from parameters to arguments depending on the semantic of the broker function. However, it is important to note that the mapping is often partial. Thus, some arguments of the call/invoke instruction are mapped to parameters of the callee while others are not.

Definition at line 51 of file AbstractCallSite.h.

AbstractCallSite::AbstractCallSite ( const Use * U )

Sole constructor for abstract call sites (ACS).

Create an abstract call site from a use.

An abstract call site can only be constructed through a llvm::Use because each operand (=use) of an instruction could potentially be a different abstract call site. Furthermore, even if the value of the llvm::Use is the same, and the user is as well, the abstract call sites might not be.

If a use is not associated with an abstract call site the constructed ACS will evaluate to false if converted to a boolean.

If the use is the callee use of a call or invoke instruction, the constructed abstract call site will behave as a llvm::CallSite would.

If the use is not a callee use of a call or invoke instruction, the callback metadata is used to determine the argument <-> parameter mapping as well as the callee of the abstract call site.

Definition at line 55 of file AbstractCallSite.cpp.

References assert(), llvm::cast(), llvm::dyn_cast(), llvm::MDOperand::get(), llvm::MDNode::getNumOperands(), llvm::MDNode::getOperand(), if(), and llvm::MDNode::operands().

getCallArgOperand() [1/2]

Value * llvm::AbstractCallSite::getCallArgOperand ( Argument & Arg) const inline

getCallArgOperand() [2/2]

Value * llvm::AbstractCallSite::getCallArgOperand ( unsigned ArgNo) const inline

Return the operand of the underlying instruction associated with the function parameter number ArgNo or nullptr if there is none.

Definition at line 185 of file AbstractCallSite.h.

References isCallbackCall().

getCallArgOperandNo() [1/2]

int llvm::AbstractCallSite::getCallArgOperandNo ( Argument & Arg) const inline

getCallArgOperandNo() [2/2]

int llvm::AbstractCallSite::getCallArgOperandNo ( unsigned ArgNo) const inline

Return the operand index of the underlying instruction associated with the function parameter number ArgNo or -1 if there is none.

Definition at line 171 of file AbstractCallSite.h.

References isCallbackCall().

getCallArgOperandNoForCallee()

int llvm::AbstractCallSite::getCallArgOperandNoForCallee ( ) const inline

getCallbackUses()

getCalledFunction()

Function * llvm::AbstractCallSite::getCalledFunction ( ) const inline

getCalledOperand()

Value * llvm::AbstractCallSite::getCalledOperand ( ) const inline

getCalleeUseForCallback()

const Use & llvm::AbstractCallSite::getCalleeUseForCallback ( ) const inline

getInstruction()

CallBase * llvm::AbstractCallSite::getInstruction ( ) const inline

getNumArgOperands()

unsigned llvm::AbstractCallSite::getNumArgOperands ( ) const inline

isCallbackCall()

bool llvm::AbstractCallSite::isCallbackCall ( ) const inline

Return true if this ACS represents a callback call.

Definition at line 127 of file AbstractCallSite.h.

Referenced by llvm::Attributor::checkForAllCallSites(), llvm::forEachCallbackCallSite(), llvm::IRPosition::getAssociatedArgument(), getCallArgOperand(), getCallArgOperandNo(), getCallArgOperandNoForCallee(), getCalledOperand(), getNumArgOperands(), isCallee(), isDirectCall(), isIndirectCall(), and llvm::Attributor::isValidFunctionSignatureRewrite().

isCallee() [1/2]

bool llvm::AbstractCallSite::isCallee ( const Use * U) const inline

isCallee() [2/2]

isDirectCall()

bool llvm::AbstractCallSite::isDirectCall ( ) const inline

isIndirectCall()

bool llvm::AbstractCallSite::isIndirectCall ( ) const inline

operator bool()

llvm::AbstractCallSite::operator bool ( ) const inlineexplicit

Conversion operator to conveniently check for a valid/initialized ACS.

Definition at line 111 of file AbstractCallSite.h.


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