13#ifndef LLVM_CLANG_LIB_CODEGEN_CODEGENFUNCTION_H
14#define LLVM_CLANG_LIB_CODEGEN_CODEGENFUNCTION_H
37#include "llvm/ADT/ArrayRef.h"
38#include "llvm/ADT/DenseMap.h"
39#include "llvm/ADT/MapVector.h"
40#include "llvm/ADT/SmallVector.h"
41#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
42#include "llvm/IR/Instructions.h"
43#include "llvm/IR/ValueHandle.h"
44#include "llvm/Support/Debug.h"
45#include "llvm/Transforms/Utils/SanitizerStats.h"
55class CanonicalLoopInfo;
60class CXXDestructorDecl;
66class FunctionProtoType;
68class ObjCContainerDecl;
69class ObjCInterfaceDecl;
72class ObjCImplementationDecl;
73class ObjCPropertyImplDecl;
76class ObjCForCollectionStmt;
79class ObjCAtSynchronizedStmt;
80class ObjCAutoreleasePoolStmt;
81class OMPUseDevicePtrClause;
82class OMPUseDeviceAddrClause;
84class OMPExecutableDirective;
86namespace analyze_os_log {
87class OSLogBufferLayout;
96class BlockByrefHelpers;
100class TargetCodeGenInfo;
115#define LIST_SANITIZER_CHECKS \
116 SANITIZER_CHECK(AddOverflow, add_overflow, 0) \
117 SANITIZER_CHECK(BuiltinUnreachable, builtin_unreachable, 0) \
118 SANITIZER_CHECK(CFICheckFail, cfi_check_fail, 0) \
119 SANITIZER_CHECK(DivremOverflow, divrem_overflow, 0) \
120 SANITIZER_CHECK(DynamicTypeCacheMiss, dynamic_type_cache_miss, 0) \
121 SANITIZER_CHECK(FloatCastOverflow, float_cast_overflow, 0) \
122 SANITIZER_CHECK(FunctionTypeMismatch, function_type_mismatch, 0) \
123 SANITIZER_CHECK(ImplicitConversion, implicit_conversion, 0) \
124 SANITIZER_CHECK(InvalidBuiltin, invalid_builtin, 0) \
125 SANITIZER_CHECK(InvalidObjCCast, invalid_objc_cast, 0) \
126 SANITIZER_CHECK(LoadInvalidValue, load_invalid_value, 0) \
127 SANITIZER_CHECK(MissingReturn, missing_return, 0) \
128 SANITIZER_CHECK(MulOverflow, mul_overflow, 0) \
129 SANITIZER_CHECK(NegateOverflow, negate_overflow, 0) \
130 SANITIZER_CHECK(NullabilityArg, nullability_arg, 0) \
131 SANITIZER_CHECK(NullabilityReturn, nullability_return, 1) \
132 SANITIZER_CHECK(NonnullArg, nonnull_arg, 0) \
133 SANITIZER_CHECK(NonnullReturn, nonnull_return, 1) \
134 SANITIZER_CHECK(OutOfBounds, out_of_bounds, 0) \
135 SANITIZER_CHECK(PointerOverflow, pointer_overflow, 0) \
136 SANITIZER_CHECK(ShiftOutOfBounds, shift_out_of_bounds, 0) \
137 SANITIZER_CHECK(SubOverflow, sub_overflow, 0) \
138 SANITIZER_CHECK(TypeMismatch, type_mismatch, 1) \
139 SANITIZER_CHECK(AlignmentAssumption, alignment_assumption, 0) \
140 SANITIZER_CHECK(VLABoundNotPositive, vla_bound_not_positive, 0) \
141 SANITIZER_CHECK(BoundsSafety, bounds_safety, 0)
144#define SANITIZER_CHECK(Enum, Name, Version) Enum,
146#undef SANITIZER_CHECK
152 typedef llvm::PointerIntPair<llvm::Value*, 1, bool>
saved_type;
160 if (!isa<llvm::Instruction>(value))
return false;
163 llvm::BasicBlock *block = cast<llvm::Instruction>(value)->getParent();
164 return (block != &block->getParent()->getEntryBlock());
214 enum Kind { ScalarLiteral, ScalarAddress, AggregateLiteral,
215 AggregateAddress, ComplexAddress };
222 LLVM_PREFERRED_TYPE(Kind)
230 : Vals{Val1, Val2}, K(ComplexAddress) {}
233 : AggregateAddr(AggregateAddr), K(K) {}
244 return saved_type::needsSaving(value);
247 return saved_type::save(CGF, value);
250 return value.restore(CGF);
268 :
Block(
Block), ScopeDepth(Depth), Index(Index) {}
270 bool isValid()
const {
return Block !=
nullptr; }
271 llvm::BasicBlock *
getBlock()
const {
return Block; }
281 llvm::BasicBlock *Block;
329 const unsigned,
const bool)>
333 typedef llvm::function_ref<std::pair<LValue, LValue>(
338 typedef llvm::function_ref<std::pair<llvm::Value *, llvm::Value *>(
346 llvm::BasicBlock::iterator InsertPt)
const;
364 std::unique_ptr<CGCoroData>
Data;
395 Twine
const &SuspendPointName,
424 return !LabelMap.empty();
440 llvm::AssertingVH<llvm::Instruction> PostAllocaInsertPt =
nullptr;
446 if (!PostAllocaInsertPt) {
448 "Expected static alloca insertion point at function prologue");
450 "EBB should be entry block of the current code gen function");
452 PostAllocaInsertPt->setName(
"postallocapt");
456 return PostAllocaInsertPt;
463 : Kind(K), ThisValue(nullptr), CXXThisFieldDecl(nullptr) {}
466 : Kind(K), ThisValue(nullptr), CXXThisFieldDecl(nullptr) {
469 S.getCapturedRecordDecl()->field_begin();
472 I !=
E; ++I, ++Field) {
473 if (I->capturesThis())
474 CXXThisFieldDecl = *Field;
475 else if (I->capturesVariable())
476 CaptureFields[I->getCapturedVar()->getCanonicalDecl()] = *Field;
477 else if (I->capturesVariableByCopy())
478 CaptureFields[I->getCapturedVar()->getCanonicalDecl()] = *Field;
513 return CaptureFields;
521 llvm::SmallDenseMap<const VarDecl *, FieldDecl *> CaptureFields;
525 llvm::Value *ThisValue;
549 const Decl *CalleeDecl;
556 return isa_and_nonnull<FunctionDecl>(CalleeDecl);
560 if (
const auto *FD = dyn_cast<FunctionDecl>(CalleeDecl))
561 return FD->getNumParams();
562 return cast<ObjCMethodDecl>(CalleeDecl)->param_size();
565 if (
const auto *FD = dyn_cast<FunctionDecl>(CalleeDecl))
566 return FD->getParamDecl(I);
567 return *(cast<ObjCMethodDecl>(CalleeDecl)->param_begin() + I);
653 llvm::DenseMap<const VarDecl *, llvm::Value *>
NRVOFlags;
684 assert(!
Deactivated &&
"Deactivating already deactivated scope");
688 Stack[I - 1].DominatingIP);
689 Stack[I - 1].DominatingIP->eraseFromParent();
707 bool isRedundantBeforeReturn()
override {
return true; }
714 : Addr(addr.getPointer()), Size(size) {}
729 LLVM_PREFERRED_TYPE(
bool)
804 void ConstructorHelper(
FPOptions FPFeatures);
807 llvm::fp::ExceptionBehavior OldExcept;
808 llvm::RoundingMode OldRounding;
809 std::optional<CGBuilderTy::FastMathFlagGuard> FMFGuard;
824 llvm::FunctionCallee BeginCatchFn;
828 llvm::AllocaInst *ForEHVar =
nullptr;
832 llvm::AllocaInst *SavedExnVar =
nullptr;
836 llvm::FunctionCallee beginCatchFn,
837 llvm::FunctionCallee endCatchFn, llvm::FunctionCallee rethrowFn);
852 template <
class T,
class... As>
857 return EHStack.pushCleanup<
T>(kind, A...);
860 typedef std::tuple<typename DominatingValue<As>::saved_type...> SavedTuple;
870 template <
class T,
class... As>
873 return pushCleanupAfterFullExprWithActiveFlag<T>(
878 "cleanup active flag should never need saving");
880 typedef std::tuple<typename DominatingValue<As>::saved_type...> SavedTuple;
884 pushCleanupAfterFullExprWithActiveFlag<CleanupType>(Kind, ActiveFlag, Saved);
887 template <
class T,
class... As>
898 static_assert(
sizeof(Header) %
alignof(
T) == 0,
899 "Cleanup will be allocated on misaligned address");
902 new (Buffer +
sizeof(Header))
T(A...);
904 new (Buffer +
sizeof(Header) +
sizeof(
T))
RawAddress(ActiveFlag);
910 template <
class T,
class... As>
913 llvm::Instruction *DominatingIP =
955 llvm::Instruction *DominatingIP);
965 llvm::Instruction *DominatingIP);
971 size_t LifetimeExtendedCleanupStackSize;
973 bool OldDidCallStackSave;
989 LifetimeExtendedCleanupStackSize =
991 OldDidCallStackSave =
CGF.DidCallStackSave;
992 CGF.DidCallStackSave =
false;
1014 void ForceCleanup(std::initializer_list<llvm::Value**> ValuesToReload = {}) {
1016 CGF.DidCallStackSave = OldDidCallStackSave;
1041 CGF.CurLexicalScope =
this;
1048 Labels.push_back(label);
1068 CGF.CurLexicalScope = ParentScope;
1071 if (!Labels.empty())
1076 return !Labels.empty();
1094 assert(SavedLocals.empty() &&
"Did not restored original addresses.");
1104 if (SavedLocals.count(LocalVD))
return false;
1107 auto it = CGF.LocalDeclMap.find(LocalVD);
1108 if (it != CGF.LocalDeclMap.end())
1109 SavedLocals.try_emplace(LocalVD, it->second);
1120 SavedTempAddresses.try_emplace(LocalVD, TempAddr);
1129 copyInto(SavedTempAddresses, CGF.LocalDeclMap);
1130 SavedTempAddresses.clear();
1131 return !SavedLocals.empty();
1136 if (!SavedLocals.empty()) {
1137 copyInto(SavedLocals, CGF.LocalDeclMap);
1138 SavedLocals.clear();
1146 for (
auto &Pair : Src) {
1147 if (!Pair.second.isValid()) {
1148 Dest.erase(Pair.first);
1152 auto I = Dest.find(Pair.first);
1153 if (I != Dest.end())
1154 I->second = Pair.second;
1225 : CGF(CGF), SavedMap(CGF.LocalDeclMap) {}
1233 std::initializer_list<llvm::Value **> ValuesToReload = {});
1240 size_t OldLifetimeExtendedStackSize,
1241 std::initializer_list<llvm::Value **> ValuesToReload = {});
1283 llvm::BasicBlock *StartBB;
1287 : StartBB(CGF.
Builder.GetInsertBlock()) {}
1290 assert(CGF.OutermostConditional !=
this);
1291 if (!CGF.OutermostConditional)
1292 CGF.OutermostConditional =
this;
1296 assert(CGF.OutermostConditional !=
nullptr);
1297 if (CGF.OutermostConditional ==
this)
1298 CGF.OutermostConditional =
nullptr;
1316 auto store =
new llvm::StoreInst(value, addr.
emitRawPointer(CGF),
1317 block->back().getIterator());
1333 : CGF(CGF), SavedOutermostConditional(CGF.OutermostConditional) {
1334 CGF.OutermostConditional =
nullptr;
1338 CGF.OutermostConditional = SavedOutermostConditional;
1347 llvm::Instruction *Inst =
nullptr;
1367 : OpaqueValue(ov), BoundLValue(boundLValue) {}
1377 return expr->isGLValue() ||
1378 expr->getType()->isFunctionType() ||
1394 CGF.OpaqueLValues.insert(std::make_pair(ov, lv));
1402 CGF.OpaqueRValues.insert(std::make_pair(ov, rv));
1414 bool isValid()
const {
return OpaqueValue !=
nullptr; }
1418 assert(OpaqueValue &&
"no data to unbind!");
1421 CGF.OpaqueLValues.erase(OpaqueValue);
1423 CGF.OpaqueRValues.erase(OpaqueValue);
1446 if (isa<ConditionalOperator>(op))
1460 assert(OV->
getSourceExpr() &&
"wrong form of OpaqueValueMapping used "
1461 "for OVE with no source expression");
1484 if (
Data.isValid())
Data.unbind(CGF);
1491 unsigned VLAExprCounter = 0;
1492 bool DisableDebugInfo =
false;
1496 bool DidCallStackSave =
false;
1502 llvm::IndirectBrInst *IndirectBranch =
nullptr;
1510 llvm::DenseMap<const ParmVarDecl *, EHScopeStack::stable_iterator>
1511 CalleeDestructedParamCleanups;
1516 llvm::SmallDenseMap<const ParmVarDecl *, const ImplicitParamDecl *, 2>
1521 llvm::DenseMap<llvm::AllocaInst *, int> EscapedLocals;
1524 llvm::DenseMap<const LabelDecl*, JumpDest> LabelMap;
1528 struct BreakContinue {
1529 BreakContinue(JumpDest Break, JumpDest Continue)
1530 : BreakBlock(Break), ContinueBlock(Continue) {}
1532 JumpDest BreakBlock;
1533 JumpDest ContinueBlock;
1535 SmallVector<BreakContinue, 8> BreakContinueStack;
1538 class OpenMPCancelExitStack {
1542 CancelExit() =
default;
1545 : Kind(Kind), ExitBlock(ExitBlock), ContBlock(ContBlock) {}
1549 bool HasBeenEmitted =
false;
1554 SmallVector<CancelExit, 8> Stack;
1557 OpenMPCancelExitStack() : Stack(1) {}
1558 ~OpenMPCancelExitStack() =
default;
1560 JumpDest getExitBlock()
const {
return Stack.back().ExitBlock; }
1564 const llvm::function_ref<
void(CodeGenFunction &)> CodeGen) {
1565 if (Stack.back().Kind == Kind && getExitBlock().isValid()) {
1566 assert(CGF.getOMPCancelDestination(Kind).isValid());
1567 assert(CGF.HaveInsertPoint());
1568 assert(!Stack.back().HasBeenEmitted);
1569 auto IP = CGF.Builder.saveAndClearIP();
1570 CGF.EmitBlock(Stack.back().ExitBlock.getBlock());
1572 CGF.EmitBranch(Stack.back().ContBlock.getBlock());
1573 CGF.Builder.restoreIP(IP);
1574 Stack.back().HasBeenEmitted =
true;
1583 Stack.push_back({
Kind,
1584 HasCancel ? CGF.getJumpDestInCurrentScope(
"cancel.exit")
1586 HasCancel ? CGF.getJumpDestInCurrentScope(
"cancel.cont")
1591 void exit(CodeGenFunction &CGF) {
1592 if (getExitBlock().isValid()) {
1593 assert(CGF.getOMPCancelDestination(Stack.back().Kind).isValid());
1594 bool HaveIP = CGF.HaveInsertPoint();
1595 if (!Stack.back().HasBeenEmitted) {
1597 CGF.EmitBranchThroughCleanup(Stack.back().ContBlock);
1598 CGF.EmitBlock(Stack.back().ExitBlock.getBlock());
1599 CGF.EmitBranchThroughCleanup(Stack.back().ContBlock);
1601 CGF.EmitBlock(Stack.back().ContBlock.getBlock());
1603 CGF.Builder.CreateUnreachable();
1604 CGF.Builder.ClearInsertionPoint();
1610 OpenMPCancelExitStack OMPCancelStack;
1613 llvm::Value *emitCondLikelihoodViaExpectIntrinsic(llvm::Value *Cond,
1622 llvm::MDNode *createProfileWeights(uint64_t TrueCount,
1623 uint64_t FalseCount)
const;
1624 llvm::MDNode *createProfileWeights(ArrayRef<uint64_t> Weights)
const;
1625 llvm::MDNode *createProfileWeightsForLoop(
const Stmt *Cond,
1626 uint64_t LoopCount)
const;
1633 !
CurFn->hasFnAttribute(llvm::Attribute::NoProfile) &&
1634 !
CurFn->hasFnAttribute(llvm::Attribute::SkipProfile)) {
1636 PGO.emitCounterSetOrIncrement(
Builder, S, StepV);
1638 PGO.setCurrentStmt(S);
1644 !
CurFn->hasFnAttribute(llvm::Attribute::NoProfile));
1651 PGO.emitMCDCParameters(
Builder);
1652 MCDCCondBitmapAddr =
1658 const BinaryOperator *BOp = dyn_cast<BinaryOperator>(
E->IgnoreParens());
1665 PGO.emitMCDCCondBitmapReset(
Builder,
E, MCDCCondBitmapAddr);
1666 PGO.setCurrentStmt(
E);
1674 PGO.emitMCDCTestVectorBitmapUpdate(
Builder,
E, MCDCCondBitmapAddr, *
this);
1675 PGO.setCurrentStmt(
E);
1682 PGO.emitMCDCCondBitmapUpdate(
Builder,
E, MCDCCondBitmapAddr, Val, *
this);
1683 PGO.setCurrentStmt(
E);
1689 return PGO.getStmtCount(S).value_or(0);
1694 PGO.setCurrentRegionCount(Count);
1700 return PGO.getCurrentRegionCount();
1707 llvm::SwitchInst *SwitchInsn =
nullptr;
1716 llvm::BasicBlock *CaseRangeBlock =
nullptr;
1720 llvm::DenseMap<const OpaqueValueExpr *, LValue> OpaqueLValues;
1721 llvm::DenseMap<const OpaqueValueExpr *, RValue> OpaqueRValues;
1729 llvm::DenseMap<const Expr*, llvm::Value*> VLASizeMap;
1733 llvm::BasicBlock *UnreachableBlock =
nullptr;
1736 unsigned NumReturnExprs = 0;
1739 unsigned NumSimpleReturnExprs = 0;
1757 : CGF(CGF), OldCXXDefaultInitExprThis(CGF.CXXDefaultInitExprThis) {
1758 CGF.CXXDefaultInitExprThis = This;
1761 CGF.CXXDefaultInitExprThis = OldCXXDefaultInitExprThis;
1766 Address OldCXXDefaultInitExprThis;
1802 : CGF(CGF), OldArrayInitIndex(CGF.ArrayInitIndex) {
1803 CGF.ArrayInitIndex = Index;
1806 CGF.ArrayInitIndex = OldArrayInitIndex;
1811 llvm::Value *OldArrayInitIndex;
1819 OldCXXABIThisDecl(CGF.CXXABIThisDecl),
1820 OldCXXABIThisValue(CGF.CXXABIThisValue),
1821 OldCXXThisValue(CGF.CXXThisValue),
1822 OldCXXABIThisAlignment(CGF.CXXABIThisAlignment),
1823 OldCXXThisAlignment(CGF.CXXThisAlignment),
1825 OldCXXInheritedCtorInitExprArgs(
1826 std::move(CGF.CXXInheritedCtorInitExprArgs)) {
1829 cast<CXXConstructorDecl>(GD.
getDecl());
1830 CGF.CXXABIThisDecl =
nullptr;
1831 CGF.CXXABIThisValue =
nullptr;
1832 CGF.CXXThisValue =
nullptr;
1837 CGF.CXXInheritedCtorInitExprArgs.clear();
1840 CGF.CurGD = OldCurGD;
1841 CGF.CurFuncDecl = OldCurFuncDecl;
1842 CGF.CurCodeDecl = OldCurCodeDecl;
1843 CGF.CXXABIThisDecl = OldCXXABIThisDecl;
1844 CGF.CXXABIThisValue = OldCXXABIThisValue;
1845 CGF.CXXThisValue = OldCXXThisValue;
1846 CGF.CXXABIThisAlignment = OldCXXABIThisAlignment;
1847 CGF.CXXThisAlignment = OldCXXThisAlignment;
1848 CGF.ReturnValue = OldReturnValue;
1849 CGF.FnRetTy = OldFnRetTy;
1850 CGF.CXXInheritedCtorInitExprArgs =
1851 std::move(OldCXXInheritedCtorInitExprArgs);
1857 const Decl *OldCurFuncDecl;
1858 const Decl *OldCurCodeDecl;
1860 llvm::Value *OldCXXABIThisValue;
1861 llvm::Value *OldCXXThisValue;
1892 llvm::CallInst *RTLFnCI;
1896 RLFnCI->removeFromParent();
1926 StringRef FirstSeparator =
".",
1927 StringRef Separator =
".");
1932 CGBuilderTy::InsertPointGuard IPG(CGF.
Builder);
1933 assert(IP.getBlock()->end() != IP.getPoint() &&
1934 "OpenMP IR Builder should cause terminated block!");
1936 llvm::BasicBlock *IPBB = IP.getBlock();
1937 llvm::BasicBlock *DestBB = IPBB->getUniqueSuccessor();
1938 assert(DestBB &&
"Finalization block should have one successor!");
1941 IPBB->getTerminator()->eraseFromParent();
1942 CGF.
Builder.SetInsertPoint(IPBB);
1955 const Stmt *RegionBodyStmt,
1961 llvm::BasicBlock &FiniBB, llvm::Function *Fn,
1963 llvm::BasicBlock *CodeGenIPBB = CodeGenIP.getBlock();
1964 if (llvm::Instruction *CodeGenIPBBTI = CodeGenIPBB->getTerminator())
1965 CodeGenIPBBTI->eraseFromParent();
1967 CGF.
Builder.SetInsertPoint(CodeGenIPBB);
1969 if (Fn->doesNotThrow())
1974 if (CGF.
Builder.saveIP().isSet())
1975 CGF.
Builder.CreateBr(&FiniBB);
1987 const Stmt *RegionBodyStmt,
1995 llvm::AssertingVH<llvm::Instruction> OldAllocaIP;
2001 llvm::BasicBlock &RetBB)
2003 assert(AllocaIP.isSet() &&
2004 "Must specify Insertion point for allocas of outlined function");
2021 llvm::AssertingVH<llvm::Instruction> OldAllocaIP;
2026 llvm::BasicBlock &FiniBB)
2032 assert((!AllocaIP.isSet() ||
2034 "Insertion point should be in the entry block of containing "
2037 if (AllocaIP.isSet())
2056 llvm::Value *CXXABIThisValue =
nullptr;
2057 llvm::Value *CXXThisValue =
nullptr;
2067 llvm::Value *ArrayInitIndex =
nullptr;
2076 llvm::Value *CXXStructorImplicitParamValue =
nullptr;
2081 ConditionalEvaluation *OutermostConditional =
nullptr;
2084 LexicalScope *CurLexicalScope =
nullptr;
2092 llvm::DenseMap<const ValueDecl *, BlockByrefInfo> BlockByrefInfos;
2096 llvm::Value *RetValNullabilityPrecondition =
nullptr;
2100 bool requiresReturnValueNullabilityCheck()
const {
2101 return RetValNullabilityPrecondition;
2109 bool requiresReturnValueCheck()
const;
2114 llvm::BasicBlock *TerminateLandingPad =
nullptr;
2115 llvm::BasicBlock *TerminateHandler =
nullptr;
2119 llvm::MapVector<llvm::Value *, llvm::BasicBlock *> TerminateFunclets;
2123 unsigned LargestVectorWidth = 0;
2127 bool ShouldEmitLifetimeMarkers;
2131 void EmitKernelMetadata(
const FunctionDecl *FD, llvm::Function *Fn);
2140 if (DisableDebugInfo)
2166 if (!UnreachableBlock) {
2170 return UnreachableBlock;
2198 llvm::Value *arrayEnd,
2208 Destroyer *destroyer,
bool useEHCleanupForArray);
2213 bool useEHCleanupForArray);
2216 bool useEHCleanupForArray);
2218 llvm::Value *CompletePtr,
2222 std::pair<llvm::Value *, llvm::Value *> AddrSizePair);
2224 bool useEHCleanupForArray);
2227 bool useEHCleanupForArray,
2232 bool checkZeroLength,
bool useEHCleanup);
2250 llvm_unreachable(
"bad destruction kind");
2271 llvm::Constant *AtomicHelperFn);
2282 llvm::Constant *AtomicHelperFn);
2297 bool IsLambdaConversionToBlock,
2298 bool BuildGlobalBlock);
2335 bool LoadBlockVarAddr,
bool CanThrow);
2346 bool followForward =
true);
2350 const llvm::Twine &name);
2385 llvm::Constant *CallOpFn =
nullptr);
2392 llvm::Function **ImplFn);
2413 const ThunkInfo *Thunk,
bool IsUnprototyped);
2419 llvm::FunctionCallee Callee);
2424 bool IsUnprototyped);
2453 bool BaseIsNonVirtualPrimaryBase,
2513 llvm::Value *VTable,
2514 llvm::Type *VTableTy,
2515 uint64_t VTableByteOffset);
2583 llvm::Type *LLVMTy =
nullptr);
2608 llvm::Function *parent =
nullptr,
2609 llvm::BasicBlock *before =
nullptr) {
2610 return llvm::BasicBlock::Create(
getLLVMContext(), name, parent, before);
2630 void EmitBlock(llvm::BasicBlock *BB,
bool IsFinished=
false);
2649 return Builder.GetInsertBlock() !=
nullptr;
2670 llvm::BasicBlock *LHSBlock,
2671 llvm::BasicBlock *RHSBlock,
2672 llvm::BasicBlock *MergeBlock,
2674 Builder.SetInsertPoint(MergeBlock);
2675 llvm::PHINode *PtrPhi =
Builder.CreatePHI(LHS.
getType(), 2,
"cond");
2692 if (Alignment.isZero())
2768 struct AllocaTracker {
2769 void Add(llvm::AllocaInst *I) { Allocas.push_back(I); }
2775 AllocaTracker *Allocas =
nullptr;
2781 : CGF(CGF), OldTracker(CGF.Allocas) {
2782 CGF.Allocas = &Tracker;
2790 AllocaTracker *OldTracker;
2791 AllocaTracker Tracker;
2821 llvm::Value *ArraySize =
nullptr);
2823 const Twine &Name =
"tmp",
2824 llvm::Value *ArraySize =
nullptr,
2827 const Twine &Name =
"tmp",
2828 llvm::Value *ArraySize =
nullptr);
2841 const Twine &Name =
"tmp");
2859 const Twine &Name =
"tmp",
2866 const Twine &Name =
"tmp");
2893 llvm::Value *Dst,
QualType DstType,
2908 bool ignoreResult =
false);
2933 bool capturedByInit);
2939 const RecordDecl *RD = cast<RecordDecl>(RT->getDecl());
2982 bool isVolatile =
false);
2986 auto it = LocalDeclMap.find(VD);
2987 assert(it != LocalDeclMap.end() &&
2988 "Invalid argument to GetAddrOfLocalVar(), no decl!");
3071 assert(CXXThisValue &&
"no 'this' value for this function");
3072 return CXXThisValue;
3081 assert(CXXStructorImplicitParamValue &&
"no VTT value for this function");
3082 return CXXStructorImplicitParamValue;
3091 bool BaseIsVirtual);
3107 bool NullCheckValue);
3133 bool ForVirtualBase,
3141 bool ForVirtualBase,
Address This,
3142 bool InheritedFromVBase,
3170 bool NewPointerIsChecked,
3171 bool ZeroInitialization =
false);
3174 llvm::Value *NumElements,
3177 bool NewPointerIsChecked,
3178 bool ZeroInitialization =
false);
3187 llvm::Type *ElementTy,
Address NewPtr,
3188 llvm::Value *NumElements,
3189 llvm::Value *AllocSizeWithoutCookie);
3206 QualType DeleteTy, llvm::Value *NumElements =
nullptr,
3210 const CallExpr *TheCallExpr,
bool IsDelete);
3267 llvm::Value *ArraySize =
nullptr) {
3271 SkippedChecks, ArraySize);
3277 llvm::Value *ArraySize =
nullptr) {
3281 SkippedChecks, ArraySize);
3290 llvm::Value *ArraySize =
nullptr);
3296 QualType IndexType,
bool Accessed);
3298 llvm::Value *Index,
QualType IndexType,
3299 QualType IndexedType,
bool Accessed);
3314 bool isInc,
bool isPre);
3316 bool isInc,
bool isPre);
3340 bool capturedByInit);
3365 llvm::Value *NRVOFlag;
3369 bool IsEscapingByRef;
3373 bool IsConstantAggregate;
3376 llvm::Value *SizeForLifetimeMarkers;
3387 AutoVarEmission(
const VarDecl &variable)
3388 : Variable(&variable), Addr(
Address::
invalid()), NRVOFlag(nullptr),
3389 IsEscapingByRef(
false), IsConstantAggregate(
false),
3392 bool wasEmittedAsGlobal()
const {
return !Addr.
isValid(); }
3398 return SizeForLifetimeMarkers !=
nullptr;
3402 return SizeForLifetimeMarkers;
3419 if (!IsEscapingByRef)
return Addr;
3437 bool EmitDebugInfo);
3440 llvm::GlobalValue::LinkageTypes
Linkage);
3499 llvm::Value *Alignment,
3500 llvm::Value *OffsetValue,
3501 llvm::Value *TheCheck,
3502 llvm::Instruction *Assumption);
3506 llvm::Value *Alignment,
3507 llvm::Value *OffsetValue =
nullptr);
3511 llvm::Value *Alignment,
3512 llvm::Value *OffsetValue =
nullptr);
3540 bool GetLast =
false,
3579 bool ignoreResult =
false);
3583 bool ignoreResult =
false);
3599 llvm::Function *FinallyFunc);
3601 const Stmt *OutlinedStmt);
3610 llvm::Value *ParentFP,
3611 llvm::Value *EntryEBP);
3632 llvm::Value *ParentFP);
3645 CGF.OMPCancelStack.enter(CGF, Kind, HasCancel);
3712 const llvm::DenseMap<const ValueDecl *, llvm::Value *>
3713 CaptureDeviceAddrMap);
3716 const llvm::DenseMap<const ValueDecl *, llvm::Value *>
3717 CaptureDeviceAddrMap);
3752 llvm::Value *IsLastIterCond =
nullptr);
3771 bool ForInscan =
false);
3907 StringRef ParentName,
3934 StringRef ParentName,
3979 const Expr *LoopCond,
const Expr *IncExpr,
4016 struct OMPLoopArguments {
4026 llvm::Value *Chunk =
nullptr;
4028 Expr *EUB =
nullptr;
4030 Expr *IncExpr =
nullptr;
4032 Expr *Init =
nullptr;
4034 Expr *Cond =
nullptr;
4036 Expr *NextLB =
nullptr;
4038 Expr *NextUB =
nullptr;
4041 OMPLoopArguments() =
default;
4043 llvm::Value *Chunk =
nullptr,
Expr *EUB =
nullptr,
4044 Expr *IncExpr =
nullptr,
Expr *Init =
nullptr,
4045 Expr *Cond =
nullptr,
Expr *NextLB =
nullptr,
4046 Expr *NextUB =
nullptr)
4047 : LB(LB), UB(UB), ST(ST), IL(IL), Chunk(Chunk), EUB(EUB),
4048 IncExpr(IncExpr), Init(Init), Cond(Cond), NextLB(NextLB),
4051 void EmitOMPOuterLoop(
bool DynamicOrOrdered,
bool IsMonotonic,
4053 const OMPLoopArguments &LoopArgs,
4058 OMPPrivateScope &LoopScope,
bool Ordered,
4059 const OMPLoopArguments &LoopArgs,
4063 OMPPrivateScope &LoopScope,
4064 const OMPLoopArguments &LoopArgs,