21 #include "llvm/ADT/SmallSet.h"
22 #include "llvm/IR/CallSite.h"
23 #include "llvm/IR/DataLayout.h"
24 #include "llvm/IR/Module.h"
28 using namespace clang;
29 using namespace CodeGen;
32 :
Name(name), CXXThisIndex(0), CanBeGlobal(
false), NeedsCopyDispose(
false),
33 HasCXXObject(
false), UsesStret(
false), HasCapturedVariableLayout(
false),
34 LocalAddress(
Address::invalid()), StructureType(nullptr), Block(block),
35 DominatingIP(nullptr) {
39 if (!name.empty() && name[0] ==
'\01')
40 name = name.substr(1);
49 llvm::Constant *blockFn);
81 llvm::IntegerType *
ulong =
83 llvm::PointerType *i8p =
nullptr;
86 llvm::Type::getInt8PtrTy(
95 elements.addInt(ulong, 0);
113 std::string typeAtEncoding =
115 elements.add(llvm::ConstantExpr::getBitCast(
126 elements.addNullPointer(i8p);
128 unsigned AddrSpace = 0;
132 llvm::GlobalVariable *global =
133 elements.finishAndCreateGlobal(
"__block_descriptor_tmp",
155 struct objc_class *isa;
182 _ResultType (*invoke)(Block_literal *, _ParamTypes...);
185 struct Block_descriptor *block_descriptor;
188 _CapturesTypes captures...;
194 struct BlockLayoutChunk {
206 : Alignment(align), Size(size), Lifetime(lifetime),
207 Capture(capture),
Type(type), FieldType(fieldType) {}
216 info.
Captures.insert({Capture->getVariable(),
C});
223 bool operator<(
const BlockLayoutChunk &left,
const BlockLayoutChunk &right) {
224 if (left.Alignment != right.Alignment)
225 return left.Alignment > right.Alignment;
227 auto getPrefOrder = [](
const BlockLayoutChunk &chunk) {
228 if (chunk.Capture && chunk.Capture->isByRef())
237 return getPrefOrder(left) < getPrefOrder(right);
247 if (!recordType)
return true;
249 const auto *record = cast<CXXRecordDecl>(recordType->
getDecl());
252 if (!record->hasTrivialDestructor())
return false;
253 if (record->hasNonTrivialCopyConstructor())
return false;
257 return !record->hasMutableFields();
271 if (isa<ParmVarDecl>(var))
291 if (!init)
return nullptr;
313 assert(elementTypes.empty());
315 elementTypes.push_back(CGM.
IntTy);
316 elementTypes.push_back(CGM.
IntTy);
330 return FD->getType();
364 "Can't capture 'this' outside a method");
370 std::pair<CharUnits,CharUnits> tinfo
372 maxFieldAlign =
std::max(maxFieldAlign, tinfo.second);
374 layout.push_back(BlockLayoutChunk(tinfo.second, tinfo.first,
376 nullptr, llvmType, thisType));
380 for (
const auto &CI : block->
captures()) {
381 const VarDecl *variable = CI.getVariable();
389 maxFieldAlign =
std::max(maxFieldAlign, align);
433 }
else if (CI.hasCopyExpr()) {
441 if (!record->hasTrivialDestructor()) {
452 maxFieldAlign =
std::max(maxFieldAlign, align);
458 BlockLayoutChunk(align, size, lifetime, &CI, llvmType, VT));
462 if (layout.empty()) {
472 std::stable_sort(layout.begin(), layout.end());
496 if (endAlign < maxFieldAlign) {
498 li = layout.begin() + 1, le = layout.end();
502 for (; li != le && endAlign < li->Alignment; ++li)
509 for (; li != le; ++li) {
510 assert(endAlign >= li->Alignment);
512 li->setIndex(info, elementTypes.size(), blockSize);
513 elementTypes.push_back(li->Type);
514 blockSize += li->Size;
518 if (endAlign >= maxFieldAlign) {
523 layout.erase(first, li);
527 assert(endAlign ==
getLowBit(blockSize));
531 if (endAlign < maxFieldAlign) {
533 CharUnits padding = newBlockSize - blockSize;
541 elementTypes.push_back(llvm::ArrayType::get(CGM.
Int8Ty,
543 blockSize = newBlockSize;
547 assert(endAlign >= maxFieldAlign);
548 assert(endAlign ==
getLowBit(blockSize));
553 li = layout.begin(), le = layout.end(); li != le; ++li) {
554 if (endAlign < li->Alignment) {
558 CharUnits padding = li->Alignment - endAlign;
559 elementTypes.push_back(llvm::ArrayType::get(CGM.
Int8Ty,
561 blockSize += padding;
564 assert(endAlign >= li->Alignment);
565 li->setIndex(info, elementTypes.size(), blockSize);
566 elementTypes.push_back(li->Type);
567 blockSize += li->Size;
592 if (blockInfo.CanBeGlobal)
return;
596 blockInfo.BlockAlign,
"block");
599 if (!blockInfo.NeedsCopyDispose)
return;
603 for (
const auto &CI : block->
captures()) {
606 if (CI.isByRef())
continue;
609 const VarDecl *variable = CI.getVariable();
630 "expected ObjC ARC to be enabled");
644 if (!blockInfo.DominatingIP)
645 blockInfo.DominatingIP = cast<llvm::Instruction>(addr.
getPointer());
649 if (useArrayEHCleanup)
653 destroyer, useArrayEHCleanup);
667 i = cleanups.begin(), e = cleanups.end(); i != e; ++i) {
676 assert(head && *head);
691 assert(head &&
"destroying an empty chain");
696 }
while (head !=
nullptr);
708 blockInfo.BlockExpression = blockExpr;
713 std::unique_ptr<CGBlockInfo> blockInfo;
717 blockInfo->BlockExpression = blockExpr;
724 llvm::Constant *blockFn
728 blockFn = llvm::ConstantExpr::getBitCast(blockFn,
VoidPtrTy);
736 llvm::Constant *
isa =
742 isa = llvm::ConstantExpr::getBitCast(isa,
VoidPtrTy);
748 assert(blockAddr.
isValid() &&
"block has no address!");
772 auto addHeaderField =
774 storeField(value, index, offset, name);
780 addHeaderField(llvm::ConstantInt::get(
IntTy, flags.getBitMask()),
782 addHeaderField(llvm::ConstantInt::get(
IntTy, 0),
794 "block.captured-this.addr");
799 for (
const auto &CI : blockDecl->
captures()) {
800 const VarDecl *variable = CI.getVariable();
821 }
else if (CI.isByRef()) {
831 "block.capture.addr");
833 auto I = LocalDeclMap.find(variable);
834 assert(
I != LocalDeclMap.end());
838 DeclRefExpr declRef(const_cast<VarDecl *>(variable),
861 }
else if (
const Expr *copyExpr = CI.getCopyExpr()) {
911 DeclRefExpr declRef(const_cast<VarDecl *>(variable),
944 if (BlockDescriptorType)
945 return BlockDescriptorType;
965 "struct.__block_descriptor", UnsignedLongTy, UnsignedLongTy);
968 unsigned AddrSpace = 0;
971 BlockDescriptorType = llvm::PointerType::get(BlockDescriptorType, AddrSpace);
972 return BlockDescriptorType;
976 if (GenericBlockLiteralType)
977 return GenericBlockLiteralType;
988 GenericBlockLiteralType =
992 return GenericBlockLiteralType;
1007 unsigned AddrSpace = 0;
1016 Builder.CreatePointerCast(BlockPtr, BlockLiteralTy,
"block.literal");
1029 GenericVoidPtrTy =
Builder.getInt8PtrTy(
1036 BlockPtr =
Builder.CreatePointerCast(BlockPtr, GenericVoidPtrTy);
1054 llvm::Type *BlockFTyPtr = llvm::PointerType::getUnqual(BlockFTy);
1061 return EmitCall(FnInfo, Callee, ReturnValue, Args);
1066 assert(
BlockInfo &&
"evaluating block ref without block information?");
1070 if (capture.
isConstant())
return LocalDeclMap.find(variable)->second;
1074 capture.
getOffset(),
"block.capture.addr");
1083 auto byrefPointerType = llvm::PointerType::get(byrefInfo.Type, 0);
1097 llvm::Constant *Addr) {
1098 bool Ok = EmittedGlobalBlocks.insert(std::make_pair(BE, Addr)).second;
1100 assert(Ok &&
"Trying to replace an already-existing global block!");
1116 llvm::Constant *blockFn;
1124 blockFn = llvm::ConstantExpr::getBitCast(blockFn,
VoidPtrTy);
1131 llvm::Constant *blockFn) {
1137 "Refusing to re-emit a global block.");
1141 auto fields = builder.beginStruct();
1157 fields.addInt(CGM.
IntTy, 0);
1160 fields.add(blockFn);
1165 unsigned AddrSpace = 0;
1169 llvm::Constant *literal = fields.finishAndCreateGlobal(
1170 "__block_literal_global", blockInfo.
BlockAlign,
1177 llvm::ConstantExpr::getPointerCast(literal, RequiredType);
1185 assert(
BlockInfo &&
"not emitting prologue of block invocation function?!");
1199 DI->EmitDeclareOfBlockLiteralArgVariable(*
BlockInfo, arg, argNum,
1219 assert(
BlockInfo &&
"not in a block invocation function!");
1228 bool IsLambdaConversionToBlock) {
1240 for (DeclMapTy::const_iterator i = ldm.begin(), e = ldm.end(); i != e; ++i) {
1241 const auto *var = dyn_cast<
VarDecl>(i->first);
1242 if (var && !var->hasLocalStorage())
1243 setAddrOfLocalVar(var, i->second);
1268 args.push_back(&SelfDecl);
1319 for (
const auto &CI : blockDecl->
captures()) {
1320 const VarDecl *variable = CI.getVariable();
1330 setAddrOfLocalVar(variable, alloca);
1334 llvm::BasicBlock *entry =
Builder.GetInsertBlock();
1335 llvm::BasicBlock::iterator entry_ptr =
Builder.GetInsertPoint();
1338 if (IsLambdaConversionToBlock)
1347 llvm::BasicBlock *resume =
Builder.GetInsertBlock();
1351 Builder.SetInsertPoint(entry, entry_ptr);
1356 for (
const auto &CI : blockDecl->
captures()) {
1357 const VarDecl *variable = CI.getVariable();
1364 auto addr = LocalDeclMap.find(variable)->second;
1365 DI->EmitDeclareOfAutoVariable(variable, addr.
getPointer(),
1370 DI->EmitDeclareOfBlockDeclRefVariable(
1371 variable, BlockPointerDbgLoc,
Builder, blockInfo,
1372 entry_ptr == entry->end() ?
nullptr : &*entry_ptr);
1377 cast<CompoundStmt>(blockDecl->
getBody())->getRBracLoc());
1381 if (resume ==
nullptr)
1382 Builder.ClearInsertionPoint();
1384 Builder.SetInsertPoint(resume);
1405 struct BlockCaptureManagedEntity {
1414 :
Kind(Type), Flags(Flags), CI(CI), Capture(Capture) {}
1419 static std::pair<BlockCaptureEntityKind, BlockFieldFlags>
1425 return std::make_pair(BlockCaptureEntityKind::CXXRecord,
BlockFieldFlags());
1432 return std::make_pair(BlockCaptureEntityKind::BlockObject, Flags);
1448 return std::make_pair(BlockCaptureEntityKind::ARCWeak, Flags);
1455 return std::make_pair(!isBlockPointer ? BlockCaptureEntityKind::ARCStrong
1456 : BlockCaptureEntityKind::BlockObject,
1463 return std::make_pair(BlockCaptureEntityKind::BlockObject, Flags);
1473 llvm::function_ref<std::pair<BlockCaptureEntityKind, BlockFieldFlags>(
1477 const VarDecl *Variable = CI.getVariable();
1482 auto Info = Predicate(CI, Variable->
getType(), LangOpts);
1484 ManagedCaptures.emplace_back(Info.first, Info.second, CI, Capture);
1503 args.push_back(&DstDecl);
1506 args.push_back(&SrcDecl);
1515 llvm::Function *Fn =
1550 for (
const auto &CopiedCapture : CopiedCaptures) {
1555 unsigned index = capture.
getIndex();
1561 assert(CopiedCapture.Kind == BlockCaptureEntityKind::CXXRecord);
1563 }
else if (CopiedCapture.Kind == BlockCaptureEntityKind::ARCWeak) {
1567 if (CopiedCapture.Kind == BlockCaptureEntityKind::ARCStrong) {
1572 auto *ty = cast<llvm::PointerType>(srcValue->getType());
1573 llvm::Value *null = llvm::ConstantPointerNull::get(ty);
1585 cast<llvm::Instruction>(dstField.
getPointer())->eraseFromParent();
1588 assert(CopiedCapture.Kind == BlockCaptureEntityKind::BlockObject);
1597 bool copyCanThrow =
false;
1598 if (CI.
isByRef() && variable->getType()->getAsCXXRecordDecl()) {
1599 const Expr *copyExpr =
1602 copyCanThrow =
true;
1617 return llvm::ConstantExpr::getBitCast(Fn,
VoidPtrTy);
1620 static std::pair<BlockCaptureEntityKind, BlockFieldFlags>
1628 return std::make_pair(BlockCaptureEntityKind::BlockObject, Flags);
1632 if (Record->hasTrivialDestructor())
1634 return std::make_pair(BlockCaptureEntityKind::CXXRecord,
BlockFieldFlags());
1651 return std::make_pair(BlockCaptureEntityKind::ARCStrong, Flags);
1655 return std::make_pair(BlockCaptureEntityKind::ARCWeak, Flags);
1660 return std::make_pair(BlockCaptureEntityKind::BlockObject, Flags);
1680 args.push_back(&SrcDecl);
1689 llvm::Function *Fn =
1721 for (
const auto &DestroyedCapture : DestroyedCaptures) {
1730 if (DestroyedCapture.Kind == BlockCaptureEntityKind::CXXRecord) {
1736 }
else if (DestroyedCapture.Kind == BlockCaptureEntityKind::ARCWeak) {
1740 }
else if (DestroyedCapture.Kind == BlockCaptureEntityKind::ARCStrong) {
1747 assert(DestroyedCapture.Kind == BlockCaptureEntityKind::BlockObject);
1758 return llvm::ConstantExpr::getBitCast(Fn,
VoidPtrTy);
1794 void profileImpl(llvm::FoldingSetNodeID &
id)
const override {
1795 id.AddInteger(Flags.getBitMask());
1813 void profileImpl(llvm::FoldingSetNodeID &
id)
const override {
1833 llvm::ConstantPointerNull::get(cast<llvm::PointerType>(value->getType()));
1849 void profileImpl(llvm::FoldingSetNodeID &
id)
const override {
1859 ARCStrongBlockByrefHelpers(
CharUnits alignment)
1876 void profileImpl(llvm::FoldingSetNodeID &
id)
const override {
1886 const Expr *CopyExpr;
1890 const Expr *copyExpr)
1893 bool needsCopy()
const override {
return CopyExpr !=
nullptr; }
1896 if (!CopyExpr)
return;
1906 void profileImpl(llvm::FoldingSetNodeID &
id)
const override {
1907 id.AddPointer(VarType.getCanonicalType().getAsOpaquePtr());
1912 static llvm::Constant *
1922 args.push_back(&Dst);
1926 args.push_back(&Src);
1935 llvm::Function *Fn =
1940 = &Context.
Idents.
get(
"__Block_byref_object_copy_");
1972 generator.
emitCopy(CGF, destField, srcField);
1977 return llvm::ConstantExpr::getBitCast(Fn, CGF.
Int8PtrTy);
1989 static llvm::Constant *
1999 args.push_back(&Src);
2008 llvm::Function *Fn =
2010 "__Block_byref_object_dispose_",
2014 = &Context.
Idents.
get(
"__Block_byref_object_dispose_");
2030 auto byrefPtrType = byrefInfo.
Type->getPointerTo(0);
2039 return llvm::ConstantExpr::getBitCast(Fn, CGF.
Int8PtrTy);
2055 llvm::FoldingSetNodeID
id;
2056 generator.Profile(
id);
2061 if (node)
return static_cast<T*
>(node);
2066 T *copy =
new (CGM.
getContext()) T(std::forward<T>(generator));
2075 CodeGenFunction::buildByrefHelpers(llvm::StructType &byrefType,
2076 const AutoVarEmission &emission) {
2077 const VarDecl &var = *emission.Variable;
2089 if (!copyExpr && record->hasTrivialDestructor())
return nullptr;
2092 CGM, byrefInfo, CXXByrefHelpers(valueAlignment, type, copyExpr));
2115 ARCWeakByrefHelpers(valueAlignment));
2123 ARCStrongBlockByrefHelpers(valueAlignment));
2129 ARCStrongByrefHelpers(valueAlignment));
2132 llvm_unreachable(
"fell out of lifetime switch!");
2149 ObjectByrefHelpers(valueAlignment, flags));
2154 bool followForward) {
2162 const llvm::Twine &name) {
2164 if (followForward) {
2190 auto it = BlockByrefInfos.find(D);
2191 if (it != BlockByrefInfos.end())
2194 llvm::StructType *byrefType =
2208 types.push_back(llvm::PointerType::getUnqual(byrefType));
2221 if (hasCopyAndDispose) {
2231 bool HasByrefExtendedLayout =
false;
2233 if (
getContext().getByrefLifetime(Ty, Lifetime, HasByrefExtendedLayout) &&
2234 HasByrefExtendedLayout) {
2243 bool packed =
false;
2248 if (varOffset != size) {
2250 llvm::ArrayType::get(
Int8Ty, (varOffset - size).getQuantity());
2252 types.push_back(paddingTy);
2260 types.push_back(varTy);
2262 byrefType->setBody(types, packed);
2265 info.
Type = byrefType;
2270 auto pair = BlockByrefInfos.insert({D, info});
2271 assert(pair.second &&
"info was inserted recursively?");
2272 return pair.first->second;
2282 llvm::StructType *byrefType = cast<llvm::StructType>(
2283 cast<llvm::PointerType>(addr.
getPointer()->getType())->getElementType());
2285 unsigned nextHeaderIndex = 0;
2288 const Twine &name) {
2290 nextHeaderOffset, name);
2294 nextHeaderOffset += fieldSize;
2300 const VarDecl &D = *emission.Variable;
2303 bool HasByrefExtendedLayout;
2305 bool ByRefHasLifetime =
2325 if (ByRefHasLifetime) {
2327 else switch (ByrefLifetime) {
2345 printf(
"\n Inline flag for BYREF variable layout (%d):", flags.getBitMask());
2347 printf(
" BLOCK_BYREF_HAS_COPY_DISPOSE");
2351 printf(
" BLOCK_BYREF_LAYOUT_EXTENDED");
2353 printf(
" BLOCK_BYREF_LAYOUT_STRONG");
2355 printf(
" BLOCK_BYREF_LAYOUT_WEAK");
2357 printf(
" BLOCK_BYREF_LAYOUT_UNRETAINED");
2359 printf(
" BLOCK_BYREF_LAYOUT_NON_OBJECT");
2364 storeHeaderField(llvm::ConstantInt::get(
IntTy, flags.getBitMask()),
2368 V = llvm::ConstantInt::get(
IntTy, byrefSize.getQuantity());
2369 storeHeaderField(V,
getIntSize(),
"byref.size");
2373 "byref.copyHelper");
2375 "byref.disposeHelper");
2378 if (ByRefHasLifetime && HasByrefExtendedLayout) {
2397 CallBlockRelease(
llvm::Value *Addr) : Addr(Addr) {}
2421 llvm::Constant *C) {
2422 auto *GV = cast<llvm::GlobalValue>(C->stripPointerCasts());
2429 assert((isa<llvm::Function>(C->stripPointerCasts()) ||
2430 isa<llvm::GlobalVariable>(C->stripPointerCasts())) &&
2431 "expected Function or GlobalVariable");
2435 if ((ND = dyn_cast<FunctionDecl>(
Result)) ||
2440 if (GV->isDeclaration() && (!ND || !ND->hasAttr<DLLExportAttr>())) {
2441 GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
2444 GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
2452 if (GV->isDeclaration() && GV->hasExternalLinkage())
2453 GV->setLinkage(llvm::GlobalValue::ExternalWeakLinkage);
2457 if (BlockObjectDispose)
2458 return BlockObjectDispose;
2461 llvm::FunctionType *fty
2462 = llvm::FunctionType::get(
VoidTy, args,
false);
2463 BlockObjectDispose = CreateRuntimeFunction(fty,
"_Block_object_dispose");
2465 return BlockObjectDispose;
2469 if (BlockObjectAssign)
2470 return BlockObjectAssign;
2473 llvm::FunctionType *fty
2474 = llvm::FunctionType::get(
VoidTy, args,
false);
2475 BlockObjectAssign = CreateRuntimeFunction(fty,
"_Block_object_assign");
2477 return BlockObjectAssign;
2481 if (NSConcreteGlobalBlock)
2482 return NSConcreteGlobalBlock;
2484 NSConcreteGlobalBlock = GetOrCreateLLVMGlobal(
"_NSConcreteGlobalBlock",
2488 return NSConcreteGlobalBlock;
2492 if (NSConcreteStackBlock)
2493 return NSConcreteStackBlock;
2495 NSConcreteStackBlock = GetOrCreateLLVMGlobal(
"_NSConcreteStackBlock",
2499 return NSConcreteStackBlock;
const CGFunctionInfo & arrangeBuiltinFunctionDeclaration(QualType resultType, const FunctionArgList &args)
A builtin function is a freestanding function using the default C conventions.
void enterNonTrivialFullExpression(const ExprWithCleanups *E)
Enter a full-expression with a non-trivial number of objects to clean up.
ReturnValueSlot - Contains the address where the return value of a function can be stored...
Information about the layout of a __block variable.
llvm::Constant * GenerateCopyHelperFunction(const CGBlockInfo &blockInfo)
Generate the copy-helper function for a block closure object: static void block_copy_helper(block_t *...
static llvm::Constant * generateByrefDisposeHelper(CodeGenFunction &CGF, const BlockByrefInfo &byrefInfo, BlockByrefHelpers &generator)
Generate code for a __block variable's dispose helper.
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
llvm::Value * BlockPointer
llvm::IntegerType * IntTy
int
llvm::Type * getGenericBlockLiteralType()
The type of a generic block literal.
void ActivateCleanupBlock(EHScopeStack::stable_iterator Cleanup, llvm::Instruction *DominatingIP)
ActivateCleanupBlock - Activates an initially-inactive cleanup.
const CGFunctionInfo & arrangeBlockFunctionDeclaration(const FunctionProtoType *type, const FunctionArgList &args)
Block invocation functions are C functions with an implicit parameter.
External linkage, which indicates that the entity can be referred to from other translation units...
Parameter for captured context.
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
CharUnits BlockHeaderForcedGapOffset
static llvm::Constant * buildByrefDisposeHelper(CodeGenModule &CGM, const BlockByrefInfo &byrefInfo, BlockByrefHelpers &generator)
Build the dispose helper for a __block variable.
A class which contains all the information about a particular captured value.
Destroyer * getDestroyer(QualType::DestructionKind destructionKind)
A (possibly-)qualified type.
ArrayRef< Capture > captures() const
CodeGenTypes & getTypes()
llvm::Type * ConvertTypeForMem(QualType T)
CharUnits getDeclAlign(const Decl *D, bool ForAlignof=false) const
Return a conservative estimate of the alignment of the specified decl D.
bool isByRef() const
Whether this is a "by ref" capture, i.e.
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after...
llvm::Module & getModule() const
llvm::LLVMContext & getLLVMContext()
void EmitARCDestroyWeak(Address addr)
void @objc_destroyWeak(i8** addr) Essentially objc_storeWeak(addr, nil).
llvm::Constant * CopyHelper
The standard implementation of ConstantInitBuilder used in Clang.
FunctionType - C99 6.7.5.3 - Function Declarators.
CharUnits getOffset() const
static T * buildByrefHelpers(CodeGenModule &CGM, const BlockByrefInfo &byrefInfo, T &&generator)
Lazily build the copy and dispose helpers for a __block variable with the given information.
Expr * getCopyExpr() const
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Address getAddress() const
param_iterator param_end()
std::string getObjCEncodingForBlock(const BlockExpr *blockExpr) const
Return the encoded type for this block declaration.
static llvm::Constant * buildBlockDescriptor(CodeGenModule &CGM, const CGBlockInfo &blockInfo)
buildBlockDescriptor - Build the block descriptor meta-data for a block.
const llvm::DataLayout & getDataLayout() const
llvm::Value * LoadCXXThis()
LoadCXXThis - Load the value of 'this'.
The base class of the type hierarchy.
const Expr * getInit() const
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
void EmitARCCopyWeak(Address dst, Address src)
void @objc_copyWeak(i8** dest, i8** src) Disregards the current value in dest.
void ForceCleanup(std::initializer_list< llvm::Value ** > ValuesToReload={})
Force the emission of cleanups now, instead of waiting until this object is destroyed.
const LangOptions & getLangOpts() const
CharUnits alignTo(const CharUnits &Align) const
alignTo - Returns the next integer (mod 2**64) that is greater than or equal to this quantity and is ...
bool isBlockPointerType() const
llvm::Value * EmitARCRetainNonBlock(llvm::Value *value)
Retain the given object, with normal retain semantics.
llvm::IntegerType * Int8Ty
i8, i16, i32, and i64
uint32_t getBitMask() const
Address GetAddrOfLocalVar(const VarDecl *VD)
GetAddrOfLocalVar - Return the address of a local variable.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
CGBlockInfo(const BlockDecl *blockDecl, StringRef Name)
bool capturesCXXThis() const
const Expr * getCallee() const
ObjCLifetime getObjCLifetime() const
bool hasCaptures() const
hasCaptures - True if this block (or its nested blocks) captures anything of local storage from its e...
const FunctionProtoType * getFunctionType() const
getFunctionType - Return the underlying function type for this block.
This class gathers all debug information during compilation and is responsible for emitting to llvm g...
CharUnits GetTargetTypeStoreSize(llvm::Type *Ty) const
Return the store size, in character units, of the given LLVM type.
static std::pair< BlockCaptureEntityKind, BlockFieldFlags > computeCopyInfoForBlockCapture(const BlockDecl::Capture &CI, QualType T, const LangOptions &LangOpts)
virtual llvm::Constant * BuildRCBlockLayout(CodeGen::CodeGenModule &CGM, const CodeGen::CGBlockInfo &blockInfo)=0
llvm::Type * ConvertTypeForMem(QualType T)
ConvertTypeForMem - Convert type T into a llvm::Type.
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
bool isObjCRetainableType() const
static void destroyBlockInfos(CGBlockInfo *info)
Destroy a chain of block layouts.
The collection of all-type qualifiers we support.
llvm::Constant * getPointer() const
llvm::DenseMap< const VarDecl *, FieldDecl * > LambdaCaptureFields
One of these records is kept for each identifier that is lexed.
void emitByrefStructureInit(const AutoVarEmission &emission)
Initialize the structural components of a __block variable, i.e.
CGBlockInfo * FirstBlockInfo
FirstBlockInfo - The head of a singly-linked-list of block layouts.
CGDebugInfo * getDebugInfo()
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
llvm::Type * ConvertType(QualType T)
ConvertType - Convert type T into a llvm::Type.
CharUnits getIntSize() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
void EmitExprAsInit(const Expr *init, const ValueDecl *D, LValue lvalue, bool capturedByInit)
EmitExprAsInit - Emits the code necessary to initialize a location in memory with the given initializ...
bool HasCapturedVariableLayout
HasCapturedVariableLayout : True if block has captured variables and their layout meta-data has been ...
bool isReferenceType() const
static std::pair< BlockCaptureEntityKind, BlockFieldFlags > computeDestroyInfoForBlockCapture(const BlockDecl::Capture &CI, QualType T, const LangOptions &LangOpts)
const Stmt * getBody() const
static void findBlockCapturedManagedEntities(const CGBlockInfo &BlockInfo, const LangOptions &LangOpts, SmallVectorImpl< BlockCaptureManagedEntity > &ManagedCaptures, llvm::function_ref< std::pair< BlockCaptureEntityKind, BlockFieldFlags >(const BlockDecl::Capture &, QualType, const LangOptions &)> Predicate)
Find the set of block captures that need to be explicitly copied or destroy.
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
static llvm::Constant * generateByrefCopyHelper(CodeGenFunction &CGF, const BlockByrefInfo &byrefInfo, BlockByrefHelpers &generator)
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
static bool isSafeForCXXConstantCapture(QualType type)
Determines if the given type is safe for constant capture in C++.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
static ApplyDebugLocation CreateArtificial(CodeGenFunction &CGF)
Apply TemporaryLocation if it is valid.
const Capture & getCapture(const VarDecl *var) const
llvm::Value * EmitARCStoreStrongCall(Address addr, llvm::Value *value, bool resultIgnored)
Store into a strong object.
Address GetAddrOfBlockDecl(const VarDecl *var, bool ByRef)
const LangOptions & getLangOpts() const
CharUnits - This is an opaque type for sizes expressed in character units.
void EmitARCDestroyStrong(Address addr, ARCPreciseLifetime_t precise)
Destroy a __strong variable.
QualType getReturnType() const
bool HasCXXObject
HasCXXObject - True if the block's custom copy/dispose functions need to be run even in GC mode...
llvm::Value * EmitBlockLiteral(const BlockExpr *)
Emit a block literal expression in the current function.
llvm::PointerType * VoidPtrTy
bool getByrefLifetime(QualType Ty, Qualifiers::ObjCLifetime &Lifetime, bool &HasByrefExtendedLayout) const
Returns true, if given type has a known lifetime.
bool needsEHCleanup(QualType::DestructionKind kind)
Determines whether an EH cleanup is required to destroy a type with the given destruction kind...
RecordDecl * getDecl() const
CharUnits getPointerSize() const
llvm::Constant * getAddrOfGlobalBlockIfEmitted(const BlockExpr *BE)
Returns the address of a block which requires no caputres, or null if we've yet to emit the block for...
Address EmitLoadOfReference(Address Ref, const ReferenceType *RefTy, LValueBaseInfo *BaseInfo=nullptr)
std::string getNameAsString() const
getNameAsString - Get a human-readable name for the declaration, even if it is one of the special kin...
Scope - A scope is a transient data structure that is used while parsing the program.
llvm::PointerType * VoidPtrPtrTy
void EmitStmt(const Stmt *S)
EmitStmt - Emit the code for the statement.
void assignRegionCounters(GlobalDecl GD, llvm::Function *Fn)
Assign counters to regions and configure them for PGO of a given function.
static Capture makeConstant(llvm::Value *value)
GlobalDecl CurGD
CurGD - The GlobalDecl for the current function being compiled.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
void incrementProfileCounter(const Stmt *S, llvm::Value *StepV=nullptr)
Increment the profiler's counter for the given statement by StepV.
llvm::AllocaInst * CreateTempAlloca(llvm::Type *Ty, const Twine &Name="tmp", llvm::Value *ArraySize=nullptr)
CreateTempAlloca - This creates an alloca and inserts it into the entry block if ArraySize is nullptr...
detail::InMemoryDirectory::const_iterator I
llvm::Constant * getNSConcreteStackBlock()
std::pair< CharUnits, CharUnits > getTypeInfoInChars(const Type *T) const
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInlineSpecified=false, bool hasWrittenPrototype=true, bool isConstexprSpecified=false)
This object can be modified without requiring retains or releases.
bool NeedsCopyDispose
True if the block needs a custom copy or dispose function.
const BlockExpr * BlockExpression
llvm::CallSite EmitRuntimeCallOrInvoke(llvm::Value *callee, ArrayRef< llvm::Value * > args, const Twine &name="")
Emits a call or invoke instruction to the given runtime function.
static llvm::Constant * buildCopyHelper(CodeGenModule &CGM, const CGBlockInfo &blockInfo)
Build the helper function to copy a block.
Represents a prototype with parameter type info, e.g.
bool isConversionFromLambda() const
llvm::CallInst * EmitNounwindRuntimeCall(llvm::Value *callee, const Twine &name="")
const CodeGen::CGBlockInfo * BlockInfo
llvm::Function * GenerateBlockFunction(GlobalDecl GD, const CGBlockInfo &Info, const DeclMapTy &ldm, bool IsLambdaConversionToBlock)
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
CGBlockInfo - Information to generate a block literal.
virtual void emitCopy(CodeGenFunction &CGF, Address dest, Address src)=0
unsigned getNumObjects() const
const TargetInfo & getTarget() const
RValue - This trivial value class is used to represent the result of an expression that is evaluated...
bool CanBeGlobal
CanBeGlobal - True if the block can be global, i.e.
SourceLocation getLocEnd() const LLVM_READONLY
StringRef getBlockMangledName(GlobalDecl GD, const BlockDecl *BD)
llvm::Constant * getNullPointer(llvm::PointerType *T, QualType QT)
Get target specific null pointer.
bool isObjCInertUnsafeUnretainedType() const
Was this type written with the special inert-in-MRC __unsafe_unretained qualifier?
CGBlockInfo * NextBlockInfo
The next block in the block-info chain.
CGObjCRuntime & getObjCRuntime()
Return a reference to the configured Objective-C runtime.
llvm::Value * getPointer() const
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
QualType getPointeeType() const
unsigned getIndex() const
Expr - This represents one expression.
virtual bool needsCopy() const
void EmitARCMoveWeak(Address dst, Address src)
void @objc_moveWeak(i8** dest, i8** src) Disregards the current value in dest.
Emit only debug info necessary for generating line number tables (-gline-tables-only).
VarDecl * getVariable() const
The variable being captured.
Enters a new scope for capturing cleanups, all of which will be executed once the scope is exited...
llvm::Constant * DisposeHelper
void EmitCallArgs(CallArgList &Args, const T *CallArgTypeInfo, llvm::iterator_range< CallExpr::const_arg_iterator > ArgRange, AbstractCallee AC=AbstractCallee(), unsigned ParamsToSkip=0, EvaluationOrder Order=EvaluationOrder::Default)
EmitCallArgs - Emit call arguments for a function.
void SetInternalFunctionAttributes(const Decl *D, llvm::Function *F, const CGFunctionInfo &FI)
Set the attributes on the LLVM function for the given decl and function info.
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
BlockCaptureEntityKind
Represents a type of copy/destroy operation that should be performed for an entity that's captured by...
static llvm::Constant * buildGlobalBlock(CodeGenModule &CGM, const CGBlockInfo &blockInfo, llvm::Constant *blockFn)
Build the given block as a global block.
llvm::Constant * GenerateDestroyHelperFunction(const CGBlockInfo &blockInfo)
Generate the destroy-helper function for a block closure object: static void block_destroy_helper(blo...
TranslationUnitDecl * getTranslationUnitDecl() const
bool isObjCGCWeak() const
true when Type is objc's weak.
capture_const_iterator capture_begin() const
void EmitLambdaBlockInvokeBody()
ASTContext & getContext() const
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
internal::Matcher< T > id(StringRef ID, const internal::BindableMatcher< T > &InnerMatcher)
If the provided matcher matches a node, binds the node to ID.
void add(RValue rvalue, QualType type, bool needscopy=false)
stable_iterator stable_begin() const
Create a stable reference to the top of the EH stack.
llvm::LLVMContext & getLLVMContext()
bool ReturnSlotInterferesWithArgs(const CGFunctionInfo &FI)
Return true iff the given type uses an argument slot when 'sret' is used as a return type...
llvm::IntegerType * Int32Ty
static Capture makeIndex(unsigned index, CharUnits offset, QualType FieldType)
bool isa(CodeGen::Address addr)
static CharUnits getLowBit(CharUnits v)
Get the low bit of a nonzero character count.
static AggValueSlot forAddr(Address addr, Qualifiers quals, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, IsAliased_t isAliased, IsZeroed_t isZeroed=IsNotZeroed)
forAddr - Make a slot for an aggregate value.
static QualType getCaptureFieldType(const CodeGenFunction &CGF, const BlockDecl::Capture &CI)
GlobalDecl - represents a global declaration.
EHScopeStack::stable_iterator getCleanup() const
virtual llvm::Constant * BuildByrefLayout(CodeGen::CodeGenModule &CGM, QualType T)=0
Returns an i8* which points to the byref layout information.
bool hasObjCLifetime() const
param_iterator param_begin()
The l-value was considered opaque, so the alignment was determined from a type.
void setBlockContextParameter(const ImplicitParamDecl *D, unsigned argNum, llvm::Value *ptr)
bool UsesStret
UsesStret : True if the block uses an stret return.
void enterByrefCleanup(const AutoVarEmission &emission)
Enter a cleanup to destroy a __block variable.
bool HaveInsertPoint() const
HaveInsertPoint - True if an insertion point is defined.
There is no lifetime qualification on this type.
Address CreateBitCast(Address Addr, llvm::Type *Ty, const llvm::Twine &Name="")
ArrayRef< CleanupObject > getObjects() const
Assigning into this object requires the old value to be released and the new value to be retained...
Expr * getBlockVarCopyInits(const VarDecl *VD)
Get the copy initialization expression of the VarDecl VD, or NULL if none exists. ...
void PushDestructorCleanup(QualType T, Address Addr)
PushDestructorCleanup - Push a cleanup to call the complete-object destructor of an object of the giv...
ASTContext & getContext() const
void pushDestroy(QualType::DestructionKind dtorKind, Address addr, QualType type)
pushDestroy - Push the standard destructor for the given type as at least a normal cleanup...
Encodes a location in the source.
CharUnits getPointerAlign() const
static DeclContext * castToDeclContext(const TranslationUnitDecl *D)
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
LValue EmitDeclRefLValue(const DeclRefExpr *E)
A saved depth on the scope stack.
llvm::StructType * StructureType
static void configureBlocksRuntimeObject(CodeGenModule &CGM, llvm::Constant *C)
Adjust the declaration of something from the blocks API.
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PL, ArrayRef< Expr * > IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
capture_const_iterator capture_end() const
const BlockByrefInfo & getBlockByrefInfo(const VarDecl *var)
BuildByrefInfo - This routine changes a __block variable declared as T x into:
A scoped helper to set the current debug location to the specified location or preferred location of ...
llvm::DenseMap< const VarDecl *, Capture > Captures
The mapping of allocated indexes within the block.
QualType fieldType() const
const CodeGenOptions & getCodeGenOpts() const
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
static bool isBlockPointer(Expr *Arg)
llvm::Constant * getBlockObjectDispose()
void PopCleanupBlocks(EHScopeStack::stable_iterator OldCleanupStackSize, std::initializer_list< llvm::Value ** > ValuesToReload={})
Takes the old cleanup stack size and emits the cleanup blocks that have been added.
void StartFunction(GlobalDecl GD, QualType RetTy, llvm::Function *Fn, const CGFunctionInfo &FnInfo, const FunctionArgList &Args, SourceLocation Loc=SourceLocation(), SourceLocation StartLoc=SourceLocation())
Emit code for the start of a function.
const LangOptions & getLangOpts() const
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
const T * castAs() const
Member-template castAs<specific type>.
static Destroyer emitARCIntrinsicUse
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
All available information about a concrete callee.
bool operator<(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
virtual bool needsDispose() const
unsigned CXXThisIndex
The field index of 'this' within the block, if there is one.
Assigning into this object requires a lifetime extension.
const BlockDecl * getBlockDecl() const
static Destroyer destroyARCStrongImprecise
void FinishFunction(SourceLocation EndLoc=SourceLocation())
FinishFunction - Complete IR generation of the current function.
const CGFunctionInfo & arrangeBlockFunctionCall(const CallArgList &args, const FunctionType *type)
A block function is essentially a free function with an extra implicit argument.
ConstantAddress GetAddrOfConstantCString(const std::string &Str, const char *GlobalName=nullptr)
Returns a pointer to a character array containing the literal and a terminating '\0' character...
llvm::Value * EmitScalarExpr(const Expr *E, bool IgnoreResultAssign=false)
EmitScalarExpr - Emit the computation of the specified expression of LLVM scalar type, returning the result.
FunctionArgList - Type for representing both the decl and type of parameters to a function...
static llvm::Constant * tryCaptureAsConstant(CodeGenModule &CGM, CodeGenFunction *CGF, const VarDecl *var)
It is illegal to modify a const object after initialization.
CGFunctionInfo - Class to encapsulate the information about a function definition.
This class organizes the cross-function state that is used while generating LLVM code.
virtual llvm::Constant * BuildGCBlockLayout(CodeGen::CodeGenModule &CGM, const CodeGen::CGBlockInfo &blockInfo)=0
Address LoadBlockStruct()
static void computeBlockInfo(CodeGenModule &CGM, CodeGenFunction *CGF, CGBlockInfo &info)
Compute the layout of the given block.
llvm::FoldingSet< BlockByrefHelpers > ByrefHelpersCache
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Address CreateStructGEP(Address Addr, unsigned Index, CharUnits Offset, const llvm::Twine &Name="")
llvm::LoadInst * CreateAlignedLoad(llvm::Value *Addr, CharUnits Align, const llvm::Twine &Name="")
llvm::Value * getConstant() const
static llvm::Constant * buildDisposeHelper(CodeGenModule &CGM, const CGBlockInfo &blockInfo)
Build the helper function to dispose of a block.
std::unique_ptr< DiagnosticConsumer > create(StringRef OutputFile, DiagnosticOptions *Diags, bool MergeChildRecords=false)
Returns a DiagnosticConsumer that serializes diagnostics to a bitcode file.
llvm::LoadInst * CreateLoad(Address Addr, const llvm::Twine &Name="")
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
int printf(__constant const char *st,...)
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
detail::InMemoryDirectory::const_iterator E
llvm::StoreInst * CreateStore(llvm::Value *Val, Address Addr, bool IsVolatile=false)
void EmitAggExpr(const Expr *E, AggValueSlot AS)
EmitAggExpr - Emit the computation of the specified expression of aggregate type. ...
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
llvm::DenseMap< const Decl *, Address > DeclMapTy
static void enterBlockScope(CodeGenFunction &CGF, BlockDecl *block)
Enter the scope of a block.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
const T * getAs() const
Member-template getAs<specific type>'.
StructBuilder beginStruct(llvm::StructType *structTy=nullptr)
CharUnits getIntAlign() const
CanQualType UnsignedLongTy
static llvm::Constant * buildByrefCopyHelper(CodeGenModule &CGM, const BlockByrefInfo &byrefInfo, BlockByrefHelpers &generator)
Build the copy helper for a __block variable.
llvm::PointerType * Int8PtrTy
Base for LValueReferenceType and RValueReferenceType.
void EmitSynthesizedCXXCopyCtor(Address Dest, Address Src, const Expr *Exp)
static CGBlockInfo * findAndRemoveBlockInfo(CGBlockInfo **head, const BlockDecl *block)
Find the layout for the given block in a linked list and remove it.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
virtual void emitDispose(CodeGenFunction &CGF, Address field)=0
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
llvm::Constant * getBlockObjectAssign()
llvm::Constant * EmitConstantInit(const VarDecl &D, CodeGenFunction *CGF=nullptr)
Try to emit the initializer for the given declaration as a constant; returns 0 if the expression cann...
char __ovld __cnfn max(char x, char y)
Returns y if x < y, otherwise it returns x.
const Decl * CurFuncDecl
CurFuncDecl - Holds the Decl for the current outermost non-closure context.
A pair of helper functions for a __block variable.
Reading or writing from this object requires a barrier call.
static void initializeForBlockHeader(CodeGenModule &CGM, CGBlockInfo &info, SmallVectorImpl< llvm::Type * > &elementTypes)
Represents a C++ struct/union/class.
CharUnits alignmentAtOffset(CharUnits offset) const
Given that this is a non-zero alignment value, what is the alignment at the given offset...
bool isObjCObjectPointerType() const
llvm::Type * ConvertType(QualType T)
uint32_t getBitMask() const
void setAddrOfGlobalBlock(const BlockExpr *BE, llvm::Constant *Addr)
Notes that BE's global block is available via Addr.
LValue MakeAddrLValue(Address Addr, QualType T, LValueBaseInfo BaseInfo=LValueBaseInfo(AlignmentSource::Type))
const BlockDecl * getBlockDecl() const
virtual ~BlockByrefHelpers()
CharUnits BlockHeaderForcedGapSize
llvm::Value * EmitARCRetainBlock(llvm::Value *value, bool mandatory)
Retain the given block, with _Block_copy semantics.
bool isNested() const
Whether this is a nested capture, i.e.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
TranslationUnitDecl - The top declaration context.
unsigned getTargetAddressSpace(QualType T) const
A reference to a declared variable, function, enum, etc.
static RValue get(llvm::Value *V)
RValue EmitBlockCallExpr(const CallExpr *E, ReturnValueSlot ReturnValue)
static ApplyDebugLocation CreateEmpty(CodeGenFunction &CGF)
Set the IRBuilder to not attach debug locations.
llvm::Constant * getNSConcreteGlobalBlock()
llvm::Type * getBlockDescriptorType()
Fetches the type of a generic block descriptor.
llvm::Constant * GetAddrOfGlobalBlock(const BlockExpr *BE, StringRef Name)
Gets the address of a block which requires no captures.
An l-value expression is a reference to an object with independent storage.
const BlockExpr * getBlockExpr() const
SourceLocation getLocation() const
Information for lazily generating a cleanup.
NamedDecl - This represents a decl with a name.
llvm::Instruction * DominatingIP
An instruction which dominates the full-expression that the block is inside.
unsigned long ulong
An unsigned 64-bit integer.
bool isConstQualified() const
Determine whether this type is const-qualified.
static bool isObjCNSObjectType(QualType Ty)
Return true if this is an NSObject object with its NSObject attribute set.
SourceLocation getLocStart() const LLVM_READONLY
CallArgList - Type for representing both the value and type of arguments in a call.
Address CreateMemTemp(QualType T, const Twine &Name="tmp", bool CastToDefaultAddrSpace=true)
CreateMemTemp - Create a temporary memory object of the given type, with appropriate alignment...
Address emitBlockByrefAddress(Address baseAddr, const VarDecl *V, bool followForward=true)
BuildBlockByrefAddress - Computes the location of the data in a variable which is declared as __block...
Abstract information about a function or function prototype.
bool BlockRequiresCopying(QualType Ty, const VarDecl *D)
Returns true iff we need copy/dispose helpers for the given type.
void BuildBlockRelease(llvm::Value *DeclPtr, BlockFieldFlags flags)
RValue EmitCall(const CGFunctionInfo &CallInfo, const CGCallee &Callee, ReturnValueSlot ReturnValue, const CallArgList &Args, llvm::Instruction **callOrInvoke=nullptr)
EmitCall - Generate a call of the given function, expecting the given result type, and using the given argument list which specifies both the LLVM arguments and the types they were derived from.
void setCleanup(EHScopeStack::stable_iterator cleanup)
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
void Destroyer(CodeGenFunction &CGF, Address addr, QualType ty)
unsigned char PointerSizeInBytes
llvm::FunctionType * GetFunctionType(const CGFunctionInfo &Info)
GetFunctionType - Get the LLVM function type for.