14 #ifndef LLVM_CLANG_LIB_CODEGEN_CGCALL_H 15 #define LLVM_CLANG_LIB_CODEGEN_CGCALL_H 22 #include "llvm/IR/Value.h" 53 : CalleeProtoTy(calleeProtoTy), CalleeDecl(calleeDecl) {}
55 : CalleeProtoTy(calleeProtoTy), CalleeDecl() {}
57 : CalleeProtoTy(nullptr), CalleeDecl(calleeDecl) {}
76 struct BuiltinInfoStorage {
80 struct PseudoDestructorInfoStorage {
83 struct VirtualInfoStorage {
87 llvm::FunctionType *FTy;
90 SpecialKind KindOrFunctionPointer;
98 explicit CGCallee(SpecialKind
kind) : KindOrFunctionPointer(kind) {}
101 : KindOrFunctionPointer(SpecialKind::Builtin) {
107 CGCallee() : KindOrFunctionPointer(SpecialKind::Invalid) {}
112 : KindOrFunctionPointer(SpecialKind(
uintptr_t(functionPtr))) {
113 AbstractInfo = abstractInfo;
114 assert(functionPtr &&
"configuring callee without function pointer");
115 assert(functionPtr->getType()->isPointerTy());
116 assert(functionPtr->getType()->getPointerElementType()->isFunctionTy());
135 return CGCallee(abstractInfo, functionPtr);
141 return CGCallee(abstractInfo, functionPtr.getCallee());
145 llvm::FunctionType *FTy) {
155 return KindOrFunctionPointer == SpecialKind::Builtin;
167 return KindOrFunctionPointer == SpecialKind::PseudoDestructor;
170 assert(isPseudoDestructor());
171 return PseudoDestructorInfo.Expr;
179 return VirtualInfo.MD;
180 assert(isOrdinary());
184 assert(isOrdinary());
188 assert(isOrdinary());
189 KindOrFunctionPointer = SpecialKind(
uintptr_t(functionPtr));
193 return KindOrFunctionPointer == SpecialKind::Virtual;
197 return VirtualInfo.CE;
201 return VirtualInfo.MD;
205 return VirtualInfo.Addr;
209 return VirtualInfo.FTy;
232 : RV(rv), HasLV(
false), IsUsed(
false), Ty(ty) {}
234 : LV(lv), HasLV(
true), IsUsed(
false), Ty(ty) {}
243 assert(HasLV && !IsUsed);
247 assert(!HasLV && !IsUsed);
297 insert(end(), other.begin(), other.end());
298 Writebacks.insert(Writebacks.end(),
299 other.Writebacks.begin(), other.Writebacks.end());
300 CleanupsToDeactivate.insert(CleanupsToDeactivate.end(),
301 other.CleanupsToDeactivate.begin(),
302 other.CleanupsToDeactivate.end());
303 assert(!(StackBase && other.StackBase) &&
"can't merge stackbases");
305 StackBase = other.StackBase;
310 Writeback writeback = { srcLV, temporary, toUse };
311 Writebacks.push_back(writeback);
316 typedef llvm::iterator_range<SmallVectorImpl<Writeback>::const_iterator>
324 llvm::Instruction *IsActiveIP) {
328 CleanupsToDeactivate.push_back(ArgCleanup);
332 return CleanupsToDeactivate;
352 llvm::CallInst *StackBase;
364 llvm::PointerIntPair<llvm::Value *, 2, unsigned int>
Value;
376 : Value(Addr.isValid() ? Addr.getPointer() : nullptr,
377 (IsVolatile ? IS_VOLATILE : 0) | (IsUnused ? IS_UNUSED : 0)),
378 Alignment(Addr.isValid() ? Addr.getAlignment() :
CharUnits::Zero()) {}
382 bool isVolatile()
const {
return Value.getInt() & IS_VOLATILE; }
384 bool isUnused()
const {
return Value.getInt() & IS_UNUSED; }
ReturnValueSlot - Contains the address where the return value of a function can be stored...
Represents a function declaration or definition.
static CGCallee forDirect(llvm::FunctionCallee functionPtr, const CGCalleeInfo &abstractInfo=CGCalleeInfo())
A (possibly-)qualified type.
CGCallee(const CGCalleeInfo &abstractInfo, llvm::Value *functionPtr)
Construct a callee.
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion...
C Language Family Type Representation.
static const Builtin::Info BuiltinInfo[]
Decl - This represents one declaration (or definition), e.g.
void addUncopiedAggregate(LValue LV, QualType type)
CallArg(LValue lv, QualType ty)
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
constexpr XRayInstrMask Function
bool hasWritebacks() const
llvm::Instruction * getStackBase() const
llvm::Value * getFunctionPointer() const
void add(RValue rvalue, QualType type)
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
VirtualInfoStorage VirtualInfo
EHScopeStack::stable_iterator Cleanup
bool isUsingInAlloca() const
Returns if we're using an inalloca struct to pass arguments in memory.
void addArgCleanupDeactivation(EHScopeStack::stable_iterator Cleanup, llvm::Instruction *IsActiveIP)
const CXXPseudoDestructorExpr * getPseudoDestructorExpr() const
CharUnits - This is an opaque type for sizes expressed in character units.
const FunctionDecl * getBuiltinDecl() const
void setFunctionPointer(llvm::Value *functionPtr)
llvm::iterator_range< SmallVectorImpl< Writeback >::const_iterator > writeback_const_range
const CallExpr * getVirtualCallExpr() const
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
void addFrom(const CallArgList &other)
Add all the arguments from another CallArgList to this one.
Represents a prototype with parameter type info, e.g.
RValue - This trivial value class is used to represent the result of an expression that is evaluated...
bool isPseudoDestructor() const
writeback_const_range writebacks() const
void addWriteback(LValue srcLV, Address temporary, llvm::Value *toUse)
PseudoDestructorInfoStorage PseudoDestructorInfo
Address Temporary
The temporary alloca.
llvm::Value * ToUse
A value to "use" after the writeback, or null.
This represents one expression.
CGCalleeInfo(const FunctionProtoType *calleeProtoTy)
static CGCallee forDirect(llvm::Constant *functionPtr, const CGCalleeInfo &abstractInfo=CGCalleeInfo())
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
Address getThisAddress() const
static SVal getValue(SVal val, SValBuilder &svalBuilder)
BuiltinInfoStorage BuiltinInfo
CGCalleeInfo AbstractInfo
GlobalDecl - represents a global declaration.
LValue getKnownLValue() const
A saved depth on the scope stack.
llvm::FunctionType * getVirtualFunctionType() const
void setRValue(RValue _RV)
GlobalDecl getVirtualMethodDecl() const
All available information about a concrete callee.
FunctionArgList - Type for representing both the decl and type of parameters to a function...
Optional< types::ID > Type
llvm::Instruction * IsActiveIP
The "is active" insertion point.
Dataflow Directional Tag Classes.
CGCalleeInfo(const FunctionProtoType *calleeProtoTy, GlobalDecl calleeDecl)
LValue Source
The original argument.
static CGCallee forBuiltin(unsigned builtinID, const FunctionDecl *builtinDecl)
unsigned getBuiltinID() const
static CGCallee forPseudoDestructor(const CXXPseudoDestructorExpr *E)
ReturnValueSlot(Address Addr, bool IsVolatile, bool IsUnused=false)
RValue getKnownRValue() const
const GlobalDecl getCalleeDecl() const
unsigned kind
All of the diagnostics that can be emitted by the frontend.
CallArg(RValue rv, QualType ty)
static CGCallee forVirtual(const CallExpr *CE, GlobalDecl MD, Address Addr, llvm::FunctionType *FTy)
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
const FunctionProtoType * getCalleeFunctionProtoType() const
LValue - This represents an lvalue references.
CGCalleeInfo getAbstractInfo() const
CallArgList - Type for representing both the value and type of arguments in a call.
CGCalleeInfo(GlobalDecl calleeDecl)
Abstract information about a function or function prototype.
ArrayRef< CallArgCleanup > getCleanupsToDeactivate() const