Go to the documentation of this file.
35 #include "llvm/Analysis/ValueTracking.h"
36 #include "llvm/IR/DataLayout.h"
37 #include "llvm/IR/GlobalVariable.h"
38 #include "llvm/IR/Intrinsics.h"
39 #include "llvm/IR/Type.h"
41 using namespace clang;
42 using namespace CodeGen;
45 "Clang max alignment greater than what LLVM supports?");
49 case Decl::BuiltinTemplate:
50 case Decl::TranslationUnit:
51 case Decl::ExternCContext:
53 case Decl::UnresolvedUsingTypename:
54 case Decl::ClassTemplateSpecialization:
55 case Decl::ClassTemplatePartialSpecialization:
56 case Decl::VarTemplateSpecialization:
57 case Decl::VarTemplatePartialSpecialization:
58 case Decl::TemplateTypeParm:
59 case Decl::UnresolvedUsingValue:
60 case Decl::NonTypeTemplateParm:
61 case Decl::CXXDeductionGuide:
63 case Decl::CXXConstructor:
64 case Decl::CXXDestructor:
65 case Decl::CXXConversion:
67 case Decl::MSProperty:
68 case Decl::IndirectField:
70 case Decl::ObjCAtDefsField:
72 case Decl::ImplicitParam:
73 case Decl::ClassTemplate:
74 case Decl::VarTemplate:
75 case Decl::FunctionTemplate:
76 case Decl::TypeAliasTemplate:
77 case Decl::TemplateTemplateParm:
78 case Decl::ObjCMethod:
79 case Decl::ObjCCategory:
80 case Decl::ObjCProtocol:
81 case Decl::ObjCInterface:
82 case Decl::ObjCCategoryImpl:
83 case Decl::ObjCImplementation:
84 case Decl::ObjCProperty:
85 case Decl::ObjCCompatibleAlias:
86 case Decl::PragmaComment:
87 case Decl::PragmaDetectMismatch:
88 case Decl::AccessSpec:
89 case Decl::LinkageSpec:
91 case Decl::ObjCPropertyImpl:
92 case Decl::FileScopeAsm:
94 case Decl::FriendTemplate:
97 case Decl::ClassScopeFunctionSpecialization:
98 case Decl::UsingShadow:
99 case Decl::ConstructorUsingShadow:
100 case Decl::ObjCTypeParam:
102 case Decl::UnresolvedUsingIfExists:
103 llvm_unreachable(
"Declaration should not be in declstmts!");
105 case Decl::CXXRecord:
113 DI->EmitAndRetainType(
getContext().getEnumType(cast<EnumDecl>(&D)));
116 case Decl::EnumConstant:
117 case Decl::StaticAssert:
121 case Decl::UnnamedGlobalConstant:
122 case Decl::TemplateParamObject:
123 case Decl::OMPThreadPrivate:
124 case Decl::OMPAllocate:
125 case Decl::OMPCapturedExpr:
126 case Decl::OMPRequires:
129 case Decl::LifetimeExtendedTemporary:
130 case Decl::RequiresExprBody:
134 case Decl::NamespaceAlias:
136 DI->EmitNamespaceAlias(cast<NamespaceAliasDecl>(D));
140 DI->EmitUsingDecl(cast<UsingDecl>(D));
142 case Decl::UsingEnum:
144 DI->EmitUsingEnumDecl(cast<UsingEnumDecl>(D));
146 case Decl::UsingPack:
147 for (
auto *Using : cast<UsingPackDecl>(D).expansions())
150 case Decl::UsingDirective:
152 DI->EmitUsingDirective(cast<UsingDirectiveDecl>(D));
155 case Decl::Decomposition: {
156 const VarDecl &VD = cast<VarDecl>(D);
158 "Should not see file-scope variables inside a function!");
160 if (
auto *DD = dyn_cast<DecompositionDecl>(&VD))
161 for (
auto *B : DD->bindings())
162 if (
auto *HD = B->getHoldingVar())
167 case Decl::OMPDeclareReduction:
170 case Decl::OMPDeclareMapper:
174 case Decl::TypeAlias: {
175 QualType Ty = cast<TypedefNameDecl>(D).getUnderlyingType();
177 DI->EmitAndRetainType(Ty);
200 llvm::GlobalValue::LinkageTypes
Linkage =
225 if (
auto *CD = dyn_cast<CapturedDecl>(DC))
226 DC = cast<DeclContext>(CD->getNonClosureContext());
227 if (
const auto *FD = dyn_cast<FunctionDecl>(DC))
229 else if (
const auto *BD = dyn_cast<BlockDecl>(DC))
231 else if (
const auto *OMD = dyn_cast<ObjCMethodDecl>(DC))
232 ContextName = OMD->getSelector().getAsString();
234 llvm_unreachable(
"Unknown context for static var decl");
246 if (llvm::Constant *ExistingGV = StaticLocalDeclMap[&D])
254 if (D.hasAttr<AsmLabelAttr>())
265 llvm::Constant *Init =
nullptr;
267 D.hasAttr<CUDASharedAttr>() || D.hasAttr<LoaderUninitializedAttr>())
268 Init = llvm::UndefValue::get(LTy);
272 llvm::GlobalVariable *GV =
new llvm::GlobalVariable(
274 nullptr, llvm::GlobalVariable::NotThreadLocal, TargetAS);
275 GV->setAlignment(
getContext().getDeclAlign(&D).getAsAlign());
278 GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));
287 llvm::Constant *Addr = GV;
288 if (AS != ExpectedAS) {
290 *
this, GV, AS, ExpectedAS,
291 LTy->getPointerTo(
getContext().getTargetAddressSpace(ExpectedAS)));
298 const Decl *DC = cast<Decl>(D.getDeclContext());
302 if (isa<BlockDecl>(DC) || isa<CapturedDecl>(DC)) {
310 if (
const auto *CD = dyn_cast<CXXConstructorDecl>(DC))
312 else if (
const auto *DD = dyn_cast<CXXDestructorDecl>(DC))
314 else if (
const auto *FD = dyn_cast<FunctionDecl>(DC))
319 assert(isa<ObjCMethodDecl>(DC) &&
"unexpected parent code decl");
334 llvm::GlobalVariable *
336 llvm::GlobalVariable *GV) {
350 GV->setConstant(
false);
362 assert(VarSize == CstSize &&
"Emitted constant has unexpected size");
369 if (GV->getValueType() != Init->getType()) {
370 llvm::GlobalVariable *OldGV = GV;
372 GV =
new llvm::GlobalVariable(
374 OldGV->getLinkage(), Init,
"",
375 OldGV, OldGV->getThreadLocalMode(),
376 OldGV->getType()->getPointerAddressSpace());
377 GV->setVisibility(OldGV->getVisibility());
378 GV->setDSOLocal(OldGV->isDSOLocal());
379 GV->setComdat(OldGV->getComdat());
385 llvm::Constant *NewPtrForOldDecl =
386 llvm::ConstantExpr::getBitCast(GV, OldGV->getType());
387 OldGV->replaceAllUsesWith(NewPtrForOldDecl);
390 OldGV->eraseFromParent();
394 GV->setInitializer(Init);
410 llvm::GlobalValue::LinkageTypes
Linkage) {
420 setAddrOfLocalVar(&D,
Address(addr, elemTy, alignment));
429 llvm::Type *expectedType = addr->getType();
431 llvm::GlobalVariable *
var =
432 cast<llvm::GlobalVariable>(addr->stripPointerCasts());
441 if (D.
getInit() && !isCudaSharedVar)
449 if (
auto *SA = D.
getAttr<PragmaClangBSSSectionAttr>())
450 var->addAttribute(
"bss-section", SA->getName());
451 if (
auto *SA = D.
getAttr<PragmaClangDataSectionAttr>())
452 var->addAttribute(
"data-section", SA->getName());
453 if (
auto *SA = D.
getAttr<PragmaClangRodataSectionAttr>())
454 var->addAttribute(
"rodata-section", SA->getName());
455 if (
auto *SA = D.
getAttr<PragmaClangRelroSectionAttr>())
456 var->addAttribute(
"relro-section", SA->getName());
458 if (
const SectionAttr *SA = D.
getAttr<SectionAttr>())
459 var->setSection(SA->getName());
463 else if (D.
hasAttr<UsedAttr>())
471 llvm::Constant *castedAddr =
472 llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(
var, expectedType);
473 LocalDeclMap.find(&D)->second =
Address(castedAddr, elemTy, alignment);
490 bool useEHCleanupForArray)
491 : addr(addr),
type(
type), destroyer(destroyer),
492 useEHCleanupForArray(useEHCleanupForArray) {}
497 bool useEHCleanupForArray;
501 bool useEHCleanupForArray =
502 flags.isForNormalCleanup() && this->useEHCleanupForArray;
508 template <
class Derived>
511 : NRVOFlag(NRVOFlag), Loc(addr), Ty(
type) {}
513 llvm::Value *NRVOFlag;
519 bool NRVO = flags.isForNormalCleanup() && NRVOFlag;
521 llvm::BasicBlock *SkipDtorBB =
nullptr;
526 llvm::Value *DidNRVO =
528 CGF.
Builder.CreateCondBr(DidNRVO, SkipDtorBB, RunDtorBB);
532 static_cast<Derived *
>(
this)->emitDestructorCall(CGF);
537 virtual ~DestroyNRVOVariable() =
default;
540 struct DestroyNRVOVariableCXX final
541 : DestroyNRVOVariable<DestroyNRVOVariableCXX> {
544 : DestroyNRVOVariable<DestroyNRVOVariableCXX>(addr,
type, NRVOFlag),
556 struct DestroyNRVOVariableC final
557 : DestroyNRVOVariable<DestroyNRVOVariableC> {
559 : DestroyNRVOVariable<DestroyNRVOVariableC>(addr, Ty, NRVOFlag) {}
568 CallStackRestore(
Address Stack) : Stack(Stack) {}
569 bool isRedundantBeforeReturn()
override {
return true; }
572 llvm::Function *F = CGF.
CGM.
getIntrinsic(llvm::Intrinsic::stackrestore);
593 llvm::Constant *CleanupFn;
597 CallCleanupFunction(llvm::Constant *CleanupFn,
const CGFunctionInfo *Info,
599 : CleanupFn(CleanupFn), FnInfo(*Info), Var(*Var) {}
634 llvm_unreachable(
"present but none");
642 (
var.hasAttr<ObjCPreciseLifetimeAttr>()
666 if (
const Expr *e = dyn_cast<Expr>(
s)) {
669 s = e = e->IgnoreParenCasts();
671 if (
const DeclRefExpr *ref = dyn_cast<DeclRefExpr>(e))
672 return (ref->getDecl() == &
var);
673 if (
const BlockExpr *be = dyn_cast<BlockExpr>(e)) {
674 const BlockDecl *block = be->getBlockDecl();
675 for (
const auto &I : block->
captures()) {
676 if (I.getVariable() == &
var)
682 for (
const Stmt *SubStmt :
s->children())
691 if (!
decl)
return false;
692 if (!isa<VarDecl>(
decl))
return false;
699 bool needsCast =
false;
706 case CK_BlockPointerToObjCPointerCast:
712 case CK_LValueToRValue: {
755 if (!
SanOpts.
has(SanitizerKind::NullabilityAssign))
765 llvm::Value *IsNotNull =
Builder.CreateIsNotNull(RHS);
766 llvm::Constant *StaticData[] = {
768 llvm::ConstantInt::get(
Int8Ty, 0),
770 EmitCheck({{IsNotNull, SanitizerKind::NullabilityAssign}},
771 SanitizerHandler::TypeMismatch, StaticData, RHS);
775 LValue lvalue,
bool capturedByInit) {
787 init = DIE->getExpr();
791 if (
auto *EWC = dyn_cast<ExprWithCleanups>(init)) {
793 return EmitScalarInit(EWC->getSubExpr(), D, lvalue, capturedByInit);
800 bool accessedByInit =
false;
802 accessedByInit = (capturedByInit ||
isAccessedBy(D, init));
803 if (accessedByInit) {
806 if (capturedByInit) {
828 llvm::Value *value =
nullptr;
832 llvm_unreachable(
"present but none");
835 if (!D || !isa<VarDecl>(D) || !cast<VarDecl>(D)->isARCPseudoStrong()) {
896 if (isa<llvm::ConstantAggregateZero>(Init) ||
897 isa<llvm::ConstantPointerNull>(Init) ||
898 isa<llvm::UndefValue>(Init))
900 if (isa<llvm::ConstantInt>(Init) || isa<llvm::ConstantFP>(Init) ||
901 isa<llvm::ConstantVector>(Init) || isa<llvm::BlockAddress>(Init) ||
902 isa<llvm::ConstantExpr>(Init))
903 return Init->isNullValue() ||
NumStores--;
906 if (isa<llvm::ConstantArray>(Init) || isa<llvm::ConstantStruct>(Init)) {
907 for (
unsigned i = 0, e = Init->getNumOperands(); i != e; ++i) {
908 llvm::Constant *Elt = cast<llvm::Constant>(Init->getOperand(i));
915 if (llvm::ConstantDataSequential *CDS =
916 dyn_cast<llvm::ConstantDataSequential>(Init)) {
917 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
918 llvm::Constant *Elt = CDS->getElementAsConstant(i);
932 llvm::Constant *Init,
Address Loc,
935 assert(!Init->isNullValue() && !isa<llvm::UndefValue>(Init) &&
936 "called emitStoresForInitAfterBZero for zero or undef value.");
938 if (isa<llvm::ConstantInt>(Init) || isa<llvm::ConstantFP>(Init) ||
939 isa<llvm::ConstantVector>(Init) || isa<llvm::BlockAddress>(Init) ||
940 isa<llvm::ConstantExpr>(Init)) {
941 auto *I = Builder.CreateStore(Init, Loc, isVolatile);
943 I->addAnnotationMetadata(
"auto-init");
947 if (llvm::ConstantDataSequential *CDS =
948 dyn_cast<llvm::ConstantDataSequential>(Init)) {
949 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
950 llvm::Constant *Elt = CDS->getElementAsConstant(i);
953 if (!Elt->isNullValue() && !isa<llvm::UndefValue>(Elt))
955 CGM, Elt, Builder.CreateConstInBoundsGEP2_32(Loc, 0, i), isVolatile,
956 Builder, IsAutoInit);
961 assert((isa<llvm::ConstantStruct>(Init) || isa<llvm::ConstantArray>(Init)) &&
962 "Unknown value type!");
964 for (
unsigned i = 0, e = Init->getNumOperands(); i != e; ++i) {
965 llvm::Constant *Elt = cast<llvm::Constant>(Init->getOperand(i));
968 if (!Elt->isNullValue() && !isa<llvm::UndefValue>(Elt))
970 Builder.CreateConstInBoundsGEP2_32(Loc, 0, i),
971 isVolatile, Builder, IsAutoInit);
979 uint64_t GlobalSize) {
981 if (isa<llvm::ConstantAggregateZero>(Init))
return true;
987 unsigned StoreBudget = 6;
988 uint64_t SizeLimit = 32;
990 return GlobalSize > SizeLimit &&
1000 uint64_t GlobalSize,
1001 const llvm::DataLayout &DL) {
1002 uint64_t SizeLimit = 32;
1003 if (GlobalSize <= SizeLimit)
1005 return llvm::isBytewiseValue(Init, DL);
1012 uint64_t GlobalByteSize) {
1014 uint64_t ByteSizeLimit = 64;
1017 if (GlobalByteSize <= ByteSizeLimit)
1030 return llvm::Constant::getNullValue(Ty);
1034 llvm::Constant *constant);
1039 llvm::StructType *STy,
1040 llvm::Constant *constant) {
1042 const llvm::StructLayout *Layout = DL.getStructLayout(STy);
1043 llvm::Type *Int8Ty = llvm::IntegerType::getInt8Ty(CGM.
getLLVMContext());
1044 unsigned SizeSoFar = 0;
1046 bool NestedIntact =
true;
1047 for (
unsigned i = 0, e = STy->getNumElements(); i != e; i++) {
1048 unsigned CurOff = Layout->getElementOffset(i);
1049 if (SizeSoFar < CurOff) {
1050 assert(!STy->isPacked());
1051 auto *PadTy = llvm::ArrayType::get(Int8Ty, CurOff - SizeSoFar);
1054 llvm::Constant *CurOp;
1055 if (constant->isZeroValue())
1056 CurOp = llvm::Constant::getNullValue(STy->getElementType(i));
1058 CurOp = cast<llvm::Constant>(constant->getAggregateElement(i));
1061 NestedIntact =
false;
1062 Values.push_back(NewOp);
1063 SizeSoFar = CurOff + DL.getTypeAllocSize(CurOp->getType());
1065 unsigned TotalSize = Layout->getSizeInBytes();
1066 if (SizeSoFar < TotalSize) {
1067 auto *PadTy = llvm::ArrayType::get(Int8Ty, TotalSize - SizeSoFar);
1070 if (NestedIntact && Values.size() == STy->getNumElements())
1072 return llvm::ConstantStruct::getAnon(Values, STy->isPacked());
1078 llvm::Constant *constant) {
1079 llvm::Type *OrigTy = constant->getType();
1080 if (
const auto STy = dyn_cast<llvm::StructType>(OrigTy))
1082 if (
auto *ArrayTy = dyn_cast<llvm::ArrayType>(OrigTy)) {
1084 uint64_t Size = ArrayTy->getNumElements();
1087 llvm::Type *ElemTy = ArrayTy->getElementType();
1088 bool ZeroInitializer = constant->isNullValue();
1089 llvm::Constant *OpValue, *PaddedOp;
1090 if (ZeroInitializer) {
1091 OpValue = llvm::Constant::getNullValue(ElemTy);
1094 for (
unsigned Op = 0; Op != Size; ++Op) {
1095 if (!ZeroInitializer) {
1096 OpValue = constant->getAggregateElement(Op);
1099 Values.push_back(PaddedOp);
1101 auto *NewElemTy = Values[0]->getType();
1102 if (NewElemTy == ElemTy)
1104 auto *NewArrayTy = llvm::ArrayType::get(NewElemTy, Size);
1105 return llvm::ConstantArray::get(NewArrayTy, Values);
1114 llvm::Constant *Constant,
1117 if (
const auto *FD = dyn_cast<FunctionDecl>(DC)) {
1118 if (
const auto *CC = dyn_cast<CXXConstructorDecl>(FD))
1119 return CC->getNameAsString();
1120 if (
const auto *CD = dyn_cast<CXXDestructorDecl>(FD))
1121 return CD->getNameAsString();
1123 }
else if (
const auto *OM = dyn_cast<ObjCMethodDecl>(DC)) {
1124 return OM->getNameAsString();
1125 }
else if (isa<BlockDecl>(DC)) {
1127 }
else if (isa<CapturedDecl>(DC)) {
1128 return "<captured>";
1130 llvm_unreachable(
"expected a function or method");
1136 llvm::GlobalVariable *&CacheEntry = InitializerConstants[&D];
1137 if (!CacheEntry || CacheEntry->getInitializer() != Constant) {
1138 auto *Ty = Constant->getType();
1139 bool isConstant =
true;
1140 llvm::GlobalVariable *InsertBefore =
nullptr;
1147 Name = (
"__const." + FunctionName(DC) +
"." + D.
getName()).str();
1149 llvm_unreachable(
"local variable has no parent function or method");
1150 llvm::GlobalVariable *GV =
new llvm::GlobalVariable(
1151 getModule(), Ty, isConstant, llvm::GlobalValue::PrivateLinkage,
1152 Constant, Name, InsertBefore, llvm::GlobalValue::NotThreadLocal, AS);
1154 GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
1156 }
else if (CacheEntry->getAlignment() < uint64_t(Align.
getQuantity())) {
1157 CacheEntry->setAlignment(Align.
getAsAlign());
1160 return Address(CacheEntry, CacheEntry->getValueType(), Align);
1166 llvm::Constant *Constant,
1169 return Builder.CreateElementBitCast(SrcPtr, CGM.
Int8Ty);
1175 llvm::Constant *constant,
bool IsAutoInit) {
1176 auto *Ty = constant->getType();
1177 uint64_t ConstantSize = CGM.
getDataLayout().getTypeAllocSize(Ty);
1181 bool canDoSingleStore = Ty->isIntOrIntVectorTy() ||
1182 Ty->isPtrOrPtrVectorTy() || Ty->isFPOrFPVectorTy();
1183 if (canDoSingleStore) {
1184 auto *I = Builder.CreateStore(constant, Loc, isVolatile);
1186 I->addAnnotationMetadata(
"auto-init");
1190 auto *SizeVal = llvm::ConstantInt::get(CGM.
IntPtrTy, ConstantSize);
1195 auto *I = Builder.CreateMemSet(Loc, llvm::ConstantInt::get(CGM.
Int8Ty, 0),
1196 SizeVal, isVolatile);
1198 I->addAnnotationMetadata(
"auto-init");
1200 bool valueAlreadyCorrect =
1201 constant->isNullValue() || isa<llvm::UndefValue>(constant);
1202 if (!valueAlreadyCorrect) {
1203 Loc = Builder.CreateElementBitCast(Loc, Ty);
1211 llvm::Value *Pattern =
1214 uint64_t
Value = 0x00;
1215 if (!isa<llvm::UndefValue>(Pattern)) {
1216 const llvm::APInt &AP = cast<llvm::ConstantInt>(Pattern)->getValue();
1217 assert(AP.getBitWidth() <= 8);
1218 Value = AP.getLimitedValue();
1220 auto *I = Builder.CreateMemSet(
1221 Loc, llvm::ConstantInt::get(CGM.
Int8Ty,
Value), SizeVal, isVolatile);
1223 I->addAnnotationMetadata(
"auto-init");
1229 if (
auto *STy = dyn_cast<llvm::StructType>(Ty)) {
1232 for (
unsigned i = 0; i != constant->getNumOperands(); i++) {
1233 Address EltPtr = Builder.CreateStructGEP(Loc, i);
1235 CGM, D, EltPtr, isVolatile, Builder,
1236 cast<llvm::Constant>(Builder.CreateExtractValue(constant, i)),
1241 }
else if (
auto *ATy = dyn_cast<llvm::ArrayType>(Ty)) {
1244 for (
unsigned i = 0; i != ATy->getNumElements(); i++) {
1245 Address EltPtr = Builder.CreateConstArrayGEP(Loc, i);
1247 CGM, D, EltPtr, isVolatile, Builder,
1248 cast<llvm::Constant>(Builder.CreateExtractValue(constant, i)),
1258 Builder.CreateMemCpy(Loc,
1261 SizeVal, isVolatile);
1263 I->addAnnotationMetadata(
"auto-init");
1270 llvm::Constant *constant =
1282 assert(!isa<llvm::UndefValue>(constant));
1288 auto *Ty = constant->getType();
1289 if (isa<llvm::UndefValue>(constant))
1291 if (Ty->isStructTy() || Ty->isArrayTy() || Ty->isVectorTy())
1292 for (llvm::Use &Op : constant->operands())
1299 llvm::Constant *constant) {
1300 auto *Ty = constant->getType();
1301 if (isa<llvm::UndefValue>(constant))
1303 if (!(Ty->isStructTy() || Ty->isArrayTy() || Ty->isVectorTy()))
1308 for (
unsigned Op = 0, NumOp = constant->getNumOperands(); Op != NumOp; ++Op) {
1309 auto *OpValue = cast<llvm::Constant>(constant->getOperand(Op));
1312 if (Ty->isStructTy())
1313 return llvm::ConstantStruct::get(cast<llvm::StructType>(Ty), Values);
1314 if (Ty->isArrayTy())
1315 return llvm::ConstantArray::get(cast<llvm::ArrayType>(Ty), Values);
1316 assert(Ty->isVectorTy());
1317 return llvm::ConstantVector::get(Values);
1333 llvm::Value *Addr) {
1334 if (!ShouldEmitLifetimeMarkers)
1337 assert(Addr->getType()->getPointerAddressSpace() ==
1339 "Pointer should be in alloca address space");
1340 llvm::Value *SizeV = llvm::ConstantInt::get(
1341 Int64Ty, Size.isScalable() ? -1 : Size.getFixedValue());
1345 C->setDoesNotThrow();
1350 assert(Addr->getType()->getPointerAddressSpace() ==
1352 "Pointer should be in alloca address space");
1356 C->setDoesNotThrow();
1368 while (
getContext().getAsVariableArrayType(Type1D)) {
1370 if (
auto *C = dyn_cast<llvm::ConstantInt>(VlaSize.NumElts))
1374 Twine Name = Twine(
"__vla_expr") + Twine(VLAExprCounter++);
1376 StringRef NameRef = Name.toStringRef(Buffer);
1378 VLAExprNames.push_back(&Ident);
1382 Dimensions.emplace_back(SizeExprAddr.getPointer(),
1385 Type1D = VlaSize.Type;
1394 unsigned NameIdx = 0;
1395 for (
auto &VlaSize : Dimensions) {
1397 if (
auto *C = dyn_cast<llvm::ConstantInt>(VlaSize.NumElts))
1398 MD = llvm::ConstantAsMetadata::get(C);
1402 assert(cast<llvm::PointerType>(VlaSize.NumElts->getType())
1403 ->isOpaqueOrPointeeTypeMatches(
SizeTy) &&
1404 "Number of VLA elements must be SizeTy");
1406 SizeTy->getScalarSizeInBits(),
false);
1411 ArtificialDecl->setImplicit();
1416 assert(MD &&
"No Size expression debug node created");
1433 emission.IsEscapingByRef = isEscapingByRef;
1458 address = OpenMPLocalAddr;
1459 AllocaAddr = OpenMPLocalAddr;
1472 getContext().getBaseElementType(Ty)->isObjCObjectPointerType()) &&
1488 assert(emission.wasEmittedAsGlobal());
1493 emission.IsConstantAggregate =
true;
1508 const auto *RD = RecordTy->getDecl();
1509 const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD);
1510 if ((CXXRD && !CXXRD->hasTrivialDestructor()) ||
1511 RD->isNonTrivialToPrimitiveDestroy()) {
1518 nullptr, &AllocaAddr);
1529 llvm::Type *allocaTy;
1530 if (isEscapingByRef) {
1532 allocaTy = byrefInfo.Type;
1533 allocaAlignment = byrefInfo.ByrefAlignment;
1536 allocaAlignment = alignment;
1543 nullptr, &AllocaAddr);
1548 bool IsMSCatchParam =
1570 emission.SizeForLifetimeMarkers =
1580 if (!DidCallStackSave) {
1586 llvm::Value *
V =
Builder.CreateCall(F);
1589 DidCallStackSave =
true;
1609 setAddrOfLocalVar(&D, address);
1610 emission.Addr = address;
1611 emission.AllocaAddr = AllocaAddr;
1620 if (UsePointerValue) {
1645 if (
const Expr *E = dyn_cast<Expr>(S))
1647 for (
const Stmt *SubStmt : S->children())
1660 if (
const BlockExpr *BE = dyn_cast<BlockExpr>(E)) {
1662 for (
const auto &I :
Block->captures()) {
1663 if (I.getVariable() == &Var)
1671 if (
const StmtExpr *SE = dyn_cast<StmtExpr>(E)) {
1673 for (
const auto *BI : CS->
body())
1674 if (
const auto *BIE = dyn_cast<Expr>(BI)) {
1678 else if (
const auto *DS = dyn_cast<DeclStmt>(BI)) {
1680 for (
const auto *I : DS->decls()) {
1681 if (
const auto *VD = dyn_cast<VarDecl>((I))) {
1682 const Expr *Init = VD->getInit();
1710 if (Constructor->isTrivial() &&
1711 Constructor->isDefaultConstructor() &&
1712 !Construct->requiresZeroInitialization())
1718 void CodeGenFunction::emitZeroOrPatternForAutoVarInit(
QualType type,
1723 bool isVolatile =
type.isVolatileQualified();
1724 if (!Size.isZero()) {
1725 switch (trivialAutoVarInit) {
1727 llvm_unreachable(
"Uninitialized handled by caller");
1751 auto SizeVal = VlaSize.NumElts;
1753 switch (trivialAutoVarInit) {
1755 llvm_unreachable(
"Uninitialized handled by caller");
1760 if (!EltSize.
isOne())
1763 SizeVal, isVolatile);
1764 I->addAnnotationMetadata(
"auto-init");
1778 llvm::Value *IsZeroSizedVLA =
Builder.CreateICmpEQ(
1779 SizeVal, llvm::ConstantInt::get(SizeVal->getType(), 0),
1781 Builder.CreateCondBr(IsZeroSizedVLA, ContBB, SetupBB);
1783 if (!EltSize.
isOne())
1785 llvm::Value *BaseSizeInChars =
1788 llvm::Value *
End =
Builder.CreateInBoundsGEP(
1789 Begin.getElementType(),
Begin.getPointer(), SizeVal,
"vla.end");
1790 llvm::BasicBlock *OriginBB =
Builder.GetInsertBlock();
1792 llvm::PHINode *Cur =
Builder.CreatePHI(
Begin.getType(), 2,
"vla.cur");
1793 Cur->addIncoming(
Begin.getPointer(), OriginBB);
1799 BaseSizeInChars, isVolatile);
1800 I->addAnnotationMetadata(
"auto-init");
1802 Builder.CreateInBoundsGEP(
Int8Ty, Cur, BaseSizeInChars,
"vla.next");
1803 llvm::Value *Done =
Builder.CreateICmpEQ(Next,
End,
"vla-init.isdone");
1804 Builder.CreateCondBr(Done, ContBB, LoopBB);
1805 Cur->addIncoming(Next, LoopBB);
1812 assert(emission.Variable &&
"emission was not valid!");
1815 if (emission.wasEmittedAsGlobal())
return;
1817 const VarDecl &D = *emission.Variable;
1832 if (emission.IsEscapingByRef)
1839 type.isNonTrivialToPrimitiveDefaultInitialize() ==
1842 if (emission.IsEscapingByRef)
1851 bool capturedByInit =
1852 Init && emission.IsEscapingByRef &&
isCapturedBy(D, Init);
1854 bool locIsByrefHeader = !capturedByInit;
1862 : (D.
getAttr<UninitializedAttr>()
1866 auto initializeWhatIsTechnicallyUninitialized = [&](
Address Loc) {
1867 if (trivialAutoVarInit ==
1872 if (emission.IsEscapingByRef && !locIsByrefHeader)
1875 return emitZeroOrPatternForAutoVarInit(
type, D, Loc);
1879 return initializeWhatIsTechnicallyUninitialized(Loc);
1881 llvm::Constant *constant =
nullptr;
1882 if (emission.IsConstantAggregate ||
1884 assert(!capturedByInit &&
"constant init contains a capturing block?");
1886 if (constant && !constant->isZeroValue() &&
1887 (trivialAutoVarInit !=
1905 initializeWhatIsTechnicallyUninitialized(Loc);
1911 if (!emission.IsConstantAggregate) {
1934 LValue lvalue,
bool capturedByInit) {
1937 if (
type->isReferenceType()) {
1956 if (
type->isAtomicType()) {
1960 if (isa<VarDecl>(D))
1962 else if (
auto *FD = dyn_cast<FieldDecl>(D))
1972 llvm_unreachable(
"bad evaluation kind");
1993 llvm_unreachable(
"no cleanup for trivially-destructible variable");
1998 if (emission.NRVOFlag) {
1999 assert(!
type->isArrayType());
2001 EHStack.pushCleanup<DestroyNRVOVariableCXX>(cleanupKind, addr,
type, dtor,
2009 if (
var->isARCPseudoStrong())
return;
2015 if (!
var->hasAttr<ObjCPreciseLifetimeAttr>())
2024 if (emission.NRVOFlag) {
2025 assert(!
type->isArrayType());
2026 EHStack.pushCleanup<DestroyNRVOVariableC>(cleanupKind, addr,
2027 emission.NRVOFlag,
type);
2038 bool useEHCleanup = (cleanupKind &
EHCleanup);
2039 EHStack.pushCleanup<DestroyObject>(cleanupKind, addr,
type, destroyer,
2044 assert(emission.Variable &&
"emission was not valid!");
2047 if (emission.wasEmittedAsGlobal())
return;
2053 const VarDecl &D = *emission.Variable;
2061 D.
hasAttr<ObjCPreciseLifetimeAttr>()) {
2066 if (
const CleanupAttr *CA = D.
getAttr<CleanupAttr>()) {
2070 assert(F &&
"Could not find function!");
2079 if (emission.IsEscapingByRef &&
2103 llvm_unreachable(
"Unknown DestructionKind");
2110 assert(dtorKind &&
"cannot push destructor for trivial type");
2120 assert(dtorKind &&
"cannot push destructor for trivial type");
2129 bool useEHCleanupForArray) {
2130 pushFullExprCleanup<DestroyObject>(cleanupKind, addr,
type,
2131 destroyer, useEHCleanupForArray);
2135 EHStack.pushCleanup<CallStackRestore>(
Kind, SPMem);
2140 Destroyer *destroyer,
2141 bool useEHCleanupForArray) {
2149 EHStack.pushCleanup<DestroyObject>(
2151 destroyer, useEHCleanupForArray);
2153 return pushCleanupAfterFullExprWithActiveFlag<DestroyObject>(
2162 using ConditionalCleanupType =
2170 EHStack.pushCleanup<ConditionalCleanupType>(
2172 destroyer, useEHCleanupForArray);
2176 pushCleanupAfterFullExprWithActiveFlag<ConditionalCleanupType>(
2177 cleanupKind, ActiveFlag, SavedAddr,
type, destroyer,
2178 useEHCleanupForArray);
2193 Destroyer *destroyer,
2194 bool useEHCleanupForArray) {
2197 return destroyer(*
this, addr,
type);
2206 bool checkZeroLength =
true;
2209 if (llvm::ConstantInt *constLength = dyn_cast<llvm::ConstantInt>(
length)) {
2211 if (constLength->isZero())
return;
2212 checkZeroLength =
false;
2219 checkZeroLength, useEHCleanupForArray);
2236 Destroyer *destroyer,
2237 bool checkZeroLength,
2238 bool useEHCleanup) {
2246 if (checkZeroLength) {
2247 llvm::Value *isEmpty =
Builder.CreateICmpEQ(begin, end,
2248 "arraydestroy.isempty");
2249 Builder.CreateCondBr(isEmpty, doneBB, bodyBB);
2253 llvm::BasicBlock *entryBB =
Builder.GetInsertBlock();
2255 llvm::PHINode *elementPast =
2256 Builder.CreatePHI(begin->getType(), 2,
"arraydestroy.elementPast");
2257 elementPast->addIncoming(end, entryBB);
2260 llvm::Value *negativeOne = llvm::ConstantInt::get(
SizeTy, -1,
true);
2262 llvm::Value *element =
Builder.CreateInBoundsGEP(
2263 llvmElementType, elementPast, negativeOne,
"arraydestroy.element");
2270 destroyer(*
this,
Address(element, llvmElementType, elementAlign),
2277 llvm::Value *done =
Builder.CreateICmpEQ(element, begin,
"arraydestroy.done");
2278 Builder.CreateCondBr(done, doneBB, bodyBB);
2279 elementPast->addIncoming(element,
Builder.GetInsertBlock());
2288 llvm::Value *begin, llvm::Value *end,
2294 unsigned arrayDepth = 0;
2303 llvm::Value *zero = llvm::ConstantInt::get(CGF.
SizeTy, 0);
2306 begin = CGF.
Builder.CreateInBoundsGEP(
2307 elemTy, begin, gepIndices,
"pad.arraybegin");
2308 end = CGF.
Builder.CreateInBoundsGEP(
2309 elemTy, end, gepIndices,
"pad.arrayend");
2324 llvm::Value *ArrayBegin;
2325 llvm::Value *ArrayEnd;
2330 RegularPartialArrayDestroy(llvm::Value *arrayBegin, llvm::Value *arrayEnd,
2333 : ArrayBegin(arrayBegin), ArrayEnd(arrayEnd),
2334 ElementType(elementType), Destroyer(destroyer),
2335 ElementAlign(elementAlign) {}
2339 ElementType, ElementAlign, Destroyer);
2347 llvm::Value *ArrayBegin;
2353 IrregularPartialArrayDestroy(llvm::Value *arrayBegin,
2358 : ArrayBegin(arrayBegin), ArrayEndPointer(arrayEndPointer),
2359 ElementType(elementType), Destroyer(destroyer),
2360 ElementAlign(elementAlign) {}
2365 ElementType, ElementAlign, Destroyer);
2380 Destroyer *destroyer) {
2381 pushFullExprCleanup<IrregularPartialArrayDestroy>(
EHCleanup,
2382 arrayBegin, arrayEndPointer,
2383 elementType, elementAlign,
2394 llvm::Value *arrayEnd,
2397 Destroyer *destroyer) {
2398 pushFullExprCleanup<RegularPartialArrayDestroy>(
EHCleanup,
2399 arrayBegin, arrayEnd,
2400 elementType, elementAlign,
2406 if (LifetimeStartFn)
2407 return LifetimeStartFn;
2408 LifetimeStartFn = llvm::Intrinsic::getDeclaration(&
getModule(),
2410 return LifetimeStartFn;
2416 return LifetimeEndFn;
2417 LifetimeEndFn = llvm::Intrinsic::getDeclaration(&
getModule(),
2419 return LifetimeEndFn;
2428 ConsumeARCParameter(llvm::Value *param,
2430 : Param(param), Precise(precise) {}
2447 assert((isa<ParmVarDecl>(D) || isa<ImplicitParamDecl>(D)) &&
2448 "Invalid argument to EmitParmDecl");
2455 if (
auto IPD = dyn_cast<ImplicitParamDecl>(&D)) {
2473 bool DoStore =
false;
2485 AllocaPtr = DeclPtr;
2489 if (SrcLangAS != DestLangAS) {
2490 assert(
getContext().getTargetAddressSpace(SrcLangAS) ==
2495 *
this,
V, SrcLangAS, DestLangAS, T,
true));
2507 "unexpected destructor type");
2509 CalleeDestructedParamCleanups[cast<ParmVarDecl>(&D)] =
2520 DeclPtr = OpenMPLocalAddr;
2521 AllocaPtr = DeclPtr;
2525 D.
getName() +
".addr", &AllocaPtr);
2530 llvm::Value *ArgVal = (DoStore ? Arg.
getDirectValue() :
nullptr);
2540 bool isConsumed = D.
hasAttr<NSConsumedAttr>();
2545 "pseudo-strong variable isn't strong?");
2546 assert(qs.
hasConst() &&
"pseudo-strong variable should be const!");
2595 setAddrOfLocalVar(&D, DeclPtr);
2601 llvm::DILocalVariable *DILocalVar = DI->EmitDeclareOfArgVariable(
2603 if (
const auto *Var = dyn_cast_or_null<ParmVarDecl>(&D))
2604 DI->getParamDbgMappings().insert({Var, DILocalVar});
2608 if (D.
hasAttr<AnnotateAttr>())
2614 if (requiresReturnValueNullabilityCheck()) {
2618 RetValNullabilityPrecondition =
2619 Builder.CreateAnd(RetValNullabilityPrecondition,
2627 if (!LangOpts.OpenMP || (!LangOpts.EmitAllDecls && !D->
isUsed()))
2634 if (!LangOpts.OpenMP || LangOpts.OpenMPSimd ||
2635 (!LangOpts.EmitAllDecls && !D->
isUsed()))
2646 const auto *DE = cast<DeclRefExpr>(E);
2647 const auto *VD = cast<VarDecl>(DE->getDecl());
2650 if (!VD->hasGlobalStorage())
2670 if (Entry->getType()->getAddressSpace() == TargetAS)
2675 llvm::PointerType *PTy = llvm::PointerType::get(Ty, TargetAS);
2680 llvm::GlobalVariable *DummyGV =
new llvm::GlobalVariable(
2681 getModule(), Entry->getValueType(),
false,
2682 llvm::GlobalValue::CommonLinkage,
nullptr,
"dummy",
nullptr,
2683 llvm::GlobalVariable::NotThreadLocal, Entry->getAddressSpace());
2684 Entry->replaceAllUsesWith(DummyGV);
2686 Entry->mutateType(PTy);
2687 llvm::Constant *NewPtrForOldDecl =
2688 llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(
2689 Entry, DummyGV->getType());
2693 DummyGV->replaceAllUsesWith(NewPtrForOldDecl);
2694 DummyGV->eraseFromParent();
bool isTypeConstant(QualType QTy, bool ExcludeCtorDtor)
isTypeConstant - Determine whether an object of this type can be emitted as a constant.
@ InternalLinkage
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
void emitAutoVarTypeCleanup(const AutoVarEmission &emission, QualType::DestructionKind dtorKind)
Enter a destroy cleanup for the given local variable.
RAII object to set/unset CodeGenFunction::IsSanitizerScope.
llvm::Type * ConvertTypeForMem(QualType T)
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
static Destroyer destroyCXXObject
llvm::Value * EmitARCRetainNonBlock(llvm::Value *value)
Retain the given object, with normal retain semantics.
This represents '#pragma omp allocate ...' directive.
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Determine the nullability of the given type.
bool isOne() const
isOne - Test whether the quantity equals one.
bool useLifetimeMarkers() const
llvm::CallInst * CreateMemCpy(Address Dest, Address Src, llvm::Value *Size, bool IsVolatile=false)
void addUsedOrCompilerUsedGlobal(llvm::GlobalValue *GV)
Add a global to a list to be added to the llvm.compiler.used metadata.
void emitByrefStructureInit(const AutoVarEmission &emission)
Initialize the structural components of a __block variable, i.e.
bool isRecordType() const
void EmitVarDecl(const VarDecl &D)
EmitVarDecl - Emit a local variable declaration.
llvm::IntegerType * SizeTy
@ Dtor_Base
Base object dtor.
static void emitStoresForInitAfterBZero(CodeGenModule &CGM, llvm::Constant *Init, Address Loc, bool isVolatile, CGBuilderTy &Builder, bool IsAutoInit)
For inits that canEmitInitWithFewStoresAfterBZero returned true for, emit the scalar stores that woul...
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
llvm::PointerType * Int8PtrTy
Represents a C++ constructor within a class.
StorageDuration getStorageDuration() const
Get the storage duration of this variable, per C++ [basic.stc].
llvm::Align getAsAlign() const
getAsAlign - Returns Quantity as a valid llvm::Align, Beware llvm::Align assumes power of two 8-bit b...
llvm::Constant * tryEmitForInitializer(const VarDecl &D)
Try to emit the initiaizer of the given declaration as an abstract constant.
virtual Address getAddressOfLocalVariable(CodeGenFunction &CGF, const VarDecl *VD)
Gets the OpenMP-specific address of the local variable.
llvm::Constant * EmitNullConstant(QualType T)
Return the result of value-initializing the given type, i.e.
CharUnits alignmentOfArrayElement(CharUnits elementSize) const
Given that this is the alignment of the first element of an array, return the minimum alignment of an...
RValue - This trivial value class is used to represent the result of an expression that is evaluated.
void initFullExprCleanupWithFlag(Address ActiveFlag)
static void emitStoresForZeroInit(CodeGenModule &CGM, const VarDecl &D, Address Loc, bool isVolatile, CGBuilderTy &Builder)
llvm::Constant * EmitCheckSourceLocation(SourceLocation Loc)
Emit a description of a source location in a format suitable for passing to a runtime sanitizer handl...
RValue EmitReferenceBindingToExpr(const Expr *E)
Emits a reference binding to the passed in expression.
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
RValue EmitCall(const CGFunctionInfo &CallInfo, const CGCallee &Callee, ReturnValueSlot ReturnValue, const CallArgList &Args, llvm::CallBase **callOrInvoke, bool IsMustTail, SourceLocation Loc)
EmitCall - Generate a call of the given function, expecting the given result type,...
bool mightBeUsableInConstantExpressions(const ASTContext &C) const
Determine whether this variable's value might be usable in a constant expression, according to the re...
static bool containsUndef(llvm::Constant *constant)
bool hasGlobalStorage() const
Returns true for all variables that do not have local storage.
const DeclContext * getParentFunctionOrMethod() const
If this decl is defined inside a function/method/block it returns the corresponding DeclContext,...
void addUsedGlobal(llvm::GlobalValue *GV)
Add a global to a list to be added to the llvm.used metadata.
CGOpenCLRuntime & getOpenCLRuntime()
Return a reference to the configured OpenCL runtime.
Address getObjectAddress(CodeGenFunction &CGF) const
Returns the address of the object within this declaration.
static Destroyer destroyARCStrongPrecise
CharUnits getAlignment() const
Return the alignment of this pointer.
void EmitLifetimeEnd(llvm::Value *Size, llvm::Value *Addr)
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.
bool isExternallyVisible() const
@ OCL_Weak
Reading or writing from this object requires a barrier call.
static bool isAccessedBy(const VarDecl &var, const Stmt *s)
Encodes a location in the source.
bool hasLabelBeenSeenInCurrentScope() const
Return true if a label was seen in the current scope.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
Address getAddress(CodeGenFunction &CGF) const
void EmitAutoVarDecl(const VarDecl &D)
EmitAutoVarDecl - Emit an auto variable declaration.
void PopCleanupBlock(bool FallThroughIsBranchThrough=false)
PopCleanupBlock - Will pop the cleanup entry on the stack and process all branch fixups.
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...
llvm::ConstantInt * getSize(CharUnits numChars)
Emit the given number of characters as a value of type size_t.
CharUnits getPointerAlign() const
A (possibly-)qualified type.
unsigned getTargetAddressSpace(QualType T) const
bool has(SanitizerMask K) const
Check if a certain (single) sanitizer is enabled.
ASTContext & getContext() const
const_arg_iterator arg_begin() const
static Address createUnnamedGlobalForMemcpyFrom(CodeGenModule &CGM, const VarDecl &D, CGBuilderTy &Builder, llvm::Constant *Constant, CharUnits Align)
The collection of all-type qualifiers we support.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required.
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.
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...
llvm::Value * getDirectValue() const
llvm::BasicBlock * createBasicBlock(const Twine &name="", llvm::Function *parent=nullptr, llvm::BasicBlock *before=nullptr)
createBasicBlock - Create an LLVM basic block.
void EmitARCCopyWeak(Address dst, Address src)
void @objc_copyWeak(i8** dest, i8** src) Disregards the current value in dest.
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 ...
llvm::StoreInst * CreateStore(llvm::Value *Val, Address Addr, bool IsVolatile=false)
void setAddress(Address address)
@ NoDebugInfo
Don't generate debug info.
LangAS GetGlobalVarAddressSpace(const VarDecl *D)
Return the AST address space of the underlying global variable for D, as determined by its declaratio...
ARCPreciseLifetime_t
Does an ARC strong l-value have precise lifetime?
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
llvm::DILocalVariable * EmitDeclareOfAutoVariable(const VarDecl *Decl, llvm::Value *AI, CGBuilderTy &Builder, const bool UsePointerValue=false)
Emit call to llvm.dbg.declare for an automatic variable declaration.
@ TCK_NonnullAssign
Checking the value assigned to a _Nonnull pointer. Must not be null.
@ Ctor_Base
Base object ctor.
const LangOptions & getLangOpts() const
bool HaveInsertPoint() const
HaveInsertPoint - True if an insertion point is defined.
Destroyer * getDestroyer(QualType::DestructionKind destructionKind)
@ EHCleanup
Denotes a cleanup that should run when a scope is exited using exceptional control flow (a throw stat...
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...
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...
const TargetCodeGenInfo & getTargetCodeGenInfo()
@ SD_Automatic
Automatic storage duration (most local variables).
void pushLifetimeExtendedDestroy(CleanupKind kind, Address addr, QualType type, Destroyer *destroyer, bool useEHCleanupForArray)
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...
void add(RValue rvalue, QualType type)
llvm::Constant * tryEmitAbstractForInitializer(const VarDecl &D)
Try to emit the initializer of the given declaration as an abstract constant.
void EmitStoreThroughLValue(RValue Src, LValue Dst, bool isInit=false)
EmitStoreThroughLValue - Store the specified rvalue into the specified lvalue, where both are guarant...
@ Dtor_Complete
Complete object dtor.
StringRef getMangledName(GlobalDecl GD)
static Destroyer destroyARCWeak
void EmitCXXDestructorCall(const CXXDestructorDecl *D, CXXDtorType Type, bool ForVirtualBase, bool Delegating, Address This, QualType ThisTy)
CGOpenMPRuntime & getOpenMPRuntime()
Return a reference to the configured OpenMP runtime.
void EmitVariablyModifiedType(QualType Ty)
EmitVLASize - Capture all the sizes for the VLA expressions in the given variably-modified type and s...
llvm::GlobalValue * GetGlobalValue(StringRef Ref)
GlobalDecl - represents a global declaration.
AggValueSlot::Overlap_t getOverlapForFieldInit(const FieldDecl *FD)
Determine whether a field initialization may overlap some other object.
LangAS GetGlobalConstantAddressSpace() const
Return the AST address space of constant literal, which is used to emit the constant literal as globa...
IdentifierInfo & getOwn(StringRef Name)
Gets an IdentifierInfo for the given name without consulting external sources.
static bool isCapturedBy(const VarDecl &, const Expr *)
Determines whether the given __block variable is potentially captured by the given expression.
ArrayRef< Capture > captures() const
llvm::PointerType * AllocaInt8PtrTy
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
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...
std::pair< llvm::Value *, llvm::Value * > ComplexPairTy
CharUnits getFlexibleArrayInitChars(const ASTContext &Ctx) const
If hasFlexibleArrayInit is true, compute the number of additional bytes necessary to store those elem...
llvm::Constant * getOrCreateStaticVarDecl(const VarDecl &D, llvm::GlobalValue::LinkageTypes Linkage)
llvm::Type * ConvertTypeForMem(QualType T, bool ForBitField=false)
ConvertTypeForMem - Convert type T into a llvm::Type.
ReturnValueSlot - Contains the address where the return value of a function can be stored,...
Address CreateDefaultAlignTempAlloca(llvm::Type *Ty, const Twine &Name="tmp")
CreateDefaultAlignedTempAlloca - This creates an alloca with the default ABI alignment of the given L...
float __ovld __cnfn length(float)
Return the length of vector p, i.e., sqrt(p.x2 + p.y 2 + ...)
Enters a new scope for capturing cleanups, all of which will be executed once the scope is exited.
void EmitOMPDeclareMapper(const OMPDeclareMapperDecl *D, CodeGenFunction *CGF=nullptr)
Emit a code for declare mapper construct.
const CodeGen::CGBlockInfo * BlockInfo
VlaSizePair getVLAElements1D(const VariableArrayType *vla)
Return the number of elements for a single dimension for the given array type.
static bool hasScalarEvaluationKind(QualType T)
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
CompoundStmt - This represents a group of statements like { stmt stmt }.
Address getOriginalAllocatedAddress() const
Returns the address for the original alloca instruction.
This represents '#pragma omp declare reduction ...' directive.
Information for lazily generating a cleanup.
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
void emitDestroy(Address addr, QualType type, Destroyer *destroyer, bool useEHCleanupForArray)
emitDestroy - Immediately perform the destruction of the given object.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
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.
LangAS getAddressSpace() const
Return the address space of this type.
@ PDIK_Struct
The type is a struct containing a field whose type is not PCK_Trivial.
Decl * getNonClosureContext()
Find the innermost non-closure ancestor of this declaration, walking up through blocks,...
static const RecordType * getRecordType(QualType QT)
Checks that the passed in QualType either is of RecordType or points to RecordType.
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
Scope - A scope is a transient data structure that is used while parsing the program.
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 either trap or call a handler function in the UBSan runtime with the p...
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
llvm::IntegerType * Int64Ty
void defaultInitNonTrivialCStructVar(LValue Dst)
llvm::Value * EmitARCUnsafeUnretainedScalarExpr(const Expr *expr)
EmitARCUnsafeUnretainedScalarExpr - Semantically equivalent to immediately releasing the resut of Emi...
const CodeGenOptions & getCodeGenOpts() const
Address createUnnamedGlobalFrom(const VarDecl &D, llvm::Constant *Constant, CharUnits Align)
Represents an array type, per C99 6.7.5.2 - Array Declarators.
llvm::Value * EmitARCStoreWeak(Address addr, llvm::Value *value, bool ignored)
i8* @objc_storeWeak(i8** addr, i8* value) Returns value.
void EnsureInsertPoint()
EnsureInsertPoint - Ensure that an insertion point is defined so that emitted IR has a place to go.
const T * getAs() const
Member-template getAs<specific type>'.
const TargetInfo & getTarget() const
CGDebugInfo * getDebugInfo()
const VariableArrayType * getAsVariableArrayType(QualType T) const
llvm::Constant * GetAddrOfGlobal(GlobalDecl GD, ForDefinition_t IsForDefinition=NotForDefinition)
static const uint64_t MaximumAlignment
bool isEscapingByref() const
Indicates the capture is a __block variable that is captured by a block that can potentially escape (...
bool isNRVOVariable() const
Determine whether this local variable can be used with the named return value optimization (NRVO).
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 void EmitAutoVarWithLifetime(CodeGenFunction &CGF, const VarDecl &var, Address addr, Qualifiers::ObjCLifetime lifetime)
EmitAutoVarWithLifetime - Does the setup required for an automatic variable with lifetime.
static CharUnits One()
One - Construct a CharUnits quantity of one.
llvm::Module & getModule() const
llvm::Value * EmitARCStoreStrongCall(Address addr, llvm::Value *value, bool resultIgnored)
Store into a strong object.
Represents a C++ destructor within a class.
Address getAllocatedAddress() const
Returns the raw, allocated address, which is not necessarily the address of the object itself.
This class gathers all debug information during compilation and is responsible for emitting to llvm g...
void EmitGlobalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl)
Emit information about a global variable.
CleanupKind getCleanupKind(QualType::DestructionKind kind)
bool hasExternalStorage() const
Returns true if a variable has extern or private_extern storage.
bool needsEHCleanup(QualType::DestructionKind kind)
Determines whether an EH cleanup is required to destroy a type with the given destruction kind.
void pushEHDestroy(QualType::DestructionKind dtorKind, Address addr, QualType type)
pushEHDestroy - Push the standard destructor for the given type as an EH-only cleanup.
bool Zero(InterpState &S, CodePtr OpPC)
QualType getIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
getIntTypeForBitwidth - sets integer QualTy according to specified details: bitwidth,...
Represents a variable declaration or definition.
void AddGlobalAnnotations(const ValueDecl *D, llvm::GlobalValue *GV)
Add global annotations that are set on D, for the global GV.
void EmitOMPAllocateDecl(const OMPAllocateDecl *D)
Emit a code for the allocate directive.
This represents '#pragma omp declare mapper ...' directive.
CodeGenTypes & getTypes()
Address createCleanupActiveFlag()
static constexpr Variable var(Literal L)
Returns the variable of L.
void EmitAutoVarInit(const AutoVarEmission &emission)
const BlockByrefInfo & getBlockByrefInfo(const VarDecl *var)
BuildByrefInfo - This routine changes a __block variable declared as T x into:
bool isLocalVarDecl() const
Returns true for local variable declarations other than parameters.
VlaSizePair getVLASize(const VariableArrayType *vla)
Returns an LLVM value that corresponds to the size, in non-variably-sized elements,...
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
static llvm::Constant * constStructWithPadding(CodeGenModule &CGM, IsPattern isPattern, llvm::StructType *STy, llvm::Constant *constant)
Helper function for constWithPadding() to deal with padding in structures.
static void drillIntoBlockVariable(CodeGenFunction &CGF, LValue &lvalue, const VarDecl *var)
AutoVarEmission EmitAutoVarAlloca(const VarDecl &var)
EmitAutoVarAlloca - Emit the alloca and debug information for a local variable.
llvm::GlobalVariable * AddInitializerToStaticVarDecl(const VarDecl &D, llvm::GlobalVariable *GV)
AddInitializerToStaticVarDecl - Add the initializer for 'D' to the global variable that has already b...
ASTContext & getContext() const
@ NormalCleanup
Denotes a cleanup that should run when a scope is exited using normal control flow (falling off the e...
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...
llvm::LoadInst * CreateFlagLoad(llvm::Value *Addr, const llvm::Twine &Name="")
Emit a load from an i1 flag variable.
void enterByrefCleanup(CleanupKind Kind, Address Addr, BlockFieldFlags Flags, bool LoadBlockVarAddr, bool CanThrow)
Enter a cleanup to destroy a __block variable.
bool isParamDestroyedInCallee() const
CleanupKind getARCCleanupKind()
Retrieves the default cleanup kind for an ARC cleanup.
ConditionalCleanup stores the saved form of its parameters, then restores them and performs the clean...
SanitizerSet SanOpts
Sanitizers enabled for this function.
static TypeEvaluationKind getEvaluationKind(QualType T)
getEvaluationKind - Return the TypeEvaluationKind of QualType T.
void EmitAtomicInit(Expr *E, LValue lvalue)
const AstTypeMatcher< ArrayType > arrayType
Matches all kinds of arrays.
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
static llvm::Constant * constWithPadding(CodeGenModule &CGM, IsPattern isPattern, llvm::Constant *constant)
Replace all padding bytes in a given constant with either a pattern byte or 0x00.
@ OCL_Autoreleasing
Assigning into this object requires a lifetime extension.
static CGCallee forDirect(llvm::Constant *functionPtr, const CGCalleeInfo &abstractInfo=CGCalleeInfo())
bool Null(InterpState &S, CodePtr OpPC)
llvm::Value * EmitARCRetainScalarExpr(const Expr *expr)
EmitARCRetainScalarExpr - Semantically equivalent to EmitARCRetainObject(e->getType(),...
bool isTrivialInitializer(const Expr *Init)
Determine whether the given initializer is trivial in the sense that it requires no code to be genera...
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
VarBypassDetector Bypasses
Qualifiers::ObjCLifetime getObjCLifetime() const
static Destroyer destroyARCStrongImprecise
LangAS
Defines the address space values used by the address space qualifier of QualType.
static bool ContainsLabel(const Stmt *S, bool IgnoreCaseStmts=false)
ContainsLabel - Return true if the statement contains a label in it.
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
const llvm::DataLayout & getDataLayout() const
const T * castAs() const
Member-template castAs<specific type>.
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
llvm::Constant * initializationPatternFor(CodeGenModule &, llvm::Type *)
LValue - This represents an lvalue references.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
const TargetCodeGenInfo & getTargetHooks() const
LValue EmitDeclRefLValue(const DeclRefExpr *E)
void EmitCXXGuardedInit(const VarDecl &D, llvm::GlobalVariable *DeclPtr, bool PerformInit)
Emit code in this function to perform a guarded variable initialization.
void setStaticLocalDeclAddress(const VarDecl *D, llvm::Constant *C)
llvm::Value * getPointer() const
void ErrorUnsupported(const Stmt *S, const char *Type)
Print out an error that codegen doesn't support the specified stmt yet.
static void emitStoresForConstant(CodeGenModule &CGM, const VarDecl &D, Address Loc, bool isVolatile, CGBuilderTy &Builder, llvm::Constant *constant, bool IsAutoInit)
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
CharUnits getDeclAlign(const Decl *D, bool ForAlignof=false) const
Return a conservative estimate of the alignment of the specified decl D.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
const internal::VariadicDynCastAllOfMatcher< Stmt, CastExpr > castExpr
Matches any cast nodes of Clang's AST.
void pushDestroy(QualType::DestructionKind dtorKind, Address addr, QualType type)
pushDestroy - Push the standard destructor for the given type as at least a normal cleanup.
static bool shouldSplitConstantStore(CodeGenModule &CGM, uint64_t GlobalByteSize)
Decide whether we want to split a constant structure or array store into a sequence of its fields' st...
virtual void processRequiresDirective(const OMPRequiresDecl *D)
Perform check on requires decl to ensure that target architecture supports unified addressing.
bool hasFlexibleArrayInit(const ASTContext &Ctx) const
Whether this variable has a flexible array member initialized with one or more elements.
void EmitParmDecl(const VarDecl &D, ParamValue Arg, unsigned ArgNo)
EmitParmDecl - Emit a ParmVarDecl or an ImplicitParamDecl.
void EmitARCMoveWeak(Address dst, Address src)
void @objc_moveWeak(i8** dest, i8** src) Disregards the current value in dest.
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.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
bool isConstant(const ASTContext &Ctx) const
This class organizes the cross-function state that is used while generating LLVM code.
Address withPointer(llvm::Value *NewPointer) const
Return address with different pointer, but same element type and alignment.
@ DK_objc_strong_lifetime
void EmitARCRelease(llvm::Value *value, ARCPreciseLifetime_t precise)
Release the given object.
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
ComplexPairTy EmitComplexExpr(const Expr *E, bool IgnoreReal=false, bool IgnoreImag=false)
EmitComplexExpr - Emit the computation of the specified expression of complex type,...
void EmitOMPDeclareReduction(const OMPDeclareReductionDecl *D, CodeGenFunction *CGF=nullptr)
Emit a code for declare reduction construct.
void EmitScalarInit(const Expr *init, const ValueDecl *D, LValue lvalue, bool capturedByInit)
@ ThreadPrivateVar
Parameter for Thread private variable.
Decl - This represents one declaration (or definition), e.g.
void EmitAggExpr(const Expr *E, AggValueSlot AS)
EmitAggExpr - Emit the computation of the specified expression of aggregate type.
static ApplyDebugLocation CreateDefaultArtificial(CodeGenFunction &CGF, SourceLocation TemporaryLocation)
Apply TemporaryLocation if it is valid.
static llvm::Constant * patternOrZeroFor(CodeGenModule &CGM, IsPattern isPattern, llvm::Type *Ty)
Generate a constant filled with either a pattern or zeroes.
static AggValueSlot forLValue(const LValue &LV, CodeGenFunction &CGF, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, IsAliased_t isAliased, Overlap_t mayOverlap, IsZeroed_t isZeroed=IsNotZeroed, IsSanitizerChecked_t isChecked=IsNotSanitizerChecked)
bool isObjCGCWeak() const
true when Type is objc's weak.
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...
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
bool isConstantSizeType() const
Return true if this is not a variable sized type, according to the rules of C99 6....
llvm::Type * ConvertType(QualType T)
bool hasReducedDebugInfo() const
Check if type and variable info should be emitted.
llvm::Type * getElementType() const
Return the type of the values stored in this address.
const Expr * getInit() const
LValue MakeAddrLValue(Address Addr, QualType T, AlignmentSource Source=AlignmentSource::Type)
One of these records is kept for each identifier that is lexed.
llvm::Value * getPointer(CodeGenFunction &CGF) const
llvm::Constant * getNullPointer(llvm::PointerType *T, QualType QT)
Get target specific null pointer.
static void emitStoresForPatternInit(CodeGenModule &CGM, const VarDecl &D, Address Loc, bool isVolatile, CGBuilderTy &Builder)
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...
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...
llvm::Value * EmitScalarExpr(const Expr *E, bool IgnoreResultAssign=false)
EmitScalarExpr - Emit the computation of the specified expression of LLVM scalar type,...
static Destroyer destroyNonTrivialCStruct
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...
bool supportsCOMDAT() const
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.
CGFunctionInfo - Class to encapsulate the information about a function definition.
bool isARCPseudoStrong() const
Determine whether this variable is an ARC pseudo-__strong variable.
void setBlockContextParameter(const ImplicitParamDecl *D, unsigned argNum, llvm::Value *ptr)
llvm::Value * EmitLifetimeStart(llvm::TypeSize Size, llvm::Value *Addr)
Emit a lifetime.begin marker if some criteria are satisfied.
void EmitStoreOfComplex(ComplexPairTy V, LValue dest, bool isInit)
EmitStoreOfComplex - Store a complex number into the specified l-value.
@ OCL_None
There is no lifetime qualification on this type.
void EmitVarAnnotations(const VarDecl *D, llvm::Value *V)
Emit local annotations for the local variable V, declared by D.
static Address getAddressOfLocalVariable(CodeGenFunction &CGF, const VarDecl *VD)
Gets the OpenMP-specific address of the local variable /p VD.
virtual void emitUserDefinedReduction(CodeGenFunction *CGF, const OMPDeclareReductionDecl *D)
Emit code for the specified user defined reduction construct.
static bool cxxDestructorCanThrow(QualType T)
Check if T is a C++ class that has a destructor that can throw.
static llvm::Constant * replaceUndef(CodeGenModule &CGM, IsPattern isPattern, llvm::Constant *constant)
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
static RValue get(llvm::Value *V)
llvm::Value * getAnyValue() const
ObjCLifetime getObjCLifetime() const
Stmt - This represents one statement.
Address getIndirectAddress() const
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
void emitUserDefinedMapper(const OMPDeclareMapperDecl *D, CodeGenFunction *CGF=nullptr)
Emit the function for the user defined mapper construct.
void setLocation(SourceLocation Loc)
Update the current source location.
llvm::IntegerType * IntPtrTy
llvm::Function * getLLVMLifetimeEndFn()
Lazily declare the @llvm.lifetime.end intrinsic.
static bool tryEmitARCCopyWeakInit(CodeGenFunction &CGF, const LValue &destLV, const Expr *init)
const CGFunctionInfo & arrangeFunctionDeclaration(const FunctionDecl *FD)
Free functions are functions that are compatible with an ordinary C function pointer type.
__device__ __2f16 float bool s
This represents '#pragma omp requires...' directive.
bool CurFuncIsThunk
In C++, whether we are code generating a thunk.
Address ReturnValuePointer
ReturnValuePointer - The temporary alloca to hold a pointer to sret.
llvm::Value * getSizeForLifetimeMarkers() const
void registerVLASizeExpression(QualType Ty, llvm::Metadata *SizeExpr)
Register VLA size expression debug node with the qualified type.
static std::string getStaticDeclName(CodeGenModule &CGM, const VarDecl &D)
stable_iterator stable_begin() const
Create a stable reference to the top of the EH stack.
void Destroyer(CodeGenFunction &CGF, Address addr, QualType ty)
void EmitAutoVarCleanups(const AutoVarEmission &emission)
llvm::GlobalValue::LinkageTypes getLLVMLinkageVarDefinition(const VarDecl *VD, bool IsConstant)
Returns LLVM linkage for a declarator.
const Decl * getDecl() const
void EmitStaticVarDecl(const VarDecl &D, llvm::GlobalValue::LinkageTypes Linkage)
StringRef getBlockMangledName(GlobalDecl GD, const BlockDecl *BD)
LValue EmitLValue(const Expr *E)
EmitLValue - Emit code to compute a designator that specifies the location of the expression.
void EmitARCInitWeak(Address addr, llvm::Value *value)
i8* @objc_initWeak(i8** addr, i8* value) Returns value.
RecordDecl * getDecl() const
QualType::DestructionKind needsDestruction(const ASTContext &Ctx) const
Would the destruction of this variable have any effect, and if so, what kind?
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
virtual llvm::Value * performAddrSpaceCast(CodeGen::CodeGenFunction &CGF, llvm::Value *V, LangAS SrcAddr, LangAS DestAddr, llvm::Type *DestTy, bool IsNonNull=false) const
Perform address space cast of an expression of pointer type.
void pushStackRestore(CleanupKind kind, Address SPMem)
static const NamedDecl * getDefinition(const Decl *D)
CharUnits - This is an opaque type for sizes expressed in character units.
bool IsBypassed(const VarDecl *D) const
Returns true if the variable declaration was by bypassed by any goto or switch statement.
void EmitDecl(const Decl &D)
EmitDecl - Emit a declaration.
Allows to disable automatic handling of functions used in target regions as those marked as omp decla...
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...
This represents one expression.
void setGVProperties(llvm::GlobalValue *GV, GlobalDecl GD) const
Set visibility, dllimport/dllexport and dso_local.
A use of a default initializer in a constructor or in aggregate initialization.
bool hasLocalStorage() const
Returns true if a variable with function scope is a non-static local variable.
llvm::IntegerType * Int8Ty
i8, i16, i32, and i64
llvm::Function * getLLVMLifetimeStartFn()
Lazily declare the @llvm.lifetime.start intrinsic.
llvm::Function * getIntrinsic(unsigned IID, ArrayRef< llvm::Type * > Tys=None)
bool isInConditionalBranch() const
isInConditionalBranch - Return true if we're currently emitting one branch or the other of a conditio...
@ NonNull
Values of this type can never be null.
bool isExceptionVariable() const
Determine whether this variable is the exception variable in a C++ catch statememt or an Objective-C ...
SourceLocation getLocation() const
CallArgList - Type for representing both the value and type of arguments in a call.
A reference to a declared variable, function, enum, etc.
llvm::CallInst * CreateMemSet(Address Dest, llvm::Value *Value, llvm::Value *Size, bool IsVolatile=false)
static llvm::Value * shouldUseMemSetToInitialize(llvm::Constant *Init, uint64_t GlobalSize, const llvm::DataLayout &DL)
Decide whether we should use memset to initialize a local variable instead of using a memcpy from a c...
Represents a function declaration or definition.
void setTLSMode(llvm::GlobalValue *GV, const VarDecl &D) const
Set the TLS mode for the given LLVM GlobalValue for the thread-local variable declaration D.
void finalize(llvm::GlobalVariable *global)
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
EmitBlock - Emit the given block.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
SanitizerMetadata * getSanitizerMetadata()
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,...
LangAS getASTAllocaAddressSpace() const
Represents a call to a C++ constructor.
const LangOptions & getLangOpts() const
llvm::LLVMContext & getLLVMContext()
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
const LangOptions & getLangOpts() const
void EmitOMPRequiresDecl(const OMPRequiresDecl *D)
Emit a code for requires directive.
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...
llvm::Constant * EmitCheckTypeDescriptor(QualType T)
Emit a description of a type in a format suitable for passing to a runtime sanitizer handler.
llvm::LoadInst * CreateLoad(Address Addr, const llvm::Twine &Name="")
void setNonGC(bool Value)
DominatingValue< T >::saved_type saveValueInCond(T value)
Address ReturnValue
ReturnValue - The temporary alloca to hold the return value.
DeclContext * getDeclContext()
void EmitExtendGCLifetime(llvm::Value *object)
EmitExtendGCLifetime - Given a pointer to an Objective-C object, make sure it survives garbage collec...
llvm::Value * EmitARCRetainAutoreleaseScalarExpr(const Expr *expr)
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.