13 #ifndef LLVM_CLANG_LIB_CODEGEN_CODEGENFUNCTION_H 14 #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" 56 class CXXDestructorDecl;
57 class CXXForRangeStmt;
61 class EnumConstantDecl;
63 class FunctionProtoType;
65 class ObjCContainerDecl;
66 class ObjCInterfaceDecl;
69 class ObjCImplementationDecl;
70 class ObjCPropertyImplDecl;
73 class ObjCForCollectionStmt;
75 class ObjCAtThrowStmt;
76 class ObjCAtSynchronizedStmt;
77 class ObjCAutoreleasePoolStmt;
79 namespace analyze_os_log {
80 class OSLogBufferLayout;
90 class BlockByrefHelpers;
93 class BlockFieldFlags;
94 class RegionCodeGenTy;
95 class TargetCodeGenInfo;
110 #define LIST_SANITIZER_CHECKS \ 111 SANITIZER_CHECK(AddOverflow, add_overflow, 0) \ 112 SANITIZER_CHECK(BuiltinUnreachable, builtin_unreachable, 0) \ 113 SANITIZER_CHECK(CFICheckFail, cfi_check_fail, 0) \ 114 SANITIZER_CHECK(DivremOverflow, divrem_overflow, 0) \ 115 SANITIZER_CHECK(DynamicTypeCacheMiss, dynamic_type_cache_miss, 0) \ 116 SANITIZER_CHECK(FloatCastOverflow, float_cast_overflow, 0) \ 117 SANITIZER_CHECK(FunctionTypeMismatch, function_type_mismatch, 1) \ 118 SANITIZER_CHECK(ImplicitConversion, implicit_conversion, 0) \ 119 SANITIZER_CHECK(InvalidBuiltin, invalid_builtin, 0) \ 120 SANITIZER_CHECK(LoadInvalidValue, load_invalid_value, 0) \ 121 SANITIZER_CHECK(MissingReturn, missing_return, 0) \ 122 SANITIZER_CHECK(MulOverflow, mul_overflow, 0) \ 123 SANITIZER_CHECK(NegateOverflow, negate_overflow, 0) \ 124 SANITIZER_CHECK(NullabilityArg, nullability_arg, 0) \ 125 SANITIZER_CHECK(NullabilityReturn, nullability_return, 1) \ 126 SANITIZER_CHECK(NonnullArg, nonnull_arg, 0) \ 127 SANITIZER_CHECK(NonnullReturn, nonnull_return, 1) \ 128 SANITIZER_CHECK(OutOfBounds, out_of_bounds, 0) \ 129 SANITIZER_CHECK(PointerOverflow, pointer_overflow, 0) \ 130 SANITIZER_CHECK(ShiftOutOfBounds, shift_out_of_bounds, 0) \ 131 SANITIZER_CHECK(SubOverflow, sub_overflow, 0) \ 132 SANITIZER_CHECK(TypeMismatch, type_mismatch, 1) \ 133 SANITIZER_CHECK(AlignmentAssumption, alignment_assumption, 0) \ 134 SANITIZER_CHECK(VLABoundNotPositive, vla_bound_not_positive, 0) 137 #define SANITIZER_CHECK(Enum, Name, Version) Enum, 139 #undef SANITIZER_CHECK 145 typedef llvm::PointerIntPair<llvm::Value*, 1, bool>
saved_type;
150 if (!isa<llvm::Instruction>(value))
return false;
153 llvm::BasicBlock *block = cast<llvm::Instruction>(value)->getParent();
154 return (block != &block->getParent()->getEntryBlock());
166 return static_cast<T*
>(DominatingLLVMValue::restore(CGF, value));
180 return DominatingLLVMValue::needsSaving(value.
getPointer());
183 return { DominatingLLVMValue::save(CGF, value.
getPointer()),
187 return Address(DominatingLLVMValue::restore(CGF, value.SavedValue),
196 enum Kind { ScalarLiteral, ScalarAddress, AggregateLiteral,
197 AggregateAddress, ComplexAddress };
203 :
Value(v), K(k), Align(
a) {}
206 static bool needsSaving(
RValue value);
214 return saved_type::needsSaving(value);
217 return saved_type::save(CGF, value);
220 return value.restore(CGF);
235 JumpDest() : Block(nullptr), ScopeDepth(), Index(0) {}
239 : Block(Block), ScopeDepth(Depth), Index(Index) {}
241 bool isValid()
const {
return Block !=
nullptr; }
242 llvm::BasicBlock *
getBlock()
const {
return Block; }
252 llvm::BasicBlock *Block;
273 const unsigned,
const bool)>
277 typedef llvm::function_ref<std::pair<LValue, LValue>(
282 typedef llvm::function_ref<std::pair<llvm::Value *, llvm::Value *>(
289 void InsertHelper(llvm::Instruction *I,
const llvm::Twine &Name,
290 llvm::BasicBlock *BB,
291 llvm::BasicBlock::iterator InsertPt)
const;
300 llvm::Function *CurFn =
nullptr;
306 std::unique_ptr<CGCoroData>
Data;
313 return CurCoro.
Data !=
nullptr;
332 Address ReturnValuePointer = Address::invalid();
337 return CurLexicalScope->hasLabels();
338 return !LabelMap.empty();
349 :
Kind(K), ThisValue(nullptr), CXXThisFieldDecl(nullptr) {}
352 :
Kind(K), ThisValue(nullptr), CXXThisFieldDecl(nullptr) {
358 I != E; ++I, ++Field) {
359 if (I->capturesThis())
360 CXXThisFieldDecl = *Field;
361 else if (I->capturesVariable())
362 CaptureFields[I->getCapturedVar()->getCanonicalDecl()] = *Field;
363 else if (I->capturesVariableByCopy())
364 CaptureFields[I->getCapturedVar()->getCanonicalDecl()] = *Field;
402 llvm::SmallDenseMap<const VarDecl *, FieldDecl *> CaptureFields;
416 CodeGenFunction &CGF;
421 : CGF(CGF), PrevCapturedStmtInfo(CGF.CapturedStmtInfo) {
430 const Decl *CalleeDecl;
437 return dyn_cast_or_null<FunctionDecl>(CalleeDecl);
441 if (
const auto *FD = dyn_cast<FunctionDecl>(CalleeDecl))
442 return FD->getNumParams();
443 return cast<ObjCMethodDecl>(CalleeDecl)->param_size();
446 if (
const auto *FD = dyn_cast<FunctionDecl>(CalleeDecl))
447 return FD->getParamDecl(I);
448 return *(cast<ObjCMethodDecl>(CalleeDecl)->param_begin() + I);
456 bool IsSanitizerScope =
false;
460 CodeGenFunction *CGF;
468 bool CurFuncIsThunk =
false;
471 bool AutoreleaseResult =
false;
475 bool SawAsmBlock =
false;
481 bool IsOutlinedSEHHelper =
false;
485 bool IsInPreservedAIRegion =
false;
495 llvm::DenseMap<const VarDecl *, llvm::Value *>
NRVOFlags;
501 llvm::Instruction *CurrentFuncletPad =
nullptr;
509 : Addr(addr.getPointer()), Size(size) {}
531 Address NormalCleanupDest = Address::invalid();
533 unsigned NextCleanupDestIndex = 1;
539 llvm::BasicBlock *EHResumeBlock =
nullptr;
547 llvm::AllocaInst *EHSelectorSlot =
nullptr;
558 llvm::BasicBlock *EmitLandingPad();
560 llvm::BasicBlock *getInvokeDestImpl();
578 llvm::FunctionCallee BeginCatchFn;
582 llvm::AllocaInst *ForEHVar;
586 llvm::AllocaInst *SavedExnVar;
589 void enter(CodeGenFunction &CGF,
const Stmt *Finally,
590 llvm::FunctionCallee beginCatchFn,
591 llvm::FunctionCallee endCatchFn, llvm::FunctionCallee rethrowFn);
592 void exit(CodeGenFunction &CGF);
600 return CurrentFuncletPad && isa<llvm::CleanupPadInst>(CurrentFuncletPad);
606 template <
class T,
class... As>
610 if (!isInConditionalBranch())
611 return EHStack.pushCleanup<T>(
kind, A...);
614 typedef std::tuple<typename DominatingValue<As>::saved_type...> SavedTuple;
615 SavedTuple Saved{saveValueInCond(A)...};
619 initFullExprCleanup();
624 template <
class T,
class... As>
626 if (!isInConditionalBranch())
627 return pushCleanupAfterFullExprImpl<T>(
Kind, Address::invalid(), A...);
629 Address ActiveFlag = createCleanupActiveFlag();
631 "cleanup active flag should never need saving");
633 typedef std::tuple<typename DominatingValue<As>::saved_type...> SavedTuple;
634 SavedTuple Saved{saveValueInCond(A)...};
637 pushCleanupAfterFullExprImpl<CleanupType>(
Kind, ActiveFlag, Saved);
640 template <
class T,
class... As>
646 size_t OldSize = LifetimeExtendedCleanupStack.size();
647 LifetimeExtendedCleanupStack.resize(
648 LifetimeExtendedCleanupStack.size() +
sizeof(Header) + Header.
Size +
651 static_assert(
sizeof(Header) %
alignof(T) == 0,
652 "Cleanup will be allocated on misaligned address");
653 char *Buffer = &LifetimeExtendedCleanupStack[OldSize];
655 new (Buffer +
sizeof(Header)) T(A...);
657 new (Buffer +
sizeof(Header) +
sizeof(T))
Address(ActiveFlag);
663 initFullExprCleanupWithFlag(createCleanupActiveFlag());
666 void initFullExprCleanupWithFlag(
Address ActiveFlag);
667 Address createCleanupActiveFlag();
683 void PopCleanupBlock(
bool FallThroughIsBranchThrough =
false);
694 llvm::Instruction *DominatingIP);
704 llvm::Instruction *DominatingIP);
710 size_t LifetimeExtendedCleanupStackSize;
711 bool OldDidCallStackSave;
725 : PerformCleanup(
true), CGF(CGF)
728 LifetimeExtendedCleanupStackSize =
730 OldDidCallStackSave = CGF.DidCallStackSave;
731 CGF.DidCallStackSave =
false;
753 void ForceCleanup(std::initializer_list<llvm::Value**> ValuesToReload = {}) {
754 assert(PerformCleanup &&
"Already forced cleanup");
755 CGF.DidCallStackSave = OldDidCallStackSave;
758 PerformCleanup =
false;
765 EHScopeStack::stable_end();
779 CGF.CurLexicalScope =
this;
785 assert(PerformCleanup &&
"adding label to dead scope?");
786 Labels.push_back(label);
797 if (PerformCleanup) {
806 CGF.CurLexicalScope = ParentScope;
807 RunCleanupsScope::ForceCleanup();
814 return !Labels.empty();
817 void rescopeLabels();
820 typedef llvm::DenseMap<const Decl *, Address>
DeclMapTy;
824 DeclMapTy SavedLocals;
825 DeclMapTy SavedTempAddresses;
832 assert(SavedLocals.empty() &&
"Did not restored original addresses.");
842 if (SavedLocals.count(LocalVD))
return false;
845 auto it = CGF.LocalDeclMap.find(LocalVD);
846 if (it != CGF.LocalDeclMap.end())
847 SavedLocals.try_emplace(LocalVD, it->second);
849 SavedLocals.try_emplace(LocalVD, Address::invalid());
858 SavedTempAddresses.try_emplace(LocalVD, TempAddr);
867 copyInto(SavedTempAddresses, CGF.LocalDeclMap);
868 SavedTempAddresses.clear();
869 return !SavedLocals.empty();
874 if (!SavedLocals.empty()) {
875 copyInto(SavedLocals, CGF.LocalDeclMap);
883 static void copyInto(
const DeclMapTy &Src, DeclMapTy &Dest) {
884 for (
auto &Pair : Src) {
885 if (!Pair.second.isValid()) {
886 Dest.erase(Pair.first);
890 auto I = Dest.find(Pair.first);
892 I->second = Pair.second;
917 const llvm::function_ref<
Address()> PrivateGen) {
918 assert(PerformCleanup &&
"adding private to dead scope");
919 return MappedVars.
setVarAddr(CGF, LocalVD, PrivateGen());
933 RunCleanupsScope::ForceCleanup();
954 std::initializer_list<llvm::Value **> ValuesToReload = {});
961 size_t OldLifetimeExtendedStackSize,
962 std::initializer_list<llvm::Value **> ValuesToReload = {});
964 void ResolveBranchFixups(llvm::BasicBlock *Target);
972 NextCleanupDestIndex++);
979 return getJumpDestInCurrentScope(createBasicBlock(Name));
985 void EmitBranchThroughCleanup(
JumpDest Dest);
990 bool isObviouslyBranchWithoutCleanups(
JumpDest Dest)
const;
995 void popCatchScope();
997 llvm::BasicBlock *getEHResumeBlock(
bool isCleanup);
1004 llvm::BasicBlock *StartBB;
1008 : StartBB(CGF.Builder.GetInsertBlock()) {}
1011 assert(CGF.OutermostConditional !=
this);
1012 if (!CGF.OutermostConditional)
1013 CGF.OutermostConditional =
this;
1016 void end(CodeGenFunction &CGF) {
1017 assert(CGF.OutermostConditional !=
nullptr);
1018 if (CGF.OutermostConditional ==
this)
1019 CGF.OutermostConditional =
nullptr;
1034 assert(isInConditionalBranch());
1035 llvm::BasicBlock *block = OutermostConditional->getStartingBlock();
1036 auto store =
new llvm::StoreInst(value, addr.
getPointer(), &block->back());
1043 CodeGenFunction &CGF;
1052 : CGF(CGF), SavedOutermostConditional(CGF.OutermostConditional) {
1053 CGF.OutermostConditional =
nullptr;
1057 CGF.OutermostConditional = SavedOutermostConditional;
1066 llvm::Instruction *Inst;
1067 friend class CodeGenFunction;
1086 : OpaqueValue(ov), BoundLValue(boundLValue) {}
1098 hasAggregateEvaluationKind(expr->
getType());
1104 if (shouldBindAsLValue(ov))
1112 assert(shouldBindAsLValue(ov));
1113 CGF.OpaqueLValues.insert(std::make_pair(ov, lv));
1120 assert(!shouldBindAsLValue(ov));
1121 CGF.OpaqueRValues.insert(std::make_pair(ov, rv));
1133 bool isValid()
const {
return OpaqueValue !=
nullptr; }
1137 assert(OpaqueValue &&
"no data to unbind!");
1140 CGF.OpaqueLValues.erase(OpaqueValue);
1142 CGF.OpaqueRValues.erase(OpaqueValue);
1150 CodeGenFunction &CGF;
1155 return OpaqueValueMappingData::shouldBindAsLValue(expr);
1165 if (isa<ConditionalOperator>(op))
1179 assert(OV->
getSourceExpr() &&
"wrong form of OpaqueValueMapping used " 1180 "for OVE with no source expression");
1181 Data = OpaqueValueMappingData::bind(CGF, OV, OV->
getSourceExpr());
1210 unsigned VLAExprCounter = 0;
1211 bool DisableDebugInfo =
false;
1215 bool DidCallStackSave =
false;
1221 llvm::IndirectBrInst *IndirectBranch =
nullptr;
1225 DeclMapTy LocalDeclMap;
1229 llvm::DenseMap<const ParmVarDecl *, EHScopeStack::stable_iterator>
1230 CalleeDestructedParamCleanups;
1235 llvm::SmallDenseMap<const ParmVarDecl *, const ImplicitParamDecl *, 2>
1240 llvm::DenseMap<llvm::AllocaInst *, int> EscapedLocals;
1243 llvm::DenseMap<const LabelDecl*, JumpDest> LabelMap;
1247 struct BreakContinue {
1249 : BreakBlock(Break), ContinueBlock(Continue) {}
1257 class OpenMPCancelExitStack {
1261 CancelExit() =
default;
1264 :
Kind(Kind), ExitBlock(ExitBlock), ContBlock(ContBlock) {}
1268 bool HasBeenEmitted =
false;
1276 OpenMPCancelExitStack() : Stack(1) {}
1277 ~OpenMPCancelExitStack() =
default;
1279 JumpDest getExitBlock()
const {
return Stack.back().ExitBlock; }
1283 const llvm::function_ref<
void(CodeGenFunction &)> CodeGen) {
1284 if (Stack.back().Kind == Kind && getExitBlock().isValid()) {
1287 assert(!Stack.back().HasBeenEmitted);
1288 auto IP = CGF.
Builder.saveAndClearIP();
1289 CGF.
EmitBlock(Stack.back().ExitBlock.getBlock());
1291 CGF.
EmitBranch(Stack.back().ContBlock.getBlock());
1293 Stack.back().HasBeenEmitted =
true;
1302 Stack.push_back({
Kind,
1310 void exit(CodeGenFunction &CGF) {
1311 if (getExitBlock().isValid()) {
1314 if (!Stack.back().HasBeenEmitted) {
1317 CGF.
EmitBlock(Stack.back().ExitBlock.getBlock());
1320 CGF.
EmitBlock(Stack.back().ContBlock.getBlock());
1322 CGF.
Builder.CreateUnreachable();
1323 CGF.
Builder.ClearInsertionPoint();
1329 OpenMPCancelExitStack OMPCancelStack;
1334 llvm::MDNode *createProfileWeights(uint64_t TrueCount, uint64_t FalseCount);
1336 llvm::MDNode *createProfileWeightsForLoop(
const Stmt *Cond,
1337 uint64_t LoopCount);
1351 if (!Count.hasValue())
1371 llvm::SwitchInst *SwitchInsn =
nullptr;
1377 llvm::BasicBlock *CaseRangeBlock =
nullptr;
1381 llvm::DenseMap<const OpaqueValueExpr *, LValue> OpaqueLValues;
1382 llvm::DenseMap<const OpaqueValueExpr *, RValue> OpaqueRValues;
1390 llvm::DenseMap<const Expr*, llvm::Value*> VLASizeMap;
1394 llvm::BasicBlock *UnreachableBlock =
nullptr;
1397 unsigned NumReturnExprs = 0;
1400 unsigned NumSimpleReturnExprs = 0;
1418 : CGF(CGF), OldCXXDefaultInitExprThis(CGF.CXXDefaultInitExprThis) {
1419 CGF.CXXDefaultInitExprThis = This;
1422 CGF.CXXDefaultInitExprThis = OldCXXDefaultInitExprThis;
1426 CodeGenFunction &CGF;
1427 Address OldCXXDefaultInitExprThis;
1435 : CGF(CGF), OldCXXThisValue(CGF.CXXThisValue),
1436 OldCXXThisAlignment(CGF.CXXThisAlignment),
1437 SourceLocScope(E, CGF.CurSourceLocExprScope) {
1438 CGF.CXXThisValue = CGF.CXXDefaultInitExprThis.
getPointer();
1439 CGF.CXXThisAlignment = CGF.CXXDefaultInitExprThis.
getAlignment();
1442 CGF.CXXThisValue = OldCXXThisValue;
1443 CGF.CXXThisAlignment = OldCXXThisAlignment;
1463 : CGF(CGF), OldArrayInitIndex(CGF.ArrayInitIndex) {
1464 CGF.ArrayInitIndex = Index;
1467 CGF.ArrayInitIndex = OldArrayInitIndex;
1471 CodeGenFunction &CGF;
1478 : CGF(CGF), OldCurGD(CGF.CurGD), OldCurFuncDecl(CGF.CurFuncDecl),
1479 OldCurCodeDecl(CGF.CurCodeDecl),
1480 OldCXXABIThisDecl(CGF.CXXABIThisDecl),
1481 OldCXXABIThisValue(CGF.CXXABIThisValue),
1482 OldCXXThisValue(CGF.CXXThisValue),
1483 OldCXXABIThisAlignment(CGF.CXXABIThisAlignment),
1484 OldCXXThisAlignment(CGF.CXXThisAlignment),
1485 OldReturnValue(CGF.ReturnValue), OldFnRetTy(CGF.FnRetTy),
1486 OldCXXInheritedCtorInitExprArgs(
1487 std::move(CGF.CXXInheritedCtorInitExprArgs)) {
1490 cast<CXXConstructorDecl>(GD.
getDecl());
1491 CGF.CXXABIThisDecl =
nullptr;
1492 CGF.CXXABIThisValue =
nullptr;
1493 CGF.CXXThisValue =
nullptr;
1498 CGF.CXXInheritedCtorInitExprArgs.clear();
1501 CGF.
CurGD = OldCurGD;
1504 CGF.CXXABIThisDecl = OldCXXABIThisDecl;
1505 CGF.CXXABIThisValue = OldCXXABIThisValue;
1506 CGF.CXXThisValue = OldCXXThisValue;
1507 CGF.CXXABIThisAlignment = OldCXXABIThisAlignment;
1508 CGF.CXXThisAlignment = OldCXXThisAlignment;
1511 CGF.CXXInheritedCtorInitExprArgs =
1512 std::move(OldCXXInheritedCtorInitExprArgs);
1516 CodeGenFunction &CGF;
1518 const Decl *OldCurFuncDecl;
1519 const Decl *OldCurCodeDecl;
1541 Address CXXDefaultInitExprThis = Address::invalid();
1554 llvm::Value *CXXStructorImplicitParamValue =
nullptr;
1570 llvm::DenseMap<const ValueDecl *, BlockByrefInfo> BlockByrefInfos;
1574 llvm::Value *RetValNullabilityPrecondition =
nullptr;
1578 bool requiresReturnValueNullabilityCheck()
const {
1579 return RetValNullabilityPrecondition;
1584 Address ReturnLocation = Address::invalid();
1587 bool requiresReturnValueCheck()
const {
1588 return requiresReturnValueNullabilityCheck() ||
1589 (SanOpts.
has(SanitizerKind::ReturnsNonnullAttribute) &&
1590 CurCodeDecl && CurCodeDecl->
getAttr<ReturnsNonNullAttr>());
1593 llvm::BasicBlock *TerminateLandingPad =
nullptr;
1594 llvm::BasicBlock *TerminateHandler =
nullptr;
1595 llvm::BasicBlock *TrapBB =
nullptr;
1598 llvm::MapVector<llvm::Value *, llvm::BasicBlock *> TerminateFunclets;
1602 unsigned LargestVectorWidth = 0;
1605 const bool ShouldEmitLifetimeMarkers;
1610 llvm::Function *Fn);
1613 CodeGenFunction(
CodeGenModule &cgm,
bool suppressNewContext=
false);
1619 if (DisableDebugInfo)
1642 Address getNormalCleanupDestSlot();
1645 if (!UnreachableBlock) {
1646 UnreachableBlock = createBasicBlock(
"unreachable");
1647 new llvm::UnreachableInst(getLLVMContext(), UnreachableBlock);
1649 return UnreachableBlock;
1654 return getInvokeDestImpl();
1671 void pushIrregularPartialArrayCleanup(
llvm::Value *arrayBegin,
1675 Destroyer *destroyer);
1676 void pushRegularPartialArrayCleanup(
llvm::Value *arrayBegin,
1680 Destroyer *destroyer);
1687 Destroyer *destroyer,
bool useEHCleanupForArray);
1690 bool useEHCleanupForArray);
1691 void pushCallObjectDeleteCleanup(
const FunctionDecl *OperatorDelete,
1696 bool useEHCleanupForArray);
1698 Destroyer *destroyer,
1699 bool useEHCleanupForArray,
1703 Destroyer *destroyer,
1704 bool checkZeroLength,
bool useEHCleanup);
1712 case QualType::DK_none:
1714 case QualType::DK_cxx_destructor:
1715 case QualType::DK_objc_weak_lifetime:
1716 case QualType::DK_nontrivial_c_struct:
1717 return getLangOpts().Exceptions;
1718 case QualType::DK_objc_strong_lifetime:
1719 return getLangOpts().Exceptions &&
1722 llvm_unreachable(
"bad destruction kind");
1743 llvm::Constant *AtomicHelperFn);
1754 llvm::Constant *AtomicHelperFn);
1767 llvm::Function *GenerateBlockFunction(
GlobalDecl GD,
1769 const DeclMapTy &ldm,
1770 bool IsLambdaConversionToBlock,
1771 bool BuildGlobalBlock);
1774 static bool cxxDestructorCanThrow(
QualType T);
1776 llvm::Constant *GenerateCopyHelperFunction(
const CGBlockInfo &blockInfo);
1777 llvm::Constant *GenerateDestroyHelperFunction(
const CGBlockInfo &blockInfo);
1778 llvm::Constant *GenerateObjCAtomicSetterCopyHelperFunction(
1780 llvm::Constant *GenerateObjCAtomicGetterCopyHelperFunction(
1808 bool LoadBlockVarAddr,
bool CanThrow);
1819 bool followForward =
true);
1823 const llvm::Twine &
name);
1829 void GenerateCode(
GlobalDecl GD, llvm::Function *Fn,
1834 void markAsIgnoreThreadCheckingAtRuntime(llvm::Function *Fn);
1852 void EmitFunctionBody(
const Stmt *Body);
1853 void EmitBlockWithFallThrough(llvm::BasicBlock *BB,
const Stmt *S);
1855 void EmitForwardingCallToLambda(
const CXXMethodDecl *LambdaCallOperator,
1857 void EmitLambdaBlockInvokeBody();
1858 void EmitLambdaDelegatingInvokeBody(
const CXXMethodDecl *MD);
1861 EmitStoreThroughLValue(RValue::get(VLASizeMap[VAT->
getSizeExpr()]), LV);
1863 void EmitAsanPrologueOrEpilogue(
bool Prologue);
1869 llvm::DebugLoc EmitReturnBlock();
1875 void StartThunk(llvm::Function *Fn,
GlobalDecl GD,
1878 void EmitCallAndReturnForThunk(llvm::FunctionCallee Callee,
1879 const ThunkInfo *Thunk,
bool IsUnprototyped);
1885 llvm::FunctionCallee Callee);
1888 void generateThunk(llvm::Function *Fn,
const CGFunctionInfo &FnInfo,
1890 bool IsUnprototyped);
1892 llvm::Function *GenerateVarArgsThunk(llvm::Function *Fn,
1910 void InitializeVTablePointer(
const VPtr &vptr);
1915 VPtrsVector getVTablePointers(
const CXXRecordDecl *VTableClass);
1919 bool BaseIsNonVirtualPrimaryBase,
1921 VisitedVirtualBasesSetTy &VBases, VPtrsVector &vptrs);
1923 void InitializeVTablePointers(
const CXXRecordDecl *ClassDecl);
1966 bool ShouldEmitVTableTypeCheckedLoad(
const CXXRecordDecl *RD);
1970 uint64_t VTableByteOffset);
1980 bool ShouldInstrumentFunction();
1984 bool ShouldXRayInstrumentFunction()
const;
1988 bool AlwaysEmitXRayCustomEvents()
const;
1992 bool AlwaysEmitXRayTypedEvents()
const;
1995 llvm::Constant *EncodeAddrForUseInPrologue(llvm::Function *F,
1996 llvm::Constant *Addr);
2012 void EmitFunctionEpilog(
const CGFunctionInfo &FI,
bool EmitRetDbgLoc,
2019 void EmitStartEHSpec(
const Decl *D);
2022 void EmitEndEHSpec(
const Decl *D);
2025 llvm::BasicBlock *getTerminateLandingPad();
2029 llvm::BasicBlock *getTerminateFunclet();
2034 llvm::BasicBlock *getTerminateHandler();
2036 llvm::Type *ConvertTypeForMem(
QualType T);
2037 llvm::Type *ConvertType(
QualType T);
2039 return ConvertType(getContext().getTypeDeclType(T));
2062 llvm::Function *parent =
nullptr,
2063 llvm::BasicBlock *
before =
nullptr) {
2074 void SimplifyForwardingBlocks(llvm::BasicBlock *BB);
2084 void EmitBlock(llvm::BasicBlock *BB,
bool IsFinished=
false);
2088 void EmitBlockAfterUses(llvm::BasicBlock *BB);
2098 void EmitBranch(llvm::BasicBlock *Block);
2103 return Builder.GetInsertBlock() !=
nullptr;
2111 if (!HaveInsertPoint())
2112 EmitBlock(createBasicBlock());
2117 void ErrorUnsupported(
const Stmt *S,
const char *Type);
2125 return LValue::MakeAddr(Addr, T, getContext(),
LValueBaseInfo(Source),
2131 return LValue::MakeAddr(Addr, T, getContext(), BaseInfo, TBAAInfo);
2136 return LValue::MakeAddr(
Address(V, Alignment), T, getContext(),
2142 return LValue::MakeAddr(
Address(V, Alignment), T, getContext(),
2143 BaseInfo, TBAAInfo);
2151 bool forPointeeType =
false);
2165 return EmitLoadOfReferenceLValue(RefLVal);
2199 llvm::AllocaInst *CreateTempAlloca(llvm::Type *Ty,
const Twine &Name =
"tmp",
2202 const Twine &Name =
"tmp",
2206 const Twine &Name =
"tmp",
2219 Address CreateDefaultAlignTempAlloca(llvm::Type *Ty,
2220 const Twine &Name =
"tmp");
2251 Address CreateMemTempWithoutCast(
QualType T,
const Twine &Name =
"tmp");
2253 const Twine &Name =
"tmp");
2258 return AggValueSlot::forAddr(CreateMemTemp(T, Name),
2260 AggValueSlot::IsNotDestructed,
2261 AggValueSlot::DoesNotNeedGCBarriers,
2262 AggValueSlot::IsNotAliased,
2263 AggValueSlot::DoesNotOverlap);
2274 void EmitIgnoredExpr(
const Expr *E);
2284 bool ignoreResult =
false);
2301 void EmitAnyExprToMem(
const Expr *E,
Address Location,
2304 void EmitAnyExprToExn(
const Expr *E,
Address Addr);
2309 bool capturedByInit);
2315 const RecordDecl *RD = cast<RecordDecl>(RT->getDecl());
2326 return AggValueSlot::DoesNotOverlap;
2340 bool IsVolatile = hasVolatileMember(EltTy);
2341 EmitAggregateCopy(Dest, Src, EltTy, AggValueSlot::MayOverlap, IsVolatile);
2346 EmitAggregateCopy(Dest, Src, Src.
getType(), MayOverlap);
2358 bool isVolatile =
false);
2362 auto it = LocalDeclMap.find(VD);
2363 assert(it != LocalDeclMap.end() &&
2364 "Invalid argument to GetAddrOfLocalVar(), no decl!");
2381 static unsigned getAccessedFieldNo(
unsigned Idx,
const llvm::Constant *Elts);
2383 llvm::BlockAddress *GetAddrOfLabel(
const LabelDecl *L);
2384 llvm::BasicBlock *GetIndirectGotoBlock();
2387 static bool IsWrappedCXXThis(
const Expr *E);
2422 void EmitVariablyModifiedType(
QualType Ty);
2446 assert(CXXThisValue &&
"no 'this' value for this function");
2447 return CXXThisValue;
2456 assert(CXXStructorImplicitParamValue &&
"no VTT value for this function");
2457 return CXXStructorImplicitParamValue;
2463 GetAddressOfDirectBaseInCompleteClass(
Address Value,
2466 bool BaseIsVirtual);
2468 static bool ShouldNullCheckClassCastValue(
const CastExpr *Cast);
2482 bool NullCheckValue);
2508 bool ForVirtualBase,
2516 bool ForVirtualBase,
Address This,
2517 bool InheritedFromVBase,
2521 bool ForVirtualBase,
bool Delegating,
2525 bool ForVirtualBase,
bool Delegating,
2535 void EmitVTableAssumptionLoad(
const VPtr &vptr,
Address This);
2545 bool NewPointerIsChecked,
2546 bool ZeroInitialization =
false);
2552 bool NewPointerIsChecked,
2553 bool ZeroInitialization =
false);
2558 bool ForVirtualBase,
bool Delegating,
Address This,
2562 llvm::Type *ElementTy,
Address NewPtr,
2580 const CallExpr *TheCallExpr,
bool IsDelete);
2621 TCK_DynamicOperation
2632 bool sanitizePerformTypeCheck()
const;
2646 QualType IndexType,
bool Accessed);
2649 bool isInc,
bool isPre);
2651 bool isInc,
bool isPre);
2657 unsigned getDebugInfoFIndex(
const RecordDecl *Rec,
unsigned FieldIndex);
2667 void EmitDecl(
const Decl &D);
2672 void EmitVarDecl(
const VarDecl &D);
2675 bool capturedByInit);
2682 bool isTrivialInitializer(
const Expr *Init);
2687 void EmitAutoVarDecl(
const VarDecl &D);
2690 friend class CodeGenFunction;
2704 bool IsEscapingByRef;
2708 bool IsConstantAggregate;
2719 : Variable(nullptr), Addr(
Address::invalid()),
2720 AllocaAddr(
Address::invalid()) {}
2723 : Variable(&variable), Addr(
Address::invalid()), NRVOFlag(nullptr),
2724 IsEscapingByRef(
false), IsConstantAggregate(
false),
2725 SizeForLifetimeMarkers(nullptr), AllocaAddr(
Address::invalid()) {}
2727 bool wasEmittedAsGlobal()
const {
return !Addr.
isValid(); }
2733 return SizeForLifetimeMarkers !=
nullptr;
2736 assert(useLifetimeMarkers());
2737 return SizeForLifetimeMarkers;
2754 if (!IsEscapingByRef)
return Addr;
2770 void EmitAndRegisterVariableArrayDimensions(
CGDebugInfo *DI,
2772 bool EmitDebugInfo);
2774 void EmitStaticVarDecl(
const VarDecl &D,
2775 llvm::GlobalValue::LinkageTypes
Linkage);
2794 assert(!isIndirect());
2799 assert(isIndirect());
2800 return Address(Value, CharUnits::fromQuantity(Alignment));
2825 llvm::Instruction *Assumption);
2846 void EmitStopPoint(
const Stmt *S);
2862 bool EmitSimpleStmt(
const Stmt *S);
2867 bool GetLast =
false,
2869 AggValueSlot::ignored());
2877 void EmitGotoStmt(
const GotoStmt &S);
2879 void EmitIfStmt(
const IfStmt &S);
2884 void EmitForStmt(
const ForStmt &S,
2887 void EmitDeclStmt(
const DeclStmt &S);
2892 void EmitCaseStmt(
const CaseStmt &S);
2893 void EmitCaseStmtRange(
const CaseStmt &S);
2894 void EmitAsmStmt(
const AsmStmt &S);
2906 bool ignoreResult =
false);
2910 bool ignoreResult =
false);
2912 RValue EmitCoroutineIntrinsic(
const CallExpr *E,
unsigned int IID);
2914 void EnterCXXTryStmt(
const CXXTryStmt &S,
bool IsFnTryBlock =
false);
2915 void ExitCXXTryStmt(
const CXXTryStmt &S,
bool IsFnTryBlock =
false);
2924 llvm::Function *FinallyFunc);
2925 void startOutlinedSEHHelper(CodeGenFunction &ParentCGF,
bool IsFilter,
2926 const Stmt *OutlinedStmt);
2928 llvm::Function *GenerateSEHFilterFunction(CodeGenFunction &ParentCGF,
2931 llvm::Function *GenerateSEHFinallyFunction(CodeGenFunction &ParentCGF,
2934 void EmitSEHExceptionCodeSave(CodeGenFunction &ParentCGF,
2947 void EmitCapturedLocals(CodeGenFunction &ParentCGF,
const Stmt *OutlinedStmt,
2955 Address recoverAddrOfEscapedLocal(CodeGenFunction &ParentCGF,
2964 CodeGenFunction &CGF;
2970 CGF.OMPCancelStack.enter(CGF, Kind, HasCancel);
2979 llvm::Function *GenerateCapturedStmtFunction(
const CapturedStmt &S);
2981 llvm::Function *GenerateOpenMPCapturedStmtFunction(
const CapturedStmt &S);
2995 void EmitOMPAggregateAssign(
3009 void EmitOMPCopy(
QualType OriginalType,
3026 std::pair<bool, RValue> EmitOMPAtomicSimpleUpdateExpr(
3034 void EmitOMPUseDevicePtrClause(
3036 const llvm::DenseMap<const ValueDecl *, Address> &CaptureDeviceAddrMap);
3078 void EmitOMPLinearClauseFinal(
3080 const llvm::function_ref<
llvm::Value *(CodeGenFunction &)> CondGen);
3105 typedef const llvm::function_ref<void(CodeGenFunction & ,
3117 unsigned NumberOfTargetItems = 0;
3120 Address SizesArray,
unsigned NumberOfTargetItems)
3121 : BasePointersArray(BasePointersArray), PointersArray(PointersArray),
3122 SizesArray(SizesArray), NumberOfTargetItems(NumberOfTargetItems) {}
3164 void EmitOMPDistributeParallelForDirective(
3166 void EmitOMPDistributeParallelForSimdDirective(
3169 void EmitOMPTargetParallelForSimdDirective(
3175 void EmitOMPTeamsDistributeParallelForSimdDirective(
3177 void EmitOMPTeamsDistributeParallelForDirective(
3180 void EmitOMPTargetTeamsDistributeDirective(
3182 void EmitOMPTargetTeamsDistributeParallelForDirective(
3184 void EmitOMPTargetTeamsDistributeParallelForSimdDirective(
3186 void EmitOMPTargetTeamsDistributeSimdDirective(
3191 StringRef ParentName,
3194 EmitOMPTargetParallelDeviceFunction(
CodeGenModule &CGM, StringRef ParentName,
3197 static void EmitOMPTargetParallelForDeviceFunction(
3201 static void EmitOMPTargetParallelForSimdDeviceFunction(
3206 EmitOMPTargetTeamsDeviceFunction(
CodeGenModule &CGM, StringRef ParentName,
3209 static void EmitOMPTargetTeamsDistributeDeviceFunction(
3213 static void EmitOMPTargetTeamsDistributeSimdDeviceFunction(
3217 static void EmitOMPTargetSimdDeviceFunction(
CodeGenModule &CGM,
3218 StringRef ParentName,
3222 static void EmitOMPTargetTeamsDistributeParallelForSimdDeviceFunction(
3226 static void EmitOMPTargetTeamsDistributeParallelForDeviceFunction(
3239 void EmitOMPInnerLoop(
3240 const Stmt &S,
bool RequiresCleanup,
const Expr *LoopCond,
3241 const Expr *IncExpr,
3242 const llvm::function_ref<
void(CodeGenFunction &)> BodyGen,
3243 const llvm::function_ref<
void(CodeGenFunction &)> PostIncGen);
3266 void EmitOMPSimdFinal(
3268 const llvm::function_ref<
llvm::Value *(CodeGenFunction &)> CondGen);
3278 struct OMPLoopArguments {
3280 Address LB = Address::invalid();
3282 Address UB = Address::invalid();
3284 Address ST = Address::invalid();
3286 Address IL = Address::invalid();
3290 Expr *EUB =
nullptr;
3292 Expr *IncExpr =
nullptr;
3294 Expr *Init =
nullptr;
3296 Expr *Cond =
nullptr;
3298 Expr *NextLB =
nullptr;
3300 Expr *NextUB =
nullptr;
3301 OMPLoopArguments() =
default;
3304 Expr *IncExpr =
nullptr,
Expr *Init =
nullptr,
3305 Expr *Cond =
nullptr,
Expr *NextLB =
nullptr,
3306 Expr *NextUB =
nullptr)
3307 : LB(LB), UB(UB), ST(ST), IL(IL), Chunk(Chunk), EUB(EUB),
3308 IncExpr(IncExpr), Init(Init), Cond(Cond), NextLB(NextLB),
3311 void EmitOMPOuterLoop(
bool DynamicOrOrdered,
bool IsMonotonic,
3313 const OMPLoopArguments &LoopArgs,
3319 const OMPLoopArguments &LoopArgs,
3324 const OMPLoopArguments &LoopArgs,
3377 bool LValueIsSuitableForInlineAtomic(
LValue Src);
3383 llvm::AtomicOrdering AO,
bool IsVolatile =
false,
3386 void EmitAtomicStore(
RValue rvalue,
LValue lvalue,
bool isInit);
3388 void EmitAtomicStore(
RValue rvalue,
LValue lvalue, llvm::AtomicOrdering AO,
3389 bool IsVolatile,
bool isInit);
3391 std::pair<RValue, llvm::Value *> EmitAtomicCompareExchange(
3393 llvm::AtomicOrdering Success =
3394 llvm::AtomicOrdering::SequentiallyConsistent,
3395 llvm::AtomicOrdering Failure =
3396 llvm::AtomicOrdering::SequentiallyConsistent,
3397 bool IsWeak =
false,
AggValueSlot Slot = AggValueSlot::ignored());
3399 void EmitAtomicUpdate(
LValue LVal, llvm::AtomicOrdering AO,
3424 bool isNontemporal =
false) {
3425 return EmitLoadOfScalar(Addr, Volatile, Ty, Loc,
LValueBaseInfo(Source),
3432 bool isNontemporal =
false);
3446 bool isInit =
false,
bool isNontemporal =
false) {
3447 EmitStoreOfScalar(Value, Addr, Volatile, Ty,
LValueBaseInfo(Source),
3454 bool isInit =
false,
bool isNontemporal =
false);
3474 void EmitStoreThroughLValue(
RValue Src,
LValue Dst,
bool isInit =
false);
3475 void EmitStoreThroughExtVectorComponentLValue(
RValue Src,
LValue Dst);
3476 void EmitStoreThroughGlobalRegLValue(
RValue Src,
LValue Dst);
3484 void EmitStoreThroughBitfieldLValue(
RValue Src,
LValue Dst,
3506 bool Accessed =
false);
3508 bool IsLowerBound =
true);
3523 Address EmitArrayToPointerDecay(
const Expr *Array,
3528 llvm::PointerIntPair<llvm::Constant*, 1, bool> ValueAndIsReference;
3530 : ValueAndIsReference(C, isReference) {}
3541 return ValueAndIsReference.getOpaqueValue() !=
nullptr;
3546 assert(isReference());
3552 assert(!isReference());
3553 return ValueAndIsReference.getPointer();
3578 unsigned CVRQualifiers);
3604 llvm::CallBase **callOrInvoke =
nullptr) {
3605 return EmitCall(CallInfo, Callee, ReturnValue, Args, callOrInvoke,
3618 llvm::CallInst *EmitRuntimeCall(llvm::FunctionCallee callee,
3619 const Twine &name =
"");
3620 llvm::CallInst *EmitRuntimeCall(llvm::FunctionCallee callee,
3622 const Twine &name =
"");
3623 llvm::CallInst *EmitNounwindRuntimeCall(llvm::FunctionCallee callee,
3624 const Twine &name =
"");
3625 llvm::CallInst *EmitNounwindRuntimeCall(llvm::FunctionCallee callee,
3627 const Twine &name =
"");
3632 llvm::CallBase *EmitCallOrInvoke(llvm::FunctionCallee Callee,
3634 const Twine &Name =
"");
3635 llvm::CallBase *EmitRuntimeCallOrInvoke(llvm::FunctionCallee callee,
3637 const Twine &name =
"");
3638 llvm::CallBase *EmitRuntimeCallOrInvoke(llvm::FunctionCallee callee,
3639 const Twine &name =
"");
3640 void EmitNoreturnRuntimeCallOrInvoke(llvm::FunctionCallee callee,
3653 static std::string getNonTrivialCopyConstructorStr(
QualType QT,
3659 static std::string getNonTrivialDestructorStr(
QualType QT,
3666 void defaultInitNonTrivialCStructVar(
LValue Dst);
3667 void callCStructDefaultConstructor(
LValue Dst);
3668 void callCStructDestructor(
LValue Dst);
3669 void callCStructCopyConstructor(
LValue Dst,
LValue Src);
3670 void callCStructMoveConstructor(
LValue Dst,
LValue Src);
3671 void callCStructCopyAssignmentOperator(
LValue Dst,
LValue Src);
3672 void callCStructMoveAssignmentOperator(
LValue Dst,
LValue Src);
3692 bool IsArrow,
const Expr *Base);
3721 llvm::Function *generateBuiltinOSLogHelperFunction(
3732 const llvm::CmpInst::Predicate Fp,
3733 const llvm::CmpInst::Predicate Ip,
3734 const llvm::Twine &Name =
"");
3736 llvm::Triple::ArchType Arch);
3738 llvm::Value *EmitCommonNeonBuiltinExpr(
unsigned BuiltinID,
3739 unsigned LLVMIntrinsic,
3740 unsigned AltLLVMIntrinsic,
3741 const char *NameHint,
3746 llvm::Triple::ArchType Arch);
3748 llvm::Function *LookupNeonLLVMIntrinsic(
unsigned IntrinsicID,
3749 unsigned Modifier, llvm::Type *ArgTy,
3754 unsigned shift = 0,
bool rightshift =
false);
3757 bool negateForRightShift);
3759 llvm::Type *Ty,
bool usgn,
const char *name);
3762 llvm::Triple::ArchType Arch);
3770 llvm::Value *EmitWebAssemblyBuiltinExpr(
unsigned BuiltinID,
3802 void EmitARCDestroyWeak(
Address addr);
3813 bool resultIgnored);
3815 bool resultIgnored);
3829 llvm::Type *returnType);
3832 std::pair<LValue,llvm::Value*>
3834 std::pair<LValue,llvm::Value*>
3836 std::pair<LValue,llvm::Value*>
3837 EmitARCStoreUnsafeUnretained(
const BinaryOperator *e,
bool ignored);
3840 llvm::Type *returnType);
3842 llvm::Type *returnType);
3851 bool allowUnsafeClaim);
3864 void EmitObjCAutoreleasePoolPop(
llvm::Value *Ptr);
3867 void EmitObjCAutoreleasePoolCleanup(
llvm::Value *Ptr);
3868 void EmitObjCMRRAutoreleasePoolPop(
llvm::Value *Ptr);
3871 RValue EmitReferenceBindingToExpr(
const Expr *E);
3881 llvm::Value *EmitScalarExpr(
const Expr *E ,
bool IgnoreResultAssign =
false);
3909 ComplexPairTy EmitComplexExpr(
const Expr *E,
3910 bool IgnoreReal =
false,
3911 bool IgnoreImag =
false);
3915 void EmitComplexExprIntoLValue(
const Expr *E,
LValue dest,
bool isInit);
3918 void EmitStoreOfComplex(ComplexPairTy V,
LValue dest,
bool isInit);
3930 llvm::GlobalVariable *
3931 AddInitializerToStaticVarDecl(
const VarDecl &D,
3932 llvm::GlobalVariable *GV);
3935 void EmitInvariantStart(llvm::Constant *Addr,
CharUnits Size);
3939 void EmitCXXGlobalVarDeclInit(
const VarDecl &D, llvm::Constant *DeclPtr,
3942 llvm::Function *createAtExitStub(
const VarDecl &VD, llvm::FunctionCallee Dtor,
3943 llvm::Constant *Addr);
3947 void registerGlobalDtorWithAtExit(
const VarDecl &D, llvm::FunctionCallee fn,
3948 llvm::Constant *addr);
3951 void registerGlobalDtorWithAtExit(llvm::Constant *dtorStub);
3958 void EmitCXXGuardedInit(
const VarDecl &D, llvm::GlobalVariable *DeclPtr,
3964 void EmitCXXGuardedInitBranch(
llvm::Value *NeedsInit,
3965 llvm::BasicBlock *InitBlock,
3966 llvm::BasicBlock *NoInitBlock,
3972 GenerateCXXGlobalInitFunc(llvm::Function *Fn,
3978 void GenerateCXXGlobalDtorsFunc(
3980 const std::vector<std::tuple<llvm::FunctionType *, llvm::WeakTrackingVH,
3981 llvm::Constant *>> &DtorsAndObjects);
3983 void GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn,
3985 llvm::GlobalVariable *Addr,
3993 if (
const auto *EWC = dyn_cast<ExprWithCleanups>(E))
3994 if (EWC->getNumObjects() == 0)
3996 enterNonTrivialFullExpression(E);
3998 void enterNonTrivialFullExpression(
const FullExpr *E);
4000 void EmitCXXThrowExpr(
const CXXThrowExpr *E,
bool KeepInsertionPoint =
true);
4009 llvm::Value *EmitAnnotationCall(llvm::Function *AnnotationFn,
4011 StringRef AnnotationStr,
4028 static bool ContainsLabel(
const Stmt *S,
bool IgnoreCaseStmts =
false);
4033 static bool containsBreak(
const Stmt *S);
4037 static bool mightAddDeclToScope(
const Stmt *S);
4042 bool ConstantFoldsToSimpleInteger(
const Expr *Cond,
bool &Result,
4043 bool AllowLabels =
false);
4048 bool ConstantFoldsToSimpleInteger(
const Expr *Cond, llvm::APSInt &Result,
4049 bool AllowLabels =
false);
4056 void EmitBranchOnBoolExpr(
const Expr *Cond, llvm::BasicBlock *TrueBlock,
4057 llvm::BasicBlock *FalseBlock, uint64_t TrueCount);
4065 enum { NotSubtraction =
false, IsSubtraction =
true };
4077 const Twine &Name =
"");
4092 llvm::Constant *EmitCheckTypeDescriptor(
QualType T);
4105 void EmitCheck(
ArrayRef<std::pair<llvm::Value *, SanitizerMask>> Checked,
4128 void EmitCfiCheckStub();
4131 void EmitCfiCheckFail();
4149 void SetFPAccuracy(
llvm::Value *Val,
float Accuracy);
4152 llvm::MDNode *getRangeForLoadFromType(
QualType Ty);
4155 void deferPlaceholderReplacement(llvm::Instruction *Old,
llvm::Value *New);
4158 DeferredReplacements;
4162 assert(!LocalDeclMap.count(VD) &&
"Decl already exists in LocalDeclMap!");
4163 LocalDeclMap.insert({VD, Addr});
4176 void ExpandTypeToArgs(
QualType Ty,
CallArg Arg, llvm::FunctionType *IRFuncTy,
4178 unsigned &IRCallArgPos);
4181 const Expr *InputExpr, std::string &ConstraintStr);
4185 std::string &ConstraintStr,
4193 llvm::Value *evaluateOrEmitBuiltinObjectSize(
const Expr *E,
unsigned Type,
4194 llvm::IntegerType *ResType,
4202 llvm::IntegerType *ResType,
4216 return classDecl->getTypeParamListAsWritten();
4220 return catDecl->getTypeParamList();
4226 template<
typename T>
4240 template <
typename T>
4242 llvm::iterator_range<CallExpr::const_arg_iterator> ArgRange,
4244 unsigned ParamsToSkip = 0,
4249 assert((ParamsToSkip == 0 || CallArgTypeInfo) &&
4250 "Can't skip parameters if type info is not provided");
4251 if (CallArgTypeInfo) {
4253 bool isGenericMethod = isObjCMethodWithTypeParams(CallArgTypeInfo);
4257 for (
auto I = CallArgTypeInfo->param_type_begin() + ParamsToSkip,
4258 E = CallArgTypeInfo->param_type_end();
4259 I != E; ++I, ++Arg) {
4260 assert(Arg != ArgRange.end() &&
"Running over edge of argument list!");
4261 assert((isGenericMethod ||
4262 ((*I)->isVariablyModifiedType() ||
4263 (*I).getNonReferenceType()->isObjCRetainableType() ||
4265 .getCanonicalType((*I).getNonReferenceType())
4268 .getCanonicalType((*Arg)->getType())
4270 "type mismatch in call argument!");
4271 ArgTypes.push_back(*I);
4277 assert((Arg == ArgRange.end() || !CallArgTypeInfo ||
4278 CallArgTypeInfo->isVariadic()) &&
4279 "Extra arguments in non-variadic function!");
4282 for (
auto *A : llvm::make_range(Arg, ArgRange.end()))
4283 ArgTypes.push_back(CallArgTypeInfo ? getVarArgType(A) : A->getType());
4285 EmitCallArgs(Args, ArgTypes, ArgRange, AC, ParamsToSkip, Order);
4289 llvm::iterator_range<CallExpr::const_arg_iterator> ArgRange,
4291 unsigned ParamsToSkip = 0,
4311 Address EmitPointerWithAlignment(
const Expr *Addr,
4320 void EmitSanitizerStatReport(llvm::SanitizerStatKind SSK);
4330 : Architecture(Arch), Features(Feats.begin(), Feats.end()) {}
4335 : Function(F), Conditions(Arch, Feats) {}
4341 void EmitMultiVersionResolver(llvm::Function *Resolver,
4349 void EmitDeclMetadata();
4354 void AddObjCARCExceptionMetadata(llvm::Instruction *Inst);
4356 llvm::Value *GetValueForARMHint(
unsigned BuiltinID);
4368 if (!needsSaving(value))
return saved_type(value,
false);
4371 auto align = CharUnits::fromQuantity(
4380 inline llvm::Value *DominatingLLVMValue::restore(CodeGenFunction &CGF,
4383 if (!value.getInt())
return value.getPointer();
4386 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
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()
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion...
CXXDefaultArgExprScope(CodeGenFunction &CGF, const CXXDefaultArgExpr *E)
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
const llvm::function_ref< void(CodeGenFunction &, llvm::Function *, const OMPTaskDataTy &)> TaskGenTy
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)
RValue EmitCall(const CGFunctionInfo &CallInfo, const CGCallee &Callee, ReturnValueSlot ReturnValue, const CallArgList &Args, llvm::CallBase **callOrInvoke=nullptr)
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>'.
SourceLocExprScopeGuard SourceLocScope
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
void EmitLambdaVLACapture(const VariableArrayType *VAT, LValue LV)
This represents '#pragma omp cancellation point' directive.
ObjCStringLiteral, used for Objective-C string literals i.e.
Expr * getSizeExpr() const
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.
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
A default argument (C++ [dcl.fct.default]).
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].
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...
AggValueSlot::Overlap_t getOverlapForReturnValue()
Determine whether a return value slot may overlap some other object.
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.
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()
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)
Represents the current source location and context used to determine the value of the source location...
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
CXXDefaultInitExprScope(CodeGenFunction &CGF, const CXXDefaultInitExpr *E)
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)
Iterator for iterating over Stmt * arrays that contain only 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.
A use of a default initializer in a constructor or in aggregate initialization.
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)
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.
CurrentSourceLocExprScope CurSourceLocExprScope
Source location information about the default argument or member initializer expression we're evaluat...
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.