14 #ifndef LLVM_CLANG_LIB_CODEGEN_CODEGENFUNCTION_H 15 #define LLVM_CLANG_LIB_CODEGEN_CODEGENFUNCTION_H 35 #include "llvm/ADT/ArrayRef.h" 36 #include "llvm/ADT/DenseMap.h" 37 #include "llvm/ADT/MapVector.h" 38 #include "llvm/ADT/SmallVector.h" 39 #include "llvm/IR/ValueHandle.h" 40 #include "llvm/Support/Debug.h" 41 #include "llvm/Transforms/Utils/SanitizerStats.h" 57 class CXXDestructorDecl;
58 class CXXForRangeStmt;
62 class EnumConstantDecl;
64 class FunctionProtoType;
66 class ObjCContainerDecl;
67 class ObjCInterfaceDecl;
70 class ObjCImplementationDecl;
71 class ObjCPropertyImplDecl;
74 class ObjCForCollectionStmt;
76 class ObjCAtThrowStmt;
77 class ObjCAtSynchronizedStmt;
78 class ObjCAutoreleasePoolStmt;
80 namespace analyze_os_log {
81 class OSLogBufferLayout;
91 class BlockByrefHelpers;
94 class BlockFieldFlags;
95 class RegionCodeGenTy;
96 class TargetCodeGenInfo;
111 #define LIST_SANITIZER_CHECKS \ 112 SANITIZER_CHECK(AddOverflow, add_overflow, 0) \ 113 SANITIZER_CHECK(BuiltinUnreachable, builtin_unreachable, 0) \ 114 SANITIZER_CHECK(CFICheckFail, cfi_check_fail, 0) \ 115 SANITIZER_CHECK(DivremOverflow, divrem_overflow, 0) \ 116 SANITIZER_CHECK(DynamicTypeCacheMiss, dynamic_type_cache_miss, 0) \ 117 SANITIZER_CHECK(FloatCastOverflow, float_cast_overflow, 0) \ 118 SANITIZER_CHECK(FunctionTypeMismatch, function_type_mismatch, 0) \ 119 SANITIZER_CHECK(ImplicitConversion, implicit_conversion, 0) \ 120 SANITIZER_CHECK(InvalidBuiltin, invalid_builtin, 0) \ 121 SANITIZER_CHECK(LoadInvalidValue, load_invalid_value, 0) \ 122 SANITIZER_CHECK(MissingReturn, missing_return, 0) \ 123 SANITIZER_CHECK(MulOverflow, mul_overflow, 0) \ 124 SANITIZER_CHECK(NegateOverflow, negate_overflow, 0) \ 125 SANITIZER_CHECK(NullabilityArg, nullability_arg, 0) \ 126 SANITIZER_CHECK(NullabilityReturn, nullability_return, 1) \ 127 SANITIZER_CHECK(NonnullArg, nonnull_arg, 0) \ 128 SANITIZER_CHECK(NonnullReturn, nonnull_return, 1) \ 129 SANITIZER_CHECK(OutOfBounds, out_of_bounds, 0) \ 130 SANITIZER_CHECK(PointerOverflow, pointer_overflow, 0) \ 131 SANITIZER_CHECK(ShiftOutOfBounds, shift_out_of_bounds, 0) \ 132 SANITIZER_CHECK(SubOverflow, sub_overflow, 0) \ 133 SANITIZER_CHECK(TypeMismatch, type_mismatch, 1) \ 134 SANITIZER_CHECK(AlignmentAssumption, alignment_assumption, 0) \ 135 SANITIZER_CHECK(VLABoundNotPositive, vla_bound_not_positive, 0) 138 #define SANITIZER_CHECK(Enum, Name, Version) Enum, 140 #undef SANITIZER_CHECK 146 typedef llvm::PointerIntPair<llvm::Value*, 1, bool>
saved_type;
151 if (!isa<llvm::Instruction>(value))
return false;
154 llvm::BasicBlock *block = cast<llvm::Instruction>(value)->getParent();
155 return (block != &block->getParent()->getEntryBlock());
167 return static_cast<T*
>(DominatingLLVMValue::restore(CGF, value));
181 return DominatingLLVMValue::needsSaving(value.
getPointer());
184 return { DominatingLLVMValue::save(CGF, value.
getPointer()),
188 return Address(DominatingLLVMValue::restore(CGF, value.SavedValue),
197 enum Kind { ScalarLiteral, ScalarAddress, AggregateLiteral,
198 AggregateAddress, ComplexAddress };
204 :
Value(v), K(k), Align(a) {}
207 static bool needsSaving(
RValue value);
215 return saved_type::needsSaving(value);
218 return saved_type::save(CGF, value);
221 return value.restore(CGF);
236 JumpDest() : Block(nullptr), ScopeDepth(), Index(0) {}
240 : Block(Block), ScopeDepth(Depth), Index(Index) {}
242 bool isValid()
const {
return Block !=
nullptr; }
243 llvm::BasicBlock *
getBlock()
const {
return Block; }
253 llvm::BasicBlock *Block;
274 const unsigned,
const bool)>
278 typedef llvm::function_ref<std::pair<LValue, LValue>(
283 typedef llvm::function_ref<std::pair<llvm::Value *, llvm::Value *>(
290 void InsertHelper(llvm::Instruction *I,
const llvm::Twine &Name,
291 llvm::BasicBlock *BB,
292 llvm::BasicBlock::iterator InsertPt)
const;
301 llvm::Function *CurFn =
nullptr;
307 std::unique_ptr<CGCoroData>
Data;
314 return CurCoro.
Data !=
nullptr;
334 return CurLexicalScope->hasLabels();
335 return !LabelMap.empty();
346 :
Kind(K), ThisValue(nullptr), CXXThisFieldDecl(nullptr) {}
349 :
Kind(K), ThisValue(nullptr), CXXThisFieldDecl(nullptr) {
355 I != E; ++I, ++Field) {
356 if (I->capturesThis())
357 CXXThisFieldDecl = *Field;
358 else if (I->capturesVariable())
359 CaptureFields[I->getCapturedVar()->getCanonicalDecl()] = *Field;
360 else if (I->capturesVariableByCopy())
361 CaptureFields[I->getCapturedVar()->getCanonicalDecl()] = *Field;
399 llvm::SmallDenseMap<const VarDecl *, FieldDecl *> CaptureFields;
413 CodeGenFunction &CGF;
418 : CGF(CGF), PrevCapturedStmtInfo(CGF.CapturedStmtInfo) {
427 const Decl *CalleeDecl;
434 return dyn_cast_or_null<FunctionDecl>(CalleeDecl);
438 if (
const auto *FD = dyn_cast<FunctionDecl>(CalleeDecl))
439 return FD->getNumParams();
440 return cast<ObjCMethodDecl>(CalleeDecl)->param_size();
443 if (
const auto *FD = dyn_cast<FunctionDecl>(CalleeDecl))
444 return FD->getParamDecl(I);
445 return *(cast<ObjCMethodDecl>(CalleeDecl)->param_begin() + I);
453 bool IsSanitizerScope =
false;
457 CodeGenFunction *CGF;
465 bool CurFuncIsThunk =
false;
468 bool AutoreleaseResult =
false;
472 bool SawAsmBlock =
false;
478 bool IsOutlinedSEHHelper =
false;
488 llvm::DenseMap<const VarDecl *, llvm::Value *>
NRVOFlags;
494 llvm::Instruction *CurrentFuncletPad =
nullptr;
502 : Addr(addr.getPointer()), Size(size) {}
524 Address NormalCleanupDest = Address::invalid();
526 unsigned NextCleanupDestIndex = 1;
532 llvm::BasicBlock *EHResumeBlock =
nullptr;
540 llvm::AllocaInst *EHSelectorSlot =
nullptr;
551 llvm::BasicBlock *EmitLandingPad();
553 llvm::BasicBlock *getInvokeDestImpl();
571 llvm::Constant *BeginCatchFn;
575 llvm::AllocaInst *ForEHVar;
579 llvm::AllocaInst *SavedExnVar;
582 void enter(CodeGenFunction &CGF,
const Stmt *Finally,
583 llvm::Constant *beginCatchFn, llvm::Constant *endCatchFn,
584 llvm::Constant *rethrowFn);
585 void exit(CodeGenFunction &CGF);
593 return CurrentFuncletPad && isa<llvm::CleanupPadInst>(CurrentFuncletPad);
599 template <
class T,
class... As>
603 if (!isInConditionalBranch())
604 return EHStack.pushCleanup<T>(
kind, A...);
607 typedef std::tuple<typename DominatingValue<As>::saved_type...> SavedTuple;
608 SavedTuple Saved{saveValueInCond(A)...};
612 initFullExprCleanup();
617 template <
class T,
class... As>
619 if (!isInConditionalBranch())
620 return pushCleanupAfterFullExprImpl<T>(
Kind, Address::invalid(), A...);
622 Address ActiveFlag = createCleanupActiveFlag();
624 "cleanup active flag should never need saving");
626 typedef std::tuple<typename DominatingValue<As>::saved_type...> SavedTuple;
627 SavedTuple Saved{saveValueInCond(A)...};
630 pushCleanupAfterFullExprImpl<CleanupType>(
Kind, ActiveFlag, Saved);
633 template <
class T,
class... As>
639 size_t OldSize = LifetimeExtendedCleanupStack.size();
640 LifetimeExtendedCleanupStack.resize(
641 LifetimeExtendedCleanupStack.size() +
sizeof(Header) + Header.
Size +
644 static_assert(
sizeof(Header) %
alignof(T) == 0,
645 "Cleanup will be allocated on misaligned address");
646 char *Buffer = &LifetimeExtendedCleanupStack[OldSize];
648 new (Buffer +
sizeof(Header)) T(A...);
650 new (Buffer +
sizeof(Header) +
sizeof(T))
Address(ActiveFlag);
656 initFullExprCleanupWithFlag(createCleanupActiveFlag());
659 void initFullExprCleanupWithFlag(
Address ActiveFlag);
660 Address createCleanupActiveFlag();
675 void PopCleanupBlock(
bool FallThroughIsBranchThrough =
false);
686 llvm::Instruction *DominatingIP);
696 llvm::Instruction *DominatingIP);
702 size_t LifetimeExtendedCleanupStackSize;
703 bool OldDidCallStackSave;
717 : PerformCleanup(
true), CGF(CGF)
720 LifetimeExtendedCleanupStackSize =
722 OldDidCallStackSave = CGF.DidCallStackSave;
723 CGF.DidCallStackSave =
false;
745 void ForceCleanup(std::initializer_list<llvm::Value**> ValuesToReload = {}) {
746 assert(PerformCleanup &&
"Already forced cleanup");
747 CGF.DidCallStackSave = OldDidCallStackSave;
750 PerformCleanup =
false;
757 EHScopeStack::stable_end();
771 CGF.CurLexicalScope =
this;
777 assert(PerformCleanup &&
"adding label to dead scope?");
778 Labels.push_back(label);
789 if (PerformCleanup) {
798 CGF.CurLexicalScope = ParentScope;
799 RunCleanupsScope::ForceCleanup();
806 return !Labels.empty();
809 void rescopeLabels();
812 typedef llvm::DenseMap<const Decl *, Address>
DeclMapTy;
816 DeclMapTy SavedLocals;
817 DeclMapTy SavedTempAddresses;
824 assert(SavedLocals.empty() &&
"Did not restored original addresses.");
834 if (SavedLocals.count(LocalVD))
return false;
837 auto it = CGF.LocalDeclMap.find(LocalVD);
838 if (it != CGF.LocalDeclMap.end())
839 SavedLocals.try_emplace(LocalVD, it->second);
841 SavedLocals.try_emplace(LocalVD, Address::invalid());
850 SavedTempAddresses.try_emplace(LocalVD, TempAddr);
859 copyInto(SavedTempAddresses, CGF.LocalDeclMap);
860 SavedTempAddresses.clear();
861 return !SavedLocals.empty();
866 if (!SavedLocals.empty()) {
867 copyInto(SavedLocals, CGF.LocalDeclMap);
875 static void copyInto(
const DeclMapTy &Src, DeclMapTy &Dest) {
876 for (
auto &Pair : Src) {
877 if (!Pair.second.isValid()) {
878 Dest.erase(Pair.first);
882 auto I = Dest.find(Pair.first);
884 I->second = Pair.second;
909 const llvm::function_ref<
Address()> PrivateGen) {
910 assert(PerformCleanup &&
"adding private to dead scope");
911 return MappedVars.
setVarAddr(CGF, LocalVD, PrivateGen());
925 RunCleanupsScope::ForceCleanup();
946 std::initializer_list<llvm::Value **> ValuesToReload = {});
953 size_t OldLifetimeExtendedStackSize,
954 std::initializer_list<llvm::Value **> ValuesToReload = {});
956 void ResolveBranchFixups(llvm::BasicBlock *Target);
964 NextCleanupDestIndex++);
971 return getJumpDestInCurrentScope(createBasicBlock(Name));
977 void EmitBranchThroughCleanup(
JumpDest Dest);
982 bool isObviouslyBranchWithoutCleanups(
JumpDest Dest)
const;
987 void popCatchScope();
989 llvm::BasicBlock *getEHResumeBlock(
bool isCleanup);
996 llvm::BasicBlock *StartBB;
1000 : StartBB(CGF.Builder.GetInsertBlock()) {}
1003 assert(CGF.OutermostConditional !=
this);
1004 if (!CGF.OutermostConditional)
1005 CGF.OutermostConditional =
this;
1008 void end(CodeGenFunction &CGF) {
1009 assert(CGF.OutermostConditional !=
nullptr);
1010 if (CGF.OutermostConditional ==
this)
1011 CGF.OutermostConditional =
nullptr;
1026 assert(isInConditionalBranch());
1027 llvm::BasicBlock *block = OutermostConditional->getStartingBlock();
1028 auto store =
new llvm::StoreInst(value, addr.
getPointer(), &block->back());
1035 CodeGenFunction &CGF;
1044 : CGF(CGF), SavedOutermostConditional(CGF.OutermostConditional) {
1045 CGF.OutermostConditional =
nullptr;
1049 CGF.OutermostConditional = SavedOutermostConditional;
1058 llvm::Instruction *Inst;
1059 friend class CodeGenFunction;
1078 : OpaqueValue(ov), BoundLValue(boundLValue) {}
1090 hasAggregateEvaluationKind(expr->
getType());
1096 if (shouldBindAsLValue(ov))
1104 assert(shouldBindAsLValue(ov));
1105 CGF.OpaqueLValues.insert(std::make_pair(ov, lv));
1112 assert(!shouldBindAsLValue(ov));
1113 CGF.OpaqueRValues.insert(std::make_pair(ov, rv));
1125 bool isValid()
const {
return OpaqueValue !=
nullptr; }
1129 assert(OpaqueValue &&
"no data to unbind!");
1132 CGF.OpaqueLValues.erase(OpaqueValue);
1134 CGF.OpaqueRValues.erase(OpaqueValue);
1142 CodeGenFunction &CGF;
1147 return OpaqueValueMappingData::shouldBindAsLValue(expr);
1157 if (isa<ConditionalOperator>(op))
1171 assert(OV->
getSourceExpr() &&
"wrong form of OpaqueValueMapping used " 1172 "for OVE with no source expression");
1173 Data = OpaqueValueMappingData::bind(CGF, OV, OV->
getSourceExpr());
1202 unsigned VLAExprCounter = 0;
1203 bool DisableDebugInfo =
false;
1207 bool DidCallStackSave =
false;
1213 llvm::IndirectBrInst *IndirectBranch =
nullptr;
1217 DeclMapTy LocalDeclMap;
1221 llvm::DenseMap<const ParmVarDecl *, EHScopeStack::stable_iterator>
1222 CalleeDestructedParamCleanups;
1227 llvm::SmallDenseMap<const ParmVarDecl *, const ImplicitParamDecl *, 2>
1232 llvm::DenseMap<llvm::AllocaInst *, int> EscapedLocals;
1235 llvm::DenseMap<const LabelDecl*, JumpDest> LabelMap;
1239 struct BreakContinue {
1241 : BreakBlock(Break), ContinueBlock(Continue) {}
1249 class OpenMPCancelExitStack {
1253 CancelExit() =
default;
1256 :
Kind(Kind), ExitBlock(ExitBlock), ContBlock(ContBlock) {}
1260 bool HasBeenEmitted =
false;
1268 OpenMPCancelExitStack() : Stack(1) {}
1269 ~OpenMPCancelExitStack() =
default;
1271 JumpDest getExitBlock()
const {
return Stack.back().ExitBlock; }
1275 const llvm::function_ref<
void(CodeGenFunction &)> CodeGen) {
1276 if (Stack.back().Kind == Kind && getExitBlock().isValid()) {
1279 assert(!Stack.back().HasBeenEmitted);
1280 auto IP = CGF.
Builder.saveAndClearIP();
1281 CGF.
EmitBlock(Stack.back().ExitBlock.getBlock());
1283 CGF.
EmitBranch(Stack.back().ContBlock.getBlock());
1285 Stack.back().HasBeenEmitted =
true;
1294 Stack.push_back({
Kind,
1302 void exit(CodeGenFunction &CGF) {
1303 if (getExitBlock().isValid()) {
1306 if (!Stack.back().HasBeenEmitted) {
1309 CGF.
EmitBlock(Stack.back().ExitBlock.getBlock());
1312 CGF.
EmitBlock(Stack.back().ContBlock.getBlock());
1314 CGF.
Builder.CreateUnreachable();
1315 CGF.
Builder.ClearInsertionPoint();
1321 OpenMPCancelExitStack OMPCancelStack;
1326 llvm::MDNode *createProfileWeights(uint64_t TrueCount, uint64_t FalseCount);
1328 llvm::MDNode *createProfileWeightsForLoop(
const Stmt *Cond,
1329 uint64_t LoopCount);
1343 if (!Count.hasValue())
1363 llvm::SwitchInst *SwitchInsn =
nullptr;
1369 llvm::BasicBlock *CaseRangeBlock =
nullptr;
1373 llvm::DenseMap<const OpaqueValueExpr *, LValue> OpaqueLValues;
1374 llvm::DenseMap<const OpaqueValueExpr *, RValue> OpaqueRValues;
1382 llvm::DenseMap<const Expr*, llvm::Value*> VLASizeMap;
1386 llvm::BasicBlock *UnreachableBlock =
nullptr;
1389 unsigned NumReturnExprs = 0;
1392 unsigned NumSimpleReturnExprs = 0;
1404 : CGF(CGF), OldCXXDefaultInitExprThis(CGF.CXXDefaultInitExprThis) {
1405 CGF.CXXDefaultInitExprThis = This;
1408 CGF.CXXDefaultInitExprThis = OldCXXDefaultInitExprThis;
1412 CodeGenFunction &CGF;
1413 Address OldCXXDefaultInitExprThis;
1421 : CGF(CGF), OldCXXThisValue(CGF.CXXThisValue),
1422 OldCXXThisAlignment(CGF.CXXThisAlignment) {
1423 CGF.CXXThisValue = CGF.CXXDefaultInitExprThis.
getPointer();
1424 CGF.CXXThisAlignment = CGF.CXXDefaultInitExprThis.
getAlignment();
1427 CGF.CXXThisValue = OldCXXThisValue;
1428 CGF.CXXThisAlignment = OldCXXThisAlignment;
1442 : CGF(CGF), OldArrayInitIndex(CGF.ArrayInitIndex) {
1443 CGF.ArrayInitIndex = Index;
1446 CGF.ArrayInitIndex = OldArrayInitIndex;
1450 CodeGenFunction &CGF;
1457 : CGF(CGF), OldCurGD(CGF.CurGD), OldCurFuncDecl(CGF.CurFuncDecl),
1458 OldCurCodeDecl(CGF.CurCodeDecl),
1459 OldCXXABIThisDecl(CGF.CXXABIThisDecl),
1460 OldCXXABIThisValue(CGF.CXXABIThisValue),
1461 OldCXXThisValue(CGF.CXXThisValue),
1462 OldCXXABIThisAlignment(CGF.CXXABIThisAlignment),
1463 OldCXXThisAlignment(CGF.CXXThisAlignment),
1464 OldReturnValue(CGF.ReturnValue), OldFnRetTy(CGF.FnRetTy),
1465 OldCXXInheritedCtorInitExprArgs(
1466 std::move(CGF.CXXInheritedCtorInitExprArgs)) {
1469 cast<CXXConstructorDecl>(GD.
getDecl());
1470 CGF.CXXABIThisDecl =
nullptr;
1471 CGF.CXXABIThisValue =
nullptr;
1472 CGF.CXXThisValue =
nullptr;
1477 CGF.CXXInheritedCtorInitExprArgs.clear();
1480 CGF.
CurGD = OldCurGD;
1483 CGF.CXXABIThisDecl = OldCXXABIThisDecl;
1484 CGF.CXXABIThisValue = OldCXXABIThisValue;
1485 CGF.CXXThisValue = OldCXXThisValue;
1486 CGF.CXXABIThisAlignment = OldCXXABIThisAlignment;
1487 CGF.CXXThisAlignment = OldCXXThisAlignment;
1490 CGF.CXXInheritedCtorInitExprArgs =
1491 std::move(OldCXXInheritedCtorInitExprArgs);
1495 CodeGenFunction &CGF;
1497 const Decl *OldCurFuncDecl;
1498 const Decl *OldCurCodeDecl;
1520 Address CXXDefaultInitExprThis = Address::invalid();
1533 llvm::Value *CXXStructorImplicitParamValue =
nullptr;
1549 llvm::DenseMap<const ValueDecl *, BlockByrefInfo> BlockByrefInfos;
1553 llvm::Value *RetValNullabilityPrecondition =
nullptr;
1557 bool requiresReturnValueNullabilityCheck()
const {
1558 return RetValNullabilityPrecondition;
1563 Address ReturnLocation = Address::invalid();
1566 bool requiresReturnValueCheck()
const {
1567 return requiresReturnValueNullabilityCheck() ||
1568 (SanOpts.
has(SanitizerKind::ReturnsNonnullAttribute) &&
1569 CurCodeDecl && CurCodeDecl->
getAttr<ReturnsNonNullAttr>());
1572 llvm::BasicBlock *TerminateLandingPad =
nullptr;
1573 llvm::BasicBlock *TerminateHandler =
nullptr;
1574 llvm::BasicBlock *TrapBB =
nullptr;
1577 llvm::MapVector<llvm::Value *, llvm::BasicBlock *> TerminateFunclets;
1581 unsigned LargestVectorWidth = 0;
1584 const bool ShouldEmitLifetimeMarkers;
1589 llvm::Function *Fn);
1592 CodeGenFunction(
CodeGenModule &cgm,
bool suppressNewContext=
false);
1598 if (DisableDebugInfo)
1621 Address getNormalCleanupDestSlot();
1624 if (!UnreachableBlock) {
1625 UnreachableBlock = createBasicBlock(
"unreachable");
1626 new llvm::UnreachableInst(getLLVMContext(), UnreachableBlock);
1628 return UnreachableBlock;
1633 return getInvokeDestImpl();
1650 void pushIrregularPartialArrayCleanup(
llvm::Value *arrayBegin,
1654 Destroyer *destroyer);
1655 void pushRegularPartialArrayCleanup(
llvm::Value *arrayBegin,
1659 Destroyer *destroyer);
1666 Destroyer *destroyer,
bool useEHCleanupForArray);
1669 bool useEHCleanupForArray);
1670 void pushCallObjectDeleteCleanup(
const FunctionDecl *OperatorDelete,
1675 bool useEHCleanupForArray);
1677 Destroyer *destroyer,
1678 bool useEHCleanupForArray,
1682 Destroyer *destroyer,
1683 bool checkZeroLength,
bool useEHCleanup);
1691 case QualType::DK_none:
1693 case QualType::DK_cxx_destructor:
1694 case QualType::DK_objc_weak_lifetime:
1695 case QualType::DK_nontrivial_c_struct:
1696 return getLangOpts().Exceptions;
1697 case QualType::DK_objc_strong_lifetime:
1698 return getLangOpts().Exceptions &&
1701 llvm_unreachable(
"bad destruction kind");
1722 llvm::Constant *AtomicHelperFn);
1733 llvm::Constant *AtomicHelperFn);
1746 llvm::Function *GenerateBlockFunction(
GlobalDecl GD,
1748 const DeclMapTy &ldm,
1749 bool IsLambdaConversionToBlock,
1750 bool BuildGlobalBlock);
1753 static bool cxxDestructorCanThrow(
QualType T);
1755 llvm::Constant *GenerateCopyHelperFunction(
const CGBlockInfo &blockInfo);
1756 llvm::Constant *GenerateDestroyHelperFunction(
const CGBlockInfo &blockInfo);
1757 llvm::Constant *GenerateObjCAtomicSetterCopyHelperFunction(
1759 llvm::Constant *GenerateObjCAtomicGetterCopyHelperFunction(
1787 bool LoadBlockVarAddr,
bool CanThrow);
1798 bool followForward =
true);
1802 const llvm::Twine &name);
1808 void GenerateCode(
GlobalDecl GD, llvm::Function *Fn,
1813 void markAsIgnoreThreadCheckingAtRuntime(llvm::Function *Fn);
1831 void EmitFunctionBody(
const Stmt *Body);
1832 void EmitBlockWithFallThrough(llvm::BasicBlock *BB,
const Stmt *S);
1834 void EmitForwardingCallToLambda(
const CXXMethodDecl *LambdaCallOperator,
1836 void EmitLambdaBlockInvokeBody();
1837 void EmitLambdaDelegatingInvokeBody(
const CXXMethodDecl *MD);
1839 void EmitAsanPrologueOrEpilogue(
bool Prologue);
1845 llvm::DebugLoc EmitReturnBlock();
1851 void StartThunk(llvm::Function *Fn,
GlobalDecl GD,
1854 void EmitCallAndReturnForThunk(llvm::Constant *Callee,
const ThunkInfo *Thunk,
1855 bool IsUnprototyped);
1864 void generateThunk(llvm::Function *Fn,
const CGFunctionInfo &FnInfo,
1866 bool IsUnprototyped);
1868 llvm::Function *GenerateVarArgsThunk(llvm::Function *Fn,
1886 void InitializeVTablePointer(
const VPtr &vptr);
1891 VPtrsVector getVTablePointers(
const CXXRecordDecl *VTableClass);
1895 bool BaseIsNonVirtualPrimaryBase,
1897 VisitedVirtualBasesSetTy &VBases, VPtrsVector &vptrs);
1899 void InitializeVTablePointers(
const CXXRecordDecl *ClassDecl);
1942 bool ShouldEmitVTableTypeCheckedLoad(
const CXXRecordDecl *RD);
1946 uint64_t VTableByteOffset);
1956 bool ShouldInstrumentFunction();
1960 bool ShouldXRayInstrumentFunction()
const;
1964 bool AlwaysEmitXRayCustomEvents()
const;
1968 bool AlwaysEmitXRayTypedEvents()
const;
1971 llvm::Constant *EncodeAddrForUseInPrologue(llvm::Function *F,
1972 llvm::Constant *Addr);
1988 void EmitFunctionEpilog(
const CGFunctionInfo &FI,
bool EmitRetDbgLoc,
1995 void EmitStartEHSpec(
const Decl *D);
1998 void EmitEndEHSpec(
const Decl *D);
2001 llvm::BasicBlock *getTerminateLandingPad();
2005 llvm::BasicBlock *getTerminateFunclet();
2010 llvm::BasicBlock *getTerminateHandler();
2012 llvm::Type *ConvertTypeForMem(
QualType T);
2013 llvm::Type *ConvertType(
QualType T);
2015 return ConvertType(getContext().getTypeDeclType(T));
2038 llvm::Function *parent =
nullptr,
2039 llvm::BasicBlock *before =
nullptr) {
2050 void SimplifyForwardingBlocks(llvm::BasicBlock *BB);
2060 void EmitBlock(llvm::BasicBlock *BB,
bool IsFinished=
false);
2064 void EmitBlockAfterUses(llvm::BasicBlock *BB);
2074 void EmitBranch(llvm::BasicBlock *Block);
2079 return Builder.GetInsertBlock() !=
nullptr;
2087 if (!HaveInsertPoint())
2088 EmitBlock(createBasicBlock());
2093 void ErrorUnsupported(
const Stmt *S,
const char *Type);
2101 return LValue::MakeAddr(Addr, T, getContext(),
LValueBaseInfo(Source),
2107 return LValue::MakeAddr(Addr, T, getContext(), BaseInfo, TBAAInfo);
2112 return LValue::MakeAddr(
Address(V, Alignment), T, getContext(),
2118 return LValue::MakeAddr(
Address(V, Alignment), T, getContext(),
2119 BaseInfo, TBAAInfo);
2127 bool forPointeeType =
false);
2141 return EmitLoadOfReferenceLValue(RefLVal);
2175 llvm::AllocaInst *CreateTempAlloca(llvm::Type *Ty,
const Twine &Name =
"tmp",
2178 const Twine &Name =
"tmp",
2182 const Twine &Name =
"tmp",
2195 Address CreateDefaultAlignTempAlloca(llvm::Type *Ty,
2196 const Twine &Name =
"tmp");
2227 Address CreateMemTempWithoutCast(
QualType T,
const Twine &Name =
"tmp");
2229 const Twine &Name =
"tmp");
2234 return AggValueSlot::forAddr(CreateMemTemp(T, Name),
2236 AggValueSlot::IsNotDestructed,
2237 AggValueSlot::DoesNotNeedGCBarriers,
2238 AggValueSlot::IsNotAliased,
2239 AggValueSlot::DoesNotOverlap);
2250 void EmitIgnoredExpr(
const Expr *E);
2260 bool ignoreResult =
false);
2277 void EmitAnyExprToMem(
const Expr *E,
Address Location,
2280 void EmitAnyExprToExn(
const Expr *E,
Address Addr);
2285 bool capturedByInit);
2291 const RecordDecl *RD = cast<RecordDecl>(RT->getDecl());
2302 return AggValueSlot::DoesNotOverlap;
2312 return AggValueSlot::DoesNotOverlap;
2323 bool IsVolatile = hasVolatileMember(EltTy);
2324 EmitAggregateCopy(Dest, Src, EltTy, AggValueSlot::MayOverlap, IsVolatile);
2329 EmitAggregateCopy(Dest, Src, Src.
getType(), MayOverlap);
2341 bool isVolatile =
false);
2345 auto it = LocalDeclMap.find(VD);
2346 assert(it != LocalDeclMap.end() &&
2347 "Invalid argument to GetAddrOfLocalVar(), no decl!");
2364 static unsigned getAccessedFieldNo(
unsigned Idx,
const llvm::Constant *Elts);
2366 llvm::BlockAddress *GetAddrOfLabel(
const LabelDecl *L);
2367 llvm::BasicBlock *GetIndirectGotoBlock();
2370 static bool IsWrappedCXXThis(
const Expr *E);
2405 void EmitVariablyModifiedType(
QualType Ty);
2429 assert(CXXThisValue &&
"no 'this' value for this function");
2430 return CXXThisValue;
2439 assert(CXXStructorImplicitParamValue &&
"no VTT value for this function");
2440 return CXXStructorImplicitParamValue;
2446 GetAddressOfDirectBaseInCompleteClass(
Address Value,
2449 bool BaseIsVirtual);
2451 static bool ShouldNullCheckClassCastValue(
const CastExpr *Cast);
2465 bool NullCheckValue);
2491 bool ForVirtualBase,
2499 bool ForVirtualBase,
Address This,
2500 bool InheritedFromVBase,
2504 bool ForVirtualBase,
bool Delegating,
2507 bool NewPointerIsChecked);
2510 bool ForVirtualBase,
bool Delegating,
2514 bool NewPointerIsChecked);
2521 void EmitVTableAssumptionLoad(
const VPtr &vptr,
Address This);
2531 bool NewPointerIsChecked,
2532 bool ZeroInitialization =
false);
2538 bool NewPointerIsChecked,
2539 bool ZeroInitialization =
false);
2544 bool ForVirtualBase,
bool Delegating,
2548 llvm::Type *ElementTy,
Address NewPtr,
2566 const CallExpr *TheCallExpr,
bool IsDelete);
2607 TCK_DynamicOperation
2618 bool sanitizePerformTypeCheck()
const;
2630 QualType IndexType,
bool Accessed);
2633 bool isInc,
bool isPre);
2635 bool isInc,
bool isPre);
2648 void EmitDecl(
const Decl &D);
2653 void EmitVarDecl(
const VarDecl &D);
2656 bool capturedByInit);
2663 bool isTrivialInitializer(
const Expr *Init);
2668 void EmitAutoVarDecl(
const VarDecl &D);
2671 friend class CodeGenFunction;
2685 bool IsEscapingByRef;
2689 bool IsConstantAggregate;
2700 : Variable(nullptr), Addr(
Address::invalid()),
2701 AllocaAddr(
Address::invalid()) {}
2704 : Variable(&variable), Addr(
Address::invalid()), NRVOFlag(nullptr),
2705 IsEscapingByRef(
false), IsConstantAggregate(
false),
2706 SizeForLifetimeMarkers(nullptr), AllocaAddr(
Address::invalid()) {}
2708 bool wasEmittedAsGlobal()
const {
return !Addr.
isValid(); }
2714 return SizeForLifetimeMarkers !=
nullptr;
2717 assert(useLifetimeMarkers());
2718 return SizeForLifetimeMarkers;
2735 if (!IsEscapingByRef)
return Addr;
2751 void EmitAndRegisterVariableArrayDimensions(
CGDebugInfo *DI,
2753 bool EmitDebugInfo);
2755 void EmitStaticVarDecl(
const VarDecl &D,
2756 llvm::GlobalValue::LinkageTypes
Linkage);
2775 assert(!isIndirect());
2780 assert(isIndirect());
2781 return Address(Value, CharUnits::fromQuantity(Alignment));
2806 llvm::Instruction *Assumption);
2827 void EmitStopPoint(
const Stmt *S);
2843 bool EmitSimpleStmt(
const Stmt *S);
2848 bool GetLast =
false,
2850 AggValueSlot::ignored());
2858 void EmitGotoStmt(
const GotoStmt &S);
2860 void EmitIfStmt(
const IfStmt &S);
2865 void EmitForStmt(
const ForStmt &S,
2868 void EmitDeclStmt(
const DeclStmt &S);
2873 void EmitCaseStmt(
const CaseStmt &S);
2874 void EmitCaseStmtRange(
const CaseStmt &S);
2875 void EmitAsmStmt(
const AsmStmt &S);
2887 bool ignoreResult =
false);
2891 bool ignoreResult =
false);
2893 RValue EmitCoroutineIntrinsic(
const CallExpr *E,
unsigned int IID);
2895 void EnterCXXTryStmt(
const CXXTryStmt &S,
bool IsFnTryBlock =
false);
2896 void ExitCXXTryStmt(
const CXXTryStmt &S,
bool IsFnTryBlock =
false);
2905 llvm::Function *FinallyFunc);
2906 void startOutlinedSEHHelper(CodeGenFunction &ParentCGF,
bool IsFilter,
2907 const Stmt *OutlinedStmt);
2909 llvm::Function *GenerateSEHFilterFunction(CodeGenFunction &ParentCGF,
2912 llvm::Function *GenerateSEHFinallyFunction(CodeGenFunction &ParentCGF,
2915 void EmitSEHExceptionCodeSave(CodeGenFunction &ParentCGF,
2928 void EmitCapturedLocals(CodeGenFunction &ParentCGF,
const Stmt *OutlinedStmt,
2936 Address recoverAddrOfEscapedLocal(CodeGenFunction &ParentCGF,
2945 CodeGenFunction &CGF;
2951 CGF.OMPCancelStack.enter(CGF, Kind, HasCancel);
2960 llvm::Function *GenerateCapturedStmtFunction(
const CapturedStmt &S);
2962 llvm::Function *GenerateOpenMPCapturedStmtFunction(
const CapturedStmt &S);
2976 void EmitOMPAggregateAssign(
2990 void EmitOMPCopy(
QualType OriginalType,
3007 std::pair<bool, RValue> EmitOMPAtomicSimpleUpdateExpr(
3015 void EmitOMPUseDevicePtrClause(
3017 const llvm::DenseMap<const ValueDecl *, Address> &CaptureDeviceAddrMap);
3059 void EmitOMPLinearClauseFinal(
3061 const llvm::function_ref<
llvm::Value *(CodeGenFunction &)> CondGen);
3086 typedef const llvm::function_ref<void(CodeGenFunction & ,
3098 unsigned NumberOfTargetItems = 0;
3101 Address SizesArray,
unsigned NumberOfTargetItems)
3102 : BasePointersArray(BasePointersArray), PointersArray(PointersArray),
3103 SizesArray(SizesArray), NumberOfTargetItems(NumberOfTargetItems) {}
3145 void EmitOMPDistributeParallelForDirective(
3147 void EmitOMPDistributeParallelForSimdDirective(
3150 void EmitOMPTargetParallelForSimdDirective(
3156 void EmitOMPTeamsDistributeParallelForSimdDirective(
3158 void EmitOMPTeamsDistributeParallelForDirective(
3161 void EmitOMPTargetTeamsDistributeDirective(
3163 void EmitOMPTargetTeamsDistributeParallelForDirective(
3165 void EmitOMPTargetTeamsDistributeParallelForSimdDirective(
3167 void EmitOMPTargetTeamsDistributeSimdDirective(
3172 StringRef ParentName,
3175 EmitOMPTargetParallelDeviceFunction(
CodeGenModule &CGM, StringRef ParentName,
3178 static void EmitOMPTargetParallelForDeviceFunction(
3182 static void EmitOMPTargetParallelForSimdDeviceFunction(
3187 EmitOMPTargetTeamsDeviceFunction(
CodeGenModule &CGM, StringRef ParentName,
3190 static void EmitOMPTargetTeamsDistributeDeviceFunction(
3194 static void EmitOMPTargetTeamsDistributeSimdDeviceFunction(
3198 static void EmitOMPTargetSimdDeviceFunction(
CodeGenModule &CGM,
3199 StringRef ParentName,
3203 static void EmitOMPTargetTeamsDistributeParallelForSimdDeviceFunction(
3207 static void EmitOMPTargetTeamsDistributeParallelForDeviceFunction(
3220 void EmitOMPInnerLoop(
3221 const Stmt &S,
bool RequiresCleanup,
const Expr *LoopCond,
3222 const Expr *IncExpr,
3223 const llvm::function_ref<
void(CodeGenFunction &)> BodyGen,
3224 const llvm::function_ref<
void(CodeGenFunction &)> PostIncGen);
3247 void EmitOMPSimdFinal(
3249 const llvm::function_ref<
llvm::Value *(CodeGenFunction &)> CondGen);
3259 struct OMPLoopArguments {
3261 Address LB = Address::invalid();
3263 Address UB = Address::invalid();
3265 Address ST = Address::invalid();
3267 Address IL = Address::invalid();
3271 Expr *EUB =
nullptr;
3273 Expr *IncExpr =
nullptr;
3275 Expr *Init =
nullptr;
3277 Expr *Cond =
nullptr;
3279 Expr *NextLB =
nullptr;
3281 Expr *NextUB =
nullptr;
3282 OMPLoopArguments() =
default;
3285 Expr *IncExpr =
nullptr,
Expr *Init =
nullptr,
3286 Expr *Cond =
nullptr,
Expr *NextLB =
nullptr,
3287 Expr *NextUB =
nullptr)
3288 : LB(LB), UB(UB), ST(ST), IL(IL), Chunk(Chunk), EUB(EUB),
3289 IncExpr(IncExpr), Init(Init), Cond(Cond), NextLB(NextLB),
3292 void EmitOMPOuterLoop(
bool DynamicOrOrdered,
bool IsMonotonic,
3294 const OMPLoopArguments &LoopArgs,
3300 const OMPLoopArguments &LoopArgs,
3305 const OMPLoopArguments &LoopArgs,
3358 bool LValueIsSuitableForInlineAtomic(
LValue Src);
3364 llvm::AtomicOrdering AO,
bool IsVolatile =
false,
3367 void EmitAtomicStore(
RValue rvalue,
LValue lvalue,
bool isInit);
3369 void EmitAtomicStore(
RValue rvalue,
LValue lvalue, llvm::AtomicOrdering AO,
3370 bool IsVolatile,
bool isInit);
3372 std::pair<RValue, llvm::Value *> EmitAtomicCompareExchange(
3374 llvm::AtomicOrdering Success =
3375 llvm::AtomicOrdering::SequentiallyConsistent,
3376 llvm::AtomicOrdering Failure =
3377 llvm::AtomicOrdering::SequentiallyConsistent,
3378 bool IsWeak =
false,
AggValueSlot Slot = AggValueSlot::ignored());
3380 void EmitAtomicUpdate(
LValue LVal, llvm::AtomicOrdering AO,
3405 bool isNontemporal =
false) {
3406 return EmitLoadOfScalar(Addr, Volatile, Ty, Loc,
LValueBaseInfo(Source),
3413 bool isNontemporal =
false);
3427 bool isInit =
false,
bool isNontemporal =
false) {
3428 EmitStoreOfScalar(Value, Addr, Volatile, Ty,
LValueBaseInfo(Source),
3435 bool isInit =
false,
bool isNontemporal =
false);
3455 void EmitStoreThroughLValue(
RValue Src,
LValue Dst,
bool isInit =
false);
3456 void EmitStoreThroughExtVectorComponentLValue(
RValue Src,
LValue Dst);
3457 void EmitStoreThroughGlobalRegLValue(
RValue Src,
LValue Dst);
3465 void EmitStoreThroughBitfieldLValue(
RValue Src,
LValue Dst,
3487 bool Accessed =
false);
3489 bool IsLowerBound =
true);
3504 Address EmitArrayToPointerDecay(
const Expr *Array,
3509 llvm::PointerIntPair<llvm::Constant*, 1, bool> ValueAndIsReference;
3511 : ValueAndIsReference(C, isReference) {}
3522 return ValueAndIsReference.getOpaqueValue() !=
nullptr;
3527 assert(isReference());
3533 assert(!isReference());
3534 return ValueAndIsReference.getPointer();
3559 unsigned CVRQualifiers);
3586 llvm::Instruction **callOrInvoke =
nullptr) {
3587 return EmitCall(CallInfo, Callee, ReturnValue, Args, callOrInvoke,
3599 llvm::CallInst *EmitRuntimeCall(
llvm::Value *callee,
3600 const Twine &name =
"");
3601 llvm::CallInst *EmitRuntimeCall(
llvm::Value *callee,
3603 const Twine &name =
"");
3604 llvm::CallInst *EmitNounwindRuntimeCall(
llvm::Value *callee,
3605 const Twine &name =
"");
3606 llvm::CallInst *EmitNounwindRuntimeCall(
llvm::Value *callee,
3608 const Twine &name =
"");
3613 llvm::CallSite EmitCallOrInvoke(
llvm::Value *Callee,
3615 const Twine &Name =
"");
3616 llvm::CallSite EmitRuntimeCallOrInvoke(
llvm::Value *callee,
3618 const Twine &name =
"");
3619 llvm::CallSite EmitRuntimeCallOrInvoke(
llvm::Value *callee,
3620 const Twine &name =
"");
3621 void EmitNoreturnRuntimeCallOrInvoke(
llvm::Value *callee,
3634 static std::string getNonTrivialCopyConstructorStr(
QualType QT,
3640 static std::string getNonTrivialDestructorStr(
QualType QT,
3647 void defaultInitNonTrivialCStructVar(
LValue Dst);
3648 void callCStructDefaultConstructor(
LValue Dst);
3649 void callCStructDestructor(
LValue Dst);
3650 void callCStructCopyConstructor(
LValue Dst,
LValue Src);
3651 void callCStructMoveConstructor(
LValue Dst,
LValue Src);
3652 void callCStructCopyAssignmentOperator(
LValue Dst,
LValue Src);
3653 void callCStructMoveAssignmentOperator(
LValue Dst,
LValue Src);
3674 bool IsArrow,
const Expr *Base);
3703 llvm::Function *generateBuiltinOSLogHelperFunction(
3714 const llvm::CmpInst::Predicate Fp,
3715 const llvm::CmpInst::Predicate Ip,
3716 const llvm::Twine &Name =
"");
3718 llvm::Triple::ArchType Arch);
3720 llvm::Value *EmitCommonNeonBuiltinExpr(
unsigned BuiltinID,
3721 unsigned LLVMIntrinsic,
3722 unsigned AltLLVMIntrinsic,
3723 const char *NameHint,
3728 llvm::Triple::ArchType Arch);
3733 llvm::Function *LookupNeonLLVMIntrinsic(
unsigned IntrinsicID,
3734 unsigned Modifier, llvm::Type *ArgTy,
3739 unsigned shift = 0,
bool rightshift =
false);
3742 bool negateForRightShift);
3744 llvm::Type *Ty,
bool usgn,
const char *name);
3747 llvm::Triple::ArchType Arch);
3755 llvm::Value *EmitWebAssemblyBuiltinExpr(
unsigned BuiltinID,
3787 void EmitARCDestroyWeak(
Address addr);
3798 bool resultIgnored);
3800 bool resultIgnored);
3814 llvm::Type *returnType);
3817 std::pair<LValue,llvm::Value*>
3819 std::pair<LValue,llvm::Value*>
3821 std::pair<LValue,llvm::Value*>
3822 EmitARCStoreUnsafeUnretained(
const BinaryOperator *e,
bool ignored);
3825 llvm::Type *returnType);
3827 llvm::Type *returnType);
3834 bool allowUnsafeClaim);
3847 void EmitObjCAutoreleasePoolPop(
llvm::Value *Ptr);
3850 void EmitObjCAutoreleasePoolCleanup(
llvm::Value *Ptr);
3851 void EmitObjCMRRAutoreleasePoolPop(
llvm::Value *Ptr);
3854 RValue EmitReferenceBindingToExpr(
const Expr *E);
3864 llvm::Value *EmitScalarExpr(
const Expr *E ,
bool IgnoreResultAssign =
false);
3892 ComplexPairTy EmitComplexExpr(
const Expr *E,
3893 bool IgnoreReal =
false,
3894 bool IgnoreImag =
false);
3898 void EmitComplexExprIntoLValue(
const Expr *E,
LValue dest,
bool isInit);
3901 void EmitStoreOfComplex(ComplexPairTy V,
LValue dest,
bool isInit);
3913 llvm::GlobalVariable *
3914 AddInitializerToStaticVarDecl(
const VarDecl &D,
3915 llvm::GlobalVariable *GV);
3918 void EmitInvariantStart(llvm::Constant *Addr,
CharUnits Size);
3922 void EmitCXXGlobalVarDeclInit(
const VarDecl &D, llvm::Constant *DeclPtr,
3925 llvm::Constant *createAtExitStub(
const VarDecl &VD, llvm::Constant *Dtor,
3926 llvm::Constant *Addr);
3930 void registerGlobalDtorWithAtExit(
const VarDecl &D, llvm::Constant *fn,
3931 llvm::Constant *addr);
3934 void registerGlobalDtorWithAtExit(llvm::Constant *dtorStub);
3941 void EmitCXXGuardedInit(
const VarDecl &D, llvm::GlobalVariable *DeclPtr,
3947 void EmitCXXGuardedInitBranch(
llvm::Value *NeedsInit,
3948 llvm::BasicBlock *InitBlock,
3949 llvm::BasicBlock *NoInitBlock,
3955 GenerateCXXGlobalInitFunc(llvm::Function *Fn,
3961 void GenerateCXXGlobalDtorsFunc(
3963 const std::vector<std::pair<llvm::WeakTrackingVH, llvm::Constant *>>
3966 void GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn,
3968 llvm::GlobalVariable *Addr,
3976 if (
const auto *EWC = dyn_cast<ExprWithCleanups>(E))
3977 if (EWC->getNumObjects() == 0)
3979 enterNonTrivialFullExpression(E);
3981 void enterNonTrivialFullExpression(
const FullExpr *E);
3983 void EmitCXXThrowExpr(
const CXXThrowExpr *E,
bool KeepInsertionPoint =
true);
3996 StringRef AnnotationStr,
4013 static bool ContainsLabel(
const Stmt *S,
bool IgnoreCaseStmts =
false);
4018 static bool containsBreak(
const Stmt *S);
4022 static bool mightAddDeclToScope(
const Stmt *S);
4027 bool ConstantFoldsToSimpleInteger(
const Expr *Cond,
bool &Result,
4028 bool AllowLabels =
false);
4033 bool ConstantFoldsToSimpleInteger(
const Expr *Cond, llvm::APSInt &Result,
4034 bool AllowLabels =
false);
4041 void EmitBranchOnBoolExpr(
const Expr *Cond, llvm::BasicBlock *TrueBlock,
4042 llvm::BasicBlock *FalseBlock, uint64_t TrueCount);
4050 enum { NotSubtraction =
false, IsSubtraction =
true };
4062 const Twine &Name =
"");
4077 llvm::Constant *EmitCheckTypeDescriptor(
QualType T);
4090 void EmitCheck(
ArrayRef<std::pair<llvm::Value *, SanitizerMask>> Checked,
4113 void EmitCfiCheckStub();
4116 void EmitCfiCheckFail();
4134 void SetFPAccuracy(
llvm::Value *Val,
float Accuracy);
4137 llvm::MDNode *getRangeForLoadFromType(
QualType Ty);
4140 void deferPlaceholderReplacement(llvm::Instruction *Old,
llvm::Value *New);
4143 DeferredReplacements;
4147 assert(!LocalDeclMap.count(VD) &&
"Decl already exists in LocalDeclMap!");
4148 LocalDeclMap.insert({VD, Addr});
4161 void ExpandTypeToArgs(
QualType Ty,
CallArg Arg, llvm::FunctionType *IRFuncTy,
4163 unsigned &IRCallArgPos);
4166 const Expr *InputExpr, std::string &ConstraintStr);
4170 std::string &ConstraintStr,
4178 llvm::Value *evaluateOrEmitBuiltinObjectSize(
const Expr *E,
unsigned Type,
4179 llvm::IntegerType *ResType,
4186 llvm::IntegerType *ResType,
4196 return classDecl->getTypeParamListAsWritten();
4200 return catDecl->getTypeParamList();
4206 template<
typename T>
4220 template <
typename T>
4222 llvm::iterator_range<CallExpr::const_arg_iterator> ArgRange,
4224 unsigned ParamsToSkip = 0,
4229 assert((ParamsToSkip == 0 || CallArgTypeInfo) &&
4230 "Can't skip parameters if type info is not provided");
4231 if (CallArgTypeInfo) {
4233 bool isGenericMethod = isObjCMethodWithTypeParams(CallArgTypeInfo);
4237 for (
auto I = CallArgTypeInfo->param_type_begin() + ParamsToSkip,
4238 E = CallArgTypeInfo->param_type_end();
4239 I != E; ++I, ++Arg) {
4240 assert(Arg != ArgRange.end() &&
"Running over edge of argument list!");
4241 assert((isGenericMethod ||
4242 ((*I)->isVariablyModifiedType() ||
4243 (*I).getNonReferenceType()->isObjCRetainableType() ||
4245 .getCanonicalType((*I).getNonReferenceType())
4248 .getCanonicalType((*Arg)->getType())
4250 "type mismatch in call argument!");
4251 ArgTypes.push_back(*I);
4257 assert((Arg == ArgRange.end() || !CallArgTypeInfo ||
4258 CallArgTypeInfo->isVariadic()) &&
4259 "Extra arguments in non-variadic function!");
4262 for (
auto *A : llvm::make_range(Arg, ArgRange.end()))
4263 ArgTypes.push_back(CallArgTypeInfo ? getVarArgType(A) : A->getType());
4265 EmitCallArgs(Args, ArgTypes, ArgRange, AC, ParamsToSkip, Order);
4269 llvm::iterator_range<CallExpr::const_arg_iterator> ArgRange,
4271 unsigned ParamsToSkip = 0,
4291 Address EmitPointerWithAlignment(
const Expr *Addr,
4300 void EmitSanitizerStatReport(llvm::SanitizerStatKind SSK);
4310 : Architecture(Arch), Features(Feats.begin(), Feats.end()) {}
4315 : Function(F), Conditions(Arch, Feats) {}
4321 void EmitMultiVersionResolver(llvm::Function *Resolver,
4329 void EmitDeclMetadata();
4334 void AddObjCARCExceptionMetadata(llvm::Instruction *Inst);
4336 llvm::Value *GetValueForARMHint(
unsigned BuiltinID);
4348 if (!needsSaving(value))
return saved_type(value,
false);
4351 auto align = CharUnits::fromQuantity(
4360 inline llvm::Value *DominatingLLVMValue::restore(CodeGenFunction &CGF,
4363 if (!value.getInt())
return value.getPointer();
4366 auto alloca = cast<llvm::AllocaInst>(value.getPointer());
const llvm::DataLayout & getDataLayout() const
A call to an overloaded operator written using operator syntax.
ReturnValueSlot - Contains the address where the return value of a function can be stored...
llvm::Value * getArrayInitIndex()
Get the index of the current ArrayInitLoopExpr, if any.
Optional< uint64_t > getStmtCount(const Stmt *S)
Check if an execution count is known for a given statement.
This represents '#pragma omp distribute simd' composite directive.
Information about the layout of a __block variable.
This represents '#pragma omp master' directive.
virtual void EmitBody(CodeGenFunction &CGF, const Stmt *S)
Emit the captured statement body.
This represents '#pragma omp task' directive.
Represents a function declaration or definition.
void end(CodeGenFunction &CGF)
~InlinedInheritingConstructorScope()
LValue getReferenceLValue(CodeGenFunction &CGF, Expr *refExpr) const
CXXDefaultInitExprScope(CodeGenFunction &CGF)
PointerType - C99 6.7.5.1 - Pointer Declarators.
llvm::Constant * getValue() const
Scheduling data for loop-based OpenMP directives.
A (possibly-)qualified type.
CodeGenTypes & getTypes()
static CGCallee BuildAppleKextVirtualCall(CodeGenFunction &CGF, GlobalDecl GD, llvm::Type *Ty, const CXXRecordDecl *RD)
const CodeGenOptions & getCodeGenOpts() const
The class detects jumps which bypass local variables declaration: goto L; int a; L: ...
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...
void enterFullExpression(const FullExpr *E)
AlignmentSource
The source of the alignment of an l-value; an expression of confidence in the alignment actually matc...
bool HaveInsertPoint() const
HaveInsertPoint - True if an insertion point is defined.
bool isSEHTryScope() const
Returns true inside SEH __try blocks.
llvm::LLVMContext & getLLVMContext()
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
FieldConstructionScope(CodeGenFunction &CGF, Address This)
Represents a 'co_return' statement in the C++ Coroutines TS.
Stmt - This represents one statement.
IfStmt - This represents an if/then/else.
static T * buildByrefHelpers(CodeGenModule &CGM, const BlockByrefInfo &byrefInfo, T &&generator)
Lazily build the copy and dispose helpers for a __block variable with the given information.
bool requiresCleanups() const
Determine whether this scope requires any cleanups.
C Language Family Type Representation.
OpaqueValueMapping(CodeGenFunction &CGF, const AbstractConditionalOperator *op)
Build the opaque value mapping for the given conditional operator if it's the GNU ...
This represents '#pragma omp for simd' directive.
Checking the 'this' pointer for a constructor call.
bool hasVolatileMember() const
bool hasLabelBeenSeenInCurrentScope() const
Return true if a label was seen in the current scope.
Decl - This represents one declaration (or definition), e.g.
This represents '#pragma omp teams distribute parallel for' composite directive.
const Decl * CurCodeDecl
CurCodeDecl - This is the inner-most code context, which includes blocks.
static bool classof(const CGCapturedStmtInfo *)
Represents an attribute applied to a statement.
static Destroyer destroyARCStrongPrecise
llvm::Value * LoadCXXThis()
LoadCXXThis - Load the value of 'this'.
The base class of the type hierarchy.
This represents '#pragma omp target teams distribute' combined directive.
Represents Objective-C's @throw statement.
CGCapturedStmtInfo(const CapturedStmt &S, CapturedRegionKind K=CR_Default)
const RecordDecl * getCapturedRecordDecl() const
Retrieve the record declaration for captured variables.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
void SpecialInitFn(CodeGenFunction &Init, const VarDecl &D, llvm::Value *Address)
virtual const FieldDecl * lookup(const VarDecl *VD) const
Lookup the captured field decl for a variable.
Represents a call to a C++ constructor.
bool isZero() const
isZero - Test whether the quantity equals zero.
stable_iterator stable_begin() const
Create a stable reference to the top of the EH stack.
DominatingValue< T >::saved_type saveValueInCond(T value)
CGCapturedStmtInfo(CapturedRegionKind K=CR_Default)
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
const ParmVarDecl * getParamDecl(unsigned I) const
bool currentFunctionUsesSEHTry() const
This represents '#pragma omp parallel for' directive.
void emitCounterIncrement(CGBuilderTy &Builder, const Stmt *S, llvm::Value *StepV)
This represents '#pragma omp target teams distribute parallel for' combined directive.
Represents a C++ constructor within a class.
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
static bool needsSaving(llvm::Value *value)
Answer whether the given value needs extra work to be saved.
static type restore(CodeGenFunction &CGF, saved_type value)
static OpaqueValueMappingData bind(CodeGenFunction &CGF, const OpaqueValueExpr *ov, const RValue &rv)
Represents a point when we exit a loop.
static Destroyer destroyARCWeak
const CXXBaseSpecifier *const * path_const_iterator
This represents '#pragma omp target exit data' directive.
Address GetAddrOfLocalVar(const VarDecl *VD)
GetAddrOfLocalVar - Return the address of a local variable.
TypeEvaluationKind
The kind of evaluation to perform on values of a particular type.
Represents a variable declaration or definition.
Address getObjectAddress(CodeGenFunction &CGF) const
Returns the address of the object within this declaration.
VlaSizePair(llvm::Value *NE, QualType T)
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
CompoundLiteralExpr - [C99 6.5.2.5].
RAII object to set/unset CodeGenFunction::IsSanitizerScope.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
const T * getAs() const
Member-template getAs<specific type>'.
uint64_t getProfileCount(const Stmt *S)
Get the profiler's count for the given statement.
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 setCurrentProfileCount(uint64_t Count)
Set the profiler's current count.
llvm::Value * getPointer() const
bool shouldUseFusedARCCalls()
bool useLifetimeMarkers() const
static ConstantEmission forValue(llvm::Constant *C)
capture_iterator capture_begin()
Retrieve an iterator pointing to the first capture.
A C++ throw-expression (C++ [except.throw]).
Represents a parameter to a function.
bool hasFunctionDecl() const
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have...
Defines the clang::Expr interface and subclasses for C++ expressions.
AbstractCallee(const ObjCMethodDecl *OMD)
The collection of all-type qualifiers we support.
EHScopeStack::stable_iterator PrologueCleanupDepth
PrologueCleanupDepth - The cleanup depth enclosing all the cleanups associated with the parameters...
A jump destination is an abstract label, branching to which may require a jump out through normal cle...
~CXXDefaultInitExprScope()
LabelStmt - Represents a label, which has a substatement.
Represents a struct/union/class.
llvm::DenseMap< const VarDecl *, FieldDecl * > LambdaCaptureFields
LValue MakeAddrLValue(llvm::Value *V, QualType T, CharUnits Alignment, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
const TargetInfo & getTarget() const
An object to manage conditionally-evaluated expressions.
PeepholeProtection protectFromPeepholes(RValue rvalue)
protectFromPeepholes - Protect a value that we're intending to store to the side, but which will prob...
ConditionalCleanup stores the saved form of its parameters, then restores them and performs the clean...
ArrayInitLoopExprScope(CodeGenFunction &CGF, llvm::Value *Index)
void unbind(CodeGenFunction &CGF)
void setScopeDepth(EHScopeStack::stable_iterator depth)
This represents '#pragma omp parallel' directive.
CGDebugInfo * getDebugInfo()
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const CXXRecordDecl * NearestVBase
Address getIndirectAddress() const
void addLabel(const LabelDecl *label)
AbstractCallee(const FunctionDecl *FD)
FullExpr - Represents a "full-expression" node.
llvm::SmallPtrSet< const CXXRecordDecl *, 4 > VisitedVirtualBasesSetTy
The scope used to remap some variables as private in the OpenMP loop body (or other captured region e...
SmallVector< Address, 1 > SEHCodeSlotStack
A stack of exception code slots.
Represents a member of a struct/union/class.
An RAII object to set (and then clear) a mapping for an OpaqueValueExpr.
bool isReferenceType() const
Helper class with most of the code for saving a value for a conditional expression cleanup...
llvm::BasicBlock * getStartingBlock() const
Returns a block which will be executed prior to each evaluation of the conditional code...
This represents '#pragma omp target simd' directive.
virtual void setContextValue(llvm::Value *V)
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Defines some OpenMP-specific enums and functions.
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Address getAllocatedAddress() const
Returns the raw, allocated address, which is not necessarily the address of the object itself...
A metaprogramming class for ensuring that a value will dominate an arbitrary position in a function...
This represents '#pragma omp barrier' directive.
CleanupKind getCleanupKind(QualType::DestructionKind kind)
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp, [NSNumber numberWithInt:42]];.
The this pointer adjustment as well as an optional return adjustment for a thunk. ...
This is a common base class for loop directives ('omp simd', 'omp for', 'omp for simd' etc...
This represents '#pragma omp critical' directive.
const AstTypeMatcher< ComplexType > complexType
Matches C99 complex types.
unsigned getNumParams() const
bool isCleanupPadScope() const
Returns true while emitting a cleanuppad.
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...
RValue EmitAnyExpr(const Expr *E, AggValueSlot aggSlot=AggValueSlot::ignored(), bool ignoreResult=false)
EmitAnyExpr - Emit code to compute the specified expression which can have any type.
void pushFullExprCleanup(CleanupKind kind, As... A)
pushFullExprCleanup - Push a cleanup to be run at the end of the current full-expression.
OpenMPDistScheduleClauseKind
OpenMP attributes for 'dist_schedule' clause.
IndirectGotoStmt - This represents an indirect goto.
Describes an C or C++ initializer list.
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
This represents '#pragma omp distribute parallel for' composite directive.
void setCurrentRegionCount(uint64_t Count)
Set the counter value for the current region.
A class controlling the emission of a finally block.
This represents '#pragma omp teams distribute parallel for simd' composite directive.
static bool hasScalarEvaluationKind(QualType T)
ForStmt - This represents a 'for (init;cond;inc)' stmt.
InlinedInheritingConstructorScope(CodeGenFunction &CGF, GlobalDecl GD)
MultiVersionResolverOption(llvm::Function *F, StringRef Arch, ArrayRef< StringRef > Feats)
ObjCContainerDecl - Represents a container for method declarations.
CharUnits - This is an opaque type for sizes expressed in character units.
llvm::function_ref< std::pair< LValue, LValue > CodeGenFunction &, const OMPExecutableDirective &S)> CodeGenLoopBoundsTy
bool requiresLandingPad() const
CGCapturedStmtRAII(CodeGenFunction &CGF, CGCapturedStmtInfo *NewCapturedStmtInfo)
LexicalScope(CodeGenFunction &CGF, SourceRange Range)
Enter a new cleanup scope.
RAII for correct setting/restoring of CapturedStmtInfo.
TBAAAccessInfo getTBAAAccessInfo(QualType AccessType)
getTBAAAccessInfo - Get TBAA information that describes an access to an object of the given type...
CharUnits getAlignment() const
Return the alignment of this pointer.
EHScopeStack::stable_iterator CurrentCleanupScopeDepth
Represents a declaration of a type.
A builtin binary operation expression such as "x + y" or "x <= y".
bool needsEHCleanup(QualType::DestructionKind kind)
Determines whether an EH cleanup is required to destroy a type with the given destruction kind...
static OpaqueValueMappingData bind(CodeGenFunction &CGF, const OpaqueValueExpr *ov, const LValue &lv)
void restore(CodeGenFunction &CGF)
Restores original addresses of the variables.
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
bool isCXXThisExprCaptured() const
#define LIST_SANITIZER_CHECKS
This represents '#pragma omp cancellation point' directive.
ObjCStringLiteral, used for Objective-C string literals i.e.
field_iterator field_begin() const
CaseStmt - Represent a case statement.
A stack of scopes which respond to exceptions, including cleanups and catch blocks.
llvm::BasicBlock * createBasicBlock(const Twine &name="", llvm::Function *parent=nullptr, llvm::BasicBlock *before=nullptr)
createBasicBlock - Create an LLVM basic block.
This represents '#pragma omp teams' directive.
Denotes a cleanup that should run when a scope is exited using normal control flow (falling off the e...
Enums/classes describing ABI related information about constructors, destructors and thunks...
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
This represents '#pragma omp teams distribute simd' combined directive.
void ForceCleanup(std::initializer_list< llvm::Value **> ValuesToReload={})
Force the emission of cleanups now, instead of waiting until this object is destroyed.
Represents binding an expression to a temporary.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
GlobalDecl CurGD
CurGD - The GlobalDecl for the current function being compiled.
Controls insertion of cancellation exit blocks in worksharing constructs.
void incrementProfileCounter(const Stmt *S, llvm::Value *StepV=nullptr)
Increment the profiler's counter for the given statement by StepV.
uint64_t getCurrentProfileCount()
Get the profiler's current count.
CallLifetimeEnd(Address addr, llvm::Value *size)
llvm::function_ref< std::pair< llvm::Value *, llvm::Value * > CodeGenFunction &, const OMPExecutableDirective &S, Address LB, Address UB)> CodeGenDispatchBoundsTy
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...
Represents an ObjC class declaration.
Checking the operand of a cast to a virtual base object.
JumpDest getJumpDestInCurrentScope(StringRef Name=StringRef())
The given basic block lies in the current EH scope, but may be a target of a potentially scope-crossi...
const Decl * getDecl() const
Checking the operand of a load. Must be suitably sized and aligned.
void begin(CodeGenFunction &CGF)
~LexicalScope()
Exit this cleanup scope, emitting any accumulated cleanups.
Checking the 'this' pointer for a call to a non-static member function.
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...
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
This represents '#pragma omp target parallel for simd' directive.
OpenMP 4.0 [2.4, Array Sections].
Const iterator for iterating over Stmt * arrays that contain only Expr *.
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
CompoundStmt - This represents a group of statements like { stmt stmt }.
std::pair< llvm::Value *, llvm::Value * > ComplexPairTy
ASTContext & getContext() const
Represents a prototype with parameter type info, e.g.
Describes the capture of either a variable, or 'this', or variable-length array type.
This represents '#pragma omp taskgroup' directive.
const TargetCodeGenInfo & getTargetCodeGenInfo()
CGBlockInfo - Information to generate a block literal.
RValue - This trivial value class is used to represent the result of an expression that is evaluated...
CleanupKind getARCCleanupKind()
Retrieves the default cleanup kind for an ARC cleanup.
static AutoVarEmission invalid()
bool isGlobalVarCaptured(const VarDecl *VD) const
Checks if the global variable is captured in current function.
The class used to assign some variables some temporarily addresses.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Represents a call to the builtin function __builtin_va_arg.
AggValueSlot::Overlap_t overlapForFieldInit(const FieldDecl *FD)
Determine whether a field initialization may overlap some other object.
void pushCleanupAfterFullExpr(CleanupKind Kind, As... A)
Queue a cleanup to be pushed after finishing the current full-expression.
LValue MakeAddrLValue(Address Addr, QualType T, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
This represents '#pragma omp distribute' directive.
Exposes information about the current target.
llvm::SmallVector< StringRef, 8 > Features
CXXDtorType
C++ destructor types.
bool addPrivate(const VarDecl *LocalVD, const llvm::function_ref< Address()> PrivateGen)
Registers LocalVD variable as a private and apply PrivateGen function for it to generate correspondin...
EHScopeStack::stable_iterator getScopeDepth() const
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
This represents one expression.
Address getOriginalAllocatedAddress() const
Returns the address for the original alloca instruction.
stable_iterator getInnermostNormalCleanup() const
Returns the innermost normal cleanup on the stack, or stable_end() if there are no normal cleanups...
Enters a new scope for capturing cleanups, all of which will be executed once the scope is exited...
llvm::function_ref< void(CodeGenFunction &, SourceLocation, const unsigned, const bool)> CodeGenOrderedTy
static ParamValue forIndirect(Address addr)
OpaqueValueMapping(CodeGenFunction &CGF, const OpaqueValueExpr *opaqueValue, RValue rvalue)
void EmitCallArgs(CallArgList &Args, const T *CallArgTypeInfo, llvm::iterator_range< CallExpr::const_arg_iterator > ArgRange, AbstractCallee AC=AbstractCallee(), unsigned ParamsToSkip=0, EvaluationOrder Order=EvaluationOrder::Default)
EmitCallArgs - Emit call arguments for a function.
llvm::BasicBlock * getBlock() const
void ForceCleanup()
Force the emission of cleanups now, instead of waiting until this object is destroyed.
static bool isObjCMethodWithTypeParams(const ObjCMethodDecl *method)
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Represents a C++ destructor within a class.
This represents '#pragma omp target teams distribute parallel for simd' combined directive.
static saved_type save(CodeGenFunction &CGF, type value)
AggValueSlot CreateAggTemp(QualType T, const Twine &Name="tmp")
CreateAggTemp - Create a temporary memory object for the given aggregate type.
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
DeclContext * getDeclContext()
static bool needsSaving(type value)
Represents Objective-C's @synchronized statement.
ObjCSelectorExpr used for @selector in Objective-C.
CXXTryStmt - A C++ try block, including all handlers.
~OMPPrivateScope()
Exit scope - all the mapped variables are restored.
This represents '#pragma omp target teams distribute simd' combined directive.
const AstTypeMatcher< ArrayType > arrayType
Matches all kinds of arrays.
llvm::LLVMContext & getLLVMContext()
llvm::Value * OldCXXThisValue
Checking the value assigned to a _Nonnull pointer. Must not be null.
An RAII object to record that we're evaluating a statement expression.
This represents '#pragma omp for' directive.
~ArrayInitLoopExprScope()
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
This represents '#pragma omp target teams' directive.
LValue MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T)
An expression that sends a message to the given Objective-C object or class.
JumpDest(llvm::BasicBlock *Block, EHScopeStack::stable_iterator Depth, unsigned Index)
SourceLocation getEnd() const
An object which temporarily prevents a value from being destroyed by aggressive peephole optimization...
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
static bool CanThrow(Expr *E, ASTContext &Ctx)
The scope of a CXXDefaultInitExpr.
OMPTargetDataInfo(Address BasePointersArray, Address PointersArray, Address SizesArray, unsigned NumberOfTargetItems)
This represents '#pragma omp cancel' directive.
RunCleanupsScope(CodeGenFunction &CGF)
Enter a new cleanup scope.
const LangOptions & getLangOpts() const
ASTContext & getContext() const
Conds(StringRef Arch, ArrayRef< StringRef > Feats)
static bool shouldBindAsLValue(const Expr *expr)
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
GlobalDecl - represents a global declaration.
This represents '#pragma omp flush' directive.
This represents '#pragma omp parallel for simd' directive.
DoStmt - This represents a 'do/while' stmt.
AsmStmt is the base class for GCCAsmStmt and MSAsmStmt.
VarBypassDetector Bypasses
void PopCleanupBlocks(EHScopeStack::stable_iterator OldCleanupStackSize, std::initializer_list< llvm::Value **> ValuesToReload={})
Takes the old cleanup stack size and emits the cleanup blocks that have been added.
llvm::function_ref< void(CodeGenFunction &, const OMPLoopDirective &, JumpDest)> CodeGenLoopTy
This represents '#pragma omp target enter data' directive.
OMPPrivateScope(CodeGenFunction &CGF)
Enter a new OpenMP private scope.
The scope of an ArrayInitLoopExpr.
virtual llvm::Value * getContextValue() const
static bool needsSaving(type value)
llvm::SmallVector< VPtr, 4 > VPtrsVector
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
This captures a statement into a function.
Represents a call to an inherited base class constructor from an inheriting constructor.
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
void initFullExprCleanup()
Set up the last cleanup that was pushed as a conditional full-expression cleanup. ...
~FieldConstructionScope()
This represents '#pragma omp single' directive.
Encodes a location in the source.
void EnsureInsertPoint()
EnsureInsertPoint - Ensure that an insertion point is defined so that emitted IR has a place to go...
A saved depth on the scope stack.
std::unique_ptr< CGCoroData > Data
Represents a C++ temporary.
~RunCleanupsScope()
Exit this cleanup scope, emitting any accumulated cleanups.
llvm::BasicBlock * getUnreachableBlock()
AggValueSlot::Overlap_t overlapForReturnValue()
Determine whether a return value slot may overlap some other object.
void setBeforeOutermostConditional(llvm::Value *value, Address addr)
This is a basic class for representing single OpenMP executable directive.
SmallVector< llvm::Value *, 8 > ObjCEHValueStack
ObjCEHValueStack - Stack of Objective-C exception values, used for rethrows.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
Represents a call to a member function that may be written either with member call syntax (e...
const Decl * getDecl() const
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
Checking the operand of a cast to a base object.
OpenMPDirectiveKind
OpenMP directives.
Represents the declaration of a label.
CharUnits OldCXXThisAlignment
A scoped helper to set the current debug location to the specified location or preferred location of ...
Represents a static or instance method of a struct/union/class.
void EmitStmt(const Stmt *S, ArrayRef< const Attr *> Attrs=None)
EmitStmt - Emit the code for the statement.
static type restore(CodeGenFunction &CGF, saved_type value)
unsigned getDestIndex() const
OpenMPLinearClauseKind Modifier
Modifier of 'linear' clause.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
This represents '#pragma omp taskwait' directive.
SanitizerSet SanOpts
Sanitizers enabled for this function.
ObjCCategoryDecl - Represents a category declaration.
This is a basic class for representing single OpenMP clause.
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load, __atomic_store, and __atomic_compare_exchange_*, for the similarly-named C++11 instructions, and __c11 variants for <stdatomic.h>, and corresponding __opencl_atomic_* for OpenCL 2.0.
ObjCProtocolExpr used for protocol expression in Objective-C.
TypeCheckKind
Situations in which we might emit a check for the suitability of a pointer or glvalue.
This represents '#pragma omp target' directive.
static Destroyer emitARCIntrinsicUse
All available information about a concrete callee.
LValue MakeAddrLValue(llvm::Value *V, QualType T, CharUnits Alignment, AlignmentSource Source=AlignmentSource::Type)
JumpDest getJumpDestInCurrentScope(llvm::BasicBlock *Target)
The given basic block lies in the current EH scope, but may be a target of a potentially scope-crossi...
TargetCodeGenInfo - This class organizes various target-specific codegeneration issues, like target-specific attributes, builtins and so on.
Checking the object expression in a non-static data member access.
This represents '#pragma omp ordered' directive.
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
void EmitAggregateAssign(LValue Dest, LValue Src, QualType EltTy)
Emit an aggregate assignment.
static ParamValue forDirect(llvm::Value *value)
This represents '#pragma omp target update' directive.
ObjCBoxedExpr - used for generalized expression boxing.
uint64_t getCurrentRegionCount() const
Return the counter value of the current region.
virtual FieldDecl * getThisFieldDecl() const
llvm::Value * getDirectValue() const
const CGFunctionInfo * CurFnInfo
void Emit(CodeGenFunction &CGF, Flags flags) override
Emit the cleanup.
static ConstantEmission forReference(llvm::Constant *C)
const TargetCodeGenInfo & getTargetHooks() const
static Destroyer destroyARCStrongImprecise
CXXCtorType
C++ constructor types.
CompoundAssignOperator - For compound assignments (e.g.
JumpDest getOMPCancelDestination(OpenMPDirectiveKind Kind)
FunctionArgList - Type for representing both the decl and type of parameters to a function...
OpaqueValueExpr * getOpaqueValue() const
getOpaqueValue - Return the opaque value placeholder.
CGFunctionInfo - Class to encapsulate the information about a function definition.
This class organizes the cross-function state that is used while generating LLVM code.
Optional< types::ID > Type
Dataflow Directional Tag Classes.
Class provides a way to call simple version of codegen for OpenMP region, or an advanced with possibl...
[C99 6.4.2.2] - A predefined identifier such as func.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
static bool shouldBindAsLValue(const Expr *expr)
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
This represents '#pragma omp section' directive.
This represents '#pragma omp teams distribute' directive.
A scope within which we are constructing the fields of an object which might use a CXXDefaultInitExpr...
llvm::LoadInst * CreateAlignedLoad(llvm::Value *Addr, CharUnits Align, const llvm::Twine &Name="")
Checking the bound value in a reference binding.
bool isInConditionalBranch() const
isInConditionalBranch - Return true if we're currently emitting one branch or the other of a conditio...
This represents '#pragma omp simd' directive.
Represents a 'co_yield' expression.
llvm::Value * getAnyValue() const
StmtExprEvaluation(CodeGenFunction &CGF)
Checking the destination of a store. Must be suitably sized and aligned.
A pointer to member type per C++ 8.3.3 - Pointers to members.
llvm::SmallVector< char, 256 > LifetimeExtendedCleanupStack
llvm::StoreInst * CreateStore(llvm::Value *Val, Address Addr, bool IsVolatile=false)
This represents '#pragma omp atomic' directive.
LValue MakeAddrLValue(Address Addr, QualType T, AlignmentSource Source=AlignmentSource::Type)
bool hasProfileClangInstr() const
Check if Clang profile instrumenation is on.
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
Represents a __leave statement.
JumpDest ReturnBlock
ReturnBlock - Unified return block.
llvm::DenseMap< const Decl *, Address > DeclMapTy
Checking the operand of a static_cast to a derived reference type.
virtual StringRef getHelperName() const
Get the name of the capture helper.
static bool hasAggregateEvaluationKind(QualType T)
SwitchStmt - This represents a 'switch' stmt.
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
API for captured statement code generation.
static saved_type save(CodeGenFunction &CGF, type value)
static bool isObjCMethodWithTypeParams(const T *)
Represents the body of a coroutine.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
llvm::Type * ConvertType(const TypeDecl *T)
Checking the operand of a static_cast to a derived pointer type.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
CharUnits OffsetFromNearestVBase
Represents Objective-C's collection statement.
CodeGenTypes & getTypes() const
AbstractConditionalOperator - An abstract base class for ConditionalOperator and BinaryConditionalOpe...
Implements C++ ABI-specific code generation functions.
ObjCEncodeExpr, used for @encode in Objective-C.
A stack of loop information corresponding to loop nesting levels.
This class organizes the cross-module state that is used while lowering AST types to LLVM types...
Represents a call to a CUDA kernel function.
bool isFunctionType() const
Represents a 'co_await' expression.
const TargetInfo & Target
llvm::AssertingVH< llvm::Instruction > AllocaInsertPt
AllocaInsertPoint - This is an instruction in the entry block before which we prefer to insert alloca...
void pushCleanupTuple(CleanupKind Kind, std::tuple< As... > A)
Push a lazily-created cleanup on the stack. Tuple version.
bool setVarAddr(CodeGenFunction &CGF, const VarDecl *LocalVD, Address TempAddr)
Sets the address of the variable LocalVD to be TempAddr in function CGF.
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
EmitBlock - Emit the given block.
static Destroyer destroyNonTrivialCStruct
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
llvm::Value * LoadCXXVTT()
LoadCXXVTT - Load the VTT parameter to base constructors/destructors have virtual bases...
ARCPreciseLifetime_t
Does an ARC strong l-value have precise lifetime?
ObjCIvarRefExpr - A reference to an ObjC instance variable.
const Decl * CurFuncDecl
CurFuncDecl - Holds the Decl for the current outermost non-closure context.
A pair of helper functions for a __block variable.
GotoStmt - This represents a direct goto.
DominatingLLVMValue::saved_type SavedValue
static OpaqueValueMappingData bind(CodeGenFunction &CGF, const OpaqueValueExpr *ov, const Expr *e)
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
void setCurrentStmt(const Stmt *S)
If the execution count for the current statement is known, record that as the current count...
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...
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
void unprotectFromPeepholes(PeepholeProtection protection)
A non-RAII class containing all the information about a bound opaque value.
This represents '#pragma omp target parallel' directive.
Represents a C++ struct/union/class.
ContinueStmt - This represents a continue.
void EmitBranch(llvm::BasicBlock *Block)
EmitBranch - Emit a branch to the specified basic block from the current insert block, taking care to avoid creation of branches from dummy blocks.
void EmitAggregateCopyCtor(LValue Dest, LValue Src, AggValueSlot::Overlap_t MayOverlap)
llvm::PointerIntPair< llvm::Value *, 1, bool > saved_type
llvm::BasicBlock * getInvokeDest()
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
static Destroyer destroyCXXObject
LValue EmitLoadOfReferenceLValue(Address RefAddr, QualType RefTy, AlignmentSource Source=AlignmentSource::Type)
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
A specialization of Address that requires the address to be an LLVM Constant.
ObjCIvarDecl - Represents an ObjC instance variable.
static type restore(CodeGenFunction &CGF, saved_type value)
BuiltinCheckKind
Specifies which type of sanitizer check to apply when handling a particular builtin.
WhileStmt - This represents a 'while' stmt.
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.
OMPCancelStackRAII(CodeGenFunction &CGF, OpenMPDirectiveKind Kind, bool HasCancel)
unsigned kind
All of the diagnostics that can be emitted by the frontend.
Represents Objective-C's @try ... @catch ... @finally statement.
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of captures.
bool has(SanitizerMask K) const
Check if a certain (single) sanitizer is enabled.
This represents '#pragma omp taskloop simd' directive.
llvm::Function * Function
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
CapturedRegionKind getKind() const
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
CGCapturedStmtInfo * CapturedStmtInfo
llvm::Value * getSizeForLifetimeMarkers() const
void pushCleanupAfterFullExprImpl(CleanupKind Kind, Address ActiveFlag, As... A)
RValue EmitCall(const CGFunctionInfo &CallInfo, const CGCallee &Callee, ReturnValueSlot ReturnValue, const CallArgList &Args, llvm::Instruction **callOrInvoke=nullptr)
const llvm::function_ref< void(CodeGenFunction &, llvm::Value *, const OMPTaskDataTy &)> TaskGenTy
This represents '#pragma omp sections' directive.
Struct with all information about dynamic [sub]class needed to set vptr.
bool hasVolatileMember(QualType T)
hasVolatileMember - returns true if aggregate type has a volatile member.
This represents '#pragma omp target data' directive.
A reference to a declared variable, function, enum, etc.
ConditionalEvaluation(CodeGenFunction &CGF)
This structure provides a set of types that are commonly used during IR emission. ...
BreakStmt - This represents a break.
void EmitLifetimeEnd(llvm::Value *Size, llvm::Value *Addr)
CapturedRegionKind
The different kinds of captured statement.
void EmitBranchThroughCleanup(JumpDest Dest)
EmitBranchThroughCleanup - Emit a branch from the current insert block through the normal cleanup han...
const CXXRecordDecl * VTableClass
A trivial tuple used to represent a source range.
LValue - This represents an lvalue references.
An abstract representation of regular/ObjC call/message targets.
This represents '#pragma omp taskyield' directive.
Information for lazily generating a cleanup.
This represents a decl that may have a name.
This represents '#pragma omp distribute parallel for simd' composite directive.
Represents a C array with a specified size that is not an integer-constant-expression.
This represents '#pragma omp parallel sections' directive.
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
const LangOptions & getLangOpts() const
Expr * getCommon() const
getCommon - Return the common expression, written to the left of the condition.
bool apply(CodeGenFunction &CGF)
Applies new addresses to the list of the variables.
SourceLocation getBegin() const
CallArgList - Type for representing both the value and type of arguments in a call.
OpaqueValueMapping(CodeGenFunction &CGF, const OpaqueValueExpr *opaqueValue, LValue lvalue)
Represents Objective-C's @autoreleasepool Statement.
OpaqueValueMapping(CodeGenFunction &CGF, const OpaqueValueExpr *OV)
Build the opaque value mapping for an OpaqueValueExpr whose source expression is set to the expressio...
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...
bool isLocalVarDeclOrParm() const
Similar to isLocalVarDecl but also includes parameters.
This represents '#pragma omp target parallel for' directive.
llvm::SmallVector< const JumpDest *, 2 > SEHTryEpilogueStack
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL, ArrayRef< Expr *> PL, ArrayRef< Expr *> IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
bool Privatize()
Privatizes local variables previously registered as private.
void Destroyer(CodeGenFunction &CGF, Address addr, QualType ty)
This represents '#pragma omp taskloop' directive.