Lines Matching refs:CGM
52 static llvm::Constant *buildGlobalBlock(CodeGenModule &CGM,
57 static llvm::Constant *buildCopyHelper(CodeGenModule &CGM, in buildCopyHelper() argument
59 return CodeGenFunction(CGM).GenerateCopyHelperFunction(blockInfo); in buildCopyHelper()
63 static llvm::Constant *buildDisposeHelper(CodeGenModule &CGM, in buildDisposeHelper() argument
65 return CodeGenFunction(CGM).GenerateDestroyHelperFunction(blockInfo); in buildDisposeHelper()
84 CodeGenModule &CGM);
87 CodeGenModule &CGM) { in getBlockDescriptorName() argument
92 if (CGM.getLangOpts().Exceptions) in getBlockDescriptorName()
94 if (CGM.getCodeGenOpts().ObjCAutoRefCountExceptions) in getBlockDescriptorName()
110 BlockInfo.BlockAlign, CGM); in getBlockDescriptorName()
116 BlockInfo.BlockAlign, CGM); in getBlockDescriptorName()
118 BlockInfo.BlockAlign, CGM); in getBlockDescriptorName()
126 if (!CGM.getCodeGenOpts().DisableBlockSignatureString) { in getBlockDescriptorName()
128 CGM.getContext().getObjCEncodingForBlock(BlockInfo.getBlockExpr()); in getBlockDescriptorName()
134 Name += "l" + CGM.getObjCRuntime().getRCBlockLayoutStr(CGM, BlockInfo); in getBlockDescriptorName()
152 static llvm::Constant *buildBlockDescriptor(CodeGenModule &CGM, in buildBlockDescriptor() argument
154 ASTContext &C = CGM.getContext(); in buildBlockDescriptor()
157 cast<llvm::IntegerType>(CGM.getTypes().ConvertType(C.UnsignedLongTy)); in buildBlockDescriptor()
159 if (CGM.getLangOpts().OpenCL) in buildBlockDescriptor()
161 CGM.getLLVMContext(), C.getTargetAddressSpace(LangAS::opencl_constant)); in buildBlockDescriptor()
163 i8p = CGM.VoidPtrTy; in buildBlockDescriptor()
169 CGM.getLangOpts().getGC() == LangOptions::NonGC) { in buildBlockDescriptor()
170 descName = getBlockDescriptorName(blockInfo, CGM); in buildBlockDescriptor()
171 if (llvm::GlobalValue *desc = CGM.getModule().getNamedValue(descName)) in buildBlockDescriptor()
177 ConstantInitBuilder builder(CGM); in buildBlockDescriptor()
193 llvm::Constant *copyHelper = buildCopyHelper(CGM, blockInfo); in buildBlockDescriptor()
197 llvm::Constant *disposeHelper = buildDisposeHelper(CGM, blockInfo); in buildBlockDescriptor()
208 if (CGM.getCodeGenOpts().DisableBlockSignatureString) { in buildBlockDescriptor()
212 CGM.getContext().getObjCEncodingForBlock(blockInfo.getBlockExpr()); in buildBlockDescriptor()
213 elements.add(CGM.GetAddrOfConstantCString(typeAtEncoding).getPointer()); in buildBlockDescriptor()
218 if (CGM.getLangOpts().getGC() != LangOptions::NonGC) in buildBlockDescriptor()
219 elements.add(CGM.getObjCRuntime().BuildGCBlockLayout(CGM, blockInfo)); in buildBlockDescriptor()
221 elements.add(CGM.getObjCRuntime().BuildRCBlockLayout(CGM, blockInfo)); in buildBlockDescriptor()
243 elements.finishAndCreateGlobal(descName, CGM.getPointerAlign(), in buildBlockDescriptor()
247 if (CGM.supportsCOMDAT()) in buildBlockDescriptor()
248 global->setComdat(CGM.getModule().getOrInsertComdat(descName)); in buildBlockDescriptor()
393 CGBlockInfo &Info, CodeGenModule &CGM) { in addBlockLayout() argument
402 const LangOptions &LangOpts = CGM.getLangOpts(); in addBlockLayout()
446 static llvm::Constant *tryCaptureAsConstant(CodeGenModule &CGM, in tryCaptureAsConstant() argument
464 if (CGM.getLangOpts().CPlusPlus && !isSafeForCXXConstantCapture(type)) in tryCaptureAsConstant()
473 return ConstantEmitter(CGM, CGF).tryEmitAbstractForInitializer(*var); in tryCaptureAsConstant()
482 static void initializeForBlockHeader(CodeGenModule &CGM, CGBlockInfo &info, in initializeForBlockHeader() argument
486 if (CGM.getLangOpts().OpenCL) { in initializeForBlockHeader()
490 CGM.getTarget().getPointerAlign(LangAS::opencl_generic) / 8); in initializeForBlockHeader()
492 CGM.getTarget().getPointerWidth(LangAS::opencl_generic) / 8); in initializeForBlockHeader()
493 assert(CGM.getIntSize() <= GenPtrSize); in initializeForBlockHeader()
494 assert(CGM.getIntAlign() <= GenPtrAlign); in initializeForBlockHeader()
495 assert((2 * CGM.getIntSize()).isMultipleOf(GenPtrAlign)); in initializeForBlockHeader()
496 elementTypes.push_back(CGM.IntTy); /* total size */ in initializeForBlockHeader()
497 elementTypes.push_back(CGM.IntTy); /* align */ in initializeForBlockHeader()
499 CGM.getOpenCLRuntime() in initializeForBlockHeader()
502 2 * CGM.getIntSize().getQuantity() + GenPtrSize.getQuantity(); in initializeForBlockHeader()
505 CGM.getTargetCodeGenInfo().getTargetOpenCLBlockHelper()) { in initializeForBlockHeader()
509 unsigned Align = CGM.getDataLayout().getABITypeAlign(I).value(); in initializeForBlockHeader()
513 Offset += CGM.getDataLayout().getTypeAllocSize(I); in initializeForBlockHeader()
522 assert(CGM.getIntSize() <= CGM.getPointerSize()); in initializeForBlockHeader()
523 assert(CGM.getIntAlign() <= CGM.getPointerAlign()); in initializeForBlockHeader()
524 assert((2 * CGM.getIntSize()).isMultipleOf(CGM.getPointerAlign())); in initializeForBlockHeader()
525 info.BlockAlign = CGM.getPointerAlign(); in initializeForBlockHeader()
526 info.BlockSize = 3 * CGM.getPointerSize() + 2 * CGM.getIntSize(); in initializeForBlockHeader()
527 elementTypes.push_back(CGM.VoidPtrTy); in initializeForBlockHeader()
528 elementTypes.push_back(CGM.IntTy); in initializeForBlockHeader()
529 elementTypes.push_back(CGM.IntTy); in initializeForBlockHeader()
530 elementTypes.push_back(CGM.VoidPtrTy); in initializeForBlockHeader()
531 elementTypes.push_back(CGM.getBlockDescriptorType()); in initializeForBlockHeader()
554 static void computeBlockInfo(CodeGenModule &CGM, CodeGenFunction *CGF, in computeBlockInfo() argument
556 ASTContext &C = CGM.getContext(); in computeBlockInfo()
560 initializeForBlockHeader(CGM, info, elementTypes); in computeBlockInfo()
563 CGM.getTargetCodeGenInfo().getTargetOpenCLBlockHelper()) in computeBlockInfo()
568 llvm::StructType::get(CGM.getLLVMContext(), elementTypes, true); in computeBlockInfo()
573 CGM.getLangOpts().getGC() == LangOptions::NonGC) in computeBlockInfo()
594 llvm::Type *llvmType = CGM.getTypes().ConvertType(thisType); in computeBlockInfo()
595 auto TInfo = CGM.getContext().getTypeInfoInChars(thisType); in computeBlockInfo()
599 layout, info, CGM); in computeBlockInfo()
608 CharUnits align = CGM.getPointerAlign(); in computeBlockInfo()
615 addBlockLayout(align, CGM.getPointerSize(), &CI, CGM.VoidPtrTy, in computeBlockInfo()
616 variable->getType(), layout, info, CGM); in computeBlockInfo()
622 if (llvm::Constant *constant = tryCaptureAsConstant(CGM, CGF, variable)) { in computeBlockInfo()
630 if (CGM.getLangOpts().CPlusPlus) in computeBlockInfo()
644 CGM.getTypes().ConvertTypeForMem(VT); in computeBlockInfo()
646 addBlockLayout(align, size, &CI, llvmType, VT, layout, info, CGM); in computeBlockInfo()
652 llvm::StructType::get(CGM.getLLVMContext(), elementTypes, true); in computeBlockInfo()
731 elementTypes.push_back(llvm::ArrayType::get(CGM.Int8Ty, in computeBlockInfo()
749 elementTypes.push_back(llvm::ArrayType::get(CGM.Int8Ty, in computeBlockInfo()
763 llvm::StructType::get(CGM.getLLVMContext(), elementTypes, true); in computeBlockInfo()
773 if (llvm::Constant *Block = CGM.getAddrOfGlobalBlockIfEmitted(blockExpr)) in EmitBlockLiteral()
777 computeBlockInfo(CGM, this, blockInfo); in EmitBlockLiteral()
786 bool IsOpenCL = CGM.getContext().getLangOpts().OpenCL; in EmitBlockLiteral()
788 IsOpenCL ? CGM.getOpenCLRuntime().getGenericVoidPointerType() : VoidPtrTy; in EmitBlockLiteral()
791 CGM.getTarget().getPointerWidth(GenVoidPtrAddr) / 8); in EmitBlockLiteral()
794 CodeGenFunction BlockCGF{CGM, true}; in EmitBlockLiteral()
802 return CGM.getAddrOfGlobalBlockIfEmitted(blockInfo.BlockExpression); in EmitBlockLiteral()
817 ? CGM.getNSConcreteGlobalBlock() in EmitBlockLiteral()
818 : CGM.getNSConcreteStackBlock(); in EmitBlockLiteral()
822 descriptor = buildBlockDescriptor(CGM, blockInfo); in EmitBlockLiteral()
825 if (!CGM.getCodeGenOpts().DisableBlockSignatureString) in EmitBlockLiteral()
876 CGM.getTargetCodeGenInfo().getTargetOpenCLBlockHelper()) { in EmitBlockLiteral()
881 CGM.getDataLayout().getTypeAllocSize(I.first->getType())), in EmitBlockLiteral()
980 CGM.getCodeGenOpts().OptimizationLevel != 0) { in EmitBlockLiteral()
1047 CGM.getCodeGenOpts().OptimizationLevel != 0) { in EmitBlockLiteral()
1048 assert(CGM.getLangOpts().ObjCAutoRefCount && in EmitBlockLiteral()
1089 CGM.getOpenCLRuntime().recordBlockInfo(blockInfo.BlockExpression, InvokeFn, in EmitBlockLiteral()
1169 llvm::Type *GenBlockTy = CGM.getGenericBlockLiteralType(); in EmitBlockCallExpr()
1181 CGM.getOpenCLRuntime().getGenericVoidPointerType(); in EmitBlockCallExpr()
1192 Func = CGM.getOpenCLRuntime().getInvokeFunction(E->getCallee()); in EmitBlockCallExpr()
1217 CGM.getTypes().arrangeBlockFunctionCall(Args, FuncTy); in EmitBlockCallExpr()
1288 static llvm::Constant *buildGlobalBlock(CodeGenModule &CGM, in buildGlobalBlock() argument
1295 assert(!CGM.getAddrOfGlobalBlockIfEmitted(blockInfo.BlockExpression) && in buildGlobalBlock()
1299 ConstantInitBuilder builder(CGM); in buildGlobalBlock()
1302 bool IsOpenCL = CGM.getLangOpts().OpenCL; in buildGlobalBlock()
1303 bool IsWindows = CGM.getTarget().getTriple().isOSWindows(); in buildGlobalBlock()
1307 fields.addNullPointer(CGM.Int8PtrPtrTy); in buildGlobalBlock()
1309 fields.add(CGM.getNSConcreteGlobalBlock()); in buildGlobalBlock()
1313 if (!CGM.getCodeGenOpts().DisableBlockSignatureString) in buildGlobalBlock()
1318 fields.addInt(CGM.IntTy, flags.getBitMask()); in buildGlobalBlock()
1321 fields.addInt(CGM.IntTy, 0); in buildGlobalBlock()
1323 fields.addInt(CGM.IntTy, blockInfo.BlockSize.getQuantity()); in buildGlobalBlock()
1324 fields.addInt(CGM.IntTy, blockInfo.BlockAlign.getQuantity()); in buildGlobalBlock()
1332 fields.add(buildBlockDescriptor(CGM, blockInfo)); in buildGlobalBlock()
1334 CGM.getTargetCodeGenInfo().getTargetOpenCLBlockHelper()) { in buildGlobalBlock()
1335 for (auto *I : Helper->getCustomFieldValues(CGM, blockInfo)) { in buildGlobalBlock()
1341 if (CGM.getContext().getLangOpts().OpenCL) in buildGlobalBlock()
1342 AddrSpace = CGM.getContext().getTargetAddressSpace(LangAS::opencl_global); in buildGlobalBlock()
1353 auto *Init = llvm::Function::Create(llvm::FunctionType::get(CGM.VoidTy, in buildGlobalBlock()
1355 &CGM.getModule()); in buildGlobalBlock()
1356 llvm::IRBuilder<> b(llvm::BasicBlock::Create(CGM.getLLVMContext(), "entry", in buildGlobalBlock()
1358 b.CreateAlignedStore(CGM.getNSConcreteGlobalBlock(), in buildGlobalBlock()
1360 CGM.getPointerAlign().getAsAlign()); in buildGlobalBlock()
1364 auto *InitVar = new llvm::GlobalVariable(CGM.getModule(), Init->getType(), in buildGlobalBlock()
1368 CGM.addUsedGlobal(InitVar); in buildGlobalBlock()
1373 CGM.getTypes().ConvertType(blockInfo.getBlockExpr()->getType()); in buildGlobalBlock()
1376 CGM.setAddrOfGlobalBlock(blockInfo.BlockExpression, Result); in buildGlobalBlock()
1377 if (CGM.getContext().getLangOpts().OpenCL) in buildGlobalBlock()
1378 CGM.getOpenCLRuntime().recordBlockInfo( in buildGlobalBlock()
1395 if (CGM.getCodeGenOpts().hasReducedDebugInfo()) { in setBlockContextParameter()
1461 const IdentifierInfo *II = &CGM.getContext().Idents.get(".block_descriptor"); in GenerateBlockFunction()
1474 CGM.getTypes().arrangeBlockFunctionDeclaration(fnType, args); in GenerateBlockFunction()
1475 if (CGM.ReturnSlotInterferesWithArgs(fnInfo)) in GenerateBlockFunction()
1478 llvm::FunctionType *fnLLVMType = CGM.getTypes().GetFunctionType(fnInfo); in GenerateBlockFunction()
1480 StringRef name = CGM.getBlockMangledName(GD, blockDecl); in GenerateBlockFunction()
1482 fnLLVMType, llvm::GlobalValue::InternalLinkage, name, &CGM.getModule()); in GenerateBlockFunction()
1483 CGM.SetInternalFunctionAttributes(blockDecl, fn, fnInfo); in GenerateBlockFunction()
1487 ? CGM.getOpenCLRuntime().getGenericVoidPointerType() in GenerateBlockFunction()
1489 buildGlobalBlock(CGM, blockInfo, in GenerateBlockFunction()
1503 if (CGM.getCodeGenOpts().OptimizationLevel == 0) { in GenerateBlockFunction()
1568 if (CGM.getCodeGenOpts().hasReducedDebugInfo()) { in GenerateBlockFunction()
1697 CodeGenModule &CGM) { in getBlockCaptureStr() argument
1699 ASTContext &Ctx = CGM.getContext(); in getBlockCaptureStr()
1726 CGM.getCXXABI().getMangleContext().mangleCanonicalTypeName(CaptureTy, Out); in getBlockCaptureStr()
1792 CharUnits BlockAlignment, CaptureStrKind StrKind, CodeGenModule &CGM) { in getCopyDestroyHelperFuncName() argument
1799 if (CGM.getLangOpts().Exceptions) in getCopyDestroyHelperFuncName()
1801 if (CGM.getCodeGenOpts().ObjCAutoRefCountExceptions) in getCopyDestroyHelperFuncName()
1809 Name += getBlockCaptureStr(Cap, StrKind, BlockAlignment, CGM); in getCopyDestroyHelperFuncName()
1860 CodeGenModule &CGM) { in setBlockHelperAttributesVisibility() argument
1862 CGM.SetInternalFunctionAttributes(GlobalDecl(), Fn, FI); in setBlockHelperAttributesVisibility()
1866 CGM.SetLLVMFunctionAttributes(GlobalDecl(), FI, Fn, /*IsThunk=*/false); in setBlockHelperAttributesVisibility()
1867 CGM.SetLLVMFunctionAttributesForDefinition(nullptr, Fn); in setBlockHelperAttributesVisibility()
1882 CaptureStrKind::CopyHelper, CGM); in GenerateCopyHelperFunction()
1884 if (llvm::GlobalValue *Func = CGM.getModule().getNamedValue(FuncName)) in GenerateCopyHelperFunction()
1898 CGM.getTypes().arrangeBuiltinFunctionDeclaration(ReturnTy, args); in GenerateCopyHelperFunction()
1902 llvm::FunctionType *LTy = CGM.getTypes().GetFunctionType(FI); in GenerateCopyHelperFunction()
1906 FuncName, &CGM.getModule()); in GenerateCopyHelperFunction()
1907 if (CGM.supportsCOMDAT()) in GenerateCopyHelperFunction()
1908 Fn->setComdat(CGM.getModule().getOrInsertComdat(FuncName)); in GenerateCopyHelperFunction()
1915 CGM); in GenerateCopyHelperFunction()
1961 if (CGM.getCodeGenOpts().OptimizationLevel == 0) { in GenerateCopyHelperFunction()
1991 EmitRuntimeCallOrInvoke(CGM.getBlockObjectAssign(), args); in GenerateCopyHelperFunction()
1993 EmitNounwindRuntimeCall(CGM.getBlockObjectAssign(), args); in GenerateCopyHelperFunction()
2071 CaptureStrKind::DisposeHelper, CGM); in GenerateDestroyHelperFunction()
2073 if (llvm::GlobalValue *Func = CGM.getModule().getNamedValue(FuncName)) in GenerateDestroyHelperFunction()
2085 CGM.getTypes().arrangeBuiltinFunctionDeclaration(ReturnTy, args); in GenerateDestroyHelperFunction()
2089 llvm::FunctionType *LTy = CGM.getTypes().GetFunctionType(FI); in GenerateDestroyHelperFunction()
2093 FuncName, &CGM.getModule()); in GenerateDestroyHelperFunction()
2094 if (CGM.supportsCOMDAT()) in GenerateDestroyHelperFunction()
2095 Fn->setComdat(CGM.getModule().getOrInsertComdat(FuncName)); in GenerateDestroyHelperFunction()
2101 CGM); in GenerateDestroyHelperFunction()
2154 llvm::FunctionCallee fn = CGF.CGM.getBlockObjectAssign(); in emitCopy()
2208 if (CGF.CGM.getCodeGenOpts().OptimizationLevel == 0) { in emitCopy()
2330 CGF.CGM.getTypes().arrangeBuiltinFunctionDeclaration(ReturnTy, args); in generateByrefCopyHelper()
2332 llvm::FunctionType *LTy = CGF.CGM.getTypes().GetFunctionType(FI); in generateByrefCopyHelper()
2338 "__Block_byref_object_copy_", &CGF.CGM.getModule()); in generateByrefCopyHelper()
2344 CGF.CGM.SetInternalFunctionAttributes(GlobalDecl(), Fn, FI); in generateByrefCopyHelper()
2374 static llvm::Constant *buildByrefCopyHelper(CodeGenModule &CGM, in buildByrefCopyHelper() argument
2377 CodeGenFunction CGF(CGM); in buildByrefCopyHelper()
2395 CGF.CGM.getTypes().arrangeBuiltinFunctionDeclaration(R, args); in generateByrefDisposeHelper()
2397 llvm::FunctionType *LTy = CGF.CGM.getTypes().GetFunctionType(FI); in generateByrefDisposeHelper()
2404 &CGF.CGM.getModule()); in generateByrefDisposeHelper()
2409 CGF.CGM.SetInternalFunctionAttributes(GlobalDecl(), Fn, FI); in generateByrefDisposeHelper()
2430 static llvm::Constant *buildByrefDisposeHelper(CodeGenModule &CGM, in buildByrefDisposeHelper() argument
2433 CodeGenFunction CGF(CGM); in buildByrefDisposeHelper()
2440 static T *buildByrefHelpers(CodeGenModule &CGM, const BlockByrefInfo &byrefInfo, in buildByrefHelpers() argument
2447 = CGM.ByrefHelpersCache.FindNodeOrInsertPos(id, insertPos); in buildByrefHelpers()
2450 generator.CopyHelper = buildByrefCopyHelper(CGM, byrefInfo, generator); in buildByrefHelpers()
2451 generator.DisposeHelper = buildByrefDisposeHelper(CGM, byrefInfo, generator); in buildByrefHelpers()
2453 T *copy = new (CGM.getContext()) T(std::forward<T>(generator)); in buildByrefHelpers()
2454 CGM.ByrefHelpersCache.InsertNode(copy, insertPos); in buildByrefHelpers()
2479 CGM.getContext().getBlockVarCopyInit(&var).getCopyExpr(); in buildByrefHelpers()
2483 CGM, byrefInfo, CXXByrefHelpers(valueAlignment, type, copyExpr)); in buildByrefHelpers()
2491 CGM, byrefInfo, NonTrivialCStructByrefHelpers(valueAlignment, type)); in buildByrefHelpers()
2512 return ::buildByrefHelpers(CGM, byrefInfo, in buildByrefHelpers()
2520 return ::buildByrefHelpers(CGM, byrefInfo, in buildByrefHelpers()
2526 return ::buildByrefHelpers(CGM, byrefInfo, in buildByrefHelpers()
2536 } else if (CGM.getContext().isObjCNSObjectType(type) || in buildByrefHelpers()
2546 return ::buildByrefHelpers(CGM, byrefInfo, in buildByrefHelpers()
2653 } else if (CGM.getDataLayout().getABITypeAlign(varTy) > in getBlockByrefInfo()
2740 if (CGM.getLangOpts().ObjCGCBitmapPrint) { in emitByrefStructureInit()
2763 CharUnits byrefSize = CGM.GetTargetTypeStoreSize(byrefType); in emitByrefStructureInit()
2775 auto layoutInfo = CGM.getObjCRuntime().BuildByrefLayout(CGM, type); in emitByrefStructureInit()
2782 llvm::FunctionCallee F = CGM.getBlockObjectDispose(); in BuildBlockRelease()
2800 static void configureBlocksRuntimeObject(CodeGenModule &CGM, in configureBlocksRuntimeObject() argument
2804 if (CGM.getTarget().getTriple().isOSBinFormatCOFF()) { in configureBlocksRuntimeObject()
2805 const IdentifierInfo &II = CGM.getContext().Idents.get(C->getName()); in configureBlocksRuntimeObject()
2806 TranslationUnitDecl *TUDecl = CGM.getContext().getTranslationUnitDecl(); in configureBlocksRuntimeObject()
2829 if (CGM.getLangOpts().BlocksRuntimeOptional && GV->isDeclaration() && in configureBlocksRuntimeObject()
2833 CGM.setDSOLocal(GV); in configureBlocksRuntimeObject()