|
LLVM
10.0.0
|
#include "llvm/IR/CallSite.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). More... | |
| operator bool () const | |
| Conversion operator to conveniently check for a valid/initialized ACS. More... | |
| Instruction * | getInstruction () const |
| Return the underlying instruction. More... | |
| CallSite | getCallSite () const |
| Return the call site abstraction for the underlying instruction. More... | |
| bool | isDirectCall () const |
| Return true if this ACS represents a direct call. More... | |
| bool | isIndirectCall () const |
| Return true if this ACS represents an indirect call. More... | |
| bool | isCallbackCall () const |
| Return true if this ACS represents a callback call. More... | |
| bool | isCallee (Value::const_user_iterator UI) const |
Return true if UI is the use that defines the callee of this ACS. More... | |
| bool | isCallee (const Use *U) const |
Return true if U is the use that defines the callee of this ACS. More... | |
| unsigned | getNumArgOperands () const |
| Return the number of parameters of the callee. More... | |
| int | getCallArgOperandNo (Argument &Arg) const |
Return the operand index of the underlying instruction associated with Arg. More... | |
| 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. More... | |
| Value * | getCallArgOperand (Argument &Arg) const |
Return the operand of the underlying instruction associated with Arg. More... | |
| 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. More... | |
| int | getCallArgOperandNoForCallee () const |
| Return the operand index of the underlying instruction associated with the callee of this ACS. More... | |
| const Use & | getCalleeUseForCallback () const |
| Return the use of the callee value in the underlying instruction. More... | |
| Value * | getCalledValue () const |
| Return the pointer to function that is being called. More... | |
| Function * | getCalledFunction () const |
| Return the function being called if this is a direct call, otherwise return null (if it's an indirect call). More... | |
Static Public Member Functions | |
| static void | getCallbackUses (ImmutableCallSite ICS, SmallVectorImpl< const Use *> &CBUses) |
Add operand uses of ICS that represent callback uses into CBUses. More... | |
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 730 of file CallSite.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 56 of file AbstractCallSite.cpp.
References llvm::Function::arg_size(), assert(), Callee, llvm::numbers::e, llvm::MDOperand::get(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getArgumentNo(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getCalledFunction(), llvm::GlobalObject::getMetadata(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getNumArgOperands(), llvm::MDNode::getNumOperands(), llvm::MDNode::getOperand(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::isCallee(), llvm::Function::isVarArg(), 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 853 of file CallSite.h.
References llvm::Argument::getArgNo().
Referenced by PropagateConstantsIntoArguments().
Return the operand of the underlying instruction associated with the function parameter number ArgNo or nullptr if there is none.
Definition at line 859 of file CallSite.h.
References llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getArgOperand(), isDirectCall(), and llvm::AbstractCallSite::CallbackInfo::ParameterEncoding.
|
inline |
Return the operand index of the underlying instruction associated with Arg.
Definition at line 839 of file CallSite.h.
References llvm::Argument::getArgNo().
Referenced by llvm::IRPosition::callsite_argument(), and llvm::IRPosition::getAssociatedArgument().
|
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 845 of file CallSite.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 870 of file CallSite.h.
References assert(), llvm::AbstractCallSite::CallbackInfo::ParameterEncoding, and llvm::SmallVectorBase::size().
|
static |
Add operand uses of ICS that represent callback uses into CBUses.
All uses added to CBUses can be used to create abstract call sites for which AbstractCallSite::isCallbackCall() will return true.
Definition at line 36 of file AbstractCallSite.cpp.
References llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::arg_begin(), Callee, llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getCalledFunction(), llvm::GlobalObject::getMetadata(), llvm::MDNode::getOperand(), llvm::MDNode::operands(), and llvm::SmallVectorTemplateBase< T >::push_back().
Referenced by 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 894 of file CallSite.h.
References llvm::dyn_cast(), and llvm::Value::stripPointerCasts().
Referenced by llvm::IRPosition::getAssociatedArgument().
|
inline |
Return the pointer to function that is being called.
Definition at line 886 of file CallSite.h.
References llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getArgOperand(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getCalledValue(), and isDirectCall().
Return the use of the callee value in the underlying instruction.
Only valid for callback calls!
Definition at line 878 of file CallSite.h.
References assert().
Referenced by llvm::Attributor::checkForAllCallSites().
|
inline |
Return the call site abstraction for the underlying instruction.
Definition at line 794 of file CallSite.h.
|
inline |
Return the underlying instruction.
Definition at line 791 of file CallSite.h.
Referenced by llvm::IRPosition::callsite_argument(), llvm::Attributor::checkForAllCallSites(), and llvm::Attributor::run().
|
inline |
Return the number of parameters of the callee.
Definition at line 830 of file CallSite.h.
References llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getNumArgOperands(), isDirectCall(), llvm::AbstractCallSite::CallbackInfo::ParameterEncoding, and llvm::SmallVectorBase::size().
Referenced by llvm::IRPosition::getAssociatedArgument(), and PropagateConstantsIntoArguments().
|
inline |
Return true if this ACS represents a callback call.
Definition at line 807 of file CallSite.h.
References llvm::SmallVectorBase::empty(), and llvm::AbstractCallSite::CallbackInfo::ParameterEncoding.
Referenced by llvm::Attributor::checkForAllCallSites(), llvm::IRPosition::getAssociatedArgument(), and PropagateConstantsIntoArguments().
|
inline |
Return true if UI is the use that defines the callee of this ACS.
Definition at line 814 of file CallSite.h.
Referenced by llvm::Attributor::checkForAllCallSites().
Return true if U is the use that defines the callee of this ACS.
Definition at line 819 of file CallSite.h.
References assert(), llvm::SmallVectorBase::empty(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getArgumentNo(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::isCallee(), isDirectCall(), and llvm::AbstractCallSite::CallbackInfo::ParameterEncoding.
|
inline |
Return true if this ACS represents a direct call.
Definition at line 797 of file CallSite.h.
|
inline |
Return true if this ACS represents an indirect call.
Definition at line 802 of file CallSite.h.
|
inlineexplicit |
Conversion operator to conveniently check for a valid/initialized ACS.
Definition at line 788 of file CallSite.h.
1.8.13