clang  15.0.0git
CGStmt.cpp
Go to the documentation of this file.
1 //===--- CGStmt.cpp - Emit LLVM Code from Statements ----------------------===//
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 // This contains code to emit Stmt nodes as LLVM code.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "CGDebugInfo.h"
14 #include "CGOpenMPRuntime.h"
15 #include "CodeGenFunction.h"
16 #include "CodeGenModule.h"
17 #include "TargetInfo.h"
18 #include "clang/AST/Attr.h"
19 #include "clang/AST/Expr.h"
20 #include "clang/AST/Stmt.h"
21 #include "clang/AST/StmtVisitor.h"
22 #include "clang/Basic/Builtins.h"
26 #include "clang/Basic/TargetInfo.h"
27 #include "llvm/ADT/SmallSet.h"
28 #include "llvm/ADT/StringExtras.h"
29 #include "llvm/IR/Assumptions.h"
30 #include "llvm/IR/DataLayout.h"
31 #include "llvm/IR/InlineAsm.h"
32 #include "llvm/IR/Intrinsics.h"
33 #include "llvm/IR/MDBuilder.h"
34 #include "llvm/Support/SaveAndRestore.h"
35 
36 using namespace clang;
37 using namespace CodeGen;
38 
39 //===----------------------------------------------------------------------===//
40 // Statement Emission
41 //===----------------------------------------------------------------------===//
42 
44  if (CGDebugInfo *DI = getDebugInfo()) {
45  SourceLocation Loc;
46  Loc = S->getBeginLoc();
47  DI->EmitLocation(Builder, Loc);
48 
49  LastStopPoint = Loc;
50  }
51 }
52 
54  assert(S && "Null statement?");
55  PGO.setCurrentStmt(S);
56 
57  // These statements have their own debug info handling.
58  if (EmitSimpleStmt(S, Attrs))
59  return;
60 
61  // Check if we are generating unreachable code.
62  if (!HaveInsertPoint()) {
63  // If so, and the statement doesn't contain a label, then we do not need to
64  // generate actual code. This is safe because (1) the current point is
65  // unreachable, so we don't need to execute the code, and (2) we've already
66  // handled the statements which update internal data structures (like the
67  // local variable map) which could be used by subsequent statements.
68  if (!ContainsLabel(S)) {
69  // Verify that any decl statements were handled as simple, they may be in
70  // scope of subsequent reachable statements.
71  assert(!isa<DeclStmt>(*S) && "Unexpected DeclStmt!");
72  return;
73  }
74 
75  // Otherwise, make a new block to hold the code.
77  }
78 
79  // Generate a stoppoint if we are emitting debug info.
80  EmitStopPoint(S);
81 
82  // Ignore all OpenMP directives except for simd if OpenMP with Simd is
83  // enabled.
84  if (getLangOpts().OpenMP && getLangOpts().OpenMPSimd) {
85  if (const auto *D = dyn_cast<OMPExecutableDirective>(S)) {
87  return;
88  }
89  }
90 
91  switch (S->getStmtClass()) {
92  case Stmt::NoStmtClass:
93  case Stmt::CXXCatchStmtClass:
94  case Stmt::SEHExceptStmtClass:
95  case Stmt::SEHFinallyStmtClass:
96  case Stmt::MSDependentExistsStmtClass:
97  llvm_unreachable("invalid statement class to emit generically");
98  case Stmt::NullStmtClass:
99  case Stmt::CompoundStmtClass:
100  case Stmt::DeclStmtClass:
101  case Stmt::LabelStmtClass:
102  case Stmt::AttributedStmtClass:
103  case Stmt::GotoStmtClass:
104  case Stmt::BreakStmtClass:
105  case Stmt::ContinueStmtClass:
106  case Stmt::DefaultStmtClass:
107  case Stmt::CaseStmtClass:
108  case Stmt::SEHLeaveStmtClass:
109  llvm_unreachable("should have emitted these statements as simple");
110 
111 #define STMT(Type, Base)
112 #define ABSTRACT_STMT(Op)
113 #define EXPR(Type, Base) \
114  case Stmt::Type##Class:
115 #include "clang/AST/StmtNodes.inc"
116  {
117  // Remember the block we came in on.
118  llvm::BasicBlock *incoming = Builder.GetInsertBlock();
119  assert(incoming && "expression emission must have an insertion point");
120 
121  EmitIgnoredExpr(cast<Expr>(S));
122 
123  llvm::BasicBlock *outgoing = Builder.GetInsertBlock();
124  assert(outgoing && "expression emission cleared block!");
125 
126  // The expression emitters assume (reasonably!) that the insertion
127  // point is always set. To maintain that, the call-emission code
128  // for noreturn functions has to enter a new block with no
129  // predecessors. We want to kill that block and mark the current
130  // insertion point unreachable in the common case of a call like
131  // "exit();". Since expression emission doesn't otherwise create
132  // blocks with no predecessors, we can just test for that.
133  // However, we must be careful not to do this to our incoming
134  // block, because *statement* emission does sometimes create
135  // reachable blocks which will have no predecessors until later in
136  // the function. This occurs with, e.g., labels that are not
137  // reachable by fallthrough.
138  if (incoming != outgoing && outgoing->use_empty()) {
139  outgoing->eraseFromParent();
140  Builder.ClearInsertionPoint();
141  }
142  break;
143  }
144 
145  case Stmt::IndirectGotoStmtClass:
146  EmitIndirectGotoStmt(cast<IndirectGotoStmt>(*S)); break;
147 
148  case Stmt::IfStmtClass: EmitIfStmt(cast<IfStmt>(*S)); break;
149  case Stmt::WhileStmtClass: EmitWhileStmt(cast<WhileStmt>(*S), Attrs); break;
150  case Stmt::DoStmtClass: EmitDoStmt(cast<DoStmt>(*S), Attrs); break;
151  case Stmt::ForStmtClass: EmitForStmt(cast<ForStmt>(*S), Attrs); break;
152 
153  case Stmt::ReturnStmtClass: EmitReturnStmt(cast<ReturnStmt>(*S)); break;
154 
155  case Stmt::SwitchStmtClass: EmitSwitchStmt(cast<SwitchStmt>(*S)); break;
156  case Stmt::GCCAsmStmtClass: // Intentional fall-through.
157  case Stmt::MSAsmStmtClass: EmitAsmStmt(cast<AsmStmt>(*S)); break;
158  case Stmt::CoroutineBodyStmtClass:
159  EmitCoroutineBody(cast<CoroutineBodyStmt>(*S));
160  break;
161  case Stmt::CoreturnStmtClass:
162  EmitCoreturnStmt(cast<CoreturnStmt>(*S));
163  break;
164  case Stmt::CapturedStmtClass: {
165  const CapturedStmt *CS = cast<CapturedStmt>(S);
167  }
168  break;
169  case Stmt::ObjCAtTryStmtClass:
170  EmitObjCAtTryStmt(cast<ObjCAtTryStmt>(*S));
171  break;
172  case Stmt::ObjCAtCatchStmtClass:
173  llvm_unreachable(
174  "@catch statements should be handled by EmitObjCAtTryStmt");
175  case Stmt::ObjCAtFinallyStmtClass:
176  llvm_unreachable(
177  "@finally statements should be handled by EmitObjCAtTryStmt");
178  case Stmt::ObjCAtThrowStmtClass:
179  EmitObjCAtThrowStmt(cast<ObjCAtThrowStmt>(*S));
180  break;
181  case Stmt::ObjCAtSynchronizedStmtClass:
182  EmitObjCAtSynchronizedStmt(cast<ObjCAtSynchronizedStmt>(*S));
183  break;
184  case Stmt::ObjCForCollectionStmtClass:
185  EmitObjCForCollectionStmt(cast<ObjCForCollectionStmt>(*S));
186  break;
187  case Stmt::ObjCAutoreleasePoolStmtClass:
188  EmitObjCAutoreleasePoolStmt(cast<ObjCAutoreleasePoolStmt>(*S));
189  break;
190 
191  case Stmt::CXXTryStmtClass:
192  EmitCXXTryStmt(cast<CXXTryStmt>(*S));
193  break;
194  case Stmt::CXXForRangeStmtClass:
195  EmitCXXForRangeStmt(cast<CXXForRangeStmt>(*S), Attrs);
196  break;
197  case Stmt::SEHTryStmtClass:
198  EmitSEHTryStmt(cast<SEHTryStmt>(*S));
199  break;
200  case Stmt::OMPMetaDirectiveClass:
201  EmitOMPMetaDirective(cast<OMPMetaDirective>(*S));
202  break;
203  case Stmt::OMPCanonicalLoopClass:
204  EmitOMPCanonicalLoop(cast<OMPCanonicalLoop>(S));
205  break;
206  case Stmt::OMPParallelDirectiveClass:
207  EmitOMPParallelDirective(cast<OMPParallelDirective>(*S));
208  break;
209  case Stmt::OMPSimdDirectiveClass:
210  EmitOMPSimdDirective(cast<OMPSimdDirective>(*S));
211  break;
212  case Stmt::OMPTileDirectiveClass:
213  EmitOMPTileDirective(cast<OMPTileDirective>(*S));
214  break;
215  case Stmt::OMPUnrollDirectiveClass:
216  EmitOMPUnrollDirective(cast<OMPUnrollDirective>(*S));
217  break;
218  case Stmt::OMPForDirectiveClass:
219  EmitOMPForDirective(cast<OMPForDirective>(*S));
220  break;
221  case Stmt::OMPForSimdDirectiveClass:
222  EmitOMPForSimdDirective(cast<OMPForSimdDirective>(*S));
223  break;
224  case Stmt::OMPSectionsDirectiveClass:
225  EmitOMPSectionsDirective(cast<OMPSectionsDirective>(*S));
226  break;
227  case Stmt::OMPSectionDirectiveClass:
228  EmitOMPSectionDirective(cast<OMPSectionDirective>(*S));
229  break;
230  case Stmt::OMPSingleDirectiveClass:
231  EmitOMPSingleDirective(cast<OMPSingleDirective>(*S));
232  break;
233  case Stmt::OMPMasterDirectiveClass:
234  EmitOMPMasterDirective(cast<OMPMasterDirective>(*S));
235  break;
236  case Stmt::OMPCriticalDirectiveClass:
237  EmitOMPCriticalDirective(cast<OMPCriticalDirective>(*S));
238  break;
239  case Stmt::OMPParallelForDirectiveClass:
240  EmitOMPParallelForDirective(cast<OMPParallelForDirective>(*S));
241  break;
242  case Stmt::OMPParallelForSimdDirectiveClass:
243  EmitOMPParallelForSimdDirective(cast<OMPParallelForSimdDirective>(*S));
244  break;
245  case Stmt::OMPParallelMasterDirectiveClass:
246  EmitOMPParallelMasterDirective(cast<OMPParallelMasterDirective>(*S));
247  break;
248  case Stmt::OMPParallelSectionsDirectiveClass:
249  EmitOMPParallelSectionsDirective(cast<OMPParallelSectionsDirective>(*S));
250  break;
251  case Stmt::OMPTaskDirectiveClass:
252  EmitOMPTaskDirective(cast<OMPTaskDirective>(*S));
253  break;
254  case Stmt::OMPTaskyieldDirectiveClass:
255  EmitOMPTaskyieldDirective(cast<OMPTaskyieldDirective>(*S));
256  break;
257  case Stmt::OMPBarrierDirectiveClass:
258  EmitOMPBarrierDirective(cast<OMPBarrierDirective>(*S));
259  break;
260  case Stmt::OMPTaskwaitDirectiveClass:
261  EmitOMPTaskwaitDirective(cast<OMPTaskwaitDirective>(*S));
262  break;
263  case Stmt::OMPTaskgroupDirectiveClass:
264  EmitOMPTaskgroupDirective(cast<OMPTaskgroupDirective>(*S));
265  break;
266  case Stmt::OMPFlushDirectiveClass:
267  EmitOMPFlushDirective(cast<OMPFlushDirective>(*S));
268  break;
269  case Stmt::OMPDepobjDirectiveClass:
270  EmitOMPDepobjDirective(cast<OMPDepobjDirective>(*S));
271  break;
272  case Stmt::OMPScanDirectiveClass:
273  EmitOMPScanDirective(cast<OMPScanDirective>(*S));
274  break;
275  case Stmt::OMPOrderedDirectiveClass:
276  EmitOMPOrderedDirective(cast<OMPOrderedDirective>(*S));
277  break;
278  case Stmt::OMPAtomicDirectiveClass:
279  EmitOMPAtomicDirective(cast<OMPAtomicDirective>(*S));
280  break;
281  case Stmt::OMPTargetDirectiveClass:
282  EmitOMPTargetDirective(cast<OMPTargetDirective>(*S));
283  break;
284  case Stmt::OMPTeamsDirectiveClass:
285  EmitOMPTeamsDirective(cast<OMPTeamsDirective>(*S));
286  break;
287  case Stmt::OMPCancellationPointDirectiveClass:
288  EmitOMPCancellationPointDirective(cast<OMPCancellationPointDirective>(*S));
289  break;
290  case Stmt::OMPCancelDirectiveClass:
291  EmitOMPCancelDirective(cast<OMPCancelDirective>(*S));
292  break;
293  case Stmt::OMPTargetDataDirectiveClass:
294  EmitOMPTargetDataDirective(cast<OMPTargetDataDirective>(*S));
295  break;
296  case Stmt::OMPTargetEnterDataDirectiveClass:
297  EmitOMPTargetEnterDataDirective(cast<OMPTargetEnterDataDirective>(*S));
298  break;
299  case Stmt::OMPTargetExitDataDirectiveClass:
300  EmitOMPTargetExitDataDirective(cast<OMPTargetExitDataDirective>(*S));
301  break;
302  case Stmt::OMPTargetParallelDirectiveClass:
303  EmitOMPTargetParallelDirective(cast<OMPTargetParallelDirective>(*S));
304  break;
305  case Stmt::OMPTargetParallelForDirectiveClass:
306  EmitOMPTargetParallelForDirective(cast<OMPTargetParallelForDirective>(*S));
307  break;
308  case Stmt::OMPTaskLoopDirectiveClass:
309  EmitOMPTaskLoopDirective(cast<OMPTaskLoopDirective>(*S));
310  break;
311  case Stmt::OMPTaskLoopSimdDirectiveClass:
312  EmitOMPTaskLoopSimdDirective(cast<OMPTaskLoopSimdDirective>(*S));
313  break;
314  case Stmt::OMPMasterTaskLoopDirectiveClass:
315  EmitOMPMasterTaskLoopDirective(cast<OMPMasterTaskLoopDirective>(*S));
316  break;
317  case Stmt::OMPMasterTaskLoopSimdDirectiveClass:
319  cast<OMPMasterTaskLoopSimdDirective>(*S));
320  break;
321  case Stmt::OMPParallelMasterTaskLoopDirectiveClass:
323  cast<OMPParallelMasterTaskLoopDirective>(*S));
324  break;
325  case Stmt::OMPParallelMasterTaskLoopSimdDirectiveClass:
327  cast<OMPParallelMasterTaskLoopSimdDirective>(*S));
328  break;
329  case Stmt::OMPDistributeDirectiveClass:
330  EmitOMPDistributeDirective(cast<OMPDistributeDirective>(*S));
331  break;
332  case Stmt::OMPTargetUpdateDirectiveClass:
333  EmitOMPTargetUpdateDirective(cast<OMPTargetUpdateDirective>(*S));
334  break;
335  case Stmt::OMPDistributeParallelForDirectiveClass:
337  cast<OMPDistributeParallelForDirective>(*S));
338  break;
339  case Stmt::OMPDistributeParallelForSimdDirectiveClass:
341  cast<OMPDistributeParallelForSimdDirective>(*S));
342  break;
343  case Stmt::OMPDistributeSimdDirectiveClass:
344  EmitOMPDistributeSimdDirective(cast<OMPDistributeSimdDirective>(*S));
345  break;
346  case Stmt::OMPTargetParallelForSimdDirectiveClass:
348  cast<OMPTargetParallelForSimdDirective>(*S));
349  break;
350  case Stmt::OMPTargetSimdDirectiveClass:
351  EmitOMPTargetSimdDirective(cast<OMPTargetSimdDirective>(*S));
352  break;
353  case Stmt::OMPTeamsDistributeDirectiveClass:
354  EmitOMPTeamsDistributeDirective(cast<OMPTeamsDistributeDirective>(*S));
355  break;
356  case Stmt::OMPTeamsDistributeSimdDirectiveClass:
358  cast<OMPTeamsDistributeSimdDirective>(*S));
359  break;
360  case Stmt::OMPTeamsDistributeParallelForSimdDirectiveClass:
362  cast<OMPTeamsDistributeParallelForSimdDirective>(*S));
363  break;
364  case Stmt::OMPTeamsDistributeParallelForDirectiveClass:
366  cast<OMPTeamsDistributeParallelForDirective>(*S));
367  break;
368  case Stmt::OMPTargetTeamsDirectiveClass:
369  EmitOMPTargetTeamsDirective(cast<OMPTargetTeamsDirective>(*S));
370  break;
371  case Stmt::OMPTargetTeamsDistributeDirectiveClass:
373  cast<OMPTargetTeamsDistributeDirective>(*S));
374  break;
375  case Stmt::OMPTargetTeamsDistributeParallelForDirectiveClass:
377  cast<OMPTargetTeamsDistributeParallelForDirective>(*S));
378  break;
379  case Stmt::OMPTargetTeamsDistributeParallelForSimdDirectiveClass:
381  cast<OMPTargetTeamsDistributeParallelForSimdDirective>(*S));
382  break;
383  case Stmt::OMPTargetTeamsDistributeSimdDirectiveClass:
385  cast<OMPTargetTeamsDistributeSimdDirective>(*S));
386  break;
387  case Stmt::OMPInteropDirectiveClass:
388  EmitOMPInteropDirective(cast<OMPInteropDirective>(*S));
389  break;
390  case Stmt::OMPDispatchDirectiveClass:
391  llvm_unreachable("Dispatch directive not supported yet.");
392  break;
393  case Stmt::OMPMaskedDirectiveClass:
394  EmitOMPMaskedDirective(cast<OMPMaskedDirective>(*S));
395  break;
396  case Stmt::OMPGenericLoopDirectiveClass:
397  EmitOMPGenericLoopDirective(cast<OMPGenericLoopDirective>(*S));
398  break;
399  case Stmt::OMPTeamsGenericLoopDirectiveClass:
400  llvm_unreachable("teams loop directive not supported yet.");
401  break;
402  case Stmt::OMPTargetTeamsGenericLoopDirectiveClass:
403  llvm_unreachable("target teams loop directive not supported yet.");
404  break;
405  case Stmt::OMPParallelGenericLoopDirectiveClass:
406  llvm_unreachable("parallel loop directive not supported yet.");
407  break;
408  case Stmt::OMPTargetParallelGenericLoopDirectiveClass:
409  llvm_unreachable("target parallel loop directive not supported yet.");
410  break;
411  }
412 }
413 
415  ArrayRef<const Attr *> Attrs) {
416  switch (S->getStmtClass()) {
417  default:
418  return false;
419  case Stmt::NullStmtClass:
420  break;
421  case Stmt::CompoundStmtClass:
422  EmitCompoundStmt(cast<CompoundStmt>(*S));
423  break;
424  case Stmt::DeclStmtClass:
425  EmitDeclStmt(cast<DeclStmt>(*S));
426  break;
427  case Stmt::LabelStmtClass:
428  EmitLabelStmt(cast<LabelStmt>(*S));
429  break;
430  case Stmt::AttributedStmtClass:
431  EmitAttributedStmt(cast<AttributedStmt>(*S));
432  break;
433  case Stmt::GotoStmtClass:
434  EmitGotoStmt(cast<GotoStmt>(*S));
435  break;
436  case Stmt::BreakStmtClass:
437  EmitBreakStmt(cast<BreakStmt>(*S));
438  break;
439  case Stmt::ContinueStmtClass:
440  EmitContinueStmt(cast<ContinueStmt>(*S));
441  break;
442  case Stmt::DefaultStmtClass:
443  EmitDefaultStmt(cast<DefaultStmt>(*S), Attrs);
444  break;
445  case Stmt::CaseStmtClass:
446  EmitCaseStmt(cast<CaseStmt>(*S), Attrs);
447  break;
448  case Stmt::SEHLeaveStmtClass:
449  EmitSEHLeaveStmt(cast<SEHLeaveStmt>(*S));
450  break;
451  }
452  return true;
453 }
454 
455 /// EmitCompoundStmt - Emit a compound statement {..} node. If GetLast is true,
456 /// this captures the expression result of the last sub-statement and returns it
457 /// (for use by the statement expression extension).
459  AggValueSlot AggSlot) {
460  PrettyStackTraceLoc CrashInfo(getContext().getSourceManager(),S.getLBracLoc(),
461  "LLVM IR generation of compound statement ('{}')");
462 
463  // Keep track of the current cleanup stack depth, including debug scopes.
464  LexicalScope Scope(*this, S.getSourceRange());
465 
466  return EmitCompoundStmtWithoutScope(S, GetLast, AggSlot);
467 }
468 
469 Address
471  bool GetLast,
472  AggValueSlot AggSlot) {
473 
474  const Stmt *ExprResult = S.getStmtExprResult();
475  assert((!GetLast || (GetLast && ExprResult)) &&
476  "If GetLast is true then the CompoundStmt must have a StmtExprResult");
477 
478  Address RetAlloca = Address::invalid();
479 
480  for (auto *CurStmt : S.body()) {
481  if (GetLast && ExprResult == CurStmt) {
482  // We have to special case labels here. They are statements, but when put
483  // at the end of a statement expression, they yield the value of their
484  // subexpression. Handle this by walking through all labels we encounter,
485  // emitting them before we evaluate the subexpr.
486  // Similar issues arise for attributed statements.
487  while (!isa<Expr>(ExprResult)) {
488  if (const auto *LS = dyn_cast<LabelStmt>(ExprResult)) {
489  EmitLabel(LS->getDecl());
490  ExprResult = LS->getSubStmt();
491  } else if (const auto *AS = dyn_cast<AttributedStmt>(ExprResult)) {
492  // FIXME: Update this if we ever have attributes that affect the
493  // semantics of an expression.
494  ExprResult = AS->getSubStmt();
495  } else {
496  llvm_unreachable("unknown value statement");
497  }
498  }
499 
501 
502  const Expr *E = cast<Expr>(ExprResult);
503  QualType ExprTy = E->getType();
504  if (hasAggregateEvaluationKind(ExprTy)) {
505  EmitAggExpr(E, AggSlot);
506  } else {
507  // We can't return an RValue here because there might be cleanups at
508  // the end of the StmtExpr. Because of that, we have to emit the result
509  // here into a temporary alloca.
510  RetAlloca = CreateMemTemp(ExprTy);
511  EmitAnyExprToMem(E, RetAlloca, Qualifiers(),
512  /*IsInit*/ false);
513  }
514  } else {
515  EmitStmt(CurStmt);
516  }
517  }
518 
519  return RetAlloca;
520 }
521 
522 void CodeGenFunction::SimplifyForwardingBlocks(llvm::BasicBlock *BB) {
523  llvm::BranchInst *BI = dyn_cast<llvm::BranchInst>(BB->getTerminator());
524 
525  // If there is a cleanup stack, then we it isn't worth trying to
526  // simplify this block (we would need to remove it from the scope map
527  // and cleanup entry).
528  if (!EHStack.empty())
529  return;
530 
531  // Can only simplify direct branches.
532  if (!BI || !BI->isUnconditional())
533  return;
534 
535  // Can only simplify empty blocks.
536  if (BI->getIterator() != BB->begin())
537  return;
538 
539  BB->replaceAllUsesWith(BI->getSuccessor(0));
540  BI->eraseFromParent();
541  BB->eraseFromParent();
542 }
543 
544 void CodeGenFunction::EmitBlock(llvm::BasicBlock *BB, bool IsFinished) {
545  llvm::BasicBlock *CurBB = Builder.GetInsertBlock();
546 
547  // Fall out of the current block (if necessary).
548  EmitBranch(BB);
549 
550  if (IsFinished && BB->use_empty()) {
551  delete BB;
552  return;
553  }
554 
555  // Place the block after the current block, if possible, or else at
556  // the end of the function.
557  if (CurBB && CurBB->getParent())
558  CurFn->getBasicBlockList().insertAfter(CurBB->getIterator(), BB);
559  else
560  CurFn->getBasicBlockList().push_back(BB);
561  Builder.SetInsertPoint(BB);
562 }
563 
564 void CodeGenFunction::EmitBranch(llvm::BasicBlock *Target) {
565  // Emit a branch from the current block to the target one if this
566  // was a real block. If this was just a fall-through block after a
567  // terminator, don't emit it.
568  llvm::BasicBlock *CurBB = Builder.GetInsertBlock();
569 
570  if (!CurBB || CurBB->getTerminator()) {
571  // If there is no insert point or the previous block is already
572  // terminated, don't touch it.
573  } else {
574  // Otherwise, create a fall-through branch.
575  Builder.CreateBr(Target);
576  }
577 
578  Builder.ClearInsertionPoint();
579 }
580 
581 void CodeGenFunction::EmitBlockAfterUses(llvm::BasicBlock *block) {
582  bool inserted = false;
583  for (llvm::User *u : block->users()) {
584  if (llvm::Instruction *insn = dyn_cast<llvm::Instruction>(u)) {
585  CurFn->getBasicBlockList().insertAfter(insn->getParent()->getIterator(),
586  block);
587  inserted = true;
588  break;
589  }
590  }
591 
592  if (!inserted)
593  CurFn->getBasicBlockList().push_back(block);
594 
595  Builder.SetInsertPoint(block);
596 }
597 
600  JumpDest &Dest = LabelMap[D];
601  if (Dest.isValid()) return Dest;
602 
603  // Create, but don't insert, the new block.
604  Dest = JumpDest(createBasicBlock(D->getName()),
607  return Dest;
608 }
609 
611  // Add this label to the current lexical scope if we're within any
612  // normal cleanups. Jumps "in" to this label --- when permitted by
613  // the language --- may need to be routed around such cleanups.
614  if (EHStack.hasNormalCleanups() && CurLexicalScope)
615  CurLexicalScope->addLabel(D);
616 
617  JumpDest &Dest = LabelMap[D];
618 
619  // If we didn't need a forward reference to this label, just go
620  // ahead and create a destination at the current scope.
621  if (!Dest.isValid()) {
622  Dest = getJumpDestInCurrentScope(D->getName());
623 
624  // Otherwise, we need to give this label a target depth and remove
625  // it from the branch-fixups list.
626  } else {
627  assert(!Dest.getScopeDepth().isValid() && "already emitted label!");
630  }
631 
632  EmitBlock(Dest.getBlock());
633 
634  // Emit debug info for labels.
635  if (CGDebugInfo *DI = getDebugInfo()) {
637  DI->setLocation(D->getLocation());
638  DI->EmitLabel(D, Builder);
639  }
640  }
641 
643 }
644 
645 /// Change the cleanup scope of the labels in this lexical scope to
646 /// match the scope of the enclosing context.
648  assert(!Labels.empty());
649  EHScopeStack::stable_iterator innermostScope
651 
652  // Change the scope depth of all the labels.
654  i = Labels.begin(), e = Labels.end(); i != e; ++i) {
655  assert(CGF.LabelMap.count(*i));
656  JumpDest &dest = CGF.LabelMap.find(*i)->second;
657  assert(dest.getScopeDepth().isValid());
658  assert(innermostScope.encloses(dest.getScopeDepth()));
659  dest.setScopeDepth(innermostScope);
660  }
661 
662  // Reparent the labels if the new scope also has cleanups.
663  if (innermostScope != EHScopeStack::stable_end() && ParentScope) {
664  ParentScope->Labels.append(Labels.begin(), Labels.end());
665  }
666 }
667 
668 
670  EmitLabel(S.getDecl());
671 
672  // IsEHa - emit eha.scope.begin if it's a side entry of a scope
673  if (getLangOpts().EHAsynch && S.isSideEntry())
675 
676  EmitStmt(S.getSubStmt());
677 }
678 
680  bool nomerge = false;
681  bool noinline = false;
682  bool alwaysinline = false;
683  const CallExpr *musttail = nullptr;
684 
685  for (const auto *A : S.getAttrs()) {
686  switch (A->getKind()) {
687  default:
688  break;
689  case attr::NoMerge:
690  nomerge = true;
691  break;
692  case attr::NoInline:
693  noinline = true;
694  break;
695  case attr::AlwaysInline:
696  alwaysinline = true;
697  break;
698  case attr::MustTail:
699  const Stmt *Sub = S.getSubStmt();
700  const ReturnStmt *R = cast<ReturnStmt>(Sub);
701  musttail = cast<CallExpr>(R->getRetValue()->IgnoreParens());
702  break;
703  }
704  }
705  SaveAndRestore<bool> save_nomerge(InNoMergeAttributedStmt, nomerge);
706  SaveAndRestore<bool> save_noinline(InNoInlineAttributedStmt, noinline);
708  alwaysinline);
709  SaveAndRestore<const CallExpr *> save_musttail(MustTailCall, musttail);
710  EmitStmt(S.getSubStmt(), S.getAttrs());
711 }
712 
714  // If this code is reachable then emit a stop point (if generating
715  // debug info). We have to do this ourselves because we are on the
716  // "simple" statement path.
717  if (HaveInsertPoint())
718  EmitStopPoint(&S);
719 
721 }
722 
723 
725  if (const LabelDecl *Target = S.getConstantTarget()) {
727  return;
728  }
729 
730  // Ensure that we have an i8* for our PHI node.
731  llvm::Value *V = Builder.CreateBitCast(EmitScalarExpr(S.getTarget()),
732  Int8PtrTy, "addr");
733  llvm::BasicBlock *CurBB = Builder.GetInsertBlock();
734 
735  // Get the basic block for the indirect goto.
736  llvm::BasicBlock *IndGotoBB = GetIndirectGotoBlock();
737 
738  // The first instruction in the block has to be the PHI for the switch dest,
739  // add an entry for this branch.
740  cast<llvm::PHINode>(IndGotoBB->begin())->addIncoming(V, CurBB);
741 
742  EmitBranch(IndGotoBB);
743 }
744 
746  // The else branch of a consteval if statement is always the only branch that
747  // can be runtime evaluated.
748  if (S.isConsteval()) {
749  const Stmt *Executed = S.isNegatedConsteval() ? S.getThen() : S.getElse();
750  if (Executed) {
751  RunCleanupsScope ExecutedScope(*this);
752  EmitStmt(Executed);
753  }
754  return;
755  }
756 
757  // C99 6.8.4.1: The first substatement is executed if the expression compares
758  // unequal to 0. The condition must be a scalar type.
759  LexicalScope ConditionScope(*this, S.getCond()->getSourceRange());
760 
761  if (S.getInit())
762  EmitStmt(S.getInit());
763 
764  if (S.getConditionVariable())
765  EmitDecl(*S.getConditionVariable());
766 
767  // If the condition constant folds and can be elided, try to avoid emitting
768  // the condition and the dead arm of the if/else.
769  bool CondConstant;
770  if (ConstantFoldsToSimpleInteger(S.getCond(), CondConstant,
771  S.isConstexpr())) {
772  // Figure out which block (then or else) is executed.
773  const Stmt *Executed = S.getThen();
774  const Stmt *Skipped = S.getElse();
775  if (!CondConstant) // Condition false?
776  std::swap(Executed, Skipped);
777 
778  // If the skipped block has no labels in it, just emit the executed block.
779  // This avoids emitting dead code and simplifies the CFG substantially.
780  if (S.isConstexpr() || !ContainsLabel(Skipped)) {
781  if (CondConstant)
783  if (Executed) {
784  RunCleanupsScope ExecutedScope(*this);
785  EmitStmt(Executed);
786  }
787  return;
788  }
789  }
790 
791  // Otherwise, the condition did not fold, or we couldn't elide it. Just emit
792  // the conditional branch.
793  llvm::BasicBlock *ThenBlock = createBasicBlock("if.then");
794  llvm::BasicBlock *ContBlock = createBasicBlock("if.end");
795  llvm::BasicBlock *ElseBlock = ContBlock;
796  if (S.getElse())
797  ElseBlock = createBasicBlock("if.else");
798 
799  // Prefer the PGO based weights over the likelihood attribute.
800  // When the build isn't optimized the metadata isn't used, so don't generate
801  // it.
803  uint64_t Count = getProfileCount(S.getThen());
804  if (!Count && CGM.getCodeGenOpts().OptimizationLevel)
805  LH = Stmt::getLikelihood(S.getThen(), S.getElse());
806  EmitBranchOnBoolExpr(S.getCond(), ThenBlock, ElseBlock, Count, LH);
807 
808  // Emit the 'then' code.
809  EmitBlock(ThenBlock);
811  {
812  RunCleanupsScope ThenScope(*this);
813  EmitStmt(S.getThen());
814  }
815  EmitBranch(ContBlock);
816 
817  // Emit the 'else' code if present.
818  if (const Stmt *Else = S.getElse()) {
819  {
820  // There is no need to emit line number for an unconditional branch.
821  auto NL = ApplyDebugLocation::CreateEmpty(*this);
822  EmitBlock(ElseBlock);
823  }
824  {
825  RunCleanupsScope ElseScope(*this);
826  EmitStmt(Else);
827  }
828  {
829  // There is no need to emit line number for an unconditional branch.
830  auto NL = ApplyDebugLocation::CreateEmpty(*this);
831  EmitBranch(ContBlock);
832  }
833  }
834 
835  // Emit the continuation block for code after the if.
836  EmitBlock(ContBlock, true);
837 }
838 
840  ArrayRef<const Attr *> WhileAttrs) {
841  // Emit the header for the loop, which will also become
842  // the continue target.
843  JumpDest LoopHeader = getJumpDestInCurrentScope("while.cond");
844  EmitBlock(LoopHeader.getBlock());
845 
846  // Create an exit block for when the condition fails, which will
847  // also become the break target.
849 
850  // Store the blocks to use for break and continue.
851  BreakContinueStack.push_back(BreakContinue(LoopExit, LoopHeader));
852 
853  // C++ [stmt.while]p2:
854  // When the condition of a while statement is a declaration, the
855  // scope of the variable that is declared extends from its point
856  // of declaration (3.3.2) to the end of the while statement.
857  // [...]
858  // The object created in a condition is destroyed and created
859  // with each iteration of the loop.
860  RunCleanupsScope ConditionScope(*this);
861 
862  if (S.getConditionVariable())
863  EmitDecl(*S.getConditionVariable());
864 
865  // Evaluate the conditional in the while header. C99 6.8.5.1: The
866  // evaluation of the controlling expression takes place before each
867  // execution of the loop body.
868  llvm::Value *BoolCondVal = EvaluateExprAsBool(S.getCond());
869 
870  // while(1) is common, avoid extra exit blocks. Be sure
871  // to correctly handle break/continue though.
872  llvm::ConstantInt *C = dyn_cast<llvm::ConstantInt>(BoolCondVal);
873  bool CondIsConstInt = C != nullptr;
874  bool EmitBoolCondBranch = !CondIsConstInt || !C->isOne();
875  const SourceRange &R = S.getSourceRange();
877  WhileAttrs, SourceLocToDebugLoc(R.getBegin()),
879  checkIfLoopMustProgress(CondIsConstInt));
880 
881  // As long as the condition is true, go to the loop body.
882  llvm::BasicBlock *LoopBody = createBasicBlock("while.body");
883  if (EmitBoolCondBranch) {
884  llvm::BasicBlock *ExitBlock = LoopExit.getBlock();
885  if (ConditionScope.requiresCleanups())
886  ExitBlock = createBasicBlock("while.exit");
887  llvm::MDNode *Weights =
888  createProfileWeightsForLoop(S.getCond(), getProfileCount(S.getBody()));
889  if (!Weights && CGM.getCodeGenOpts().OptimizationLevel)
890  BoolCondVal = emitCondLikelihoodViaExpectIntrinsic(
891  BoolCondVal, Stmt::getLikelihood(S.getBody()));
892  Builder.CreateCondBr(BoolCondVal, LoopBody, ExitBlock, Weights);
893 
894  if (ExitBlock != LoopExit.getBlock()) {
895  EmitBlock(ExitBlock);
897  }
898  } else if (const Attr *A = Stmt::getLikelihoodAttr(S.getBody())) {
899  CGM.getDiags().Report(A->getLocation(),
900  diag::warn_attribute_has_no_effect_on_infinite_loop)
901  << A << A->getRange();
902  CGM.getDiags().Report(
903  S.getWhileLoc(),
904  diag::note_attribute_has_no_effect_on_infinite_loop_here)
905  << SourceRange(S.getWhileLoc(), S.getRParenLoc());
906  }
907 
908  // Emit the loop body. We have to emit this in a cleanup scope
909  // because it might be a singleton DeclStmt.
910  {
911  RunCleanupsScope BodyScope(*this);
912  EmitBlock(LoopBody);
914  EmitStmt(S.getBody());
915  }
916 
917  BreakContinueStack.pop_back();
918 
919  // Immediately force cleanup.
920  ConditionScope.ForceCleanup();
921 
922  EmitStopPoint(&S);
923  // Branch to the loop header again.
924  EmitBranch(LoopHeader.getBlock());
925 
926  LoopStack.pop();
927 
928  // Emit the exit block.
929  EmitBlock(LoopExit.getBlock(), true);
930 
931  // The LoopHeader typically is just a branch if we skipped emitting
932  // a branch, try to erase it.
933  if (!EmitBoolCondBranch)
934  SimplifyForwardingBlocks(LoopHeader.getBlock());
935 }
936 
938  ArrayRef<const Attr *> DoAttrs) {
940  JumpDest LoopCond = getJumpDestInCurrentScope("do.cond");
941 
942  uint64_t ParentCount = getCurrentProfileCount();
943 
944  // Store the blocks to use for break and continue.
945  BreakContinueStack.push_back(BreakContinue(LoopExit, LoopCond));
946 
947  // Emit the body of the loop.
948  llvm::BasicBlock *LoopBody = createBasicBlock("do.body");
949 
950  EmitBlockWithFallThrough(LoopBody, &S);
951  {
952  RunCleanupsScope BodyScope(*this);
953  EmitStmt(S.getBody());
954  }
955 
956  EmitBlock(LoopCond.getBlock());
957 
958  // C99 6.8.5.2: "The evaluation of the controlling expression takes place
959  // after each execution of the loop body."
960 
961  // Evaluate the conditional in the while header.
962  // C99 6.8.5p2/p4: The first substatement is executed if the expression
963  // compares unequal to 0. The condition must be a scalar type.
964  llvm::Value *BoolCondVal = EvaluateExprAsBool(S.getCond());
965 
966  BreakContinueStack.pop_back();
967 
968  // "do {} while (0)" is common in macros, avoid extra blocks. Be sure
969  // to correctly handle break/continue though.
970  llvm::ConstantInt *C = dyn_cast<llvm::ConstantInt>(BoolCondVal);
971  bool CondIsConstInt = C;
972  bool EmitBoolCondBranch = !C || !C->isZero();
973 
974  const SourceRange &R = S.getSourceRange();
975  LoopStack.push(LoopBody, CGM.getContext(), CGM.getCodeGenOpts(), DoAttrs,
978  checkIfLoopMustProgress(CondIsConstInt));
979 
980  // As long as the condition is true, iterate the loop.
981  if (EmitBoolCondBranch) {
982  uint64_t BackedgeCount = getProfileCount(S.getBody()) - ParentCount;
983  Builder.CreateCondBr(
984  BoolCondVal, LoopBody, LoopExit.getBlock(),
985  createProfileWeightsForLoop(S.getCond(), BackedgeCount));
986  }
987 
988  LoopStack.pop();
989 
990  // Emit the exit block.
991  EmitBlock(LoopExit.getBlock());
992 
993  // The DoCond block typically is just a branch if we skipped
994  // emitting a branch, try to erase it.
995  if (!EmitBoolCondBranch)
997 }
998 
1000  ArrayRef<const Attr *> ForAttrs) {
1002 
1003  LexicalScope ForScope(*this, S.getSourceRange());
1004 
1005  // Evaluate the first part before the loop.
1006  if (S.getInit())
1007  EmitStmt(S.getInit());
1008 
1009  // Start the loop with a block that tests the condition.
1010  // If there's an increment, the continue scope will be overwritten
1011  // later.
1012  JumpDest CondDest = getJumpDestInCurrentScope("for.cond");
1013  llvm::BasicBlock *CondBlock = CondDest.getBlock();
1014  EmitBlock(CondBlock);
1015 
1016  Expr::EvalResult Result;
1017  bool CondIsConstInt =
1018  !S.getCond() || S.getCond()->EvaluateAsInt(Result, getContext());
1019 
1020  const SourceRange &R = S.getSourceRange();
1021  LoopStack.push(CondBlock, CGM.getContext(), CGM.getCodeGenOpts(), ForAttrs,
1024  checkIfLoopMustProgress(CondIsConstInt));
1025 
1026  // Create a cleanup scope for the condition variable cleanups.
1027  LexicalScope ConditionScope(*this, S.getSourceRange());
1028 
1029  // If the for loop doesn't have an increment we can just use the condition as
1030  // the continue block. Otherwise, if there is no condition variable, we can
1031  // form the continue block now. If there is a condition variable, we can't
1032  // form the continue block until after we've emitted the condition, because
1033  // the condition is in scope in the increment, but Sema's jump diagnostics
1034  // ensure that there are no continues from the condition variable that jump
1035  // to the loop increment.
1036  JumpDest Continue;
1037  if (!S.getInc())
1038  Continue = CondDest;
1039  else if (!S.getConditionVariable())
1040  Continue = getJumpDestInCurrentScope("for.inc");
1041  BreakContinueStack.push_back(BreakContinue(LoopExit, Continue));
1042 
1043  if (S.getCond()) {
1044  // If the for statement has a condition scope, emit the local variable
1045  // declaration.
1046  if (S.getConditionVariable()) {
1047  EmitDecl(*S.getConditionVariable());
1048 
1049  // We have entered the condition variable's scope, so we're now able to
1050  // jump to the continue block.
1051  Continue = S.getInc() ? getJumpDestInCurrentScope("for.inc") : CondDest;
1052  BreakContinueStack.back().ContinueBlock = Continue;
1053  }
1054 
1055  llvm::BasicBlock *ExitBlock = LoopExit.getBlock();
1056  // If there are any cleanups between here and the loop-exit scope,
1057  // create a block to stage a loop exit along.
1058  if (ForScope.requiresCleanups())
1059  ExitBlock = createBasicBlock("for.cond.cleanup");
1060 
1061  // As long as the condition is true, iterate the loop.
1062  llvm::BasicBlock *ForBody = createBasicBlock("for.body");
1063 
1064  // C99 6.8.5p2/p4: The first substatement is executed if the expression
1065  // compares unequal to 0. The condition must be a scalar type.
1066  llvm::Value *BoolCondVal = EvaluateExprAsBool(S.getCond());
1067  llvm::MDNode *Weights =
1068  createProfileWeightsForLoop(S.getCond(), getProfileCount(S.getBody()));
1069  if (!Weights && CGM.getCodeGenOpts().OptimizationLevel)
1070  BoolCondVal = emitCondLikelihoodViaExpectIntrinsic(
1071  BoolCondVal, Stmt::getLikelihood(S.getBody()));
1072 
1073  Builder.CreateCondBr(BoolCondVal, ForBody, ExitBlock, Weights);
1074 
1075  if (ExitBlock != LoopExit.getBlock()) {
1076  EmitBlock(ExitBlock);
1078  }
1079 
1080  EmitBlock(ForBody);
1081  } else {
1082  // Treat it as a non-zero constant. Don't even create a new block for the
1083  // body, just fall into it.
1084  }
1086 
1087  {
1088  // Create a separate cleanup scope for the body, in case it is not
1089  // a compound statement.
1090  RunCleanupsScope BodyScope(*this);
1091  EmitStmt(S.getBody());
1092  }
1093 
1094  // If there is an increment, emit it next.
1095  if (S.getInc()) {
1096  EmitBlock(Continue.getBlock());
1097  EmitStmt(S.getInc());
1098  }
1099 
1100  BreakContinueStack.pop_back();
1101 
1102  ConditionScope.ForceCleanup();
1103 
1104  EmitStopPoint(&S);
1105  EmitBranch(CondBlock);
1106 
1107  ForScope.ForceCleanup();
1108 
1109  LoopStack.pop();
1110 
1111  // Emit the fall-through block.
1112  EmitBlock(LoopExit.getBlock(), true);
1113 }
1114 
1115 void
1117  ArrayRef<const Attr *> ForAttrs) {
1119 
1120  LexicalScope ForScope(*this, S.getSourceRange());
1121 
1122  // Evaluate the first pieces before the loop.
1123  if (S.getInit())
1124  EmitStmt(S.getInit());
1125  EmitStmt(S.getRangeStmt());
1126  EmitStmt(S.getBeginStmt());
1127  EmitStmt(S.getEndStmt());
1128 
1129  // Start the loop with a block that tests the condition.
1130  // If there's an increment, the continue scope will be overwritten
1131  // later.
1132  llvm::BasicBlock *CondBlock = createBasicBlock("for.cond");
1133  EmitBlock(CondBlock);
1134 
1135  const SourceRange &R = S.getSourceRange();
1136  LoopStack.push(CondBlock, CGM.getContext(), CGM.getCodeGenOpts(), ForAttrs,
1139 
1140  // If there are any cleanups between here and the loop-exit scope,
1141  // create a block to stage a loop exit along.
1142  llvm::BasicBlock *ExitBlock = LoopExit.getBlock();
1143  if (ForScope.requiresCleanups())
1144  ExitBlock = createBasicBlock("for.cond.cleanup");
1145 
1146  // The loop body, consisting of the specified body and the loop variable.
1147  llvm::BasicBlock *ForBody = createBasicBlock("for.body");
1148 
1149  // The body is executed if the expression, contextually converted
1150  // to bool, is true.
1151  llvm::Value *BoolCondVal = EvaluateExprAsBool(S.getCond());
1152  llvm::MDNode *Weights =
1153  createProfileWeightsForLoop(S.getCond(), getProfileCount(S.getBody()));
1154  if (!Weights && CGM.getCodeGenOpts().OptimizationLevel)
1155  BoolCondVal = emitCondLikelihoodViaExpectIntrinsic(
1156  BoolCondVal, Stmt::getLikelihood(S.getBody()));
1157  Builder.CreateCondBr(BoolCondVal, ForBody, ExitBlock, Weights);
1158 
1159  if (ExitBlock != LoopExit.getBlock()) {
1160  EmitBlock(ExitBlock);
1162  }
1163 
1164  EmitBlock(ForBody);
1166 
1167  // Create a block for the increment. In case of a 'continue', we jump there.
1168  JumpDest Continue = getJumpDestInCurrentScope("for.inc");
1169 
1170  // Store the blocks to use for break and continue.
1171  BreakContinueStack.push_back(BreakContinue(LoopExit, Continue));
1172 
1173  {
1174  // Create a separate cleanup scope for the loop variable and body.
1175  LexicalScope BodyScope(*this, S.getSourceRange());
1176  EmitStmt(S.getLoopVarStmt());
1177  EmitStmt(S.getBody());
1178  }
1179 
1180  EmitStopPoint(&S);
1181  // If there is an increment, emit it next.
1182  EmitBlock(Continue.getBlock());
1183  EmitStmt(S.getInc());
1184 
1185  BreakContinueStack.pop_back();
1186 
1187  EmitBranch(CondBlock);
1188 
1189  ForScope.ForceCleanup();
1190 
1191  LoopStack.pop();
1192 
1193  // Emit the fall-through block.
1194  EmitBlock(LoopExit.getBlock(), true);
1195 }
1196 
1197 void CodeGenFunction::EmitReturnOfRValue(RValue RV, QualType Ty) {
1198  if (RV.isScalar()) {
1200  } else if (RV.isAggregate()) {
1201  LValue Dest = MakeAddrLValue(ReturnValue, Ty);
1202  LValue Src = MakeAddrLValue(RV.getAggregateAddress(), Ty);
1203  EmitAggregateCopy(Dest, Src, Ty, getOverlapForReturnValue());
1204  } else {
1206  /*init*/ true);
1207  }
1209 }
1210 
1211 namespace {
1212 // RAII struct used to save and restore a return statment's result expression.
1213 struct SaveRetExprRAII {
1214  SaveRetExprRAII(const Expr *RetExpr, CodeGenFunction &CGF)
1215  : OldRetExpr(CGF.RetExpr), CGF(CGF) {
1216  CGF.RetExpr = RetExpr;
1217  }
1218  ~SaveRetExprRAII() { CGF.RetExpr = OldRetExpr; }
1219  const Expr *OldRetExpr;
1220  CodeGenFunction &CGF;
1221 };
1222 } // namespace
1223 
1224 /// If we have 'return f(...);', where both caller and callee are SwiftAsync,
1225 /// codegen it as 'tail call ...; ret void;'.
1227  const CGFunctionInfo *CurFnInfo) {
1228  auto calleeQualType = CE->getCallee()->getType();
1229  const FunctionType *calleeType = nullptr;
1230  if (calleeQualType->isFunctionPointerType() ||
1231  calleeQualType->isFunctionReferenceType() ||
1232  calleeQualType->isBlockPointerType() ||
1233  calleeQualType->isMemberFunctionPointerType()) {
1234  calleeType = calleeQualType->getPointeeType()->castAs<FunctionType>();
1235  } else if (auto *ty = dyn_cast<FunctionType>(calleeQualType)) {
1236  calleeType = ty;
1237  } else if (auto CMCE = dyn_cast<CXXMemberCallExpr>(CE)) {
1238  if (auto methodDecl = CMCE->getMethodDecl()) {
1239  // getMethodDecl() doesn't handle member pointers at the moment.
1240  calleeType = methodDecl->getType()->castAs<FunctionType>();
1241  } else {
1242  return;
1243  }
1244  } else {
1245  return;
1246  }
1247  if (calleeType->getCallConv() == CallingConv::CC_SwiftAsync &&
1249  auto CI = cast<llvm::CallInst>(&Builder.GetInsertBlock()->back());
1250  CI->setTailCallKind(llvm::CallInst::TCK_MustTail);
1251  Builder.CreateRetVoid();
1252  Builder.ClearInsertionPoint();
1253  }
1254 }
1255 
1256 /// EmitReturnStmt - Note that due to GCC extensions, this can have an operand
1257 /// if the function returns void, or may be missing one if the function returns
1258 /// non-void. Fun stuff :).
1260  if (requiresReturnValueCheck()) {
1261  llvm::Constant *SLoc = EmitCheckSourceLocation(S.getBeginLoc());
1262  auto *SLocPtr =
1263  new llvm::GlobalVariable(CGM.getModule(), SLoc->getType(), false,
1264  llvm::GlobalVariable::PrivateLinkage, SLoc);
1265  SLocPtr->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
1267  assert(ReturnLocation.isValid() && "No valid return location");
1268  Builder.CreateStore(Builder.CreateBitCast(SLocPtr, Int8PtrTy),
1269  ReturnLocation);
1270  }
1271 
1272  // Returning from an outlined SEH helper is UB, and we already warn on it.
1273  if (IsOutlinedSEHHelper) {
1274  Builder.CreateUnreachable();
1275  Builder.ClearInsertionPoint();
1276  }
1277 
1278  // Emit the result value, even if unused, to evaluate the side effects.
1279  const Expr *RV = S.getRetValue();
1280 
1281  // Record the result expression of the return statement. The recorded
1282  // expression is used to determine whether a block capture's lifetime should
1283  // end at the end of the full expression as opposed to the end of the scope
1284  // enclosing the block expression.
1285  //
1286  // This permits a small, easily-implemented exception to our over-conservative
1287  // rules about not jumping to statements following block literals with
1288  // non-trivial cleanups.
1289  SaveRetExprRAII SaveRetExpr(RV, *this);
1290 
1291  RunCleanupsScope cleanupScope(*this);
1292  if (const auto *EWC = dyn_cast_or_null<ExprWithCleanups>(RV))
1293  RV = EWC->getSubExpr();
1294  // FIXME: Clean this up by using an LValue for ReturnTemp,
1295  // EmitStoreThroughLValue, and EmitAnyExpr.
1296  // Check if the NRVO candidate was not globalized in OpenMP mode.
1297  if (getLangOpts().ElideConstructors && S.getNRVOCandidate() &&
1298  S.getNRVOCandidate()->isNRVOVariable() &&
1299  (!getLangOpts().OpenMP ||
1301  .getAddressOfLocalVariable(*this, S.getNRVOCandidate())
1302  .isValid())) {
1303  // Apply the named return value optimization for this return statement,
1304  // which means doing nothing: the appropriate result has already been
1305  // constructed into the NRVO variable.
1306 
1307  // If there is an NRVO flag for this variable, set it to 1 into indicate
1308  // that the cleanup code should not destroy the variable.
1309  if (llvm::Value *NRVOFlag = NRVOFlags[S.getNRVOCandidate()])
1310  Builder.CreateFlagStore(Builder.getTrue(), NRVOFlag);
1311  } else if (!ReturnValue.isValid() || (RV && RV->getType()->isVoidType())) {
1312  // Make sure not to return anything, but evaluate the expression
1313  // for side effects.
1314  if (RV) {
1315  EmitAnyExpr(RV);
1316  if (auto *CE = dyn_cast<CallExpr>(RV))
1318  }
1319  } else if (!RV) {
1320  // Do nothing (return value is left uninitialized)
1321  } else if (FnRetTy->isReferenceType()) {
1322  // If this function returns a reference, take the address of the expression
1323  // rather than the value.
1324  RValue Result = EmitReferenceBindingToExpr(RV);
1325  Builder.CreateStore(Result.getScalarVal(), ReturnValue);
1326  } else {
1327  switch (getEvaluationKind(RV->getType())) {
1328  case TEK_Scalar:
1330  break;
1331  case TEK_Complex:
1333  /*isInit*/ true);
1334  break;
1335  case TEK_Aggregate:
1342  break;
1343  }
1344  }
1345 
1346  ++NumReturnExprs;
1347  if (!RV || RV->isEvaluatable(getContext()))
1348  ++NumSimpleReturnExprs;
1349 
1350  cleanupScope.ForceCleanup();
1352 }
1353 
1355  // As long as debug info is modeled with instructions, we have to ensure we
1356  // have a place to insert here and write the stop point here.
1357  if (HaveInsertPoint())
1358  EmitStopPoint(&S);
1359 
1360  for (const auto *I : S.decls())
1361  EmitDecl(*I);
1362 }
1363 
1365  assert(!BreakContinueStack.empty() && "break stmt not in a loop or switch!");
1366 
1367  // If this code is reachable then emit a stop point (if generating
1368  // debug info). We have to do this ourselves because we are on the
1369  // "simple" statement path.
1370  if (HaveInsertPoint())
1371  EmitStopPoint(&S);
1372 
1373  EmitBranchThroughCleanup(BreakContinueStack.back().BreakBlock);
1374 }
1375 
1377  assert(!BreakContinueStack.empty() && "continue stmt not in a loop!");
1378 
1379  // If this code is reachable then emit a stop point (if generating
1380  // debug info). We have to do this ourselves because we are on the
1381  // "simple" statement path.
1382  if (HaveInsertPoint())
1383  EmitStopPoint(&S);
1384 
1385  EmitBranchThroughCleanup(BreakContinueStack.back().ContinueBlock);
1386 }
1387 
1388 /// EmitCaseStmtRange - If case statement range is not too big then
1389 /// add multiple cases to switch instruction, one for each value within
1390 /// the range. If range is too big then emit "if" condition check.
1392  ArrayRef<const Attr *> Attrs) {
1393  assert(S.getRHS() && "Expected RHS value in CaseStmt");
1394 
1395  llvm::APSInt LHS = S.getLHS()->EvaluateKnownConstInt(getContext());
1396  llvm::APSInt RHS = S.getRHS()->EvaluateKnownConstInt(getContext());
1397 
1398  // Emit the code for this case. We do this first to make sure it is
1399  // properly chained from our predecessor before generating the
1400  // switch machinery to enter this block.
1401  llvm::BasicBlock *CaseDest = createBasicBlock("sw.bb");
1402  EmitBlockWithFallThrough(CaseDest, &S);
1403  EmitStmt(S.getSubStmt());
1404 
1405  // If range is empty, do nothing.
1406  if (LHS.isSigned() ? RHS.slt(LHS) : RHS.ult(LHS))
1407  return;
1408 
1410  llvm::APInt Range = RHS - LHS;
1411  // FIXME: parameters such as this should not be hardcoded.
1412  if (Range.ult(llvm::APInt(Range.getBitWidth(), 64))) {
1413  // Range is small enough to add multiple switch instruction cases.
1414  uint64_t Total = getProfileCount(&S);
1415  unsigned NCases = Range.getZExtValue() + 1;
1416  // We only have one region counter for the entire set of cases here, so we
1417  // need to divide the weights evenly between the generated cases, ensuring
1418  // that the total weight is preserved. E.g., a weight of 5 over three cases
1419  // will be distributed as weights of 2, 2, and 1.
1420  uint64_t Weight = Total / NCases, Rem = Total % NCases;
1421  for (unsigned I = 0; I != NCases; ++I) {
1422  if (SwitchWeights)
1423  SwitchWeights->push_back(Weight + (Rem ? 1 : 0));
1424  else if (SwitchLikelihood)
1425  SwitchLikelihood->push_back(LH);
1426 
1427  if (Rem)
1428  Rem--;
1429  SwitchInsn->addCase(Builder.getInt(LHS), CaseDest);
1430  ++LHS;
1431  }
1432  return;
1433  }
1434 
1435  // The range is too big. Emit "if" condition into a new block,
1436  // making sure to save and restore the current insertion point.
1437  llvm::BasicBlock *RestoreBB = Builder.GetInsertBlock();
1438 
1439  // Push this test onto the chain of range checks (which terminates
1440  // in the default basic block). The switch's default will be changed
1441  // to the top of this chain after switch emission is complete.
1442  llvm::BasicBlock *FalseDest = CaseRangeBlock;
1443  CaseRangeBlock = createBasicBlock("sw.caserange");
1444 
1445  CurFn->getBasicBlockList().push_back(CaseRangeBlock);
1446  Builder.SetInsertPoint(CaseRangeBlock);
1447 
1448  // Emit range check.
1449  llvm::Value *Diff =
1450  Builder.CreateSub(SwitchInsn->getCondition(), Builder.getInt(LHS));
1451  llvm::Value *Cond =
1452  Builder.CreateICmpULE(Diff, Builder.getInt(Range), "inbounds");
1453 
1454  llvm::MDNode *Weights = nullptr;
1455  if (SwitchWeights) {
1456  uint64_t ThisCount = getProfileCount(&S);
1457  uint64_t DefaultCount = (*SwitchWeights)[0];
1458  Weights = createProfileWeights(ThisCount, DefaultCount);
1459 
1460  // Since we're chaining the switch default through each large case range, we
1461  // need to update the weight for the default, ie, the first case, to include
1462  // this case.
1463  (*SwitchWeights)[0] += ThisCount;
1464  } else if (SwitchLikelihood)
1465  Cond = emitCondLikelihoodViaExpectIntrinsic(Cond, LH);
1466 
1467  Builder.CreateCondBr(Cond, CaseDest, FalseDest, Weights);
1468 
1469  // Restore the appropriate insertion point.
1470  if (RestoreBB)
1471  Builder.SetInsertPoint(RestoreBB);
1472  else
1473  Builder.ClearInsertionPoint();
1474 }
1475 
1477  ArrayRef<const Attr *> Attrs) {
1478  // If there is no enclosing switch instance that we're aware of, then this
1479  // case statement and its block can be elided. This situation only happens
1480  // when we've constant-folded the switch, are emitting the constant case,
1481  // and part of the constant case includes another case statement. For
1482  // instance: switch (4) { case 4: do { case 5: } while (1); }
1483  if (!SwitchInsn) {
1484  EmitStmt(S.getSubStmt());
1485  return;
1486  }
1487 
1488  // Handle case ranges.
1489  if (S.getRHS()) {
1490  EmitCaseStmtRange(S, Attrs);
1491  return;
1492  }
1493 
1494  llvm::ConstantInt *CaseVal =
1495  Builder.getInt(S.getLHS()->EvaluateKnownConstInt(getContext()));
1496  if (SwitchLikelihood)
1497  SwitchLikelihood->push_back(Stmt::getLikelihood(Attrs));
1498 
1499  // If the body of the case is just a 'break', try to not emit an empty block.
1500  // If we're profiling or we're not optimizing, leave the block in for better
1501  // debug and coverage analysis.
1503  CGM.getCodeGenOpts().OptimizationLevel > 0 &&
1504  isa<BreakStmt>(S.getSubStmt())) {
1505  JumpDest Block = BreakContinueStack.back().BreakBlock;
1506 
1507  // Only do this optimization if there are no cleanups that need emitting.
1509  if (SwitchWeights)
1510  SwitchWeights->push_back(getProfileCount(&S));
1511  SwitchInsn->addCase(CaseVal, Block.getBlock());
1512 
1513  // If there was a fallthrough into this case, make sure to redirect it to
1514  // the end of the switch as well.
1515  if (Builder.GetInsertBlock()) {
1516  Builder.CreateBr(Block.getBlock());
1517  Builder.ClearInsertionPoint();
1518  }
1519  return;
1520  }
1521  }
1522 
1523  llvm::BasicBlock *CaseDest = createBasicBlock("sw.bb");
1524  EmitBlockWithFallThrough(CaseDest, &S);
1525  if (SwitchWeights)
1526  SwitchWeights->push_back(getProfileCount(&S));
1527  SwitchInsn->addCase(CaseVal, CaseDest);
1528 
1529  // Recursively emitting the statement is acceptable, but is not wonderful for
1530  // code where we have many case statements nested together, i.e.:
1531  // case 1:
1532  // case 2:
1533  // case 3: etc.
1534  // Handling this recursively will create a new block for each case statement
1535  // that falls through to the next case which is IR intensive. It also causes
1536  // deep recursion which can run into stack depth limitations. Handle
1537  // sequential non-range case statements specially.
1538  //
1539  // TODO When the next case has a likelihood attribute the code returns to the
1540  // recursive algorithm. Maybe improve this case if it becomes common practice
1541  // to use a lot of attributes.
1542  const CaseStmt *CurCase = &S;
1543  const CaseStmt *NextCase = dyn_cast<CaseStmt>(S.getSubStmt());
1544 
1545  // Otherwise, iteratively add consecutive cases to this switch stmt.
1546  while (NextCase && NextCase->getRHS() == nullptr) {
1547  CurCase = NextCase;
1548  llvm::ConstantInt *CaseVal =
1549  Builder.getInt(CurCase->getLHS()->EvaluateKnownConstInt(getContext()));
1550 
1551  if (SwitchWeights)
1552  SwitchWeights->push_back(getProfileCount(NextCase));
1554  CaseDest = createBasicBlock("sw.bb");
1555  EmitBlockWithFallThrough(CaseDest, CurCase);
1556  }
1557  // Since this loop is only executed when the CaseStmt has no attributes
1558  // use a hard-coded value.
1559  if (SwitchLikelihood)
1560  SwitchLikelihood->push_back(Stmt::LH_None);
1561 
1562  SwitchInsn->addCase(CaseVal, CaseDest);
1563  NextCase = dyn_cast<CaseStmt>(CurCase->getSubStmt());
1564  }
1565 
1566  // Generate a stop point for debug info if the case statement is
1567  // followed by a default statement. A fallthrough case before a
1568  // default case gets its own branch target.
1569  if (CurCase->getSubStmt()->getStmtClass() == Stmt::DefaultStmtClass)
1570  EmitStopPoint(CurCase);
1571 
1572  // Normal default recursion for non-cases.
1573  EmitStmt(CurCase->getSubStmt());
1574 }
1575 
1577  ArrayRef<const Attr *> Attrs) {
1578  // If there is no enclosing switch instance that we're aware of, then this
1579  // default statement can be elided. This situation only happens when we've
1580  // constant-folded the switch.
1581  if (!SwitchInsn) {
1582  EmitStmt(S.getSubStmt());
1583  return;
1584  }
1585 
1586  llvm::BasicBlock *DefaultBlock = SwitchInsn->getDefaultDest();
1587  assert(DefaultBlock->empty() &&
1588  "EmitDefaultStmt: Default block already defined?");
1589 
1590  if (SwitchLikelihood)
1591  SwitchLikelihood->front() = Stmt::getLikelihood(Attrs);
1592 
1593  EmitBlockWithFallThrough(DefaultBlock, &S);
1594 
1595  EmitStmt(S.getSubStmt());
1596 }
1597 
1598 /// CollectStatementsForCase - Given the body of a 'switch' statement and a
1599 /// constant value that is being switched on, see if we can dead code eliminate
1600 /// the body of the switch to a simple series of statements to emit. Basically,
1601 /// on a switch (5) we want to find these statements:
1602 /// case 5:
1603 /// printf(...); <--
1604 /// ++i; <--
1605 /// break;
1606 ///
1607 /// and add them to the ResultStmts vector. If it is unsafe to do this
1608 /// transformation (for example, one of the elided statements contains a label
1609 /// that might be jumped to), return CSFC_Failure. If we handled it and 'S'
1610 /// should include statements after it (e.g. the printf() line is a substmt of
1611 /// the case) then return CSFC_FallThrough. If we handled it and found a break
1612 /// statement, then return CSFC_Success.
1613 ///
1614 /// If Case is non-null, then we are looking for the specified case, checking
1615 /// that nothing we jump over contains labels. If Case is null, then we found
1616 /// the case and are looking for the break.
1617 ///
1618 /// If the recursive walk actually finds our Case, then we set FoundCase to
1619 /// true.
1620 ///
1623  const SwitchCase *Case,
1624  bool &FoundCase,
1625  SmallVectorImpl<const Stmt*> &ResultStmts) {
1626  // If this is a null statement, just succeed.
1627  if (!S)
1628  return Case ? CSFC_Success : CSFC_FallThrough;
1629 
1630  // If this is the switchcase (case 4: or default) that we're looking for, then
1631  // we're in business. Just add the substatement.
1632  if (const SwitchCase *SC = dyn_cast<SwitchCase>(S)) {
1633  if (S == Case) {
1634  FoundCase = true;
1635  return CollectStatementsForCase(SC->getSubStmt(), nullptr, FoundCase,
1636  ResultStmts);
1637  }
1638 
1639  // Otherwise, this is some other case or default statement, just ignore it.
1640  return CollectStatementsForCase(SC->getSubStmt(), Case, FoundCase,
1641  ResultStmts);
1642  }
1643 
1644  // If we are in the live part of the code and we found our break statement,
1645  // return a success!
1646  if (!Case && isa<BreakStmt>(S))
1647  return CSFC_Success;
1648 
1649  // If this is a switch statement, then it might contain the SwitchCase, the
1650  // break, or neither.
1651  if (const CompoundStmt *CS = dyn_cast<CompoundStmt>(S)) {
1652  // Handle this as two cases: we might be looking for the SwitchCase (if so
1653  // the skipped statements must be skippable) or we might already have it.
1654  CompoundStmt::const_body_iterator I = CS->body_begin(), E = CS->body_end();
1655  bool StartedInLiveCode = FoundCase;
1656  unsigned StartSize = ResultStmts.size();
1657 
1658  // If we've not found the case yet, scan through looking for it.
1659  if (Case) {
1660  // Keep track of whether we see a skipped declaration. The code could be
1661  // using the declaration even if it is skipped, so we can't optimize out
1662  // the decl if the kept statements might refer to it.
1663  bool HadSkippedDecl = false;
1664 
1665  // If we're looking for the case, just see if we can skip each of the
1666  // substatements.
1667  for (; Case && I != E; ++I) {
1668  HadSkippedDecl |= CodeGenFunction::mightAddDeclToScope(*I);
1669 
1670  switch (CollectStatementsForCase(*I, Case, FoundCase, ResultStmts)) {
1671  case CSFC_Failure: return CSFC_Failure;
1672  case CSFC_Success:
1673  // A successful result means that either 1) that the statement doesn't
1674  // have the case and is skippable, or 2) does contain the case value
1675  // and also contains the break to exit the switch. In the later case,
1676  // we just verify the rest of the statements are elidable.
1677  if (FoundCase) {
1678  // If we found the case and skipped declarations, we can't do the
1679  // optimization.
1680  if (HadSkippedDecl)
1681  return CSFC_Failure;
1682 
1683  for (++I; I != E; ++I)
1684  if (CodeGenFunction::ContainsLabel(*I, true))
1685  return CSFC_Failure;
1686  return CSFC_Success;
1687  }
1688  break;
1689  case CSFC_FallThrough:
1690  // If we have a fallthrough condition, then we must have found the
1691  // case started to include statements. Consider the rest of the
1692  // statements in the compound statement as candidates for inclusion.
1693  assert(FoundCase && "Didn't find case but returned fallthrough?");
1694  // We recursively found Case, so we're not looking for it anymore.
1695  Case = nullptr;
1696 
1697  // If we found the case and skipped declarations, we can't do the
1698  // optimization.
1699  if (HadSkippedDecl)
1700  return CSFC_Failure;
1701  break;
1702  }
1703  }
1704 
1705  if (!FoundCase)
1706  return CSFC_Success;
1707 
1708  assert(!HadSkippedDecl && "fallthrough after skipping decl");
1709  }
1710 
1711  // If we have statements in our range, then we know that the statements are
1712  // live and need to be added to the set of statements we're tracking.
1713  bool AnyDecls = false;
1714  for (; I != E; ++I) {
1715  AnyDecls |= CodeGenFunction::mightAddDeclToScope(*I);
1716 
1717  switch (CollectStatementsForCase(*I, nullptr, FoundCase, ResultStmts)) {
1718  case CSFC_Failure: return CSFC_Failure;
1719  case CSFC_FallThrough:
1720  // A fallthrough result means that the statement was simple and just
1721  // included in ResultStmt, keep adding them afterwards.
1722  break;
1723  case CSFC_Success:
1724  // A successful result means that we found the break statement and
1725  // stopped statement inclusion. We just ensure that any leftover stmts
1726  // are skippable and return success ourselves.
1727  for (++I; I != E; ++I)
1728  if (CodeGenFunction::ContainsLabel(*I, true))
1729  return CSFC_Failure;
1730  return CSFC_Success;
1731  }
1732  }
1733 
1734  // If we're about to fall out of a scope without hitting a 'break;', we
1735  // can't perform the optimization if there were any decls in that scope
1736  // (we'd lose their end-of-lifetime).
1737  if (AnyDecls) {
1738  // If the entire compound statement was live, there's one more thing we
1739  // can try before giving up: emit the whole thing as a single statement.
1740  // We can do that unless the statement contains a 'break;'.
1741  // FIXME: Such a break must be at the end of a construct within this one.
1742  // We could emit this by just ignoring the BreakStmts entirely.
1743  if (StartedInLiveCode && !CodeGenFunction::containsBreak(S)) {
1744  ResultStmts.resize(StartSize);
1745  ResultStmts.push_back(S);
1746  } else {
1747  return CSFC_Failure;
1748  }
1749  }
1750 
1751  return CSFC_FallThrough;
1752  }
1753 
1754  // Okay, this is some other statement that we don't handle explicitly, like a
1755  // for statement or increment etc. If we are skipping over this statement,
1756  // just verify it doesn't have labels, which would make it invalid to elide.
1757  if (Case) {
1758  if (CodeGenFunction::ContainsLabel(S, true))
1759  return CSFC_Failure;
1760  return CSFC_Success;
1761  }
1762 
1763  // Otherwise, we want to include this statement. Everything is cool with that
1764  // so long as it doesn't contain a break out of the switch we're in.
1766 
1767  // Otherwise, everything is great. Include the statement and tell the caller
1768  // that we fall through and include the next statement as well.
1769  ResultStmts.push_back(S);
1770  return CSFC_FallThrough;
1771 }
1772 
1773 /// FindCaseStatementsForValue - Find the case statement being jumped to and
1774 /// then invoke CollectStatementsForCase to find the list of statements to emit
1775 /// for a switch on constant. See the comment above CollectStatementsForCase
1776 /// for more details.
1778  const llvm::APSInt &ConstantCondValue,
1779  SmallVectorImpl<const Stmt*> &ResultStmts,
1780  ASTContext &C,
1781  const SwitchCase *&ResultCase) {
1782  // First step, find the switch case that is being branched to. We can do this
1783  // efficiently by scanning the SwitchCase list.
1784  const SwitchCase *Case = S.getSwitchCaseList();
1785  const DefaultStmt *DefaultCase = nullptr;
1786 
1787  for (; Case; Case = Case->getNextSwitchCase()) {
1788  // It's either a default or case. Just remember the default statement in
1789  // case we're not jumping to any numbered cases.
1790  if (const DefaultStmt *DS = dyn_cast<DefaultStmt>(Case)) {
1791  DefaultCase = DS;
1792  continue;
1793  }
1794 
1795  // Check to see if this case is the one we're looking for.
1796  const CaseStmt *CS = cast<CaseStmt>(Case);
1797  // Don't handle case ranges yet.
1798  if (CS->getRHS()) return false;
1799 
1800  // If we found our case, remember it as 'case'.
1801  if (CS->getLHS()->EvaluateKnownConstInt(C) == ConstantCondValue)
1802  break;
1803  }
1804 
1805  // If we didn't find a matching case, we use a default if it exists, or we
1806  // elide the whole switch body!
1807  if (!Case) {
1808  // It is safe to elide the body of the switch if it doesn't contain labels
1809  // etc. If it is safe, return successfully with an empty ResultStmts list.
1810  if (!DefaultCase)
1811  return !CodeGenFunction::ContainsLabel(&S);
1812  Case = DefaultCase;
1813  }
1814 
1815  // Ok, we know which case is being jumped to, try to collect all the
1816  // statements that follow it. This can fail for a variety of reasons. Also,
1817  // check to see that the recursive walk actually found our case statement.
1818  // Insane cases like this can fail to find it in the recursive walk since we
1819  // don't handle every stmt kind:
1820  // switch (4) {
1821  // while (1) {
1822  // case 4: ...
1823  bool FoundCase = false;
1824  ResultCase = Case;
1825  return CollectStatementsForCase(S.getBody(), Case, FoundCase,
1826  ResultStmts) != CSFC_Failure &&
1827  FoundCase;
1828 }
1829 
1832  // Are there enough branches to weight them?
1833  if (Likelihoods.size() <= 1)
1834  return None;
1835 
1836  uint64_t NumUnlikely = 0;
1837  uint64_t NumNone = 0;
1838  uint64_t NumLikely = 0;
1839  for (const auto LH : Likelihoods) {
1840  switch (LH) {
1841  case Stmt::LH_Unlikely:
1842  ++NumUnlikely;
1843  break;
1844  case Stmt::LH_None:
1845  ++NumNone;
1846  break;
1847  case Stmt::LH_Likely:
1848  ++NumLikely;
1849  break;
1850  }
1851  }
1852 
1853  // Is there a likelihood attribute used?
1854  if (NumUnlikely == 0 && NumLikely == 0)
1855  return None;
1856 
1857  // When multiple cases share the same code they can be combined during
1858  // optimization. In that case the weights of the branch will be the sum of
1859  // the individual weights. Make sure the combined sum of all neutral cases
1860  // doesn't exceed the value of a single likely attribute.
1861  // The additions both avoid divisions by 0 and make sure the weights of None
1862  // don't exceed the weight of Likely.
1863  const uint64_t Likely = INT32_MAX / (NumLikely + 2);
1864  const uint64_t None = Likely / (NumNone + 1);
1865  const uint64_t Unlikely = 0;
1866 
1868  Result.reserve(Likelihoods.size());
1869  for (const auto LH : Likelihoods) {
1870  switch (LH) {
1871  case Stmt::LH_Unlikely:
1872  Result.push_back(Unlikely);
1873  break;
1874  case Stmt::LH_None:
1875  Result.push_back(None);
1876  break;
1877  case Stmt::LH_Likely:
1878  Result.push_back(Likely);
1879  break;
1880  }
1881  }
1882 
1883  return Result;
1884 }
1885 
1887  // Handle nested switch statements.
1888  llvm::SwitchInst *SavedSwitchInsn = SwitchInsn;
1889  SmallVector<uint64_t, 16> *SavedSwitchWeights = SwitchWeights;
1890  SmallVector<Stmt::Likelihood, 16> *SavedSwitchLikelihood = SwitchLikelihood;
1891  llvm::BasicBlock *SavedCRBlock = CaseRangeBlock;
1892 
1893  // See if we can constant fold the condition of the switch and therefore only
1894  // emit the live case statement (if any) of the switch.
1895  llvm::APSInt ConstantCondValue;
1896  if (ConstantFoldsToSimpleInteger(S.getCond(), ConstantCondValue)) {
1897  SmallVector<const Stmt*, 4> CaseStmts;
1898  const SwitchCase *Case = nullptr;
1899  if (FindCaseStatementsForValue(S, ConstantCondValue, CaseStmts,
1900  getContext(), Case)) {
1901  if (Case)
1903  RunCleanupsScope ExecutedScope(*this);
1904 
1905  if (S.getInit())
1906  EmitStmt(S.getInit());
1907 
1908  // Emit the condition variable if needed inside the entire cleanup scope
1909  // used by this special case for constant folded switches.
1910  if (S.getConditionVariable())
1911  EmitDecl(*S.getConditionVariable());
1912 
1913  // At this point, we are no longer "within" a switch instance, so
1914  // we can temporarily enforce this to ensure that any embedded case
1915  // statements are not emitted.
1916  SwitchInsn = nullptr;
1917 
1918  // Okay, we can dead code eliminate everything except this case. Emit the
1919  // specified series of statements and we're good.
1920  for (unsigned i = 0, e = CaseStmts.size(); i != e; ++i)
1921  EmitStmt(CaseStmts[i]);
1923 
1924  // Now we want to restore the saved switch instance so that nested
1925  // switches continue to function properly
1926  SwitchInsn = SavedSwitchInsn;
1927 
1928  return;
1929  }
1930  }
1931 
1932  JumpDest SwitchExit = getJumpDestInCurrentScope("sw.epilog");
1933 
1934  RunCleanupsScope ConditionScope(*this);
1935 
1936  if (S.getInit())
1937  EmitStmt(S.getInit());
1938 
1939  if (S.getConditionVariable())
1940  EmitDecl(*S.getConditionVariable());
1941  llvm::Value *CondV = EmitScalarExpr(S.getCond());
1942 
1943  // Create basic block to hold stuff that comes after switch
1944  // statement. We also need to create a default block now so that
1945  // explicit case ranges tests can have a place to jump to on
1946  // failure.
1947  llvm::BasicBlock *DefaultBlock = createBasicBlock("sw.default");
1948  SwitchInsn = Builder.CreateSwitch(CondV, DefaultBlock);
1949  if (PGO.haveRegionCounts()) {
1950  // Walk the SwitchCase list to find how many there are.
1951  uint64_t DefaultCount = 0;
1952  unsigned NumCases = 0;
1953  for (const SwitchCase *Case = S.getSwitchCaseList();
1954  Case;
1955  Case = Case->getNextSwitchCase()) {
1956  if (isa<DefaultStmt>(Case))
1957  DefaultCount = getProfileCount(Case);
1958  NumCases += 1;
1959  }
1960  SwitchWeights = new SmallVector<uint64_t, 16>();
1961  SwitchWeights->reserve(NumCases);
1962  // The default needs to be first. We store the edge count, so we already
1963  // know the right weight.
1964  SwitchWeights->push_back(DefaultCount);
1965  } else if (CGM.getCodeGenOpts().OptimizationLevel) {
1966  SwitchLikelihood = new SmallVector<Stmt::Likelihood, 16>();
1967  // Initialize the default case.
1968  SwitchLikelihood->push_back(Stmt::LH_None);
1969  }
1970 
1971  CaseRangeBlock = DefaultBlock;
1972 
1973  // Clear the insertion point to indicate we are in unreachable code.
1974  Builder.ClearInsertionPoint();
1975 
1976  // All break statements jump to NextBlock. If BreakContinueStack is non-empty
1977  // then reuse last ContinueBlock.
1978  JumpDest OuterContinue;
1979  if (!BreakContinueStack.empty())
1980  OuterContinue = BreakContinueStack.back().ContinueBlock;
1981 
1982  BreakContinueStack.push_back(BreakContinue(SwitchExit, OuterContinue));
1983 
1984  // Emit switch body.
1985  EmitStmt(S.getBody());
1986 
1987  BreakContinueStack.pop_back();
1988 
1989  // Update the default block in case explicit case range tests have
1990  // been chained on top.
1991  SwitchInsn->setDefaultDest(CaseRangeBlock);
1992 
1993  // If a default was never emitted:
1994  if (!DefaultBlock->getParent()) {
1995  // If we have cleanups, emit the default block so that there's a
1996  // place to jump through the cleanups from.
1997  if (ConditionScope.requiresCleanups()) {
1998  EmitBlock(DefaultBlock);
1999 
2000  // Otherwise, just forward the default block to the switch end.
2001  } else {
2002  DefaultBlock->replaceAllUsesWith(SwitchExit.getBlock());
2003  delete DefaultBlock;
2004  }
2005  }
2006 
2007  ConditionScope.ForceCleanup();
2008 
2009  // Emit continuation.
2010  EmitBlock(SwitchExit.getBlock(), true);
2012 
2013  // If the switch has a condition wrapped by __builtin_unpredictable,
2014  // create metadata that specifies that the switch is unpredictable.
2015  // Don't bother if not optimizing because that metadata would not be used.
2016  auto *Call = dyn_cast<CallExpr>(S.getCond());
2017  if (Call && CGM.getCodeGenOpts().OptimizationLevel != 0) {
2018  auto *FD = dyn_cast_or_null<FunctionDecl>(Call->getCalleeDecl());
2019  if (FD && FD->getBuiltinID() == Builtin::BI__builtin_unpredictable) {
2020  llvm::MDBuilder MDHelper(getLLVMContext());
2021  SwitchInsn->setMetadata(llvm::LLVMContext::MD_unpredictable,
2022  MDHelper.createUnpredictable());
2023  }
2024  }
2025 
2026  if (SwitchWeights) {
2027  assert(SwitchWeights->size() == 1 + SwitchInsn->getNumCases() &&
2028  "switch weights do not match switch cases");
2029  // If there's only one jump destination there's no sense weighting it.
2030  if (SwitchWeights->size() > 1)
2031  SwitchInsn->setMetadata(llvm::LLVMContext::MD_prof,
2032  createProfileWeights(*SwitchWeights));
2033  delete SwitchWeights;
2034  } else if (SwitchLikelihood) {
2035  assert(SwitchLikelihood->size() == 1 + SwitchInsn->getNumCases() &&
2036  "switch likelihoods do not match switch cases");
2038  getLikelihoodWeights(*SwitchLikelihood);
2039  if (LHW) {
2040  llvm::MDBuilder MDHelper(CGM.getLLVMContext());
2041  SwitchInsn->setMetadata(llvm::LLVMContext::MD_prof,
2042  createProfileWeights(*LHW));
2043  }
2044  delete SwitchLikelihood;
2045  }
2046  SwitchInsn = SavedSwitchInsn;
2047  SwitchWeights = SavedSwitchWeights;
2048  SwitchLikelihood = SavedSwitchLikelihood;
2049  CaseRangeBlock = SavedCRBlock;
2050 }
2051 
2052 static std::string
2053 SimplifyConstraint(const char *Constraint, const TargetInfo &Target,
2055  std::string Result;
2056 
2057  while (*Constraint) {
2058  switch (*Constraint) {
2059  default:
2060  Result += Target.convertConstraint(Constraint);
2061  break;
2062  // Ignore these
2063  case '*':
2064  case '?':
2065  case '!':
2066  case '=': // Will see this and the following in mult-alt constraints.
2067  case '+':
2068  break;
2069  case '#': // Ignore the rest of the constraint alternative.
2070  while (Constraint[1] && Constraint[1] != ',')
2071  Constraint++;
2072  break;
2073  case '&':
2074  case '%':
2075  Result += *Constraint;
2076  while (Constraint[1] && Constraint[1] == *Constraint)
2077  Constraint++;
2078  break;
2079  case ',':
2080  Result += "|";
2081  break;
2082  case 'g':
2083  Result += "imr";
2084  break;
2085  case '[': {
2086  assert(OutCons &&
2087  "Must pass output names to constraints with a symbolic name");
2088  unsigned Index;
2089  bool result = Target.resolveSymbolicName(Constraint, *OutCons, Index);
2090  assert(result && "Could not resolve symbolic name"); (void)result;
2091  Result += llvm::utostr(Index);
2092  break;
2093  }
2094  }
2095 
2096  Constraint++;
2097  }
2098 
2099  return Result;
2100 }
2101 
2102 /// AddVariableConstraints - Look at AsmExpr and if it is a variable declared
2103 /// as using a particular register add that as a constraint that will be used
2104 /// in this asm stmt.
2105 static std::string
2106 AddVariableConstraints(const std::string &Constraint, const Expr &AsmExpr,
2108  const AsmStmt &Stmt, const bool EarlyClobber,
2109  std::string *GCCReg = nullptr) {
2110  const DeclRefExpr *AsmDeclRef = dyn_cast<DeclRefExpr>(&AsmExpr);
2111  if (!AsmDeclRef)
2112  return Constraint;
2113  const ValueDecl &Value = *AsmDeclRef->getDecl();
2114  const VarDecl *Variable = dyn_cast<VarDecl>(&Value);
2115  if (!Variable)
2116  return Constraint;
2117  if (Variable->getStorageClass() != SC_Register)
2118  return Constraint;
2119  AsmLabelAttr *Attr = Variable->getAttr<AsmLabelAttr>();
2120  if (!Attr)
2121  return Constraint;
2122  StringRef Register = Attr->getLabel();
2123  assert(Target.isValidGCCRegisterName(Register));
2124  // We're using validateOutputConstraint here because we only care if
2125  // this is a register constraint.
2126  TargetInfo::ConstraintInfo Info(Constraint, "");
2127  if (Target.validateOutputConstraint(Info) &&
2128  !Info.allowsRegister()) {
2129  CGM.ErrorUnsupported(&Stmt, "__asm__");
2130  return Constraint;
2131  }
2132  // Canonicalize the register here before returning it.
2133  Register = Target.getNormalizedGCCRegisterName(Register);
2134  if (GCCReg != nullptr)
2135  *GCCReg = Register.str();
2136  return (EarlyClobber ? "&{" : "{") + Register.str() + "}";
2137 }
2138 
2139 std::pair<llvm::Value*, llvm::Type *> CodeGenFunction::EmitAsmInputLValue(
2140  const TargetInfo::ConstraintInfo &Info, LValue InputValue,
2141  QualType InputType, std::string &ConstraintStr, SourceLocation Loc) {
2142  if (Info.allowsRegister() || !Info.allowsMemory()) {
2144  return {EmitLoadOfLValue(InputValue, Loc).getScalarVal(), nullptr};
2145 
2146  llvm::Type *Ty = ConvertType(InputType);
2147  uint64_t Size = CGM.getDataLayout().getTypeSizeInBits(Ty);
2148  if ((Size <= 64 && llvm::isPowerOf2_64(Size)) ||
2149  getTargetHooks().isScalarizableAsmOperand(*this, Ty)) {
2150  Ty = llvm::IntegerType::get(getLLVMContext(), Size);
2151 
2153  InputValue.getAddress(*this), Ty)),
2154  nullptr};
2155  }
2156  }
2157 
2158  Address Addr = InputValue.getAddress(*this);
2159  ConstraintStr += '*';
2160  return {Addr.getPointer(), Addr.getElementType()};
2161 }
2162 
2163 std::pair<llvm::Value *, llvm::Type *>
2164 CodeGenFunction::EmitAsmInput(const TargetInfo::ConstraintInfo &Info,
2165  const Expr *InputExpr,
2166  std::string &ConstraintStr) {
2167  // If this can't be a register or memory, i.e., has to be a constant
2168  // (immediate or symbolic), try to emit it as such.
2169  if (!Info.allowsRegister() && !Info.allowsMemory()) {
2170  if (Info.requiresImmediateConstant()) {
2171  Expr::EvalResult EVResult;
2172  InputExpr->EvaluateAsRValue(EVResult, getContext(), true);
2173 
2174  llvm::APSInt IntResult;
2175  if (EVResult.Val.toIntegralConstant(IntResult, InputExpr->getType(),
2176  getContext()))
2177  return {llvm::ConstantInt::get(getLLVMContext(), IntResult), nullptr};
2178  }
2179 
2180  Expr::EvalResult Result;
2181  if (InputExpr->EvaluateAsInt(Result, getContext()))
2182  return {llvm::ConstantInt::get(getLLVMContext(), Result.Val.getInt()),
2183  nullptr};
2184  }
2185 
2186  if (Info.allowsRegister() || !Info.allowsMemory())
2188  return {EmitScalarExpr(InputExpr), nullptr};
2189  if (InputExpr->getStmtClass() == Expr::CXXThisExprClass)
2190  return {EmitScalarExpr(InputExpr), nullptr};
2191  InputExpr = InputExpr->IgnoreParenNoopCasts(getContext());
2192  LValue Dest = EmitLValue(InputExpr);
2193  return EmitAsmInputLValue(Info, Dest, InputExpr->getType(), ConstraintStr,
2194  InputExpr->getExprLoc());
2195 }
2196 
2197 /// getAsmSrcLocInfo - Return the !srcloc metadata node to attach to an inline
2198 /// asm call instruction. The !srcloc MDNode contains a list of constant
2199 /// integers which are the source locations of the start of each line in the
2200 /// asm.
2201 static llvm::MDNode *getAsmSrcLocInfo(const StringLiteral *Str,
2202  CodeGenFunction &CGF) {
2204  // Add the location of the first line to the MDNode.
2205  Locs.push_back(llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
2206  CGF.Int64Ty, Str->getBeginLoc().getRawEncoding())));
2207  StringRef StrVal = Str->getString();
2208  if (!StrVal.empty()) {
2209  const SourceManager &SM = CGF.CGM.getContext().getSourceManager();
2210  const LangOptions &LangOpts = CGF.CGM.getLangOpts();
2211  unsigned StartToken = 0;
2212  unsigned ByteOffset = 0;
2213 
2214  // Add the location of the start of each subsequent line of the asm to the
2215  // MDNode.
2216  for (unsigned i = 0, e = StrVal.size() - 1; i != e; ++i) {
2217  if (StrVal[i] != '\n') continue;
2218  SourceLocation LineLoc = Str->getLocationOfByte(
2219  i + 1, SM, LangOpts, CGF.getTarget(), &StartToken, &ByteOffset);
2220  Locs.push_back(llvm::ConstantAsMetadata::get(
2221  llvm::ConstantInt::get(CGF.Int64Ty, LineLoc.getRawEncoding())));
2222  }
2223  }
2224 
2225  return llvm::MDNode::get(CGF.getLLVMContext(), Locs);
2226 }
2227 
2228 static void UpdateAsmCallInst(llvm::CallBase &Result, bool HasSideEffect,
2229  bool HasUnwindClobber, bool ReadOnly,
2230  bool ReadNone, bool NoMerge, const AsmStmt &S,
2231  const std::vector<llvm::Type *> &ResultRegTypes,
2232  const std::vector<llvm::Type *> &ArgElemTypes,
2233  CodeGenFunction &CGF,
2234  std::vector<llvm::Value *> &RegResults) {
2235  if (!HasUnwindClobber)
2236  Result.addFnAttr(llvm::Attribute::NoUnwind);
2237 
2238  if (NoMerge)
2239  Result.addFnAttr(llvm::Attribute::NoMerge);
2240  // Attach readnone and readonly attributes.
2241  if (!HasSideEffect) {
2242  if (ReadNone)
2243  Result.addFnAttr(llvm::Attribute::ReadNone);
2244  else if (ReadOnly)
2245  Result.addFnAttr(llvm::Attribute::ReadOnly);
2246  }
2247 
2248  // Add elementtype attribute for indirect constraints.
2249  for (auto Pair : llvm::enumerate(ArgElemTypes)) {
2250  if (Pair.value()) {
2251  auto Attr = llvm::Attribute::get(
2252  CGF.getLLVMContext(), llvm::Attribute::ElementType, Pair.value());
2253  Result.addParamAttr(Pair.index(), Attr);
2254  }
2255  }
2256 
2257  // Slap the source location of the inline asm into a !srcloc metadata on the
2258  // call.
2259  if (const auto *gccAsmStmt = dyn_cast<GCCAsmStmt>(&S))
2260  Result.setMetadata("srcloc",
2261  getAsmSrcLocInfo(gccAsmStmt->getAsmString(), CGF));
2262  else {
2263  // At least put the line number on MS inline asm blobs.
2264  llvm::Constant *Loc =
2265  llvm::ConstantInt::get(CGF.Int64Ty, S.getAsmLoc().getRawEncoding());
2266  Result.setMetadata("srcloc",
2267  llvm::MDNode::get(CGF.getLLVMContext(),
2268  llvm::ConstantAsMetadata::get(Loc)));
2269  }
2270 
2272  // Conservatively, mark all inline asm blocks in CUDA or OpenCL as
2273  // convergent (meaning, they may call an intrinsically convergent op, such
2274  // as bar.sync, and so can't have certain optimizations applied around
2275  // them).
2276  Result.addFnAttr(llvm::Attribute::Convergent);
2277  // Extract all of the register value results from the asm.
2278  if (ResultRegTypes.size() == 1) {
2279  RegResults.push_back(&Result);
2280  } else {
2281  for (unsigned i = 0, e = ResultRegTypes.size(); i != e; ++i) {
2282  llvm::Value *Tmp = CGF.Builder.CreateExtractValue(&Result, i, "asmresult");
2283  RegResults.push_back(Tmp);
2284  }
2285  }
2286 }
2287 
2289  // Assemble the final asm string.
2290  std::string AsmString = S.generateAsmString(getContext());
2291 
2292  // Get all the output and input constraints together.
2293  SmallVector<TargetInfo::ConstraintInfo, 4> OutputConstraintInfos;
2294  SmallVector<TargetInfo::ConstraintInfo, 4> InputConstraintInfos;
2295 
2296  for (unsigned i = 0, e = S.getNumOutputs(); i != e; i++) {
2297  StringRef Name;
2298  if (const GCCAsmStmt *GAS = dyn_cast<GCCAsmStmt>(&S))
2299  Name = GAS->getOutputName(i);
2300  TargetInfo::ConstraintInfo Info(S.getOutputConstraint(i), Name);
2301  bool IsValid = getTarget().validateOutputConstraint(Info); (void)IsValid;
2302  assert(IsValid && "Failed to parse output constraint");
2303  OutputConstraintInfos.push_back(Info);
2304  }
2305 
2306  for (unsigned i = 0, e = S.getNumInputs(); i != e; i++) {
2307  StringRef Name;
2308  if (const GCCAsmStmt *GAS = dyn_cast<GCCAsmStmt>(&S))
2309  Name = GAS->getInputName(i);
2310  TargetInfo::ConstraintInfo Info(S.getInputConstraint(i), Name);
2311  bool IsValid =
2312  getTarget().validateInputConstraint(OutputConstraintInfos, Info);
2313  assert(IsValid && "Failed to parse input constraint"); (void)IsValid;
2314  InputConstraintInfos.push_back(Info);
2315  }
2316 
2317  std::string Constraints;
2318 
2319  std::vector<LValue> ResultRegDests;
2320  std::vector<QualType> ResultRegQualTys;
2321  std::vector<llvm::Type *> ResultRegTypes;
2322  std::vector<llvm::Type *> ResultTruncRegTypes;
2323  std::vector<llvm::Type *> ArgTypes;
2324  std::vector<llvm::Type *> ArgElemTypes;
2325  std::vector<llvm::Value*> Args;
2326  llvm::BitVector ResultTypeRequiresCast;
2327 
2328  // Keep track of inout constraints.
2329  std::string InOutConstraints;
2330  std::vector<llvm::Value*> InOutArgs;
2331  std::vector<llvm::Type*> InOutArgTypes;
2332  std::vector<llvm::Type*> InOutArgElemTypes;
2333 
2334  // Keep track of out constraints for tied input operand.
2335  std::vector<std::string> OutputConstraints;
2336 
2337  // Keep track of defined physregs.
2338  llvm::SmallSet<std::string, 8> PhysRegOutputs;
2339 
2340  // An inline asm can be marked readonly if it meets the following conditions:
2341  // - it doesn't have any sideeffects
2342  // - it doesn't clobber memory
2343  // - it doesn't return a value by-reference
2344  // It can be marked readnone if it doesn't have any input memory constraints
2345  // in addition to meeting the conditions listed above.
2346  bool ReadOnly = true, ReadNone = true;
2347 
2348  for (unsigned i = 0, e = S.getNumOutputs(); i != e; i++) {
2349  TargetInfo::ConstraintInfo &Info = OutputConstraintInfos[i];
2350 
2351  // Simplify the output constraint.
2352  std::string OutputConstraint(S.getOutputConstraint(i));
2353  OutputConstraint = SimplifyConstraint(OutputConstraint.c_str() + 1,
2354  getTarget(), &OutputConstraintInfos);
2355 
2356  const Expr *OutExpr = S.getOutputExpr(i);
2357  OutExpr = OutExpr->IgnoreParenNoopCasts(getContext());
2358 
2359  std::string GCCReg;
2360  OutputConstraint = AddVariableConstraints(OutputConstraint, *OutExpr,
2361  getTarget(), CGM, S,
2362  Info.earlyClobber(),
2363  &GCCReg);
2364  // Give an error on multiple outputs to same physreg.
2365  if (!GCCReg.empty() && !PhysRegOutputs.insert(GCCReg).second)
2366  CGM.Error(S.getAsmLoc(), "multiple outputs to hard register: " + GCCReg);
2367 
2368  OutputConstraints.push_back(OutputConstraint);
2369  LValue Dest = EmitLValue(OutExpr);
2370  if (!Constraints.empty())
2371  Constraints += ',';
2372 
2373  // If this is a register output, then make the inline asm return it
2374  // by-value. If this is a memory result, return the value by-reference.
2375  QualType QTy = OutExpr->getType();
2376  const bool IsScalarOrAggregate = hasScalarEvaluationKind(QTy) ||
2378  if (!Info.allowsMemory() && IsScalarOrAggregate) {
2379 
2380  Constraints += "=" + OutputConstraint;
2381  ResultRegQualTys.push_back(QTy);
2382  ResultRegDests.push_back(Dest);
2383 
2384  llvm::Type *Ty = ConvertTypeForMem(QTy);
2385  const bool RequiresCast = Info.allowsRegister() &&
2386  (getTargetHooks().isScalarizableAsmOperand(*this, Ty) ||
2387  Ty->isAggregateType());
2388 
2389  ResultTruncRegTypes.push_back(Ty);
2390  ResultTypeRequiresCast.push_back(RequiresCast);
2391 
2392  if (RequiresCast) {
2393  unsigned Size = getContext().getTypeSize(QTy);
2394  Ty = llvm::IntegerType::get(getLLVMContext(), Size);
2395  }
2396  ResultRegTypes.push_back(Ty);
2397  // If this output is tied to an input, and if the input is larger, then
2398  // we need to set the actual result type of the inline asm node to be the
2399  // same as the input type.
2400  if (Info.hasMatchingInput()) {
2401  unsigned InputNo;
2402  for (InputNo = 0; InputNo != S.getNumInputs(); ++InputNo) {
2403  TargetInfo::ConstraintInfo &Input = InputConstraintInfos[InputNo];
2404  if (Input.hasTiedOperand() && Input.getTiedOperand() == i)
2405  break;
2406  }
2407  assert(InputNo != S.getNumInputs() && "Didn't find matching input!");
2408 
2409  QualType InputTy = S.getInputExpr(InputNo)->getType();
2410  QualType OutputType = OutExpr->getType();
2411 
2412  uint64_t InputSize = getContext().getTypeSize(InputTy);
2413  if (getContext().getTypeSize(OutputType) < InputSize) {
2414  // Form the asm to return the value as a larger integer or fp type.
2415  ResultRegTypes.back() = ConvertType(InputTy);
2416  }
2417  }
2418  if (llvm::Type* AdjTy =
2419  getTargetHooks().adjustInlineAsmType(*this, OutputConstraint,
2420  ResultRegTypes.back()))
2421  ResultRegTypes.back() = AdjTy;
2422  else {
2423  CGM.getDiags().Report(S.getAsmLoc(),
2424  diag::err_asm_invalid_type_in_input)
2425  << OutExpr->getType() << OutputConstraint;
2426  }
2427 
2428  // Update largest vector width for any vector types.
2429  if (auto *VT = dyn_cast<llvm::VectorType>(ResultRegTypes.back()))
2430  LargestVectorWidth =
2431  std::max((uint64_t)LargestVectorWidth,
2432  VT->getPrimitiveSizeInBits().getKnownMinSize());
2433  } else {
2434  Address DestAddr = Dest.getAddress(*this);
2435  // Matrix types in memory are represented by arrays, but accessed through
2436  // vector pointers, with the alignment specified on the access operation.
2437  // For inline assembly, update pointer arguments to use vector pointers.
2438  // Otherwise there will be a mis-match if the matrix is also an
2439  // input-argument which is represented as vector.
2440  if (isa<MatrixType>(OutExpr->getType().getCanonicalType()))
2441  DestAddr = Builder.CreateElementBitCast(
2442  DestAddr, ConvertType(OutExpr->getType()));
2443 
2444  ArgTypes.push_back(DestAddr.getType());
2445  ArgElemTypes.push_back(DestAddr.getElementType());
2446  Args.push_back(DestAddr.getPointer());
2447  Constraints += "=*";
2448  Constraints += OutputConstraint;
2449  ReadOnly = ReadNone = false;
2450  }
2451 
2452  if (Info.isReadWrite()) {
2453  InOutConstraints += ',';
2454 
2455  const Expr *InputExpr = S.getOutputExpr(i);
2456  llvm::Value *Arg;
2457  llvm::Type *ArgElemType;
2458  std::tie(Arg, ArgElemType) = EmitAsmInputLValue(
2459  Info, Dest, InputExpr->getType(), InOutConstraints,
2460  InputExpr->getExprLoc());
2461 
2462  if (llvm::Type* AdjTy =
2463  getTargetHooks().adjustInlineAsmType(*this, OutputConstraint,
2464  Arg->getType()))
2465  Arg = Builder.CreateBitCast(Arg, AdjTy);
2466 
2467  // Update largest vector width for any vector types.
2468  if (auto *VT = dyn_cast<llvm::VectorType>(Arg->getType()))
2469  LargestVectorWidth =
2470  std::max((uint64_t)LargestVectorWidth,
2471  VT->getPrimitiveSizeInBits().getKnownMinSize());
2472  // Only tie earlyclobber physregs.
2473  if (Info.allowsRegister() && (GCCReg.empty() || Info.earlyClobber()))
2474  InOutConstraints += llvm::utostr(i);
2475  else
2476  InOutConstraints += OutputConstraint;
2477 
2478  InOutArgTypes.push_back(Arg->getType());
2479  InOutArgElemTypes.push_back(ArgElemType);
2480  InOutArgs.push_back(Arg);
2481  }
2482  }
2483 
2484  // If this is a Microsoft-style asm blob, store the return registers (EAX:EDX)
2485  // to the return value slot. Only do this when returning in registers.
2486  if (isa<MSAsmStmt>(&S)) {
2487  const ABIArgInfo &RetAI = CurFnInfo->getReturnInfo();
2488  if (RetAI.isDirect() || RetAI.isExtend()) {
2489  // Make a fake lvalue for the return value slot.
2492  *this, ReturnSlot, Constraints, ResultRegTypes, ResultTruncRegTypes,
2493  ResultRegDests, AsmString, S.getNumOutputs());
2494  SawAsmBlock = true;
2495  }
2496  }
2497 
2498  for (unsigned i = 0, e = S.getNumInputs(); i != e; i++) {
2499  const Expr *InputExpr = S.getInputExpr(i);
2500 
2501  TargetInfo::ConstraintInfo &Info = InputConstraintInfos[i];
2502 
2503  if (Info.allowsMemory())
2504  ReadNone = false;
2505 
2506  if (!Constraints.empty())
2507  Constraints += ',';
2508 
2509  // Simplify the input constraint.
2510  std::string InputConstraint(S.getInputConstraint(i));
2511  InputConstraint = SimplifyConstraint(InputConstraint.c_str(), getTarget(),
2512  &OutputConstraintInfos);
2513 
2514  InputConstraint = AddVariableConstraints(
2515  InputConstraint, *InputExpr->IgnoreParenNoopCasts(getContext()),
2516  getTarget(), CGM, S, false /* No EarlyClobber */);
2517 
2518  std::string ReplaceConstraint (InputConstraint);
2519  llvm::Value *Arg;
2520  llvm::Type *ArgElemType;
2521  std::tie(Arg, ArgElemType) = EmitAsmInput(Info, InputExpr, Constraints);
2522 
2523  // If this input argument is tied to a larger output result, extend the
2524  // input to be the same size as the output. The LLVM backend wants to see
2525  // the input and output of a matching constraint be the same size. Note
2526  // that GCC does not define what the top bits are here. We use zext because
2527  // that is usually cheaper, but LLVM IR should really get an anyext someday.
2528  if (Info.hasTiedOperand()) {
2529  unsigned Output = Info.getTiedOperand();
2530  QualType OutputType = S.getOutputExpr(Output)->getType();
2531  QualType InputTy = InputExpr->getType();
2532 
2533  if (getContext().getTypeSize(OutputType) >
2534  getContext().getTypeSize(InputTy)) {
2535  // Use ptrtoint as appropriate so that we can do our extension.
2536  if (isa<llvm::PointerType>(Arg->getType()))
2537  Arg = Builder.CreatePtrToInt(Arg, IntPtrTy);
2538  llvm::Type *OutputTy = ConvertType(OutputType);
2539  if (isa<llvm::IntegerType>(OutputTy))
2540  Arg = Builder.CreateZExt(Arg, OutputTy);
2541  else if (isa<llvm::PointerType>(OutputTy))
2542  Arg = Builder.CreateZExt(Arg, IntPtrTy);
2543  else if (OutputTy->isFloatingPointTy())
2544  Arg = Builder.CreateFPExt(Arg, OutputTy);
2545  }
2546  // Deal with the tied operands' constraint code in adjustInlineAsmType.
2547  ReplaceConstraint = OutputConstraints[Output];
2548  }
2549  if (llvm::Type* AdjTy =
2550  getTargetHooks().adjustInlineAsmType(*this, ReplaceConstraint,
2551  Arg->getType()))
2552  Arg = Builder.CreateBitCast(Arg, AdjTy);
2553  else
2554  CGM.getDiags().Report(S.getAsmLoc(), diag::err_asm_invalid_type_in_input)
2555  << InputExpr->getType() << InputConstraint;
2556 
2557  // Update largest vector width for any vector types.
2558  if (auto *VT = dyn_cast<llvm::VectorType>(Arg->getType()))
2559  LargestVectorWidth =
2560  std::max((uint64_t)LargestVectorWidth,
2561  VT->getPrimitiveSizeInBits().getKnownMinSize());
2562 
2563  ArgTypes.push_back(Arg->getType());
2564  ArgElemTypes.push_back(ArgElemType);
2565  Args.push_back(Arg);
2566  Constraints += InputConstraint;
2567  }
2568 
2569  // Append the "input" part of inout constraints.
2570  for (unsigned i = 0, e = InOutArgs.size(); i != e; i++) {
2571  ArgTypes.push_back(InOutArgTypes[i]);
2572  ArgElemTypes.push_back(InOutArgElemTypes[i]);
2573  Args.push_back(InOutArgs[i]);
2574  }
2575  Constraints += InOutConstraints;
2576 
2577  // Labels
2579  llvm::BasicBlock *Fallthrough = nullptr;
2580  bool IsGCCAsmGoto = false;
2581  if (const auto *GS = dyn_cast<GCCAsmStmt>(&S)) {
2582  IsGCCAsmGoto = GS->isAsmGoto();
2583  if (IsGCCAsmGoto) {
2584  for (const auto *E : GS->labels()) {
2585  JumpDest Dest = getJumpDestForLabel(E->getLabel());
2586  Transfer.push_back(Dest.getBlock());
2587  llvm::BlockAddress *BA =
2588  llvm::BlockAddress::get(CurFn, Dest.getBlock());
2589  Args.push_back(BA);
2590  ArgTypes.push_back(BA->getType());
2591  ArgElemTypes.push_back(nullptr);
2592  if (!Constraints.empty())
2593  Constraints += ',';
2594  Constraints += 'i';
2595  }
2596  Fallthrough = createBasicBlock("asm.fallthrough");
2597  }
2598  }
2599 
2600  bool HasUnwindClobber = false;
2601 
2602  // Clobbers
2603  for (unsigned i = 0, e = S.getNumClobbers(); i != e; i++) {
2604  StringRef Clobber = S.getClobber(i);
2605 
2606  if (Clobber == "memory")
2607  ReadOnly = ReadNone = false;
2608  else if (Clobber == "unwind") {
2609  HasUnwindClobber = true;
2610  continue;
2611  } else if (Clobber != "cc") {
2612  Clobber = getTarget().getNormalizedGCCRegisterName(Clobber);
2613  if (CGM.getCodeGenOpts().StackClashProtector &&
2614  getTarget().isSPRegName(Clobber)) {
2615  CGM.getDiags().Report(S.getAsmLoc(),
2616  diag::warn_stack_clash_protection_inline_asm);
2617  }
2618  }
2619 
2620  if (isa<MSAsmStmt>(&S)) {
2621  if (Clobber == "eax" || Clobber == "edx") {
2622  if (Constraints.find("=&A") != std::string::npos)
2623  continue;
2624  std::string::size_type position1 =
2625  Constraints.find("={" + Clobber.str() + "}");
2626  if (position1 != std::string::npos) {
2627  Constraints.insert(position1 + 1, "&");
2628  continue;
2629  }
2630  std::string::size_type position2 = Constraints.find("=A");
2631  if (position2 != std::string::npos) {
2632  Constraints.insert(position2 + 1, "&");
2633  continue;
2634  }
2635  }
2636  }
2637  if (!Constraints.empty())
2638  Constraints += ',';
2639 
2640  Constraints += "~{";
2641  Constraints += Clobber;
2642  Constraints += '}';
2643  }
2644 
2645  assert(!(HasUnwindClobber && IsGCCAsmGoto) &&
2646  "unwind clobber can't be used with asm goto");
2647 
2648  // Add machine specific clobbers
2649  std::string MachineClobbers = getTarget().getClobbers();
2650  if (!MachineClobbers.empty()) {
2651  if (!Constraints.empty())
2652  Constraints += ',';
2653  Constraints += MachineClobbers;
2654  }
2655 
2656  llvm::Type *ResultType;
2657  if (ResultRegTypes.empty())
2658  ResultType = VoidTy;
2659  else if (ResultRegTypes.size() == 1)
2660  ResultType = ResultRegTypes[0];
2661  else
2662  ResultType = llvm::StructType::get(getLLVMContext(), ResultRegTypes);
2663 
2664  llvm::FunctionType *FTy =
2665  llvm::FunctionType::get(ResultType, ArgTypes, false);
2666 
2667  bool HasSideEffect = S.isVolatile() || S.getNumOutputs() == 0;
2668 
2669  llvm::InlineAsm::AsmDialect GnuAsmDialect =
2670  CGM.getCodeGenOpts().getInlineAsmDialect() == CodeGenOptions::IAD_ATT
2671  ? llvm::InlineAsm::AD_ATT
2672  : llvm::InlineAsm::AD_Intel;
2673  llvm::InlineAsm::AsmDialect AsmDialect = isa<MSAsmStmt>(&S) ?
2674  llvm::InlineAsm::AD_Intel : GnuAsmDialect;
2675 
2676  llvm::InlineAsm *IA = llvm::InlineAsm::get(
2677  FTy, AsmString, Constraints, HasSideEffect,
2678  /* IsAlignStack */ false, AsmDialect, HasUnwindClobber);
2679  std::vector<llvm::Value*> RegResults;
2680  if (IsGCCAsmGoto) {
2681  llvm::CallBrInst *Result =
2682  Builder.CreateCallBr(IA, Fallthrough, Transfer, Args);
2683  EmitBlock(Fallthrough);
2684  UpdateAsmCallInst(cast<llvm::CallBase>(*Result), HasSideEffect, false,
2685  ReadOnly, ReadNone, InNoMergeAttributedStmt, S,
2686  ResultRegTypes, ArgElemTypes, *this, RegResults);
2687  } else if (HasUnwindClobber) {
2688  llvm::CallBase *Result = EmitCallOrInvoke(IA, Args, "");
2689  UpdateAsmCallInst(*Result, HasSideEffect, true, ReadOnly, ReadNone,
2690  InNoMergeAttributedStmt, S, ResultRegTypes, ArgElemTypes,
2691  *this, RegResults);
2692  } else {
2693  llvm::CallInst *Result =
2694  Builder.CreateCall(IA, Args, getBundlesForFunclet(IA));
2695  UpdateAsmCallInst(cast<llvm::CallBase>(*Result), HasSideEffect, false,
2696  ReadOnly, ReadNone, InNoMergeAttributedStmt, S,
2697  ResultRegTypes, ArgElemTypes, *this, RegResults);
2698  }
2699 
2700  assert(RegResults.size() == ResultRegTypes.size());
2701  assert(RegResults.size() == ResultTruncRegTypes.size());
2702  assert(RegResults.size() == ResultRegDests.size());
2703  // ResultRegDests can be also populated by addReturnRegisterOutputs() above,
2704  // in which case its size may grow.
2705  assert(ResultTypeRequiresCast.size() <= ResultRegDests.size());
2706  for (unsigned i = 0, e = RegResults.size(); i != e; ++i) {
2707  llvm::Value *Tmp = RegResults[i];
2708  llvm::Type *TruncTy = ResultTruncRegTypes[i];
2709 
2710  // If the result type of the LLVM IR asm doesn't match the result type of
2711  // the expression, do the conversion.
2712  if (ResultRegTypes[i] != ResultTruncRegTypes[i]) {
2713 
2714  // Truncate the integer result to the right size, note that TruncTy can be
2715  // a pointer.
2716  if (TruncTy->isFloatingPointTy())
2717  Tmp = Builder.CreateFPTrunc(Tmp, TruncTy);
2718  else if (TruncTy->isPointerTy() && Tmp->getType()->isIntegerTy()) {
2719  uint64_t ResSize = CGM.getDataLayout().getTypeSizeInBits(TruncTy);
2720  Tmp = Builder.CreateTrunc(Tmp,
2721  llvm::IntegerType::get(getLLVMContext(), (unsigned)ResSize));
2722  Tmp = Builder.CreateIntToPtr(Tmp, TruncTy);
2723  } else if (Tmp->getType()->isPointerTy() && TruncTy->isIntegerTy()) {
2724  uint64_t TmpSize =CGM.getDataLayout().getTypeSizeInBits(Tmp->getType());
2725  Tmp = Builder.CreatePtrToInt(Tmp,
2726  llvm::IntegerType::get(getLLVMContext(), (unsigned)TmpSize));
2727  Tmp = Builder.CreateTrunc(Tmp, TruncTy);
2728  } else if (TruncTy->isIntegerTy()) {
2729  Tmp = Builder.CreateZExtOrTrunc(Tmp, TruncTy);
2730  } else if (TruncTy->isVectorTy()) {
2731  Tmp = Builder.CreateBitCast(Tmp, TruncTy);
2732  }
2733  }
2734 
2735  LValue Dest = ResultRegDests[i];
2736  // ResultTypeRequiresCast elements correspond to the first
2737  // ResultTypeRequiresCast.size() elements of RegResults.
2738  if ((i < ResultTypeRequiresCast.size()) && ResultTypeRequiresCast[i]) {
2739  unsigned Size = getContext().getTypeSize(ResultRegQualTys[i]);
2741  ResultRegTypes[i]);
2742  if (getTargetHooks().isScalarizableAsmOperand(*this, TruncTy)) {
2743  Builder.CreateStore(Tmp, A);
2744  continue;
2745  }
2746 
2747  QualType Ty = getContext().getIntTypeForBitwidth(Size, /*Signed*/ false);
2748  if (Ty.isNull()) {
2749  const Expr *OutExpr = S.getOutputExpr(i);
2750  CGM.getDiags().Report(OutExpr->getExprLoc(),
2751  diag::err_store_value_to_reg);
2752  return;
2753  }
2754  Dest = MakeAddrLValue(A, Ty);
2755  }
2756  EmitStoreThroughLValue(RValue::get(Tmp), Dest);
2757  }
2758 }
2759 
2761  const RecordDecl *RD = S.getCapturedRecordDecl();
2762  QualType RecordTy = getContext().getRecordType(RD);
2763 
2764  // Initialize the captured struct.
2765  LValue SlotLV =
2766  MakeAddrLValue(CreateMemTemp(RecordTy, "agg.captured"), RecordTy);
2767 
2768  RecordDecl::field_iterator CurField = RD->field_begin();
2769  for (CapturedStmt::const_capture_init_iterator I = S.capture_init_begin(),
2770  E = S.capture_init_end();
2771  I != E; ++I, ++CurField) {
2772  LValue LV = EmitLValueForFieldInitialization(SlotLV, *CurField);
2773  if (CurField->hasCapturedVLAType()) {
2774  EmitLambdaVLACapture(CurField->getCapturedVLAType(), LV);
2775  } else {
2776  EmitInitializerForField(*CurField, LV, *I);
2777  }
2778  }
2779 
2780  return SlotLV;
2781 }
2782 
2783 /// Generate an outlined function for the body of a CapturedStmt, store any
2784 /// captured variables into the captured struct, and call the outlined function.
2785 llvm::Function *
2787  LValue CapStruct = InitCapturedStruct(S);
2788 
2789  // Emit the CapturedDecl
2790  CodeGenFunction CGF(CGM, true);
2791  CGCapturedStmtRAII CapInfoRAII(CGF, new CGCapturedStmtInfo(S, K));
2792  llvm::Function *F = CGF.GenerateCapturedStmtFunction(S);
2793  delete CGF.CapturedStmtInfo;
2794 
2795  // Emit call to the helper function.
2796  EmitCallOrInvoke(F, CapStruct.getPointer(*this));
2797 
2798  return F;
2799 }
2800 
2802  LValue CapStruct = InitCapturedStruct(S);
2803  return CapStruct.getAddress(*this);
2804 }
2805 
2806 /// Creates the outlined function for a CapturedStmt.
2807 llvm::Function *
2809  assert(CapturedStmtInfo &&
2810  "CapturedStmtInfo should be set when generating the captured function");
2811  const CapturedDecl *CD = S.getCapturedDecl();
2812  const RecordDecl *RD = S.getCapturedRecordDecl();
2813  SourceLocation Loc = S.getBeginLoc();
2814  assert(CD->hasBody() && "missing CapturedDecl body");
2815 
2816  // Build the argument list.
2817  ASTContext &Ctx = CGM.getContext();
2818  FunctionArgList Args;
2819  Args.append(CD->param_begin(), CD->param_end());
2820 
2821  // Create the function declaration.
2822  const CGFunctionInfo &FuncInfo =
2824  llvm::FunctionType *FuncLLVMTy = CGM.getTypes().GetFunctionType(FuncInfo);
2825 
2826  llvm::Function *F =
2827  llvm::Function::Create(FuncLLVMTy, llvm::GlobalValue::InternalLinkage,
2829  CGM.SetInternalFunctionAttributes(CD, F, FuncInfo);
2830  if (CD->isNothrow())
2831  F->addFnAttr(llvm::Attribute::NoUnwind);
2832 
2833  // Generate the function.
2834  StartFunction(CD, Ctx.VoidTy, F, FuncInfo, Args, CD->getLocation(),
2835  CD->getBody()->getBeginLoc());
2836  // Set the context parameter in CapturedStmtInfo.
2837  Address DeclPtr = GetAddrOfLocalVar(CD->getContextParam());
2839 
2840  // Initialize variable-length arrays.
2842  Ctx.getTagDeclType(RD));
2843  for (auto *FD : RD->fields()) {
2844  if (FD->hasCapturedVLAType()) {
2845  auto *ExprArg =
2846  EmitLoadOfLValue(EmitLValueForField(Base, FD), S.getBeginLoc())
2847  .getScalarVal();
2848  auto VAT = FD->getCapturedVLAType();
2849  VLASizeMap[VAT->getSizeExpr()] = ExprArg;
2850  }
2851  }
2852 
2853  // If 'this' is captured, load it into CXXThisValue.
2856  LValue ThisLValue = EmitLValueForField(Base, FD);
2857  CXXThisValue = EmitLoadOfLValue(ThisLValue, Loc).getScalarVal();
2858  }
2859 
2860  PGO.assignRegionCounters(GlobalDecl(CD), F);
2861  CapturedStmtInfo->EmitBody(*this, CD->getBody());
2863 
2864  return F;
2865 }
clang::CodeGen::ABIArgInfo::isDirect
bool isDirect() const
Definition: CGFunctionInfo.h:296
clang::IndirectGotoStmt
IndirectGotoStmt - This represents an indirect goto.
Definition: Stmt.h:2648
clang::InternalLinkage
@ InternalLinkage
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
Definition: Linkage.h:31
clang::LabelStmt
LabelStmt - Represents a label, which has a substatement.
Definition: Stmt.h:1803
clang::CodeGen::CodeGenFunction::ConvertTypeForMem
llvm::Type * ConvertTypeForMem(QualType T)
Definition: CodeGenFunction.cpp:208
clang::CodeGen::CodeGenFunction::InAlwaysInlineAttributedStmt
bool InAlwaysInlineAttributedStmt
True if the current statement has always_inline attribute.
Definition: CodeGenFunction.h:559
clang::CodeGen::CodeGenFunction::EmitObjCAutoreleasePoolStmt
void EmitObjCAutoreleasePoolStmt(const ObjCAutoreleasePoolStmt &S)
Definition: CGObjC.cpp:3616
clang::TargetInfo::ConstraintInfo::allowsMemory
bool allowsMemory() const
Definition: TargetInfo.h:1025
clang::CodeGen::CodeGenFunction::EmitGotoStmt
void EmitGotoStmt(const GotoStmt &S)
Definition: CGStmt.cpp:713
clang::CodeGen::CodeGenFunction::EmitComplexExprIntoLValue
void EmitComplexExprIntoLValue(const Expr *E, LValue dest, bool isInit)
EmitComplexExprIntoLValue - Emit the given expression of complex type and place its result into the s...
Definition: CGExprComplex.cpp:1129
clang::CodeGen::CodeGenFunction::EmitOMPDistributeSimdDirective
void EmitOMPDistributeSimdDirective(const OMPDistributeSimdDirective &S)
Definition: CGStmtOpenMP.cpp:3153
clang::CodeGen::CodeGenFunction::EmitLabelStmt
void EmitLabelStmt(const LabelStmt &S)
Definition: CGStmt.cpp:669
Builtins.h
clang::CaseStmt
CaseStmt - Represent a case statement.
Definition: Stmt.h:1571
clang::CodeGen::CodeGenFunction::CGCapturedStmtInfo
API for captured statement code generation.
Definition: CodeGenFunction.h:406
max
__DEVICE__ int max(int __a, int __b)
Definition: __clang_cuda_math.h:196
clang::ReturnStmt::getRetValue
Expr * getRetValue()
Definition: Stmt.h:2797
clang::CodeGen::CodeGenFunction::getTypeSize
llvm::Value * getTypeSize(QualType Ty)
Returns calculated size of the specified type.
Definition: CGStmtOpenMP.cpp:305
clang::CodeGen::CodeGenFunction::EmitBlockAfterUses
void EmitBlockAfterUses(llvm::BasicBlock *BB)
EmitBlockAfterUses - Emit the given block somewhere hopefully near its uses, and leave the insertion ...
Definition: CGStmt.cpp:581
clang::CodeGen::CodeGenFunction::getProfileCount
uint64_t getProfileCount(const Stmt *S)
Get the profiler's count for the given statement.
Definition: CodeGenFunction.h:1531
clang::RecordDecl::field_begin
field_iterator field_begin() const
Definition: Decl.cpp:4680
clang::CodeGen::CodeGenFunction::RunCleanupsScope::requiresCleanups
bool requiresCleanups() const
Determine whether this scope requires any cleanups.
Definition: CodeGenFunction.h:907
clang::CodeGen::CodeGenFunction::EmitCXXTryStmt
void EmitCXXTryStmt(const CXXTryStmt &S)
Definition: CGException.cpp:611
clang::CodeGen::CodeGenPGO::haveRegionCounts
bool haveRegionCounts() const
Whether or not we have PGO region data for the current function.
Definition: CodeGenPGO.h:50
clang::CodeGen::CodeGenTypeCache::Int8PtrTy
llvm::PointerType * Int8PtrTy
Definition: CodeGenTypeCache.h:57
clang::CodeGen::CodeGenFunction::EmitOMPInteropDirective
void EmitOMPInteropDirective(const OMPInteropDirective &S)
Definition: CGStmtOpenMP.cpp:6780
clang::CodeGen::CodeGenFunction::EmitOMPTaskwaitDirective
void EmitOMPTaskwaitDirective(const OMPTaskwaitDirective &S)
Definition: CGStmtOpenMP.cpp:5095
clang::TargetInfo::getClobbers
virtual const char * getClobbers() const =0
Returns a string of target-specific clobbers, in LLVM format.
clang::interp::APInt
llvm::APInt APInt
Definition: Integral.h:27
clang::CodeGen::CGOpenMPRuntime::getAddressOfLocalVariable
virtual Address getAddressOfLocalVariable(CodeGenFunction &CGF, const VarDecl *VD)
Gets the OpenMP-specific address of the local variable.
Definition: CGOpenMPRuntime.cpp:12209
CSFC_Failure
@ CSFC_Failure
Definition: CGStmt.cpp:1621
clang::DeclContext::specific_decl_iterator
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
Definition: DeclBase.h:2151
clang::CodeGen::TEK_Aggregate
@ TEK_Aggregate
Definition: CodeGenFunction.h:109
clang::CodeGen::CodeGenFunction::getJumpDestForLabel
JumpDest getJumpDestForLabel(const LabelDecl *S)
getBasicBlockForLabel - Return the LLVM basicblock that the specified label maps to.
Definition: CGStmt.cpp:599
clang::CodeGen::RValue
RValue - This trivial value class is used to represent the result of an expression that is evaluated.
Definition: CGValue.h:39
getLikelihoodWeights
static Optional< SmallVector< uint64_t, 16 > > getLikelihoodWeights(ArrayRef< Stmt::Likelihood > Likelihoods)
Definition: CGStmt.cpp:1831
clang::TargetInfo::isValidGCCRegisterName
virtual bool isValidGCCRegisterName(StringRef Name) const
Returns whether the passed in string is a valid register name according to GCC.
Definition: TargetInfo.cpp:538
clang::CodeGen::CodeGenFunction::ConstantFoldsToSimpleInteger
bool ConstantFoldsToSimpleInteger(const Expr *Cond, bool &Result, bool AllowLabels=false)
ConstantFoldsToSimpleInteger - If the specified expression does not fold to a constant,...
Definition: CodeGenFunction.cpp:1561
clang::CodeGen::CodeGenFunction::EmitObjCAtTryStmt
void EmitObjCAtTryStmt(const ObjCAtTryStmt &S)
Definition: CGObjC.cpp:2038
clang::SwitchStmt
SwitchStmt - This represents a 'switch' stmt.
Definition: Stmt.h:2154
clang::CodeGen::CodeGenFunction::EmitCheckSourceLocation
llvm::Constant * EmitCheckSourceLocation(SourceLocation Loc)
Emit a description of a source location in a format suitable for passing to a runtime sanitizer handl...
Definition: CGExpr.cpp:3144
clang::CodeGen::CodeGenFunction::SimplifyForwardingBlocks
void SimplifyForwardingBlocks(llvm::BasicBlock *BB)
SimplifyForwardingBlocks - If the given basic block is only a branch to another basic block,...
Definition: CGStmt.cpp:522
clang::CodeGen::CodeGenFunction::EmitReferenceBindingToExpr
RValue EmitReferenceBindingToExpr(const Expr *E)
Emits a reference binding to the passed in expression.
Definition: CGExpr.cpp:615
CodeGenFunction.h
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:210
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::CodeGen::CodeGenFunction::EmitOMPOrderedDirective
void EmitOMPOrderedDirective(const OMPOrderedDirective &S)
Definition: CGStmtOpenMP.cpp:5623
clang::WhileStmt
WhileStmt - This represents a 'while' stmt.
Definition: Stmt.h:2345
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope
Address EmitCompoundStmtWithoutScope(const CompoundStmt &S, bool GetLast=false, AggValueSlot AVS=AggValueSlot::ignored())
Definition: CGStmt.cpp:470
clang::CodeGen::CodeGenFunction::EmitOMPSimdDirective
void EmitOMPSimdDirective(const OMPSimdDirective &S)
Definition: CGStmtOpenMP.cpp:2624
clang::CodeGen::CodeGenFunction::EmitOMPTargetDataDirective
void EmitOMPTargetDataDirective(const OMPTargetDataDirective &S)
Definition: CGStmtOpenMP.cpp:7099
clang::CodeGen::EHScopeStack::stable_iterator::isValid
bool isValid() const
Definition: EHScopeStack.h:113
clang::CodeGen::AggValueSlot::DoesNotNeedGCBarriers
@ DoesNotNeedGCBarriers
Definition: CGValue.h:554
clang::CodeGen::CodeGenFunction::InNoMergeAttributedStmt
bool InNoMergeAttributedStmt
True if the current statement has nomerge attribute.
Definition: CodeGenFunction.h:553
clang::CodeGen::CodeGenFunction::isObviouslyBranchWithoutCleanups
bool isObviouslyBranchWithoutCleanups(JumpDest Dest) const
isObviouslyBranchWithoutCleanups - Return true if a branch to the specified destination obviously has...
Definition: CGCleanup.cpp:1062
clang::ASTContext::VoidTy
CanQualType VoidTy
Definition: ASTContext.h:1096
clang::StringLiteral::getBeginLoc
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:1942
llvm::SmallVector< uint64_t, 16 >
clang::CodeGen::CodeGenFunction::EmitOMPMasterTaskLoopDirective
void EmitOMPMasterTaskLoopDirective(const OMPMasterTaskLoopDirective &S)
Definition: CGStmtOpenMP.cpp:7544
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:86
clang::CodeGen::CodeGenModule::SetInternalFunctionAttributes
void SetInternalFunctionAttributes(GlobalDecl GD, llvm::Function *F, const CGFunctionInfo &FI)
Set the attributes on the LLVM function for the given decl and function info.
Definition: CodeGenModule.cpp:2193
clang::LangOptions::assumeFunctionsAreConvergent
bool assumeFunctionsAreConvergent() const
Definition: LangOptions.h:519
clang::CodeGen::LValue::getAddress
Address getAddress(CodeGenFunction &CGF) const
Definition: CGValue.h:341
clang::SourceRange::getBegin
SourceLocation getBegin() const
Definition: SourceLocation.h:219
clang::CodeGen::CodeGenFunction::InNoInlineAttributedStmt
bool InNoInlineAttributedStmt
True if the current statement has noinline attribute.
Definition: CodeGenFunction.h:556
TargetInfo.h
clang::CodeGen::CodeGenFunction::EmitAnyExpr
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.
Definition: CGExpr.cpp:212
clang::CodeGen::CodeGenFunction::EmitLabel
void EmitLabel(const LabelDecl *D)
EmitLabel - Emit the block for the given label.
Definition: CGStmt.cpp:610
clang::CodeGen::CodeGenFunction::EmitOMPTaskLoopSimdDirective
void EmitOMPTaskLoopSimdDirective(const OMPTaskLoopSimdDirective &S)
Definition: CGStmtOpenMP.cpp:7536
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:675
Attr.h
clang::CodeGen::CodeGenFunction::GenerateCapturedStmtArgument
Address GenerateCapturedStmtArgument(const CapturedStmt &S)
Definition: CGStmt.cpp:2801
clang::CodeGen::CodeGenFunction::EmitCoroutineBody
void EmitCoroutineBody(const CoroutineBodyStmt &S)
Definition: CGCoroutine.cpp:477
clang::CodeGen::CodeGenModule::getContext
ASTContext & getContext() const
Definition: CodeGenModule.h:697
clang::Decl::hasBody
virtual bool hasBody() const
Returns true if this Decl represents a declaration for a body of code, such as a function or method d...
Definition: DeclBase.h:1025
clang::QualType::getCanonicalType
QualType getCanonicalType() const
Definition: Type.h:6539
clang::FieldDecl
Represents a member of a struct/union/class.
Definition: Decl.h:2855
clang::CodeGen::Address::isValid
bool isValid() const
Definition: Address.h:91
clang::CodeGen::CodeGenFunction::MakeAddrLValueWithoutTBAA
LValue MakeAddrLValueWithoutTBAA(Address Addr, QualType T, AlignmentSource Source=AlignmentSource::Type)
Definition: CodeGenFunction.h:2511
clang::Qualifiers
The collection of all-type qualifiers we support.
Definition: Type.h:147
clang::TargetInfo
Exposes information about the current target.
Definition: TargetInfo.h:186
clang::CodeGen::CodeGenFunction::EmitOMPTeamsDistributeDirective
void EmitOMPTeamsDistributeDirective(const OMPTeamsDistributeDirective &S)
Definition: CGStmtOpenMP.cpp:6688
clang::CodeGen::CodeGenFunction::EmitDoStmt
void EmitDoStmt(const DoStmt &S, ArrayRef< const Attr * > Attrs=None)
Definition: CGStmt.cpp:937
clang::CodeGen::EHScopeStack::hasNormalCleanups
bool hasNormalCleanups() const
Determines whether there are any normal cleanups on the stack.
Definition: EHScopeStack.h:355
clang::CodeGen::CodeGenFunction::EmitOMPDistributeParallelForSimdDirective
void EmitOMPDistributeParallelForSimdDirective(const OMPDistributeParallelForSimdDirective &S)
Definition: CGStmtOpenMP.cpp:3143
clang::CodeGen::CodeGenFunction::EmitOMPTargetDirective
void EmitOMPTargetDirective(const OMPTargetDirective &S)
Definition: CGStmtOpenMP.cpp:6502
clang::CodeGen::CodeGenFunction::createBasicBlock
llvm::BasicBlock * createBasicBlock(const Twine &name="", llvm::Function *parent=nullptr, llvm::BasicBlock *before=nullptr)
createBasicBlock - Create an LLVM basic block.
Definition: CodeGenFunction.h:2430
clang::IfStmt
IfStmt - This represents an if/then/else.
Definition: Stmt.h:1908
clang::CapturedStmt::const_capture_init_iterator
Expr *const * const_capture_init_iterator
Const iterator that walks over the capture initialization arguments.
Definition: Stmt.h:3665
clang::CodeGen::CGBuilderTy::CreateStore
llvm::StoreInst * CreateStore(llvm::Value *Val, Address Addr, bool IsVolatile=false)
Definition: CGBuilder.h:97
clang::CodeGen::TargetCodeGenInfo::isScalarizableAsmOperand
virtual bool isScalarizableAsmOperand(CodeGen::CodeGenFunction &CGF, llvm::Type *Ty) const
Target hook to decide whether an inline asm operand can be passed by value.
Definition: TargetInfo.h:152
clang::Expr::IgnoreParenNoopCasts
Expr * IgnoreParenNoopCasts(const ASTContext &Ctx) LLVM_READONLY
Skip past any parenthese and casts which do not change the value (including ptr->int casts of the sam...
Definition: Expr.cpp:2974
clang::CapturedRegionKind
CapturedRegionKind
The different kinds of captured statement.
Definition: CapturedStmt.h:16
clang::GotoStmt
GotoStmt - This represents a direct goto.
Definition: Stmt.h:2609
clang::CodeGen::CodeGenFunction::EmitOMPParallelMasterTaskLoopSimdDirective
void EmitOMPParallelMasterTaskLoopSimdDirective(const OMPParallelMasterTaskLoopSimdDirective &S)
Definition: CGStmtOpenMP.cpp:7586
clang::CodeGen::CodeGenFunction::EmitOMPTargetTeamsDistributeParallelForDirective
void EmitOMPTargetTeamsDistributeParallelForDirective(const OMPTargetTeamsDistributeParallelForDirective &S)
Definition: CGStmtOpenMP.cpp:6877
clang::CodeGen::CodeGenTypes::arrangeBuiltinFunctionDeclaration
const CGFunctionInfo & arrangeBuiltinFunctionDeclaration(QualType resultType, const FunctionArgList &args)
A builtin function is a freestanding function using the default C conventions.
Definition: CGCall.cpp:666
llvm::Optional
Definition: LLVM.h:40
SourceManager.h
clang::CodeGen::CodeGenModule::getLangOpts
const LangOptions & getLangOpts() const
Definition: CodeGenModule.h:698
clang::CodeGen::CodeGenFunction::mightAddDeclToScope
static bool mightAddDeclToScope(const Stmt *S)
Determine if the given statement might introduce a declaration into the current scope,...
Definition: CodeGenFunction.cpp:1535
clang::Type::isVoidType
bool isVoidType() const
Definition: Type.h:7037
clang::CodeGen::CodeGenFunction::HaveInsertPoint
bool HaveInsertPoint() const
HaveInsertPoint - True if an insertion point is defined.
Definition: CodeGenFunction.h:2471
clang::CodeGen::CodeGenFunction::EmitLValueForField
LValue EmitLValueForField(LValue Base, const FieldDecl *Field)
Definition: CGExpr.cpp:4357
clang::CodeGen::CodeGenFunction::JumpDest::setScopeDepth
void setScopeDepth(EHScopeStack::stable_iterator depth)
Definition: CodeGenFunction.h:251
clang::CodeGen::CodeGenFunction::EmitOMPTargetUpdateDirective
void EmitOMPTargetUpdateDirective(const OMPTargetUpdateDirective &S)
Definition: CGStmtOpenMP.cpp:7605
clang::CodeGen::CodeGenFunction::MustTailCall
const CallExpr * MustTailCall
Definition: CodeGenFunction.h:563
clang::CodeGen::CodeGenModule::getTargetCodeGenInfo
const TargetCodeGenInfo & getTargetCodeGenInfo()
Definition: TargetInfo.cpp:11336
clang::FunctionType
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:3559
clang::CapturedDecl
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:4390
clang::CodeGen::CGBuilderTy
Definition: CGBuilder.h:44
clang::CodeGen::CodeGenFunction::EmitStmt
void EmitStmt(const Stmt *S, ArrayRef< const Attr * > Attrs=None)
EmitStmt - Emit the code for the statement.
Definition: CGStmt.cpp:53
clang::Expr::EvalResult::Val
APValue Val
Val - This is the value the expression can be folded to.
Definition: Expr.h:614
clang::CodeGen::CodeGenFunction::JumpDest::getBlock
llvm::BasicBlock * getBlock() const
Definition: CodeGenFunction.h:246
CSFC_FallThrough
@ CSFC_FallThrough
Definition: CGStmt.cpp:1621
clang::ASTContext::getSourceManager
SourceManager & getSourceManager()
Definition: ASTContext.h:716
clang::CodeGen::CodeGenFunction::CGCapturedStmtInfo::EmitBody
virtual void EmitBody(CodeGenFunction &CGF, const Stmt *S)
Emit the captured statement body.
Definition: CodeGenFunction.h:449
clang::CodeGen::CodeGenFunction::EmitInitializerForField
void EmitInitializerForField(FieldDecl *Field, LValue LHS, Expr *Init)
Definition: CGClass.cpp:690
clang::CapturedStmt::getCapturedRegionKind
CapturedRegionKind getCapturedRegionKind() const
Retrieve the captured region kind.
Definition: Stmt.cpp:1406
clang::CodeGen::CodeGenFunction::EmitOMPMasterTaskLoopSimdDirective
void EmitOMPMasterTaskLoopSimdDirective(const OMPMasterTaskLoopSimdDirective &S)
Definition: CGStmtOpenMP.cpp:7556
clang::CodeGen::CodeGenFunction::EmitStoreThroughLValue
void EmitStoreThroughLValue(RValue Src, LValue Dst, bool isInit=false)
EmitStoreThroughLValue - Store the specified rvalue into the specified lvalue, where both are guarant...
Definition: CGExpr.cpp:2118
clang::CodeGen::CodeGenFunction::Builder
CGBuilderTy Builder
Definition: CodeGenFunction.h:269
clang::CodeGen::CodeGenFunction::EmitOMPCancellationPointDirective
void EmitOMPCancellationPointDirective(const OMPCancellationPointDirective &S)
Definition: CGStmtOpenMP.cpp:6937
CGDebugInfo.h
clang::SourceManager
This class handles loading and caching of source files into memory.
Definition: SourceManager.h:627
clang::CodeGen::CodeGenFunction::GetAddrOfLocalVar
Address GetAddrOfLocalVar(const VarDecl *VD)
GetAddrOfLocalVar - Return the address of a local variable.
Definition: CodeGenFunction.h:2720
clang::Stmt::NoStmtClass
@ NoStmtClass
Definition: Stmt.h:72
clang::CodeGen::CodeGenModule::getOpenMPRuntime
CGOpenMPRuntime & getOpenMPRuntime()
Return a reference to the configured OpenMP runtime.
Definition: CodeGenModule.h:605
clang::GlobalDecl
GlobalDecl - represents a global declaration.
Definition: GlobalDecl.h:56
clang::CodeGen::CodeGenFunction::EmitDefaultStmt
void EmitDefaultStmt(const DefaultStmt &S, ArrayRef< const Attr * > Attrs)
Definition: CGStmt.cpp:1576
clang::LoopExit
Represents a point when we exit a loop.
Definition: ProgramPoint.h:712
clang::CodeGen::CodeGenFunction::CGCapturedStmtRAII
RAII for correct setting/restoring of CapturedStmtInfo.
Definition: CodeGenFunction.h:479
clang::CapturedDecl::param_begin
param_iterator param_begin() const
Retrieve an iterator pointing to the first parameter decl.
Definition: Decl.h:4470
clang::CodeGen::CodeGenFunction::CGCapturedStmtInfo::isCXXThisExprCaptured
bool isCXXThisExprCaptured() const
Definition: CodeGenFunction.h:441
APSInt
llvm::APSInt APSInt
Definition: ByteCodeEmitter.cpp:19
clang::CodeGen::ABIArgInfo
ABIArgInfo - Helper class to encapsulate information about how a specific C type should be passed to ...
Definition: CGFunctionInfo.h:32
clang::CodeGen::EHScopeStack::getInnermostNormalCleanup
stable_iterator getInnermostNormalCleanup() const
Returns the innermost normal cleanup on the stack, or stable_end() if there are no normal cleanups.
Definition: EHScopeStack.h:361
clang::AttributedStmt
Represents an attribute applied to a statement.
Definition: Stmt.h:1850
clang::Type::isReferenceType
bool isReferenceType() const
Definition: Type.h:6760
clang::CallExpr::getCallee
Expr * getCallee()
Definition: Expr.h:2951
V
#define V(N, I)
Definition: ASTContext.h:3176
clang::CodeGen::CodeGenFunction::RunCleanupsScope
Enters a new scope for capturing cleanups, all of which will be executed once the scope is exited.
Definition: CodeGenFunction.h:872
clang::CodeGen::CodeGenFunction::hasScalarEvaluationKind
static bool hasScalarEvaluationKind(QualType T)
Definition: CodeGenFunction.h:2421
clang::CompoundStmt
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:1401
clang::CodeGen::CodeGenFunction::getCurrentProfileCount
uint64_t getCurrentProfileCount()
Get the profiler's current count.
Definition: CodeGenFunction.h:1545
SimplifyConstraint
static std::string SimplifyConstraint(const char *Constraint, const TargetInfo &Target, SmallVectorImpl< TargetInfo::ConstraintInfo > *OutCons=nullptr)
Definition: CGStmt.cpp:2053
clang::CapturedDecl::param_end
param_iterator param_end() const
Retrieve an iterator one past the last parameter decl.
Definition: Decl.h:4472
clang::CodeGen::CodeGenFunction::EmitCXXForRangeStmt
void EmitCXXForRangeStmt(const CXXForRangeStmt &S, ArrayRef< const Attr * > Attrs=None)
Definition: CGStmt.cpp:1116
clang::CodeGen::CodeGenFunction::EmitOMPTargetTeamsDistributeParallelForSimdDirective
void EmitOMPTargetTeamsDistributeParallelForSimdDirective(const OMPTargetTeamsDistributeParallelForSimdDirective &S)
Definition: CGStmtOpenMP.cpp:6929
clang::TargetInfo::getNormalizedGCCRegisterName
StringRef getNormalizedGCCRegisterName(StringRef Name, bool ReturnCanonical=false) const
Returns the "normalized" GCC register name.
Definition: TargetInfo.cpp:583
clang::Scope
Scope - A scope is a transient data structure that is used while parsing the program.
Definition: Scope.h:40
clang::CodeGen::CodeGenFunction::ResolveBranchFixups
void ResolveBranchFixups(llvm::BasicBlock *Target)
Definition: CGCleanup.cpp:393
clang::CodeGen::CodeGenFunction::GetIndirectGotoBlock
llvm::BasicBlock * GetIndirectGotoBlock()
Definition: CodeGenFunction.cpp:2040
clang::SourceRange::getEnd
SourceLocation getEnd() const
Definition: SourceLocation.h:220
clang::CodeGen::CodeGenTypeCache::Int64Ty
llvm::IntegerType * Int64Ty
Definition: CodeGenTypeCache.h:37
clang::CodeGen::CodeGenFunction::EmitOMPBarrierDirective
void EmitOMPBarrierDirective(const OMPBarrierDirective &S)
Definition: CGStmtOpenMP.cpp:5091
CGOpenMPRuntime.h
clang::CodeGen::CodeGenModule::getCodeGenOpts
const CodeGenOptions & getCodeGenOpts() const
Definition: CodeGenModule.h:703
clang::CodeGen::CodeGenFunction::LexicalScope::addLabel
void addLabel(const LabelDecl *label)
Definition: CodeGenFunction.h:948
clang::CodeGen::Address::getType
llvm::PointerType * getType() const
Return the type of the pointer value.
Definition: Address.h:99
clang::Decl::getBodyRBrace
SourceLocation getBodyRBrace() const
getBodyRBrace - Gets the right brace of the body, if a body exists.
Definition: DeclBase.cpp:952
clang::CodeGen::CodeGenFunction::EmitContinueStmt
void EmitContinueStmt(const ContinueStmt &S)
Definition: CGStmt.cpp:1376
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:208
clang::CodeGen::CodeGenFunction::EmitDeclStmt
void EmitDeclStmt(const DeclStmt &S)
Definition: CGStmt.cpp:1354
clang::CodeGen::RValue::isAggregate
bool isAggregate() const
Definition: CGValue.h:56
CSFC_Success
@ CSFC_Success
Definition: CGStmt.cpp:1621
clang::CodeGen::CodeGenFunction::LexicalScope::rescopeLabels
void rescopeLabels()
Change the cleanup scope of the labels in this lexical scope to match the scope of the enclosing cont...
Definition: CGStmt.cpp:647
clang::CodeGen::CodeGenFunction::EmitSehCppScopeBegin
void EmitSehCppScopeBegin()
Definition: CGCleanup.cpp:1344
clang::CodeGen::TEK_Complex
@ TEK_Complex
Definition: CodeGenFunction.h:108
clang::CodeGen::CodeGenFunction::EnsureInsertPoint
void EnsureInsertPoint()
EnsureInsertPoint - Ensure that an insertion point is defined so that emitted IR has a place to go.
Definition: CodeGenFunction.h:2479
clang::CodeGen::CodeGenFunction::getTarget
const TargetInfo & getTarget() const
Definition: CodeGenFunction.h:2024
clang::CodeGen::CodeGenFunction::getDebugInfo
CGDebugInfo * getDebugInfo()
Definition: CodeGenFunction.h:1983
clang::CodeGen::CodeGenFunction::LexicalScope::ForceCleanup
void ForceCleanup()
Force the emission of cleanups now, instead of waiting until this object is destroyed.
Definition: CodeGenFunction.h:969
clang::CompoundStmt::const_body_iterator
Stmt *const * const_body_iterator
Definition: Stmt.h:1445
clang::FunctionType::getCallConv
CallingConv getCallConv() const
Definition: Type.h:3833
clang::CaseStmt::getRHS
Expr * getRHS()
Definition: Stmt.h:1672
clang::CodeGen::CodeGenFunction::EmitOMPParallelMasterDirective
void EmitOMPParallelMasterDirective(const OMPParallelMasterDirective &S)
Definition: CGStmtOpenMP.cpp:4395
clang::CodeGen::CodeGenTypeCache::VoidTy
llvm::Type * VoidTy
void
Definition: CodeGenTypeCache.h:34
clang::ForStmt
ForStmt - This represents a 'for (init;cond;inc)' stmt.
Definition: Stmt.h:2538
clang::CodeGen::LoopInfoStack::pop
void pop()
End the current loop.
Definition: CGLoopInfo.cpp:804
clang::CodeGen::CodeGenFunction::EmitBranchOnBoolExpr
void EmitBranchOnBoolExpr(const Expr *Cond, llvm::BasicBlock *TrueBlock, llvm::BasicBlock *FalseBlock, uint64_t TrueCount, Stmt::Likelihood LH=Stmt::LH_None)
EmitBranchOnBoolExpr - Emit a branch on a boolean condition (e.g.
Definition: CodeGenFunction.cpp:1680
clang::LabelDecl
Represents the declaration of a label.
Definition: Decl.h:494
clang::CodeGen::CodeGenModule::getModule
llvm::Module & getModule() const
Definition: CodeGenModule.h:704
clang::Stmt::LH_None
@ LH_None
No attribute set or branches of the IfStmt have the same attribute.
Definition: Stmt.h:1105
clang::ASTContext::getTypeSize
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
Definition: ASTContext.h:2285
clang::CodeGen::CGFunctionInfo::getASTCallingConvention
CallingConv getASTCallingConvention() const
getASTCallingConvention() - Return the AST-specified calling convention.
Definition: CGFunctionInfo.h:682
clang::CodeGen::CGDebugInfo
This class gathers all debug information during compilation and is responsible for emitting to llvm g...
Definition: CGDebugInfo.h:55
clang::DeclRefExpr::getDecl
ValueDecl * getDecl()
Definition: Expr.h:1295
clang::CodeGen::EHScopeStack::empty
bool empty() const
Determines whether the exception-scopes stack is empty.
Definition: EHScopeStack.h:350
Expr.h
clang::Expr::EvalResult
EvalResult is a struct with detailed info about an evaluated expression.
Definition: Expr.h:612
clang::ASTContext::getRecordType
QualType getRecordType(const RecordDecl *Decl) const
Definition: ASTContext.cpp:4638
clang::ASTContext::getIntTypeForBitwidth
QualType getIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
getIntTypeForBitwidth - sets integer QualTy according to specified details: bitwidth,...
Definition: ASTContext.cpp:11728
clang::CodeGen::CodeGenFunction::EmitLambdaVLACapture
void EmitLambdaVLACapture(const VariableArrayType *VAT, LValue LV)
Definition: CodeGenFunction.h:2224
clang::CodeGen::CodeGenFunction::EmitSwitchStmt
void EmitSwitchStmt(const SwitchStmt &S)
Definition: CGStmt.cpp:1886
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:874
clang::CodeGen::ABIArgInfo::isExtend
bool isExtend() const
Definition: CGFunctionInfo.h:298
clang::Type::getPointeeType
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
Definition: Type.cpp:625
clang::CodeGen::CodeGenFunction::EmitOMPTargetTeamsDistributeSimdDirective
void EmitOMPTargetTeamsDistributeSimdDirective(const OMPTargetTeamsDistributeSimdDirective &S)
Definition: CGStmtOpenMP.cpp:6680
clang::CodeGen::CodeGenFunction::IsOutlinedSEHHelper
bool IsOutlinedSEHHelper
True if the current function is an outlined SEH helper.
Definition: CodeGenFunction.h:546
clang::StringLiteral
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1767
clang::CodeGen::CodeGenModule::getTypes
CodeGenTypes & getTypes()
Definition: CodeGenModule.h:721
clang::CodeGen::LoopInfoStack::push
void push(llvm::BasicBlock *Header, const llvm::DebugLoc &StartLoc, const llvm::DebugLoc &EndLoc)
Begin a new structured loop.
clang::CodeGen::CodeGenFunction::EmitOMPTeamsDirective
void EmitOMPTeamsDirective(const OMPTeamsDirective &S)
Definition: CGStmtOpenMP.cpp:6535
clang::Stmt::LH_Likely
@ LH_Likely
Branch has the [[likely]] attribute.
Definition: Stmt.h:1107
clang::CapturedStmt
This captures a statement into a function.
Definition: Stmt.h:3504
clang::Expr::EvaluateKnownConstInt
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
Definition: ExprConstant.cpp:15217
getAsmSrcLocInfo
static llvm::MDNode * getAsmSrcLocInfo(const StringLiteral *Str, CodeGenFunction &CGF)
getAsmSrcLocInfo - Return the !srcloc metadata node to attach to an inline asm call instruction.
Definition: CGStmt.cpp:2201
clang::CodeGen::AggValueSlot::IsDestructed
@ IsDestructed
Definition: CGValue.h:551
clang::CodeGen::CodeGenFunction::EmitCompoundStmt
Address EmitCompoundStmt(const CompoundStmt &S, bool GetLast=false, AggValueSlot AVS=AggValueSlot::ignored())
EmitCompoundStmt - Emit a compound statement {..} node.
Definition: CGStmt.cpp:458
clang::SC_Register
@ SC_Register
Definition: Specifiers.h:242
clang::CodeGen::CodeGenFunction::getLLVMContext
llvm::LLVMContext & getLLVMContext()
Definition: CodeGenFunction.h:2025
clang::CodeGen::CodeGenFunction::EmitOMPTaskLoopDirective
void EmitOMPTaskLoopDirective(const OMPTaskLoopDirective &S)
Definition: CGStmtOpenMP.cpp:7530
clang::CodeGen::CodeGenFunction::getContext
ASTContext & getContext() const
Definition: CodeGenFunction.h:1982
makeTailCallIfSwiftAsync
static void makeTailCallIfSwiftAsync(const CallExpr *CE, CGBuilderTy &Builder, const CGFunctionInfo *CurFnInfo)
If we have 'return f(...);', where both caller and callee are SwiftAsync, codegen it as 'tail call ....
Definition: CGStmt.cpp:1226
clang::SwitchCase
Definition: Stmt.h:1526
clang::CodeGen::CodeGenFunction::incrementProfileCounter
void incrementProfileCounter(const Stmt *S, llvm::Value *StepV=nullptr)
Increment the profiler's counter for the given statement by StepV.
Definition: CodeGenFunction.h:1523
clang::CodeGen::CodeGenFunction::FinishFunction
void FinishFunction(SourceLocation EndLoc=SourceLocation())
FinishFunction - Complete IR generation of the current function.
Definition: CodeGenFunction.cpp:325
clang::CodeGen::Address
An aligned address.
Definition: Address.h:74
clang::CodeGen::CodeGenFunction::EmitOMPMasterDirective
void EmitOMPMasterDirective(const OMPMasterDirective &S)
Definition: CGStmtOpenMP.cpp:4203
Base
clang::CodeGen::CodeGenFunction::getJumpDestInCurrentScope
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...
Definition: CodeGenFunction.h:1145
clang::CodeGen::CodeGenFunction::EmitOMPSectionDirective
void EmitOMPSectionDirective(const OMPSectionDirective &S)
Definition: CGStmtOpenMP.cpp:4123
CodeGenModule.h
clang::CodeGen::CodeGenFunction::EmitObjCForCollectionStmt
void EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S)
Definition: CGObjC.cpp:1714
clang::CodeGen::CodeGenFunction::getEvaluationKind
static TypeEvaluationKind getEvaluationKind(QualType T)
getEvaluationKind - Return the TypeEvaluationKind of QualType T.
Definition: CodeGenFunction.cpp:216
clang::CodeGen::CodeGenFunction::EmitOMPParallelDirective
void EmitOMPParallelDirective(const OMPParallelDirective &S)
Definition: CGStmtOpenMP.cpp:1715
clang::CodeGen::CodeGenFunction::EmitOMPParallelSectionsDirective
void EmitOMPParallelSectionsDirective(const OMPParallelSectionsDirective &S)
Definition: CGStmtOpenMP.cpp:4430
clang::CodeGen::CodeGenFunction::EmitOMPTeamsDistributeSimdDirective
void EmitOMPTeamsDistributeSimdDirective(const OMPTeamsDistributeSimdDirective &S)
Definition: CGStmtOpenMP.cpp:6711
clang::CodeGen::CodeGenFunction::EmitOMPFlushDirective
void EmitOMPFlushDirective(const OMPFlushDirective &S)
Definition: CGStmtOpenMP.cpp:5133
clang::StringLiteral::getLocationOfByte
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...
Definition: Expr.cpp:1230
clang::CodeGen::CodeGenFunction::EmitSimpleStmt
bool EmitSimpleStmt(const Stmt *S, ArrayRef< const Attr * > Attrs)
EmitSimpleStmt - Try to emit a "simple" statement which does not necessarily require an insertion poi...
Definition: CGStmt.cpp:414
clang::CodeGen::CodeGenFunction::EmitOMPTeamsDistributeParallelForSimdDirective
void EmitOMPTeamsDistributeParallelForSimdDirective(const OMPTeamsDistributeParallelForSimdDirective &S)
Definition: CGStmtOpenMP.cpp:6756
clang::CodeGen::CodeGenFunction::EmitCapturedStmt
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...
Definition: CGStmt.cpp:2786
clang::TargetInfo::ConstraintInfo::earlyClobber
bool earlyClobber()
Definition: TargetInfo.h:1023
clang::CodeGen::CodeGenFunction::EmitAnyExprToMem
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...
Definition: CGExpr.cpp:241
clang::CodeGen::CodeGenFunction::EmitOMPTaskyieldDirective
void EmitOMPTaskyieldDirective(const OMPTaskyieldDirective &S)
Definition: CGStmtOpenMP.cpp:5086
clang::CodeGen::CodeGenFunction::GenerateCapturedStmtFunction
llvm::Function * GenerateCapturedStmtFunction(const CapturedStmt &S)
Creates the outlined function for a CapturedStmt.
Definition: CGStmt.cpp:2808
clang::CodeGen::SanitizerMetadata::disableSanitizerForGlobal
void disableSanitizerForGlobal(llvm::GlobalVariable *GV)
Definition: SanitizerMetadata.cpp:82
clang::CodeGen::CodeGenFunction::EmitSEHTryStmt
void EmitSEHTryStmt(const SEHTryStmt &S)
Definition: CGException.cpp:1640
clang::CodeGen::CodeGenFunction::EmitIgnoredExpr
void EmitIgnoredExpr(const Expr *E)
EmitIgnoredExpr - Emit an expression in a context which ignores the result.
Definition: CGExpr.cpp:190
PrettyStackTrace.h
clang::CodeGen::CodeGenFunction::EmitForStmt
void EmitForStmt(const ForStmt &S, ArrayRef< const Attr * > Attrs=None)
Definition: CGStmt.cpp:999
clang::CodeGen::CodeGenFunction::EmitOMPForDirective
void EmitOMPForDirective(const OMPForDirective &S)
Definition: CGStmtOpenMP.cpp:3824
DiagnosticSema.h
clang::CodeGen::CodeGenFunction::EmitOMPSectionsDirective
void EmitOMPSectionsDirective(const OMPSectionsDirective &S)
Definition: CGStmtOpenMP.cpp:4054
clang::CodeGen::CodeGenFunction::ContainsLabel
static bool ContainsLabel(const Stmt *S, bool IgnoreCaseStmts=false)
ContainsLabel - Return true if the statement contains a label in it.
Definition: CodeGenFunction.cpp:1482
clang::CodeGen::CodeGenTypes::GetFunctionType
llvm::FunctionType * GetFunctionType(const CGFunctionInfo &Info)
GetFunctionType - Get the LLVM function type for.
Definition: CGCall.cpp:1613
clang::CodeGen::CodeGenModule::getDataLayout
const llvm::DataLayout & getDataLayout() const
Definition: CodeGenModule.h:706
clang::Type::castAs
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:7310
clang::CodeGen::CodeGenFunction::EmitOMPTargetParallelForSimdDirective
void EmitOMPTargetParallelForSimdDirective(const OMPTargetParallelForSimdDirective &S)
Definition: CGStmtOpenMP.cpp:7353
clang::CodeGen::CodeGenFunction::StartFunction
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.
Definition: CodeGenFunction.cpp:709
clang::GCCAsmStmt
This represents a GCC inline-assembly statement extension.
Definition: Stmt.h:3006
clang::CodeGen::CodeGenFunction::LoopStack
LoopInfoStack LoopStack
Definition: CodeGenFunction.h:268
clang::TargetInfo::ConstraintInfo::allowsRegister
bool allowsRegister() const
Definition: TargetInfo.h:1024
clang::CodeGen::LValue
LValue - This represents an lvalue references.
Definition: CGValue.h:171
clang::CodeGen::CodeGenFunction::EHStack
EHScopeStack EHStack
Definition: CodeGenFunction.h:619
clang::LabelDecl::getStmt
LabelStmt * getStmt() const
Definition: Decl.h:518
clang::AsmStmt
AsmStmt is the base class for GCCAsmStmt and MSAsmStmt.
Definition: Stmt.h:2847
clang::CodeGen::CodeGenFunction::getOverlapForReturnValue
AggValueSlot::Overlap_t getOverlapForReturnValue()
Determine whether a return value slot may overlap some other object.
Definition: CodeGenFunction.h:2681
clang::CodeGen::CodeGenFunction::MakeNaturalAlignAddrLValue
LValue MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T)
Definition: CodeGenFunction.cpp:187
clang::CodeGen::CodeGenFunction::getTargetHooks
const TargetCodeGenInfo & getTargetHooks() const
Definition: CodeGenFunction.h:2026
clang::CodeGen::AggValueSlot::forAddr
static AggValueSlot forAddr(Address addr, Qualifiers quals, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, IsAliased_t isAliased, Overlap_t mayOverlap, IsZeroed_t isZeroed=IsNotZeroed, IsSanitizerChecked_t isChecked=IsNotSanitizerChecked)
forAddr - Make a slot for an aggregate value.
Definition: CGValue.h:574
clang::CodeGen::CodeGenFunction::EmitOMPForSimdDirective
void EmitOMPForSimdDirective(const OMPForSimdDirective &S)
Definition: CGStmtOpenMP.cpp:3879
clang::Stmt::getStmtClass
StmtClass getStmtClass() const
Definition: Stmt.h:1160
clang::CodeGen::CodeGenFunction::EmitOMPTargetParallelForDirective
void EmitOMPTargetParallelForDirective(const OMPTargetParallelForDirective &S)
Definition: CGStmtOpenMP.cpp:7314
clang::syntax::NodeRole::Size
@ Size
clang::TargetInfo::validateInputConstraint
bool validateInputConstraint(MutableArrayRef< ConstraintInfo > OutputConstraints, ConstraintInfo &info) const
Definition: TargetInfo.cpp:721
clang::CodeGen::CodeGenFunction::EmitOMPSingleDirective
void EmitOMPSingleDirective(const OMPSingleDirective &S)
Definition: CGStmtOpenMP.cpp:4150
clang::CodeGen::CodeGenFunction::EmitOMPParallelForDirective
void EmitOMPParallelForDirective(const OMPParallelForDirective &S)
Definition: CGStmtOpenMP.cpp:4329
clang::CodeGen::CodeGenFunction::EmitCallOrInvoke
llvm::CallBase * EmitCallOrInvoke(llvm::FunctionCallee 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...
Definition: CGCall.cpp:4541
clang::CodeGen::Address::getPointer
llvm::Value * getPointer() const
Definition: Address.h:93
clang::CodeGen::CodeGenModule::ErrorUnsupported
void ErrorUnsupported(const Stmt *S, const char *Type)
Print out an error that codegen doesn't support the specified stmt yet.
Definition: CodeGenModule.cpp:1059
clang::CodeGen::CodeGenFunction
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
Definition: CodeGenFunction.h:231
clang::CodeGen::CodeGenFunction::SawAsmBlock
bool SawAsmBlock
Whether we processed a Microsoft-style asm block during CodeGen.
Definition: CodeGenFunction.h:540
clang::ValueDecl
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:674
clang::TargetInfo::ConstraintInfo::hasMatchingInput
bool hasMatchingInput() const
Return true if this output operand has a matching (tied) input operand.
Definition: TargetInfo.h:1029
clang::CodeGen::CodeGenFunction::getBundlesForFunclet
SmallVector< llvm::OperandBundleDef, 1 > getBundlesForFunclet(llvm::Value *Callee)
Definition: CGCall.cpp:4473
clang::CodeGen::CodeGenFunction::CGCapturedStmtInfo::getContextValue
virtual llvm::Value * getContextValue() const
Definition: CodeGenFunction.h:434
clang::ASTContext::getTagDeclType
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl.
Definition: ASTContext.cpp:5813
clang::CodeGen::AggValueSlot::IsNotAliased
@ IsNotAliased
Definition: CGValue.h:550
clang::CodeGen::CodeGenFunction::CGCapturedStmtInfo::getThisFieldDecl
virtual FieldDecl * getThisFieldDecl() const
Definition: CodeGenFunction.h:442
clang::CodeGen::CodeGenFunction::CGCapturedStmtInfo::setContextValue
virtual void setContextValue(llvm::Value *V)
Definition: CodeGenFunction.h:432
clang::Expr::getExprLoc
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Definition: Expr.cpp:247
clang::CodeGen::CodeGenModule
This class organizes the cross-function state that is used while generating LLVM code.
Definition: CodeGenModule.h:275
clang::RecordDecl::fields
field_range fields() const
Definition: Decl.h:4127
clang::QualType::isNull
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: Type.h:740
clang::TargetInfo::ConstraintInfo::hasTiedOperand
bool hasTiedOperand() const
Return true if this input operand is a matching constraint that ties it to an output operand.
Definition: TargetInfo.h:1036
llvm::ArrayRef
Definition: LLVM.h:34
clang::Stmt::Likelihood
Likelihood
The likelihood of a branch being taken.
Definition: Stmt.h:1103
Value
Value
Definition: UninitializedValues.cpp:102
UpdateAsmCallInst
static void UpdateAsmCallInst(llvm::CallBase &Result, bool HasSideEffect, bool HasUnwindClobber, bool ReadOnly, bool ReadNone, bool NoMerge, const AsmStmt &S, const std::vector< llvm::Type * > &ResultRegTypes, const std::vector< llvm::Type * > &ArgElemTypes, CodeGenFunction &CGF, std::vector< llvm::Value * > &RegResults)
Definition: CGStmt.cpp:2228
clang::CodeGen::CodeGenFunction::EmitAggExpr
void EmitAggExpr(const Expr *E, AggValueSlot AS)
EmitAggExpr - Emit the computation of the specified expression of aggregate type.
Definition: CGExprAgg.cpp:1993
clang::CodeGen::CodeGenFunction::LexicalScope
Definition: CodeGenFunction.h:931
clang::CodeGen::Address::invalid
static Address invalid()
Definition: Address.h:90
clang::CodeGen::CodeGenFunction::EmitObjCAtSynchronizedStmt
void EmitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt &S)
Definition: CGObjC.cpp:2046
clang::DoStmt
DoStmt - This represents a 'do/while' stmt.
Definition: Stmt.h:2482
clang::CodeGen::CodeGenFunction::NRVOFlags
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...
Definition: CodeGenFunction.h:617
clang::CapturedDecl::getBody
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
Definition: Decl.cpp:5011
clang::CapturedDecl::isNothrow
bool isNothrow() const
Definition: Decl.cpp:5014
clang::CodeGen::FunctionArgList
FunctionArgList - Type for representing both the decl and type of parameters to a function.
Definition: CGCall.h:356
StmtVisitor.h
clang::CodeGen::CodeGenFunction::EmitOMPTeamsDistributeParallelForDirective
void EmitOMPTeamsDistributeParallelForDirective(const OMPTeamsDistributeParallelForDirective &S)
Definition: CGStmtOpenMP.cpp:6733
clang::CodeGen::CGFunctionInfo::getReturnInfo
ABIArgInfo & getReturnInfo()
Definition: CGFunctionInfo.h:711
clang::CodeGen::CodeGenFunction::EmitSimpleOMPExecutableDirective
void EmitSimpleOMPExecutableDirective(const OMPExecutableDirective &D)
Emit simple code for OpenMP directives in Simd-only mode.
Definition: CGStmtOpenMP.cpp:7636
clang::CodeGen::CodeGenFunction::SourceLocToDebugLoc
llvm::DebugLoc SourceLocToDebugLoc(SourceLocation Location)
Converts Location to a DebugLoc, if debug information is enabled.
Definition: CodeGenFunction.cpp:2737
clang::CodeGen::CodeGenFunction::InitCapturedStruct
LValue InitCapturedStruct(const CapturedStmt &S)
Definition: CGStmt.cpp:2760
clang::TargetInfo::ConstraintInfo::getTiedOperand
unsigned getTiedOperand() const
Definition: TargetInfo.h:1037
llvm::SaveAndRestore< bool >
clang::CodeGen::AggValueSlot
An aggregate value slot.
Definition: CGValue.h:491
clang::BreakStmt
BreakStmt - This represents a break.
Definition: Stmt.h:2727
clang::CodeGen::CodeGenFunction::ConvertType
llvm::Type * ConvertType(QualType T)
Definition: CodeGenFunction.cpp:212
clang::CodeGen::CodeGenFunction::EmitBlockWithFallThrough
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...
Definition: CodeGenFunction.cpp:1245
clang::CodeGenOptions::hasReducedDebugInfo
bool hasReducedDebugInfo() const
Check if type and variable info should be emitted.
Definition: CodeGenOptions.h:470
clang::CodeGen::CodeGenFunction::EmitOMPTaskgroupDirective
void EmitOMPTaskgroupDirective(const OMPTaskgroupDirective &S)
Definition: CGStmtOpenMP.cpp:5102
clang::TargetInfo::ConstraintInfo::isReadWrite
bool isReadWrite() const
Definition: TargetInfo.h:1022
clang::CodeGen::RValue::getComplexVal
std::pair< llvm::Value *, llvm::Value * > getComplexVal() const
getComplexVal - Return the real/imag components of this complex value.
Definition: CGValue.h:68
clang::CodeGen::CodeGenFunction::EmitAsmStmt
void EmitAsmStmt(const AsmStmt &S)
Definition: CGStmt.cpp:2288
CollectStatementsForCase
static CSFC_Result CollectStatementsForCase(const Stmt *S, const SwitchCase *Case, bool &FoundCase, SmallVectorImpl< const Stmt * > &ResultStmts)
Definition: CGStmt.cpp:1622
clang::CodeGen::CodeGenFunction::hasAggregateEvaluationKind
static bool hasAggregateEvaluationKind(QualType T)
Definition: CodeGenFunction.h:2425
clang::CodeGen::CodeGenFunction::EmitOMPScanDirective
void EmitOMPScanDirective(const OMPScanDirective &S)
Definition: CGStmtOpenMP.cpp:5171
clang::CodeGen::Address::getElementType
llvm::Type * getElementType() const
Return the type of the values stored in this address.
Definition: Address.h:104
clang::CodeGen::EHScopeStack::stable_iterator::encloses
bool encloses(stable_iterator I) const
Returns true if this scope encloses I.
Definition: EHScopeStack.h:118
clang::Stmt::getLikelihood
static Likelihood getLikelihood(ArrayRef< const Attr * > Attrs)
Definition: Stmt.cpp:153
clang::CodeGen::CodeGenFunction::MakeAddrLValue
LValue MakeAddrLValue(Address Addr, QualType T, AlignmentSource Source=AlignmentSource::Type)
Definition: CodeGenFunction.h:2492
clang::CodeGenOptions::hasProfileClangInstr
bool hasProfileClangInstr() const
Check if Clang profile instrumenation is on.
Definition: CodeGenOptions.h:441
clang::APValue::toIntegralConstant
bool toIntegralConstant(APSInt &Result, QualType SrcTy, const ASTContext &Ctx) const
Try to convert this value to an integral constant.
Definition: APValue.cpp:942
clang::Expr::EvaluateAsRValue
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx, bool InConstantContext=false) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
Definition: ExprConstant.cpp:14976
clang::Expr::EvaluateAsInt
bool EvaluateAsInt(EvalResult &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects, bool InConstantContext=false) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer,...
Definition: ExprConstant.cpp:14994
clang::CodeGen::LValue::getPointer
llvm::Value * getPointer(CodeGenFunction &CGF) const
Definition: CGValue.h:337
clang::CodeGen::CGBuilderTy::CreateElementBitCast
Address CreateElementBitCast(Address Addr, llvm::Type *Ty, const llvm::Twine &Name="")
Cast the element type of the given address to a different type, preserving information like the align...
Definition: CGBuilder.h:165
clang::Stmt::LH_Unlikely
@ LH_Unlikely
Branch has the [[unlikely]] attribute.
Definition: Stmt.h:1104
AddVariableConstraints
static std::string AddVariableConstraints(const std::string &Constraint, const Expr &AsmExpr, const TargetInfo &Target, CodeGenModule &CGM, const AsmStmt &Stmt, const bool EarlyClobber, std::string *GCCReg=nullptr)
AddVariableConstraints - Look at AsmExpr and if it is a variable declared as using a particular regis...
Definition: CGStmt.cpp:2106
clang::CodeGen::CodeGenFunction::EmitScalarExpr
llvm::Value * EmitScalarExpr(const Expr *E, bool IgnoreResultAssign=false)
EmitScalarExpr - Emit the computation of the specified expression of LLVM scalar type,...
Definition: CGExprScalar.cpp:4869
clang::TargetInfo::ConstraintInfo
Definition: TargetInfo.h:991
clang::CodeGen::CodeGenFunction::EmitOMPTargetParallelDirective
void EmitOMPTargetParallelDirective(const OMPTargetParallelDirective &S)
Definition: CGStmtOpenMP.cpp:7274
clang::CXXForRangeStmt
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
Definition: StmtCXX.h:134
clang::LangOptions
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:78
clang::PrettyStackTraceLoc
If a crash happens while one of these objects are live, the message is printed out along with the spe...
Definition: PrettyStackTrace.h:26
clang::DeclStmt
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Definition: Stmt.h:1294
clang::CodeGen::CGFunctionInfo
CGFunctionInfo - Class to encapsulate the information about a function definition.
Definition: CGFunctionInfo.h:546
clang::ContinueStmt
ContinueStmt - This represents a continue.
Definition: Stmt.h:2697
clang::CodeGen::CodeGenFunction::EmitReturnStmt
void EmitReturnStmt(const ReturnStmt &S)
EmitReturnStmt - Note that due to GCC extensions, this can have an operand if the function returns vo...
Definition: CGStmt.cpp:1259
clang::ActionResult< Expr * >
clang::CaseStmt::getLHS
Expr * getLHS()
Definition: Stmt.h:1660
clang::CodeGen::CodeGenFunction::EmitLoadOfLValue
RValue EmitLoadOfLValue(LValue V, SourceLocation Loc)
EmitLoadOfLValue - Given an expression that represents a value lvalue, this method emits the address ...
Definition: CGExpr.cpp:1948
clang::CodeGen::CodeGenFunction::JumpDest::isValid
bool isValid() const
Definition: CodeGenFunction.h:245
clang::CodeGen::CodeGenFunction::FnRetTy
QualType FnRetTy
Definition: CodeGenFunction.h:324
clang::CodeGen::CodeGenPGO::assignRegionCounters
void assignRegionCounters(GlobalDecl GD, llvm::Function *Fn)
Assign counters to regions and configure them for PGO of a given function.
Definition: CodeGenPGO.cpp:794
clang::CodeGen::CodeGenFunction::EmitStoreOfComplex
void EmitStoreOfComplex(ComplexPairTy V, LValue dest, bool isInit)
EmitStoreOfComplex - Store a complex number into the specified l-value.
Definition: CGExprComplex.cpp:1139
clang::CodeGen::CodeGenFunction::EmitOMPMetaDirective
void EmitOMPMetaDirective(const OMPMetaDirective &S)
Definition: CGStmtOpenMP.cpp:1805
clang::CodeGen::CodeGenFunction::CGM
CodeGenModule & CGM
Definition: CodeGenFunction.h:261
clang::CodeGen::CodeGenFunction::JumpDest::getScopeDepth
EHScopeStack::stable_iterator getScopeDepth() const
Definition: CodeGenFunction.h:247
clang::CodeGen::TEK_Scalar
@ TEK_Scalar
Definition: CodeGenFunction.h:107
clang::CodeGen::CodeGenFunction::EvaluateExprAsBool
llvm::Value * EvaluateExprAsBool(const Expr *E)
EvaluateExprAsBool - Perform the usual unary conversions on the specified expression and compare the ...
Definition: CGExpr.cpp:171
clang::CodeGen::CodeGenFunction::CurFn
llvm::Function * CurFn
Definition: CodeGenFunction.h:325
clang::CodeGen::CodeGenFunction::EmitOMPTileDirective
void EmitOMPTileDirective(const OMPTileDirective &S)
Definition: CGStmtOpenMP.cpp:2670
clang::CodeGen::CodeGenFunction::EmitOMPTargetTeamsDirective
void EmitOMPTargetTeamsDirective(const OMPTargetTeamsDirective &S)
Definition: CGStmtOpenMP.cpp:6588
clang::Expr::IgnoreParens
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
Definition: Expr.cpp:2943
clang
Definition: CalledOnceCheck.h:17
clang::CodeGen::CGBuilderTy::CreateFlagStore
llvm::StoreInst * CreateFlagStore(bool Value, llvm::Value *Addr)
Emit a store to an i1 flag variable.
Definition: CGBuilder.h:126
clang::CodeGen::CodeGenFunction::JumpDest
A jump destination is an abstract label, branching to which may require a jump out through normal cle...
Definition: CodeGenFunction.h:239
clang::CodeGen::RValue::get
static RValue get(llvm::Value *V)
Definition: CGValue.h:89
clang::CodeGen::CodeGenFunction::EmitAggregateCopy
void EmitAggregateCopy(LValue Dest, LValue Src, QualType EltTy, AggValueSlot::Overlap_t MayOverlap, bool isVolatile=false)
EmitAggregateCopy - Emit an aggregate copy.
Definition: CGExprAgg.cpp:2056
clang::CodeGen::CodeGenFunction::EmitIfStmt
void EmitIfStmt(const IfStmt &S)
Definition: CGStmt.cpp:745
clang::DeclaratorContext::Block
@ Block
clang::CodeGen::CodeGenFunction::EmitOMPAtomicDirective
void EmitOMPAtomicDirective(const OMPAtomicDirective &S)
Definition: CGStmtOpenMP.cpp:6324
clang::Stmt
Stmt - This represents one statement.
Definition: Stmt.h:69
clang::Stmt::getLikelihoodAttr
static const Attr * getLikelihoodAttr(const Stmt *S)
Definition: Stmt.cpp:161
clang::DefaultStmt
Definition: Stmt.h:1727
clang::CodeGen::CodeGenFunction::RunCleanupsScope::ForceCleanup
void ForceCleanup(std::initializer_list< llvm::Value ** > ValuesToReload={})
Force the emission of cleanups now, instead of waiting until this object is destroyed.
Definition: CodeGenFunction.h:917
clang::CodeGen::CodeGenTypeCache::IntPtrTy
llvm::IntegerType * IntPtrTy
Definition: CodeGenTypeCache.h:49
CSFC_Result
CSFC_Result
CollectStatementsForCase - Given the body of a 'switch' statement and a constant value that is being ...
Definition: CGStmt.cpp:1621
clang::CC_SwiftAsync
@ CC_SwiftAsync
Definition: Specifiers.h:279
clang::CodeGen::CodeGenFunction::EmitObjCAtThrowStmt
void EmitObjCAtThrowStmt(const ObjCAtThrowStmt &S)
Definition: CGObjC.cpp:2042
clang::TargetInfo::ConstraintInfo::requiresImmediateConstant
bool requiresImmediateConstant() const
Definition: TargetInfo.h:1042
clang::CodeGen::CodeGenFunction::CapturedStmtInfo
CGCapturedStmtInfo * CapturedStmtInfo
Definition: CodeGenFunction.h:476
clang::Expr::getType
QualType getType() const
Definition: Expr.h:141
clang::Attr
Attr - This represents one attribute.
Definition: Attr.h:41
clang::CodeGen::CodeGenFunction::EmitOMPMaskedDirective
void EmitOMPMaskedDirective(const OMPMaskedDirective &S)
Definition: CGStmtOpenMP.cpp:4243
clang::CodeGen::RValue::getScalarVal
llvm::Value * getScalarVal() const
getScalarVal() - Return the Value* of this scalar value.
Definition: CGValue.h:61
clang::CodeGen::CodeGenModule::getDiags
DiagnosticsEngine & getDiags() const
Definition: CodeGenModule.h:705
clang::CodeGen::ApplyDebugLocation::CreateEmpty
static ApplyDebugLocation CreateEmpty(CodeGenFunction &CGF)
Set the IRBuilder to not attach debug locations.
Definition: CGDebugInfo.h:847
clang::Stmt::getBeginLoc
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.cpp:336
FindCaseStatementsForValue
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...
Definition: CGStmt.cpp:1777
clang::CodeGen::RValue::isScalar
bool isScalar() const
Definition: CGValue.h:54
clang::CodeGen::EHScopeStack::stable_begin
stable_iterator stable_begin() const
Create a stable reference to the top of the EH stack.
Definition: EHScopeStack.h:384
clang::CaseStmt::getSubStmt
Stmt * getSubStmt()
Definition: Stmt.h:1690
clang::TargetInfo::convertConstraint
virtual std::string convertConstraint(const char *&Constraint) const
Definition: TargetInfo.h:1137
clang::CodeGen::CodeGenFunction::RunCleanupsScope::CGF
CodeGenFunction & CGF
Definition: CodeGenFunction.h:884
clang::CodeGen::EHScopeStack::stable_iterator::invalid
static stable_iterator invalid()
Definition: EHScopeStack.h:110
clang::CodeGen::CodeGenFunction::EmitOMPTargetTeamsDistributeDirective
void EmitOMPTargetTeamsDistributeDirective(const OMPTargetTeamsDistributeDirective &S)
Definition: CGStmtOpenMP.cpp:6634
clang::CodeGen::CodeGenFunction::EmitOMPTargetEnterDataDirective
void EmitOMPTargetEnterDataDirective(const OMPTargetEnterDataDirective &S)
Definition: CGStmtOpenMP.cpp:7193
clang::CodeGen::CodeGenFunction::EmitLValue
LValue EmitLValue(const Expr *E)
EmitLValue - Emit code to compute a designator that specifies the location of the expression.
Definition: CGExpr.cpp:1305
clang::Expr::isEvaluatable
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...
Definition: ExprConstant.cpp:15208
clang::CodeGen::CodeGenFunction::RetExpr
const Expr * RetExpr
If a return statement is being visited, this holds the return statment's result expression.
Definition: CodeGenFunction.h:364
clang::CodeGen::CodeGenFunction::EmitOMPDepobjDirective
void EmitOMPDepobjDirective(const OMPDepobjDirective &S)
Definition: CGStmtOpenMP.cpp:5148
clang::CodeGen::CodeGenFunction::EmitOMPDistributeParallelForDirective
void EmitOMPDistributeParallelForDirective(const OMPDistributeParallelForDirective &S)
Definition: CGStmtOpenMP.cpp:3133
clang::CodeGen::EHScopeStack::stable_end
static stable_iterator stable_end()
Create a stable reference to the bottom of the EH stack.
Definition: EHScopeStack.h:389
clang::CodeGen::CodeGenFunction::EmitDecl
void EmitDecl(const Decl &D)
EmitDecl - Emit a declaration.
Definition: CGDecl.cpp:47
Stmt.h
clang::CodeGen::CodeGenFunction::EmitOMPCancelDirective
void EmitOMPCancelDirective(const OMPCancelDirective &S)
Definition: CGStmtOpenMP.cpp:6943
clang::CodeGen::CodeGenFunction::CurFnInfo
const CGFunctionInfo * CurFnInfo
Definition: CodeGenFunction.h:323
llvm::SmallVectorImpl
Definition: Randstruct.h:18
clang::CodeGen::CodeGenFunction::EmitStopPoint
void EmitStopPoint(const Stmt *S)
EmitStopPoint - Emit a debug stoppoint if we are emitting debug info.
Definition: CGStmt.cpp:43
clang::CodeGen::CodeGenFunction::EmitOMPTargetSimdDirective
void EmitOMPTargetSimdDirective(const OMPTargetSimdDirective &S)
Definition: CGStmtOpenMP.cpp:3176
clang::CodeGen::CodeGenFunction::containsBreak
static bool containsBreak(const Stmt *S)
containsBreak - Return true if the statement contains a break out of it.
Definition: CodeGenFunction.cpp:1514
clang::CodeGen::CodeGenFunction::CreateMemTemp
Address CreateMemTemp(QualType T, const Twine &Name="tmp", Address *Alloca=nullptr)
CreateMemTemp - Create a temporary memory object of the given type, with appropriate alignmen and cas...
Definition: CGExpr.cpp:135
clang::CodeGen::CodeGenFunction::EmitOMPTargetExitDataDirective
void EmitOMPTargetExitDataDirective(const OMPTargetExitDataDirective &S)
Definition: CGStmtOpenMP.cpp:7214
clang::Expr
This represents one expression.
Definition: Expr.h:109
clang::CodeGen::CodeGenFunction::EmitOMPUnrollDirective
void EmitOMPUnrollDirective(const OMPUnrollDirective &S)
Definition: CGStmtOpenMP.cpp:2676
SM
#define SM(sm)
Definition: Cuda.cpp:81
clang::CodeGen::CodeGenFunction::EmitBranchThroughCleanup
void EmitBranchThroughCleanup(JumpDest Dest)
EmitBranchThroughCleanup - Emit a branch from the current insert block through the normal cleanup han...
Definition: CGCleanup.cpp:1087
clang::CodeGen::CodeGenFunction::EmitOMPParallelMasterTaskLoopDirective
void EmitOMPParallelMasterTaskLoopDirective(const OMPParallelMasterTaskLoopDirective &S)
Definition: CGStmtOpenMP.cpp:7568
clang::CodeGen::CodeGenFunction::checkIfLoopMustProgress
bool checkIfLoopMustProgress(bool HasConstantCond)
Returns true if a loop must make progress, which means the mustprogress attribute can be added.
Definition: CodeGenFunction.h:586
clang::CodeGen::CodeGenPGO::setCurrentStmt
void setCurrentStmt(const Stmt *S)
If the execution count for the current statement is known, record that as the current count.
Definition: CodeGenPGO.h:73
clang::CodeGen::CodeGenFunction::EmitOMPTaskDirective
void EmitOMPTaskDirective(const OMPTaskDirective &S)
Definition: CGStmtOpenMP.cpp:5054
clang::CodeGen::CodeGenFunction::EmitOMPDistributeDirective
void EmitOMPDistributeDirective(const OMPDistributeDirective &S)
Definition: CGStmtOpenMP.cpp:5603
clang::CodeGen::CodeGenFunction::EmitWhileStmt
void EmitWhileStmt(const WhileStmt &S, ArrayRef< const Attr * > Attrs=None)
Definition: CGStmt.cpp:839
clang::TargetInfo::resolveSymbolicName
bool resolveSymbolicName(const char *&Name, ArrayRef< ConstraintInfo > OutputConstraints, unsigned &Index) const
Definition: TargetInfo.cpp:698
clang::Decl::getLocation
SourceLocation getLocation() const
Definition: DeclBase.h:425
clang::CodeGen::CodeGenFunction::CGCapturedStmtInfo::getHelperName
virtual StringRef getHelperName() const
Get the name of the capture helper.
Definition: CodeGenFunction.h:455
clang::DeclRefExpr
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1223
clang::RecordDecl
Represents a struct/union/class.
Definition: Decl.h:3901
clang::CallExpr
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2801
clang::CodeGen::CodeGenFunction::EmitOMPGenericLoopDirective
void EmitOMPGenericLoopDirective(const OMPGenericLoopDirective &S)
Definition: CGStmtOpenMP.cpp:7626
clang::CodeGen::CodeGenFunction::EmitBlock
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
EmitBlock - Emit the given block.
Definition: CGStmt.cpp:544
clang::CodeGen::CodeGenModule::getSanitizerMetadata
SanitizerMetadata * getSanitizerMetadata()
Definition: CodeGenModule.h:1322
clang::interp::Sub
bool Sub(InterpState &S, CodePtr OpPC)
Definition: Interp.h:142
clang::CodeGen::CodeGenFunction::EmitLValueForFieldInitialization
LValue EmitLValueForFieldInitialization(LValue Base, const FieldDecl *Field)
EmitLValueForFieldInitialization - Like EmitLValueForField, except that if the Field is a reference,...
Definition: CGExpr.cpp:4526
clang::CapturedDecl::getContextParam
ImplicitParamDecl * getContextParam() const
Retrieve the parameter containing captured variables.
Definition: Decl.h:4455
clang::CodeGen::CodeGenFunction::EmitOMPCanonicalLoop
void EmitOMPCanonicalLoop(const OMPCanonicalLoop *S)
Emit an OMPCanonicalLoop using the OpenMPIRBuilder.
Definition: CGStmtOpenMP.cpp:1997
clang::StringLiteral::getString
StringRef getString() const
Definition: Expr.h:1850
clang::CodeGen::CodeGenFunction::ReturnBlock
JumpDest ReturnBlock
ReturnBlock - Unified return block.
Definition: CodeGenFunction.h:352
clang::CodeGen::CodeGenModule::Error
void Error(SourceLocation loc, StringRef error)
Emit a general error that something can't be done.
Definition: CodeGenModule.cpp:1052
clang::CodeGen::CodeGenFunction::EmitCaseStmtRange
void EmitCaseStmtRange(const CaseStmt &S, ArrayRef< const Attr * > Attrs)
EmitCaseStmtRange - If case statement range is not too big then add multiple cases to switch instruct...
Definition: CGStmt.cpp:1391
clang::CodeGen::CodeGenModule::getLLVMContext
llvm::LLVMContext & getLLVMContext()
Definition: CodeGenModule.h:715
clang::CodeGenOptions::IAD_ATT
@ IAD_ATT
Definition: CodeGenOptions.h:101
clang::CodeGen::CodeGenFunction::EmitOMPParallelForSimdDirective
void EmitOMPParallelForSimdDirective(const OMPParallelForSimdDirective &S)
Definition: CGStmtOpenMP.cpp:4362
clang::CodeGen::EHScopeStack::stable_iterator
A saved depth on the scope stack.
Definition: EHScopeStack.h:101
clang::CodeGen::CodeGenFunction::EmitAttributedStmt
void EmitAttributedStmt(const AttributedStmt &S)
Definition: CGStmt.cpp:679
clang::CodeGen::CodeGenFunction::getLangOpts
const LangOptions & getLangOpts() const
Definition: CodeGenFunction.h:1995
clang::TargetInfo::validateOutputConstraint
bool validateOutputConstraint(ConstraintInfo &Info) const
Definition: TargetInfo.cpp:624
clang::CodeGen::CodeGenFunction::EmitSEHLeaveStmt
void EmitSEHLeaveStmt(const SEHLeaveStmt &S)
Definition: CGException.cpp:2269
clang::CodeGen::CodeGenFunction::EmitCoreturnStmt
void EmitCoreturnStmt(const CoreturnStmt &S)
Definition: CGCoroutine.cpp:275
clang::CodeGen::TargetCodeGenInfo::addReturnRegisterOutputs
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.
Definition: TargetInfo.h:158
clang::CodeGen::CodeGenFunction::EmitCaseStmt
void EmitCaseStmt(const CaseStmt &S, ArrayRef< const Attr * > Attrs)
Definition: CGStmt.cpp:1476
clang::CodeGen::CodeGenFunction::EmitIndirectGotoStmt
void EmitIndirectGotoStmt(const IndirectGotoStmt &S)
Definition: CGStmt.cpp:724
clang::SourceLocation::getRawEncoding
UIntTy getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it.
Definition: SourceLocation.h:146
clang::ReturnStmt
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Definition: Stmt.h:2764
clang::CodeGen::RValue::getAggregateAddress
Address getAggregateAddress() const
getAggregateAddr() - Return the Value* of the address of the aggregate.
Definition: CGValue.h:73
clang::DiagnosticsEngine::Report
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Definition: Diagnostic.h:1536
clang::CodeGen::CodeGenFunction::EmitBreakStmt
void EmitBreakStmt(const BreakStmt &S)
Definition: CGStmt.cpp:1364
clang::CodeGen::CodeGenFunction::NextCleanupDestIndex
unsigned NextCleanupDestIndex
Definition: CodeGenFunction.h:657
clang::CodeGen::CGBuilderTy::CreateLoad
llvm::LoadInst * CreateLoad(Address Addr, const llvm::Twine &Name="")
Definition: CGBuilder.h:69
clang::CodeGen::CodeGenFunction::EmitOMPCriticalDirective
void EmitOMPCriticalDirective(const OMPCriticalDirective &S)
Definition: CGStmtOpenMP.cpp:4278
clang::CodeGen::CodeGenFunction::EmitBranch
void EmitBranch(llvm::BasicBlock *Block)
EmitBranch - Emit a branch to the specified basic block from the current insert block,...
Definition: CGStmt.cpp:564
clang::SwitchCase::getNextSwitchCase
const SwitchCase * getNextSwitchCase() const
Definition: Stmt.h:1546
clang::CodeGen::CodeGenFunction::ReturnValue
Address ReturnValue
ReturnValue - The temporary alloca to hold the return value.
Definition: CodeGenFunction.h:356
clang::CodeGen::CodeGenFunction::Target
const TargetInfo & Target
Definition: CodeGenFunction.h:262
clang::NamedDecl::getName
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition: Decl.h:274