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());
121 CGCallee result(SpecialKind::Builtin);
128 CGCallee result(SpecialKind::PseudoDestructor);
135 return CGCallee(abstractInfo, functionPtr);
140 return CGCallee(abstractInfo, functionPtr.getCallee());
144 llvm::FunctionType *FTy) {
145 CGCallee result(SpecialKind::Virtual);
154 return KindOrFunctionPointer == SpecialKind::Builtin;
166 return KindOrFunctionPointer == SpecialKind::PseudoDestructor;
169 assert(isPseudoDestructor());
170 return PseudoDestructorInfo.Expr;
178 return VirtualInfo.MD;
179 assert(isOrdinary());
183 assert(isOrdinary());
187 assert(isOrdinary());
188 KindOrFunctionPointer = SpecialKind(
uintptr_t(functionPtr));
192 return KindOrFunctionPointer == SpecialKind::Virtual;
196 return VirtualInfo.CE;
200 return VirtualInfo.MD;
204 return VirtualInfo.Addr;
208 return VirtualInfo.FTy;
231 : RV(rv), HasLV(
false), IsUsed(
false), Ty(ty) {}
233 : LV(lv), HasLV(
true), IsUsed(
false), Ty(ty) {}
242 assert(HasLV && !IsUsed);
246 assert(!HasLV && !IsUsed);
295 insert(end(), other.begin(), other.end());
296 Writebacks.insert(Writebacks.end(), other.Writebacks.begin(),
297 other.Writebacks.end());
298 CleanupsToDeactivate.insert(CleanupsToDeactivate.end(),
299 other.CleanupsToDeactivate.begin(),
300 other.CleanupsToDeactivate.end());
301 assert(!(StackBase && other.StackBase) &&
"can't merge stackbases");
303 StackBase = other.StackBase;
307 Writeback writeback = {srcLV, temporary, toUse};
308 Writebacks.push_back(writeback);
313 typedef llvm::iterator_range<SmallVectorImpl<Writeback>::const_iterator>
321 llvm::Instruction *IsActiveIP) {
325 CleanupsToDeactivate.push_back(ArgCleanup);
329 return CleanupsToDeactivate;
349 llvm::CallInst *StackBase;
360 llvm::PointerIntPair<llvm::Value *, 2, unsigned int>
Value;
372 : Value(Addr.isValid() ? Addr.getPointer() : nullptr,
373 (IsVolatile ? IS_VOLATILE : 0) | (IsUnused ? IS_UNUSED : 0)),
374 Alignment(Addr.isValid() ? Addr.getAlignment() :
CharUnits::
Zero()) {}
378 bool isVolatile()
const {
return Value.getInt() & IS_VOLATILE; }
380 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.
bool Zero(InterpState &S, CodePtr OpPC)
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