24 #include "llvm/ADT/StringExtras.h"
25 #include "llvm/IR/CallSite.h"
26 #include "llvm/IR/DataLayout.h"
27 #include "llvm/IR/InlineAsm.h"
28 #include "llvm/IR/Intrinsics.h"
29 #include "llvm/IR/MDBuilder.h"
31 using namespace clang;
32 using namespace CodeGen;
41 Loc = S->getLocStart();
49 assert(S &&
"Null statement?");
66 assert(!isa<DeclStmt>(*S) &&
"Unexpected DeclStmt!");
77 switch (S->getStmtClass()) {
78 case Stmt::NoStmtClass:
79 case Stmt::CXXCatchStmtClass:
80 case Stmt::SEHExceptStmtClass:
81 case Stmt::SEHFinallyStmtClass:
82 case Stmt::MSDependentExistsStmtClass:
83 llvm_unreachable(
"invalid statement class to emit generically");
84 case Stmt::NullStmtClass:
85 case Stmt::CompoundStmtClass:
86 case Stmt::DeclStmtClass:
87 case Stmt::LabelStmtClass:
88 case Stmt::AttributedStmtClass:
89 case Stmt::GotoStmtClass:
90 case Stmt::BreakStmtClass:
91 case Stmt::ContinueStmtClass:
92 case Stmt::DefaultStmtClass:
93 case Stmt::CaseStmtClass:
94 case Stmt::SEHLeaveStmtClass:
95 llvm_unreachable(
"should have emitted these statements as simple");
97 #define STMT(Type, Base)
98 #define ABSTRACT_STMT(Op)
99 #define EXPR(Type, Base) \
100 case Stmt::Type##Class:
101 #include "clang/AST/StmtNodes.inc"
104 llvm::BasicBlock *incoming =
Builder.GetInsertBlock();
105 assert(incoming &&
"expression emission must have an insertion point");
109 llvm::BasicBlock *outgoing =
Builder.GetInsertBlock();
110 assert(outgoing &&
"expression emission cleared block!");
124 if (incoming != outgoing && outgoing->use_empty()) {
125 outgoing->eraseFromParent();
131 case Stmt::IndirectGotoStmtClass:
134 case Stmt::IfStmtClass:
EmitIfStmt(cast<IfStmt>(*S));
break;
135 case Stmt::WhileStmtClass:
EmitWhileStmt(cast<WhileStmt>(*S));
break;
136 case Stmt::DoStmtClass:
EmitDoStmt(cast<DoStmt>(*S));
break;
137 case Stmt::ForStmtClass:
EmitForStmt(cast<ForStmt>(*S));
break;
139 case Stmt::ReturnStmtClass:
EmitReturnStmt(cast<ReturnStmt>(*S));
break;
141 case Stmt::SwitchStmtClass:
EmitSwitchStmt(cast<SwitchStmt>(*S));
break;
142 case Stmt::GCCAsmStmtClass:
143 case Stmt::MSAsmStmtClass:
EmitAsmStmt(cast<AsmStmt>(*S));
break;
144 case Stmt::CoroutineBodyStmtClass:
145 case Stmt::CoreturnStmtClass:
148 case Stmt::CapturedStmtClass: {
153 case Stmt::ObjCAtTryStmtClass:
156 case Stmt::ObjCAtCatchStmtClass:
158 "@catch statements should be handled by EmitObjCAtTryStmt");
159 case Stmt::ObjCAtFinallyStmtClass:
161 "@finally statements should be handled by EmitObjCAtTryStmt");
162 case Stmt::ObjCAtThrowStmtClass:
165 case Stmt::ObjCAtSynchronizedStmtClass:
168 case Stmt::ObjCForCollectionStmtClass:
171 case Stmt::ObjCAutoreleasePoolStmtClass:
175 case Stmt::CXXTryStmtClass:
178 case Stmt::CXXForRangeStmtClass:
181 case Stmt::SEHTryStmtClass:
184 case Stmt::OMPParallelDirectiveClass:
187 case Stmt::OMPSimdDirectiveClass:
190 case Stmt::OMPForDirectiveClass:
193 case Stmt::OMPForSimdDirectiveClass:
196 case Stmt::OMPSectionsDirectiveClass:
199 case Stmt::OMPSectionDirectiveClass:
202 case Stmt::OMPSingleDirectiveClass:
205 case Stmt::OMPMasterDirectiveClass:
208 case Stmt::OMPCriticalDirectiveClass:
211 case Stmt::OMPParallelForDirectiveClass:
214 case Stmt::OMPParallelForSimdDirectiveClass:
217 case Stmt::OMPParallelSectionsDirectiveClass:
220 case Stmt::OMPTaskDirectiveClass:
223 case Stmt::OMPTaskyieldDirectiveClass:
226 case Stmt::OMPBarrierDirectiveClass:
229 case Stmt::OMPTaskwaitDirectiveClass:
232 case Stmt::OMPTaskgroupDirectiveClass:
235 case Stmt::OMPFlushDirectiveClass:
238 case Stmt::OMPOrderedDirectiveClass:
241 case Stmt::OMPAtomicDirectiveClass:
244 case Stmt::OMPTargetDirectiveClass:
247 case Stmt::OMPTeamsDirectiveClass:
250 case Stmt::OMPCancellationPointDirectiveClass:
253 case Stmt::OMPCancelDirectiveClass:
256 case Stmt::OMPTargetDataDirectiveClass:
259 case Stmt::OMPTaskLoopDirectiveClass:
262 case Stmt::OMPTaskLoopSimdDirectiveClass:
265 case Stmt::OMPDistributeDirectiveClass:
272 switch (S->getStmtClass()) {
273 default:
return false;
274 case Stmt::NullStmtClass:
break;
275 case Stmt::CompoundStmtClass:
EmitCompoundStmt(cast<CompoundStmt>(*S));
break;
276 case Stmt::DeclStmtClass:
EmitDeclStmt(cast<DeclStmt>(*S));
break;
277 case Stmt::LabelStmtClass:
EmitLabelStmt(cast<LabelStmt>(*S));
break;
278 case Stmt::AttributedStmtClass:
280 case Stmt::GotoStmtClass:
EmitGotoStmt(cast<GotoStmt>(*S));
break;
281 case Stmt::BreakStmtClass:
EmitBreakStmt(cast<BreakStmt>(*S));
break;
282 case Stmt::ContinueStmtClass:
EmitContinueStmt(cast<ContinueStmt>(*S));
break;
283 case Stmt::DefaultStmtClass:
EmitDefaultStmt(cast<DefaultStmt>(*S));
break;
284 case Stmt::CaseStmtClass:
EmitCaseStmt(cast<CaseStmt>(*S));
break;
285 case Stmt::SEHLeaveStmtClass:
EmitSEHLeaveStmt(cast<SEHLeaveStmt>(*S));
break;
297 "LLVM IR generation of compound statement ('{}')");
321 while (
const LabelStmt *LS = dyn_cast<LabelStmt>(LastStmt)) {
323 LastStmt = LS->getSubStmt();
328 QualType ExprTy = cast<Expr>(LastStmt)->getType();
346 llvm::BranchInst *BI = dyn_cast<llvm::BranchInst>(BB->getTerminator());
355 if (!BI || !BI->isUnconditional())
359 if (BI->getIterator() != BB->begin())
362 BB->replaceAllUsesWith(BI->getSuccessor(0));
363 BI->eraseFromParent();
364 BB->eraseFromParent();
368 llvm::BasicBlock *CurBB =
Builder.GetInsertBlock();
373 if (IsFinished && BB->use_empty()) {
380 if (CurBB && CurBB->getParent())
381 CurFn->getBasicBlockList().insertAfter(CurBB->getIterator(), BB);
383 CurFn->getBasicBlockList().push_back(BB);
391 llvm::BasicBlock *CurBB =
Builder.GetInsertBlock();
393 if (!CurBB || CurBB->getTerminator()) {
405 bool inserted =
false;
406 for (llvm::User *u : block->users()) {
407 if (llvm::Instruction *insn = dyn_cast<llvm::Instruction>(u)) {
408 CurFn->getBasicBlockList().insertAfter(insn->getParent()->getIterator(),
416 CurFn->getBasicBlockList().push_back(block);
424 if (Dest.
isValid())
return Dest;
462 assert(!Labels.empty());
468 i = Labels.begin(), e = Labels.end(); i != e; ++i) {
469 assert(
CGF.LabelMap.count(*i));
471 assert(dest.getScopeDepth().isValid());
472 assert(innermostScope.encloses(dest.getScopeDepth()));
473 dest.setScopeDepth(innermostScope);
478 ParentScope->Labels.append(Labels.begin(), Labels.end());
490 switch (SubStmt->getStmtClass()) {
491 case Stmt::DoStmtClass:
494 case Stmt::ForStmtClass:
497 case Stmt::WhileStmtClass:
500 case Stmt::CXXForRangeStmtClass:
528 llvm::BasicBlock *CurBB =
Builder.GetInsertBlock();
535 cast<llvm::PHINode>(IndGotoBB->begin())->addIncoming(V, CurBB);
556 std::swap(Executed, Skipped);
575 llvm::BasicBlock *ElseBlock = ContBlock;
627 BreakContinueStack.push_back(BreakContinue(LoopExit, LoopHeader));
648 bool EmitBoolCondBranch =
true;
649 if (llvm::ConstantInt *
C = dyn_cast<llvm::ConstantInt>(BoolCondVal))
651 EmitBoolCondBranch =
false;
655 if (EmitBoolCondBranch) {
656 llvm::BasicBlock *ExitBlock = LoopExit.
getBlock();
660 BoolCondVal, LoopBody, ExitBlock,
663 if (ExitBlock != LoopExit.
getBlock()) {
678 BreakContinueStack.pop_back();
694 if (!EmitBoolCondBranch)
706 BreakContinueStack.push_back(BreakContinue(LoopExit, LoopCond));
729 BreakContinueStack.pop_back();
733 bool EmitBoolCondBranch =
true;
734 if (llvm::ConstantInt *
C = dyn_cast<llvm::ConstantInt>(BoolCondVal))
736 EmitBoolCondBranch =
false;
739 if (EmitBoolCondBranch) {
742 BoolCondVal, LoopBody, LoopExit.
getBlock(),
743 createProfileWeightsForLoop(S.
getCond(), BackedgeCount));
753 if (!EmitBoolCondBranch)
771 llvm::BasicBlock *CondBlock = Continue.
getBlock();
784 BreakContinueStack.push_back(BreakContinue(LoopExit, Continue));
796 llvm::BasicBlock *ExitBlock = LoopExit.
getBlock();
799 if (ForScope.requiresCleanups())
809 BoolCondVal, ForBody, ExitBlock,
812 if (ExitBlock != LoopExit.
getBlock()) {
837 BreakContinueStack.pop_back();
839 ConditionScope.ForceCleanup();
844 ForScope.ForceCleanup();
873 llvm::BasicBlock *ExitBlock = LoopExit.
getBlock();
874 if (ForScope.requiresCleanups())
884 BoolCondVal, ForBody, ExitBlock,
887 if (ExitBlock != LoopExit.
getBlock()) {
899 BreakContinueStack.push_back(BreakContinue(LoopExit, Continue));
913 BreakContinueStack.pop_back();
917 ForScope.ForceCleanup();
925 void CodeGenFunction::EmitReturnOfRValue(
RValue RV,
QualType Ty) {
956 dyn_cast_or_null<ExprWithCleanups>(RV)) {
958 RV = cleanups->getSubExpr();
1006 ++NumSimpleReturnExprs;
1018 for (
const auto *
I : S.
decls())
1023 assert(!BreakContinueStack.empty() &&
"break stmt not in a loop or switch!");
1035 assert(!BreakContinueStack.empty() &&
"continue stmt not in a loop!");
1050 assert(S.
getRHS() &&
"Expected RHS value in CaseStmt");
1063 if (LHS.isSigned() ? RHS.slt(LHS) : RHS.ult(LHS))
1066 llvm::APInt Range = RHS - LHS;
1068 if (Range.ult(llvm::APInt(Range.getBitWidth(), 64))) {
1071 unsigned NCases = Range.getZExtValue() + 1;
1076 uint64_t Weight = Total / NCases, Rem = Total % NCases;
1077 for (
unsigned I = 0;
I != NCases; ++
I) {
1079 SwitchWeights->push_back(Weight + (Rem ? 1 : 0));
1082 SwitchInsn->addCase(
Builder.getInt(LHS), CaseDest);
1090 llvm::BasicBlock *RestoreBB =
Builder.GetInsertBlock();
1095 llvm::BasicBlock *FalseDest = CaseRangeBlock;
1098 CurFn->getBasicBlockList().push_back(CaseRangeBlock);
1099 Builder.SetInsertPoint(CaseRangeBlock);
1103 Builder.CreateSub(SwitchInsn->getCondition(),
Builder.getInt(LHS));
1107 llvm::MDNode *Weights =
nullptr;
1108 if (SwitchWeights) {
1110 uint64_t DefaultCount = (*SwitchWeights)[0];
1111 Weights = createProfileWeights(ThisCount, DefaultCount);
1116 (*SwitchWeights)[0] += ThisCount;
1118 Builder.CreateCondBr(Cond, CaseDest, FalseDest, Weights);
1122 Builder.SetInsertPoint(RestoreBB);
1124 Builder.ClearInsertionPoint();
1144 llvm::ConstantInt *CaseVal =
1153 JumpDest Block = BreakContinueStack.back().BreakBlock;
1159 SwitchInsn->addCase(CaseVal, Block.
getBlock());
1163 if (
Builder.GetInsertBlock()) {
1165 Builder.ClearInsertionPoint();
1175 SwitchInsn->addCase(CaseVal, CaseDest);
1190 while (NextCase && NextCase->
getRHS() ==
nullptr) {
1192 llvm::ConstantInt *CaseVal =
1202 SwitchInsn->addCase(CaseVal, CaseDest);
1211 llvm::BasicBlock *DefaultBlock = SwitchInsn->getDefaultDest();
1212 assert(DefaultBlock->empty() &&
1213 "EmitDefaultStmt: Default block already defined?");
1254 if (
const SwitchCase *SC = dyn_cast<SwitchCase>(S)) {
1268 if (!Case && isa<BreakStmt>(S))
1273 if (
const CompoundStmt *CS = dyn_cast<CompoundStmt>(S)) {
1281 bool HadSkippedDecl =
false;
1285 for (; Case && I !=
E; ++
I) {
1286 HadSkippedDecl |= isa<DeclStmt>(*I);
1301 for (++I; I !=
E; ++
I)
1311 assert(FoundCase &&
"Didn't find case but returned fallthrough?");
1326 for (; I !=
E; ++
I) {
1337 for (++I; I !=
E; ++
I)
1362 ResultStmts.push_back(S);
1371 const llvm::APSInt &ConstantCondValue,
1383 if (
const DefaultStmt *DS = dyn_cast<DefaultStmt>(Case)) {
1389 const CaseStmt *CS = cast<CaseStmt>(Case);
1391 if (CS->
getRHS())
return false;
1416 bool FoundCase =
false;
1425 llvm::SwitchInst *SavedSwitchInsn = SwitchInsn;
1427 llvm::BasicBlock *SavedCRBlock = CaseRangeBlock;
1431 llvm::APSInt ConstantCondValue;
1449 SwitchInsn =
nullptr;
1453 for (
unsigned i = 0, e = CaseStmts.size(); i != e; ++i)
1459 SwitchInsn = SavedSwitchInsn;
1477 SwitchInsn =
Builder.CreateSwitch(CondV, DefaultBlock);
1480 uint64_t DefaultCount = 0;
1481 unsigned NumCases = 0;
1485 if (isa<DefaultStmt>(Case))
1490 SwitchWeights->reserve(NumCases);
1493 SwitchWeights->push_back(DefaultCount);
1495 CaseRangeBlock = DefaultBlock;
1498 Builder.ClearInsertionPoint();
1503 if (!BreakContinueStack.empty())
1504 OuterContinue = BreakContinueStack.back().ContinueBlock;
1506 BreakContinueStack.push_back(BreakContinue(SwitchExit, OuterContinue));
1511 BreakContinueStack.pop_back();
1515 SwitchInsn->setDefaultDest(CaseRangeBlock);
1518 if (!DefaultBlock->getParent()) {
1526 DefaultBlock->replaceAllUsesWith(SwitchExit.
getBlock());
1527 delete DefaultBlock;
1542 const Decl *TargetDecl = Call->getCalleeDecl();
1543 if (
const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(TargetDecl)) {
1544 if (FD->getBuiltinID() == Builtin::BI__builtin_unpredictable) {
1546 SwitchInsn->setMetadata(llvm::LLVMContext::MD_unpredictable,
1547 MDHelper.createUnpredictable());
1553 if (SwitchWeights) {
1554 assert(SwitchWeights->size() == 1 + SwitchInsn->getNumCases() &&
1555 "switch weights do not match switch cases");
1557 if (SwitchWeights->size() > 1)
1558 SwitchInsn->setMetadata(llvm::LLVMContext::MD_prof,
1559 createProfileWeights(*SwitchWeights));
1560 delete SwitchWeights;
1562 SwitchInsn = SavedSwitchInsn;
1563 SwitchWeights = SavedSwitchWeights;
1564 CaseRangeBlock = SavedCRBlock;
1572 while (*Constraint) {
1573 switch (*Constraint) {
1585 while (Constraint[1] && Constraint[1] !=
',')
1590 Result += *Constraint;
1591 while (Constraint[1] && Constraint[1] == *Constraint)
1602 "Must pass output names to constraints with a symbolic name");
1605 assert(result &&
"Could not resolve symbolic name"); (void)result;
1606 Result += llvm::utostr(Index);
1633 AsmLabelAttr *
Attr = Variable->
getAttr<AsmLabelAttr>();
1636 StringRef Register = Attr->getLabel();
1642 !Info.allowsRegister()) {
1648 return (EarlyClobber ?
"&{" :
"{") + Register.str() +
"}";
1654 std::string &ConstraintStr,
1663 if (Size <= 64 && llvm::isPowerOf2_64(Size)) {
1665 Ty = llvm::PointerType::getUnqual(Ty);
1671 ConstraintStr +=
'*';
1676 ConstraintStr +=
'*';
1684 const Expr *InputExpr,
1685 std::string &ConstraintStr) {
1693 "Required-immediate inlineasm arg isn't constant?");
1699 if (InputExpr->getStmtClass() == Expr::CXXThisExprClass)
1703 return EmitAsmInputLValue(Info, Dest, InputExpr->
getType(), ConstraintStr,
1715 Locs.push_back(llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
1718 if (!StrVal.empty()) {
1721 unsigned StartToken = 0;
1722 unsigned ByteOffset = 0;
1726 for (
unsigned i = 0, e = StrVal.size() - 1; i != e; ++i) {
1727 if (StrVal[i] !=
'\n')
continue;
1729 i + 1, SM, LangOpts, CGF.
getTarget(), &StartToken, &ByteOffset);
1730 Locs.push_back(llvm::ConstantAsMetadata::get(
1748 if (
const GCCAsmStmt *GAS = dyn_cast<GCCAsmStmt>(&S))
1749 Name = GAS->getOutputName(i);
1752 assert(IsValid &&
"Failed to parse output constraint");
1753 OutputConstraintInfos.push_back(Info);
1756 for (
unsigned i = 0, e = S.
getNumInputs(); i != e; i++) {
1758 if (
const GCCAsmStmt *GAS = dyn_cast<GCCAsmStmt>(&S))
1759 Name = GAS->getInputName(i);
1763 assert(IsValid &&
"Failed to parse input constraint"); (void)IsValid;
1764 InputConstraintInfos.push_back(Info);
1767 std::string Constraints;
1769 std::vector<LValue> ResultRegDests;
1770 std::vector<QualType> ResultRegQualTys;
1771 std::vector<llvm::Type *> ResultRegTypes;
1772 std::vector<llvm::Type *> ResultTruncRegTypes;
1773 std::vector<llvm::Type *> ArgTypes;
1774 std::vector<llvm::Value*> Args;
1777 std::string InOutConstraints;
1778 std::vector<llvm::Value*> InOutArgs;
1779 std::vector<llvm::Type*> InOutArgTypes;
1787 bool ReadOnly =
true, ReadNone =
true;
1805 if (!Constraints.empty())
1811 Constraints +=
"=" + OutputConstraint;
1812 ResultRegQualTys.push_back(OutExpr->getType());
1813 ResultRegDests.push_back(Dest);
1815 ResultTruncRegTypes.push_back(ResultRegTypes.back());
1822 for (InputNo = 0; InputNo != S.
getNumInputs(); ++InputNo) {
1827 assert(InputNo != S.
getNumInputs() &&
"Didn't find matching input!");
1830 QualType OutputType = OutExpr->getType();
1839 getTargetHooks().adjustInlineAsmType(*
this, OutputConstraint,
1840 ResultRegTypes.back()))
1841 ResultRegTypes.back() = AdjTy;
1844 diag::err_asm_invalid_type_in_input)
1845 << OutExpr->getType() << OutputConstraint;
1848 ArgTypes.push_back(Dest.getAddress().getType());
1849 Args.push_back(Dest.getPointer());
1850 Constraints +=
"=*";
1851 Constraints += OutputConstraint;
1852 ReadOnly = ReadNone =
false;
1856 InOutConstraints +=
',';
1869 InOutConstraints += llvm::utostr(i);
1871 InOutConstraints += OutputConstraint;
1873 InOutArgTypes.push_back(Arg->getType());
1874 InOutArgs.push_back(Arg);
1880 if (isa<MSAsmStmt>(&S)) {
1886 *
this, ReturnSlot, Constraints, ResultRegTypes, ResultTruncRegTypes,
1892 for (
unsigned i = 0, e = S.
getNumInputs(); i != e; i++) {
1900 if (!Constraints.empty())
1906 &OutputConstraintInfos);
1912 llvm::Value *Arg = EmitAsmInput(Info, InputExpr, Constraints);
1921 QualType OutputType = S.getOutputExpr(Output)->getType();
1927 if (isa<llvm::PointerType>(Arg->getType()))
1930 if (isa<llvm::IntegerType>(OutputTy))
1931 Arg =
Builder.CreateZExt(Arg, OutputTy);
1932 else if (isa<llvm::PointerType>(OutputTy))
1935 assert(OutputTy->isFloatingPointTy() &&
"Unexpected output type");
1936 Arg =
Builder.CreateFPExt(Arg, OutputTy);
1941 getTargetHooks().adjustInlineAsmType(*
this, InputConstraint,
1946 << InputExpr->
getType() << InputConstraint;
1948 ArgTypes.push_back(Arg->getType());
1949 Args.push_back(Arg);
1950 Constraints += InputConstraint;
1954 for (
unsigned i = 0, e = InOutArgs.size(); i != e; i++) {
1955 ArgTypes.push_back(InOutArgTypes[i]);
1956 Args.push_back(InOutArgs[i]);
1958 Constraints += InOutConstraints;
1964 if (Clobber ==
"memory")
1965 ReadOnly = ReadNone =
false;
1966 else if (Clobber !=
"cc")
1969 if (!Constraints.empty())
1972 Constraints +=
"~{";
1973 Constraints += Clobber;
1979 if (!MachineClobbers.empty()) {
1980 if (!Constraints.empty())
1982 Constraints += MachineClobbers;
1986 if (ResultRegTypes.empty())
1988 else if (ResultRegTypes.size() == 1)
1989 ResultType = ResultRegTypes[0];
1991 ResultType = llvm::StructType::get(
getLLVMContext(), ResultRegTypes);
1993 llvm::FunctionType *FTy =
1994 llvm::FunctionType::get(ResultType, ArgTypes,
false);
1997 llvm::InlineAsm::AsmDialect AsmDialect = isa<MSAsmStmt>(&
S) ?
1998 llvm::InlineAsm::AD_Intel : llvm::InlineAsm::AD_ATT;
1999 llvm::InlineAsm *IA =
2000 llvm::InlineAsm::get(FTy, AsmString, Constraints, HasSideEffect,
2002 llvm::CallInst *Result =
Builder.CreateCall(IA, Args);
2003 Result->addAttribute(llvm::AttributeSet::FunctionIndex,
2004 llvm::Attribute::NoUnwind);
2006 if (isa<MSAsmStmt>(&S)) {
2010 if (AsmString.find(
"__MSASMLABEL_") != std::string::npos)
2011 Result->addAttribute(llvm::AttributeSet::FunctionIndex,
2012 llvm::Attribute::NoDuplicate);
2016 if (!HasSideEffect) {
2018 Result->addAttribute(llvm::AttributeSet::FunctionIndex,
2019 llvm::Attribute::ReadNone);
2021 Result->addAttribute(llvm::AttributeSet::FunctionIndex,
2022 llvm::Attribute::ReadOnly);
2027 if (
const GCCAsmStmt *gccAsmStmt = dyn_cast<GCCAsmStmt>(&S)) {
2033 Result->setMetadata(
"srcloc",
2035 llvm::ConstantAsMetadata::get(Loc)));
2039 std::vector<llvm::Value*> RegResults;
2040 if (ResultRegTypes.size() == 1) {
2041 RegResults.push_back(Result);
2043 for (
unsigned i = 0, e = ResultRegTypes.size(); i != e; ++i) {
2045 RegResults.push_back(Tmp);
2049 assert(RegResults.size() == ResultRegTypes.size());
2050 assert(RegResults.size() == ResultTruncRegTypes.size());
2051 assert(RegResults.size() == ResultRegDests.size());
2052 for (
unsigned i = 0, e = RegResults.size(); i != e; ++i) {
2057 if (ResultRegTypes[i] != ResultTruncRegTypes[i]) {
2058 llvm::Type *TruncTy = ResultTruncRegTypes[i];
2062 if (TruncTy->isFloatingPointTy())
2063 Tmp =
Builder.CreateFPTrunc(Tmp, TruncTy);
2064 else if (TruncTy->isPointerTy() && Tmp->getType()->isIntegerTy()) {
2066 Tmp =
Builder.CreateTrunc(Tmp,
2068 Tmp =
Builder.CreateIntToPtr(Tmp, TruncTy);
2069 }
else if (Tmp->getType()->isPointerTy() && TruncTy->isIntegerTy()) {
2071 Tmp =
Builder.CreatePtrToInt(Tmp,
2073 Tmp =
Builder.CreateTrunc(Tmp, TruncTy);
2074 }
else if (TruncTy->isIntegerTy()) {
2075 Tmp =
Builder.CreateTrunc(Tmp, TruncTy);
2076 }
else if (TruncTy->isVectorTy()) {
2096 I !=
E; ++
I, ++CurField) {
2098 if (CurField->hasCapturedVLAType()) {
2099 auto VAT = CurField->getCapturedVLAType();
2136 "CapturedStmtInfo should be set when generating the captured function");
2140 assert(CD->
hasBody() &&
"missing CapturedDecl body");
2159 F->addFnAttr(llvm::Attribute::NoUnwind);
2164 CD->
getBody()->getLocStart());
2171 Ctx.getTagDeclType(RD));
2172 for (
auto *FD : RD->
fields()) {
2173 if (FD->hasCapturedVLAType()) {
2176 auto VAT = FD->getCapturedVLAType();
2177 VLASizeMap[VAT->getSizeExpr()] = ExprArg;
void EmitInitializerForField(FieldDecl *Field, LValue LHS, Expr *Init, ArrayRef< VarDecl * > ArrayIndexes)
void EmitIndirectGotoStmt(const IndirectGotoStmt &S)
const SwitchCase * getNextSwitchCase() const
virtual void EmitBody(CodeGenFunction &CGF, const Stmt *S)
Emit the captured statement body.
This represents a GCC inline-assembly statement extension.
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
unsigned getNumOutputs() const
void EmitOMPTaskwaitDirective(const OMPTaskwaitDirective &S)
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
A (possibly-)qualified type.
capture_init_iterator capture_init_begin()
Retrieve the first initialization argument.
void EmitSEHLeaveStmt(const SEHLeaveStmt &S)
llvm::Value * getPointer() const
CodeGenTypes & getTypes()
llvm::Type * ConvertTypeForMem(QualType T)
void EmitBranchOnBoolExpr(const Expr *Cond, llvm::BasicBlock *TrueBlock, llvm::BasicBlock *FalseBlock, uint64_t TrueCount)
EmitBranchOnBoolExpr - Emit a branch on a boolean condition (e.g.
void EmitGotoStmt(const GotoStmt &S)
void EmitAttributedStmt(const AttributedStmt &S)
bool hasMatchingInput() const
Return true if this output operand has a matching (tied) input operand.
llvm::Module & getModule() const
void EmitOMPDistributeDirective(const OMPDistributeDirective &S)
void EmitCXXTryStmt(const CXXTryStmt &S)
const TargetInfo & getTarget() const
IfStmt - This represents an if/then/else.
std::pair< llvm::Value *, llvm::Value * > getComplexVal() const
getComplexVal - Return the real/imag components of this complex value.
static stable_iterator stable_end()
Create a stable reference to the bottom of the EH stack.
const Expr * getOutputExpr(unsigned i) const
Decl - This represents one declaration (or definition), e.g.
Address getAddress() const
Defines the PrettyStackTraceEntry class, which is used to make crashes give more contextual informati...
Represents an attribute applied to a statement.
void EmitAutoVarDecl(const VarDecl &D)
EmitAutoVarDecl - Emit an auto variable declaration.
const llvm::DataLayout & getDataLayout() const
void EmitOMPOrderedDirective(const OMPOrderedDirective &S)
bool validateOutputConstraint(ConstraintInfo &Info) const
void EmitStoreThroughLValue(RValue Src, LValue Dst, bool isInit=false)
EmitStoreThroughLValue - Store the specified rvalue into the specified lvalue, where both are guarant...
void EmitComplexExprIntoLValue(const Expr *E, LValue dest, bool isInit)
EmitComplexExprIntoLValue - Emit the given expression of complex type and place its result into the s...
Address GenerateCapturedStmtArgument(const CapturedStmt &S)
QualType getRecordType(const RecordDecl *Decl) const
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
bool validateInputConstraint(MutableArrayRef< ConstraintInfo > OutputConstraints, ConstraintInfo &info) const
const Stmt * getElse() const
SourceLocation getLocStart() const LLVM_READONLY
const LangOptions & getLangOpts() const
LValue EmitLValueForFieldInitialization(LValue Base, const FieldDecl *Field)
EmitLValueForFieldInitialization - Like EmitLValueForField, except that if the Field is a reference...
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "for" statement, if any.
const CGFunctionInfo & arrangeFreeFunctionDeclaration(QualType ResTy, const FunctionArgList &Args, const FunctionType::ExtInfo &Info, bool isVariadic)
void EmitOMPParallelForSimdDirective(const OMPParallelForSimdDirective &S)
Address GetAddrOfLocalVar(const VarDecl *VD)
GetAddrOfLocalVar - Return the address of a local variable.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
void EmitOMPCriticalDirective(const OMPCriticalDirective &S)
uint64_t getProfileCount(const Stmt *S)
Get the profiler's count for the given statement.
field_iterator field_begin() const
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
This class gathers all debug information during compilation and is responsible for emitting to llvm g...
void EmitLabel(const LabelDecl *D)
EmitLabel - Emit the block for the given label.
CapturedRegionKind getCapturedRegionKind() const
Retrieve the captured region kind.
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
static llvm::Value * getTypeSize(CodeGenFunction &CGF, QualType Ty)
void SimplifyForwardingBlocks(llvm::BasicBlock *BB)
SimplifyForwardingBlocks - If the given basic block is only a branch to another basic block...
The collection of all-type qualifiers we support.
A jump destination is an abstract label, branching to which may require a jump out through normal cle...
LabelStmt - Represents a label, which has a substatement.
void EmitOMPTaskLoopSimdDirective(const OMPTaskLoopSimdDirective &S)
JumpDest getJumpDestForLabel(const LabelDecl *S)
getBasicBlockForLabel - Return the LLVM basicblock that the specified label maps to.
RecordDecl - Represents a struct/union/class.
void EmitCXXForRangeStmt(const CXXForRangeStmt &S, ArrayRef< const Attr * > Attrs=None)
void EmitOMPSimdDirective(const OMPSimdDirective &S)
void setScopeDepth(EHScopeStack::stable_iterator depth)
unsigned getNumInputs() const
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
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 ...
void addLabel(const LabelDecl *label)
RValue EmitReferenceBindingToExpr(const Expr *E)
Emits a reference binding to the passed in expression.
bool isReferenceType() const
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
void rescopeLabels()
Change the cleanup scope of the labels in this lexical scope to match the scope of the enclosing cont...
virtual void setContextValue(llvm::Value *V)
llvm::CallSite EmitCallOrInvoke(llvm::Value *Callee, ArrayRef< llvm::Value * > Args, const Twine &Name="")
Emits a call or invoke instruction to the given function, depending on the current state of the EH st...
SourceLocation getLBracLoc() const
static bool FindCaseStatementsForValue(const SwitchStmt &S, const llvm::APSInt &ConstantCondValue, SmallVectorImpl< const Stmt * > &ResultStmts, ASTContext &C, const SwitchCase *&ResultCase)
FindCaseStatementsForValue - Find the case statement being jumped to and then invoke CollectStatement...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
StorageClass getStorageClass() const
Returns the storage class as written in the source.
const VarDecl * getNRVOCandidate() const
Retrieve the variable that might be used for the named return value optimization. ...
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.
IndirectGotoStmt - This represents an indirect goto.
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
static bool hasScalarEvaluationKind(QualType T)
bool resolveSymbolicName(const char *&Name, ArrayRef< ConstraintInfo > OutputConstraints, unsigned &Index) const
ForStmt - This represents a 'for (init;cond;inc)' stmt.
StringRef getOutputConstraint(unsigned i) const
getOutputConstraint - Return the constraint string for the specified output operand.
void EmitDoStmt(const DoStmt &S, ArrayRef< const Attr * > Attrs=None)
void pop()
End the current loop.
bool isValidGCCRegisterName(StringRef Name) const
Returns whether the passed in string is a valid register name according to GCC.
void EmitOMPCancellationPointDirective(const OMPCancellationPointDirective &S)
RAII for correct setting/restoring of CapturedStmtInfo.
field_range fields() const
void EmitContinueStmt(const ContinueStmt &S)
void EmitOMPTargetDirective(const OMPTargetDirective &S)
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
bool IsOutlinedSEHHelper
True if the current function is an outlined SEH helper.
ABIArgInfo - Helper class to encapsulate information about how a specific C type should be passed to ...
void EmitSwitchStmt(const SwitchStmt &S)
If a crash happens while one of these objects are live, the message is printed out along with the spe...
LabelStmt * getStmt() const
bool isObviouslyBranchWithoutCleanups(JumpDest Dest) const
isObviouslyBranchWithoutCleanups - Return true if a branch to the specified destination obviously has...
Scope - A scope is a transient data structure that is used while parsing the program.
void incrementProfileCounter(const Stmt *S)
Increment the profiler's counter for the given statement.
void EmitStmt(const Stmt *S)
EmitStmt - Emit the code for the statement.
void EmitOMPParallelDirective(const OMPParallelDirective &S)
llvm::BasicBlock * createBasicBlock(const Twine &name="", llvm::Function *parent=nullptr, llvm::BasicBlock *before=nullptr)
createBasicBlock - Create an LLVM basic block.
void EmitIgnoredExpr(const Expr *E)
EmitIgnoredExpr - Emit an expression in a context which ignores the result.
void assignRegionCounters(GlobalDecl GD, llvm::Function *Fn)
Assign counters to regions and configure them for PGO of a given function.
llvm::Function * EmitCapturedStmt(const CapturedStmt &S, CapturedRegionKind K)
Generate an outlined function for the body of a CapturedStmt, store any captured variables into the c...
void push(llvm::BasicBlock *Header)
Begin a new structured loop.
bool requiresCleanups() const
Determine whether this scope requires any cleanups.
virtual FieldDecl * getThisFieldDecl() const
void EmitDefaultStmt(const DefaultStmt &S)
static bool ContainsLabel(const Stmt *S, bool IgnoreCaseStmts=false)
ContainsLabel - Return true if the statement contains a label in it.
const RecordDecl * getCapturedRecordDecl() const
Retrieve the record declaration for captured variables.
void EmitCaseStmtRange(const CaseStmt &S)
EmitCaseStmtRange - If case statement range is not too big then add multiple cases to switch instruct...
uint64_t getCurrentProfileCount()
Get the profiler's current count.
This represents the body of a CapturedStmt, and serves as its DeclContext.
detail::InMemoryDirectory::const_iterator I
LValue EmitLValueForField(LValue Base, const FieldDecl *Field)
LValue MakeAddrLValue(Address Addr, QualType T, AlignmentSource AlignSource=AlignmentSource::Type)
CompoundStmt - This represents a group of statements like { stmt stmt }.
SourceLocation getAsmLoc() const
void EmitOMPParallelSectionsDirective(const OMPParallelSectionsDirective &S)
const TargetCodeGenInfo & getTargetCodeGenInfo()
Expr * IgnoreParenNoopCasts(ASTContext &Ctx) LLVM_READONLY
IgnoreParenNoopCasts - Ignore parentheses and casts that do not change the value (including ptr->int ...
void EmitAnyExprToMem(const Expr *E, Address Location, Qualifiers Quals, bool IsInitializer)
EmitAnyExprToMem - Emits the code necessary to evaluate an arbitrary expression into the given memory...
RValue - This trivial value class is used to represent the result of an expression that is evaluated...
virtual std::string convertConstraint(const char *&Constraint) const
SourceLocation getBodyRBrace() const
getBodyRBrace - Gets the right brace of the body, if a body exists.
std::string generateAsmString(const ASTContext &C) const
Assemble final IR asm string.
Exposes information about the current target.
virtual StringRef getHelperName() const
Get the name of the capture helper.
static TypeEvaluationKind getEvaluationKind(QualType T)
hasAggregateLLVMType - Return true if the specified AST type will map into an aggregate LLVM type or ...
LabelDecl * getDecl() const
bool empty() const
Determines whether the exception-scopes stack is empty.
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
const Expr * getInputExpr(unsigned i) const
Enters a new scope for capturing cleanups, all of which will be executed once the scope is exited...
void EmitCaseStmt(const CaseStmt &S)
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "while" statement, if any.
void EmitOMPTeamsDirective(const OMPTeamsDirective &S)
void SetInternalFunctionAttributes(const Decl *D, llvm::Function *F, const CGFunctionInfo &FI)
Set the attributes on the LLVM function for the given decl and function info.
Address EmitCompoundStmt(const CompoundStmt &S, bool GetLast=false, AggValueSlot AVS=AggValueSlot::ignored())
EmitCompoundStmt - Emit a compound statement {..} node.
LabelDecl * getConstantTarget()
getConstantTarget - Returns the fixed target of this indirect goto, if one exists.
bool haveRegionCounts() const
Whether or not we have PGO region data for the current function.
void EmitSEHTryStmt(const SEHTryStmt &S)
ASTContext & getContext() const
llvm::BasicBlock * getBlock() const
EHScopeStack::stable_iterator getScopeDepth() const
static llvm::MDNode * getAsmSrcLocInfo(const StringLiteral *Str, CodeGenFunction &CGF)
getAsmSrcLocInfo - Return the !srcloc metadata node to attach to an inline asm call instruction...
stable_iterator stable_begin() const
Create a stable reference to the top of the EH stack.
llvm::LLVMContext & getLLVMContext()
llvm::BasicBlock * GetIndirectGotoBlock()
llvm::IntegerType * Int32Ty
const SwitchCase * getSwitchCaseList() const
void EmitOMPMasterDirective(const OMPMasterDirective &S)
bool EvaluateAsInt(llvm::APSInt &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer...
llvm::Function * GenerateCapturedStmtFunction(const CapturedStmt &S)
Creates the outlined function for a CapturedStmt.
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
LValue MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T)
void ResolveBranchFixups(llvm::BasicBlock *Target)
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)
Creates clause with a list of variables VL and a linear step Step.
void EmitOMPBarrierDirective(const OMPBarrierDirective &S)
static CSFC_Result CollectStatementsForCase(const Stmt *S, const SwitchCase *Case, bool &FoundCase, SmallVectorImpl< const Stmt * > &ResultStmts)
virtual llvm::Value * getContextValue() const
unsigned getTiedOperand() const
StringRef getInputConstraint(unsigned i) const
getInputConstraint - Return the specified input constraint.
The result type of a method or function.
static AggValueSlot forAddr(Address addr, Qualifiers quals, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, IsAliased_t isAliased, IsZeroed_t isZeroed=IsNotZeroed)
forAddr - Make a slot for an aggregate value.
llvm::StoreInst * CreateFlagStore(bool Value, llvm::Value *Addr)
Emit a store to an i1 flag variable.
GlobalDecl - represents a global declaration.
bool isCXXThisExprCaptured() const
DoStmt - This represents a 'do/while' stmt.
AsmStmt is the base class for GCCAsmStmt and MSAsmStmt.
void EmitDeclStmt(const DeclStmt &S)
The l-value was considered opaque, so the alignment was determined from a type.
LabelDecl * getLabel() const
void EmitOMPFlushDirective(const OMPFlushDirective &S)
bool HaveInsertPoint() const
HaveInsertPoint - True if an insertion point is defined.
bool SawAsmBlock
Whether we processed a Microsoft-style asm block during CodeGen.
Address CreateBitCast(Address Addr, llvm::Type *Ty, const llvm::Twine &Name="")
This captures a statement into a function.
ASTContext & getContext() const
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...
void EmitOMPForDirective(const OMPForDirective &S)
A saved depth on the scope stack.
llvm::Value * EvaluateExprAsBool(const Expr *E)
EvaluateExprAsBool - Perform the usual unary conversions on the specified expression and compare the ...
void EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S)
bool ConstantFoldsToSimpleInteger(const Expr *Cond, bool &Result)
ConstantFoldsToSimpleInteger - If the specified expression does not fold to a constant, or if it does but contains a label, return false.
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
LabelDecl - Represents the declaration of a label.
const Expr * getCond() const
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
bool allowsMemory() const
param_iterator param_begin() const
Retrieve an iterator pointing to the first parameter decl.
void EmitOMPTaskgroupDirective(const OMPTaskgroupDirective &S)
const CodeGenOptions & getCodeGenOpts() const
void EmitOMPSingleDirective(const OMPSingleDirective &S)
void StartFunction(GlobalDecl GD, QualType RetTy, llvm::Function *Fn, const CGFunctionInfo &FnInfo, const FunctionArgList &Args, SourceLocation Loc=SourceLocation(), SourceLocation StartLoc=SourceLocation())
Emit code for the start of a function.
const LangOptions & getLangOpts() const
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "switch" statement, if any.
void EmitOMPForSimdDirective(const OMPForSimdDirective &S)
void EmitOMPAtomicDirective(const OMPAtomicDirective &S)
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...
void EmitOMPSectionDirective(const OMPSectionDirective &S)
virtual llvm::Type * adjustInlineAsmType(CodeGen::CodeGenFunction &CGF, StringRef Constraint, llvm::Type *Ty) const
Corrects the low-level LLVM type for a given constraint and "usual" type.
void EmitOMPSectionsDirective(const OMPSectionsDirective &S)
void EmitForStmt(const ForStmt &S, ArrayRef< const Attr * > Attrs=None)
void EmitOMPTaskLoopDirective(const OMPTaskLoopDirective &S)
const CGFunctionInfo * CurFnInfo
void enterFullExpression(const ExprWithCleanups *E)
void EmitDecl(const Decl &D)
EmitDecl - Emit a declaration.
void FinishFunction(SourceLocation EndLoc=SourceLocation())
FinishFunction - Complete IR generation of the current function.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
llvm::Value * EmitScalarExpr(const Expr *E, bool IgnoreResultAssign=false)
EmitScalarExpr - Emit the computation of the specified expression of LLVM scalar type, returning the result.
FunctionArgList - Type for representing both the decl and type of parameters to a function...
void EmitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt &S)
void ErrorUnsupported(const Stmt *S, const char *Type)
Print out an error that codegen doesn't support the specified stmt yet.
CGFunctionInfo - Class to encapsulate the information about a function definition.
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "if" statement, if any.
This class organizes the cross-function state that is used while generating LLVM code.
void EmitOMPTaskyieldDirective(const OMPTaskyieldDirective &S)
LValue InitCapturedStruct(const CapturedStmt &S)
Address CreateMemTemp(QualType T, const Twine &Name="tmp")
CreateMemTemp - Create a temporary memory object of the given type, with appropriate alignment...
const Stmt * getBody() const
llvm::Value * getScalarVal() const
getScalarVal() - Return the Value* of this scalar value.
void EmitOMPParallelForDirective(const OMPParallelForDirective &S)
CSFC_Result
CollectStatementsForCase - Given the body of a 'switch' statement and a constant value that is being ...
bool hasTiedOperand() const
Return true if this input operand is a matching constraint that ties it to an output operand...
llvm::LoadInst * CreateLoad(Address Addr, const llvm::Twine &Name="")
llvm::IntegerType * IntPtrTy
StringRef getString() const
detail::InMemoryDirectory::const_iterator E
void EmitAggregateCopy(Address DestPtr, Address SrcPtr, QualType EltTy, bool isVolatile=false, bool isAssignment=false)
EmitAggregateCopy - Emit an aggregate copy.
void EmitOMPCancelDirective(const OMPCancelDirective &S)
llvm::StoreInst * CreateStore(llvm::Value *Val, Address Addr, bool IsVolatile=false)
const Expr * getRetValue() const
void EmitObjCAtThrowStmt(const ObjCAtThrowStmt &S)
body_iterator body_begin()
Stmt *const * const_body_iterator
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).
void EmitAggExpr(const Expr *E, AggValueSlot AS)
EmitAggExpr - Emit the computation of the specified expression of aggregate type. ...
const Stmt * getThen() const
JumpDest ReturnBlock
ReturnBlock - Unified return block.
static bool hasAggregateEvaluationKind(QualType T)
SwitchStmt - This represents a 'switch' stmt.
bool isEvaluatable(const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
isEvaluatable - Call EvaluateAsRValue to see if this expression can be constant folded without side-e...
static stable_iterator invalid()
API for captured statement code generation.
static std::string SimplifyConstraint(const char *Constraint, const TargetInfo &Target, SmallVectorImpl< TargetInfo::ConstraintInfo > *OutCons=nullptr)
void EmitBlockWithFallThrough(llvm::BasicBlock *BB, const Stmt *S)
When instrumenting to collect profile data, the counts for some blocks such as switch cases need to n...
DeclStmt * getBeginEndStmt()
void EmitStoreOfComplex(ComplexPairTy V, LValue dest, bool isInit)
EmitStoreOfComplex - Store a complex number into the specified l-value.
void EmitAsmStmt(const AsmStmt &S)
static std::string AddVariableConstraints(const std::string &Constraint, const Expr &AsmExpr, const TargetInfo &Target, CodeGenModule &CGM, const AsmStmt &Stmt, const bool EarlyClobber)
AddVariableConstraints - Look at AsmExpr and if it is a variable declared as using a particular regis...
llvm::PointerType * Int8PtrTy
const TargetInfo & Target
bool allowsRegister() const
bool isNRVOVariable() const
Determine whether this local variable can be used with the named return value optimization (NRVO)...
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
SourceLocation getLocStart() const LLVM_READONLY
StringRef getClobber(unsigned i) const
ImplicitParamDecl * getContextParam() const
Retrieve the parameter containing captured variables.
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
EmitBlock - Emit the given block.
ABIArgInfo & getReturnInfo()
SourceManager & getSourceManager()
DeclStmt * getRangeStmt()
void EmitStopPoint(const Stmt *S)
EmitStopPoint - Emit a debug stoppoint if we are emitting debug info.
GotoStmt - This represents a direct goto.
ArrayRef< const Attr * > getAttrs() const
unsigned NextCleanupDestIndex
param_iterator param_end() const
Retrieve an iterator one past the last parameter decl.
CapturedDecl * getCapturedDecl()
Retrieve the outlined function declaration.
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...
DiagnosticsEngine & getDiags() const
void EmitIfStmt(const IfStmt &S)
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 EmitReturnStmt(const ReturnStmt &S)
EmitReturnStmt - Note that due to GCC extensions, this can have an operand if the function returns vo...
llvm::Type * ConvertType(QualType T)
WhileStmt - This represents a 'while' stmt.
LValue EmitLValue(const Expr *E)
EmitLValue - Emit code to compute a designator that specifies the location of the expression...
const Expr * getCond() const
Address ReturnValue
ReturnValue - The temporary alloca to hold the return value.
void EmitLabelStmt(const LabelStmt &S)
Address getAggregateAddress() const
getAggregateAddr() - Return the Value* of the address of the aggregate.
StringRef getNormalizedGCCRegisterName(StringRef Name) const
Returns the "normalized" GCC register name.
RValue EmitLoadOfLValue(LValue V, SourceLocation Loc)
EmitLoadOfLValue - Given an expression that represents a value lvalue, this method emits the address ...
bool hasNormalCleanups() const
Determines whether there are any normal cleanups on the stack.
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
void ForceCleanup()
Force the emission of cleanups now, instead of waiting until this object is destroyed.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
CGCapturedStmtInfo * CapturedStmtInfo
stable_iterator getInnermostNormalCleanup() const
Returns the innermost normal cleanup on the stack, or stable_end() if there are no normal cleanups...
A reference to a declared variable, function, enum, etc.
static RValue get(llvm::Value *V)
bool EmitSimpleStmt(const Stmt *S)
EmitSimpleStmt - Try to emit a "simple" statement which does not necessarily require an insertion poi...
BreakStmt - This represents a break.
void EmitOMPTargetDataDirective(const OMPTargetDataDirective &S)
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...
static ApplyDebugLocation CreateEmpty(CodeGenFunction &CGF)
Set the IRBuilder to not attach debug locations.
Address EmitCompoundStmtWithoutScope(const CompoundStmt &S, bool GetLast=false, AggValueSlot AVS=AggValueSlot::ignored())
DeclStmt * getLoopVarStmt()
unsigned getNumClobbers() const
SourceLocation getLocation() const
void EmitObjCAtTryStmt(const ObjCAtTryStmt &S)
LValue - This represents an lvalue references.
void EmitWhileStmt(const WhileStmt &S, ArrayRef< const Attr * > Attrs=None)
virtual void addReturnRegisterOutputs(CodeGen::CodeGenFunction &CGF, CodeGen::LValue ReturnValue, std::string &Constraints, std::vector< llvm::Type * > &ResultRegTypes, std::vector< llvm::Type * > &ResultTruncRegTypes, std::vector< CodeGen::LValue > &ResultRegDests, std::string &AsmString, unsigned NumOutputs) const
Adds constraints and types for result registers.
SourceLocation getLocationOfByte(unsigned ByteNo, const SourceManager &SM, const LangOptions &Features, const TargetInfo &Target, unsigned *StartToken=nullptr, unsigned *StartTokenByteOffset=nullptr) const
getLocationOfByte - Return a source location that points to the specified byte of this string literal...
void EmitBlockAfterUses(llvm::BasicBlock *BB)
EmitBlockAfterUses - Emit the given block somewhere hopefully near its uses, and leave the insertion ...
void EmitBreakStmt(const BreakStmt &S)
Expr *const * const_capture_init_iterator
Const iterator that walks over the capture initialization arguments.
void EmitObjCAutoreleasePoolStmt(const ObjCAutoreleasePoolStmt &S)
static bool containsBreak(const Stmt *S)
containsBreak - Return true if the statement contains a break out of it.
capture_init_iterator capture_init_end()
Retrieve the iterator pointing one past the last initialization argument.
virtual bool hasBody() const
Returns true if this Decl represents a declaration for a body of code, such as a function or method d...
This class handles loading and caching of source files into memory.
Defines enum values for all the target-independent builtin functions.
void EmitOMPTaskDirective(const OMPTaskDirective &S)
bool requiresImmediateConstant() const
A class which abstracts out some details necessary for making a call.
Attr - This represents one attribute.
virtual const char * getClobbers() const =0
Returns a string of target-specific clobbers, in LLVM format.
llvm::FunctionType * GetFunctionType(const CGFunctionInfo &Info)
GetFunctionType - Get the LLVM function type for.