clang 24.0.0git
CIRGenStmt.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Emit Stmt nodes as CIR code.
10//
11//===----------------------------------------------------------------------===//
12
13#include "CIRGenBuilder.h"
14#include "CIRGenFunction.h"
15
16#include "mlir/IR/Builders.h"
17#include "mlir/IR/Location.h"
18#include "mlir/Support/LLVM.h"
19#include "clang/AST/ExprCXX.h"
20#include "clang/AST/Stmt.h"
24
25using namespace clang;
26using namespace clang::CIRGen;
27using namespace cir;
28
29static mlir::LogicalResult emitStmtWithResult(CIRGenFunction &cgf,
30 const Stmt *exprResult,
31 AggValueSlot slot,
32 Address *lastValue) {
33 // We have to special case labels here. They are statements, but when put
34 // at the end of a statement expression, they yield the value of their
35 // subexpression. Handle this by walking through all labels we encounter,
36 // emitting them before we evaluate the subexpr.
37 // Similar issues arise for attributed statements.
38 while (!isa<Expr>(exprResult)) {
39 if (const auto *ls = dyn_cast<LabelStmt>(exprResult)) {
40 if (cgf.emitLabel(*ls->getDecl()).failed())
41 return mlir::failure();
42 exprResult = ls->getSubStmt();
43 } else if (const auto *as = dyn_cast<AttributedStmt>(exprResult)) {
44 // FIXME: Update this if we ever have attributes that affect the
45 // semantics of an expression.
46 exprResult = as->getSubStmt();
47 } else {
48 llvm_unreachable("Unknown value statement");
49 }
50 }
51
52 const Expr *e = cast<Expr>(exprResult);
53 QualType exprTy = e->getType();
54 if (cgf.hasAggregateEvaluationKind(exprTy)) {
55 cgf.emitAggExpr(e, slot);
56 } else {
57 // We can't return an RValue here because there might be cleanups at
58 // the end of the StmtExpr. Because of that, we have to emit the result
59 // here into a temporary alloca.
60 cgf.emitAnyExprToMem(e, *lastValue, Qualifiers(),
61 /*IsInit*/ false);
62 }
63
64 return mlir::success();
65}
66
68 const CompoundStmt &s, Address *lastValue, AggValueSlot slot) {
69 mlir::LogicalResult result = mlir::success();
70 const Stmt *exprResult = s.body_back();
71 assert((!lastValue || (lastValue && exprResult)) &&
72 "If lastValue is not null then the CompoundStmt must have a "
73 "StmtExprResult");
74
75 for (const Stmt *curStmt : s.body()) {
76 const bool saveResult = lastValue && exprResult == curStmt;
77 if (saveResult) {
78 if (emitStmtWithResult(*this, exprResult, slot, lastValue).failed())
79 result = mlir::failure();
80 } else {
81 if (emitStmt(curStmt, /*useCurrentScope=*/false).failed())
82 result = mlir::failure();
83 }
84 }
85 return result;
86}
87
88mlir::LogicalResult
90 for (const Attr *attr : s.getAttrs()) {
91 switch (attr->getKind()) {
92 default:
93 break;
94 case attr::NoMerge:
95 case attr::NoInline:
96 case attr::AlwaysInline:
97 case attr::NoConvergent:
98 case attr::MustTail:
99 case attr::Atomic:
100 case attr::HLSLControlFlowHint:
101 cgm.errorNYI(s.getSourceRange(),
102 "Unimplemented statement attribute: ", attr->getKind());
103 break;
104 case attr::CXXAssume: {
105 const Expr *assumptionExpr = cast<CXXAssumeAttr>(attr)->getAssumption();
106 if (getLangOpts().CXXAssumptions && builder.getInsertionBlock() &&
107 !assumptionExpr->HasSideEffects(getContext())) {
108 mlir::Value assumptionValue = emitCheckedArgForAssume(assumptionExpr);
109 cir::AssumeOp::create(builder, getLoc(s.getSourceRange()),
110 assumptionValue, cir::AssumeBundleKind::None,
111 mlir::ValueRange{});
112 }
113 } break;
114 }
115 }
116
117 return emitStmt(s.getSubStmt(), /*useCurrentScope=*/true, s.getAttrs());
118}
119
121 Address *lastValue,
122 AggValueSlot slot) {
123 // Add local scope to track new declared variables.
125 mlir::Location scopeLoc = getLoc(s.getSourceRange());
126 mlir::OpBuilder::InsertPoint scopeInsPt;
127 cir::ScopeOp::create(
128 builder, scopeLoc,
129 [&](mlir::OpBuilder &b, mlir::Type &type, mlir::Location loc) {
130 scopeInsPt = b.saveInsertionPoint();
131 });
132 mlir::OpBuilder::InsertionGuard guard(builder);
133 builder.restoreInsertionPoint(scopeInsPt);
134 LexicalScope lexScope(*this, scopeLoc, builder.getInsertionBlock());
135 return emitCompoundStmtWithoutScope(s, lastValue, slot);
136}
137
141
142// Build CIR for a statement. useCurrentScope should be true if no new scopes
143// need to be created when finding a compound statement.
144mlir::LogicalResult CIRGenFunction::emitStmt(const Stmt *s,
145 bool useCurrentScope,
147 if (mlir::succeeded(emitSimpleStmt(s, useCurrentScope)))
148 return mlir::success();
149
150 switch (s->getStmtClass()) {
152 case Stmt::CXXCatchStmtClass:
153 case Stmt::SEHExceptStmtClass:
154 case Stmt::SEHFinallyStmtClass:
155 case Stmt::MSDependentExistsStmtClass:
156 case Stmt::UnresolvedSYCLKernelCallStmtClass:
157 llvm_unreachable("invalid statement class to emit generically");
158 case Stmt::BreakStmtClass:
159 case Stmt::NullStmtClass:
160 case Stmt::CompoundStmtClass:
161 case Stmt::ContinueStmtClass:
162 case Stmt::DeclStmtClass:
163 case Stmt::ReturnStmtClass:
164 llvm_unreachable("should have emitted these statements as simple");
165
166#define STMT(Type, Base)
167#define ABSTRACT_STMT(Op)
168#define EXPR(Type, Base) case Stmt::Type##Class:
169#include "clang/AST/StmtNodes.inc"
170 {
171 assert(builder.getInsertionBlock() &&
172 "expression emission must have an insertion point");
173
175
176 // Classic codegen has a check here to see if the emitter created a new
177 // block that isn't used (comparing the incoming and outgoing insertion
178 // points) and deletes the outgoing block if it's not used. In CIR, we
179 // will handle that during the cir.canonicalize pass.
180 return mlir::success();
181 }
182 case Stmt::IfStmtClass:
183 return emitIfStmt(cast<IfStmt>(*s));
184 case Stmt::SwitchStmtClass:
186 case Stmt::ForStmtClass:
187 return emitForStmt(cast<ForStmt>(*s));
188 case Stmt::WhileStmtClass:
189 return emitWhileStmt(cast<WhileStmt>(*s));
190 case Stmt::DoStmtClass:
191 return emitDoStmt(cast<DoStmt>(*s));
192 case Stmt::CXXTryStmtClass:
194 case Stmt::CXXForRangeStmtClass:
196 case Stmt::CoroutineBodyStmtClass:
198 case Stmt::IndirectGotoStmtClass:
200 case Stmt::CoreturnStmtClass:
202 case Stmt::OpenACCComputeConstructClass:
204 case Stmt::OpenACCLoopConstructClass:
206 case Stmt::OpenACCCombinedConstructClass:
208 case Stmt::OpenACCDataConstructClass:
210 case Stmt::OpenACCEnterDataConstructClass:
212 case Stmt::OpenACCExitDataConstructClass:
214 case Stmt::OpenACCHostDataConstructClass:
216 case Stmt::OpenACCWaitConstructClass:
218 case Stmt::OpenACCInitConstructClass:
220 case Stmt::OpenACCShutdownConstructClass:
222 case Stmt::OpenACCSetConstructClass:
224 case Stmt::OpenACCUpdateConstructClass:
226 case Stmt::OpenACCCacheConstructClass:
228 case Stmt::OpenACCAtomicConstructClass:
230 case Stmt::GCCAsmStmtClass:
231 case Stmt::MSAsmStmtClass:
232 return emitAsmStmt(cast<AsmStmt>(*s));
233 case Stmt::OMPScopeDirectiveClass:
235 case Stmt::OMPErrorDirectiveClass:
237 case Stmt::OMPParallelDirectiveClass:
239 case Stmt::OMPTaskwaitDirectiveClass:
241 case Stmt::OMPTaskyieldDirectiveClass:
243 case Stmt::OMPBarrierDirectiveClass:
245 case Stmt::OMPMetaDirectiveClass:
247 case Stmt::OMPCanonicalLoopClass:
249 case Stmt::OMPSimdDirectiveClass:
251 case Stmt::OMPTileDirectiveClass:
253 case Stmt::OMPUnrollDirectiveClass:
255 case Stmt::OMPFuseDirectiveClass:
257 case Stmt::OMPForDirectiveClass:
259 case Stmt::OMPForSimdDirectiveClass:
261 case Stmt::OMPSectionsDirectiveClass:
263 case Stmt::OMPSectionDirectiveClass:
265 case Stmt::OMPSingleDirectiveClass:
267 case Stmt::OMPMasterDirectiveClass:
269 case Stmt::OMPCriticalDirectiveClass:
271 case Stmt::OMPParallelForDirectiveClass:
273 case Stmt::OMPParallelForSimdDirectiveClass:
276 case Stmt::OMPParallelMasterDirectiveClass:
278 case Stmt::OMPParallelSectionsDirectiveClass:
281 case Stmt::OMPTaskDirectiveClass:
283 case Stmt::OMPTaskgroupDirectiveClass:
285 case Stmt::OMPFlushDirectiveClass:
287 case Stmt::OMPDepobjDirectiveClass:
289 case Stmt::OMPScanDirectiveClass:
291 case Stmt::OMPOrderedDirectiveClass:
293 case Stmt::OMPAtomicDirectiveClass:
295 case Stmt::OMPTargetDirectiveClass:
297 case Stmt::OMPTeamsDirectiveClass:
299 case Stmt::OMPCancellationPointDirectiveClass:
302 case Stmt::OMPCancelDirectiveClass:
304 case Stmt::OMPTargetDataDirectiveClass:
306 case Stmt::OMPTargetEnterDataDirectiveClass:
309 case Stmt::OMPTargetExitDataDirectiveClass:
311 case Stmt::OMPTargetParallelDirectiveClass:
313 case Stmt::OMPTargetParallelForDirectiveClass:
316 case Stmt::OMPTaskLoopDirectiveClass:
318 case Stmt::OMPTaskLoopSimdDirectiveClass:
320 case Stmt::OMPMaskedTaskLoopDirectiveClass:
322 case Stmt::OMPMaskedTaskLoopSimdDirectiveClass:
325 case Stmt::OMPMasterTaskLoopDirectiveClass:
327 case Stmt::OMPMasterTaskLoopSimdDirectiveClass:
330 case Stmt::OMPParallelGenericLoopDirectiveClass:
333 case Stmt::OMPParallelMaskedDirectiveClass:
335 case Stmt::OMPParallelMaskedTaskLoopDirectiveClass:
338 case Stmt::OMPParallelMaskedTaskLoopSimdDirectiveClass:
341 case Stmt::OMPParallelMasterTaskLoopDirectiveClass:
344 case Stmt::OMPParallelMasterTaskLoopSimdDirectiveClass:
347 case Stmt::OMPDistributeDirectiveClass:
349 case Stmt::OMPDistributeParallelForDirectiveClass:
352 case Stmt::OMPDistributeParallelForSimdDirectiveClass:
355 case Stmt::OMPDistributeSimdDirectiveClass:
357 case Stmt::OMPTargetParallelGenericLoopDirectiveClass:
360 case Stmt::OMPTargetParallelForSimdDirectiveClass:
363 case Stmt::OMPTargetSimdDirectiveClass:
365 case Stmt::OMPTargetTeamsGenericLoopDirectiveClass:
368 case Stmt::OMPTargetUpdateDirectiveClass:
370 case Stmt::OMPTeamsDistributeDirectiveClass:
373 case Stmt::OMPTeamsDistributeSimdDirectiveClass:
376 case Stmt::OMPTeamsDistributeParallelForSimdDirectiveClass:
379 case Stmt::OMPTeamsDistributeParallelForDirectiveClass:
382 case Stmt::OMPTeamsGenericLoopDirectiveClass:
385 case Stmt::OMPTargetTeamsDirectiveClass:
387 case Stmt::OMPTargetTeamsDistributeDirectiveClass:
390 case Stmt::OMPTargetTeamsDistributeParallelForDirectiveClass:
393 case Stmt::OMPTargetTeamsDistributeParallelForSimdDirectiveClass:
396 case Stmt::OMPTargetTeamsDistributeSimdDirectiveClass:
399 case Stmt::OMPInteropDirectiveClass:
401 case Stmt::OMPDispatchDirectiveClass:
403 case Stmt::OMPGenericLoopDirectiveClass:
405 case Stmt::OMPReverseDirectiveClass:
407 case Stmt::OMPSplitDirectiveClass:
409 case Stmt::OMPInterchangeDirectiveClass:
411 case Stmt::OMPAssumeDirectiveClass:
413 case Stmt::OMPMaskedDirectiveClass:
415 case Stmt::OMPStripeDirectiveClass:
417 case Stmt::LabelStmtClass:
418 case Stmt::AttributedStmtClass:
419 case Stmt::GotoStmtClass:
420 case Stmt::DefaultStmtClass:
421 case Stmt::CaseStmtClass:
422 case Stmt::SEHLeaveStmtClass:
423 case Stmt::SYCLKernelCallStmtClass:
424 case Stmt::ObjCAtTryStmtClass:
425 case Stmt::ObjCAtThrowStmtClass:
426 case Stmt::ObjCAtSynchronizedStmtClass:
427 case Stmt::ObjCForCollectionStmtClass:
428 case Stmt::ObjCAutoreleasePoolStmtClass:
429 case Stmt::SEHTryStmtClass:
430 case Stmt::ObjCAtCatchStmtClass:
431 case Stmt::ObjCAtFinallyStmtClass:
432 case Stmt::DeferStmtClass:
433 case Stmt::CXXExpansionStmtPatternClass:
434 case Stmt::CXXExpansionStmtInstantiationClass:
435 cgm.errorNYI(s->getSourceRange(),
436 std::string("emitStmt: ") + s->getStmtClassName());
437 return mlir::failure();
438 case Stmt::CapturedStmtClass:
439 llvm_unreachable("CapturedStmt must be handled by the parent directive");
440 }
441
442 llvm_unreachable("Unexpected statement class");
443}
444
445mlir::LogicalResult CIRGenFunction::emitSimpleStmt(const Stmt *s,
446 bool useCurrentScope) {
447 switch (s->getStmtClass()) {
448 default:
449 return mlir::failure();
450 case Stmt::DeclStmtClass:
451 return emitDeclStmt(cast<DeclStmt>(*s));
452 case Stmt::CompoundStmtClass:
453 if (useCurrentScope)
456 case Stmt::GotoStmtClass:
457 return emitGotoStmt(cast<GotoStmt>(*s));
458 case Stmt::ContinueStmtClass:
460
461 // NullStmt doesn't need any handling, but we need to say we handled it.
462 case Stmt::NullStmtClass:
463 break;
464
465 case Stmt::LabelStmtClass:
466 return emitLabelStmt(cast<LabelStmt>(*s));
467 case Stmt::CaseStmtClass:
468 case Stmt::DefaultStmtClass:
469 // If we reached here, we must not handling a switch case in the top level.
471 /*buildingTopLevelCase=*/false);
472 break;
473
474 case Stmt::BreakStmtClass:
475 return emitBreakStmt(cast<BreakStmt>(*s));
476 case Stmt::ReturnStmtClass:
478 case Stmt::AttributedStmtClass:
480 }
481
482 return mlir::success();
483}
484
485mlir::LogicalResult CIRGenFunction::emitLabelStmt(const clang::LabelStmt &s) {
486
487 if (emitLabel(*s.getDecl()).failed())
488 return mlir::failure();
489
490 if (getContext().getLangOpts().EHAsynch && s.isSideEntry())
491 getCIRGenModule().errorNYI(s.getSourceRange(), "IsEHa: not implemented.");
492
493 return emitStmt(s.getSubStmt(), /*useCurrentScope*/ true);
494}
495
496// Add a terminating yield on a body region if no other terminators are used.
498 mlir::Location loc) {
499 if (r.empty())
500 return;
501
503 unsigned numBlocks = r.getBlocks().size();
504 for (auto &block : r.getBlocks()) {
505 // Already cleanup after return operations, which might create
506 // empty blocks if emitted as last stmt.
507 if (numBlocks != 1 && block.empty() && block.hasNoPredecessors() &&
508 block.hasNoSuccessors())
509 eraseBlocks.push_back(&block);
510
511 if (block.empty() ||
512 !block.back().hasTrait<mlir::OpTrait::IsTerminator>()) {
513 mlir::OpBuilder::InsertionGuard guardCase(builder);
514 builder.setInsertionPointToEnd(&block);
515 builder.createYield(loc);
516 }
517 }
518
519 for (auto *b : eraseBlocks)
520 b->erase();
521}
522
523mlir::LogicalResult CIRGenFunction::emitIfStmt(const IfStmt &s) {
524 mlir::LogicalResult res = mlir::success();
525 // The else branch of a consteval if statement is always the only branch
526 // that can be runtime evaluated.
527 const Stmt *constevalExecuted;
528 if (s.isConsteval()) {
529 constevalExecuted = s.isNegatedConsteval() ? s.getThen() : s.getElse();
530 if (!constevalExecuted) {
531 // No runtime code execution required
532 return res;
533 }
534 }
535
536 // C99 6.8.4.1: The first substatement is executed if the expression
537 // compares unequal to 0. The condition must be a scalar type.
538 auto ifStmtBuilder = [&]() -> mlir::LogicalResult {
539 if (s.isConsteval())
540 return emitStmt(constevalExecuted, /*useCurrentScope=*/true);
541
542 if (s.getInit())
543 if (emitStmt(s.getInit(), /*useCurrentScope=*/true).failed())
544 return mlir::failure();
545
546 if (s.getConditionVariable())
548
549 // If the condition folds to a constant and this is an 'if constexpr',
550 // we simplify it early in CIRGen to avoid emitting the full 'if'.
551 bool condConstant;
552 if (constantFoldsToBool(s.getCond(), condConstant, s.isConstexpr())) {
553 if (s.isConstexpr()) {
554 // Handle "if constexpr" explicitly here to avoid generating some
555 // ill-formed code since in CIR the "if" is no longer simplified
556 // in this lambda like in Clang but postponed to other MLIR
557 // passes.
558 if (const Stmt *executed = condConstant ? s.getThen() : s.getElse())
559 return emitStmt(executed, /*useCurrentScope=*/true);
560 // There is nothing to execute at runtime.
561 // TODO(cir): there is still an empty cir.scope generated by the caller.
562 return mlir::success();
563 }
564 }
565
568 return emitIfOnBoolExpr(s.getCond(), s.getThen(), s.getElse());
569 };
570
571 // TODO: Add a new scoped symbol table.
572 // LexicalScope ConditionScope(*this, S.getCond()->getSourceRange());
573 // The if scope contains the full source range for IfStmt.
574 mlir::Location scopeLoc = getLoc(s.getSourceRange());
575 cir::ScopeOp::create(builder, scopeLoc, /*scopeBuilder=*/
576 [&](mlir::OpBuilder &b, mlir::Location loc) {
577 LexicalScope lexScope{*this, scopeLoc,
578 builder.getInsertionBlock()};
579 res = ifStmtBuilder();
580 });
581
582 return res;
583}
584
585mlir::LogicalResult CIRGenFunction::emitDeclStmt(const DeclStmt &s) {
586 assert(builder.getInsertionBlock() && "expected valid insertion point");
587
588 for (const Decl *i : s.decls())
589 emitDecl(*i, /*evaluateConditionDecl=*/true);
590
591 return mlir::success();
592}
593
594mlir::LogicalResult CIRGenFunction::emitReturnStmt(const ReturnStmt &s) {
595 mlir::Location loc = getLoc(s.getSourceRange());
596 const Expr *rv = s.getRetValue();
597
598 RunCleanupsScope cleanupScope(*this);
599 bool createNewScope = false;
600 if (const auto *ewc = dyn_cast_or_null<ExprWithCleanups>(rv)) {
601 rv = ewc->getSubExpr();
602 createNewScope = true;
603 }
604
605 auto handleReturnVal = [&]() {
606 if (getContext().getLangOpts().ElideConstructors && s.getNRVOCandidate() &&
609 // Apply the named return value optimization for this return statement,
610 // which means doing nothing: the appropriate result has already been
611 // constructed into the NRVO variable.
612
613 // If there is an NRVO flag for this variable, set it to 1 into indicate
614 // that the cleanup code should not destroy the variable.
615 if (auto nrvoFlag = nrvoFlags[s.getNRVOCandidate()])
616 builder.createFlagStore(loc, true, nrvoFlag);
617 } else if (!rv) {
618 // No return expression. Do nothing.
619 } else if (rv->getType()->isVoidType()) {
620 // Make sure not to return anything, but evaluate the expression
621 // for side effects.
622 if (rv) {
623 emitAnyExpr(rv);
624 }
625 } else if (cast<FunctionDecl>(curGD.getDecl())
626 ->getReturnType()
627 ->isReferenceType()) {
628 // If this function returns a reference, take the address of the
629 // expression rather than the value.
631 builder.CIRBaseBuilderTy::createStore(loc, result.getValue(),
632 *fnRetAlloca);
633 } else {
634 mlir::Value value = nullptr;
636 case cir::TEK_Scalar:
637 value = emitScalarExpr(rv);
638 if (value) { // Change this to an assert once emitScalarExpr is complete
639 builder.CIRBaseBuilderTy::createStore(loc, value, *fnRetAlloca);
640 }
641 break;
642 case cir::TEK_Complex:
645 /*isInit=*/true);
646 break;
653 break;
654 }
655 }
656 };
657
658 if (!createNewScope) {
659 handleReturnVal();
660 } else {
661 FullExprCleanupScope fullExprScope(*this, rv);
662 handleReturnVal();
663 }
664
665 cleanupScope.forceCleanup();
666
667 // Classic codegen emits a branch through any cleanups before continuing to
668 // a shared return block. Because CIR handles branching through cleanups
669 // during the CFG flattening phase, we can just emit the return statement
670 // directly.
671 // TODO(cir): Eliminate this redundant load and the store above when we can.
672 if (fnRetAlloca) {
673 // Load the value from `__retval` and return it via the `cir.return` op.
674 cir::AllocaOp retAlloca =
675 mlir::cast<cir::AllocaOp>(fnRetAlloca->getDefiningOp());
676 auto value = cir::LoadOp::create(builder, loc, retAlloca.getAllocaType(),
677 *fnRetAlloca);
678
679 cir::ReturnOp::create(builder, loc, {value});
680 } else {
681 cir::ReturnOp::create(builder, loc);
682 }
683
684 // Insert the new block to continue codegen after the return statement.
685 // This will get deleted if we don't populate it. This handles the case of
686 // unreachable statements below a return.
687 builder.createBlock(builder.getBlock()->getParent());
688 return mlir::success();
689}
690
691mlir::LogicalResult CIRGenFunction::emitGotoStmt(const clang::GotoStmt &s) {
692 // FIXME: LLVM codegen inserts emit a stop point here for debug info
693 // sake when the insertion point is available, but doesn't do
694 // anything special when there isn't. We haven't implemented debug
695 // info support just yet, look at this again once we have it.
697
698 cir::GotoOp::create(builder, getLoc(s.getSourceRange()),
699 s.getLabel()->getName());
700
701 // A goto marks the end of a block, create a new one for codegen after
702 // emitGotoStmt can resume building in that block.
703 // Insert the new block to continue codegen after goto.
704 builder.createBlock(builder.getBlock()->getParent());
705
706 return mlir::success();
707}
708
709mlir::LogicalResult
711 mlir::Value val = emitScalarExpr(s.getTarget());
712 // Create the shared indirect-branch block on first use. Its successors are
713 // every address-taken label, wired in finishIndirectBranch once all labels
714 // are emitted.
716 cir::BrOp::create(builder, getLoc(s.getSourceRange()), indirectGotoBlock,
717 val);
718 builder.createBlock(builder.getBlock()->getParent());
719 return mlir::success();
720}
721
722mlir::LogicalResult
724 builder.createContinue(getLoc(s.getKwLoc()));
725
726 // Insert the new block to continue codegen after the continue statement.
727 builder.createBlock(builder.getBlock()->getParent());
728
729 return mlir::success();
730}
731
732mlir::LogicalResult CIRGenFunction::emitLabel(const clang::LabelDecl &d) {
733 // Create a new block to tag with a label and add a branch from
734 // the current one to it. If the block is empty just call attach it
735 // to this label.
736 mlir::Block *currBlock = builder.getBlock();
737 mlir::Block *labelBlock = currBlock;
738
739 if (!currBlock->empty() || currBlock->isEntryBlock()) {
740 {
741 mlir::OpBuilder::InsertionGuard guard(builder);
742 labelBlock = builder.createBlock(builder.getBlock()->getParent());
743 }
744 cir::BrOp::create(builder, getLoc(d.getSourceRange()), labelBlock);
745 }
746
747 builder.setInsertionPointToEnd(labelBlock);
748 cir::LabelOp label =
749 cir::LabelOp::create(builder, getLoc(d.getSourceRange()), d.getName());
750 builder.setInsertionPointToEnd(labelBlock);
751 auto func = cast<cir::FuncOp>(curFn);
752 cgm.mapBlockAddress(cir::BlockAddrInfoAttr::get(builder.getContext(),
753 func.getSymName(),
754 label.getLabel()),
755 label);
756 // FIXME: emit debug info for labels, incrementProfileCounter
759 return mlir::success();
760}
761
762mlir::LogicalResult CIRGenFunction::emitBreakStmt(const clang::BreakStmt &s) {
763 builder.createBreak(getLoc(s.getKwLoc()));
764
765 // Insert the new block to continue codegen after the break statement.
766 builder.createBlock(builder.getBlock()->getParent());
767
768 return mlir::success();
769}
770
771template <typename T>
772mlir::LogicalResult
774 mlir::ArrayAttr value, CaseOpKind kind,
775 bool buildingTopLevelCase) {
776
778 "only case or default stmt go here");
779
780 mlir::LogicalResult result = mlir::success();
781
782 mlir::Location loc = getLoc(stmt->getBeginLoc());
783
784 enum class SubStmtKind { Case, Default, Other };
785 SubStmtKind subStmtKind = SubStmtKind::Other;
786 const Stmt *sub = stmt->getSubStmt();
787
788 mlir::OpBuilder::InsertPoint insertPoint;
789 CaseOp::create(builder, loc, value, kind, insertPoint);
790
791 {
792 mlir::OpBuilder::InsertionGuard guardSwitch(builder);
793 builder.restoreInsertionPoint(insertPoint);
794
795 if (isa<DefaultStmt>(sub) && isa<CaseStmt>(stmt)) {
796 subStmtKind = SubStmtKind::Default;
797 builder.createYield(loc);
798 } else if (isa<CaseStmt>(sub) && isa<DefaultStmt, CaseStmt>(stmt)) {
799 subStmtKind = SubStmtKind::Case;
800 builder.createYield(loc);
801 } else {
802 result = emitStmt(sub, /*useCurrentScope=*/!isa<CompoundStmt>(sub));
803 }
804
805 insertPoint = builder.saveInsertionPoint();
806 }
807
808 // If the substmt is default stmt or case stmt, try to handle the special case
809 // to make it into the simple form. e.g.
810 //
811 // switch () {
812 // case 1:
813 // default:
814 // ...
815 // }
816 //
817 // we prefer generating
818 //
819 // cir.switch() {
820 // cir.case(equal, 1) {
821 // cir.yield
822 // }
823 // cir.case(default) {
824 // ...
825 // }
826 // }
827 //
828 // than
829 //
830 // cir.switch() {
831 // cir.case(equal, 1) {
832 // cir.case(default) {
833 // ...
834 // }
835 // }
836 // }
837 //
838 // We don't need to revert this if we find the current switch can't be in
839 // simple form later since the conversion itself should be harmless.
840 if (subStmtKind == SubStmtKind::Case) {
841 result = emitCaseStmt(*cast<CaseStmt>(sub), condType, buildingTopLevelCase);
842 } else if (subStmtKind == SubStmtKind::Default) {
843 result = emitDefaultStmt(*cast<DefaultStmt>(sub), condType,
844 buildingTopLevelCase);
845 } else if (buildingTopLevelCase) {
846 // If we're building a top level case, try to restore the insert point to
847 // the case we're building, then we can attach more random stmts to the
848 // case to make generating `cir.switch` operation to be a simple form.
849 builder.restoreInsertionPoint(insertPoint);
850 }
851
852 return result;
853}
854
855mlir::LogicalResult CIRGenFunction::emitCaseStmt(const CaseStmt &s,
856 mlir::Type condType,
857 bool buildingTopLevelCase) {
858 cir::CaseOpKind kind;
859 mlir::ArrayAttr value;
860 llvm::APSInt intVal = s.getLHS()->EvaluateKnownConstInt(getContext());
861
862 // If the case statement has an RHS value, it is representing a GNU
863 // case range statement, where LHS is the beginning of the range
864 // and RHS is the end of the range.
865 if (const Expr *rhs = s.getRHS()) {
866 llvm::APSInt endVal = rhs->EvaluateKnownConstInt(getContext());
867 value = builder.getArrayAttr({cir::IntAttr::get(condType, intVal),
868 cir::IntAttr::get(condType, endVal)});
869 kind = cir::CaseOpKind::Range;
870 } else {
871 value = builder.getArrayAttr({cir::IntAttr::get(condType, intVal)});
872 kind = cir::CaseOpKind::Equal;
873 }
874
875 return emitCaseDefaultCascade(&s, condType, value, kind,
876 buildingTopLevelCase);
877}
878
880 mlir::Type condType,
881 bool buildingTopLevelCase) {
882 return emitCaseDefaultCascade(&s, condType, builder.getArrayAttr({}),
883 cir::CaseOpKind::Default, buildingTopLevelCase);
884}
885
886mlir::LogicalResult CIRGenFunction::emitSwitchCase(const SwitchCase &s,
887 bool buildingTopLevelCase) {
888 assert(!condTypeStack.empty() &&
889 "build switch case without specifying the type of the condition");
890
891 if (s.getStmtClass() == Stmt::CaseStmtClass)
892 return emitCaseStmt(cast<CaseStmt>(s), condTypeStack.back(),
893 buildingTopLevelCase);
894
895 if (s.getStmtClass() == Stmt::DefaultStmtClass)
897 buildingTopLevelCase);
898
899 llvm_unreachable("expect case or default stmt");
900}
901
902mlir::LogicalResult
904 ArrayRef<const Attr *> forAttrs) {
905 cir::ForOp forOp;
906
907 // TODO(cir): pass in array of attributes.
908 auto forStmtBuilder = [&]() -> mlir::LogicalResult {
909 mlir::LogicalResult loopRes = mlir::success();
910 // Evaluate the first pieces before the loop.
911 if (s.getInit())
912 if (emitStmt(s.getInit(), /*useCurrentScope=*/true).failed())
913 return mlir::failure();
914 if (emitStmt(s.getRangeStmt(), /*useCurrentScope=*/true).failed())
915 return mlir::failure();
916 if (emitStmt(s.getBeginStmt(), /*useCurrentScope=*/true).failed())
917 return mlir::failure();
918 if (emitStmt(s.getEndStmt(), /*useCurrentScope=*/true).failed())
919 return mlir::failure();
920
922
923 forOp = builder.createFor(
925 /*condBuilder=*/
926 [&](mlir::OpBuilder &b, mlir::Location loc) {
927 assert(!cir::MissingFeatures::createProfileWeightsForLoop());
928 assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
929 mlir::Value condVal = evaluateExprAsBool(s.getCond());
930 builder.createCondition(condVal);
931 },
932 /*bodyBuilder=*/
933 [&](mlir::OpBuilder &b, mlir::Location loc) {
934 // https://en.cppreference.com/w/cpp/language/for
935 // In C++ the scope of the init-statement and the scope of
936 // statement are one and the same.
937 RunCleanupsScope bodyScope(*this);
938 bool useCurrentScope = true;
939 if (emitStmt(s.getLoopVarStmt(), useCurrentScope).failed())
940 loopRes = mlir::failure();
941 if (emitStmt(s.getBody(), useCurrentScope).failed())
942 loopRes = mlir::failure();
943 emitStopPoint(&s);
944 },
945 /*stepBuilder=*/
946 [&](mlir::OpBuilder &b, mlir::Location loc) {
947 if (s.getInc())
948 if (emitStmt(s.getInc(), /*useCurrentScope=*/true).failed())
949 loopRes = mlir::failure();
950 builder.createYield(loc);
951 });
952 return loopRes;
953 };
954
955 mlir::LogicalResult res = mlir::success();
956 mlir::Location scopeLoc = getLoc(s.getSourceRange());
957 cir::ScopeOp::create(builder, scopeLoc, /*scopeBuilder=*/
958 [&](mlir::OpBuilder &b, mlir::Location loc) {
959 // Create a cleanup scope for the condition
960 // variable cleanups. Logical equivalent from
961 // LLVM codegn for LexicalScope
962 // ConditionScope(*this, S.getSourceRange())...
963 LexicalScope lexScope{*this, loc,
964 builder.getInsertionBlock()};
965 res = forStmtBuilder();
966 });
967
968 if (res.failed())
969 return res;
970
971 terminateStructuredRegionBody(forOp.getBody(), getLoc(s.getEndLoc()));
972 return mlir::success();
973}
974
975mlir::LogicalResult CIRGenFunction::emitForStmt(const ForStmt &s) {
976 cir::ForOp forOp;
977
978 // TODO: pass in an array of attributes.
979 auto forStmtBuilder = [&]() -> mlir::LogicalResult {
980 mlir::LogicalResult loopRes = mlir::success();
981 // Evaluate the first part before the loop.
982 if (s.getInit())
983 if (emitStmt(s.getInit(), /*useCurrentScope=*/true).failed())
984 return mlir::failure();
986
987 // If the condition variable has a non-trivial destructor, its lifetime is
988 // a single iteration, so capture its cleanup and emit it into the loop's
989 // per-iteration cleanup region. This scope is constructed after the
990 // init-statement so its cleanups are not captured.
991 const VarDecl *condVar = s.getConditionVariable();
992 bool needsCondCleanup =
993 condVar && condVar->needsDestruction(getContext()) != QualType::DK_none;
994 // We will also need cleanup if lifetime markers are enabled.
996 DeferredLoopConditionCleanup loopCondScope(*this, needsCondCleanup);
997
998 auto condBuilder = [&](mlir::OpBuilder &b, mlir::Location loc) {
1001 mlir::Value condVal;
1002 if (s.getCond()) {
1003 // If the for statement declares a condition variable, emit that here.
1004 if (condVar)
1005 emitLoopConditionVariable(*condVar, loopCondScope);
1006 // C99 6.8.5p2/p4: The first substatement is executed if the
1007 // expression compares unequal to 0. The condition must be a
1008 // scalar type.
1009 condVal = evaluateExprAsBool(s.getCond());
1010 } else {
1011 condVal = cir::ConstantOp::create(b, loc, builder.getTrueAttr());
1012 }
1013 builder.createCondition(condVal);
1014 };
1015 auto bodyBuilder = [&](mlir::OpBuilder &b, mlir::Location loc) {
1016 // The scope of the for loop body is nested within the scope of the
1017 // for loop's init-statement and condition.
1018 RunCleanupsScope bodyScope(*this);
1019 if (emitStmt(s.getBody(), /*useCurrentScope=*/false).failed())
1020 loopRes = mlir::failure();
1021 emitStopPoint(&s);
1022 };
1023 auto stepBuilder = [&](mlir::OpBuilder &b, mlir::Location loc) {
1024 if (s.getInc())
1025 if (emitStmt(s.getInc(), /*useCurrentScope=*/true).failed())
1026 loopRes = mlir::failure();
1027 builder.createYield(loc);
1028 };
1029
1030 if (needsCondCleanup) {
1031 cir::CleanupKind cleanupKind = getLangOpts().Exceptions
1032 ? cir::CleanupKind::All
1033 : cir::CleanupKind::Normal;
1034 forOp = builder.createFor(
1035 getLoc(s.getSourceRange()), condBuilder, bodyBuilder, stepBuilder,
1036 /*cleanupBuilder=*/
1037 [&](mlir::OpBuilder &b, mlir::Location loc) {
1038 loopCondScope.emitIntoLoopCleanupRegion(loc);
1039 builder.createYield(loc);
1040 },
1041 cleanupKind);
1042 } else {
1043 forOp = builder.createFor(getLoc(s.getSourceRange()), condBuilder,
1044 bodyBuilder, stepBuilder);
1045 }
1046 return loopRes;
1047 };
1048
1049 auto res = mlir::success();
1050 auto scopeLoc = getLoc(s.getSourceRange());
1051 cir::ScopeOp::create(builder, scopeLoc, /*scopeBuilder=*/
1052 [&](mlir::OpBuilder &b, mlir::Location loc) {
1053 LexicalScope lexScope{*this, loc,
1054 builder.getInsertionBlock()};
1055 res = forStmtBuilder();
1056 });
1057
1058 if (res.failed())
1059 return res;
1060
1061 terminateStructuredRegionBody(forOp.getBody(), getLoc(s.getEndLoc()));
1062 return mlir::success();
1063}
1064
1065mlir::LogicalResult CIRGenFunction::emitDoStmt(const DoStmt &s) {
1066 cir::DoWhileOp doWhileOp;
1067
1068 // TODO: pass in array of attributes.
1069 auto doStmtBuilder = [&]() -> mlir::LogicalResult {
1070 mlir::LogicalResult loopRes = mlir::success();
1072
1073 doWhileOp = builder.createDoWhile(
1075 /*condBuilder=*/
1076 [&](mlir::OpBuilder &b, mlir::Location loc) {
1077 assert(!cir::MissingFeatures::createProfileWeightsForLoop());
1078 assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
1079 // C99 6.8.5p2/p4: The first substatement is executed if the
1080 // expression compares unequal to 0. The condition must be a
1081 // scalar type.
1082 mlir::Value condVal = evaluateExprAsBool(s.getCond());
1083 builder.createCondition(condVal);
1084 },
1085 /*bodyBuilder=*/
1086 [&](mlir::OpBuilder &b, mlir::Location loc) {
1087 // The scope of the do-while loop body is a nested scope.
1088 RunCleanupsScope bodyScope(*this);
1089 if (emitStmt(s.getBody(), /*useCurrentScope=*/false).failed())
1090 loopRes = mlir::failure();
1091 emitStopPoint(&s);
1092 });
1093 return loopRes;
1094 };
1095
1096 mlir::LogicalResult res = mlir::success();
1097 mlir::Location scopeLoc = getLoc(s.getSourceRange());
1098 cir::ScopeOp::create(builder, scopeLoc, /*scopeBuilder=*/
1099 [&](mlir::OpBuilder &b, mlir::Location loc) {
1100 LexicalScope lexScope{*this, loc,
1101 builder.getInsertionBlock()};
1102 res = doStmtBuilder();
1103 });
1104
1105 if (res.failed())
1106 return res;
1107
1108 terminateStructuredRegionBody(doWhileOp.getBody(), getLoc(s.getEndLoc()));
1109 return mlir::success();
1110}
1111
1112mlir::LogicalResult CIRGenFunction::emitWhileStmt(const WhileStmt &s) {
1113 cir::WhileOp whileOp;
1114
1115 // TODO: pass in array of attributes.
1116 auto whileStmtBuilder = [&]() -> mlir::LogicalResult {
1117 mlir::LogicalResult loopRes = mlir::success();
1119
1120 // If the condition variable has a non-trivial destructor, its lifetime is
1121 // a single iteration, so capture its cleanup and emit it into the loop's
1122 // per-iteration cleanup region.
1123 const VarDecl *condVar = s.getConditionVariable();
1124 bool needsCondCleanup =
1125 condVar && condVar->needsDestruction(getContext()) != QualType::DK_none;
1126 // We will also need cleanup if lifetime markers are enabled.
1128 DeferredLoopConditionCleanup loopCondScope(*this, needsCondCleanup);
1129
1130 auto condBuilder = [&](mlir::OpBuilder &b, mlir::Location loc) {
1133 // If the while statement declares a condition variable, emit that here.
1134 if (condVar)
1135 emitLoopConditionVariable(*condVar, loopCondScope);
1136 // C99 6.8.5p2/p4: The first substatement is executed if the
1137 // expression compares unequal to 0. The condition must be a
1138 // scalar type.
1139 mlir::Value condVal = evaluateExprAsBool(s.getCond());
1140 builder.createCondition(condVal);
1141 };
1142 auto bodyBuilder = [&](mlir::OpBuilder &b, mlir::Location loc) {
1143 // The scope of the while loop body is a nested scope.
1144 RunCleanupsScope bodyScope(*this);
1145 if (emitStmt(s.getBody(), /*useCurrentScope=*/false).failed())
1146 loopRes = mlir::failure();
1147 emitStopPoint(&s);
1148 };
1149
1150 if (needsCondCleanup) {
1151 cir::CleanupKind cleanupKind = getLangOpts().Exceptions
1152 ? cir::CleanupKind::All
1153 : cir::CleanupKind::Normal;
1154 whileOp = builder.createWhile(
1155 getLoc(s.getSourceRange()), condBuilder, bodyBuilder,
1156 /*cleanupBuilder=*/
1157 [&](mlir::OpBuilder &b, mlir::Location loc) {
1158 loopCondScope.emitIntoLoopCleanupRegion(loc);
1159 builder.createYield(loc);
1160 },
1161 cleanupKind);
1162 } else {
1163 whileOp = builder.createWhile(getLoc(s.getSourceRange()), condBuilder,
1164 bodyBuilder);
1165 }
1166 return loopRes;
1167 };
1168
1169 mlir::LogicalResult res = mlir::success();
1170 mlir::Location scopeLoc = getLoc(s.getSourceRange());
1171 cir::ScopeOp::create(builder, scopeLoc, /*scopeBuilder=*/
1172 [&](mlir::OpBuilder &b, mlir::Location loc) {
1173 LexicalScope lexScope{*this, loc,
1174 builder.getInsertionBlock()};
1175 res = whileStmtBuilder();
1176 });
1177
1178 if (res.failed())
1179 return res;
1180
1181 terminateStructuredRegionBody(whileOp.getBody(), getLoc(s.getEndLoc()));
1182 return mlir::success();
1183}
1184
1185mlir::LogicalResult CIRGenFunction::emitSwitchBody(const Stmt *s) {
1186 // It is rare but legal if the switch body is not a compound stmt. e.g.,
1187 //
1188 // switch(a)
1189 // while(...) {
1190 // case1
1191 // ...
1192 // case2
1193 // ...
1194 // }
1195 if (!isa<CompoundStmt>(s))
1196 return emitStmt(s, /*useCurrentScope=*/true);
1197
1199
1200 ArrayRef<Stmt *> body{compoundStmt->body_begin(), compoundStmt->body_end()};
1201
1202 mlir::Block *switchBlock = builder.getBlock();
1203
1204 // Any statements appearing before the first case statement are 'unassociated'
1205 // with anything. So we have to create them FIRST in their own block. After
1206 // that, the 'case' regions will take care of future ones.
1207 if (!body.empty() && !isa<SwitchCase>(body.front())) {
1208 builder.setInsertionPointToEnd(switchBlock);
1209 {
1210 // This is needed to handle cleanups in a compound statement before the
1211 // first case statement.
1212 RunCleanupsScope preCaseScope(*this);
1213 while (!body.empty() && !isa<SwitchCase>(body.front())) {
1214
1215 auto *c = body.front();
1216 if (mlir::failed(
1217 emitStmt(c, /*useCurrentScope=*/!isa<CompoundStmt>(c))))
1218 return mlir::failure();
1219
1220 body = body.drop_front();
1221 }
1222 }
1223
1224 // Now that we've emitted ALL of the statements, we can create a new block
1225 // for the actual case statements/etc to appear.
1226 mlir::Block *lastBlock = builder.getBlock();
1227 switchBlock = builder.createBlock(switchBlock->getParent());
1228 builder.setInsertionPointToEnd(lastBlock);
1229 cir::BrOp::create(builder, getLoc(s->getSourceRange()), switchBlock);
1230 }
1231
1232 for (auto *c : body) {
1233 if (auto *switchCase = dyn_cast<SwitchCase>(c)) {
1234 builder.setInsertionPointToEnd(switchBlock);
1235 // Reset insert point automatically, so that we can attach following
1236 // random stmt to the region of previous built case op to try to make
1237 // the being generated `cir.switch` to be in simple form.
1238 if (mlir::failed(
1239 emitSwitchCase(*switchCase, /*buildingTopLevelCase=*/true)))
1240 return mlir::failure();
1241
1242 continue;
1243 }
1244
1245 // Otherwise, just build the statements in the nearest case region.
1246 if (mlir::failed(emitStmt(c, /*useCurrentScope=*/!isa<CompoundStmt>(c))))
1247 return mlir::failure();
1248 }
1249
1250 return mlir::success();
1251}
1252
1254 // TODO: LLVM codegen does some early optimization to fold the condition and
1255 // only emit live cases. CIR should use MLIR to achieve similar things,
1256 // nothing to be done here.
1257 // if (ConstantFoldsToSimpleInteger(S.getCond(), ConstantCondValue))...
1259
1260 SwitchOp swop;
1261 auto switchStmtBuilder = [&]() -> mlir::LogicalResult {
1262 if (s.getInit())
1263 if (emitStmt(s.getInit(), /*useCurrentScope=*/true).failed())
1264 return mlir::failure();
1265
1266 if (s.getConditionVariable())
1267 emitDecl(*s.getConditionVariable(), /*evaluateConditionDecl=*/true);
1268
1269 mlir::Value condV = emitScalarExpr(s.getCond());
1270
1271 // TODO: PGO and likelihood (e.g. PGO.haveRegionCounts())
1274 // TODO: if the switch has a condition wrapped by __builtin_unpredictable?
1276
1277 mlir::LogicalResult res = mlir::success();
1278 swop = SwitchOp::create(
1279 builder, getLoc(s.getBeginLoc()), condV,
1280 /*switchBuilder=*/
1281 [&](mlir::OpBuilder &b, mlir::Location loc, mlir::OperationState &os) {
1282 curLexScope->setAsSwitch();
1283
1284 condTypeStack.push_back(condV.getType());
1285
1286 res = emitSwitchBody(s.getBody());
1287
1288 condTypeStack.pop_back();
1289 });
1290
1291 return res;
1292 };
1293
1294 // The switch scope contains the full source range for SwitchStmt.
1295 mlir::Location scopeLoc = getLoc(s.getSourceRange());
1296 mlir::LogicalResult res = mlir::success();
1297 cir::ScopeOp::create(builder, scopeLoc, /*scopeBuilder=*/
1298 [&](mlir::OpBuilder &b, mlir::Location loc) {
1299 LexicalScope lexScope{*this, loc,
1300 builder.getInsertionBlock()};
1301 res = switchStmtBuilder();
1302 });
1303
1305 swop.collectCases(cases);
1306 for (auto caseOp : cases)
1307 terminateStructuredRegionBody(caseOp.getCaseRegion(), caseOp.getLoc());
1308 terminateStructuredRegionBody(swop.getBody(), swop.getLoc());
1309
1310 swop.setAllEnumCasesCovered(s.isAllEnumCasesCovered());
1311
1312 return res;
1313}
1314
1315void CIRGenFunction::emitReturnOfRValue(mlir::Location loc, RValue rv,
1316 QualType ty) {
1317 if (rv.isScalar()) {
1318 builder.createStore(loc, rv.getValue(), returnValue);
1319 } else if (rv.isAggregate()) {
1320 Address rvAddr = rv.getAggregateAddress();
1321 // If the aggregate is already in the return slot (e.g. a callee was
1322 // invoked through a ReturnValueSlot bound to returnValue), the copy is
1323 // a no-op. Calling emitAggregateCopy here would also incorrectly
1324 // require the type to have a trivial copy/move.
1325 if (rvAddr.getPointer() != returnValue.getPointer()) {
1326 LValue dest = makeAddrLValue(returnValue, ty);
1327 LValue src = makeAddrLValue(rvAddr, ty);
1329 }
1330 } else {
1331 cgm.errorNYI(loc, "emitReturnOfRValue: complex return type");
1332 }
1333
1334 // Classic codegen emits a branch through any cleanups before continuing to
1335 // a shared return block. Because CIR handles branching through cleanups
1336 // during the CFG flattening phase, we can just emit the return statement
1337 // directly.
1338 // TODO(cir): Eliminate this redundant load and the store above when we can.
1339 // Load the value from `__retval` and return it via the `cir.return` op.
1340 cir::AllocaOp retAlloca =
1341 mlir::cast<cir::AllocaOp>(fnRetAlloca->getDefiningOp());
1342 auto value = cir::LoadOp::create(builder, loc, retAlloca.getAllocaType(),
1343 *fnRetAlloca);
1344
1345 cir::ReturnOp::create(builder, loc, {value});
1346}
static mlir::LogicalResult emitStmtWithResult(CIRGenFunction &cgf, const Stmt *exprResult, AggValueSlot slot, Address *lastValue)
Defines the clang::Expr interface and subclasses for C++ expressions.
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a kind
This file defines OpenACC AST classes for statement-level contructs.
This file defines OpenMP AST classes for executable directives and clauses.
Attr - This represents one attribute.
Definition Attr.h:46
Represents an attribute applied to a statement.
Definition Stmt.h:2212
Stmt * getSubStmt()
Definition Stmt.h:2248
ArrayRef< const Attr * > getAttrs() const
Definition Stmt.h:2244
BreakStmt - This represents a break.
Definition Stmt.h:3144
mlir::Value getPointer() const
Definition Address.h:98
An aggregate value slot.
static AggValueSlot forAddr(Address addr, clang::Qualifiers quals, IsDestructed_t isDestructed, IsAliased_t isAliased, Overlap_t mayOverlap, IsZeroed_t isZeroed=IsNotZeroed)
Captures the destructor cleanup for a loop's condition variable so that it can be emitted into the lo...
Enters a new scope for capturing cleanups, all of which will be executed once the scope is exited.
void forceCleanup(ArrayRef< mlir::Value * > valuesToReload={})
Force the emission of cleanups now, instead of waiting until this object is destroyed.
mlir::LogicalResult emitOMPTargetParallelForDirective(const OMPTargetParallelForDirective &s)
mlir::LogicalResult emitOMPParallelMasterTaskLoopSimdDirective(const OMPParallelMasterTaskLoopSimdDirective &s)
mlir::LogicalResult emitOMPSimdDirective(const OMPSimdDirective &s)
mlir::Value emitCheckedArgForAssume(const Expr *e)
Emits an argument for a call to a __builtin_assume.
mlir::LogicalResult emitDoStmt(const clang::DoStmt &s)
mlir::LogicalResult emitOMPCriticalDirective(const OMPCriticalDirective &s)
static cir::TypeEvaluationKind getEvaluationKind(clang::QualType type)
Return the cir::TypeEvaluationKind of QualType type.
clang::GlobalDecl curGD
The GlobalDecl for the current function being compiled or the global variable currently being initial...
mlir::LogicalResult emitCoreturnStmt(const CoreturnStmt &s)
mlir::LogicalResult emitOpenACCDataConstruct(const OpenACCDataConstruct &s)
mlir::LogicalResult emitOpenACCCombinedConstruct(const OpenACCCombinedConstruct &s)
mlir::LogicalResult emitOMPParallelMasterDirective(const OMPParallelMasterDirective &s)
mlir::LogicalResult emitOpenACCWaitConstruct(const OpenACCWaitConstruct &s)
mlir::LogicalResult emitOMPCancellationPointDirective(const OMPCancellationPointDirective &s)
mlir::LogicalResult emitOMPParallelMaskedTaskLoopDirective(const OMPParallelMaskedTaskLoopDirective &s)
mlir::LogicalResult emitOMPReverseDirective(const OMPReverseDirective &s)
const clang::LangOptions & getLangOpts() const
mlir::LogicalResult emitOpenACCUpdateConstruct(const OpenACCUpdateConstruct &s)
mlir::LogicalResult emitOMPTileDirective(const OMPTileDirective &s)
mlir::LogicalResult emitIfOnBoolExpr(const clang::Expr *cond, const clang::Stmt *thenS, const clang::Stmt *elseS)
Emit an if on a boolean condition to the specified blocks.
mlir::LogicalResult emitOMPTargetTeamsDirective(const OMPTargetTeamsDirective &s)
mlir::LogicalResult emitOMPTeamsDistributeParallelForDirective(const OMPTeamsDistributeParallelForDirective &s)
mlir::LogicalResult emitOMPBarrierDirective(const OMPBarrierDirective &s)
mlir::LogicalResult emitOMPTargetParallelDirective(const OMPTargetParallelDirective &s)
mlir::LogicalResult emitOpenACCCacheConstruct(const OpenACCCacheConstruct &s)
mlir::LogicalResult emitOMPTargetDirective(const OMPTargetDirective &s)
mlir::LogicalResult emitCXXForRangeStmt(const CXXForRangeStmt &s, llvm::ArrayRef< const Attr * > attrs)
mlir::Value evaluateExprAsBool(const clang::Expr *e)
Perform the usual unary conversions on the specified expression and compare the result against zero,...
void emitAggregateCopy(LValue dest, LValue src, QualType eltTy, AggValueSlot::Overlap_t mayOverlap, bool isVolatile=false)
Emit an aggregate copy.
mlir::LogicalResult emitOMPScopeDirective(const OMPScopeDirective &s)
mlir::Location getLoc(clang::SourceLocation srcLoc)
Helpers to convert Clang's SourceLocation to a MLIR Location.
mlir::LogicalResult emitOMPDepobjDirective(const OMPDepobjDirective &s)
bool constantFoldsToBool(const clang::Expr *cond, bool &resultBool, bool allowLabels=false)
If the specified expression does not fold to a constant, or if it does but contains a label,...
void emitLoopConditionVariable(const clang::VarDecl &d, DeferredLoopConditionCleanup &condCleanup)
Emit a loop's condition-variable declaration.
mlir::LogicalResult emitReturnStmt(const clang::ReturnStmt &s)
mlir::LogicalResult emitOpenACCInitConstruct(const OpenACCInitConstruct &s)
void emitAnyExprToMem(const Expr *e, Address location, Qualifiers quals, bool isInitializer)
Emits the code necessary to evaluate an arbitrary expression into the given memory location.
mlir::LogicalResult emitOMPDistributeParallelForSimdDirective(const OMPDistributeParallelForSimdDirective &s)
mlir::LogicalResult emitOMPUnrollDirective(const OMPUnrollDirective &s)
mlir::LogicalResult emitOMPTaskDirective(const OMPTaskDirective &s)
mlir::LogicalResult emitOpenACCSetConstruct(const OpenACCSetConstruct &s)
RValue emitReferenceBindingToExpr(const Expr *e)
Emits a reference binding to the passed in expression.
mlir::LogicalResult emitOMPTeamsGenericLoopDirective(const OMPTeamsGenericLoopDirective &s)
mlir::LogicalResult emitOMPCanonicalLoop(const OMPCanonicalLoop &s)
mlir::LogicalResult emitSwitchStmt(const clang::SwitchStmt &s)
mlir::LogicalResult emitOMPTeamsDirective(const OMPTeamsDirective &s)
mlir::LogicalResult emitCaseStmt(const clang::CaseStmt &s, mlir::Type condType, bool buildingTopLevelCase)
llvm::ScopedHashTableScope< const clang::Decl *, mlir::Value > SymTableScopeTy
mlir::LogicalResult emitOMPMaskedTaskLoopDirective(const OMPMaskedTaskLoopDirective &s)
mlir::LogicalResult emitOMPFuseDirective(const OMPFuseDirective &s)
mlir::LogicalResult emitSimpleStmt(const clang::Stmt *s, bool useCurrentScope)
mlir::LogicalResult emitOMPSectionDirective(const OMPSectionDirective &s)
mlir::Block * indirectGotoBlock
IndirectBranch - The first time an indirect goto is seen we create a block reserved for the indirect ...
mlir::Operation * curFn
The current function or global initializer that is generated code for.
mlir::LogicalResult emitAsmStmt(const clang::AsmStmt &s)
mlir::LogicalResult emitOMPParallelForSimdDirective(const OMPParallelForSimdDirective &s)
mlir::LogicalResult emitOMPDistributeParallelForDirective(const OMPDistributeParallelForDirective &s)
mlir::LogicalResult emitOpenACCComputeConstruct(const OpenACCComputeConstruct &s)
mlir::LogicalResult emitOMPMasterTaskLoopSimdDirective(const OMPMasterTaskLoopSimdDirective &s)
mlir::LogicalResult emitSwitchBody(const clang::Stmt *s)
mlir::LogicalResult emitForStmt(const clang::ForStmt &s)
mlir::LogicalResult emitOMPTaskwaitDirective(const OMPTaskwaitDirective &s)
mlir::LogicalResult emitOMPFlushDirective(const OMPFlushDirective &s)
mlir::LogicalResult emitOMPGenericLoopDirective(const OMPGenericLoopDirective &s)
mlir::LogicalResult emitOMPTargetUpdateDirective(const OMPTargetUpdateDirective &s)
std::optional< mlir::Value > fnRetAlloca
The compiler-generated variable that holds the return value.
mlir::LogicalResult emitOMPOrderedDirective(const OMPOrderedDirective &s)
mlir::LogicalResult emitOMPTargetParallelForSimdDirective(const OMPTargetParallelForSimdDirective &s)
mlir::LogicalResult emitOMPInterchangeDirective(const OMPInterchangeDirective &s)
mlir::LogicalResult emitOMPDispatchDirective(const OMPDispatchDirective &s)
mlir::LogicalResult emitCXXTryStmt(const clang::CXXTryStmt &s, cxxTryBodyEmitter &bodyCallback)
mlir::LogicalResult emitOMPParallelDirective(const OMPParallelDirective &s)
mlir::LogicalResult emitAttributedStmt(const AttributedStmt &s)
mlir::LogicalResult emitOMPForSimdDirective(const OMPForSimdDirective &s)
mlir::LogicalResult emitOMPTaskLoopDirective(const OMPTaskLoopDirective &s)
Address returnValue
The temporary alloca to hold the return value.
mlir::LogicalResult emitOMPTargetDataDirective(const OMPTargetDataDirective &s)
mlir::LogicalResult emitLabel(const clang::LabelDecl &d)
mlir::LogicalResult emitOMPTargetParallelGenericLoopDirective(const OMPTargetParallelGenericLoopDirective &s)
static bool hasAggregateEvaluationKind(clang::QualType type)
mlir::LogicalResult emitOMPParallelMaskedDirective(const OMPParallelMaskedDirective &s)
mlir::LogicalResult emitOMPMaskedTaskLoopSimdDirective(const OMPMaskedTaskLoopSimdDirective &s)
mlir::LogicalResult emitOMPAtomicDirective(const OMPAtomicDirective &s)
mlir::LogicalResult emitOpenACCShutdownConstruct(const OpenACCShutdownConstruct &s)
mlir::LogicalResult emitBreakStmt(const clang::BreakStmt &s)
mlir::LogicalResult emitIndirectGotoStmt(const IndirectGotoStmt &s)
mlir::LogicalResult emitOMPTeamsDistributeParallelForSimdDirective(const OMPTeamsDistributeParallelForSimdDirective &s)
mlir::LogicalResult emitOMPTaskgroupDirective(const OMPTaskgroupDirective &s)
mlir::LogicalResult emitOMPParallelMaskedTaskLoopSimdDirective(const OMPParallelMaskedTaskLoopSimdDirective &s)
mlir::LogicalResult emitOMPTeamsDistributeDirective(const OMPTeamsDistributeDirective &s)
void emitReturnOfRValue(mlir::Location loc, RValue rv, QualType ty)
mlir::LogicalResult emitOMPInteropDirective(const OMPInteropDirective &s)
mlir::LogicalResult emitOMPErrorDirective(const OMPErrorDirective &s)
mlir::LogicalResult emitOMPSingleDirective(const OMPSingleDirective &s)
mlir::LogicalResult emitContinueStmt(const clang::ContinueStmt &s)
mlir::LogicalResult emitOMPTaskyieldDirective(const OMPTaskyieldDirective &s)
mlir::LogicalResult emitOMPTargetTeamsDistributeSimdDirective(const OMPTargetTeamsDistributeSimdDirective &s)
mlir::LogicalResult emitOMPScanDirective(const OMPScanDirective &s)
llvm::SmallVector< mlir::Type, 2 > condTypeStack
The type of the condition for the emitting switch statement.
mlir::LogicalResult emitOMPTargetEnterDataDirective(const OMPTargetEnterDataDirective &s)
void emitStopPoint(const Stmt *s)
Build a debug stoppoint if we are emitting debug info.
mlir::LogicalResult emitOMPMasterTaskLoopDirective(const OMPMasterTaskLoopDirective &s)
mlir::LogicalResult emitOpenACCHostDataConstruct(const OpenACCHostDataConstruct &s)
mlir::Value emitScalarExpr(const clang::Expr *e, bool ignoreResultAssign=false)
Emit the computation of the specified expression of scalar type.
mlir::LogicalResult emitIfStmt(const clang::IfStmt &s)
mlir::LogicalResult emitOMPForDirective(const OMPForDirective &s)
mlir::LogicalResult emitOMPMasterDirective(const OMPMasterDirective &s)
AggValueSlot::Overlap_t getOverlapForReturnValue()
Determine whether a return value slot may overlap some other object.
mlir::LogicalResult emitSwitchCase(const clang::SwitchCase &s, bool buildingTopLevelCase)
mlir::LogicalResult emitOMPMetaDirective(const OMPMetaDirective &s)
mlir::LogicalResult emitOMPDistributeSimdDirective(const OMPDistributeSimdDirective &s)
void emitDecl(const clang::Decl &d, bool evaluateConditionDecl=false)
mlir::LogicalResult emitOMPParallelGenericLoopDirective(const OMPParallelGenericLoopDirective &s)
mlir::LogicalResult emitOMPMaskedDirective(const OMPMaskedDirective &s)
mlir::LogicalResult emitOMPSplitDirective(const OMPSplitDirective &s)
llvm::DenseMap< const VarDecl *, mlir::Value > nrvoFlags
A mapping from NRVO variables to the flags used to indicate when the NRVO has been applied to this va...
mlir::LogicalResult emitOpenACCEnterDataConstruct(const OpenACCEnterDataConstruct &s)
mlir::LogicalResult emitOMPTargetExitDataDirective(const OMPTargetExitDataDirective &s)
mlir::LogicalResult emitOMPTargetTeamsDistributeParallelForDirective(const OMPTargetTeamsDistributeParallelForDirective &s)
void emitComplexExprIntoLValue(const Expr *e, LValue dest, bool isInit)
mlir::LogicalResult emitOMPParallelForDirective(const OMPParallelForDirective &s)
mlir::LogicalResult emitCaseDefaultCascade(const T *stmt, mlir::Type condType, mlir::ArrayAttr value, cir::CaseOpKind kind, bool buildingTopLevelCase)
mlir::LogicalResult emitOMPSectionsDirective(const OMPSectionsDirective &s)
LValue makeAddrLValue(Address addr, QualType ty, AlignmentSource source=AlignmentSource::Type)
mlir::LogicalResult emitOMPDistributeDirective(const OMPDistributeDirective &s)
RValue emitAnyExpr(const clang::Expr *e, AggValueSlot aggSlot=AggValueSlot::ignored(), bool ignoreResult=false)
Emit code to compute the specified expression which can have any type.
mlir::LogicalResult emitOMPTargetTeamsDistributeParallelForSimdDirective(const OMPTargetTeamsDistributeParallelForSimdDirective &s)
mlir::LogicalResult emitOMPTargetTeamsGenericLoopDirective(const OMPTargetTeamsGenericLoopDirective &s)
mlir::LogicalResult emitDeclStmt(const clang::DeclStmt &s)
mlir::LogicalResult emitOMPTeamsDistributeSimdDirective(const OMPTeamsDistributeSimdDirective &s)
mlir::LogicalResult emitDefaultStmt(const clang::DefaultStmt &s, mlir::Type condType, bool buildingTopLevelCase)
mlir::LogicalResult emitWhileStmt(const clang::WhileStmt &s)
mlir::LogicalResult emitLabelStmt(const clang::LabelStmt &s)
mlir::LogicalResult emitOMPTaskLoopSimdDirective(const OMPTaskLoopSimdDirective &s)
void terminateStructuredRegionBody(mlir::Region &r, mlir::Location loc)
clang::ASTContext & getContext() const
mlir::LogicalResult emitCoroutineBody(const CoroutineBodyStmt &s)
mlir::LogicalResult emitCompoundStmt(const clang::CompoundStmt &s, Address *lastValue=nullptr, AggValueSlot slot=AggValueSlot::ignored())
mlir::LogicalResult emitGotoStmt(const clang::GotoStmt &s)
mlir::LogicalResult emitOMPParallelMasterTaskLoopDirective(const OMPParallelMasterTaskLoopDirective &s)
mlir::LogicalResult emitStmt(const clang::Stmt *s, bool useCurrentScope, llvm::ArrayRef< const Attr * > attrs={})
mlir::LogicalResult emitOMPCancelDirective(const OMPCancelDirective &s)
mlir::LogicalResult emitOMPStripeDirective(const OMPStripeDirective &s)
mlir::LogicalResult emitOMPTargetTeamsDistributeDirective(const OMPTargetTeamsDistributeDirective &s)
mlir::LogicalResult emitCompoundStmtWithoutScope(const clang::CompoundStmt &s, Address *lastValue=nullptr, AggValueSlot slot=AggValueSlot::ignored())
mlir::LogicalResult emitOMPParallelSectionsDirective(const OMPParallelSectionsDirective &s)
mlir::LogicalResult emitOpenACCExitDataConstruct(const OpenACCExitDataConstruct &s)
void emitIgnoredExpr(const clang::Expr *e)
Emit code to compute the specified expression, ignoring the result.
void emitAggExpr(const clang::Expr *e, AggValueSlot slot)
mlir::LogicalResult emitOpenACCAtomicConstruct(const OpenACCAtomicConstruct &s)
mlir::LogicalResult emitOMPTargetSimdDirective(const OMPTargetSimdDirective &s)
mlir::LogicalResult emitOMPAssumeDirective(const OMPAssumeDirective &s)
mlir::LogicalResult emitOpenACCLoopConstruct(const OpenACCLoopConstruct &s)
DiagnosticBuilder errorNYI(SourceLocation, llvm::StringRef)
Helpers to emit "not yet implemented" error diagnostics.
This trivial value class is used to represent the result of an expression that is evaluated.
Definition CIRGenValue.h:33
Address getAggregateAddress() const
Return the value of the address of the aggregate.
Definition CIRGenValue.h:69
bool isAggregate() const
Definition CIRGenValue.h:51
mlir::Value getValue() const
Return the value of this scalar value.
Definition CIRGenValue.h:57
bool isScalar() const
Definition CIRGenValue.h:49
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
Definition StmtCXX.h:136
DeclStmt * getBeginStmt()
Definition StmtCXX.h:164
DeclStmt * getEndStmt()
Definition StmtCXX.h:167
DeclStmt * getRangeStmt()
Definition StmtCXX.h:163
SourceLocation getEndLoc() const LLVM_READONLY
Definition StmtCXX.h:209
CaseStmt - Represent a case statement.
Definition Stmt.h:1929
Expr * getLHS()
Definition Stmt.h:2012
Expr * getRHS()
Definition Stmt.h:2024
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition Stmt.h:1749
body_range body()
Definition Stmt.h:1812
Stmt * body_back()
Definition Stmt.h:1817
ContinueStmt - This represents a continue.
Definition Stmt.h:3128
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Definition Stmt.h:1640
decl_range decls()
Definition Stmt.h:1688
DoStmt - This represents a 'do/while' stmt.
Definition Stmt.h:2841
SourceLocation getEndLoc() const
Definition Stmt.h:2878
This represents one expression.
Definition Expr.h:112
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
Definition Expr.cpp:3699
QualType getType() const
Definition Expr.h:144
ForStmt - This represents a 'for (init;cond;inc)' stmt.
Definition Stmt.h:2897
Stmt * getInit()
Definition Stmt.h:2912
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "for" statement, if any.
Definition Stmt.cpp:1120
SourceLocation getEndLoc() const
Definition Stmt.h:2961
Stmt * getBody()
Definition Stmt.h:2941
Expr * getInc()
Definition Stmt.h:2940
Expr * getCond()
Definition Stmt.h:2939
GotoStmt - This represents a direct goto.
Definition Stmt.h:2978
LabelDecl * getLabel() const
Definition Stmt.h:2991
IfStmt - This represents an if/then/else.
Definition Stmt.h:2268
Stmt * getThen()
Definition Stmt.h:2357
Stmt * getInit()
Definition Stmt.h:2418
Expr * getCond()
Definition Stmt.h:2345
bool isConstexpr() const
Definition Stmt.h:2461
bool isNegatedConsteval() const
Definition Stmt.h:2457
Stmt * getElse()
Definition Stmt.h:2366
bool isConsteval() const
Definition Stmt.h:2448
VarDecl * getConditionVariable()
Retrieve the variable declared in this "if" statement, if any.
Definition Stmt.cpp:1068
IndirectGotoStmt - This represents an indirect goto.
Definition Stmt.h:3017
Represents the declaration of a label.
Definition Decl.h:524
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition Decl.h:554
LabelStmt - Represents a label, which has a substatement.
Definition Stmt.h:2155
LabelDecl * getDecl() const
Definition Stmt.h:2173
bool isSideEntry() const
Definition Stmt.h:2202
Stmt * getSubStmt()
Definition Stmt.h:2177
SourceLocation getKwLoc() const
Definition Stmt.h:3091
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition Decl.h:301
A (possibly-)qualified type.
Definition TypeBase.h:938
The collection of all-type qualifiers we support.
Definition TypeBase.h:332
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Definition Stmt.h:3169
const VarDecl * getNRVOCandidate() const
Retrieve the variable that might be used for the named return value optimization.
Definition Stmt.h:3205
Expr * getRetValue()
Definition Stmt.h:3196
Stmt - This represents one statement.
Definition Stmt.h:85
@ NoStmtClass
Definition Stmt.h:88
StmtClass getStmtClass() const
Definition Stmt.h:1502
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition Stmt.cpp:343
const char * getStmtClassName() const
Definition Stmt.cpp:86
SwitchStmt - This represents a 'switch' stmt.
Definition Stmt.h:2518
bool isAllEnumCasesCovered() const
Returns true if the SwitchStmt is a switch of an enum value and all cases have been explicitly covere...
Definition Stmt.h:2678
Expr * getCond()
Definition Stmt.h:2581
VarDecl * getConditionVariable()
Retrieve the variable declared in this "switch" statement, if any.
Definition Stmt.cpp:1186
Stmt * getInit()
Definition Stmt.h:2598
SourceLocation getBeginLoc() const
Definition Stmt.h:2682
bool isVoidType() const
Definition TypeBase.h:9092
Represents a variable declaration or definition.
Definition Decl.h:932
bool isNRVOVariable() const
Determine whether this local variable can be used with the named return value optimization (NRVO).
Definition Decl.h:1536
QualType::DestructionKind needsDestruction(const ASTContext &Ctx) const
Would the destruction of this variable have any effect, and if so, what kind?
Definition Decl.cpp:2814
WhileStmt - This represents a 'while' stmt.
Definition Stmt.h:2706
Expr * getCond()
Definition Stmt.h:2758
VarDecl * getConditionVariable()
Retrieve the variable declared in this "while" statement, if any.
Definition Stmt.cpp:1247
SourceLocation getEndLoc() const LLVM_READONLY
Definition Stmt.h:2820
Stmt * getBody()
Definition Stmt.h:2770
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
const internal::VariadicDynCastAllOfMatcher< Stmt, CompoundStmt > compoundStmt
Matches compound statements.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicDynCastAllOfMatcher< Stmt, SwitchCase > switchCase
Matches case and default statements inside switch statements.
const internal::VariadicAllOfMatcher< Stmt > stmt
Matches statements.
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
Definition Address.h:330
@ Default
Set to the current date and time.
const FunctionProtoType * T
U cast(CodeGen::Address addr)
Definition Address.h:327
@ Other
Other implicit parameter.
Definition Decl.h:1774
static bool emitLifetimeMarkers()
static bool aggValueSlotGC()
static bool createProfileWeightsForLoop()
static bool loopInfoStack()
static bool emitCondLikelihoodViaExpectIntrinsic()
static bool constantFoldSwitchStatement()
static bool insertBuiltinUnpredictable()
static bool generateDebugInfo()
static bool incrementProfileCounter()
Represents a scope, including function bodies, compound statements, and the substatements of if/while...