15 #ifndef LLVM_CLANG_LIB_CODEGEN_CGCALL_H 16 #define LLVM_CLANG_LIB_CODEGEN_CGCALL_H 23 #include "llvm/IR/Value.h" 49 const Decl *CalleeDecl;
52 explicit CGCalleeInfo() : CalleeProtoTy(nullptr), CalleeDecl(nullptr) {}
54 : CalleeProtoTy(calleeProtoTy), CalleeDecl(calleeDecl) {}
56 : CalleeProtoTy(calleeProtoTy), CalleeDecl(nullptr) {}
58 : CalleeProtoTy(nullptr), CalleeDecl(calleeDecl) {}
77 struct BuiltinInfoStorage {
81 struct PseudoDestructorInfoStorage {
84 struct VirtualInfoStorage {
88 llvm::FunctionType *FTy;
91 SpecialKind KindOrFunctionPointer;
99 explicit CGCallee(SpecialKind
kind) : KindOrFunctionPointer(kind) {}
102 : KindOrFunctionPointer(SpecialKind::Builtin) {
108 CGCallee() : KindOrFunctionPointer(SpecialKind::Invalid) {}
113 : KindOrFunctionPointer(SpecialKind(
uintptr_t(functionPtr))) {
114 AbstractInfo = abstractInfo;
115 assert(functionPtr &&
"configuring callee without function pointer");
116 assert(functionPtr->getType()->isPointerTy());
117 assert(functionPtr->getType()->getPointerElementType()->isFunctionTy());
122 CGCallee result(SpecialKind::Builtin);
129 CGCallee result(SpecialKind::PseudoDestructor);
136 return CGCallee(abstractInfo, functionPtr);
140 llvm::FunctionType *FTy) {
141 CGCallee result(SpecialKind::Virtual);
150 return KindOrFunctionPointer == SpecialKind::Builtin;
162 return KindOrFunctionPointer == SpecialKind::PseudoDestructor;
165 assert(isPseudoDestructor());
166 return PseudoDestructorInfo.Expr;
174 return VirtualInfo.MD.getDecl();
175 assert(isOrdinary());
179 assert(isOrdinary());
183 assert(isOrdinary());
184 KindOrFunctionPointer = SpecialKind(
uintptr_t(functionPtr));
188 return KindOrFunctionPointer == SpecialKind::Virtual;
192 return VirtualInfo.CE;
196 return VirtualInfo.MD;
200 return VirtualInfo.Addr;
205 return VirtualInfo.FTy;
206 return cast<llvm::FunctionType>(
207 getFunctionPointer()->getType()->getPointerElementType());
230 : RV(rv), HasLV(
false), IsUsed(
false), Ty(ty) {}
232 : LV(lv), HasLV(
true), IsUsed(
false), Ty(ty) {}
241 assert(HasLV && !IsUsed);
245 assert(!HasLV && !IsUsed);
295 insert(end(), other.begin(), other.end());
296 Writebacks.insert(Writebacks.end(),
297 other.Writebacks.begin(), 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;
308 Writeback writeback = { srcLV, temporary, toUse };
309 Writebacks.push_back(writeback);
314 typedef llvm::iterator_range<SmallVectorImpl<Writeback>::const_iterator>
322 llvm::Instruction *IsActiveIP) {
326 CleanupsToDeactivate.push_back(ArgCleanup);
330 return CleanupsToDeactivate;
350 llvm::CallInst *StackBase;
362 llvm::PointerIntPair<llvm::Value *, 2, unsigned int>
Value;
374 : Value(Addr.isValid() ? Addr.getPointer() : nullptr,
375 (IsVolatile ? IS_VOLATILE : 0) | (IsUnused ? IS_UNUSED : 0)),
376 Alignment(Addr.isValid() ? Addr.getAlignment() :
CharUnits::Zero()) {}
380 bool isVolatile()
const {
return Value.getInt() & IS_VOLATILE; }
382 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.
A (possibly-)qualified type.
CGCallee(const CGCalleeInfo &abstractInfo, llvm::Value *functionPtr)
Construct a callee.
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
const Decl * getCalleeDecl() const
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
CGCalleeInfo(const Decl *calleeDecl)
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)
llvm::FunctionType * getFunctionType() const
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.
Expr - This represents one expression.
CGCalleeInfo(const FunctionProtoType *calleeProtoTy)
static CGCallee forDirect(llvm::Constant *functionPtr, const CGCalleeInfo &abstractInfo=CGCalleeInfo())
Address getThisAddress() const
static SVal getValue(SVal val, SValBuilder &svalBuilder)
BuiltinInfoStorage BuiltinInfo
CGCalleeInfo AbstractInfo
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
GlobalDecl - represents a global declaration.
LValue getKnownLValue() const
A saved depth on the scope stack.
void setRValue(RValue _RV)
GlobalDecl getVirtualMethodDecl() const
All available information about a concrete callee.
CGCalleeInfo(const FunctionProtoType *calleeProtoTy, const Decl *calleeDecl)
FunctionArgList - Type for representing both the decl and type of parameters to a function...
llvm::Instruction * IsActiveIP
The "is active" insertion point.
Dataflow Directional Tag Classes.
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
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.
Abstract information about a function or function prototype.
ArrayRef< CallArgCleanup > getCleanupsToDeactivate() const