LLVM 20.0.0git
|
#include "llvm/IR/AbstractCallSite.h"
Classes | |
struct | CallbackInfo |
The encoding of a callback with regards to the underlying instruction. More... | |
Public Member Functions | |
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). | |
Static Public Member Functions | |
static void | getCallbackUses (const CallBase &CB, SmallVectorImpl< const Use * > &CallbackUses) |
Add operand uses of CB that represent callback uses into CallbackUses . | |
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 50 of file AbstractCallSite.h.
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 llvm::CallBase::arg_size(), assert(), llvm::MDOperand::get(), llvm::CallBase::getArgOperandNo(), llvm::CallBase::getCalledFunction(), llvm::MDNode::getNumOperands(), llvm::MDNode::getOperand(), Idx, llvm::CallBase::isCallee(), llvm::MDNode::operands(), llvm::AbstractCallSite::CallbackInfo::ParameterEncoding, and llvm::SmallVectorTemplateBase< T, bool >::push_back().
Return the operand of the underlying instruction associated with Arg
.
Definition at line 177 of file AbstractCallSite.h.
References llvm::Argument::getArgNo(), and getCallArgOperand().
Referenced by llvm::Attributor::checkForAllCallSites(), and getCallArgOperand().
Return the operand of the underlying instruction associated with the function parameter number ArgNo
or nullptr if there is none.
Definition at line 183 of file AbstractCallSite.h.
References llvm::CallBase::getArgOperand(), isDirectCall(), and llvm::AbstractCallSite::CallbackInfo::ParameterEncoding.
|
inline |
Return the operand index of the underlying instruction associated with Arg
.
Definition at line 163 of file AbstractCallSite.h.
References llvm::Argument::getArgNo(), and getCallArgOperandNo().
Referenced by llvm::IRPosition::callsite_argument(), llvm::IRPosition::getAssociatedArgument(), and getCallArgOperandNo().
|
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 169 of file AbstractCallSite.h.
References isDirectCall(), and llvm::AbstractCallSite::CallbackInfo::ParameterEncoding.
|
inline |
Return the operand index of the underlying instruction associated with the callee of this ACS.
Only valid for callback calls!
Definition at line 194 of file AbstractCallSite.h.
References assert(), isCallbackCall(), llvm::AbstractCallSite::CallbackInfo::ParameterEncoding, and llvm::SmallVectorBase< Size_T >::size().
Referenced by getCalledOperand(), and getCalleeUseForCallback().
|
static |
Add operand uses of CB
that represent callback uses into CallbackUses
.
All uses added to CallbackUses
can be used to create abstract call sites for which AbstractCallSite::isCallbackCall() will return true.
Definition at line 34 of file AbstractCallSite.cpp.
References llvm::CallBase::arg_begin(), llvm::CallBase::arg_size(), llvm::CallBase::getCalledFunction(), llvm::MDNode::getOperand(), llvm::MDNode::operands(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().
Referenced by llvm::forEachCallbackCallSite(), and llvm::IRPosition::getAssociatedArgument().
|
inline |
Return the function being called if this is a direct call, otherwise return null (if it's an indirect call).
Definition at line 218 of file AbstractCallSite.h.
References getCalledOperand().
Referenced by llvm::Attributor::checkForAllCallSites(), llvm::forEachCallbackFunction(), llvm::IRPosition::getAssociatedArgument(), and llvm::Attributor::isValidFunctionSignatureRewrite().
|
inline |
Return the pointer to function that is being called.
Definition at line 210 of file AbstractCallSite.h.
References llvm::CallBase::getArgOperand(), getCallArgOperandNoForCallee(), llvm::CallBase::getCalledOperand(), and isDirectCall().
Referenced by getCalledFunction().
Return the use of the callee value in the underlying instruction.
Only valid for callback calls!
Definition at line 202 of file AbstractCallSite.h.
References assert(), getCallArgOperandNoForCallee(), getInstruction(), and llvm::User::getOperandUse().
Referenced by llvm::Attributor::checkForAllCallSites().
|
inline |
Return the underlying instruction.
Definition at line 112 of file AbstractCallSite.h.
Referenced by llvm::IRPosition::callsite_argument(), llvm::Attributor::checkForAllCallSites(), getCalleeUseForCallback(), and llvm::Attributor::isValidFunctionSignatureRewrite().
|
inline |
Return the number of parameters of the callee.
Definition at line 154 of file AbstractCallSite.h.
References llvm::CallBase::arg_size(), isDirectCall(), llvm::AbstractCallSite::CallbackInfo::ParameterEncoding, and llvm::SmallVectorBase< Size_T >::size().
Referenced by llvm::IRPosition::callsite_argument(), llvm::Attributor::checkForAllCallSites(), llvm::IRPosition::getAssociatedArgument(), and llvm::Attributor::isValidFunctionSignatureRewrite().
|
inline |
Return true if this ACS represents a callback call.
Definition at line 125 of file AbstractCallSite.h.
References llvm::SmallVectorBase< Size_T >::empty(), and llvm::AbstractCallSite::CallbackInfo::ParameterEncoding.
Referenced by llvm::Attributor::checkForAllCallSites(), llvm::forEachCallbackCallSite(), llvm::IRPosition::getAssociatedArgument(), getCallArgOperandNoForCallee(), isDirectCall(), isIndirectCall(), and llvm::Attributor::isValidFunctionSignatureRewrite().
Return true if U
is the use that defines the callee of this ACS.
Definition at line 137 of file AbstractCallSite.h.
References assert(), llvm::SmallVectorBase< Size_T >::empty(), llvm::CallBase::getArgOperandNo(), llvm::CallBase::isCallee(), isDirectCall(), and llvm::AbstractCallSite::CallbackInfo::ParameterEncoding.
|
inline |
Return true if UI
is the use that defines the callee of this ACS.
Definition at line 132 of file AbstractCallSite.h.
References isCallee().
Referenced by llvm::Attributor::checkForAllCallSites(), and isCallee().
|
inline |
Return true if this ACS represents a direct call.
Definition at line 115 of file AbstractCallSite.h.
References isCallbackCall(), and llvm::CallBase::isIndirectCall().
Referenced by getCallArgOperand(), getCallArgOperandNo(), getCalledOperand(), getNumArgOperands(), and isCallee().
|
inline |
Return true if this ACS represents an indirect call.
Definition at line 120 of file AbstractCallSite.h.
References isCallbackCall(), and llvm::CallBase::isIndirectCall().
|
inlineexplicit |
Conversion operator to conveniently check for a valid/initialized ACS.
Definition at line 109 of file AbstractCallSite.h.