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(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;
333 return CurLexicalScope->hasLabels();
334 return !LabelMap.empty();
345 :
Kind(K), ThisValue(nullptr), CXXThisFieldDecl(nullptr) {}
348 :
Kind(K), ThisValue(nullptr), CXXThisFieldDecl(nullptr) {
354 I != E; ++I, ++Field) {
355 if (I->capturesThis())
356 CXXThisFieldDecl = *Field;
357 else if (I->capturesVariable())
358 CaptureFields[I->getCapturedVar()->getCanonicalDecl()] = *Field;
359 else if (I->capturesVariableByCopy())
360 CaptureFields[I->getCapturedVar()->getCanonicalDecl()] = *Field;
398 llvm::SmallDenseMap<const VarDecl *, FieldDecl *> CaptureFields;
412 CodeGenFunction &CGF;
417 : CGF(CGF), PrevCapturedStmtInfo(CGF.CapturedStmtInfo) {
426 const Decl *CalleeDecl;
433 return dyn_cast_or_null<FunctionDecl>(CalleeDecl);
437 if (
const auto *FD = dyn_cast<FunctionDecl>(CalleeDecl))
438 return FD->getNumParams();
439 return cast<ObjCMethodDecl>(CalleeDecl)->param_size();
442 if (
const auto *FD = dyn_cast<FunctionDecl>(CalleeDecl))
443 return FD->getParamDecl(I);
444 return *(cast<ObjCMethodDecl>(CalleeDecl)->param_begin() + I);
452 bool IsSanitizerScope =
false;
456 CodeGenFunction *CGF;
464 bool CurFuncIsThunk =
false;
467 bool AutoreleaseResult =
false;
471 bool SawAsmBlock =
false;
477 bool IsOutlinedSEHHelper =
false;
487 llvm::DenseMap<const VarDecl *, llvm::Value *>
NRVOFlags;
493 llvm::Instruction *CurrentFuncletPad =
nullptr;
501 : Addr(addr.getPointer()), Size(size) {}
523 Address NormalCleanupDest = Address::invalid();
525 unsigned NextCleanupDestIndex = 1;
531 llvm::BasicBlock *EHResumeBlock =
nullptr;
539 llvm::AllocaInst *EHSelectorSlot =
nullptr;
550 llvm::BasicBlock *EmitLandingPad();
552 llvm::BasicBlock *getInvokeDestImpl();
570 llvm::Constant *BeginCatchFn;
574 llvm::AllocaInst *ForEHVar;
578 llvm::AllocaInst *SavedExnVar;
581 void enter(CodeGenFunction &CGF,
const Stmt *Finally,
582 llvm::Constant *beginCatchFn, llvm::Constant *endCatchFn,
583 llvm::Constant *rethrowFn);
584 void exit(CodeGenFunction &CGF);
592 return CurrentFuncletPad && isa<llvm::CleanupPadInst>(CurrentFuncletPad);
598 template <
class T,
class... As>
602 if (!isInConditionalBranch())
603 return EHStack.pushCleanup<T>(
kind, A...);
606 typedef std::tuple<typename DominatingValue<As>::saved_type...> SavedTuple;
607 SavedTuple Saved{saveValueInCond(A)...};
611 initFullExprCleanup();
616 template <
class T,
class... As>
618 if (!isInConditionalBranch())
619 return pushCleanupAfterFullExprImpl<T>(
Kind, Address::invalid(), A...);
621 Address ActiveFlag = createCleanupActiveFlag();
623 "cleanup active flag should never need saving");
625 typedef std::tuple<typename DominatingValue<As>::saved_type...> SavedTuple;
626 SavedTuple Saved{saveValueInCond(A)...};
629 pushCleanupAfterFullExprImpl<CleanupType>(
Kind, ActiveFlag, Saved);
632 template <
class T,
class... As>
638 size_t OldSize = LifetimeExtendedCleanupStack.size();
639 LifetimeExtendedCleanupStack.resize(
640 LifetimeExtendedCleanupStack.size() +
sizeof(Header) + Header.
Size +
643 static_assert(
sizeof(Header) %
alignof(T) == 0,
644 "Cleanup will be allocated on misaligned address");
645 char *Buffer = &LifetimeExtendedCleanupStack[OldSize];
647 new (Buffer +
sizeof(Header)) T(A...);
649 new (Buffer +
sizeof(Header) +
sizeof(T))
Address(ActiveFlag);
655 initFullExprCleanupWithFlag(createCleanupActiveFlag());
658 void initFullExprCleanupWithFlag(
Address ActiveFlag);
659 Address createCleanupActiveFlag();
674 void PopCleanupBlock(
bool FallThroughIsBranchThrough =
false);
685 llvm::Instruction *DominatingIP);
695 llvm::Instruction *DominatingIP);
701 size_t LifetimeExtendedCleanupStackSize;
702 bool OldDidCallStackSave;
716 : PerformCleanup(
true), CGF(CGF)
719 LifetimeExtendedCleanupStackSize =
721 OldDidCallStackSave = CGF.DidCallStackSave;
722 CGF.DidCallStackSave =
false;
744 void ForceCleanup(std::initializer_list<llvm::Value**> ValuesToReload = {}) {
745 assert(PerformCleanup &&
"Already forced cleanup");
746 CGF.DidCallStackSave = OldDidCallStackSave;
749 PerformCleanup =
false;
756 EHScopeStack::stable_end();
770 CGF.CurLexicalScope =
this;
776 assert(PerformCleanup &&
"adding label to dead scope?");
777 Labels.push_back(label);
788 if (PerformCleanup) {
797 CGF.CurLexicalScope = ParentScope;
798 RunCleanupsScope::ForceCleanup();
805 return !Labels.empty();
808 void rescopeLabels();
811 typedef llvm::DenseMap<const Decl *, Address>
DeclMapTy;
815 DeclMapTy SavedLocals;
816 DeclMapTy SavedTempAddresses;
823 assert(SavedLocals.empty() &&
"Did not restored original addresses.");
833 if (SavedLocals.count(LocalVD))
return false;
836 auto it = CGF.LocalDeclMap.find(LocalVD);
837 if (it != CGF.LocalDeclMap.end())
838 SavedLocals.try_emplace(LocalVD, it->second);
840 SavedLocals.try_emplace(LocalVD, Address::invalid());
849 SavedTempAddresses.try_emplace(LocalVD, TempAddr);
858 copyInto(SavedTempAddresses, CGF.LocalDeclMap);
859 SavedTempAddresses.clear();
860 return !SavedLocals.empty();
865 if (!SavedLocals.empty()) {
866 copyInto(SavedLocals, CGF.LocalDeclMap);
874 static void copyInto(
const DeclMapTy &Src, DeclMapTy &Dest) {
875 for (
auto &Pair : Src) {
876 if (!Pair.second.isValid()) {
877 Dest.erase(Pair.first);
881 auto I = Dest.find(Pair.first);
883 I->second = Pair.second;
908 const llvm::function_ref<
Address()> PrivateGen) {
909 assert(PerformCleanup &&
"adding private to dead scope");
910 return MappedVars.
setVarAddr(CGF, LocalVD, PrivateGen());
924 RunCleanupsScope::ForceCleanup();
945 std::initializer_list<llvm::Value **> ValuesToReload = {});
952 size_t OldLifetimeExtendedStackSize,
953 std::initializer_list<llvm::Value **> ValuesToReload = {});
955 void ResolveBranchFixups(llvm::BasicBlock *Target);
963 NextCleanupDestIndex++);
970 return getJumpDestInCurrentScope(createBasicBlock(Name));
976 void EmitBranchThroughCleanup(
JumpDest Dest);
981 bool isObviouslyBranchWithoutCleanups(
JumpDest Dest)
const;
986 void popCatchScope();
988 llvm::BasicBlock *getEHResumeBlock(
bool isCleanup);
995 llvm::BasicBlock *StartBB;
999 : StartBB(CGF.Builder.GetInsertBlock()) {}
1002 assert(CGF.OutermostConditional !=
this);
1003 if (!CGF.OutermostConditional)
1004 CGF.OutermostConditional =
this;
1007 void end(CodeGenFunction &CGF) {
1008 assert(CGF.OutermostConditional !=
nullptr);
1009 if (CGF.OutermostConditional ==
this)
1010 CGF.OutermostConditional =
nullptr;
1025 assert(isInConditionalBranch());
1026 llvm::BasicBlock *block = OutermostConditional->getStartingBlock();
1027 auto store =
new llvm::StoreInst(value, addr.
getPointer(), &block->back());
1034 CodeGenFunction &CGF;
1043 : CGF(CGF), SavedOutermostConditional(CGF.OutermostConditional) {
1044 CGF.OutermostConditional =
nullptr;
1048 CGF.OutermostConditional = SavedOutermostConditional;
1057 llvm::Instruction *Inst;
1058 friend class CodeGenFunction;
1077 : OpaqueValue(ov), BoundLValue(boundLValue) {}
1089 hasAggregateEvaluationKind(expr->
getType());
1095 if (shouldBindAsLValue(ov))
1103 assert(shouldBindAsLValue(ov));
1104 CGF.OpaqueLValues.insert(std::make_pair(ov, lv));
1111 assert(!shouldBindAsLValue(ov));
1112 CGF.OpaqueRValues.insert(std::make_pair(ov, rv));
1124 bool isValid()
const {
return OpaqueValue !=
nullptr; }
1128 assert(OpaqueValue &&
"no data to unbind!");
1131 CGF.OpaqueLValues.erase(OpaqueValue);
1133 CGF.OpaqueRValues.erase(OpaqueValue);
1141 CodeGenFunction &CGF;
1146 return OpaqueValueMappingData::shouldBindAsLValue(expr);
1156 if (isa<ConditionalOperator>(op))
1170 assert(OV->
getSourceExpr() &&
"wrong form of OpaqueValueMapping used " 1171 "for OVE with no source expression");
1172 Data = OpaqueValueMappingData::bind(CGF, OV, OV->
getSourceExpr());
1200 bool DisableDebugInfo =
false;
1204 bool DidCallStackSave =
false;
1210 llvm::IndirectBrInst *IndirectBranch =
nullptr;
1214 DeclMapTy LocalDeclMap;
1218 llvm::DenseMap<const ParmVarDecl *, EHScopeStack::stable_iterator>
1219 CalleeDestructedParamCleanups;
1224 llvm::SmallDenseMap<const ParmVarDecl *, const ImplicitParamDecl *, 2>
1229 llvm::DenseMap<llvm::AllocaInst *, int> EscapedLocals;
1232 llvm::DenseMap<const LabelDecl*, JumpDest> LabelMap;
1236 struct BreakContinue {
1238 : BreakBlock(Break), ContinueBlock(Continue) {}
1246 class OpenMPCancelExitStack {
1250 CancelExit() =
default;
1253 :
Kind(Kind), ExitBlock(ExitBlock), ContBlock(ContBlock) {}
1257 bool HasBeenEmitted =
false;
1265 OpenMPCancelExitStack() : Stack(1) {}
1266 ~OpenMPCancelExitStack() =
default;
1268 JumpDest getExitBlock()
const {
return Stack.back().ExitBlock; }
1272 const llvm::function_ref<
void(CodeGenFunction &)> CodeGen) {
1273 if (Stack.back().Kind == Kind && getExitBlock().isValid()) {
1276 assert(!Stack.back().HasBeenEmitted);
1277 auto IP = CGF.
Builder.saveAndClearIP();
1278 CGF.
EmitBlock(Stack.back().ExitBlock.getBlock());
1280 CGF.
EmitBranch(Stack.back().ContBlock.getBlock());
1282 Stack.back().HasBeenEmitted =
true;
1291 Stack.push_back({
Kind,
1299 void exit(CodeGenFunction &CGF) {
1300 if (getExitBlock().isValid()) {
1303 if (!Stack.back().HasBeenEmitted) {
1306 CGF.
EmitBlock(Stack.back().ExitBlock.getBlock());
1309 CGF.
EmitBlock(Stack.back().ContBlock.getBlock());
1311 CGF.
Builder.CreateUnreachable();
1312 CGF.
Builder.ClearInsertionPoint();
1318 OpenMPCancelExitStack OMPCancelStack;
1323 llvm::MDNode *createProfileWeights(uint64_t TrueCount, uint64_t FalseCount);
1325 llvm::MDNode *createProfileWeightsForLoop(
const Stmt *Cond,
1326 uint64_t LoopCount);
1340 if (!Count.hasValue())
1360 llvm::SwitchInst *SwitchInsn =
nullptr;
1366 llvm::BasicBlock *CaseRangeBlock =
nullptr;
1370 llvm::DenseMap<const OpaqueValueExpr *, LValue> OpaqueLValues;
1371 llvm::DenseMap<const OpaqueValueExpr *, RValue> OpaqueRValues;
1379 llvm::DenseMap<const Expr*, llvm::Value*> VLASizeMap;
1383 llvm::BasicBlock *UnreachableBlock =
nullptr;
1386 unsigned NumReturnExprs = 0;
1389 unsigned NumSimpleReturnExprs = 0;
1401 : CGF(CGF), OldCXXDefaultInitExprThis(CGF.CXXDefaultInitExprThis) {
1402 CGF.CXXDefaultInitExprThis = This;
1405 CGF.CXXDefaultInitExprThis = OldCXXDefaultInitExprThis;
1409 CodeGenFunction &CGF;
1410 Address OldCXXDefaultInitExprThis;
1418 : CGF(CGF), OldCXXThisValue(CGF.CXXThisValue),
1419 OldCXXThisAlignment(CGF.CXXThisAlignment) {
1420 CGF.CXXThisValue = CGF.CXXDefaultInitExprThis.
getPointer();
1421 CGF.CXXThisAlignment = CGF.CXXDefaultInitExprThis.
getAlignment();
1424 CGF.CXXThisValue = OldCXXThisValue;
1425 CGF.CXXThisAlignment = OldCXXThisAlignment;
1439 : CGF(CGF), OldArrayInitIndex(CGF.ArrayInitIndex) {
1440 CGF.ArrayInitIndex = Index;
1443 CGF.ArrayInitIndex = OldArrayInitIndex;
1447 CodeGenFunction &CGF;
1454 : CGF(CGF), OldCurGD(CGF.CurGD), OldCurFuncDecl(CGF.CurFuncDecl),
1455 OldCurCodeDecl(CGF.CurCodeDecl),
1456 OldCXXABIThisDecl(CGF.CXXABIThisDecl),
1457 OldCXXABIThisValue(CGF.CXXABIThisValue),
1458 OldCXXThisValue(CGF.CXXThisValue),
1459 OldCXXABIThisAlignment(CGF.CXXABIThisAlignment),
1460 OldCXXThisAlignment(CGF.CXXThisAlignment),
1461 OldReturnValue(CGF.ReturnValue), OldFnRetTy(CGF.FnRetTy),
1462 OldCXXInheritedCtorInitExprArgs(
1463 std::move(CGF.CXXInheritedCtorInitExprArgs)) {
1466 cast<CXXConstructorDecl>(GD.
getDecl());
1467 CGF.CXXABIThisDecl =
nullptr;
1468 CGF.CXXABIThisValue =
nullptr;
1469 CGF.CXXThisValue =
nullptr;
1474 CGF.CXXInheritedCtorInitExprArgs.clear();
1477 CGF.
CurGD = OldCurGD;
1480 CGF.CXXABIThisDecl = OldCXXABIThisDecl;
1481 CGF.CXXABIThisValue = OldCXXABIThisValue;
1482 CGF.CXXThisValue = OldCXXThisValue;
1483 CGF.CXXABIThisAlignment = OldCXXABIThisAlignment;
1484 CGF.CXXThisAlignment = OldCXXThisAlignment;
1487 CGF.CXXInheritedCtorInitExprArgs =
1488 std::move(OldCXXInheritedCtorInitExprArgs);
1492 CodeGenFunction &CGF;
1494 const Decl *OldCurFuncDecl;
1495 const Decl *OldCurCodeDecl;
1517 Address CXXDefaultInitExprThis = Address::invalid();
1530 llvm::Value *CXXStructorImplicitParamValue =
nullptr;
1546 llvm::DenseMap<const ValueDecl *, BlockByrefInfo> BlockByrefInfos;
1550 llvm::Value *RetValNullabilityPrecondition =
nullptr;
1554 bool requiresReturnValueNullabilityCheck()
const {
1555 return RetValNullabilityPrecondition;
1560 Address ReturnLocation = Address::invalid();
1563 bool requiresReturnValueCheck()
const {
1564 return requiresReturnValueNullabilityCheck() ||
1565 (SanOpts.
has(SanitizerKind::ReturnsNonnullAttribute) &&
1566 CurCodeDecl && CurCodeDecl->
getAttr<ReturnsNonNullAttr>());
1569 llvm::BasicBlock *TerminateLandingPad =
nullptr;
1570 llvm::BasicBlock *TerminateHandler =
nullptr;
1571 llvm::BasicBlock *TrapBB =
nullptr;
1574 llvm::MapVector<llvm::Value *, llvm::BasicBlock *> TerminateFunclets;
1578 unsigned LargestVectorWidth = 0;
1581 const bool ShouldEmitLifetimeMarkers;
1586 llvm::Function *Fn);
1589 CodeGenFunction(
CodeGenModule &cgm,
bool suppressNewContext=
false);
1595 if (DisableDebugInfo)
1618 Address getNormalCleanupDestSlot();
1621 if (!UnreachableBlock) {
1622 UnreachableBlock = createBasicBlock(
"unreachable");
1623 new llvm::UnreachableInst(getLLVMContext(), UnreachableBlock);
1625 return UnreachableBlock;
1630 return getInvokeDestImpl();
1647 void pushIrregularPartialArrayCleanup(
llvm::Value *arrayBegin,
1651 Destroyer *destroyer);
1652 void pushRegularPartialArrayCleanup(
llvm::Value *arrayBegin,
1656 Destroyer *destroyer);
1663 Destroyer *destroyer,
bool useEHCleanupForArray);
1666 bool useEHCleanupForArray);
1667 void pushCallObjectDeleteCleanup(
const FunctionDecl *OperatorDelete,
1672 bool useEHCleanupForArray);
1674 Destroyer *destroyer,
1675 bool useEHCleanupForArray,
1679 Destroyer *destroyer,
1680 bool checkZeroLength,
bool useEHCleanup);
1688 case QualType::DK_none:
1690 case QualType::DK_cxx_destructor:
1691 case QualType::DK_objc_weak_lifetime:
1692 case QualType::DK_nontrivial_c_struct:
1693 return getLangOpts().Exceptions;
1694 case QualType::DK_objc_strong_lifetime:
1695 return getLangOpts().Exceptions &&
1698 llvm_unreachable(
"bad destruction kind");
1719 llvm::Constant *AtomicHelperFn);
1730 llvm::Constant *AtomicHelperFn);
1743 llvm::Function *GenerateBlockFunction(
GlobalDecl GD,
1745 const DeclMapTy &ldm,
1746 bool IsLambdaConversionToBlock,
1747 bool BuildGlobalBlock);
1749 llvm::Constant *GenerateCopyHelperFunction(
const CGBlockInfo &blockInfo);
1750 llvm::Constant *GenerateDestroyHelperFunction(
const CGBlockInfo &blockInfo);
1751 llvm::Constant *GenerateObjCAtomicSetterCopyHelperFunction(
1753 llvm::Constant *GenerateObjCAtomicGetterCopyHelperFunction(
1780 bool LoadBlockVarAddr);
1791 bool followForward =
true);
1795 const llvm::Twine &name);
1801 void GenerateCode(
GlobalDecl GD, llvm::Function *Fn,
1820 void EmitBlockWithFallThrough(llvm::BasicBlock *BB,
const Stmt *S);
1822 void EmitForwardingCallToLambda(
const CXXMethodDecl *LambdaCallOperator,
1824 void EmitLambdaBlockInvokeBody();
1825 void EmitLambdaDelegatingInvokeBody(
const CXXMethodDecl *MD);
1827 void EmitAsanPrologueOrEpilogue(
bool Prologue);
1833 llvm::DebugLoc EmitReturnBlock();
1839 void StartThunk(llvm::Function *Fn,
GlobalDecl GD,
1842 void EmitCallAndReturnForThunk(llvm::Constant *Callee,
const ThunkInfo *Thunk,
1843 bool IsUnprototyped);
1852 void generateThunk(llvm::Function *Fn,
const CGFunctionInfo &FnInfo,
1854 bool IsUnprototyped);
1856 llvm::Function *GenerateVarArgsThunk(llvm::Function *Fn,
1874 void InitializeVTablePointer(
const VPtr &vptr);
1879 VPtrsVector getVTablePointers(
const CXXRecordDecl *VTableClass);
1883 bool BaseIsNonVirtualPrimaryBase,
1885 VisitedVirtualBasesSetTy &VBases, VPtrsVector &vptrs);
1887 void InitializeVTablePointers(
const CXXRecordDecl *ClassDecl);
1930 bool ShouldEmitVTableTypeCheckedLoad(
const CXXRecordDecl *RD);
1934 uint64_t VTableByteOffset);
1944 bool ShouldInstrumentFunction();
1948 bool ShouldXRayInstrumentFunction()
const;
1952 bool AlwaysEmitXRayCustomEvents()
const;
1956 bool AlwaysEmitXRayTypedEvents()
const;
1959 llvm::Constant *EncodeAddrForUseInPrologue(llvm::Function *F,
1960 llvm::Constant *Addr);
1976 void EmitFunctionEpilog(
const CGFunctionInfo &FI,
bool EmitRetDbgLoc,
1983 void EmitStartEHSpec(
const Decl *D);
1986 void EmitEndEHSpec(
const Decl *D);
1989 llvm::BasicBlock *getTerminateLandingPad();
1993 llvm::BasicBlock *getTerminateFunclet();
1998 llvm::BasicBlock *getTerminateHandler();
2000 llvm::Type *ConvertTypeForMem(
QualType T);
2001 llvm::Type *ConvertType(
QualType T);
2003 return ConvertType(getContext().getTypeDeclType(T));
2026 llvm::Function *parent =
nullptr,
2027 llvm::BasicBlock *before =
nullptr) {
2038 void SimplifyForwardingBlocks(llvm::BasicBlock *BB);
2048 void EmitBlock(llvm::BasicBlock *BB,
bool IsFinished=
false);
2052 void EmitBlockAfterUses(llvm::BasicBlock *BB);
2062 void EmitBranch(llvm::BasicBlock *Block);
2067 return Builder.GetInsertBlock() !=
nullptr;
2075 if (!HaveInsertPoint())
2076 EmitBlock(createBasicBlock());
2081 void ErrorUnsupported(
const Stmt *S,
const char *Type);
2089 return LValue::MakeAddr(Addr, T, getContext(),
LValueBaseInfo(Source),
2095 return LValue::MakeAddr(Addr, T, getContext(), BaseInfo, TBAAInfo);
2100 return LValue::MakeAddr(
Address(V, Alignment), T, getContext(),
2106 return LValue::MakeAddr(
Address(V, Alignment), T, getContext(),
2107 BaseInfo, TBAAInfo);
2115 bool forPointeeType =
false);
2129 return EmitLoadOfReferenceLValue(RefLVal);
2163 llvm::AllocaInst *CreateTempAlloca(llvm::Type *Ty,
const Twine &Name =
"tmp",
2166 const Twine &Name =
"tmp",
2170 const Twine &Name =
"tmp",
2183 Address CreateDefaultAlignTempAlloca(llvm::Type *Ty,
2184 const Twine &Name =
"tmp");
2215 Address CreateMemTempWithoutCast(
QualType T,
const Twine &Name =
"tmp");
2217 const Twine &Name =
"tmp");
2222 return AggValueSlot::forAddr(CreateMemTemp(T, Name),
2224 AggValueSlot::IsNotDestructed,
2225 AggValueSlot::DoesNotNeedGCBarriers,
2226 AggValueSlot::IsNotAliased,
2227 AggValueSlot::DoesNotOverlap);
2238 void EmitIgnoredExpr(
const Expr *E);
2248 bool ignoreResult =
false);
2265 void EmitAnyExprToMem(
const Expr *E,
Address Location,
2268 void EmitAnyExprToExn(
const Expr *E,
Address Addr);
2273 bool capturedByInit);
2279 const RecordDecl *RD = cast<RecordDecl>(RT->getDecl());
2290 return AggValueSlot::DoesNotOverlap;
2300 return AggValueSlot::DoesNotOverlap;
2311 bool IsVolatile = hasVolatileMember(EltTy);
2312 EmitAggregateCopy(Dest, Src, EltTy, AggValueSlot::MayOverlap, IsVolatile);
2317 EmitAggregateCopy(Dest, Src, Src.
getType(), MayOverlap);
2329 bool isVolatile =
false);
2333 auto it = LocalDeclMap.find(VD);
2334 assert(it != LocalDeclMap.end() &&
2335 "Invalid argument to GetAddrOfLocalVar(), no decl!");
2352 static unsigned getAccessedFieldNo(
unsigned Idx,
const llvm::Constant *Elts);
2354 llvm::BlockAddress *GetAddrOfLabel(
const LabelDecl *L);
2355 llvm::BasicBlock *GetIndirectGotoBlock();
2358 static bool IsWrappedCXXThis(
const Expr *E);
2393 void EmitVariablyModifiedType(
QualType Ty);
2417 assert(CXXThisValue &&
"no 'this' value for this function");
2418 return CXXThisValue;
2427 assert(CXXStructorImplicitParamValue &&
"no VTT value for this function");
2428 return CXXStructorImplicitParamValue;
2434 GetAddressOfDirectBaseInCompleteClass(
Address Value,
2437 bool BaseIsVirtual);
2439 static bool ShouldNullCheckClassCastValue(
const CastExpr *Cast);
2453 bool NullCheckValue);
2479 bool ForVirtualBase,
2487 bool ForVirtualBase,
Address This,
2488 bool InheritedFromVBase,
2492 bool ForVirtualBase,
bool Delegating,
2495 bool NewPointerIsChecked);
2498 bool ForVirtualBase,
bool Delegating,
2502 bool NewPointerIsChecked);
2509 void EmitVTableAssumptionLoad(
const VPtr &vptr,
Address This);
2519 bool NewPointerIsChecked,
2520 bool ZeroInitialization =
false);
2526 bool NewPointerIsChecked,
2527 bool ZeroInitialization =
false);
2532 bool ForVirtualBase,
bool Delegating,
2536 llvm::Type *ElementTy,
Address NewPtr,
2554 const CallExpr *TheCallExpr,
bool IsDelete);
2595 TCK_DynamicOperation
2606 bool sanitizePerformTypeCheck()
const;
2618 QualType IndexType,
bool Accessed);
2621 bool isInc,
bool isPre);
2623 bool isInc,
bool isPre);
2627 Builder.CreateAlignmentAssumption(CGM.
getDataLayout(), PtrValue, Alignment,
2642 void EmitDecl(
const Decl &D);
2647 void EmitVarDecl(
const VarDecl &D);
2650 bool capturedByInit);
2657 bool isTrivialInitializer(
const Expr *Init);
2662 void EmitAutoVarDecl(
const VarDecl &D);
2665 friend class CodeGenFunction;
2682 bool IsConstantAggregate;
2693 : Variable(nullptr), Addr(
Address::invalid()),
2694 AllocaAddr(
Address::invalid()) {}
2697 : Variable(&variable), Addr(
Address::invalid()), NRVOFlag(nullptr),
2699 SizeForLifetimeMarkers(nullptr), AllocaAddr(
Address::invalid()) {}
2701 bool wasEmittedAsGlobal()
const {
return !Addr.
isValid(); }
2707 return SizeForLifetimeMarkers !=
nullptr;
2710 assert(useLifetimeMarkers());
2711 return SizeForLifetimeMarkers;
2728 if (!IsByRef)
return Addr;
2744 void EmitAndRegisterVariableArrayDimensions(
CGDebugInfo *DI,
2746 bool EmitDebugInfo);
2748 void EmitStaticVarDecl(
const VarDecl &D,
2749 llvm::GlobalValue::LinkageTypes
Linkage);
2768 assert(!isIndirect());
2773 assert(isIndirect());
2774 return Address(Value, CharUnits::fromQuantity(Alignment));
2795 Builder.CreateAlignmentAssumption(CGM.
getDataLayout(), PtrValue, Alignment,
2804 void EmitStopPoint(
const Stmt *S);
2820 bool EmitSimpleStmt(
const Stmt *S);
2825 bool GetLast =
false,
2827 AggValueSlot::ignored());
2835 void EmitGotoStmt(
const GotoStmt &S);
2837 void EmitIfStmt(
const IfStmt &S);
2842 void EmitForStmt(
const ForStmt &S,
2845 void EmitDeclStmt(
const DeclStmt &S);
2850 void EmitCaseStmt(
const CaseStmt &S);
2851 void EmitCaseStmtRange(
const CaseStmt &S);
2852 void EmitAsmStmt(
const AsmStmt &S);
2864 bool ignoreResult =
false);
2868 bool ignoreResult =
false);
2870 RValue EmitCoroutineIntrinsic(
const CallExpr *E,
unsigned int IID);
2872 void EnterCXXTryStmt(
const CXXTryStmt &S,
bool IsFnTryBlock =
false);
2873 void ExitCXXTryStmt(
const CXXTryStmt &S,
bool IsFnTryBlock =
false);
2882 llvm::Function *FinallyFunc);
2883 void startOutlinedSEHHelper(CodeGenFunction &ParentCGF,
bool IsFilter,
2884 const Stmt *OutlinedStmt);
2886 llvm::Function *GenerateSEHFilterFunction(CodeGenFunction &ParentCGF,
2889 llvm::Function *GenerateSEHFinallyFunction(CodeGenFunction &ParentCGF,
2892 void EmitSEHExceptionCodeSave(CodeGenFunction &ParentCGF,
2905 void EmitCapturedLocals(CodeGenFunction &ParentCGF,
const Stmt *OutlinedStmt,
2913 Address recoverAddrOfEscapedLocal(CodeGenFunction &ParentCGF,
2922 CodeGenFunction &CGF;
2928 CGF.OMPCancelStack.enter(CGF, Kind, HasCancel);
2937 llvm::Function *GenerateCapturedStmtFunction(
const CapturedStmt &S);
2939 llvm::Function *GenerateOpenMPCapturedStmtFunction(
const CapturedStmt &S);
2953 void EmitOMPAggregateAssign(
2967 void EmitOMPCopy(
QualType OriginalType,
2984 std::pair<bool, RValue> EmitOMPAtomicSimpleUpdateExpr(
2992 void EmitOMPUseDevicePtrClause(
2994 const llvm::DenseMap<const ValueDecl *, Address> &CaptureDeviceAddrMap);
3036 void EmitOMPLinearClauseFinal(
3038 const llvm::function_ref<
llvm::Value *(CodeGenFunction &)> CondGen);
3063 typedef const llvm::function_ref<void(CodeGenFunction & ,
3075 unsigned NumberOfTargetItems = 0;
3078 Address SizesArray,
unsigned NumberOfTargetItems)
3079 : BasePointersArray(BasePointersArray), PointersArray(PointersArray),
3080 SizesArray(SizesArray), NumberOfTargetItems(NumberOfTargetItems) {}
3122 void EmitOMPDistributeParallelForDirective(
3124 void EmitOMPDistributeParallelForSimdDirective(
3127 void EmitOMPTargetParallelForSimdDirective(
3133 void EmitOMPTeamsDistributeParallelForSimdDirective(
3135 void EmitOMPTeamsDistributeParallelForDirective(
3138 void EmitOMPTargetTeamsDistributeDirective(
3140 void EmitOMPTargetTeamsDistributeParallelForDirective(
3142 void EmitOMPTargetTeamsDistributeParallelForSimdDirective(
3144 void EmitOMPTargetTeamsDistributeSimdDirective(
3149 StringRef ParentName,
3152 EmitOMPTargetParallelDeviceFunction(
CodeGenModule &CGM, StringRef ParentName,
3155 static void EmitOMPTargetParallelForDeviceFunction(
3159 static void EmitOMPTargetParallelForSimdDeviceFunction(
3164 EmitOMPTargetTeamsDeviceFunction(
CodeGenModule &CGM, StringRef ParentName,
3167 static void EmitOMPTargetTeamsDistributeDeviceFunction(
3171 static void EmitOMPTargetTeamsDistributeSimdDeviceFunction(
3175 static void EmitOMPTargetSimdDeviceFunction(
CodeGenModule &CGM,
3176 StringRef ParentName,
3180 static void EmitOMPTargetTeamsDistributeParallelForSimdDeviceFunction(
3184 static void EmitOMPTargetTeamsDistributeParallelForDeviceFunction(
3197 void EmitOMPInnerLoop(
3198 const Stmt &S,
bool RequiresCleanup,
const Expr *LoopCond,
3199 const Expr *IncExpr,
3200 const llvm::function_ref<
void(CodeGenFunction &)> BodyGen,
3201 const llvm::function_ref<
void(CodeGenFunction &)> PostIncGen);
3224 void EmitOMPSimdFinal(
3226 const llvm::function_ref<
llvm::Value *(CodeGenFunction &)> CondGen);
3236 struct OMPLoopArguments {
3238 Address LB = Address::invalid();
3240 Address UB = Address::invalid();
3242 Address ST = Address::invalid();
3244 Address IL = Address::invalid();
3248 Expr *EUB =
nullptr;
3250 Expr *IncExpr =
nullptr;
3252 Expr *Init =
nullptr;
3254 Expr *Cond =
nullptr;
3256 Expr *NextLB =
nullptr;
3258 Expr *NextUB =
nullptr;
3259 OMPLoopArguments() =
default;
3262 Expr *IncExpr =
nullptr,
Expr *Init =
nullptr,
3263 Expr *Cond =
nullptr,
Expr *NextLB =
nullptr,
3264 Expr *NextUB =
nullptr)
3265 : LB(LB), UB(UB), ST(ST), IL(IL), Chunk(Chunk), EUB(EUB),
3266 IncExpr(IncExpr), Init(Init), Cond(Cond), NextLB(NextLB),
3269 void EmitOMPOuterLoop(
bool DynamicOrOrdered,
bool IsMonotonic,
3271 const OMPLoopArguments &LoopArgs,
3277 const OMPLoopArguments &LoopArgs,
3282 const OMPLoopArguments &LoopArgs,
3335 bool LValueIsSuitableForInlineAtomic(
LValue Src);
3341 llvm::AtomicOrdering AO,
bool IsVolatile =
false,
3344 void EmitAtomicStore(
RValue rvalue,
LValue lvalue,
bool isInit);
3346 void EmitAtomicStore(
RValue rvalue,
LValue lvalue, llvm::AtomicOrdering AO,
3347 bool IsVolatile,
bool isInit);
3349 std::pair<RValue, llvm::Value *> EmitAtomicCompareExchange(
3351 llvm::AtomicOrdering Success =
3352 llvm::AtomicOrdering::SequentiallyConsistent,
3353 llvm::AtomicOrdering Failure =
3354 llvm::AtomicOrdering::SequentiallyConsistent,
3355 bool IsWeak =
false,
AggValueSlot Slot = AggValueSlot::ignored());
3357 void EmitAtomicUpdate(
LValue LVal, llvm::AtomicOrdering AO,
3382 bool isNontemporal =
false) {
3383 return EmitLoadOfScalar(Addr, Volatile, Ty, Loc,
LValueBaseInfo(Source),
3390 bool isNontemporal =
false);
3404 bool isInit =
false,
bool isNontemporal =
false) {
3405 EmitStoreOfScalar(Value, Addr, Volatile, Ty,
LValueBaseInfo(Source),
3412 bool isInit =
false,
bool isNontemporal =
false);
3432 void EmitStoreThroughLValue(
RValue Src,
LValue Dst,
bool isInit =
false);
3433 void EmitStoreThroughExtVectorComponentLValue(
RValue Src,
LValue Dst);
3434 void EmitStoreThroughGlobalRegLValue(
RValue Src,
LValue Dst);
3442 void EmitStoreThroughBitfieldLValue(
RValue Src,
LValue Dst,
3464 bool Accessed =
false);
3466 bool IsLowerBound =
true);
3481 Address EmitArrayToPointerDecay(
const Expr *Array,
3486 llvm::PointerIntPair<llvm::Constant*, 1, bool> ValueAndIsReference;
3488 : ValueAndIsReference(C, isReference) {}
3499 return ValueAndIsReference.getOpaqueValue() !=
nullptr;
3504 assert(isReference());
3510 assert(!isReference());
3511 return ValueAndIsReference.getPointer();
3535 unsigned CVRQualifiers);
3562 llvm::Instruction **callOrInvoke =
nullptr) {
3563 return EmitCall(CallInfo, Callee, ReturnValue, Args, callOrInvoke,
3575 llvm::CallInst *EmitRuntimeCall(
llvm::Value *callee,
3576 const Twine &name =
"");
3577 llvm::CallInst *EmitRuntimeCall(
llvm::Value *callee,
3579 const Twine &name =
"");
3580 llvm::CallInst *EmitNounwindRuntimeCall(
llvm::Value *callee,
3581 const Twine &name =
"");
3582 llvm::CallInst *EmitNounwindRuntimeCall(
llvm::Value *callee,
3584 const Twine &name =
"");
3589 llvm::CallSite EmitCallOrInvoke(
llvm::Value *Callee,
3591 const Twine &Name =
"");
3592 llvm::CallSite EmitRuntimeCallOrInvoke(
llvm::Value *callee,
3594 const Twine &name =
"");
3595 llvm::CallSite EmitRuntimeCallOrInvoke(
llvm::Value *callee,
3596 const Twine &name =
"");
3597 void EmitNoreturnRuntimeCallOrInvoke(
llvm::Value *callee,
3610 void defaultInitNonTrivialCStructVar(
LValue Dst);
3611 void callCStructDefaultConstructor(
LValue Dst);
3612 void callCStructDestructor(
LValue Dst);
3613 void callCStructCopyConstructor(
LValue Dst,
LValue Src);
3614 void callCStructMoveConstructor(
LValue Dst,
LValue Src);
3615 void callCStructCopyAssignmentOperator(
LValue Dst,
LValue Src);
3616 void callCStructMoveAssignmentOperator(
LValue Dst,
LValue Src);
3637 bool IsArrow,
const Expr *Base);
3659 unsigned BuiltinID,
const CallExpr *E,
3665 llvm::Function *generateBuiltinOSLogHelperFunction(
3676 const llvm::CmpInst::Predicate Fp,
3677 const llvm::CmpInst::Predicate Ip,
3678 const llvm::Twine &Name =
"");
3680 llvm::Triple::ArchType Arch);
3682 llvm::Value *EmitCommonNeonBuiltinExpr(
unsigned BuiltinID,
3683 unsigned LLVMIntrinsic,
3684 unsigned AltLLVMIntrinsic,
3685 const char *NameHint,
3690 llvm::Triple::ArchType Arch);
3695 llvm::Function *LookupNeonLLVMIntrinsic(
unsigned IntrinsicID,
3696 unsigned Modifier, llvm::Type *ArgTy,
3701 unsigned shift = 0,
bool rightshift =
false);
3704 bool negateForRightShift);
3706 llvm::Type *Ty,
bool usgn,
const char *name);
3709 llvm::Triple::ArchType Arch);
3717 llvm::Value *EmitWebAssemblyBuiltinExpr(
unsigned BuiltinID,
3749 void EmitARCDestroyWeak(
Address addr);
3760 bool resultIgnored);
3762 bool resultIgnored);
3774 std::pair<LValue,llvm::Value*>
3776 std::pair<LValue,llvm::Value*>
3778 std::pair<LValue,llvm::Value*>
3779 EmitARCStoreUnsafeUnretained(
const BinaryOperator *e,
bool ignored);
3787 bool allowUnsafeClaim);
3800 void EmitObjCAutoreleasePoolPop(
llvm::Value *Ptr);
3803 void EmitObjCAutoreleasePoolCleanup(
llvm::Value *Ptr);
3804 void EmitObjCMRRAutoreleasePoolPop(
llvm::Value *Ptr);
3807 RValue EmitReferenceBindingToExpr(
const Expr *E);
3817 llvm::Value *EmitScalarExpr(
const Expr *E ,
bool IgnoreResultAssign =
false);
3845 ComplexPairTy EmitComplexExpr(
const Expr *E,
3846 bool IgnoreReal =
false,
3847 bool IgnoreImag =
false);
3851 void EmitComplexExprIntoLValue(
const Expr *E,
LValue dest,
bool isInit);
3854 void EmitStoreOfComplex(ComplexPairTy V,
LValue dest,
bool isInit);
3866 llvm::GlobalVariable *
3867 AddInitializerToStaticVarDecl(
const VarDecl &D,
3868 llvm::GlobalVariable *GV);
3873 void EmitCXXGlobalVarDeclInit(
const VarDecl &D, llvm::Constant *DeclPtr,
3876 llvm::Constant *createAtExitStub(
const VarDecl &VD, llvm::Constant *Dtor,
3877 llvm::Constant *Addr);
3881 void registerGlobalDtorWithAtExit(
const VarDecl &D, llvm::Constant *fn,
3882 llvm::Constant *addr);
3885 void registerGlobalDtorWithAtExit(llvm::Constant *dtorStub);
3892 void EmitCXXGuardedInit(
const VarDecl &D, llvm::GlobalVariable *DeclPtr,
3898 void EmitCXXGuardedInitBranch(
llvm::Value *NeedsInit,
3899 llvm::BasicBlock *InitBlock,
3900 llvm::BasicBlock *NoInitBlock,
3905 void GenerateCXXGlobalInitFunc(llvm::Function *Fn,
3907 Address Guard = Address::invalid());
3911 void GenerateCXXGlobalDtorsFunc(
3913 const std::vector<std::pair<llvm::WeakTrackingVH, llvm::Constant *>>
3916 void GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn,
3918 llvm::GlobalVariable *Addr,
3927 enterNonTrivialFullExpression(E);
3931 void EmitCXXThrowExpr(
const CXXThrowExpr *E,
bool KeepInsertionPoint =
true);
3944 StringRef AnnotationStr,
3961 static bool ContainsLabel(
const Stmt *S,
bool IgnoreCaseStmts =
false);
3966 static bool containsBreak(
const Stmt *S);
3970 static bool mightAddDeclToScope(
const Stmt *S);
3975 bool ConstantFoldsToSimpleInteger(
const Expr *Cond,
bool &Result,
3976 bool AllowLabels =
false);
3981 bool ConstantFoldsToSimpleInteger(
const Expr *Cond, llvm::APSInt &Result,
3982 bool AllowLabels =
false);
3989 void EmitBranchOnBoolExpr(
const Expr *Cond, llvm::BasicBlock *TrueBlock,
3990 llvm::BasicBlock *FalseBlock, uint64_t TrueCount);
3998 enum { NotSubtraction =
false, IsSubtraction =
true };
4010 const Twine &Name =
"");
4025 llvm::Constant *EmitCheckTypeDescriptor(
QualType T);
4038 void EmitCheck(
ArrayRef<std::pair<llvm::Value *, SanitizerMask>> Checked,
4061 void EmitCfiCheckStub();
4064 void EmitCfiCheckFail();
4082 void SetFPAccuracy(
llvm::Value *Val,
float Accuracy);
4085 llvm::MDNode *getRangeForLoadFromType(
QualType Ty);
4088 void deferPlaceholderReplacement(llvm::Instruction *Old,
llvm::Value *New);
4091 DeferredReplacements;
4095 assert(!LocalDeclMap.count(VD) &&
"Decl already exists in LocalDeclMap!");
4096 LocalDeclMap.insert({VD, Addr});
4109 void ExpandTypeToArgs(
QualType Ty,
CallArg Arg, llvm::FunctionType *IRFuncTy,
4111 unsigned &IRCallArgPos);
4114 const Expr *InputExpr, std::string &ConstraintStr);
4118 std::string &ConstraintStr,
4126 llvm::Value *evaluateOrEmitBuiltinObjectSize(
const Expr *E,
unsigned Type,
4127 llvm::IntegerType *ResType,
4134 llvm::IntegerType *ResType,
4144 return classDecl->getTypeParamListAsWritten();
4148 return catDecl->getTypeParamList();
4154 template<
typename T>
4168 template <
typename T>
4170 llvm::iterator_range<CallExpr::const_arg_iterator> ArgRange,
4172 unsigned ParamsToSkip = 0,
4177 assert((ParamsToSkip == 0 || CallArgTypeInfo) &&
4178 "Can't skip parameters if type info is not provided");
4179 if (CallArgTypeInfo) {
4181 bool isGenericMethod = isObjCMethodWithTypeParams(CallArgTypeInfo);
4185 for (
auto I = CallArgTypeInfo->param_type_begin() + ParamsToSkip,
4186 E = CallArgTypeInfo->param_type_end();
4187 I != E; ++I, ++Arg) {
4188 assert(Arg != ArgRange.end() &&
"Running over edge of argument list!");
4189 assert((isGenericMethod ||
4190 ((*I)->isVariablyModifiedType() ||
4191 (*I).getNonReferenceType()->isObjCRetainableType() ||
4193 .getCanonicalType((*I).getNonReferenceType())
4196 .getCanonicalType((*Arg)->getType())
4198 "type mismatch in call argument!");
4199 ArgTypes.push_back(*I);
4205 assert((Arg == ArgRange.end() || !CallArgTypeInfo ||
4206 CallArgTypeInfo->isVariadic()) &&
4207 "Extra arguments in non-variadic function!");
4210 for (
auto *A : llvm::make_range(Arg, ArgRange.end()))
4211 ArgTypes.push_back(CallArgTypeInfo ? getVarArgType(A) : A->getType());
4213 EmitCallArgs(Args, ArgTypes, ArgRange, AC, ParamsToSkip, Order);
4217 llvm::iterator_range<CallExpr::const_arg_iterator> ArgRange,
4219 unsigned ParamsToSkip = 0,
4239 Address EmitPointerWithAlignment(
const Expr *Addr,
4248 void EmitSanitizerStatReport(llvm::SanitizerStatKind SSK);
4255 const TargetInfo &TargInfo, llvm::Function *F,
4256 const clang::TargetAttr::ParsedTargetAttr &PT)
4257 : Function(F), ParsedAttribute(PT), Priority(0u) {
4258 for (StringRef Feat : PT.Features)
4262 if (!PT.Architecture.empty())
4271 void EmitTargetMultiVersionResolver(
4272 llvm::Function *Resolver,
4282 : Function(F), FeatureMask(static_cast<uint32_t>(Mask)) {}
4287 void EmitCPUDispatchMultiVersionResolver(
4288 llvm::Function *Resolver,
4295 void EmitDeclMetadata();
4300 void AddObjCARCExceptionMetadata(llvm::Instruction *Inst);
4302 llvm::Value *GetValueForARMHint(
unsigned BuiltinID);
4315 if (!needsSaving(value))
return saved_type(value,
false);
4318 auto align = CharUnits::fromQuantity(
4327 inline llvm::Value *DominatingLLVMValue::restore(CodeGenFunction &CGF,
4330 if (!value.getInt())
return value.getPointer();
4333 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...
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.
TargetAttr::ParsedTargetAttr ParsedAttribute
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 an expression – generally a full-expression – that introduces cleanups to be run at the ...
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)
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)
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.
bool operator>(const TargetMultiVersionResolverOption &Other) const
TargetMultiVersionResolverOption(const TargetInfo &TargInfo, llvm::Function *F, const clang::TargetAttr::ParsedTargetAttr &PT)
ObjCStringLiteral, used for Objective-C string literals i.e.
field_iterator field_begin() const
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.
llvm::Function * Function
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.
void EmitAlignmentAssumption(llvm::Value *PtrValue, llvm::Value *Alignment, llvm::Value *OffsetValue=nullptr)
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.
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 ...
Expr - 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.
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
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 EmitAlignmentAssumption(llvm::Value *PtrValue, unsigned Alignment, llvm::Value *OffsetValue=nullptr)
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...
llvm::Function * Function
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)
void enterFullExpression(const ExprWithCleanups *E)
const TargetCodeGenInfo & getTargetHooks() const
static Destroyer destroyARCStrongImprecise
CXXCtorType
C++ constructor types.
bool operator>(const CPUDispatchMultiVersionResolverOption &Other) const
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.
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)
CPUDispatchMultiVersionResolverOption(llvm::Function *F, uint64_t Mask)
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.
unsigned getNumObjects() const
ObjCEncodeExpr, used for @encode in Objective-C.
A stack of loop information corresponding to loop nesting levels.
virtual unsigned multiVersionSortPriority(StringRef Name) const
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.
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.
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)
__DEVICE__ int max(int __a, int __b)
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.