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;
78 class ReturnsNonNullAttr;
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, 1) \ 119 SANITIZER_CHECK(ImplicitConversion, implicit_conversion, 0) \ 120 SANITIZER_CHECK(InvalidBuiltin, invalid_builtin, 0) \ 121 SANITIZER_CHECK(LoadInvalidValue, load_invalid_value, 0) \ 122 SANITIZER_CHECK(MissingReturn, missing_return, 0) \ 123 SANITIZER_CHECK(MulOverflow, mul_overflow, 0) \ 124 SANITIZER_CHECK(NegateOverflow, negate_overflow, 0) \ 125 SANITIZER_CHECK(NullabilityArg, nullability_arg, 0) \ 126 SANITIZER_CHECK(NullabilityReturn, nullability_return, 1) \ 127 SANITIZER_CHECK(NonnullArg, nonnull_arg, 0) \ 128 SANITIZER_CHECK(NonnullReturn, nonnull_return, 1) \ 129 SANITIZER_CHECK(OutOfBounds, out_of_bounds, 0) \ 130 SANITIZER_CHECK(PointerOverflow, pointer_overflow, 0) \ 131 SANITIZER_CHECK(ShiftOutOfBounds, shift_out_of_bounds, 0) \ 132 SANITIZER_CHECK(SubOverflow, sub_overflow, 0) \ 133 SANITIZER_CHECK(TypeMismatch, type_mismatch, 1) \ 134 SANITIZER_CHECK(AlignmentAssumption, alignment_assumption, 0) \ 135 SANITIZER_CHECK(VLABoundNotPositive, vla_bound_not_positive, 0) 138 #define SANITIZER_CHECK(Enum, Name, Version) Enum, 140 #undef SANITIZER_CHECK 146 typedef llvm::PointerIntPair<llvm::Value*, 1, bool>
saved_type;
151 if (!isa<llvm::Instruction>(value))
return false;
154 llvm::BasicBlock *block = cast<llvm::Instruction>(value)->getParent();
155 return (block != &block->getParent()->getEntryBlock());
167 return static_cast<T*
>(DominatingLLVMValue::restore(CGF, value));
181 return DominatingLLVMValue::needsSaving(value.
getPointer());
184 return { DominatingLLVMValue::save(CGF, value.
getPointer()),
188 return Address(DominatingLLVMValue::restore(CGF, value.SavedValue),
197 enum Kind { ScalarLiteral, ScalarAddress, AggregateLiteral,
198 AggregateAddress, ComplexAddress };
204 :
Value(v), K(k), Align(a) {}
207 static bool needsSaving(
RValue value);
215 return saved_type::needsSaving(value);
218 return saved_type::save(CGF, value);
221 return value.restore(CGF);
236 JumpDest() : Block(nullptr), ScopeDepth(), Index(0) {}
240 : Block(Block), ScopeDepth(Depth), Index(Index) {}
242 bool isValid()
const {
return Block !=
nullptr; }
243 llvm::BasicBlock *
getBlock()
const {
return Block; }
253 llvm::BasicBlock *Block;
274 const unsigned,
const bool)>
278 typedef llvm::function_ref<std::pair<LValue, LValue>(
283 typedef llvm::function_ref<std::pair<llvm::Value *, llvm::Value *>(
290 void InsertHelper(llvm::Instruction *I,
const llvm::Twine &Name,
291 llvm::BasicBlock *BB,
292 llvm::BasicBlock::iterator InsertPt)
const;
301 llvm::Function *CurFn =
nullptr;
307 std::unique_ptr<CGCoroData>
Data;
314 return CurCoro.
Data !=
nullptr;
333 Address ReturnValuePointer = Address::invalid();
338 return CurLexicalScope->hasLabels();
339 return !LabelMap.empty();
350 :
Kind(K), ThisValue(nullptr), CXXThisFieldDecl(nullptr) {}
353 :
Kind(K), ThisValue(nullptr), CXXThisFieldDecl(nullptr) {
359 I != E; ++I, ++Field) {
360 if (I->capturesThis())
361 CXXThisFieldDecl = *Field;
362 else if (I->capturesVariable())
363 CaptureFields[I->getCapturedVar()->getCanonicalDecl()] = *Field;
364 else if (I->capturesVariableByCopy())
365 CaptureFields[I->getCapturedVar()->getCanonicalDecl()] = *Field;
403 llvm::SmallDenseMap<const VarDecl *, FieldDecl *> CaptureFields;
417 CodeGenFunction &CGF;
422 : CGF(CGF), PrevCapturedStmtInfo(CGF.CapturedStmtInfo) {
431 const Decl *CalleeDecl;
438 return dyn_cast_or_null<FunctionDecl>(CalleeDecl);
442 if (
const auto *FD = dyn_cast<FunctionDecl>(CalleeDecl))
443 return FD->getNumParams();
444 return cast<ObjCMethodDecl>(CalleeDecl)->param_size();
447 if (
const auto *FD = dyn_cast<FunctionDecl>(CalleeDecl))
448 return FD->getParamDecl(I);
449 return *(cast<ObjCMethodDecl>(CalleeDecl)->param_begin() + I);
457 bool IsSanitizerScope =
false;
461 CodeGenFunction *CGF;
469 bool CurFuncIsThunk =
false;
472 bool AutoreleaseResult =
false;
476 bool SawAsmBlock =
false;
482 bool IsOutlinedSEHHelper =
false;
486 bool IsInPreservedAIRegion =
false;
496 llvm::DenseMap<const VarDecl *, llvm::Value *>
NRVOFlags;
502 llvm::Instruction *CurrentFuncletPad =
nullptr;
510 : Addr(addr.getPointer()), Size(size) {}
532 Address NormalCleanupDest = Address::invalid();
534 unsigned NextCleanupDestIndex = 1;
540 llvm::BasicBlock *EHResumeBlock =
nullptr;
548 llvm::AllocaInst *EHSelectorSlot =
nullptr;
559 llvm::BasicBlock *EmitLandingPad();
561 llvm::BasicBlock *getInvokeDestImpl();
579 llvm::FunctionCallee BeginCatchFn;
583 llvm::AllocaInst *ForEHVar;
587 llvm::AllocaInst *SavedExnVar;
590 void enter(CodeGenFunction &CGF,
const Stmt *Finally,
591 llvm::FunctionCallee beginCatchFn,
592 llvm::FunctionCallee endCatchFn, llvm::FunctionCallee rethrowFn);
593 void exit(CodeGenFunction &CGF);
601 return CurrentFuncletPad && isa<llvm::CleanupPadInst>(CurrentFuncletPad);
607 template <
class T,
class... As>
611 if (!isInConditionalBranch())
612 return EHStack.pushCleanup<T>(
kind, A...);
615 typedef std::tuple<typename DominatingValue<As>::saved_type...> SavedTuple;
616 SavedTuple Saved{saveValueInCond(A)...};
620 initFullExprCleanup();
625 template <
class T,
class... As>
627 if (!isInConditionalBranch())
628 return pushCleanupAfterFullExprImpl<T>(
Kind, Address::invalid(), A...);
630 Address ActiveFlag = createCleanupActiveFlag();
632 "cleanup active flag should never need saving");
634 typedef std::tuple<typename DominatingValue<As>::saved_type...> SavedTuple;
635 SavedTuple Saved{saveValueInCond(A)...};
638 pushCleanupAfterFullExprImpl<CleanupType>(
Kind, ActiveFlag, Saved);
641 template <
class T,
class... As>
647 size_t OldSize = LifetimeExtendedCleanupStack.size();
648 LifetimeExtendedCleanupStack.resize(
649 LifetimeExtendedCleanupStack.size() +
sizeof(Header) + Header.
Size +
652 static_assert(
sizeof(Header) %
alignof(T) == 0,
653 "Cleanup will be allocated on misaligned address");
654 char *Buffer = &LifetimeExtendedCleanupStack[OldSize];
656 new (Buffer +
sizeof(Header)) T(A...);
658 new (Buffer +
sizeof(Header) +
sizeof(T))
Address(ActiveFlag);
664 initFullExprCleanupWithFlag(createCleanupActiveFlag());
667 void initFullExprCleanupWithFlag(
Address ActiveFlag);
668 Address createCleanupActiveFlag();
684 void PopCleanupBlock(
bool FallThroughIsBranchThrough =
false);
695 llvm::Instruction *DominatingIP);
705 llvm::Instruction *DominatingIP);
711 size_t LifetimeExtendedCleanupStackSize;
712 bool OldDidCallStackSave;
726 : PerformCleanup(
true), CGF(CGF)
729 LifetimeExtendedCleanupStackSize =
731 OldDidCallStackSave = CGF.DidCallStackSave;
732 CGF.DidCallStackSave =
false;
754 void ForceCleanup(std::initializer_list<llvm::Value**> ValuesToReload = {}) {
755 assert(PerformCleanup &&
"Already forced cleanup");
756 CGF.DidCallStackSave = OldDidCallStackSave;
759 PerformCleanup =
false;
766 EHScopeStack::stable_end();
780 CGF.CurLexicalScope =
this;
786 assert(PerformCleanup &&
"adding label to dead scope?");
787 Labels.push_back(label);
798 if (PerformCleanup) {
807 CGF.CurLexicalScope = ParentScope;
808 RunCleanupsScope::ForceCleanup();
815 return !Labels.empty();
818 void rescopeLabels();
821 typedef llvm::DenseMap<const Decl *, Address>
DeclMapTy;
825 DeclMapTy SavedLocals;
826 DeclMapTy SavedTempAddresses;
833 assert(SavedLocals.empty() &&
"Did not restored original addresses.");
843 if (SavedLocals.count(LocalVD))
return false;
846 auto it = CGF.LocalDeclMap.find(LocalVD);
847 if (it != CGF.LocalDeclMap.end())
848 SavedLocals.try_emplace(LocalVD, it->second);
850 SavedLocals.try_emplace(LocalVD, Address::invalid());
859 SavedTempAddresses.try_emplace(LocalVD, TempAddr);
868 copyInto(SavedTempAddresses, CGF.LocalDeclMap);
869 SavedTempAddresses.clear();
870 return !SavedLocals.empty();
875 if (!SavedLocals.empty()) {
876 copyInto(SavedLocals, CGF.LocalDeclMap);
884 static void copyInto(
const DeclMapTy &Src, DeclMapTy &Dest) {
885 for (
auto &Pair : Src) {
886 if (!Pair.second.isValid()) {
887 Dest.erase(Pair.first);
891 auto I = Dest.find(Pair.first);
893 I->second = Pair.second;
918 const llvm::function_ref<
Address()> PrivateGen) {
919 assert(PerformCleanup &&
"adding private to dead scope");
920 return MappedVars.
setVarAddr(CGF, LocalVD, PrivateGen());
934 RunCleanupsScope::ForceCleanup();
955 CodeGenFunction &CGF;
960 : CGF(CGF), SavedMap(CGF.LocalDeclMap) {}
968 std::initializer_list<llvm::Value **> ValuesToReload = {});
975 size_t OldLifetimeExtendedStackSize,
976 std::initializer_list<llvm::Value **> ValuesToReload = {});
978 void ResolveBranchFixups(llvm::BasicBlock *Target);
986 NextCleanupDestIndex++);
993 return getJumpDestInCurrentScope(createBasicBlock(Name));
999 void EmitBranchThroughCleanup(
JumpDest Dest);
1004 bool isObviouslyBranchWithoutCleanups(
JumpDest Dest)
const;
1009 void popCatchScope();
1011 llvm::BasicBlock *getEHResumeBlock(
bool isCleanup);
1018 llvm::BasicBlock *StartBB;
1022 : StartBB(CGF.Builder.GetInsertBlock()) {}
1025 assert(CGF.OutermostConditional !=
this);
1026 if (!CGF.OutermostConditional)
1027 CGF.OutermostConditional =
this;
1030 void end(CodeGenFunction &CGF) {
1031 assert(CGF.OutermostConditional !=
nullptr);
1032 if (CGF.OutermostConditional ==
this)
1033 CGF.OutermostConditional =
nullptr;
1048 assert(isInConditionalBranch());
1049 llvm::BasicBlock *block = OutermostConditional->getStartingBlock();
1050 auto store =
new llvm::StoreInst(value, addr.
getPointer(), &block->back());
1057 CodeGenFunction &CGF;
1066 : CGF(CGF), SavedOutermostConditional(CGF.OutermostConditional) {
1067 CGF.OutermostConditional =
nullptr;
1071 CGF.OutermostConditional = SavedOutermostConditional;
1080 llvm::Instruction *Inst;
1081 friend class CodeGenFunction;
1100 : OpaqueValue(ov), BoundLValue(boundLValue) {}
1112 hasAggregateEvaluationKind(expr->
getType());
1118 if (shouldBindAsLValue(ov))
1126 assert(shouldBindAsLValue(ov));
1127 CGF.OpaqueLValues.insert(std::make_pair(ov, lv));
1134 assert(!shouldBindAsLValue(ov));
1135 CGF.OpaqueRValues.insert(std::make_pair(ov, rv));
1147 bool isValid()
const {
return OpaqueValue !=
nullptr; }
1151 assert(OpaqueValue &&
"no data to unbind!");
1154 CGF.OpaqueLValues.erase(OpaqueValue);
1156 CGF.OpaqueRValues.erase(OpaqueValue);
1164 CodeGenFunction &CGF;
1169 return OpaqueValueMappingData::shouldBindAsLValue(expr);
1179 if (isa<ConditionalOperator>(op))
1193 assert(OV->
getSourceExpr() &&
"wrong form of OpaqueValueMapping used " 1194 "for OVE with no source expression");
1195 Data = OpaqueValueMappingData::bind(CGF, OV, OV->
getSourceExpr());
1224 unsigned VLAExprCounter = 0;
1225 bool DisableDebugInfo =
false;
1229 bool DidCallStackSave =
false;
1235 llvm::IndirectBrInst *IndirectBranch =
nullptr;
1239 DeclMapTy LocalDeclMap;
1243 llvm::DenseMap<const ParmVarDecl *, EHScopeStack::stable_iterator>
1244 CalleeDestructedParamCleanups;
1249 llvm::SmallDenseMap<const ParmVarDecl *, const ImplicitParamDecl *, 2>
1254 llvm::DenseMap<llvm::AllocaInst *, int> EscapedLocals;
1257 llvm::DenseMap<const LabelDecl*, JumpDest> LabelMap;
1261 struct BreakContinue {
1263 : BreakBlock(Break), ContinueBlock(Continue) {}
1271 class OpenMPCancelExitStack {
1275 CancelExit() =
default;
1278 :
Kind(Kind), ExitBlock(ExitBlock), ContBlock(ContBlock) {}
1282 bool HasBeenEmitted =
false;
1290 OpenMPCancelExitStack() : Stack(1) {}
1291 ~OpenMPCancelExitStack() =
default;
1293 JumpDest getExitBlock()
const {
return Stack.back().ExitBlock; }
1297 const llvm::function_ref<
void(CodeGenFunction &)> CodeGen) {
1298 if (Stack.back().Kind == Kind && getExitBlock().isValid()) {
1301 assert(!Stack.back().HasBeenEmitted);
1302 auto IP = CGF.
Builder.saveAndClearIP();
1303 CGF.
EmitBlock(Stack.back().ExitBlock.getBlock());
1305 CGF.
EmitBranch(Stack.back().ContBlock.getBlock());
1307 Stack.back().HasBeenEmitted =
true;
1316 Stack.push_back({
Kind,
1324 void exit(CodeGenFunction &CGF) {
1325 if (getExitBlock().isValid()) {
1328 if (!Stack.back().HasBeenEmitted) {
1331 CGF.
EmitBlock(Stack.back().ExitBlock.getBlock());
1334 CGF.
EmitBlock(Stack.back().ContBlock.getBlock());
1336 CGF.
Builder.CreateUnreachable();
1337 CGF.
Builder.ClearInsertionPoint();
1343 OpenMPCancelExitStack OMPCancelStack;
1348 llvm::MDNode *createProfileWeights(uint64_t TrueCount, uint64_t FalseCount);
1350 llvm::MDNode *createProfileWeightsForLoop(
const Stmt *Cond,
1351 uint64_t LoopCount);
1365 if (!Count.hasValue())
1385 llvm::SwitchInst *SwitchInsn =
nullptr;
1391 llvm::BasicBlock *CaseRangeBlock =
nullptr;
1395 llvm::DenseMap<const OpaqueValueExpr *, LValue> OpaqueLValues;
1396 llvm::DenseMap<const OpaqueValueExpr *, RValue> OpaqueRValues;
1404 llvm::DenseMap<const Expr*, llvm::Value*> VLASizeMap;
1408 llvm::BasicBlock *UnreachableBlock =
nullptr;
1411 unsigned NumReturnExprs = 0;
1414 unsigned NumSimpleReturnExprs = 0;
1432 : CGF(CGF), OldCXXDefaultInitExprThis(CGF.CXXDefaultInitExprThis) {
1433 CGF.CXXDefaultInitExprThis =
This;
1436 CGF.CXXDefaultInitExprThis = OldCXXDefaultInitExprThis;
1440 CodeGenFunction &CGF;
1441 Address OldCXXDefaultInitExprThis;
1449 : CGF(CGF), OldCXXThisValue(CGF.CXXThisValue),
1450 OldCXXThisAlignment(CGF.CXXThisAlignment),
1451 SourceLocScope(E, CGF.CurSourceLocExprScope) {
1452 CGF.CXXThisValue = CGF.CXXDefaultInitExprThis.
getPointer();
1453 CGF.CXXThisAlignment = CGF.CXXDefaultInitExprThis.
getAlignment();
1456 CGF.CXXThisValue = OldCXXThisValue;
1457 CGF.CXXThisAlignment = OldCXXThisAlignment;
1477 : CGF(CGF), OldArrayInitIndex(CGF.ArrayInitIndex) {
1478 CGF.ArrayInitIndex = Index;
1481 CGF.ArrayInitIndex = OldArrayInitIndex;
1485 CodeGenFunction &CGF;
1492 : CGF(CGF), OldCurGD(CGF.CurGD), OldCurFuncDecl(CGF.CurFuncDecl),
1493 OldCurCodeDecl(CGF.CurCodeDecl),
1494 OldCXXABIThisDecl(CGF.CXXABIThisDecl),
1495 OldCXXABIThisValue(CGF.CXXABIThisValue),
1496 OldCXXThisValue(CGF.CXXThisValue),
1497 OldCXXABIThisAlignment(CGF.CXXABIThisAlignment),
1498 OldCXXThisAlignment(CGF.CXXThisAlignment),
1499 OldReturnValue(CGF.ReturnValue), OldFnRetTy(CGF.FnRetTy),
1500 OldCXXInheritedCtorInitExprArgs(
1501 std::move(CGF.CXXInheritedCtorInitExprArgs)) {
1504 cast<CXXConstructorDecl>(GD.
getDecl());
1505 CGF.CXXABIThisDecl =
nullptr;
1506 CGF.CXXABIThisValue =
nullptr;
1507 CGF.CXXThisValue =
nullptr;
1512 CGF.CXXInheritedCtorInitExprArgs.clear();
1515 CGF.
CurGD = OldCurGD;
1518 CGF.CXXABIThisDecl = OldCXXABIThisDecl;
1519 CGF.CXXABIThisValue = OldCXXABIThisValue;
1520 CGF.CXXThisValue = OldCXXThisValue;
1521 CGF.CXXABIThisAlignment = OldCXXABIThisAlignment;
1522 CGF.CXXThisAlignment = OldCXXThisAlignment;
1525 CGF.CXXInheritedCtorInitExprArgs =
1526 std::move(OldCXXInheritedCtorInitExprArgs);
1530 CodeGenFunction &CGF;
1532 const Decl *OldCurFuncDecl;
1533 const Decl *OldCurCodeDecl;
1555 Address CXXDefaultInitExprThis = Address::invalid();
1568 llvm::Value *CXXStructorImplicitParamValue =
nullptr;
1584 llvm::DenseMap<const ValueDecl *, BlockByrefInfo> BlockByrefInfos;
1588 llvm::Value *RetValNullabilityPrecondition =
nullptr;
1592 bool requiresReturnValueNullabilityCheck()
const {
1593 return RetValNullabilityPrecondition;
1598 Address ReturnLocation = Address::invalid();
1601 bool requiresReturnValueCheck()
const;
1603 llvm::BasicBlock *TerminateLandingPad =
nullptr;
1604 llvm::BasicBlock *TerminateHandler =
nullptr;
1605 llvm::BasicBlock *TrapBB =
nullptr;
1608 llvm::MapVector<llvm::Value *, llvm::BasicBlock *> TerminateFunclets;
1612 unsigned LargestVectorWidth = 0;
1615 const bool ShouldEmitLifetimeMarkers;
1620 llvm::Function *Fn);
1623 CodeGenFunction(
CodeGenModule &cgm,
bool suppressNewContext=
false);
1629 if (DisableDebugInfo)
1652 Address getNormalCleanupDestSlot();
1655 if (!UnreachableBlock) {
1656 UnreachableBlock = createBasicBlock(
"unreachable");
1657 new llvm::UnreachableInst(getLLVMContext(), UnreachableBlock);
1659 return UnreachableBlock;
1664 return getInvokeDestImpl();
1681 void pushIrregularPartialArrayCleanup(
llvm::Value *arrayBegin,
1685 Destroyer *destroyer);
1686 void pushRegularPartialArrayCleanup(
llvm::Value *arrayBegin,
1690 Destroyer *destroyer);
1697 Destroyer *destroyer,
bool useEHCleanupForArray);
1700 bool useEHCleanupForArray);
1701 void pushCallObjectDeleteCleanup(
const FunctionDecl *OperatorDelete,
1706 bool useEHCleanupForArray);
1708 Destroyer *destroyer,
1709 bool useEHCleanupForArray,
1713 Destroyer *destroyer,
1714 bool checkZeroLength,
bool useEHCleanup);
1722 case QualType::DK_none:
1724 case QualType::DK_cxx_destructor:
1725 case QualType::DK_objc_weak_lifetime:
1726 case QualType::DK_nontrivial_c_struct:
1727 return getLangOpts().Exceptions;
1728 case QualType::DK_objc_strong_lifetime:
1729 return getLangOpts().Exceptions &&
1732 llvm_unreachable(
"bad destruction kind");
1753 llvm::Constant *AtomicHelperFn);
1764 llvm::Constant *AtomicHelperFn);
1777 llvm::Function *GenerateBlockFunction(
GlobalDecl GD,
1779 const DeclMapTy &ldm,
1780 bool IsLambdaConversionToBlock,
1781 bool BuildGlobalBlock);
1784 static bool cxxDestructorCanThrow(
QualType T);
1786 llvm::Constant *GenerateCopyHelperFunction(
const CGBlockInfo &blockInfo);
1787 llvm::Constant *GenerateDestroyHelperFunction(
const CGBlockInfo &blockInfo);
1788 llvm::Constant *GenerateObjCAtomicSetterCopyHelperFunction(
1790 llvm::Constant *GenerateObjCAtomicGetterCopyHelperFunction(
1818 bool LoadBlockVarAddr,
bool CanThrow);
1829 bool followForward =
true);
1833 const llvm::Twine &
name);
1839 void GenerateCode(
GlobalDecl GD, llvm::Function *Fn,
1844 void markAsIgnoreThreadCheckingAtRuntime(llvm::Function *Fn);
1862 void EmitFunctionBody(
const Stmt *Body);
1863 void EmitBlockWithFallThrough(llvm::BasicBlock *BB,
const Stmt *S);
1865 void EmitForwardingCallToLambda(
const CXXMethodDecl *LambdaCallOperator,
1867 void EmitLambdaBlockInvokeBody();
1868 void EmitLambdaDelegatingInvokeBody(
const CXXMethodDecl *MD);
1871 EmitStoreThroughLValue(RValue::get(VLASizeMap[VAT->
getSizeExpr()]), LV);
1873 void EmitAsanPrologueOrEpilogue(
bool Prologue);
1879 llvm::DebugLoc EmitReturnBlock();
1885 void StartThunk(llvm::Function *Fn,
GlobalDecl GD,
1888 void EmitCallAndReturnForThunk(llvm::FunctionCallee Callee,
1889 const ThunkInfo *Thunk,
bool IsUnprototyped);
1895 llvm::FunctionCallee Callee);
1898 void generateThunk(llvm::Function *Fn,
const CGFunctionInfo &FnInfo,
1900 bool IsUnprototyped);
1902 llvm::Function *GenerateVarArgsThunk(llvm::Function *Fn,
1920 void InitializeVTablePointer(
const VPtr &vptr);
1925 VPtrsVector getVTablePointers(
const CXXRecordDecl *VTableClass);
1929 bool BaseIsNonVirtualPrimaryBase,
1931 VisitedVirtualBasesSetTy &VBases, VPtrsVector &vptrs);
1933 void InitializeVTablePointers(
const CXXRecordDecl *ClassDecl);
1976 bool ShouldEmitVTableTypeCheckedLoad(
const CXXRecordDecl *RD);
1980 uint64_t VTableByteOffset);
1990 bool ShouldInstrumentFunction();
1994 bool ShouldXRayInstrumentFunction()
const;
1998 bool AlwaysEmitXRayCustomEvents()
const;
2002 bool AlwaysEmitXRayTypedEvents()
const;
2005 llvm::Constant *EncodeAddrForUseInPrologue(llvm::Function *F,
2006 llvm::Constant *Addr);
2022 void EmitFunctionEpilog(
const CGFunctionInfo &FI,
bool EmitRetDbgLoc,
2029 void EmitStartEHSpec(
const Decl *D);
2032 void EmitEndEHSpec(
const Decl *D);
2035 llvm::BasicBlock *getTerminateLandingPad();
2039 llvm::BasicBlock *getTerminateFunclet();
2044 llvm::BasicBlock *getTerminateHandler();
2046 llvm::Type *ConvertTypeForMem(
QualType T);
2047 llvm::Type *ConvertType(
QualType T);
2049 return ConvertType(getContext().getTypeDeclType(T));
2072 llvm::Function *parent =
nullptr,
2073 llvm::BasicBlock *
before =
nullptr) {
2084 void SimplifyForwardingBlocks(llvm::BasicBlock *BB);
2094 void EmitBlock(llvm::BasicBlock *BB,
bool IsFinished=
false);
2098 void EmitBlockAfterUses(llvm::BasicBlock *BB);
2108 void EmitBranch(llvm::BasicBlock *Block);
2113 return Builder.GetInsertBlock() !=
nullptr;
2121 if (!HaveInsertPoint())
2122 EmitBlock(createBasicBlock());
2127 void ErrorUnsupported(
const Stmt *S,
const char *Type);
2135 return LValue::MakeAddr(Addr, T, getContext(),
LValueBaseInfo(Source),
2141 return LValue::MakeAddr(Addr, T, getContext(), BaseInfo, TBAAInfo);
2146 return LValue::MakeAddr(
Address(V, Alignment), T, getContext(),
2152 return LValue::MakeAddr(
Address(V, Alignment), T, getContext(),
2153 BaseInfo, TBAAInfo);
2161 bool forPointeeType =
false);
2175 return EmitLoadOfReferenceLValue(RefLVal);
2209 llvm::AllocaInst *CreateTempAlloca(llvm::Type *Ty,
const Twine &Name =
"tmp",
2212 const Twine &Name =
"tmp",
2216 const Twine &Name =
"tmp",
2229 Address CreateDefaultAlignTempAlloca(llvm::Type *Ty,
2230 const Twine &Name =
"tmp");
2261 Address CreateMemTempWithoutCast(
QualType T,
const Twine &Name =
"tmp");
2263 const Twine &Name =
"tmp");
2268 return AggValueSlot::forAddr(CreateMemTemp(T, Name),
2270 AggValueSlot::IsNotDestructed,
2271 AggValueSlot::DoesNotNeedGCBarriers,
2272 AggValueSlot::IsNotAliased,
2273 AggValueSlot::DoesNotOverlap);
2284 void EmitIgnoredExpr(
const Expr *E);
2294 bool ignoreResult =
false);
2311 void EmitAnyExprToMem(
const Expr *E,
Address Location,
2314 void EmitAnyExprToExn(
const Expr *E,
Address Addr);
2319 bool capturedByInit);
2325 const RecordDecl *RD = cast<RecordDecl>(RT->getDecl());
2336 return AggValueSlot::DoesNotOverlap;
2350 bool IsVolatile = hasVolatileMember(EltTy);
2351 EmitAggregateCopy(Dest, Src, EltTy, AggValueSlot::MayOverlap, IsVolatile);
2356 EmitAggregateCopy(Dest, Src, Src.
getType(), MayOverlap);
2368 bool isVolatile =
false);
2372 auto it = LocalDeclMap.find(VD);
2373 assert(it != LocalDeclMap.end() &&
2374 "Invalid argument to GetAddrOfLocalVar(), no decl!");
2391 static unsigned getAccessedFieldNo(
unsigned Idx,
const llvm::Constant *Elts);
2393 llvm::BlockAddress *GetAddrOfLabel(
const LabelDecl *L);
2394 llvm::BasicBlock *GetIndirectGotoBlock();
2397 static bool IsWrappedCXXThis(
const Expr *E);
2432 void EmitVariablyModifiedType(
QualType Ty);
2456 assert(CXXThisValue &&
"no 'this' value for this function");
2457 return CXXThisValue;
2466 assert(CXXStructorImplicitParamValue &&
"no VTT value for this function");
2467 return CXXStructorImplicitParamValue;
2473 GetAddressOfDirectBaseInCompleteClass(
Address Value,
2476 bool BaseIsVirtual);
2478 static bool ShouldNullCheckClassCastValue(
const CastExpr *
Cast);
2492 bool NullCheckValue);
2518 bool ForVirtualBase,
2527 bool InheritedFromVBase,
2531 bool ForVirtualBase,
bool Delegating,
2535 bool ForVirtualBase,
bool Delegating,
2545 void EmitVTableAssumptionLoad(
const VPtr &vptr,
Address This);
2555 bool NewPointerIsChecked,
2556 bool ZeroInitialization =
false);
2562 bool NewPointerIsChecked,
2563 bool ZeroInitialization =
false);
2568 bool ForVirtualBase,
bool Delegating,
Address This,
2572 llvm::Type *ElementTy,
Address NewPtr,
2590 const CallExpr *TheCallExpr,
bool IsDelete);
2631 TCK_DynamicOperation
2642 bool sanitizePerformTypeCheck()
const;
2656 QualType IndexType,
bool Accessed);
2659 bool isInc,
bool isPre);
2661 bool isInc,
bool isPre);
2667 unsigned getDebugInfoFIndex(
const RecordDecl *Rec,
unsigned FieldIndex);
2677 void EmitDecl(
const Decl &D);
2682 void EmitVarDecl(
const VarDecl &D);
2685 bool capturedByInit);
2692 bool isTrivialInitializer(
const Expr *Init);
2697 void EmitAutoVarDecl(
const VarDecl &D);
2700 friend class CodeGenFunction;
2714 bool IsEscapingByRef;
2718 bool IsConstantAggregate;
2729 : Variable(nullptr), Addr(
Address::invalid()),
2730 AllocaAddr(
Address::invalid()) {}
2733 : Variable(&variable), Addr(
Address::invalid()), NRVOFlag(nullptr),
2734 IsEscapingByRef(
false), IsConstantAggregate(
false),
2735 SizeForLifetimeMarkers(nullptr), AllocaAddr(
Address::invalid()) {}
2737 bool wasEmittedAsGlobal()
const {
return !Addr.
isValid(); }
2743 return SizeForLifetimeMarkers !=
nullptr;
2746 assert(useLifetimeMarkers());
2747 return SizeForLifetimeMarkers;
2764 if (!IsEscapingByRef)
return Addr;
2780 void EmitAndRegisterVariableArrayDimensions(
CGDebugInfo *DI,
2782 bool EmitDebugInfo);
2784 void EmitStaticVarDecl(
const VarDecl &D,
2785 llvm::GlobalValue::LinkageTypes
Linkage);
2804 assert(!isIndirect());
2809 assert(isIndirect());
2810 return Address(Value, CharUnits::fromQuantity(Alignment));
2835 llvm::Instruction *Assumption);
2851 void EmitStopPoint(
const Stmt *S);
2867 bool EmitSimpleStmt(
const Stmt *S);
2872 bool GetLast =
false,
2874 AggValueSlot::ignored());
2882 void EmitGotoStmt(
const GotoStmt &S);
2884 void EmitIfStmt(
const IfStmt &S);
2889 void EmitForStmt(
const ForStmt &S,
2892 void EmitDeclStmt(
const DeclStmt &S);
2897 void EmitCaseStmt(
const CaseStmt &S);
2898 void EmitCaseStmtRange(
const CaseStmt &S);
2899 void EmitAsmStmt(
const AsmStmt &S);
2911 bool ignoreResult =
false);
2915 bool ignoreResult =
false);
2917 RValue EmitCoroutineIntrinsic(
const CallExpr *E,
unsigned int IID);
2919 void EnterCXXTryStmt(
const CXXTryStmt &S,
bool IsFnTryBlock =
false);
2920 void ExitCXXTryStmt(
const CXXTryStmt &S,
bool IsFnTryBlock =
false);
2929 llvm::Function *FinallyFunc);
2930 void startOutlinedSEHHelper(CodeGenFunction &ParentCGF,
bool IsFilter,
2931 const Stmt *OutlinedStmt);
2933 llvm::Function *GenerateSEHFilterFunction(CodeGenFunction &ParentCGF,
2936 llvm::Function *GenerateSEHFinallyFunction(CodeGenFunction &ParentCGF,
2939 void EmitSEHExceptionCodeSave(CodeGenFunction &ParentCGF,
2952 void EmitCapturedLocals(CodeGenFunction &ParentCGF,
const Stmt *OutlinedStmt,
2960 Address recoverAddrOfEscapedLocal(CodeGenFunction &ParentCGF,
2969 CodeGenFunction &CGF;
2975 CGF.OMPCancelStack.enter(CGF, Kind, HasCancel);
2984 llvm::Function *GenerateCapturedStmtFunction(
const CapturedStmt &S);
2986 llvm::Function *GenerateOpenMPCapturedStmtFunction(
const CapturedStmt &S);
3000 void EmitOMPAggregateAssign(
3014 void EmitOMPCopy(
QualType OriginalType,
3031 std::pair<bool, RValue> EmitOMPAtomicSimpleUpdateExpr(
3039 void EmitOMPUseDevicePtrClause(
3041 const llvm::DenseMap<const ValueDecl *, Address> &CaptureDeviceAddrMap);
3083 void EmitOMPLinearClauseFinal(
3085 const llvm::function_ref<
llvm::Value *(CodeGenFunction &)> CondGen);
3110 typedef const llvm::function_ref<void(CodeGenFunction & ,
3122 unsigned NumberOfTargetItems = 0;
3125 Address SizesArray,
unsigned NumberOfTargetItems)
3126 : BasePointersArray(BasePointersArray), PointersArray(PointersArray),
3127 SizesArray(SizesArray), NumberOfTargetItems(NumberOfTargetItems) {}
3172 void EmitOMPParallelMasterTaskLoopDirective(
3174 void EmitOMPParallelMasterTaskLoopSimdDirective(
3177 void EmitOMPDistributeParallelForDirective(
3179 void EmitOMPDistributeParallelForSimdDirective(
3182 void EmitOMPTargetParallelForSimdDirective(
3188 void EmitOMPTeamsDistributeParallelForSimdDirective(
3190 void EmitOMPTeamsDistributeParallelForDirective(
3193 void EmitOMPTargetTeamsDistributeDirective(
3195 void EmitOMPTargetTeamsDistributeParallelForDirective(
3197 void EmitOMPTargetTeamsDistributeParallelForSimdDirective(
3199 void EmitOMPTargetTeamsDistributeSimdDirective(
3204 StringRef ParentName,
3207 EmitOMPTargetParallelDeviceFunction(
CodeGenModule &CGM, StringRef ParentName,
3210 static void EmitOMPTargetParallelForDeviceFunction(
3214 static void EmitOMPTargetParallelForSimdDeviceFunction(
3219 EmitOMPTargetTeamsDeviceFunction(
CodeGenModule &CGM, StringRef ParentName,
3222 static void EmitOMPTargetTeamsDistributeDeviceFunction(
3226 static void EmitOMPTargetTeamsDistributeSimdDeviceFunction(
3230 static void EmitOMPTargetSimdDeviceFunction(
CodeGenModule &CGM,
3231 StringRef ParentName,
3235 static void EmitOMPTargetTeamsDistributeParallelForSimdDeviceFunction(
3239 static void EmitOMPTargetTeamsDistributeParallelForDeviceFunction(
3252 void EmitOMPInnerLoop(
3253 const Stmt &S,
bool RequiresCleanup,
const Expr *LoopCond,
3254 const Expr *IncExpr,
3255 const llvm::function_ref<
void(CodeGenFunction &)> BodyGen,
3256 const llvm::function_ref<
void(CodeGenFunction &)> PostIncGen);
3279 void EmitOMPSimdFinal(
3281 const llvm::function_ref<
llvm::Value *(CodeGenFunction &)> CondGen);
3291 struct OMPLoopArguments {
3293 Address LB = Address::invalid();
3295 Address UB = Address::invalid();
3297 Address ST = Address::invalid();
3299 Address IL = Address::invalid();
3303 Expr *EUB =
nullptr;
3305 Expr *IncExpr =
nullptr;
3307 Expr *Init =
nullptr;
3309 Expr *Cond =
nullptr;
3311 Expr *NextLB =
nullptr;
3313 Expr *NextUB =
nullptr;
3314 OMPLoopArguments() =
default;
3317 Expr *IncExpr =
nullptr,
Expr *Init =
nullptr,
3318 Expr *Cond =
nullptr,
Expr *NextLB =
nullptr,
3319 Expr *NextUB =
nullptr)
3320 : LB(LB), UB(UB), ST(ST), IL(IL), Chunk(Chunk), EUB(EUB),
3321 IncExpr(IncExpr), Init(Init), Cond(Cond), NextLB(NextLB),
3324 void EmitOMPOuterLoop(
bool DynamicOrOrdered,
bool IsMonotonic,
3326 const OMPLoopArguments &LoopArgs,
3332 const OMPLoopArguments &LoopArgs,
3337 const OMPLoopArguments &LoopArgs,
3390 bool LValueIsSuitableForInlineAtomic(
LValue Src);
3396 llvm::AtomicOrdering AO,
bool IsVolatile =
false,
3399 void EmitAtomicStore(
RValue rvalue,
LValue lvalue,
bool isInit);
3401 void EmitAtomicStore(
RValue rvalue,
LValue lvalue, llvm::AtomicOrdering AO,
3402 bool IsVolatile,
bool isInit);
3404 std::pair<RValue, llvm::Value *> EmitAtomicCompareExchange(
3406 llvm::AtomicOrdering Success =
3407 llvm::AtomicOrdering::SequentiallyConsistent,
3408 llvm::AtomicOrdering Failure =
3409 llvm::AtomicOrdering::SequentiallyConsistent,
3410 bool IsWeak =
false,
AggValueSlot Slot = AggValueSlot::ignored());
3412 void EmitAtomicUpdate(
LValue LVal, llvm::AtomicOrdering AO,
3437 bool isNontemporal =
false) {
3438 return EmitLoadOfScalar(Addr, Volatile, Ty, Loc,
LValueBaseInfo(Source),
3445 bool isNontemporal =
false);
3459 bool isInit =
false,
bool isNontemporal =
false) {
3460 EmitStoreOfScalar(Value, Addr, Volatile, Ty,
LValueBaseInfo(Source),
3467 bool isInit =
false,
bool isNontemporal =
false);
3487 void EmitStoreThroughLValue(
RValue Src,
LValue Dst,
bool isInit =
false);
3488 void EmitStoreThroughExtVectorComponentLValue(
RValue Src,
LValue Dst);
3489 void EmitStoreThroughGlobalRegLValue(
RValue Src,
LValue Dst);
3497 void EmitStoreThroughBitfieldLValue(
RValue Src,
LValue Dst,
3519 bool Accessed =
false);
3521 bool IsLowerBound =
true);
3536 Address EmitArrayToPointerDecay(
const Expr *Array,
3541 llvm::PointerIntPair<llvm::Constant*, 1, bool> ValueAndIsReference;
3543 : ValueAndIsReference(C, isReference) {}
3554 return ValueAndIsReference.getOpaqueValue() !=
nullptr;
3559 assert(isReference());
3565 assert(!isReference());
3566 return ValueAndIsReference.getPointer();
3591 unsigned CVRQualifiers);
3617 llvm::CallBase **callOrInvoke =
nullptr) {
3618 return EmitCall(CallInfo, Callee, ReturnValue, Args, callOrInvoke,
3631 llvm::CallInst *EmitRuntimeCall(llvm::FunctionCallee callee,
3632 const Twine &name =
"");
3633 llvm::CallInst *EmitRuntimeCall(llvm::FunctionCallee callee,
3635 const Twine &name =
"");
3636 llvm::CallInst *EmitNounwindRuntimeCall(llvm::FunctionCallee callee,
3637 const Twine &name =
"");
3638 llvm::CallInst *EmitNounwindRuntimeCall(llvm::FunctionCallee callee,
3640 const Twine &name =
"");
3645 llvm::CallBase *EmitCallOrInvoke(llvm::FunctionCallee Callee,
3647 const Twine &Name =
"");
3648 llvm::CallBase *EmitRuntimeCallOrInvoke(llvm::FunctionCallee callee,
3650 const Twine &name =
"");
3651 llvm::CallBase *EmitRuntimeCallOrInvoke(llvm::FunctionCallee callee,
3652 const Twine &name =
"");
3653 void EmitNoreturnRuntimeCallOrInvoke(llvm::FunctionCallee callee,
3666 static std::string getNonTrivialCopyConstructorStr(
QualType QT,
3672 static std::string getNonTrivialDestructorStr(
QualType QT,
3679 void defaultInitNonTrivialCStructVar(
LValue Dst);
3680 void callCStructDefaultConstructor(
LValue Dst);
3681 void callCStructDestructor(
LValue Dst);
3682 void callCStructCopyConstructor(
LValue Dst,
LValue Src);
3683 void callCStructMoveConstructor(
LValue Dst,
LValue Src);
3684 void callCStructCopyAssignmentOperator(
LValue Dst,
LValue Src);
3685 void callCStructMoveAssignmentOperator(
LValue Dst,
LValue Src);
3705 bool IsArrow,
const Expr *Base);
3739 llvm::Function *generateBuiltinOSLogHelperFunction(
3751 const llvm::CmpInst::Predicate Fp,
3752 const llvm::CmpInst::Predicate Ip,
3753 const llvm::Twine &Name =
"");
3756 llvm::Triple::ArchType Arch);
3759 llvm::Triple::ArchType Arch);
3761 llvm::Value *EmitCommonNeonBuiltinExpr(
unsigned BuiltinID,
3762 unsigned LLVMIntrinsic,
3763 unsigned AltLLVMIntrinsic,
3764 const char *NameHint,
3769 llvm::Triple::ArchType Arch);
3771 llvm::Function *LookupNeonLLVMIntrinsic(
unsigned IntrinsicID,
3772 unsigned Modifier, llvm::Type *ArgTy,
3777 unsigned shift = 0,
bool rightshift =
false);
3780 bool negateForRightShift);
3782 llvm::Type *Ty,
bool usgn,
const char *name);
3785 llvm::Triple::ArchType Arch);
3794 llvm::Value *EmitWebAssemblyBuiltinExpr(
unsigned BuiltinID,
3826 void EmitARCDestroyWeak(
Address addr);
3837 bool resultIgnored);
3839 bool resultIgnored);
3853 llvm::Type *returnType);
3856 std::pair<LValue,llvm::Value*>
3858 std::pair<LValue,llvm::Value*>
3860 std::pair<LValue,llvm::Value*>
3861 EmitARCStoreUnsafeUnretained(
const BinaryOperator *e,
bool ignored);
3864 llvm::Type *returnType);
3866 llvm::Type *returnType);
3875 bool allowUnsafeClaim);
3888 void EmitObjCAutoreleasePoolPop(
llvm::Value *Ptr);
3891 void EmitObjCAutoreleasePoolCleanup(
llvm::Value *Ptr);
3892 void EmitObjCMRRAutoreleasePoolPop(
llvm::Value *Ptr);
3895 RValue EmitReferenceBindingToExpr(
const Expr *E);
3905 llvm::Value *EmitScalarExpr(
const Expr *E ,
bool IgnoreResultAssign =
false);
3933 ComplexPairTy EmitComplexExpr(
const Expr *E,
3934 bool IgnoreReal =
false,
3935 bool IgnoreImag =
false);
3939 void EmitComplexExprIntoLValue(
const Expr *E,
LValue dest,
bool isInit);
3942 void EmitStoreOfComplex(ComplexPairTy V,
LValue dest,
bool isInit);
3954 llvm::GlobalVariable *
3955 AddInitializerToStaticVarDecl(
const VarDecl &D,
3956 llvm::GlobalVariable *GV);
3959 void EmitInvariantStart(llvm::Constant *Addr,
CharUnits Size);
3963 void EmitCXXGlobalVarDeclInit(
const VarDecl &D, llvm::Constant *DeclPtr,
3966 llvm::Function *createAtExitStub(
const VarDecl &VD, llvm::FunctionCallee Dtor,
3967 llvm::Constant *Addr);
3971 void registerGlobalDtorWithAtExit(
const VarDecl &D, llvm::FunctionCallee fn,
3972 llvm::Constant *addr);
3975 void registerGlobalDtorWithAtExit(llvm::Constant *dtorStub);
3982 void EmitCXXGuardedInit(
const VarDecl &D, llvm::GlobalVariable *DeclPtr,
3988 void EmitCXXGuardedInitBranch(
llvm::Value *NeedsInit,
3989 llvm::BasicBlock *InitBlock,
3990 llvm::BasicBlock *NoInitBlock,
3996 GenerateCXXGlobalInitFunc(llvm::Function *Fn,
4002 void GenerateCXXGlobalDtorsFunc(
4004 const std::vector<std::tuple<llvm::FunctionType *, llvm::WeakTrackingVH,
4005 llvm::Constant *>> &DtorsAndObjects);
4007 void GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn,
4009 llvm::GlobalVariable *Addr,
4017 if (
const auto *EWC = dyn_cast<ExprWithCleanups>(E))
4018 if (EWC->getNumObjects() == 0)
4020 enterNonTrivialFullExpression(E);
4022 void enterNonTrivialFullExpression(
const FullExpr *E);
4024 void EmitCXXThrowExpr(
const CXXThrowExpr *E,
bool KeepInsertionPoint =
true);
4033 llvm::Value *EmitAnnotationCall(llvm::Function *AnnotationFn,
4035 StringRef AnnotationStr,
4052 static bool ContainsLabel(
const Stmt *S,
bool IgnoreCaseStmts =
false);
4057 static bool containsBreak(
const Stmt *S);
4061 static bool mightAddDeclToScope(
const Stmt *S);
4066 bool ConstantFoldsToSimpleInteger(
const Expr *Cond,
bool &Result,
4067 bool AllowLabels =
false);
4073 bool AllowLabels =
false);
4080 void EmitBranchOnBoolExpr(
const Expr *Cond, llvm::BasicBlock *TrueBlock,
4081 llvm::BasicBlock *FalseBlock, uint64_t TrueCount);
4089 enum { NotSubtraction =
false, IsSubtraction =
true };
4101 const Twine &Name =
"");
4116 llvm::Constant *EmitCheckTypeDescriptor(
QualType T);
4129 void EmitCheck(
ArrayRef<std::pair<llvm::Value *, SanitizerMask>> Checked,
4152 void EmitCfiCheckStub();
4155 void EmitCfiCheckFail();
4173 void SetFPAccuracy(
llvm::Value *Val,
float Accuracy);
4179 llvm::MDNode *getRangeForLoadFromType(
QualType Ty);
4182 void deferPlaceholderReplacement(llvm::Instruction *Old,
llvm::Value *New);
4185 DeferredReplacements;
4189 assert(!LocalDeclMap.count(VD) &&
"Decl already exists in LocalDeclMap!");
4190 LocalDeclMap.insert({VD, Addr});
4203 void ExpandTypeToArgs(
QualType Ty,
CallArg Arg, llvm::FunctionType *IRFuncTy,
4205 unsigned &IRCallArgPos);
4208 const Expr *InputExpr, std::string &ConstraintStr);
4212 std::string &ConstraintStr,
4220 llvm::Value *evaluateOrEmitBuiltinObjectSize(
const Expr *E,
unsigned Type,
4221 llvm::IntegerType *ResType,
4229 llvm::IntegerType *ResType,
4243 return classDecl->getTypeParamListAsWritten();
4247 return catDecl->getTypeParamList();
4253 template<
typename T>
4267 template <
typename T>
4269 llvm::iterator_range<CallExpr::const_arg_iterator> ArgRange,
4271 unsigned ParamsToSkip = 0,
4276 assert((ParamsToSkip == 0 || CallArgTypeInfo) &&
4277 "Can't skip parameters if type info is not provided");
4278 if (CallArgTypeInfo) {
4280 bool isGenericMethod = isObjCMethodWithTypeParams(CallArgTypeInfo);
4284 for (
auto I = CallArgTypeInfo->param_type_begin() + ParamsToSkip,
4285 E = CallArgTypeInfo->param_type_end();
4286 I != E; ++I, ++Arg) {
4287 assert(Arg != ArgRange.end() &&
"Running over edge of argument list!");
4288 assert((isGenericMethod ||
4289 ((*I)->isVariablyModifiedType() ||
4290 (*I).getNonReferenceType()->isObjCRetainableType() ||
4292 .getCanonicalType((*I).getNonReferenceType())
4295 .getCanonicalType((*Arg)->getType())
4297 "type mismatch in call argument!");
4298 ArgTypes.push_back(*I);
4304 assert((Arg == ArgRange.end() || !CallArgTypeInfo ||
4305 CallArgTypeInfo->isVariadic()) &&
4306 "Extra arguments in non-variadic function!");
4309 for (
auto *A : llvm::make_range(Arg, ArgRange.end()))
4310 ArgTypes.push_back(CallArgTypeInfo ? getVarArgType(A) : A->getType());
4312 EmitCallArgs(Args, ArgTypes, ArgRange, AC, ParamsToSkip, Order);
4316 llvm::iterator_range<CallExpr::const_arg_iterator> ArgRange,
4318 unsigned ParamsToSkip = 0,
4338 Address EmitPointerWithAlignment(
const Expr *Addr,
4347 void EmitSanitizerStatReport(llvm::SanitizerStatKind SSK);
4357 : Architecture(Arch), Features(Feats.begin(), Feats.end()) {}
4362 : Function(F), Conditions(Arch, Feats) {}
4368 void EmitMultiVersionResolver(llvm::Function *Resolver,
4376 void EmitDeclMetadata();
4381 void AddObjCARCExceptionMetadata(llvm::Instruction *Inst);
4383 llvm::Value *GetValueForARMHint(
unsigned BuiltinID);
4395 if (!needsSaving(value))
return saved_type(value,
false);
4398 auto align = CharUnits::fromQuantity(
4407 inline llvm::Value *DominatingLLVMValue::restore(CodeGenFunction &CGF,
4410 if (!value.getInt())
return value.getPointer();
4413 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()
bool Cast(InterpState &S, CodePtr OpPC)
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.
This represents '#pragma omp parallel master' directive.
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.
constexpr size_t align(size_t Size)
Aligns a size to the pointer alignment.
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.
bool ReturnValue(const T &V, APValue &R)
Convers a value to an APValue.
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>'.
bool This(InterpState &S, CodePtr OpPC)
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...
Save/restore original map of previously emitted local vars in case when we need to duplicate emission...
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 Zero(InterpState &S, CodePtr OpPC)
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
llvm::Align getAsAlign() const
getAsAlign - Returns Quantity as a valid llvm::Align, Beware llvm::Align assumes power of two 8-bit b...
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...
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
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.
This represents '#pragma omp master taskloop' directive.
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.
This represents '#pragma omp parallel master taskloop' directive.
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.
This represents '#pragma omp master taskloop simd' directive.
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.
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)
This represents '#pragma omp parallel master taskloop simd' directive.
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. ...
bool NE(InterpState &S, CodePtr OpPC)
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.
OMPLocalDeclMapRAII(CodeGenFunction &CGF)
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.
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.