33 #include "llvm/IR/DataLayout.h" 34 #include "llvm/IR/GlobalVariable.h" 35 #include "llvm/IR/Intrinsics.h" 36 #include "llvm/IR/Type.h" 38 using namespace clang;
39 using namespace CodeGen;
43 case Decl::BuiltinTemplate:
44 case Decl::TranslationUnit:
45 case Decl::ExternCContext:
47 case Decl::UnresolvedUsingTypename:
48 case Decl::ClassTemplateSpecialization:
49 case Decl::ClassTemplatePartialSpecialization:
50 case Decl::VarTemplateSpecialization:
51 case Decl::VarTemplatePartialSpecialization:
52 case Decl::TemplateTypeParm:
53 case Decl::UnresolvedUsingValue:
54 case Decl::NonTypeTemplateParm:
55 case Decl::CXXDeductionGuide:
57 case Decl::CXXConstructor:
58 case Decl::CXXDestructor:
59 case Decl::CXXConversion:
61 case Decl::MSProperty:
62 case Decl::IndirectField:
64 case Decl::ObjCAtDefsField:
66 case Decl::ImplicitParam:
67 case Decl::ClassTemplate:
68 case Decl::VarTemplate:
69 case Decl::FunctionTemplate:
70 case Decl::TypeAliasTemplate:
71 case Decl::TemplateTemplateParm:
72 case Decl::ObjCMethod:
73 case Decl::ObjCCategory:
74 case Decl::ObjCProtocol:
75 case Decl::ObjCInterface:
76 case Decl::ObjCCategoryImpl:
77 case Decl::ObjCImplementation:
78 case Decl::ObjCProperty:
79 case Decl::ObjCCompatibleAlias:
80 case Decl::PragmaComment:
81 case Decl::PragmaDetectMismatch:
82 case Decl::AccessSpec:
83 case Decl::LinkageSpec:
85 case Decl::ObjCPropertyImpl:
86 case Decl::FileScopeAsm:
88 case Decl::FriendTemplate:
91 case Decl::ClassScopeFunctionSpecialization:
92 case Decl::UsingShadow:
93 case Decl::ConstructorUsingShadow:
94 case Decl::ObjCTypeParam:
96 llvm_unreachable(
"Declaration should not be in declstmts!");
100 case Decl::EnumConstant:
101 case Decl::CXXRecord:
102 case Decl::StaticAssert:
105 case Decl::OMPThreadPrivate:
106 case Decl::OMPCapturedExpr:
111 case Decl::NamespaceAlias:
113 DI->EmitNamespaceAlias(cast<NamespaceAliasDecl>(D));
117 DI->EmitUsingDecl(cast<UsingDecl>(D));
119 case Decl::UsingPack:
120 for (
auto *Using : cast<UsingPackDecl>(D).expansions())
123 case Decl::UsingDirective:
125 DI->EmitUsingDirective(cast<UsingDirectiveDecl>(D));
128 case Decl::Decomposition: {
129 const VarDecl &VD = cast<VarDecl>(D);
131 "Should not see file-scope variables inside a function!");
133 if (
auto *DD = dyn_cast<DecompositionDecl>(&VD))
134 for (
auto *B : DD->bindings())
135 if (
auto *HD = B->getHoldingVar())
140 case Decl::OMPDeclareReduction:
144 case Decl::TypeAlias: {
148 if (Ty->isVariablyModifiedType())
169 llvm::GlobalValue::LinkageTypes
Linkage =
192 std::string ContextName;
194 if (
auto *CD = dyn_cast<CapturedDecl>(DC))
195 DC = cast<DeclContext>(CD->getNonClosureContext());
196 if (
const auto *FD = dyn_cast<FunctionDecl>(DC))
198 else if (
const auto *BD = dyn_cast<BlockDecl>(DC))
200 else if (
const auto *OMD = dyn_cast<ObjCMethodDecl>(DC))
201 ContextName = OMD->getSelector().getAsString();
203 llvm_unreachable(
"Unknown context for static var decl");
215 if (llvm::Constant *ExistingGV = StaticLocalDeclMap[&D])
223 if (D.hasAttr<AsmLabelAttr>())
224 Name = getMangledName(&D);
229 LangAS AS = GetGlobalVarAddressSpace(&D);
234 llvm::Constant *Init =
nullptr;
236 D.hasAttr<CUDASharedAttr>())
237 Init = llvm::UndefValue::get(LTy);
241 llvm::GlobalVariable *GV =
new llvm::GlobalVariable(
243 nullptr, llvm::GlobalVariable::NotThreadLocal, TargetAS);
246 if (supportsCOMDAT() && GV->isWeakForLinker())
247 GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));
252 setGVProperties(GV, &D);
256 llvm::Constant *Addr = GV;
257 if (AS != ExpectedAS) {
258 Addr = getTargetCodeGenInfo().performAddrSpaceCast(
259 *
this, GV, AS, ExpectedAS,
260 LTy->getPointerTo(
getContext().getTargetAddressSpace(ExpectedAS)));
263 setStaticLocalDeclAddress(&D, Addr);
267 const Decl *DC = cast<Decl>(D.getDeclContext());
271 if (isa<BlockDecl>(DC) || isa<CapturedDecl>(DC)) {
279 if (
const auto *CD = dyn_cast<CXXConstructorDecl>(DC))
281 else if (
const auto *DD = dyn_cast<CXXDestructorDecl>(DC))
283 else if (
const auto *FD = dyn_cast<FunctionDecl>(DC))
288 assert(isa<ObjCMethodDecl>(DC) &&
"unexpected parent code decl");
293 (void)GetAddrOfGlobal(GD);
311 llvm::GlobalVariable *
313 llvm::GlobalVariable *GV) {
325 GV->setConstant(
false);
336 if (GV->getType()->getElementType() != Init->getType()) {
337 llvm::GlobalVariable *OldGV = GV;
339 GV =
new llvm::GlobalVariable(
CGM.
getModule(), Init->getType(),
341 OldGV->getLinkage(), Init,
"",
343 OldGV->getThreadLocalMode(),
345 GV->setVisibility(OldGV->getVisibility());
346 GV->setDSOLocal(OldGV->isDSOLocal());
347 GV->setComdat(OldGV->getComdat());
353 llvm::Constant *NewPtrForOldDecl =
354 llvm::ConstantExpr::getBitCast(GV, OldGV->getType());
355 OldGV->replaceAllUsesWith(NewPtrForOldDecl);
358 OldGV->eraseFromParent();
362 GV->setInitializer(Init);
377 llvm::GlobalValue::LinkageTypes
Linkage) {
386 setAddrOfLocalVar(&D,
Address(addr, alignment));
397 llvm::GlobalVariable *var =
398 cast<llvm::GlobalVariable>(addr->stripPointerCasts());
407 if (D.
getInit() && !isCudaSharedVar)
415 if (
auto *SA = D.
getAttr<PragmaClangBSSSectionAttr>())
416 var->addAttribute(
"bss-section", SA->getName());
417 if (
auto *SA = D.
getAttr<PragmaClangDataSectionAttr>())
418 var->addAttribute(
"data-section", SA->getName());
419 if (
auto *SA = D.
getAttr<PragmaClangRodataSectionAttr>())
420 var->addAttribute(
"rodata-section", SA->getName());
422 if (
const SectionAttr *SA = D.
getAttr<SectionAttr>())
423 var->setSection(SA->getName());
433 llvm::Constant *castedAddr =
434 llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(var, expectedType);
435 if (var != castedAddr)
436 LocalDeclMap.find(&D)->second =
Address(castedAddr, alignment);
454 bool useEHCleanupForArray)
455 : addr(addr),
type(type), destroyer(destroyer),
456 useEHCleanupForArray(useEHCleanupForArray) {}
461 bool useEHCleanupForArray;
465 bool useEHCleanupForArray =
466 flags.isForNormalCleanup() && this->useEHCleanupForArray;
468 CGF.
emitDestroy(addr, type, destroyer, useEHCleanupForArray);
472 template <
class Derived>
475 : NRVOFlag(NRVOFlag), Loc(addr) {}
482 bool NRVO = flags.isForNormalCleanup() && NRVOFlag;
484 llvm::BasicBlock *SkipDtorBB =
nullptr;
491 CGF.
Builder.CreateCondBr(DidNRVO, SkipDtorBB, RunDtorBB);
495 static_cast<Derived *
>(
this)->emitDestructorCall(CGF);
500 virtual ~DestroyNRVOVariable() =
default;
503 struct DestroyNRVOVariableCXX final
504 : DestroyNRVOVariable<DestroyNRVOVariableCXX> {
507 : DestroyNRVOVariable<DestroyNRVOVariableCXX>(addr, NRVOFlag),
519 struct DestroyNRVOVariableC final
520 : DestroyNRVOVariable<DestroyNRVOVariableC> {
522 : DestroyNRVOVariable<DestroyNRVOVariableC>(addr, NRVOFlag), Ty(Ty) {}
533 CallStackRestore(
Address Stack) : Stack(Stack) {}
543 ExtendGCLifetime(
const VarDecl *var) : Var(*var) {}
557 llvm::Constant *CleanupFn;
561 CallCleanupFunction(llvm::Constant *CleanupFn,
const CGFunctionInfo *Info,
563 : CleanupFn(CleanupFn), FnInfo(*Info), Var(*Var) {}
598 llvm_unreachable(
"present but none");
606 (var.
hasAttr<ObjCPreciseLifetimeAttr>()
630 if (
const Expr *e = dyn_cast<Expr>(s)) {
633 s = e = e->IgnoreParenCasts();
635 if (
const DeclRefExpr *ref = dyn_cast<DeclRefExpr>(e))
636 return (ref->getDecl() == &var);
637 if (
const BlockExpr *be = dyn_cast<BlockExpr>(e)) {
638 const BlockDecl *block = be->getBlockDecl();
639 for (
const auto &I : block->
captures()) {
640 if (I.getVariable() == &var)
655 if (!decl)
return false;
656 if (!isa<VarDecl>(decl))
return false;
663 bool needsCast =
false;
670 case CK_BlockPointerToObjCPointerCast:
676 case CK_LValueToRValue: {
719 if (!
SanOpts.
has(SanitizerKind::NullabilityAssign))
730 llvm::Constant *StaticData[] = {
732 llvm::ConstantInt::get(
Int8Ty, 0),
734 EmitCheck({{IsNotNull, SanitizerKind::NullabilityAssign}},
735 SanitizerHandler::TypeMismatch, StaticData, RHS);
739 LValue lvalue,
bool capturedByInit) {
751 init = DIE->getExpr();
757 init = ewc->getSubExpr();
765 bool accessedByInit =
false;
767 accessedByInit = (capturedByInit ||
isAccessedBy(D, init));
768 if (accessedByInit) {
771 if (capturedByInit) {
796 llvm_unreachable(
"present but none");
854 if (isa<llvm::ConstantAggregateZero>(Init) ||
855 isa<llvm::ConstantPointerNull>(Init) ||
856 isa<llvm::UndefValue>(Init))
858 if (isa<llvm::ConstantInt>(Init) || isa<llvm::ConstantFP>(Init) ||
859 isa<llvm::ConstantVector>(Init) || isa<llvm::BlockAddress>(Init) ||
860 isa<llvm::ConstantExpr>(Init))
861 return Init->isNullValue() || NumStores--;
864 if (isa<llvm::ConstantArray>(Init) || isa<llvm::ConstantStruct>(Init)) {
865 for (
unsigned i = 0, e = Init->getNumOperands(); i != e; ++i) {
866 llvm::Constant *Elt = cast<llvm::Constant>(Init->getOperand(i));
873 if (llvm::ConstantDataSequential *CDS =
874 dyn_cast<llvm::ConstantDataSequential>(Init)) {
875 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
876 llvm::Constant *Elt = CDS->getElementAsConstant(i);
890 llvm::Constant *Init,
Address Loc,
892 assert(!Init->isNullValue() && !isa<llvm::UndefValue>(Init) &&
893 "called emitStoresForInitAfterBZero for zero or undef value.");
895 if (isa<llvm::ConstantInt>(Init) || isa<llvm::ConstantFP>(Init) ||
896 isa<llvm::ConstantVector>(Init) || isa<llvm::BlockAddress>(Init) ||
897 isa<llvm::ConstantExpr>(Init)) {
902 if (llvm::ConstantDataSequential *CDS =
903 dyn_cast<llvm::ConstantDataSequential>(Init)) {
904 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
905 llvm::Constant *Elt = CDS->getElementAsConstant(i);
908 if (!Elt->isNullValue() && !isa<llvm::UndefValue>(Elt))
912 isVolatile, Builder);
917 assert((isa<llvm::ConstantStruct>(Init) || isa<llvm::ConstantArray>(Init)) &&
918 "Unknown value type!");
920 for (
unsigned i = 0, e = Init->getNumOperands(); i != e; ++i) {
921 llvm::Constant *Elt = cast<llvm::Constant>(Init->getOperand(i));
924 if (!Elt->isNullValue() && !isa<llvm::UndefValue>(Elt))
928 isVolatile, Builder);
936 uint64_t GlobalSize) {
938 if (isa<llvm::ConstantAggregateZero>(Init))
return true;
944 unsigned StoreBudget = 6;
945 uint64_t SizeLimit = 32;
947 return GlobalSize > SizeLimit &&
957 enum class ValueType : uint8_t { Specific, Any, None }
Type;
964 bool isAny()
const {
return Type == ValueType::Any; }
966 bool isValued()
const {
return Type == ValueType::Specific; }
972 if (isNone() || Other.
isNone())
986 if (isa<llvm::ConstantAggregateZero>(C) || isa<llvm::ConstantPointerNull>(C))
988 if (isa<llvm::UndefValue>(C))
991 if (isa<llvm::ConstantInt>(C)) {
992 auto *Int = cast<llvm::ConstantInt>(C);
993 if (Int->getBitWidth() % 8 != 0)
996 if (Value.isSplat(8))
997 return BytePattern(Value.getLoBits(8).getLimitedValue());
1001 if (isa<llvm::ConstantFP>(C)) {
1002 auto *FP = cast<llvm::ConstantFP>(C);
1003 llvm::APInt Bits = FP->getValueAPF().bitcastToAPInt();
1004 if (Bits.getBitWidth() % 8 != 0)
1006 if (!Bits.isSplat(8))
1008 return BytePattern(Bits.getLimitedValue() & 0xFF);
1011 if (isa<llvm::ConstantVector>(C)) {
1012 llvm::Constant *Splat = cast<llvm::ConstantVector>(C)->getSplatValue();
1018 if (isa<llvm::ConstantArray>(C) || isa<llvm::ConstantStruct>(C)) {
1020 for (
unsigned I = 0, E = C->getNumOperands(); I != E; ++I) {
1021 llvm::Constant *Elt = cast<llvm::Constant>(C->getOperand(I));
1023 if (Pattern.isNone())
1029 if (llvm::ConstantDataSequential *CDS =
1030 dyn_cast<llvm::ConstantDataSequential>(C)) {
1032 for (
unsigned I = 0, E = CDS->getNumElements(); I != E; ++I) {
1033 llvm::Constant *Elt = CDS->getElementAsConstant(I);
1051 uint64_t GlobalSize) {
1052 uint64_t SizeLimit = 32;
1053 if (GlobalSize <= SizeLimit)
1072 if (!ShouldEmitLifetimeMarkers)
1075 assert(Addr->getType()->getPointerAddressSpace() ==
1077 "Pointer should be in alloca address space");
1082 C->setDoesNotThrow();
1087 assert(Addr->getType()->getPointerAddressSpace() ==
1089 "Pointer should be in alloca address space");
1093 C->setDoesNotThrow();
1104 while (
getContext().getAsVariableArrayType(Type1D)) {
1106 if (
auto *C = dyn_cast<llvm::ConstantInt>(VlaSize.NumElts))
1110 VlaSize.NumElts->getType(),
"__vla_expr");
1112 Dimensions.emplace_back(SizeExprAddr.getPointer(),
1115 Type1D = VlaSize.Type;
1124 for (
auto &VlaSize : Dimensions) {
1126 if (
auto *C = dyn_cast<llvm::ConstantInt>(VlaSize.NumElts))
1127 MD = llvm::ConstantAsMetadata::get(C);
1131 cast<llvm::AllocaInst>(VlaSize.NumElts)->getName());
1132 auto VlaExprTy = VlaSize.NumElts->getType()->getPointerElementType();
1134 VlaExprTy->getScalarSizeInBits(),
false);
1144 assert(MD &&
"No Size expression debug node created");
1160 bool isByRef = D.
hasAttr<BlocksAttr>();
1161 emission.IsByRef = isByRef;
1206 assert(emission.wasEmittedAsGlobal());
1211 emission.IsConstantAggregate =
true;
1224 address = OpenMPLocalAddr;
1232 const auto *RD = RecordTy->getDecl();
1234 if ((CXXRD && !CXXRD->hasTrivialDestructor()) ||
1235 RD->isNonTrivialToPrimitiveDestroy()) {
1255 allocaTy = byrefInfo.Type;
1256 allocaAlignment = byrefInfo.ByrefAlignment;
1259 allocaAlignment = alignment;
1266 nullptr, &AllocaAddr);
1271 bool IsMSCatchParam =
1293 emission.SizeForLifetimeMarkers =
1303 if (!DidCallStackSave) {
1312 DidCallStackSave =
true;
1332 setAddrOfLocalVar(&D, address);
1333 emission.Addr = address;
1334 emission.AllocaAddr = AllocaAddr;
1342 if (D.
hasAttr<AnnotateAttr>())
1359 if (
const Expr *E = dyn_cast<Expr>(S))
1374 if (
const BlockExpr *BE = dyn_cast<BlockExpr>(E)) {
1375 const BlockDecl *Block = BE->getBlockDecl();
1376 for (
const auto &I : Block->
captures()) {
1377 if (I.getVariable() == &Var)
1385 if (
const StmtExpr *SE = dyn_cast<StmtExpr>(E)) {
1387 for (
const auto *BI : CS->
body())
1388 if (
const auto *BIE = dyn_cast<Expr>(BI)) {
1392 else if (
const auto *DS = dyn_cast<DeclStmt>(BI)) {
1394 for (
const auto *I : DS->decls()) {
1395 if (
const auto *VD = dyn_cast<VarDecl>((I))) {
1396 const Expr *Init = VD->getInit();
1424 if (Constructor->isTrivial() &&
1425 Constructor->isDefaultConstructor() &&
1426 !Construct->requiresZeroInitialization())
1433 assert(emission.Variable &&
"emission was not valid!");
1436 if (emission.wasEmittedAsGlobal())
return;
1438 const VarDecl &D = *emission.Variable;
1453 if (emission.IsByRef)
1460 type.isNonTrivialToPrimitiveDefaultInitialize() ==
1463 if (emission.IsByRef)
1475 bool capturedByInit = emission.IsByRef &&
isCapturedBy(D, Init);
1480 llvm::Constant *constant =
nullptr;
1481 if (emission.IsConstantAggregate || D.
isConstexpr()) {
1482 assert(!capturedByInit &&
"constant init contains a capturing block?");
1492 if (!emission.IsConstantAggregate) {
1501 bool isVolatile = type.isVolatileQualified();
1505 getContext().getTypeSizeInChars(type).getQuantity());
1513 uint64_t ConstantSize =
1519 if (!constant->isNullValue() && !isa<llvm::UndefValue>(constant)) {
1542 llvm::GlobalVariable *GV =
new llvm::GlobalVariable(
1544 llvm::GlobalValue::PrivateLinkage, constant, Name,
nullptr,
1545 llvm::GlobalValue::NotThreadLocal, AS);
1547 GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
1569 LValue lvalue,
bool capturedByInit) {
1595 if (isa<VarDecl>(D))
1597 else if (
auto *FD = dyn_cast<FieldDecl>(D))
1608 llvm_unreachable(
"bad evaluation kind");
1621 const VarDecl *var = emission.Variable;
1629 llvm_unreachable(
"no cleanup for trivially-destructible variable");
1634 if (emission.NRVOFlag) {
1637 EHStack.pushCleanup<DestroyNRVOVariableCXX>(cleanupKind, addr, dtor,
1651 if (!var->
hasAttr<ObjCPreciseLifetimeAttr>())
1660 if (emission.NRVOFlag) {
1662 EHStack.pushCleanup<DestroyNRVOVariableC>(cleanupKind, addr,
1663 emission.NRVOFlag,
type);
1674 bool useEHCleanup = (cleanupKind &
EHCleanup);
1675 EHStack.pushCleanup<DestroyObject>(cleanupKind, addr,
type, destroyer,
1680 assert(emission.Variable &&
"emission was not valid!");
1683 if (emission.wasEmittedAsGlobal())
return;
1689 const VarDecl &D = *emission.Variable;
1697 D.
hasAttr<ObjCPreciseLifetimeAttr>()) {
1702 if (
const CleanupAttr *CA = D.
getAttr<CleanupAttr>()) {
1706 assert(F &&
"Could not find function!");
1737 llvm_unreachable(
"Unknown DestructionKind");
1744 assert(dtorKind &&
"cannot push destructor for trivial type");
1754 assert(dtorKind &&
"cannot push destructor for trivial type");
1763 bool useEHCleanupForArray) {
1764 pushFullExprCleanup<DestroyObject>(cleanupKind, addr,
type,
1765 destroyer, useEHCleanupForArray);
1769 EHStack.pushCleanup<CallStackRestore>(
Kind, SPMem);
1774 Destroyer *destroyer,
bool useEHCleanupForArray) {
1779 EHStack.pushCleanup<DestroyObject>(
1781 destroyer, useEHCleanupForArray);
1785 pushCleanupAfterFullExpr<DestroyObject>(
1786 cleanupKind, addr,
type, destroyer, useEHCleanupForArray);
1802 bool useEHCleanupForArray) {
1805 return destroyer(*
this, addr, type);
1814 bool checkZeroLength =
true;
1817 if (llvm::ConstantInt *constLength = dyn_cast<llvm::ConstantInt>(length)) {
1819 if (constLength->isZero())
return;
1820 checkZeroLength =
false;
1826 checkZeroLength, useEHCleanupForArray);
1844 bool checkZeroLength,
1845 bool useEHCleanup) {
1853 if (checkZeroLength) {
1855 "arraydestroy.isempty");
1856 Builder.CreateCondBr(isEmpty, doneBB, bodyBB);
1860 llvm::BasicBlock *entryBB =
Builder.GetInsertBlock();
1862 llvm::PHINode *elementPast =
1863 Builder.CreatePHI(begin->getType(), 2,
"arraydestroy.elementPast");
1864 elementPast->addIncoming(end, entryBB);
1869 "arraydestroy.element");
1876 destroyer(*
this,
Address(element, elementAlign), elementType);
1883 Builder.CreateCondBr(done, doneBB, bodyBB);
1884 elementPast->addIncoming(element,
Builder.GetInsertBlock());
1897 unsigned arrayDepth = 0;
1909 begin = CGF.
Builder.CreateInBoundsGEP(begin, gepIndices,
"pad.arraybegin");
1910 end = CGF.
Builder.CreateInBoundsGEP(end, gepIndices,
"pad.arrayend");
1934 : ArrayBegin(arrayBegin), ArrayEnd(arrayEnd),
1935 ElementType(elementType),
Destroyer(destroyer),
1936 ElementAlign(elementAlign) {}
1940 ElementType, ElementAlign, Destroyer);
1954 IrregularPartialArrayDestroy(
llvm::Value *arrayBegin,
1959 : ArrayBegin(arrayBegin), ArrayEndPointer(arrayEndPointer),
1960 ElementType(elementType),
Destroyer(destroyer),
1961 ElementAlign(elementAlign) {}
1966 ElementType, ElementAlign, Destroyer);
1982 pushFullExprCleanup<IrregularPartialArrayDestroy>(
EHCleanup,
1983 arrayBegin, arrayEndPointer,
1984 elementType, elementAlign,
1999 pushFullExprCleanup<RegularPartialArrayDestroy>(
EHCleanup,
2000 arrayBegin, arrayEnd,
2001 elementType, elementAlign,
2007 if (LifetimeStartFn)
2008 return LifetimeStartFn;
2009 LifetimeStartFn = llvm::Intrinsic::getDeclaration(&getModule(),
2011 return LifetimeStartFn;
2017 return LifetimeEndFn;
2018 LifetimeEndFn = llvm::Intrinsic::getDeclaration(&getModule(),
2020 return LifetimeEndFn;
2031 : Param(param), Precise(precise) {}
2047 assert((isa<ParmVarDecl>(D) || isa<ImplicitParamDecl>(D)) &&
2048 "Invalid argument to EmitParmDecl");
2055 if (
auto IPD = dyn_cast<ImplicitParamDecl>(&D)) {
2068 bool DoStore =
false;
2074 unsigned AS = DeclPtr.
getType()->getAddressSpace();
2076 if (DeclPtr.
getType() != IRTy)
2085 if (SrcLangAS != DestLangAS) {
2086 assert(
getContext().getTargetAddressSpace(SrcLangAS) ==
2089 auto *T = V->getType()->getPointerElementType()->getPointerTo(DestAS);
2091 *
this, V, SrcLangAS, DestLangAS, T,
true),
2103 "unexpected destructor type");
2105 CalleeDestructedParamCleanups[cast<ParmVarDecl>(&D)] =
2116 DeclPtr = OpenMPLocalAddr;
2135 bool isConsumed = D.
hasAttr<NSConsumedAttr>();
2194 setAddrOfLocalVar(&D, DeclPtr);
2204 if (D.
hasAttr<AnnotateAttr>())
2210 if (requiresReturnValueNullabilityCheck()) {
2214 RetValNullabilityPrecondition =
2215 Builder.CreateAnd(RetValNullabilityPrecondition,
2223 if (!LangOpts.OpenMP || (!LangOpts.EmitAllDecls && !D->
isUsed()))
2225 getOpenMPRuntime().emitUserDefinedReduction(CGF, D);
const llvm::DataLayout & getDataLayout() const
CGOpenCLRuntime & getOpenCLRuntime()
Return a reference to the configured OpenCL runtime.
ReturnValueSlot - Contains the address where the return value of a function can be stored...
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Defines the clang::ASTContext interface.
static BytePattern constantIsRepeatedBytePattern(llvm::Constant *C)
Figures out whether the constant can be initialized with memset.
static bool canEmitInitWithFewStoresAfterBZero(llvm::Constant *Init, unsigned &NumStores)
Decide whether we can emit the non-zero parts of the specified initializer with equal or fewer than N...
void setImplicit(bool I=true)
Represents a function declaration or definition.
void EmitStaticVarDecl(const VarDecl &D, llvm::GlobalValue::LinkageTypes Linkage)
llvm::Value * EmitARCRetainAutoreleaseScalarExpr(const Expr *expr)
Destroyer * getDestroyer(QualType::DestructionKind destructionKind)
A (possibly-)qualified type.
Allows to disable automatic handling of functions used in target regions as those marked as omp decla...
void EmitExtendGCLifetime(llvm::Value *object)
EmitExtendGCLifetime - Given a pointer to an Objective-C object, make sure it survives garbage collec...
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
CodeGenTypes & getTypes()
llvm::Type * ConvertTypeForMem(QualType T)
const CodeGenOptions & getCodeGenOpts() const
void EmitVarDecl(const VarDecl &D)
EmitVarDecl - Emit a local variable declaration.
Address CreateMemTemp(QualType T, const Twine &Name="tmp", Address *Alloca=nullptr)
CreateMemTemp - Create a temporary memory object of the given type, with appropriate alignmen and cas...
llvm::Constant * EmitCheckTypeDescriptor(QualType T)
Emit a description of a type in a format suitable for passing to a runtime sanitizer handler...
bool HaveInsertPoint() const
HaveInsertPoint - True if an insertion point is defined.
Stmt - This represents one statement.
llvm::Constant * tryEmitForInitializer(const VarDecl &D)
Try to emit the initiaizer of the given declaration as an abstract constant.
Defines the SourceManager interface.
bool isRecordType() const
bool hasLabelBeenSeenInCurrentScope() const
Return true if a label was seen in the current scope.
void emitAutoVarTypeCleanup(const AutoVarEmission &emission, QualType::DestructionKind dtorKind)
Enter a destroy cleanup for the given local variable.
Decl - This represents one declaration (or definition), e.g.
const Decl * CurCodeDecl
CurCodeDecl - This is the inner-most code context, which includes blocks.
void EmitCheck(ArrayRef< std::pair< llvm::Value *, SanitizerMask >> Checked, SanitizerHandler Check, ArrayRef< llvm::Constant *> StaticArgs, ArrayRef< llvm::Value *> DynamicArgs)
Create a basic block that will call a handler function in a sanitizer runtime with the provided argum...
void EmitAutoVarDecl(const VarDecl &D)
EmitAutoVarDecl - Emit an auto variable declaration.
static Destroyer destroyARCStrongPrecise
void pushLifetimeExtendedDestroy(CleanupKind kind, Address addr, QualType type, Destroyer *destroyer, bool useEHCleanupForArray)
void EmitStoreThroughLValue(RValue Src, LValue Dst, bool isInit=false)
EmitStoreThroughLValue - Store the specified rvalue into the specified lvalue, where both are guarant...
static void emitStoresForInitAfterBZero(CodeGenModule &CGM, llvm::Constant *Init, Address Loc, bool isVolatile, CGBuilderTy &Builder)
For inits that canEmitInitWithFewStoresAfterBZero returned true for, emit the scalar stores that woul...
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Represents a call to a C++ constructor.
BytePattern(uint8_t Value)
stable_iterator stable_begin() const
Create a stable reference to the top of the EH stack.
void EmitARCCopyWeak(Address dst, Address src)
void @objc_copyWeak(i8** dest, i8** src) Disregards the current value in dest.
constexpr XRayInstrMask Function
llvm::Value * EmitARCRetainNonBlock(llvm::Value *value)
Retain the given object, with normal retain semantics.
llvm::IntegerType * Int8Ty
i8, i16, i32, and i64
Represents a C++ constructor within a class.
The type is a struct containing a field whose type is not PCK_Trivial.
static bool shouldUseBZeroPlusStoresToInitialize(llvm::Constant *Init, uint64_t GlobalSize)
Decide whether we should use bzero plus some stores to initialize a local variable instead of using a...
static Destroyer destroyARCWeak
RValue EmitCall(const CGFunctionInfo &CallInfo, const CGCallee &Callee, ReturnValueSlot ReturnValue, const CallArgList &Args, llvm::Instruction **callOrInvoke, SourceLocation Loc)
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.
Represents a variable declaration or definition.
Address getObjectAddress(CodeGenFunction &CGF) const
Returns the address of the object within this declaration.
RAII object to set/unset CodeGenFunction::IsSanitizerScope.
const T * getAs() const
Member-template getAs<specific type>'.
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
This class gathers all debug information during compilation and is responsible for emitting to llvm g...
ObjCMethodDecl - Represents an instance or class method declaration.
void EmitVariablyModifiedType(QualType Ty)
EmitVLASize - Capture all the sizes for the VLA expressions in the given variably-modified type and s...
llvm::Value * getPointer() const
bool useLifetimeMarkers() const
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 ...
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have...
unsigned getAddressSpace() const
Return the address space that this address resides in.
The collection of all-type qualifiers we support.
void add(RValue rvalue, QualType type)
bool isARCPseudoStrong() const
Determine whether this variable is an ARC pseudo-__strong variable.
const TargetInfo & getTarget() const
One of these records is kept for each identifier that is lexed.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
void emitDestroy(Address addr, QualType type, Destroyer *destroyer, bool useEHCleanupForArray)
emitDestroy - Immediately perform the destruction of the given object.
void emitByrefStructureInit(const AutoVarEmission &emission)
Initialize the structural components of a __block variable, i.e.
VlaSizePair getVLAElements1D(const VariableArrayType *vla)
Return the number of elements for a single dimension for the given array type.
Address getAddress() const
CGDebugInfo * getDebugInfo()
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
llvm::Constant * tryEmitAbstractForInitializer(const VarDecl &D)
Try to emit the initializer of the given declaration as an abstract constant.
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...
Address getIndirectAddress() const
llvm::IntegerType * Int64Ty
RValue EmitReferenceBindingToExpr(const Expr *E)
Emits a reference binding to the passed in expression.
llvm::IntegerType * SizeTy
Qualifiers::ObjCLifetime getObjCLifetime() const
bool isReferenceType() const
void pushEHDestroy(QualType::DestructionKind dtorKind, Address addr, QualType type)
pushEHDestroy - Push the standard destructor for the given type as an EH-only cleanup.
Denotes a cleanup that should run when a scope is exited using exceptional control flow (a throw stat...
Address getAllocatedAddress() const
Returns the raw, allocated address, which is not necessarily the address of the object itself...
CleanupKind getCleanupKind(QualType::DestructionKind kind)
void EmitStoreOfScalar(llvm::Value *Value, Address Addr, bool Volatile, QualType Ty, AlignmentSource Source=AlignmentSource::Type, bool isInit=false, bool isNontemporal=false)
EmitStoreOfScalar - Store a scalar value to an address, taking care to appropriately convert from the...
void setNonGC(bool Value)
llvm::Constant * getLLVMLifetimeStartFn()
Lazily declare the .lifetime.start intrinsic.
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
llvm::Value * EmitARCStoreStrongCall(Address addr, llvm::Value *value, bool resultIgnored)
Store into a strong object.
void pushRegularPartialArrayCleanup(llvm::Value *arrayBegin, llvm::Value *arrayEnd, QualType elementType, CharUnits elementAlignment, Destroyer *destroyer)
pushRegularPartialArrayCleanup - Push an EH cleanup to destroy already-constructed elements of the gi...
static bool hasScalarEvaluationKind(QualType T)
static void drillIntoBlockVariable(CodeGenFunction &CGF, LValue &lvalue, const VarDecl *var)
void defaultInitNonTrivialCStructVar(LValue Dst)
Address CreateElementBitCast(Address Addr, llvm::Type *Ty, const llvm::Twine &Name="")
Cast the element type of the given address to a different type, preserving information like the align...
CharUnits - This is an opaque type for sizes expressed in character units.
void EmitOMPDeclareReduction(const OMPDeclareReductionDecl *D, CodeGenFunction *CGF=nullptr)
Emit a code for declare reduction construct.
An x-value expression is a reference to an object with independent storage but which can be "moved"...
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
void EmitGlobalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl)
Emit information about a global variable.
CharUnits getAlignment() const
Return the alignment of this pointer.
void setStaticLocalDeclAddress(const VarDecl *D, llvm::Constant *C)
bool needsEHCleanup(QualType::DestructionKind kind)
Determines whether an EH cleanup is required to destroy a type with the given destruction kind...
const_arg_iterator arg_begin() const
llvm::Value * EmitARCUnsafeUnretainedScalarExpr(const Expr *expr)
EmitARCUnsafeUnretainedScalarExpr - Semantically equivalent to immediately releasing the resut of Emi...
llvm::CallInst * CreateMemCpy(Address Dest, Address Src, llvm::Value *Size, bool IsVolatile=false)
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
CharUnits getDeclAlign(const Decl *D, bool ForAlignof=false) const
Return a conservative estimate of the alignment of the specified decl D.
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
Values of this type can never be null.
Scope - A scope is a transient data structure that is used while parsing the program.
llvm::BasicBlock * createBasicBlock(const Twine &name="", llvm::Function *parent=nullptr, llvm::BasicBlock *before=nullptr)
createBasicBlock - Create an LLVM basic block.
llvm::Value * EmitARCRetainScalarExpr(const Expr *expr)
EmitARCRetainScalarExpr - Semantically equivalent to EmitARCRetainObject(e->getType(), EmitScalarExpr(e)), but making a best-effort attempt to peephole expressions that naturally produce retained objects.
Denotes a cleanup that should run when a scope is exited using normal control flow (falling off the e...
void EmitAtomicInit(Expr *E, LValue lvalue)
const internal::VariadicDynCastAllOfMatcher< Stmt, CastExpr > castExpr
Matches any cast nodes of Clang's AST.
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
CharUnits getPointerAlign() const
static bool ContainsLabel(const Stmt *S, bool IgnoreCaseStmts=false)
ContainsLabel - Return true if the statement contains a label in it.
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
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...
static bool isCapturedBy(const VarDecl &, const Expr *)
Determines whether the given __block variable is potentially captured by the given expression...
void registerVLASizeExpression(QualType Ty, llvm::Metadata *SizeExpr)
Register VLA size expression debug node with the qualified type.
This object can be modified without requiring retains or releases.
bool isTypeConstant(QualType QTy, bool ExcludeCtorDtor)
isTypeConstant - Determine whether an object of this type can be emitted as a constant.
StorageDuration getStorageDuration() const
Get the storage duration of this variable, per C++ [basic.stc].
llvm::Value * EmitLoadOfScalar(Address Addr, bool Volatile, QualType Ty, SourceLocation Loc, AlignmentSource Source=AlignmentSource::Type, bool isNontemporal=false)
EmitLoadOfScalar - Load a scalar value from an address, taking care to appropriately convert from the...
static CharUnits One()
One - Construct a CharUnits quantity of one.
CompoundStmt - This represents a group of statements like { stmt stmt }.
std::pair< llvm::Value *, llvm::Value * > ComplexPairTy
AutoVarEmission EmitAutoVarAlloca(const VarDecl &var)
EmitAutoVarAlloca - Emit the alloca and debug information for a local variable.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
ASTContext & getContext() const
const CodeGen::CGBlockInfo * BlockInfo
IdentifierInfo & getOwn(StringRef Name)
Gets an IdentifierInfo for the given name without consulting external sources.
RValue - This trivial value class is used to represent the result of an expression that is evaluated...
void setAddress(Address address)
CleanupKind getARCCleanupKind()
Retrieves the default cleanup kind for an ARC cleanup.
StringRef getBlockMangledName(GlobalDecl GD, const BlockDecl *BD)
llvm::Constant * getNullPointer(llvm::PointerType *T, QualType QT)
Get target specific null pointer.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
AggValueSlot::Overlap_t overlapForFieldInit(const FieldDecl *FD)
Determine whether a field initialization may overlap some other object.
Address CreateDefaultAlignTempAlloca(llvm::Type *Ty, const Twine &Name="tmp")
CreateDefaultAlignedTempAlloca - This creates an alloca with the default ABI alignment of the given L...
llvm::Value * EmitARCStoreWeak(Address addr, llvm::Value *value, bool ignored)
i8* @objc_storeWeak(i8** addr, i8* value) Returns value.
void EmitCXXGuardedInit(const VarDecl &D, llvm::GlobalVariable *DeclPtr, bool PerformInit)
Emit code in this function to perform a guarded variable initialization.
llvm::DILocalVariable * EmitDeclareOfAutoVariable(const VarDecl *Decl, llvm::Value *AI, CGBuilderTy &Builder)
Emit call to llvm.dbg.declare for an automatic variable declaration.
static TypeEvaluationKind getEvaluationKind(QualType T)
getEvaluationKind - Return the TypeEvaluationKind of QualType T.
Pepresents a block literal declaration, which is like an unnamed FunctionDecl.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Expr - This represents one expression.
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).
Address getOriginalAllocatedAddress() const
Returns the address for the original alloca instruction.
void EmitAutoVarInit(const AutoVarEmission &emission)
void AddGlobalAnnotations(const ValueDecl *D, llvm::GlobalValue *GV)
Add global annotations that are set on D, for the global GV.
bool hasLocalStorage() const
Returns true if a variable with function scope is a non-static local variable.
Enters a new scope for capturing cleanups, all of which will be executed once the scope is exited...
static CGCallee forDirect(llvm::Constant *functionPtr, const CGCalleeInfo &abstractInfo=CGCalleeInfo())
virtual void EmitWorkGroupLocalVarDecl(CodeGenFunction &CGF, const VarDecl &D)
Emit the IR required for a work-group-local variable declaration, and add an entry to CGF's LocalDecl...
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Represents a C++ destructor within a class.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
bool isExceptionVariable() const
Determine whether this variable is the exception variable in a C++ catch statememt or an Objective-C ...
VlaSizePair getVLASize(const VariableArrayType *vla)
Returns an LLVM value that corresponds to the size, in non-variably-sized elements, of a variable length array type, plus that largest non-variably-sized element type.
llvm::PointerType * getType() const
Return the type of the pointer value.
ObjCLifetime getObjCLifetime() const
DeclContext * getDeclContext()
static SVal getValue(SVal val, SValBuilder &svalBuilder)
const AstTypeMatcher< ArrayType > arrayType
Matches all kinds of arrays.
llvm::LLVMContext & getLLVMContext()
void EmitNullabilityCheck(LValue LHS, llvm::Value *RHS, SourceLocation Loc)
Given an assignment *LHS = RHS, emit a test that checks if RHS is nonnull, if LHS is marked _Nonnull...
llvm::GlobalValue::LinkageTypes getLLVMLinkageVarDefinition(const VarDecl *VD, bool IsConstant)
Returns LLVM linkage for a declarator.
Checking the value assigned to a _Nonnull pointer. Must not be null.
CharUnits alignmentOfArrayElement(CharUnits elementSize) const
Given that this is the alignment of the first element of an array, return the minimum alignment of an...
llvm::PointerType * AllocaInt8PtrTy
llvm::CallInst * CreateMemSet(Address Dest, llvm::Value *Value, llvm::Value *Size, bool IsVolatile=false)
void emitArrayDestroy(llvm::Value *begin, llvm::Value *end, QualType elementType, CharUnits elementAlign, Destroyer *destroyer, bool checkZeroLength, bool useEHCleanup)
emitArrayDestroy - Destroys all the elements of the given array, beginning from last to first...
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
static bool hasNontrivialDestruction(QualType T)
hasNontrivialDestruction - Determine whether a type's destruction is non-trivial. ...
float __ovld __cnfn length(float p)
Return the length of vector p, i.e., sqrt(p.x2 + p.y 2 + ...)
const LangOptions & getLangOpts() const
ASTContext & getContext() const
ImplicitParamDecl * getSelfDecl() const
GlobalDecl - represents a global declaration.
VarBypassDetector Bypasses
The l-value was considered opaque, so the alignment was determined from a type.
void setBlockContextParameter(const ImplicitParamDecl *D, unsigned argNum, llvm::Value *ptr)
llvm::Constant * getOrCreateStaticVarDecl(const VarDecl &D, llvm::GlobalValue::LinkageTypes Linkage)
There is no lifetime qualification on this type.
Address CreateBitCast(Address Addr, llvm::Type *Ty, const llvm::Twine &Name="")
Assigning into this object requires the old value to be released and the new value to be retained...
llvm::GlobalVariable * AddInitializerToStaticVarDecl(const VarDecl &D, llvm::GlobalVariable *GV)
AddInitializerToStaticVarDecl - Add the initializer for 'D' to the global variable that has already b...
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.
void EmitAndRegisterVariableArrayDimensions(CGDebugInfo *DI, const VarDecl &D, bool EmitDebugInfo)
Emits the alloca and debug information for the size expressions for each dimension of an array...
void EnsureInsertPoint()
EnsureInsertPoint - Ensure that an insertion point is defined so that emitted IR has a place to go...
void EmitARCRelease(llvm::Value *value, ARCPreciseLifetime_t precise)
Release the given object.
LValue EmitDeclRefLValue(const DeclRefExpr *E)
This represents '#pragma omp declare reduction ...' directive.
LangAS getAddressSpace() const
Return the address space of this type.
static std::string getStaticDeclName(CodeGenModule &CGM, const VarDecl &D)
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
static BytePattern shouldUseMemSetToInitialize(llvm::Constant *Init, uint64_t GlobalSize)
Decide whether we should use memset to initialize a local variable instead of using a memcpy from a c...
std::string getNameAsString() const
Get a human-readable name for the declaration, even if it is one of the special kinds of names (C++ c...
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
static void emitPartialArrayDestroy(CodeGenFunction &CGF, llvm::Value *begin, llvm::Value *end, QualType type, CharUnits elementAlign, CodeGenFunction::Destroyer *destroyer)
Perform partial array destruction as if in an EH cleanup.
const Decl * getDecl() const
const BlockByrefInfo & getBlockByrefInfo(const VarDecl *var)
BuildByrefInfo - This routine changes a __block variable declared as T x into:
llvm::Value * EmitLifetimeStart(uint64_t Size, llvm::Value *Addr)
Emit a lifetime.begin marker if some criteria are satisfied.
LangAS getStringLiteralAddressSpace() const
Return the AST address space of string literal, which is used to emit the string literal as global va...
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
static bool isAccessedBy(const VarDecl &var, const Stmt *s)
SanitizerSet SanOpts
Sanitizers enabled for this function.
This file defines OpenMP nodes for declarative directives.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
bool isTrivialInitializer(const Expr *Init)
Determine whether the given initializer is trivial in the sense that it requires no code to be genera...
bool isObjCObjectPointerType() const
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after...
static void EmitAutoVarWithLifetime(CodeGenFunction &CGF, const VarDecl &var, Address addr, Qualifiers::ObjCLifetime lifetime)
EmitAutoVarWithLifetime - Does the setup required for an automatic variable with lifetime.
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required...
Address CreateConstInBoundsGEP2_32(Address Addr, unsigned Idx0, unsigned Idx1, const llvm::DataLayout &DL, const llvm::Twine &Name="")
void EmitParmDecl(const VarDecl &D, ParamValue Arg, unsigned ArgNo)
EmitParmDecl - Emit a ParmVarDecl or an ImplicitParamDecl.
Assigning into this object requires a lifetime extension.
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
BytePattern merge(const BytePattern Other) const
llvm::Value * getDirectValue() const
llvm::Constant * getLLVMLifetimeEndFn()
Lazily declare the .lifetime.end intrinsic.
void enterFullExpression(const ExprWithCleanups *E)
void EmitDecl(const Decl &D)
EmitDecl - Emit a declaration.
const TargetCodeGenInfo & getTargetHooks() const
static Destroyer destroyARCStrongImprecise
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
llvm::Value * EmitScalarExpr(const Expr *E, bool IgnoreResultAssign=false)
EmitScalarExpr - Emit the computation of the specified expression of LLVM scalar type, returning the result.
void addUsedGlobal(llvm::GlobalValue *GV)
Add a global to a list to be added to the llvm.used metadata.
bool isObjCGCWeak() const
true when Type is objc's weak.
Base class for declarations which introduce a typedef-name.
void ErrorUnsupported(const Stmt *S, const char *Type)
Print out an error that codegen doesn't support the specified stmt yet.
CGFunctionInfo - Class to encapsulate the information about a function definition.
This class organizes the cross-function state that is used while generating LLVM code.
CGOpenMPRuntime & getOpenMPRuntime()
Return a reference to the configured OpenMP runtime.
Dataflow Directional Tag Classes.
static ApplyDebugLocation CreateDefaultArtificial(CodeGenFunction &CGF, SourceLocation TemporaryLocation)
Apply TemporaryLocation if it is valid.
void EmitCXXDestructorCall(const CXXDestructorDecl *D, CXXDtorType Type, bool ForVirtualBase, bool Delegating, Address This)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
ArrayRef< Capture > captures() const
const CGFunctionInfo & arrangeFunctionDeclaration(const FunctionDecl *FD)
Free functions are functions that are compatible with an ordinary C function pointer type...
QualType getUnderlyingType() const
const Expr * getInit() const
llvm::LoadInst * CreateLoad(Address Addr, const llvm::Twine &Name="")
llvm::IntegerType * IntPtrTy
llvm::Value * getAnyValue() const
Decl * getNonClosureContext()
Find the innermost non-closure ancestor of this declaration, walking up through blocks, lambdas, etc.
llvm::Constant * EmitNullConstant(QualType T)
Return the result of value-initializing the given type, i.e.
llvm::Function * getIntrinsic(unsigned IID, ArrayRef< llvm::Type *> Tys=None)
llvm::StoreInst * CreateStore(llvm::Value *Val, Address Addr, bool IsVolatile=false)
static AggValueSlot forLValue(const LValue &LV, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, IsAliased_t isAliased, Overlap_t mayOverlap, IsZeroed_t isZeroed=IsNotZeroed, IsSanitizerChecked_t isChecked=IsNotSanitizerChecked)
llvm::Module & getModule() const
static bool tryEmitARCCopyWeakInit(CodeGenFunction &CGF, const LValue &destLV, const Expr *init)
LValue MakeAddrLValue(Address Addr, QualType T, AlignmentSource Source=AlignmentSource::Type)
void EmitAggExpr(const Expr *E, AggValueSlot AS)
EmitAggExpr - Emit the computation of the specified expression of aggregate type. ...
static bool hasAggregateEvaluationKind(QualType T)
void EmitAutoVarCleanups(const AutoVarEmission &emission)
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
bool isConstantSizeType() const
Return true if this is not a variable sized type, according to the rules of C99 6.7.5p3.
CodeGenTypes & getTypes() const
void EmitStoreOfComplex(ComplexPairTy V, LValue dest, bool isInit)
EmitStoreOfComplex - Store a complex number into the specified l-value.
bool isConstantInitializer(ASTContext &Ctx, bool ForRef, const Expr **Culprit=nullptr) const
isConstantInitializer - Returns true if this expression can be emitted to IR as a constant...
llvm::Type * getElementType() const
Return the type of the values stored in this address.
bool isAtomicType() const
llvm::PointerType * Int8PtrTy
llvm::LoadInst * CreateFlagLoad(llvm::Value *Addr, const llvm::Twine &Name="")
Emit a load from an i1 flag variable.
void EmitScalarInit(const Expr *init, const ValueDecl *D, LValue lvalue, bool capturedByInit)
llvm::Constant * GetAddrOfFunction(GlobalDecl GD, llvm::Type *Ty=nullptr, bool ForVTable=false, bool DontDefer=false, ForDefinition_t IsForDefinition=NotForDefinition)
Return the address of the given function.
StringRef getMangledName(GlobalDecl GD)
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
EmitBlock - Emit the given block.
void EmitARCInitWeak(Address addr, llvm::Value *value)
i8* @objc_initWeak(i8** addr, i8* value) Returns value.
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Determine the nullability of the given type.
static Destroyer destroyNonTrivialCStruct
bool IsBypassed(const VarDecl *D) const
Returns true if the variable declaration was by bypassed by any goto or switch statement.
ARCPreciseLifetime_t
Does an ARC strong l-value have precise lifetime?
ComplexPairTy EmitComplexExpr(const Expr *E, bool IgnoreReal=false, bool IgnoreImag=false)
EmitComplexExpr - Emit the computation of the specified expression of complex type, returning the result.
A use of a default initializer in a constructor or in aggregate initialization.
static llvm::Constant * EmitNullConstant(CodeGenModule &CGM, const RecordDecl *record, bool asCompleteObject)
Reading or writing from this object requires a barrier call.
llvm::DenseMap< const VarDecl *, llvm::Value * > NRVOFlags
A mapping from NRVO variables to the flags used to indicate when the NRVO has been applied to this va...
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Represents a C++ struct/union/class.
bool isNRVOVariable() const
Determine whether this local variable can be used with the named return value optimization (NRVO)...
llvm::Type * ConvertType(QualType T)
static Destroyer destroyCXXObject
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
LValue EmitLValue(const Expr *E)
EmitLValue - Emit code to compute a designator that specifies the location of the expression...
Address ReturnValue
ReturnValue - The temporary alloca to hold the return value.
static BytePattern None()
void pushStackRestore(CleanupKind kind, Address SPMem)
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
bool hasExternalStorage() const
Returns true if a variable has extern or private_extern storage.
bool has(SanitizerMask K) const
Check if a certain (single) sanitizer is enabled.
Defines the clang::TargetInfo interface.
void finalize(llvm::GlobalVariable *global)
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
LangAS getASTAllocaAddressSpace() const
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
llvm::Value * getSizeForLifetimeMarkers() const
void setLocation(SourceLocation Loc)
Update the current source location.
A reference to a declared variable, function, enum, etc.
static RValue get(llvm::Value *V)
void EmitLifetimeEnd(llvm::Value *Size, llvm::Value *Addr)
llvm::Constant * EmitCheckSourceLocation(SourceLocation Loc)
Emit a description of a source location in a format suitable for passing to a runtime sanitizer handl...
bool isLocalVarDecl() const
Returns true for local variable declarations other than parameters.
An l-value expression is a reference to an object with independent storage.
void enterByrefCleanup(CleanupKind Kind, Address Addr, BlockFieldFlags Flags, bool LoadBlockVarAddr)
Enter a cleanup to destroy a __block variable.
LValue - This represents an lvalue references.
Information for lazily generating a cleanup.
void EmitVarAnnotations(const VarDecl *D, llvm::Value *V)
Emit local annotations for the local variable V, declared by D.
Automatic storage duration (most local variables).
SanitizerMetadata * getSanitizerMetadata()
bool isConstant(const ASTContext &Ctx) const
bool CurFuncIsThunk
In C++, whether we are code generating a thunk.
const LangOptions & getLangOpts() const
unsigned getTargetAddressSpace(QualType T) const
llvm::Value * emitArrayLength(const ArrayType *arrayType, QualType &baseType, Address &addr)
emitArrayLength - Compute the length of an array, even if it's a VLA, and drill down to the base elem...
CallArgList - Type for representing both the value and type of arguments in a call.
void PopCleanupBlock(bool FallThroughIsBranchThrough=false)
PopCleanupBlock - Will pop the cleanup entry on the stack and process all branch fixups.
llvm::Value * getPointer() const
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...
SourceLocation getLocation() const
void pushIrregularPartialArrayCleanup(llvm::Value *arrayBegin, Address arrayEndPointer, QualType elementType, CharUnits elementAlignment, Destroyer *destroyer)
pushIrregularPartialArrayCleanup - Push an EH cleanup to destroy already-constructed elements of the ...
bool isExternallyVisible() const
QualType getIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
getIntTypeForBitwidth - sets integer QualTy according to specified details: bitwidth, signed/unsigned.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
void Destroyer(CodeGenFunction &CGF, Address addr, QualType ty)
static CharUnits getDeclAlign(Expr *E, CharUnits TypeAlign, ASTContext &Context)
A helper function to get the alignment of a Decl referred to by DeclRefExpr or MemberExpr.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.