clang  3.7.0
CodeGenFunction.h
Go to the documentation of this file.
1 //===-- CodeGenFunction.h - Per-Function state for LLVM CodeGen -*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This is the internal per-function state used for llvm translation.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_LIB_CODEGEN_CODEGENFUNCTION_H
15 #define LLVM_CLANG_LIB_CODEGEN_CODEGENFUNCTION_H
16 
17 #include "CGBuilder.h"
18 #include "CGDebugInfo.h"
19 #include "CGLoopInfo.h"
20 #include "CGValue.h"
21 #include "CodeGenModule.h"
22 #include "CodeGenPGO.h"
23 #include "EHScopeStack.h"
24 #include "clang/AST/CharUnits.h"
25 #include "clang/AST/ExprCXX.h"
26 #include "clang/AST/ExprObjC.h"
27 #include "clang/AST/Type.h"
28 #include "clang/Basic/ABI.h"
31 #include "clang/Basic/TargetInfo.h"
33 #include "llvm/ADT/ArrayRef.h"
34 #include "llvm/ADT/DenseMap.h"
35 #include "llvm/ADT/SmallVector.h"
36 #include "llvm/IR/ValueHandle.h"
37 #include "llvm/Support/Debug.h"
38 
39 namespace llvm {
40 class BasicBlock;
41 class LLVMContext;
42 class MDNode;
43 class Module;
44 class SwitchInst;
45 class Twine;
46 class Value;
47 class CallSite;
48 }
49 
50 namespace clang {
51 class ASTContext;
52 class BlockDecl;
53 class CXXDestructorDecl;
54 class CXXForRangeStmt;
55 class CXXTryStmt;
56 class Decl;
57 class LabelDecl;
58 class EnumConstantDecl;
59 class FunctionDecl;
60 class FunctionProtoType;
61 class LabelStmt;
62 class ObjCContainerDecl;
63 class ObjCInterfaceDecl;
64 class ObjCIvarDecl;
65 class ObjCMethodDecl;
66 class ObjCImplementationDecl;
67 class ObjCPropertyImplDecl;
68 class TargetInfo;
69 class TargetCodeGenInfo;
70 class VarDecl;
71 class ObjCForCollectionStmt;
72 class ObjCAtTryStmt;
73 class ObjCAtThrowStmt;
74 class ObjCAtSynchronizedStmt;
75 class ObjCAutoreleasePoolStmt;
76 
77 namespace CodeGen {
78 class CodeGenTypes;
79 class CGFunctionInfo;
80 class CGRecordLayout;
81 class CGBlockInfo;
82 class CGCXXABI;
83 class BlockFlags;
84 class BlockFieldFlags;
85 
86 /// The kind of evaluation to perform on values of a particular
87 /// type. Basically, is the code in CGExprScalar, CGExprComplex, or
88 /// CGExprAgg?
89 ///
90 /// TODO: should vectors maybe be split out into their own thing?
95 };
96 
97 /// CodeGenFunction - This class organizes the per-function state that is used
98 /// while generating LLVM code.
100  CodeGenFunction(const CodeGenFunction &) = delete;
101  void operator=(const CodeGenFunction &) = delete;
102 
103  friend class CGCXXABI;
104 public:
105  /// A jump destination is an abstract label, branching to which may
106  /// require a jump out through normal cleanups.
107  struct JumpDest {
108  JumpDest() : Block(nullptr), ScopeDepth(), Index(0) {}
109  JumpDest(llvm::BasicBlock *Block,
111  unsigned Index)
112  : Block(Block), ScopeDepth(Depth), Index(Index) {}
113 
114  bool isValid() const { return Block != nullptr; }
115  llvm::BasicBlock *getBlock() const { return Block; }
116  EHScopeStack::stable_iterator getScopeDepth() const { return ScopeDepth; }
117  unsigned getDestIndex() const { return Index; }
118 
119  // This should be used cautiously.
121  ScopeDepth = depth;
122  }
123 
124  private:
125  llvm::BasicBlock *Block;
127  unsigned Index;
128  };
129 
130  CodeGenModule &CGM; // Per-module state.
132 
133  typedef std::pair<llvm::Value *, llvm::Value *> ComplexPairTy;
136 
137  /// \brief CGBuilder insert helper. This function is called after an
138  /// instruction is created using Builder.
139  void InsertHelper(llvm::Instruction *I, const llvm::Twine &Name,
140  llvm::BasicBlock *BB,
141  llvm::BasicBlock::iterator InsertPt) const;
142 
143  /// CurFuncDecl - Holds the Decl for the current outermost
144  /// non-closure context.
146  /// CurCodeDecl - This is the inner-most code context, which includes blocks.
150  llvm::Function *CurFn;
151 
152  /// CurGD - The GlobalDecl for the current function being compiled.
154 
155  /// PrologueCleanupDepth - The cleanup depth enclosing all the
156  /// cleanups associated with the parameters.
158 
159  /// ReturnBlock - Unified return block.
161 
162  /// ReturnValue - The temporary alloca to hold the return value. This is null
163  /// iff the function has no return value.
165 
166  /// AllocaInsertPoint - This is an instruction in the entry block before which
167  /// we prefer to insert allocas.
168  llvm::AssertingVH<llvm::Instruction> AllocaInsertPt;
169 
170  /// \brief API for captured statement code generation.
172  public:
174  : Kind(K), ThisValue(nullptr), CXXThisFieldDecl(nullptr) {}
177  : Kind(K), ThisValue(nullptr), CXXThisFieldDecl(nullptr) {
178 
182  E = S.capture_end();
183  I != E; ++I, ++Field) {
184  if (I->capturesThis())
185  CXXThisFieldDecl = *Field;
186  else if (I->capturesVariable())
187  CaptureFields[I->getCapturedVar()] = *Field;
188  }
189  }
190 
191  virtual ~CGCapturedStmtInfo();
192 
193  CapturedRegionKind getKind() const { return Kind; }
194 
195  virtual void setContextValue(llvm::Value *V) { ThisValue = V; }
196  // \brief Retrieve the value of the context parameter.
197  virtual llvm::Value *getContextValue() const { return ThisValue; }
198 
199  /// \brief Lookup the captured field decl for a variable.
200  virtual const FieldDecl *lookup(const VarDecl *VD) const {
201  return CaptureFields.lookup(VD);
202  }
203 
204  bool isCXXThisExprCaptured() const { return getThisFieldDecl() != nullptr; }
205  virtual FieldDecl *getThisFieldDecl() const { return CXXThisFieldDecl; }
206 
207  static bool classof(const CGCapturedStmtInfo *) {
208  return true;
209  }
210 
211  /// \brief Emit the captured statement body.
212  virtual void EmitBody(CodeGenFunction &CGF, const Stmt *S) {
214  CGF.EmitStmt(S);
215  }
216 
217  /// \brief Get the name of the capture helper.
218  virtual StringRef getHelperName() const { return "__captured_stmt"; }
219 
220  private:
221  /// \brief The kind of captured statement being generated.
223 
224  /// \brief Keep the map between VarDecl and FieldDecl.
225  llvm::SmallDenseMap<const VarDecl *, FieldDecl *> CaptureFields;
226 
227  /// \brief The base address of the captured record, passed in as the first
228  /// argument of the parallel region function.
229  llvm::Value *ThisValue;
230 
231  /// \brief Captured 'this' type.
232  FieldDecl *CXXThisFieldDecl;
233  };
235 
236  /// \brief RAII for correct setting/restoring of CapturedStmtInfo.
238  private:
239  CodeGenFunction &CGF;
240  CGCapturedStmtInfo *PrevCapturedStmtInfo;
241  public:
243  CGCapturedStmtInfo *NewCapturedStmtInfo)
244  : CGF(CGF), PrevCapturedStmtInfo(CGF.CapturedStmtInfo) {
245  CGF.CapturedStmtInfo = NewCapturedStmtInfo;
246  }
247  ~CGCapturedStmtRAII() { CGF.CapturedStmtInfo = PrevCapturedStmtInfo; }
248  };
249 
250  /// BoundsChecking - Emit run-time bounds checks. Higher values mean
251  /// potentially higher performance penalties.
252  unsigned char BoundsChecking;
253 
254  /// \brief Sanitizers enabled for this function.
256 
257  /// \brief True if CodeGen currently emits code implementing sanitizer checks.
259 
260  /// \brief RAII object to set/unset CodeGenFunction::IsSanitizerScope.
262  CodeGenFunction *CGF;
263  public:
265  ~SanitizerScope();
266  };
267 
268  /// In C++, whether we are code generating a thunk. This controls whether we
269  /// should emit cleanups.
271 
272  /// In ARC, whether we should autorelease the return value.
274 
275  /// Whether we processed a Microsoft-style asm block during CodeGen. These can
276  /// potentially set the return value.
278 
279  /// True if the current function is an outlined SEH helper. This can be a
280  /// finally block or filter expression.
282 
285 
286  llvm::DenseMap<const VarDecl *, FieldDecl *> LambdaCaptureFields;
288 
289  /// \brief A mapping from NRVO variables to the flags used to indicate
290  /// when the NRVO has been applied to this variable.
291  llvm::DenseMap<const VarDecl *, llvm::Value *> NRVOFlags;
292 
296 
297  /// Header for data within LifetimeExtendedCleanupStack.
299  /// The size of the following cleanup object.
300  unsigned Size;
301  /// The kind of cleanup to push: a value from the CleanupKind enumeration.
303 
304  size_t getSize() const { return Size; }
305  CleanupKind getKind() const { return Kind; }
306  };
307 
308  /// i32s containing the indexes of the cleanup destinations.
309  llvm::AllocaInst *NormalCleanupDest;
310 
312 
313  /// FirstBlockInfo - The head of a singly-linked-list of block layouts.
315 
316  /// EHResumeBlock - Unified block containing a call to llvm.eh.resume.
317  llvm::BasicBlock *EHResumeBlock;
318 
319  /// The exception slot. All landing pads write the current exception pointer
320  /// into this alloca.
322 
323  /// The selector slot. Under the MandatoryCleanup model, all landing pads
324  /// write the current selector value into this alloca.
325  llvm::AllocaInst *EHSelectorSlot;
326 
327  /// A stack of exception code slots. Entering an __except block pushes a slot
328  /// on the stack and leaving pops one. The __exception_code() intrinsic loads
329  /// a value from the top of the stack.
331 
332  /// Value returned by __exception_info intrinsic.
333  llvm::Value *SEHInfo = nullptr;
334 
335  /// Emits a landing pad for the current EH stack.
336  llvm::BasicBlock *EmitLandingPad();
337 
338  llvm::BasicBlock *getInvokeDestImpl();
339 
340  template <class T>
342  return DominatingValue<T>::save(*this, value);
343  }
344 
345 public:
346  /// ObjCEHValueStack - Stack of Objective-C exception values, used for
347  /// rethrows.
349 
350  /// A class controlling the emission of a finally block.
351  class FinallyInfo {
352  /// Where the catchall's edge through the cleanup should go.
353  JumpDest RethrowDest;
354 
355  /// A function to call to enter the catch.
356  llvm::Constant *BeginCatchFn;
357 
358  /// An i1 variable indicating whether or not the @finally is
359  /// running for an exception.
360  llvm::AllocaInst *ForEHVar;
361 
362  /// An i8* variable into which the exception pointer to rethrow
363  /// has been saved.
364  llvm::AllocaInst *SavedExnVar;
365 
366  public:
367  void enter(CodeGenFunction &CGF, const Stmt *Finally,
368  llvm::Constant *beginCatchFn, llvm::Constant *endCatchFn,
369  llvm::Constant *rethrowFn);
370  void exit(CodeGenFunction &CGF);
371  };
372 
373  /// Returns true inside SEH __try blocks.
374  bool isSEHTryScope() const { return !SEHTryEpilogueStack.empty(); }
375 
376  /// pushFullExprCleanup - Push a cleanup to be run at the end of the
377  /// current full-expression. Safe against the possibility that
378  /// we're currently inside a conditionally-evaluated expression.
379  template <class T, class... As>
381  // If we're not in a conditional branch, or if none of the
382  // arguments requires saving, then use the unconditional cleanup.
383  if (!isInConditionalBranch())
384  return EHStack.pushCleanup<T>(kind, A...);
385 
386  // Stash values in a tuple so we can guarantee the order of saves.
387  typedef std::tuple<typename DominatingValue<As>::saved_type...> SavedTuple;
388  SavedTuple Saved{saveValueInCond(A)...};
389 
390  typedef EHScopeStack::ConditionalCleanup<T, As...> CleanupType;
391  EHStack.pushCleanupTuple<CleanupType>(kind, Saved);
393  }
394 
395  /// \brief Queue a cleanup to be pushed after finishing the current
396  /// full-expression.
397  template <class T, class... As>
399  assert(!isInConditionalBranch() && "can't defer conditional cleanup");
400 
401  LifetimeExtendedCleanupHeader Header = { sizeof(T), Kind };
402 
403  size_t OldSize = LifetimeExtendedCleanupStack.size();
405  LifetimeExtendedCleanupStack.size() + sizeof(Header) + Header.Size);
406 
407  static_assert(sizeof(Header) % llvm::AlignOf<T>::Alignment == 0,
408  "Cleanup will be allocated on misaligned address");
409  char *Buffer = &LifetimeExtendedCleanupStack[OldSize];
410  new (Buffer) LifetimeExtendedCleanupHeader(Header);
411  new (Buffer + sizeof(Header)) T(A...);
412  }
413 
414  /// Set up the last cleaup that was pushed as a conditional
415  /// full-expression cleanup.
416  void initFullExprCleanup();
417 
418  /// PushDestructorCleanup - Push a cleanup to call the
419  /// complete-object destructor of an object of the given type at the
420  /// given address. Does nothing if T is not a C++ class type with a
421  /// non-trivial destructor.
423 
424  /// PushDestructorCleanup - Push a cleanup to call the
425  /// complete-object variant of the given destructor on the object at
426  /// the given address.
427  void PushDestructorCleanup(const CXXDestructorDecl *Dtor,
428  llvm::Value *Addr);
429 
430  /// PopCleanupBlock - Will pop the cleanup entry on the stack and
431  /// process all branch fixups.
432  void PopCleanupBlock(bool FallThroughIsBranchThrough = false);
433 
434  /// DeactivateCleanupBlock - Deactivates the given cleanup block.
435  /// The block cannot be reactivated. Pops it if it's the top of the
436  /// stack.
437  ///
438  /// \param DominatingIP - An instruction which is known to
439  /// dominate the current IP (if set) and which lies along
440  /// all paths of execution between the current IP and the
441  /// the point at which the cleanup comes into scope.
443  llvm::Instruction *DominatingIP);
444 
445  /// ActivateCleanupBlock - Activates an initially-inactive cleanup.
446  /// Cannot be used to resurrect a deactivated cleanup.
447  ///
448  /// \param DominatingIP - An instruction which is known to
449  /// dominate the current IP (if set) and which lies along
450  /// all paths of execution between the current IP and the
451  /// the point at which the cleanup comes into scope.
453  llvm::Instruction *DominatingIP);
454 
455  /// \brief Enters a new scope for capturing cleanups, all of which
456  /// will be executed once the scope is exited.
458  EHScopeStack::stable_iterator CleanupStackDepth;
459  size_t LifetimeExtendedCleanupStackSize;
460  bool OldDidCallStackSave;
461  protected:
463  private:
464 
465  RunCleanupsScope(const RunCleanupsScope &) = delete;
466  void operator=(const RunCleanupsScope &) = delete;
467 
468  protected:
470 
471  public:
472  /// \brief Enter a new cleanup scope.
474  : PerformCleanup(true), CGF(CGF)
475  {
476  CleanupStackDepth = CGF.EHStack.stable_begin();
477  LifetimeExtendedCleanupStackSize =
478  CGF.LifetimeExtendedCleanupStack.size();
479  OldDidCallStackSave = CGF.DidCallStackSave;
480  CGF.DidCallStackSave = false;
481  }
482 
483  /// \brief Exit this cleanup scope, emitting any accumulated
484  /// cleanups.
486  if (PerformCleanup) {
487  CGF.DidCallStackSave = OldDidCallStackSave;
488  CGF.PopCleanupBlocks(CleanupStackDepth,
489  LifetimeExtendedCleanupStackSize);
490  }
491  }
492 
493  /// \brief Determine whether this scope requires any cleanups.
494  bool requiresCleanups() const {
495  return CGF.EHStack.stable_begin() != CleanupStackDepth;
496  }
497 
498  /// \brief Force the emission of cleanups now, instead of waiting
499  /// until this object is destroyed.
500  void ForceCleanup() {
501  assert(PerformCleanup && "Already forced cleanup");
502  CGF.DidCallStackSave = OldDidCallStackSave;
503  CGF.PopCleanupBlocks(CleanupStackDepth,
504  LifetimeExtendedCleanupStackSize);
505  PerformCleanup = false;
506  }
507  };
508 
510  SourceRange Range;
512  LexicalScope *ParentScope;
513 
514  LexicalScope(const LexicalScope &) = delete;
515  void operator=(const LexicalScope &) = delete;
516 
517  public:
518  /// \brief Enter a new cleanup scope.
520  : RunCleanupsScope(CGF), Range(Range), ParentScope(CGF.CurLexicalScope) {
521  CGF.CurLexicalScope = this;
522  if (CGDebugInfo *DI = CGF.getDebugInfo())
523  DI->EmitLexicalBlockStart(CGF.Builder, Range.getBegin());
524  }
525 
526  void addLabel(const LabelDecl *label) {
527  assert(PerformCleanup && "adding label to dead scope?");
528  Labels.push_back(label);
529  }
530 
531  /// \brief Exit this cleanup scope, emitting any accumulated
532  /// cleanups.
534  if (CGDebugInfo *DI = CGF.getDebugInfo())
535  DI->EmitLexicalBlockEnd(CGF.Builder, Range.getEnd());
536 
537  // If we should perform a cleanup, force them now. Note that
538  // this ends the cleanup scope before rescoping any labels.
539  if (PerformCleanup) {
540  ApplyDebugLocation DL(CGF, Range.getEnd());
541  ForceCleanup();
542  }
543  }
544 
545  /// \brief Force the emission of cleanups now, instead of waiting
546  /// until this object is destroyed.
547  void ForceCleanup() {
548  CGF.CurLexicalScope = ParentScope;
550 
551  if (!Labels.empty())
552  rescopeLabels();
553  }
554 
555  void rescopeLabels();
556  };
557 
558  /// \brief The scope used to remap some variables as private in the OpenMP
559  /// loop body (or other captured region emitted without outlining), and to
560  /// restore old vars back on exit.
562  typedef llvm::DenseMap<const VarDecl *, llvm::Value *> VarDeclMapTy;
563  VarDeclMapTy SavedLocals;
564  VarDeclMapTy SavedPrivates;
565 
566  private:
567  OMPPrivateScope(const OMPPrivateScope &) = delete;
568  void operator=(const OMPPrivateScope &) = delete;
569 
570  public:
571  /// \brief Enter a new OpenMP private scope.
573 
574  /// \brief Registers \a LocalVD variable as a private and apply \a
575  /// PrivateGen function for it to generate corresponding private variable.
576  /// \a PrivateGen returns an address of the generated private variable.
577  /// \return true if the variable is registered as private, false if it has
578  /// been privatized already.
579  bool
580  addPrivate(const VarDecl *LocalVD,
581  const std::function<llvm::Value *()> &PrivateGen) {
582  assert(PerformCleanup && "adding private to dead scope");
583  if (SavedLocals.count(LocalVD) > 0) return false;
584  SavedLocals[LocalVD] = CGF.LocalDeclMap.lookup(LocalVD);
585  CGF.LocalDeclMap.erase(LocalVD);
586  SavedPrivates[LocalVD] = PrivateGen();
587  CGF.LocalDeclMap[LocalVD] = SavedLocals[LocalVD];
588  return true;
589  }
590 
591  /// \brief Privatizes local variables previously registered as private.
592  /// Registration is separate from the actual privatization to allow
593  /// initializers use values of the original variables, not the private one.
594  /// This is important, for example, if the private variable is a class
595  /// variable initialized by a constructor that references other private
596  /// variables. But at initialization original variables must be used, not
597  /// private copies.
598  /// \return true if at least one variable was privatized, false otherwise.
599  bool Privatize() {
600  for (auto VDPair : SavedPrivates) {
601  CGF.LocalDeclMap[VDPair.first] = VDPair.second;
602  }
603  SavedPrivates.clear();
604  return !SavedLocals.empty();
605  }
606 
607  void ForceCleanup() {
609  // Remap vars back to the original values.
610  for (auto I : SavedLocals) {
611  CGF.LocalDeclMap[I.first] = I.second;
612  }
613  SavedLocals.clear();
614  }
615 
616  /// \brief Exit scope - all the mapped variables are restored.
618  if (PerformCleanup)
619  ForceCleanup();
620  }
621  };
622 
623  /// \brief Takes the old cleanup stack size and emits the cleanup blocks
624  /// that have been added.
625  void PopCleanupBlocks(EHScopeStack::stable_iterator OldCleanupStackSize);
626 
627  /// \brief Takes the old cleanup stack size and emits the cleanup blocks
628  /// that have been added, then adds all lifetime-extended cleanups from
629  /// the given position to the stack.
630  void PopCleanupBlocks(EHScopeStack::stable_iterator OldCleanupStackSize,
631  size_t OldLifetimeExtendedStackSize);
632 
633  void ResolveBranchFixups(llvm::BasicBlock *Target);
634 
635  /// The given basic block lies in the current EH scope, but may be a
636  /// target of a potentially scope-crossing jump; get a stable handle
637  /// to which we can perform this jump later.
639  return JumpDest(Target,
642  }
643 
644  /// The given basic block lies in the current EH scope, but may be a
645  /// target of a potentially scope-crossing jump; get a stable handle
646  /// to which we can perform this jump later.
647  JumpDest getJumpDestInCurrentScope(StringRef Name = StringRef()) {
649  }
650 
651  /// EmitBranchThroughCleanup - Emit a branch from the current insert
652  /// block through the normal cleanup handling code (if any) and then
653  /// on to \arg Dest.
654  void EmitBranchThroughCleanup(JumpDest Dest);
655 
656  /// isObviouslyBranchWithoutCleanups - Return true if a branch to the
657  /// specified destination obviously has no cleanups to run. 'false' is always
658  /// a conservatively correct answer for this method.
659  bool isObviouslyBranchWithoutCleanups(JumpDest Dest) const;
660 
661  /// popCatchScope - Pops the catch scope at the top of the EHScope
662  /// stack, emitting any required code (other than the catch handlers
663  /// themselves).
664  void popCatchScope();
665 
666  llvm::BasicBlock *getEHResumeBlock(bool isCleanup);
667  llvm::BasicBlock *getEHDispatchBlock(EHScopeStack::stable_iterator scope);
668 
669  /// An object to manage conditionally-evaluated expressions.
671  llvm::BasicBlock *StartBB;
672 
673  public:
675  : StartBB(CGF.Builder.GetInsertBlock()) {}
676 
677  void begin(CodeGenFunction &CGF) {
678  assert(CGF.OutermostConditional != this);
679  if (!CGF.OutermostConditional)
680  CGF.OutermostConditional = this;
681  }
682 
683  void end(CodeGenFunction &CGF) {
684  assert(CGF.OutermostConditional != nullptr);
685  if (CGF.OutermostConditional == this)
686  CGF.OutermostConditional = nullptr;
687  }
688 
689  /// Returns a block which will be executed prior to each
690  /// evaluation of the conditional code.
691  llvm::BasicBlock *getStartingBlock() const {
692  return StartBB;
693  }
694  };
695 
696  /// isInConditionalBranch - Return true if we're currently emitting
697  /// one branch or the other of a conditional expression.
698  bool isInConditionalBranch() const { return OutermostConditional != nullptr; }
699 
701  assert(isInConditionalBranch());
702  llvm::BasicBlock *block = OutermostConditional->getStartingBlock();
703  new llvm::StoreInst(value, addr, &block->back());
704  }
705 
706  /// An RAII object to record that we're evaluating a statement
707  /// expression.
709  CodeGenFunction &CGF;
710 
711  /// We have to save the outermost conditional: cleanups in a
712  /// statement expression aren't conditional just because the
713  /// StmtExpr is.
714  ConditionalEvaluation *SavedOutermostConditional;
715 
716  public:
718  : CGF(CGF), SavedOutermostConditional(CGF.OutermostConditional) {
719  CGF.OutermostConditional = nullptr;
720  }
721 
723  CGF.OutermostConditional = SavedOutermostConditional;
724  CGF.EnsureInsertPoint();
725  }
726  };
727 
728  /// An object which temporarily prevents a value from being
729  /// destroyed by aggressive peephole optimizations that assume that
730  /// all uses of a value have been realized in the IR.
732  llvm::Instruction *Inst;
733  friend class CodeGenFunction;
734 
735  public:
736  PeepholeProtection() : Inst(nullptr) {}
737  };
738 
739  /// A non-RAII class containing all the information about a bound
740  /// opaque value. OpaqueValueMapping, below, is a RAII wrapper for
741  /// this which makes individual mappings very simple; using this
742  /// class directly is useful when you have a variable number of
743  /// opaque values or don't want the RAII functionality for some
744  /// reason.
746  const OpaqueValueExpr *OpaqueValue;
747  bool BoundLValue;
749 
751  bool boundLValue)
752  : OpaqueValue(ov), BoundLValue(boundLValue) {}
753  public:
754  OpaqueValueMappingData() : OpaqueValue(nullptr) {}
755 
756  static bool shouldBindAsLValue(const Expr *expr) {
757  // gl-values should be bound as l-values for obvious reasons.
758  // Records should be bound as l-values because IR generation
759  // always keeps them in memory. Expressions of function type
760  // act exactly like l-values but are formally required to be
761  // r-values in C.
762  return expr->isGLValue() ||
763  expr->getType()->isFunctionType() ||
765  }
766 
768  const OpaqueValueExpr *ov,
769  const Expr *e) {
770  if (shouldBindAsLValue(ov))
771  return bind(CGF, ov, CGF.EmitLValue(e));
772  return bind(CGF, ov, CGF.EmitAnyExpr(e));
773  }
774 
776  const OpaqueValueExpr *ov,
777  const LValue &lv) {
778  assert(shouldBindAsLValue(ov));
779  CGF.OpaqueLValues.insert(std::make_pair(ov, lv));
780  return OpaqueValueMappingData(ov, true);
781  }
782 
784  const OpaqueValueExpr *ov,
785  const RValue &rv) {
786  assert(!shouldBindAsLValue(ov));
787  CGF.OpaqueRValues.insert(std::make_pair(ov, rv));
788 
789  OpaqueValueMappingData data(ov, false);
790 
791  // Work around an extremely aggressive peephole optimization in
792  // EmitScalarConversion which assumes that all other uses of a
793  // value are extant.
794  data.Protection = CGF.protectFromPeepholes(rv);
795 
796  return data;
797  }
798 
799  bool isValid() const { return OpaqueValue != nullptr; }
800  void clear() { OpaqueValue = nullptr; }
801 
802  void unbind(CodeGenFunction &CGF) {
803  assert(OpaqueValue && "no data to unbind!");
804 
805  if (BoundLValue) {
806  CGF.OpaqueLValues.erase(OpaqueValue);
807  } else {
808  CGF.OpaqueRValues.erase(OpaqueValue);
809  CGF.unprotectFromPeepholes(Protection);
810  }
811  }
812  };
813 
814  /// An RAII object to set (and then clear) a mapping for an OpaqueValueExpr.
816  CodeGenFunction &CGF;
818 
819  public:
820  static bool shouldBindAsLValue(const Expr *expr) {
822  }
823 
824  /// Build the opaque value mapping for the given conditional
825  /// operator if it's the GNU ?: extension. This is a common
826  /// enough pattern that the convenience operator is really
827  /// helpful.
828  ///
830  const AbstractConditionalOperator *op) : CGF(CGF) {
831  if (isa<ConditionalOperator>(op))
832  // Leave Data empty.
833  return;
834 
835  const BinaryConditionalOperator *e = cast<BinaryConditionalOperator>(op);
837  e->getCommon());
838  }
839 
841  const OpaqueValueExpr *opaqueValue,
842  LValue lvalue)
843  : CGF(CGF), Data(OpaqueValueMappingData::bind(CGF, opaqueValue, lvalue)) {
844  }
845 
847  const OpaqueValueExpr *opaqueValue,
848  RValue rvalue)
849  : CGF(CGF), Data(OpaqueValueMappingData::bind(CGF, opaqueValue, rvalue)) {
850  }
851 
852  void pop() {
853  Data.unbind(CGF);
854  Data.clear();
855  }
856 
858  if (Data.isValid()) Data.unbind(CGF);
859  }
860  };
861 
862  /// getByrefValueFieldNumber - Given a declaration, returns the LLVM field
863  /// number that holds the value.
864  std::pair<llvm::Type *, unsigned>
865  getByRefValueLLVMField(const ValueDecl *VD) const;
866 
867  /// BuildBlockByrefAddress - Computes address location of the
868  /// variable which is declared as __block.
870  const VarDecl *V);
871 private:
872  CGDebugInfo *DebugInfo;
873  bool DisableDebugInfo;
874 
875  /// DidCallStackSave - Whether llvm.stacksave has been called. Used to avoid
876  /// calling llvm.stacksave for multiple VLAs in the same scope.
877  bool DidCallStackSave;
878 
879  /// IndirectBranch - The first time an indirect goto is seen we create a block
880  /// with an indirect branch. Every time we see the address of a label taken,
881  /// we add the label to the indirect goto. Every subsequent indirect goto is
882  /// codegen'd as a jump to the IndirectBranch's basic block.
883  llvm::IndirectBrInst *IndirectBranch;
884 
885  /// LocalDeclMap - This keeps track of the LLVM allocas or globals for local C
886  /// decls.
887  typedef llvm::DenseMap<const Decl*, llvm::Value*> DeclMapTy;
888  DeclMapTy LocalDeclMap;
889 
890  /// Track escaped local variables with auto storage. Used during SEH
891  /// outlining to produce a call to llvm.localescape.
892  llvm::DenseMap<llvm::AllocaInst *, int> EscapedLocals;
893 
894  /// LabelMap - This keeps track of the LLVM basic block for each C label.
895  llvm::DenseMap<const LabelDecl*, JumpDest> LabelMap;
896 
897  // BreakContinueStack - This keeps track of where break and continue
898  // statements should jump to.
899  struct BreakContinue {
900  BreakContinue(JumpDest Break, JumpDest Continue)
901  : BreakBlock(Break), ContinueBlock(Continue) {}
902 
903  JumpDest BreakBlock;
904  JumpDest ContinueBlock;
905  };
906  SmallVector<BreakContinue, 8> BreakContinueStack;
907 
908  CodeGenPGO PGO;
909 
910  /// Calculate branch weights appropriate for PGO data
911  llvm::MDNode *createProfileWeights(uint64_t TrueCount, uint64_t FalseCount);
912  llvm::MDNode *createProfileWeights(ArrayRef<uint64_t> Weights);
913  llvm::MDNode *createProfileWeightsForLoop(const Stmt *Cond,
914  uint64_t LoopCount);
915 
916 public:
917  /// Increment the profiler's counter for the given statement.
919  if (CGM.getCodeGenOpts().ProfileInstrGenerate)
920  PGO.emitCounterIncrement(Builder, S);
921  PGO.setCurrentStmt(S);
922  }
923 
924  /// Get the profiler's count for the given statement.
925  uint64_t getProfileCount(const Stmt *S) {
926  Optional<uint64_t> Count = PGO.getStmtCount(S);
927  if (!Count.hasValue())
928  return 0;
929  return *Count;
930  }
931 
932  /// Set the profiler's current count.
933  void setCurrentProfileCount(uint64_t Count) {
934  PGO.setCurrentRegionCount(Count);
935  }
936 
937  /// Get the profiler's current count. This is generally the count for the most
938  /// recently incremented counter.
940  return PGO.getCurrentRegionCount();
941  }
942 
943 private:
944 
945  /// SwitchInsn - This is nearest current switch instruction. It is null if
946  /// current context is not in a switch.
947  llvm::SwitchInst *SwitchInsn;
948  /// The branch weights of SwitchInsn when doing instrumentation based PGO.
949  SmallVector<uint64_t, 16> *SwitchWeights;
950 
951  /// CaseRangeBlock - This block holds if condition check for last case
952  /// statement range in current switch instruction.
953  llvm::BasicBlock *CaseRangeBlock;
954 
955  /// OpaqueLValues - Keeps track of the current set of opaque value
956  /// expressions.
957  llvm::DenseMap<const OpaqueValueExpr *, LValue> OpaqueLValues;
958  llvm::DenseMap<const OpaqueValueExpr *, RValue> OpaqueRValues;
959 
960  // VLASizeMap - This keeps track of the associated size for each VLA type.
961  // We track this by the size expression rather than the type itself because
962  // in certain situations, like a const qualifier applied to an VLA typedef,
963  // multiple VLA types can share the same size expression.
964  // FIXME: Maybe this could be a stack of maps that is pushed/popped as we
965  // enter/leave scopes.
966  llvm::DenseMap<const Expr*, llvm::Value*> VLASizeMap;
967 
968  /// A block containing a single 'unreachable' instruction. Created
969  /// lazily by getUnreachableBlock().
970  llvm::BasicBlock *UnreachableBlock;
971 
972  /// Counts of the number return expressions in the function.
973  unsigned NumReturnExprs;
974 
975  /// Count the number of simple (constant) return expressions in the function.
976  unsigned NumSimpleReturnExprs;
977 
978  /// The last regular (non-return) debug location (breakpoint) in the function.
979  SourceLocation LastStopPoint;
980 
981 public:
982  /// A scope within which we are constructing the fields of an object which
983  /// might use a CXXDefaultInitExpr. This stashes away a 'this' value to use
984  /// if we need to evaluate a CXXDefaultInitExpr within the evaluation.
986  public:
988  : CGF(CGF), OldCXXDefaultInitExprThis(CGF.CXXDefaultInitExprThis) {
989  CGF.CXXDefaultInitExprThis = This;
990  }
992  CGF.CXXDefaultInitExprThis = OldCXXDefaultInitExprThis;
993  }
994 
995  private:
996  CodeGenFunction &CGF;
997  llvm::Value *OldCXXDefaultInitExprThis;
998  };
999 
1000  /// The scope of a CXXDefaultInitExpr. Within this scope, the value of 'this'
1001  /// is overridden to be the object under construction.
1003  public:
1005  : CGF(CGF), OldCXXThisValue(CGF.CXXThisValue) {
1006  CGF.CXXThisValue = CGF.CXXDefaultInitExprThis;
1007  }
1009  CGF.CXXThisValue = OldCXXThisValue;
1010  }
1011 
1012  public:
1015  };
1016 
1017 private:
1018  /// CXXThisDecl - When generating code for a C++ member function,
1019  /// this will hold the implicit 'this' declaration.
1020  ImplicitParamDecl *CXXABIThisDecl;
1021  llvm::Value *CXXABIThisValue;
1022  llvm::Value *CXXThisValue;
1023 
1024  /// The value of 'this' to use when evaluating CXXDefaultInitExprs within
1025  /// this expression.
1026  llvm::Value *CXXDefaultInitExprThis;
1027 
1028  /// CXXStructorImplicitParamDecl - When generating code for a constructor or
1029  /// destructor, this will hold the implicit argument (e.g. VTT).
1030  ImplicitParamDecl *CXXStructorImplicitParamDecl;
1031  llvm::Value *CXXStructorImplicitParamValue;
1032 
1033  /// OutermostConditional - Points to the outermost active
1034  /// conditional control. This is used so that we know if a
1035  /// temporary should be destroyed conditionally.
1036  ConditionalEvaluation *OutermostConditional;
1037 
1038  /// The current lexical scope.
1039  LexicalScope *CurLexicalScope;
1040 
1041  /// The current source location that should be used for exception
1042  /// handling code.
1043  SourceLocation CurEHLocation;
1044 
1045  /// ByrefValueInfoMap - For each __block variable, contains a pair of the LLVM
1046  /// type as well as the field number that contains the actual data.
1047  llvm::DenseMap<const ValueDecl *, std::pair<llvm::Type *,
1048  unsigned> > ByRefValueInfo;
1049 
1050  llvm::BasicBlock *TerminateLandingPad;
1051  llvm::BasicBlock *TerminateHandler;
1052  llvm::BasicBlock *TrapBB;
1053 
1054  /// Add a kernel metadata node to the named metadata node 'opencl.kernels'.
1055  /// In the kernel metadata node, reference the kernel function and metadata
1056  /// nodes for its optional attribute qualifiers (OpenCL 1.1 6.7.2):
1057  /// - A node for the vec_type_hint(<type>) qualifier contains string
1058  /// "vec_type_hint", an undefined value of the <type> data type,
1059  /// and a Boolean that is true if the <type> is integer and signed.
1060  /// - A node for the work_group_size_hint(X,Y,Z) qualifier contains string
1061  /// "work_group_size_hint", and three 32-bit integers X, Y and Z.
1062  /// - A node for the reqd_work_group_size(X,Y,Z) qualifier contains string
1063  /// "reqd_work_group_size", and three 32-bit integers X, Y and Z.
1064  void EmitOpenCLKernelMetadata(const FunctionDecl *FD,
1065  llvm::Function *Fn);
1066 
1067 public:
1068  CodeGenFunction(CodeGenModule &cgm, bool suppressNewContext=false);
1069  ~CodeGenFunction();
1070 
1071  CodeGenTypes &getTypes() const { return CGM.getTypes(); }
1072  ASTContext &getContext() const { return CGM.getContext(); }
1074  if (DisableDebugInfo)
1075  return nullptr;
1076  return DebugInfo;
1077  }
1078  void disableDebugInfo() { DisableDebugInfo = true; }
1079  void enableDebugInfo() { DisableDebugInfo = false; }
1080 
1082  return CGM.getCodeGenOpts().OptimizationLevel == 0;
1083  }
1084 
1085  const LangOptions &getLangOpts() const { return CGM.getLangOpts(); }
1086 
1087  /// Returns a pointer to the function's exception object and selector slot,
1088  /// which is assigned in every landing pad.
1091 
1092  /// Returns the contents of the function's exception object and selector
1093  /// slots.
1096 
1098 
1099  llvm::BasicBlock *getUnreachableBlock() {
1100  if (!UnreachableBlock) {
1101  UnreachableBlock = createBasicBlock("unreachable");
1102  new llvm::UnreachableInst(getLLVMContext(), UnreachableBlock);
1103  }
1104  return UnreachableBlock;
1105  }
1106 
1107  llvm::BasicBlock *getInvokeDest() {
1108  if (!EHStack.requiresLandingPad()) return nullptr;
1109  return getInvokeDestImpl();
1110  }
1111 
1113  const auto *FD = dyn_cast_or_null<FunctionDecl>(CurCodeDecl);
1114  return FD && FD->usesSEHTry();
1115  }
1116 
1117  const TargetInfo &getTarget() const { return Target; }
1118  llvm::LLVMContext &getLLVMContext() { return CGM.getLLVMContext(); }
1119 
1120  //===--------------------------------------------------------------------===//
1121  // Cleanups
1122  //===--------------------------------------------------------------------===//
1123 
1124  typedef void Destroyer(CodeGenFunction &CGF, llvm::Value *addr, QualType ty);
1125 
1127  llvm::Value *arrayEndPointer,
1128  QualType elementType,
1129  Destroyer *destroyer);
1131  llvm::Value *arrayEnd,
1132  QualType elementType,
1133  Destroyer *destroyer);
1134 
1135  void pushDestroy(QualType::DestructionKind dtorKind,
1136  llvm::Value *addr, QualType type);
1138  llvm::Value *addr, QualType type);
1140  Destroyer *destroyer, bool useEHCleanupForArray);
1142  QualType type, Destroyer *destroyer,
1143  bool useEHCleanupForArray);
1144  void pushCallObjectDeleteCleanup(const FunctionDecl *OperatorDelete,
1145  llvm::Value *CompletePtr,
1146  QualType ElementType);
1148  void emitDestroy(llvm::Value *addr, QualType type, Destroyer *destroyer,
1149  bool useEHCleanupForArray);
1150  llvm::Function *generateDestroyHelper(llvm::Constant *addr, QualType type,
1151  Destroyer *destroyer,
1152  bool useEHCleanupForArray,
1153  const VarDecl *VD);
1154  void emitArrayDestroy(llvm::Value *begin, llvm::Value *end,
1155  QualType type, Destroyer *destroyer,
1156  bool checkZeroLength, bool useEHCleanup);
1157 
1159 
1160  /// Determines whether an EH cleanup is required to destroy a type
1161  /// with the given destruction kind.
1163  switch (kind) {
1164  case QualType::DK_none:
1165  return false;
1168  return getLangOpts().Exceptions;
1170  return getLangOpts().Exceptions &&
1171  CGM.getCodeGenOpts().ObjCAutoRefCountExceptions;
1172  }
1173  llvm_unreachable("bad destruction kind");
1174  }
1175 
1177  return (needsEHCleanup(kind) ? NormalAndEHCleanup : NormalCleanup);
1178  }
1179 
1180  //===--------------------------------------------------------------------===//
1181  // Objective-C
1182  //===--------------------------------------------------------------------===//
1183 
1184  void GenerateObjCMethod(const ObjCMethodDecl *OMD);
1185 
1186  void StartObjCMethod(const ObjCMethodDecl *MD, const ObjCContainerDecl *CD);
1187 
1188  /// GenerateObjCGetter - Synthesize an Objective-C property getter function.
1190  const ObjCPropertyImplDecl *PID);
1191  void generateObjCGetterBody(const ObjCImplementationDecl *classImpl,
1192  const ObjCPropertyImplDecl *propImpl,
1193  const ObjCMethodDecl *GetterMothodDecl,
1194  llvm::Constant *AtomicHelperFn);
1195 
1197  ObjCMethodDecl *MD, bool ctor);
1198 
1199  /// GenerateObjCSetter - Synthesize an Objective-C property setter function
1200  /// for the given property.
1202  const ObjCPropertyImplDecl *PID);
1203  void generateObjCSetterBody(const ObjCImplementationDecl *classImpl,
1204  const ObjCPropertyImplDecl *propImpl,
1205  llvm::Constant *AtomicHelperFn);
1206  bool IndirectObjCSetterArg(const CGFunctionInfo &FI);
1208 
1209  //===--------------------------------------------------------------------===//
1210  // Block Bits
1211  //===--------------------------------------------------------------------===//
1212 
1215  static void destroyBlockInfos(CGBlockInfo *info);
1216  llvm::Constant *BuildDescriptorBlockDecl(const BlockExpr *,
1217  const CGBlockInfo &Info,
1218  llvm::StructType *,
1219  llvm::Constant *BlockVarLayout);
1220 
1221  llvm::Function *GenerateBlockFunction(GlobalDecl GD,
1222  const CGBlockInfo &Info,
1223  const DeclMapTy &ldm,
1224  bool IsLambdaConversionToBlock);
1225 
1226  llvm::Constant *GenerateCopyHelperFunction(const CGBlockInfo &blockInfo);
1227  llvm::Constant *GenerateDestroyHelperFunction(const CGBlockInfo &blockInfo);
1229  const ObjCPropertyImplDecl *PID);
1231  const ObjCPropertyImplDecl *PID);
1233 
1234  void BuildBlockRelease(llvm::Value *DeclPtr, BlockFieldFlags flags);
1235 
1236  class AutoVarEmission;
1237 
1238  void emitByrefStructureInit(const AutoVarEmission &emission);
1239  void enterByrefCleanup(const AutoVarEmission &emission);
1240 
1242  assert(BlockPointer && "no block pointer set!");
1243  return BlockPointer;
1244  }
1245 
1247  void AllocateBlockDecl(const DeclRefExpr *E);
1248  llvm::Value *GetAddrOfBlockDecl(const VarDecl *var, bool ByRef);
1249  llvm::Type *BuildByRefType(const VarDecl *var);
1250 
1251  void GenerateCode(GlobalDecl GD, llvm::Function *Fn,
1252  const CGFunctionInfo &FnInfo);
1253  /// \brief Emit code for the start of a function.
1254  /// \param Loc The location to be associated with the function.
1255  /// \param StartLoc The location of the function body.
1256  void StartFunction(GlobalDecl GD,
1257  QualType RetTy,
1258  llvm::Function *Fn,
1259  const CGFunctionInfo &FnInfo,
1260  const FunctionArgList &Args,
1262  SourceLocation StartLoc = SourceLocation());
1263 
1265  void EmitDestructorBody(FunctionArgList &Args);
1267  void EmitFunctionBody(FunctionArgList &Args, const Stmt *Body);
1268  void EmitBlockWithFallThrough(llvm::BasicBlock *BB, const Stmt *S);
1269 
1270  void EmitForwardingCallToLambda(const CXXMethodDecl *LambdaCallOperator,
1271  CallArgList &CallArgs);
1276  void EmitAsanPrologueOrEpilogue(bool Prologue);
1277 
1278  /// \brief Emit the unified return block, trying to avoid its emission when
1279  /// possible.
1280  /// \return The debug location of the user written return statement if the
1281  /// return block is is avoided.
1282  llvm::DebugLoc EmitReturnBlock();
1283 
1284  /// FinishFunction - Complete IR generation of the current function. It is
1285  /// legal to call this function even if there is no current insertion point.
1287 
1288  void StartThunk(llvm::Function *Fn, GlobalDecl GD,
1289  const CGFunctionInfo &FnInfo);
1290 
1291  void EmitCallAndReturnForThunk(llvm::Value *Callee, const ThunkInfo *Thunk);
1292 
1293  /// Emit a musttail call for a thunk with a potentially adjusted this pointer.
1294  void EmitMustTailThunk(const CXXMethodDecl *MD, llvm::Value *AdjustedThisPtr,
1295  llvm::Value *Callee);
1296 
1297  /// Generate a thunk for the given method.
1298  void generateThunk(llvm::Function *Fn, const CGFunctionInfo &FnInfo,
1299  GlobalDecl GD, const ThunkInfo &Thunk);
1300 
1301  llvm::Function *GenerateVarArgsThunk(llvm::Function *Fn,
1302  const CGFunctionInfo &FnInfo,
1303  GlobalDecl GD, const ThunkInfo &Thunk);
1304 
1306  FunctionArgList &Args);
1307 
1308  void EmitInitializerForField(FieldDecl *Field, LValue LHS, Expr *Init,
1309  ArrayRef<VarDecl *> ArrayIndexes);
1310 
1311  /// InitializeVTablePointer - Initialize the vtable pointer of the given
1312  /// subobject.
1313  ///
1315  const CXXRecordDecl *NearestVBase,
1316  CharUnits OffsetFromNearestVBase,
1317  const CXXRecordDecl *VTableClass);
1318 
1319  typedef llvm::SmallPtrSet<const CXXRecordDecl *, 4> VisitedVirtualBasesSetTy;
1321  const CXXRecordDecl *NearestVBase,
1322  CharUnits OffsetFromNearestVBase,
1323  bool BaseIsNonVirtualPrimaryBase,
1324  const CXXRecordDecl *VTableClass,
1325  VisitedVirtualBasesSetTy& VBases);
1326 
1327  void InitializeVTablePointers(const CXXRecordDecl *ClassDecl);
1328 
1329  /// GetVTablePtr - Return the Value of the vtable pointer member pointed
1330  /// to by This.
1331  llvm::Value *GetVTablePtr(llvm::Value *This, llvm::Type *Ty);
1332 
1338  };
1339 
1340  /// \brief Derived is the presumed address of an object of type T after a
1341  /// cast. If T is a polymorphic class type, emit a check that the virtual
1342  /// table for Derived belongs to a class derived from T.
1344  bool MayBeNull, CFITypeCheckKind TCK,
1345  SourceLocation Loc);
1346 
1347  /// EmitVTablePtrCheckForCall - Virtual method MD is being called via VTable.
1348  /// If vptr CFI is enabled, emit a check that VTable is valid.
1349  void EmitVTablePtrCheckForCall(const CXXMethodDecl *MD, llvm::Value *VTable,
1350  CFITypeCheckKind TCK, SourceLocation Loc);
1351 
1352  /// EmitVTablePtrCheck - Emit a check that VTable is a valid virtual table for
1353  /// RD using llvm.bitset.test.
1354  void EmitVTablePtrCheck(const CXXRecordDecl *RD, llvm::Value *VTable,
1355  CFITypeCheckKind TCK, SourceLocation Loc);
1356 
1357  /// CanDevirtualizeMemberFunctionCalls - Checks whether virtual calls on given
1358  /// expr can be devirtualized.
1360  const CXXMethodDecl *MD);
1361 
1362  /// EnterDtorCleanups - Enter the cleanups necessary to complete the
1363  /// given phase of destruction for a destructor. The end result
1364  /// should call destructors on members and base classes in reverse
1365  /// order of their construction.
1367 
1368  /// ShouldInstrumentFunction - Return true if the current function should be
1369  /// instrumented with __cyg_profile_func_* calls
1370  bool ShouldInstrumentFunction();
1371 
1372  /// EmitFunctionInstrumentation - Emit LLVM code to call the specified
1373  /// instrumentation function with the current function and the call site, if
1374  /// function instrumentation is enabled.
1375  void EmitFunctionInstrumentation(const char *Fn);
1376 
1377  /// EmitMCountInstrumentation - Emit call to .mcount.
1379 
1380  /// EmitFunctionProlog - Emit the target specific LLVM code to load the
1381  /// arguments for the given function. This is also responsible for naming the
1382  /// LLVM function arguments.
1383  void EmitFunctionProlog(const CGFunctionInfo &FI,
1384  llvm::Function *Fn,
1385  const FunctionArgList &Args);
1386 
1387  /// EmitFunctionEpilog - Emit the target specific LLVM code to return the
1388  /// given temporary.
1389  void EmitFunctionEpilog(const CGFunctionInfo &FI, bool EmitRetDbgLoc,
1390  SourceLocation EndLoc);
1391 
1392  /// EmitStartEHSpec - Emit the start of the exception spec.
1393  void EmitStartEHSpec(const Decl *D);
1394 
1395  /// EmitEndEHSpec - Emit the end of the exception spec.
1396  void EmitEndEHSpec(const Decl *D);
1397 
1398  /// getTerminateLandingPad - Return a landing pad that just calls terminate.
1399  llvm::BasicBlock *getTerminateLandingPad();
1400 
1401  /// getTerminateHandler - Return a handler (not a landing pad, just
1402  /// a catch handler) that just calls terminate. This is used when
1403  /// a terminate scope encloses a try.
1404  llvm::BasicBlock *getTerminateHandler();
1405 
1406  llvm::Type *ConvertTypeForMem(QualType T);
1407  llvm::Type *ConvertType(QualType T);
1408  llvm::Type *ConvertType(const TypeDecl *T) {
1409  return ConvertType(getContext().getTypeDeclType(T));
1410  }
1411 
1412  /// LoadObjCSelf - Load the value of self. This function is only valid while
1413  /// generating code for an Objective-C method.
1415 
1416  /// TypeOfSelfObject - Return type of object that this self represents.
1418 
1419  /// hasAggregateLLVMType - Return true if the specified AST type will map into
1420  /// an aggregate LLVM type or is void.
1422 
1424  return getEvaluationKind(T) == TEK_Scalar;
1425  }
1426 
1428  return getEvaluationKind(T) == TEK_Aggregate;
1429  }
1430 
1431  /// createBasicBlock - Create an LLVM basic block.
1432  llvm::BasicBlock *createBasicBlock(const Twine &name = "",
1433  llvm::Function *parent = nullptr,
1434  llvm::BasicBlock *before = nullptr) {
1435 #ifdef NDEBUG
1436  return llvm::BasicBlock::Create(getLLVMContext(), "", parent, before);
1437 #else
1438  return llvm::BasicBlock::Create(getLLVMContext(), name, parent, before);
1439 #endif
1440  }
1441 
1442  /// getBasicBlockForLabel - Return the LLVM basicblock that the specified
1443  /// label maps to.
1444  JumpDest getJumpDestForLabel(const LabelDecl *S);
1445 
1446  /// SimplifyForwardingBlocks - If the given basic block is only a branch to
1447  /// another basic block, simplify it. This assumes that no other code could
1448  /// potentially reference the basic block.
1449  void SimplifyForwardingBlocks(llvm::BasicBlock *BB);
1450 
1451  /// EmitBlock - Emit the given block \arg BB and set it as the insert point,
1452  /// adding a fall-through branch from the current insert block if
1453  /// necessary. It is legal to call this function even if there is no current
1454  /// insertion point.
1455  ///
1456  /// IsFinished - If true, indicates that the caller has finished emitting
1457  /// branches to the given block and does not expect to emit code into it. This
1458  /// means the block can be ignored if it is unreachable.
1459  void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false);
1460 
1461  /// EmitBlockAfterUses - Emit the given block somewhere hopefully
1462  /// near its uses, and leave the insertion point in it.
1463  void EmitBlockAfterUses(llvm::BasicBlock *BB);
1464 
1465  /// EmitBranch - Emit a branch to the specified basic block from the current
1466  /// insert block, taking care to avoid creation of branches from dummy
1467  /// blocks. It is legal to call this function even if there is no current
1468  /// insertion point.
1469  ///
1470  /// This function clears the current insertion point. The caller should follow
1471  /// calls to this function with calls to Emit*Block prior to generation new
1472  /// code.
1473  void EmitBranch(llvm::BasicBlock *Block);
1474 
1475  /// HaveInsertPoint - True if an insertion point is defined. If not, this
1476  /// indicates that the current code being emitted is unreachable.
1477  bool HaveInsertPoint() const {
1478  return Builder.GetInsertBlock() != nullptr;
1479  }
1480 
1481  /// EnsureInsertPoint - Ensure that an insertion point is defined so that
1482  /// emitted IR has a place to go. Note that by definition, if this function
1483  /// creates a block then that block is unreachable; callers may do better to
1484  /// detect when no insertion point is defined and simply skip IR generation.
1486  if (!HaveInsertPoint())
1488  }
1489 
1490  /// ErrorUnsupported - Print out an error that codegen doesn't support the
1491  /// specified stmt yet.
1492  void ErrorUnsupported(const Stmt *S, const char *Type);
1493 
1494  //===--------------------------------------------------------------------===//
1495  // Helpers
1496  //===--------------------------------------------------------------------===//
1497 
1499  CharUnits Alignment = CharUnits()) {
1500  return LValue::MakeAddr(V, T, Alignment, getContext(),
1501  CGM.getTBAAInfo(T));
1502  }
1503 
1505 
1506  /// CreateTempAlloca - This creates a alloca and inserts it into the entry
1507  /// block. The caller is responsible for setting an appropriate alignment on
1508  /// the alloca.
1509  llvm::AllocaInst *CreateTempAlloca(llvm::Type *Ty,
1510  const Twine &Name = "tmp");
1511 
1512  /// InitTempAlloca - Provide an initial value for the given alloca.
1513  void InitTempAlloca(llvm::AllocaInst *Alloca, llvm::Value *Value);
1514 
1515  /// CreateIRTemp - Create a temporary IR object of the given type, with
1516  /// appropriate alignment. This routine should only be used when an temporary
1517  /// value needs to be stored into an alloca (for example, to avoid explicit
1518  /// PHI construction), but the type is the IR type, not the type appropriate
1519  /// for storing in memory.
1520  llvm::AllocaInst *CreateIRTemp(QualType T, const Twine &Name = "tmp");
1521 
1522  /// CreateMemTemp - Create a temporary memory object of the given type, with
1523  /// appropriate alignment.
1524  llvm::AllocaInst *CreateMemTemp(QualType T, const Twine &Name = "tmp");
1525 
1526  /// CreateAggTemp - Create a temporary memory object for the given
1527  /// aggregate type.
1528  AggValueSlot CreateAggTemp(QualType T, const Twine &Name = "tmp") {
1529  CharUnits Alignment = getContext().getTypeAlignInChars(T);
1530  return AggValueSlot::forAddr(CreateMemTemp(T, Name), Alignment,
1531  T.getQualifiers(),
1535  }
1536 
1537  /// CreateInAllocaTmp - Create a temporary memory object for the given
1538  /// aggregate type.
1539  AggValueSlot CreateInAllocaTmp(QualType T, const Twine &Name = "inalloca");
1540 
1541  /// Emit a cast to void* in the appropriate address space.
1543 
1544  /// EvaluateExprAsBool - Perform the usual unary conversions on the specified
1545  /// expression and compare the result against zero, returning an Int1Ty value.
1546  llvm::Value *EvaluateExprAsBool(const Expr *E);
1547 
1548  /// EmitIgnoredExpr - Emit an expression in a context which ignores the result.
1549  void EmitIgnoredExpr(const Expr *E);
1550 
1551  /// EmitAnyExpr - Emit code to compute the specified expression which can have
1552  /// any type. The result is returned as an RValue struct. If this is an
1553  /// aggregate expression, the aggloc/agglocvolatile arguments indicate where
1554  /// the result should be returned.
1555  ///
1556  /// \param ignoreResult True if the resulting value isn't used.
1557  RValue EmitAnyExpr(const Expr *E,
1558  AggValueSlot aggSlot = AggValueSlot::ignored(),
1559  bool ignoreResult = false);
1560 
1561  // EmitVAListRef - Emit a "reference" to a va_list; this is either the address
1562  // or the value of the expression, depending on how va_list is defined.
1563  llvm::Value *EmitVAListRef(const Expr *E);
1564 
1565  /// EmitAnyExprToTemp - Similary to EmitAnyExpr(), however, the result will
1566  /// always be accessible even if no aggregate location is provided.
1567  RValue EmitAnyExprToTemp(const Expr *E);
1568 
1569  /// EmitAnyExprToMem - Emits the code necessary to evaluate an
1570  /// arbitrary expression into the given memory location.
1571  void EmitAnyExprToMem(const Expr *E, llvm::Value *Location,
1572  Qualifiers Quals, bool IsInitializer);
1573 
1574  void EmitAnyExprToExn(const Expr *E, llvm::Value *Addr);
1575 
1576  /// EmitExprAsInit - Emits the code necessary to initialize a
1577  /// location in memory with the given initializer.
1578  void EmitExprAsInit(const Expr *init, const ValueDecl *D, LValue lvalue,
1579  bool capturedByInit);
1580 
1581  /// hasVolatileMember - returns true if aggregate type has a volatile
1582  /// member.
1584  if (const RecordType *RT = T->getAs<RecordType>()) {
1585  const RecordDecl *RD = cast<RecordDecl>(RT->getDecl());
1586  return RD->hasVolatileMember();
1587  }
1588  return false;
1589  }
1590  /// EmitAggregateCopy - Emit an aggregate assignment.
1591  ///
1592  /// The difference to EmitAggregateCopy is that tail padding is not copied.
1593  /// This is required for correctness when assigning non-POD structures in C++.
1595  QualType EltTy) {
1596  bool IsVolatile = hasVolatileMember(EltTy);
1597  EmitAggregateCopy(DestPtr, SrcPtr, EltTy, IsVolatile, CharUnits::Zero(),
1598  true);
1599  }
1600 
1602  QualType DestTy, QualType SrcTy) {
1603  CharUnits DestTypeAlign = getContext().getTypeAlignInChars(DestTy);
1604  CharUnits SrcTypeAlign = getContext().getTypeAlignInChars(SrcTy);
1605  EmitAggregateCopy(DestPtr, SrcPtr, SrcTy, /*IsVolatile=*/false,
1606  std::min(DestTypeAlign, SrcTypeAlign),
1607  /*IsAssignment=*/false);
1608  }
1609 
1610  /// EmitAggregateCopy - Emit an aggregate copy.
1611  ///
1612  /// \param isVolatile - True iff either the source or the destination is
1613  /// volatile.
1614  /// \param isAssignment - If false, allow padding to be copied. This often
1615  /// yields more efficient.
1616  void EmitAggregateCopy(llvm::Value *DestPtr, llvm::Value *SrcPtr,
1617  QualType EltTy, bool isVolatile=false,
1618  CharUnits Alignment = CharUnits::Zero(),
1619  bool isAssignment = false);
1620 
1621  /// StartBlock - Start new block named N. If insert block is a dummy block
1622  /// then reuse it.
1623  void StartBlock(const char *N);
1624 
1625  /// GetAddrOfLocalVar - Return the address of a local variable.
1627  llvm::Value *Res = LocalDeclMap[VD];
1628  assert(Res && "Invalid argument to GetAddrOfLocalVar(), no decl!");
1629  return Res;
1630  }
1631 
1632  /// getOpaqueLValueMapping - Given an opaque value expression (which
1633  /// must be mapped to an l-value), return its mapping.
1636 
1637  llvm::DenseMap<const OpaqueValueExpr*,LValue>::iterator
1638  it = OpaqueLValues.find(e);
1639  assert(it != OpaqueLValues.end() && "no mapping for opaque value!");
1640  return it->second;
1641  }
1642 
1643  /// getOpaqueRValueMapping - Given an opaque value expression (which
1644  /// must be mapped to an r-value), return its mapping.
1647 
1648  llvm::DenseMap<const OpaqueValueExpr*,RValue>::iterator
1649  it = OpaqueRValues.find(e);
1650  assert(it != OpaqueRValues.end() && "no mapping for opaque value!");
1651  return it->second;
1652  }
1653 
1654  /// getAccessedFieldNo - Given an encoded value and a result number, return
1655  /// the input field number being accessed.
1656  static unsigned getAccessedFieldNo(unsigned Idx, const llvm::Constant *Elts);
1657 
1658  llvm::BlockAddress *GetAddrOfLabel(const LabelDecl *L);
1659  llvm::BasicBlock *GetIndirectGotoBlock();
1660 
1661  /// EmitNullInitialization - Generate code to set a value of the given type to
1662  /// null, If the type contains data member pointers, they will be initialized
1663  /// to -1 in accordance with the Itanium C++ ABI.
1664  void EmitNullInitialization(llvm::Value *DestPtr, QualType Ty);
1665 
1666  // EmitVAArg - Generate code to get an argument from the passed in pointer
1667  // and update it accordingly. The return value is a pointer to the argument.
1668  // FIXME: We should be able to get rid of this method and use the va_arg
1669  // instruction in LLVM instead once it works well enough.
1670  llvm::Value *EmitVAArg(llvm::Value *VAListAddr, QualType Ty);
1671 
1672  /// emitArrayLength - Compute the length of an array, even if it's a
1673  /// VLA, and drill down to the base element type.
1674  llvm::Value *emitArrayLength(const ArrayType *arrayType,
1675  QualType &baseType,
1676  llvm::Value *&addr);
1677 
1678  /// EmitVLASize - Capture all the sizes for the VLA expressions in
1679  /// the given variably-modified type and store them in the VLASizeMap.
1680  ///
1681  /// This function can be called with a null (unreachable) insert point.
1683 
1684  /// getVLASize - Returns an LLVM value that corresponds to the size,
1685  /// in non-variably-sized elements, of a variable length array type,
1686  /// plus that largest non-variably-sized element type. Assumes that
1687  /// the type has already been emitted with EmitVariablyModifiedType.
1688  std::pair<llvm::Value*,QualType> getVLASize(const VariableArrayType *vla);
1689  std::pair<llvm::Value*,QualType> getVLASize(QualType vla);
1690 
1691  /// LoadCXXThis - Load the value of 'this'. This function is only valid while
1692  /// generating code for an C++ member function.
1694  assert(CXXThisValue && "no 'this' value for this function");
1695  return CXXThisValue;
1696  }
1697 
1698  /// LoadCXXVTT - Load the VTT parameter to base constructors/destructors have
1699  /// virtual bases.
1700  // FIXME: Every place that calls LoadCXXVTT is something
1701  // that needs to be abstracted properly.
1703  assert(CXXStructorImplicitParamValue && "no VTT value for this function");
1704  return CXXStructorImplicitParamValue;
1705  }
1706 
1707  /// LoadCXXStructorImplicitParam - Load the implicit parameter
1708  /// for a constructor/destructor.
1710  assert(CXXStructorImplicitParamValue &&
1711  "no implicit argument value for this function");
1712  return CXXStructorImplicitParamValue;
1713  }
1714 
1715  /// GetAddressOfBaseOfCompleteClass - Convert the given pointer to a
1716  /// complete class to the given direct base.
1717  llvm::Value *
1719  const CXXRecordDecl *Derived,
1720  const CXXRecordDecl *Base,
1721  bool BaseIsVirtual);
1722 
1723  /// GetAddressOfBaseClass - This function will add the necessary delta to the
1724  /// load of 'this' and returns address of the base class.
1726  const CXXRecordDecl *Derived,
1729  bool NullCheckValue, SourceLocation Loc);
1730 
1732  const CXXRecordDecl *Derived,
1735  bool NullCheckValue);
1736 
1737  /// GetVTTParameter - Return the VTT parameter that should be passed to a
1738  /// base constructor/destructor with virtual bases.
1739  /// FIXME: VTTs are Itanium ABI-specific, so the definition should move
1740  /// to ItaniumCXXABI.cpp together with all the references to VTT.
1741  llvm::Value *GetVTTParameter(GlobalDecl GD, bool ForVirtualBase,
1742  bool Delegating);
1743 
1745  CXXCtorType CtorType,
1746  const FunctionArgList &Args,
1747  SourceLocation Loc);
1748  // It's important not to confuse this and the previous function. Delegating
1749  // constructors are the C++0x feature. The constructor delegate optimization
1750  // is used to reduce duplication in the base and complete consturctors where
1751  // they are substantially the same.
1753  const FunctionArgList &Args);
1755  bool ForVirtualBase, bool Delegating,
1756  llvm::Value *This, const CXXConstructExpr *E);
1757 
1759  llvm::Value *This, llvm::Value *Src,
1760  const CXXConstructExpr *E);
1761 
1763  const ConstantArrayType *ArrayTy,
1764  llvm::Value *ArrayPtr,
1765  const CXXConstructExpr *E,
1766  bool ZeroInitialization = false);
1767 
1769  llvm::Value *NumElements,
1770  llvm::Value *ArrayPtr,
1771  const CXXConstructExpr *E,
1772  bool ZeroInitialization = false);
1773 
1775 
1777  bool ForVirtualBase, bool Delegating,
1778  llvm::Value *This);
1779 
1780  void EmitNewArrayInitializer(const CXXNewExpr *E, QualType elementType,
1781  llvm::Type *ElementTy, llvm::Value *NewPtr,
1782  llvm::Value *NumElements,
1783  llvm::Value *AllocSizeWithoutCookie);
1784 
1785  void EmitCXXTemporary(const CXXTemporary *Temporary, QualType TempType,
1786  llvm::Value *Ptr);
1787 
1788  llvm::Value *EmitLifetimeStart(uint64_t Size, llvm::Value *Addr);
1789  void EmitLifetimeEnd(llvm::Value *Size, llvm::Value *Addr);
1790 
1792  void EmitCXXDeleteExpr(const CXXDeleteExpr *E);
1793 
1794  void EmitDeleteCall(const FunctionDecl *DeleteFD, llvm::Value *Ptr,
1795  QualType DeleteTy);
1796 
1798  const Expr *Arg, bool IsDelete);
1799 
1803 
1804  /// \brief Situations in which we might emit a check for the suitability of a
1805  /// pointer or glvalue.
1807  /// Checking the operand of a load. Must be suitably sized and aligned.
1809  /// Checking the destination of a store. Must be suitably sized and aligned.
1811  /// Checking the bound value in a reference binding. Must be suitably sized
1812  /// and aligned, but is not required to refer to an object (until the
1813  /// reference is used), per core issue 453.
1815  /// Checking the object expression in a non-static data member access. Must
1816  /// be an object within its lifetime.
1818  /// Checking the 'this' pointer for a call to a non-static member function.
1819  /// Must be an object within its lifetime.
1821  /// Checking the 'this' pointer for a constructor call.
1823  /// Checking the operand of a static_cast to a derived pointer type. Must be
1824  /// null or an object within its lifetime.
1826  /// Checking the operand of a static_cast to a derived reference type. Must
1827  /// be an object within its lifetime.
1829  /// Checking the operand of a cast to a base object. Must be suitably sized
1830  /// and aligned.
1832  /// Checking the operand of a cast to a virtual base object. Must be an
1833  /// object within its lifetime.
1835  };
1836 
1837  /// \brief Whether any type-checking sanitizers are enabled. If \c false,
1838  /// calls to EmitTypeCheck can be skipped.
1839  bool sanitizePerformTypeCheck() const;
1840 
1841  /// \brief Emit a check that \p V is the address of storage of the
1842  /// appropriate size and alignment for an object of type \p Type.
1844  QualType Type, CharUnits Alignment = CharUnits::Zero(),
1845  bool SkipNullCheck = false);
1846 
1847  /// \brief Emit a check that \p Base points into an array object, which
1848  /// we can access at index \p Index. \p Accessed should be \c false if we
1849  /// this expression is used as an lvalue, for instance in "&Arr[Idx]".
1850  void EmitBoundsCheck(const Expr *E, const Expr *Base, llvm::Value *Index,
1851  QualType IndexType, bool Accessed);
1852 
1854  bool isInc, bool isPre);
1856  bool isInc, bool isPre);
1857 
1858  void EmitAlignmentAssumption(llvm::Value *PtrValue, unsigned Alignment,
1859  llvm::Value *OffsetValue = nullptr) {
1860  Builder.CreateAlignmentAssumption(CGM.getDataLayout(), PtrValue, Alignment,
1861  OffsetValue);
1862  }
1863 
1864  //===--------------------------------------------------------------------===//
1865  // Declaration Emission
1866  //===--------------------------------------------------------------------===//
1867 
1868  /// EmitDecl - Emit a declaration.
1869  ///
1870  /// This function can be called with a null (unreachable) insert point.
1871  void EmitDecl(const Decl &D);
1872 
1873  /// EmitVarDecl - Emit a local variable declaration.
1874  ///
1875  /// This function can be called with a null (unreachable) insert point.
1876  void EmitVarDecl(const VarDecl &D);
1877 
1878  void EmitScalarInit(const Expr *init, const ValueDecl *D, LValue lvalue,
1879  bool capturedByInit);
1880  void EmitScalarInit(llvm::Value *init, LValue lvalue);
1881 
1882  typedef void SpecialInitFn(CodeGenFunction &Init, const VarDecl &D,
1883  llvm::Value *Address);
1884 
1885  /// \brief Determine whether the given initializer is trivial in the sense
1886  /// that it requires no code to be generated.
1887  bool isTrivialInitializer(const Expr *Init);
1888 
1889  /// EmitAutoVarDecl - Emit an auto variable declaration.
1890  ///
1891  /// This function can be called with a null (unreachable) insert point.
1892  void EmitAutoVarDecl(const VarDecl &D);
1893 
1895  friend class CodeGenFunction;
1896 
1897  const VarDecl *Variable;
1898 
1899  /// The alignment of the variable.
1900  CharUnits Alignment;
1901 
1902  /// The address of the alloca. Null if the variable was emitted
1903  /// as a global constant.
1904  llvm::Value *Address;
1905 
1906  llvm::Value *NRVOFlag;
1907 
1908  /// True if the variable is a __block variable.
1909  bool IsByRef;
1910 
1911  /// True if the variable is of aggregate type and has a constant
1912  /// initializer.
1913  bool IsConstantAggregate;
1914 
1915  /// Non-null if we should use lifetime annotations.
1916  llvm::Value *SizeForLifetimeMarkers;
1917 
1918  struct Invalid {};
1919  AutoVarEmission(Invalid) : Variable(nullptr) {}
1920 
1921  AutoVarEmission(const VarDecl &variable)
1922  : Variable(&variable), Address(nullptr), NRVOFlag(nullptr),
1923  IsByRef(false), IsConstantAggregate(false),
1924  SizeForLifetimeMarkers(nullptr) {}
1925 
1926  bool wasEmittedAsGlobal() const { return Address == nullptr; }
1927 
1928  public:
1929  static AutoVarEmission invalid() { return AutoVarEmission(Invalid()); }
1930 
1931  bool useLifetimeMarkers() const {
1932  return SizeForLifetimeMarkers != nullptr;
1933  }
1935  assert(useLifetimeMarkers());
1936  return SizeForLifetimeMarkers;
1937  }
1938 
1939  /// Returns the raw, allocated address, which is not necessarily
1940  /// the address of the object itself.
1942  return Address;
1943  }
1944 
1945  /// Returns the address of the object within this declaration.
1946  /// Note that this does not chase the forwarding pointer for
1947  /// __block decls.
1949  if (!IsByRef) return Address;
1950 
1951  auto F = CGF.getByRefValueLLVMField(Variable);
1952  return CGF.Builder.CreateStructGEP(F.first, Address, F.second,
1953  Variable->getNameAsString());
1954  }
1955  };
1956  AutoVarEmission EmitAutoVarAlloca(const VarDecl &var);
1957  void EmitAutoVarInit(const AutoVarEmission &emission);
1958  void EmitAutoVarCleanups(const AutoVarEmission &emission);
1959  void emitAutoVarTypeCleanup(const AutoVarEmission &emission,
1960  QualType::DestructionKind dtorKind);
1961 
1962  void EmitStaticVarDecl(const VarDecl &D,
1963  llvm::GlobalValue::LinkageTypes Linkage);
1964 
1965  /// EmitParmDecl - Emit a ParmVarDecl or an ImplicitParamDecl.
1966  void EmitParmDecl(const VarDecl &D, llvm::Value *Arg, bool ArgIsPointer,
1967  unsigned ArgNo);
1968 
1969  /// protectFromPeepholes - Protect a value that we're intending to
1970  /// store to the side, but which will probably be used later, from
1971  /// aggressive peepholing optimizations that might delete it.
1972  ///
1973  /// Pass the result to unprotectFromPeepholes to declare that
1974  /// protection is no longer required.
1975  ///
1976  /// There's no particular reason why this shouldn't apply to
1977  /// l-values, it's just that no existing peepholes work on pointers.
1978  PeepholeProtection protectFromPeepholes(RValue rvalue);
1979  void unprotectFromPeepholes(PeepholeProtection protection);
1980 
1981  //===--------------------------------------------------------------------===//
1982  // Statement Emission
1983  //===--------------------------------------------------------------------===//
1984 
1985  /// EmitStopPoint - Emit a debug stoppoint if we are emitting debug info.
1986  void EmitStopPoint(const Stmt *S);
1987 
1988  /// EmitStmt - Emit the code for the statement \arg S. It is legal to call
1989  /// this function even if there is no current insertion point.
1990  ///
1991  /// This function may clear the current insertion point; callers should use
1992  /// EnsureInsertPoint if they wish to subsequently generate code without first
1993  /// calling EmitBlock, EmitBranch, or EmitStmt.
1994  void EmitStmt(const Stmt *S);
1995 
1996  /// EmitSimpleStmt - Try to emit a "simple" statement which does not
1997  /// necessarily require an insertion point or debug information; typically
1998  /// because the statement amounts to a jump or a container of other
1999  /// statements.
2000  ///
2001  /// \return True if the statement was handled.
2002  bool EmitSimpleStmt(const Stmt *S);
2003 
2004  llvm::Value *EmitCompoundStmt(const CompoundStmt &S, bool GetLast = false,
2007  bool GetLast = false,
2008  AggValueSlot AVS =
2010 
2011  /// EmitLabel - Emit the block for the given label. It is legal to call this
2012  /// function even if there is no current insertion point.
2013  void EmitLabel(const LabelDecl *D); // helper for EmitLabelStmt.
2014 
2015  void EmitLabelStmt(const LabelStmt &S);
2016  void EmitAttributedStmt(const AttributedStmt &S);
2017  void EmitGotoStmt(const GotoStmt &S);
2018  void EmitIndirectGotoStmt(const IndirectGotoStmt &S);
2019  void EmitIfStmt(const IfStmt &S);
2020 
2021  void EmitCondBrHints(llvm::LLVMContext &Context, llvm::BranchInst *CondBr,
2022  ArrayRef<const Attr *> Attrs);
2023  void EmitWhileStmt(const WhileStmt &S,
2024  ArrayRef<const Attr *> Attrs = None);
2025  void EmitDoStmt(const DoStmt &S, ArrayRef<const Attr *> Attrs = None);
2026  void EmitForStmt(const ForStmt &S,
2027  ArrayRef<const Attr *> Attrs = None);
2028  void EmitReturnStmt(const ReturnStmt &S);
2029  void EmitDeclStmt(const DeclStmt &S);
2030  void EmitBreakStmt(const BreakStmt &S);
2031  void EmitContinueStmt(const ContinueStmt &S);
2032  void EmitSwitchStmt(const SwitchStmt &S);
2033  void EmitDefaultStmt(const DefaultStmt &S);
2034  void EmitCaseStmt(const CaseStmt &S);
2035  void EmitCaseStmtRange(const CaseStmt &S);
2036  void EmitAsmStmt(const AsmStmt &S);
2037 
2039  void EmitObjCAtTryStmt(const ObjCAtTryStmt &S);
2040  void EmitObjCAtThrowStmt(const ObjCAtThrowStmt &S);
2043 
2044  void EnterCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock = false);
2045  void ExitCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock = false);
2046 
2047  void EmitCXXTryStmt(const CXXTryStmt &S);
2048  void EmitSEHTryStmt(const SEHTryStmt &S);
2049  void EmitSEHLeaveStmt(const SEHLeaveStmt &S);
2050  void EnterSEHTryStmt(const SEHTryStmt &S);
2051  void ExitSEHTryStmt(const SEHTryStmt &S);
2052 
2053  void startOutlinedSEHHelper(CodeGenFunction &ParentCGF, bool IsFilter,
2054  const Stmt *OutlinedStmt);
2055 
2056  llvm::Function *GenerateSEHFilterFunction(CodeGenFunction &ParentCGF,
2057  const SEHExceptStmt &Except);
2058 
2059  llvm::Function *GenerateSEHFinallyFunction(CodeGenFunction &ParentCGF,
2060  const SEHFinallyStmt &Finally);
2061 
2062  void EmitSEHExceptionCodeSave(CodeGenFunction &ParentCGF,
2063  llvm::Value *ParentFP,
2064  llvm::Value *EntryEBP);
2068 
2069  /// Scan the outlined statement for captures from the parent function. For
2070  /// each capture, mark the capture as escaped and emit a call to
2071  /// llvm.localrecover. Insert the localrecover result into the LocalDeclMap.
2072  void EmitCapturedLocals(CodeGenFunction &ParentCGF, const Stmt *OutlinedStmt,
2073  bool IsFilter);
2074 
2075  /// Recovers the address of a local in a parent function. ParentVar is the
2076  /// address of the variable used in the immediate parent function. It can
2077  /// either be an alloca or a call to llvm.localrecover if there are nested
2078  /// outlined functions. ParentFP is the frame pointer of the outermost parent
2079  /// frame.
2081  llvm::Value *ParentVar,
2082  llvm::Value *ParentFP);
2083 
2084  void EmitCXXForRangeStmt(const CXXForRangeStmt &S,
2085  ArrayRef<const Attr *> Attrs = None);
2086 
2088  llvm::Function *EmitCapturedStmt(const CapturedStmt &S, CapturedRegionKind K);
2090  llvm::Function *GenerateCapturedStmtFunctionEpilog(const CapturedStmt &S);
2091  llvm::Function *GenerateCapturedStmtFunction(const CapturedStmt &S);
2093  /// \brief Perform element by element copying of arrays with type \a
2094  /// OriginalType from \a SrcAddr to \a DestAddr using copying procedure
2095  /// generated by \a CopyGen.
2096  ///
2097  /// \param DestAddr Address of the destination array.
2098  /// \param SrcAddr Address of the source array.
2099  /// \param OriginalType Type of destination and source arrays.
2100  /// \param CopyGen Copying procedure that copies value of single array element
2101  /// to another single array element.
2103  llvm::Value *DestAddr, llvm::Value *SrcAddr, QualType OriginalType,
2104  const llvm::function_ref<void(llvm::Value *, llvm::Value *)> &CopyGen);
2105  /// \brief Emit proper copying of data from one variable to another.
2106  ///
2107  /// \param OriginalType Original type of the copied variables.
2108  /// \param DestAddr Destination address.
2109  /// \param SrcAddr Source address.
2110  /// \param DestVD Destination variable used in \a CopyExpr (for arrays, has
2111  /// type of the base array element).
2112  /// \param SrcVD Source variable used in \a CopyExpr (for arrays, has type of
2113  /// the base array element).
2114  /// \param Copy Actual copygin expression for copying data from \a SrcVD to \a
2115  /// DestVD.
2116  void EmitOMPCopy(CodeGenFunction &CGF, QualType OriginalType,
2117  llvm::Value *DestAddr, llvm::Value *SrcAddr,
2118  const VarDecl *DestVD, const VarDecl *SrcVD,
2119  const Expr *Copy);
2120  /// \brief Emit atomic update code for constructs: \a X = \a X \a BO \a E or
2121  /// \a X = \a E \a BO \a E.
2122  ///
2123  /// \param X Value to be updated.
2124  /// \param E Update value.
2125  /// \param BO Binary operation for update operation.
2126  /// \param IsXLHSInRHSPart true if \a X is LHS in RHS part of the update
2127  /// expression, false otherwise.
2128  /// \param AO Atomic ordering of the generated atomic instructions.
2129  /// \param CommonGen Code generator for complex expressions that cannot be
2130  /// expressed through atomicrmw instruction.
2131  /// \returns <true, OldAtomicValue> if simple 'atomicrmw' instruction was
2132  /// generated, <false, RValue::get(nullptr)> otherwise.
2133  std::pair<bool, RValue> EmitOMPAtomicSimpleUpdateExpr(
2134  LValue X, RValue E, BinaryOperatorKind BO, bool IsXLHSInRHSPart,
2135  llvm::AtomicOrdering AO, SourceLocation Loc,
2136  const llvm::function_ref<RValue(RValue)> &CommonGen);
2138  OMPPrivateScope &PrivateScope);
2140  OMPPrivateScope &PrivateScope);
2141  /// \brief Emit code for copyin clause in \a D directive. The next code is
2142  /// generated at the start of outlined functions for directives:
2143  /// \code
2144  /// threadprivate_var1 = master_threadprivate_var1;
2145  /// operator=(threadprivate_var2, master_threadprivate_var2);
2146  /// ...
2147  /// __kmpc_barrier(&loc, global_tid);
2148  /// \endcode
2149  ///
2150  /// \param D OpenMP directive possibly with 'copyin' clause(s).
2151  /// \returns true if at least one copyin variable is found, false otherwise.
2153  /// \brief Emit initial code for lastprivate variables. If some variable is
2154  /// not also firstprivate, then the default initialization is used. Otherwise
2155  /// initialization of this variable is performed by EmitOMPFirstprivateClause
2156  /// method.
2157  ///
2158  /// \param D Directive that may have 'lastprivate' directives.
2159  /// \param PrivateScope Private scope for capturing lastprivate variables for
2160  /// proper codegen in internal captured statement.
2161  ///
2162  /// \returns true if there is at least one lastprivate variable, false
2163  /// otherwise.
2165  OMPPrivateScope &PrivateScope);
2166  /// \brief Emit final copying of lastprivate values to original variables at
2167  /// the end of the worksharing or simd directive.
2168  ///
2169  /// \param D Directive that has at least one 'lastprivate' directives.
2170  /// \param IsLastIterCond Boolean condition that must be set to 'i1 true' if
2171  /// it is the last iteration of the loop code in associated directive, or to
2172  /// 'i1 false' otherwise. If this item is nullptr, no final check is required.
2174  llvm::Value *IsLastIterCond = nullptr);
2175  /// \brief Emit initial code for reduction variables. Creates reduction copies
2176  /// and initializes them with the values according to OpenMP standard.
2177  ///
2178  /// \param D Directive (possibly) with the 'reduction' clause.
2179  /// \param PrivateScope Private scope for capturing reduction variables for
2180  /// proper codegen in internal captured statement.
2181  ///
2183  OMPPrivateScope &PrivateScope);
2184  /// \brief Emit final update of reduction values to original variables at
2185  /// the end of the directive.
2186  ///
2187  /// \param D Directive that has at least one 'reduction' directives.
2189  /// \brief Emit initial code for linear variables. Creates private copies
2190  /// and initializes them with the values according to OpenMP standard.
2191  ///
2192  /// \param D Directive (possibly) with the 'linear' clause.
2194 
2196  void EmitOMPSimdDirective(const OMPSimdDirective &S);
2197  void EmitOMPForDirective(const OMPForDirective &S);
2207  void EmitOMPTaskDirective(const OMPTaskDirective &S);
2217  void
2220 
2221  /// \brief Emit inner loop of the worksharing/simd construct.
2222  ///
2223  /// \param S Directive, for which the inner loop must be emitted.
2224  /// \param RequiresCleanup true, if directive has some associated private
2225  /// variables.
2226  /// \param LoopCond Bollean condition for loop continuation.
2227  /// \param IncExpr Increment expression for loop control variable.
2228  /// \param BodyGen Generator for the inner body of the inner loop.
2229  /// \param PostIncGen Genrator for post-increment code (required for ordered
2230  /// loop directvies).
2231  void EmitOMPInnerLoop(
2232  const Stmt &S, bool RequiresCleanup, const Expr *LoopCond,
2233  const Expr *IncExpr,
2234  const llvm::function_ref<void(CodeGenFunction &)> &BodyGen,
2235  const llvm::function_ref<void(CodeGenFunction &)> &PostIncGen);
2236 
2238 
2239 private:
2240 
2241  /// Helpers for the OpenMP loop directives.
2242  void EmitOMPLoopBody(const OMPLoopDirective &D, JumpDest LoopExit);
2243  void EmitOMPSimdInit(const OMPLoopDirective &D);
2244  void EmitOMPSimdFinal(const OMPLoopDirective &D);
2245  /// \brief Emit code for the worksharing loop-based directive.
2246  /// \return true, if this construct has any lastprivate clause, false -
2247  /// otherwise.
2248  bool EmitOMPWorksharingLoop(const OMPLoopDirective &S);
2249  void EmitOMPForOuterLoop(OpenMPScheduleClauseKind ScheduleKind,
2250  const OMPLoopDirective &S,
2251  OMPPrivateScope &LoopScope, bool Ordered,
2252  llvm::Value *LB, llvm::Value *UB, llvm::Value *ST,
2253  llvm::Value *IL, llvm::Value *Chunk);
2254  /// \brief Emit code for sections directive.
2255  OpenMPDirectiveKind EmitSections(const OMPExecutableDirective &S);
2256 
2257 public:
2258 
2259  //===--------------------------------------------------------------------===//
2260  // LValue Expression Emission
2261  //===--------------------------------------------------------------------===//
2262 
2263  /// GetUndefRValue - Get an appropriate 'undef' rvalue for the given type.
2265 
2266  /// EmitUnsupportedRValue - Emit a dummy r-value using the type of E
2267  /// and issue an ErrorUnsupported style diagnostic (using the
2268  /// provided Name).
2270  const char *Name);
2271 
2272  /// EmitUnsupportedLValue - Emit a dummy l-value using the type of E and issue
2273  /// an ErrorUnsupported style diagnostic (using the provided Name).
2275  const char *Name);
2276 
2277  /// EmitLValue - Emit code to compute a designator that specifies the location
2278  /// of the expression.
2279  ///
2280  /// This can return one of two things: a simple address or a bitfield
2281  /// reference. In either case, the LLVM Value* in the LValue structure is
2282  /// guaranteed to be an LLVM pointer type.
2283  ///
2284  /// If this returns a bitfield reference, nothing about the pointee type of
2285  /// the LLVM value is known: For example, it may not be a pointer to an
2286  /// integer.
2287  ///
2288  /// If this returns a normal address, and if the lvalue's C type is fixed
2289  /// size, this method guarantees that the returned pointer type will point to
2290  /// an LLVM type of the same size of the lvalue's type. If the lvalue has a
2291  /// variable length type, this is not possible.
2292  ///
2293  LValue EmitLValue(const Expr *E);
2294 
2295  /// \brief Same as EmitLValue but additionally we generate checking code to
2296  /// guard against undefined behavior. This is only suitable when we know
2297  /// that the address will be used to access the object.
2298  LValue EmitCheckedLValue(const Expr *E, TypeCheckKind TCK);
2299 
2301  SourceLocation Loc);
2302 
2303  void EmitAtomicInit(Expr *E, LValue lvalue);
2304 
2306  bool typeIsSuitableForInlineAtomic(QualType Ty, bool IsVolatile) const;
2307 
2310 
2312  llvm::AtomicOrdering AO, bool IsVolatile = false,
2314 
2315  void EmitAtomicStore(RValue rvalue, LValue lvalue, bool isInit);
2316 
2317  void EmitAtomicStore(RValue rvalue, LValue lvalue, llvm::AtomicOrdering AO,
2318  bool IsVolatile, bool isInit);
2319 
2320  std::pair<RValue, llvm::Value *> EmitAtomicCompareExchange(
2321  LValue Obj, RValue Expected, RValue Desired, SourceLocation Loc,
2322  llvm::AtomicOrdering Success = llvm::SequentiallyConsistent,
2323  llvm::AtomicOrdering Failure = llvm::SequentiallyConsistent,
2324  bool IsWeak = false, AggValueSlot Slot = AggValueSlot::ignored());
2325 
2326  void EmitAtomicUpdate(LValue LVal, llvm::AtomicOrdering AO,
2327  const llvm::function_ref<RValue(RValue)> &UpdateOp,
2328  bool IsVolatile);
2329 
2330  /// EmitToMemory - Change a scalar value from its value
2331  /// representation to its in-memory representation.
2333 
2334  /// EmitFromMemory - Change a scalar value from its memory
2335  /// representation to its value representation.
2337 
2338  /// EmitLoadOfScalar - Load a scalar value from an address, taking
2339  /// care to appropriately convert from the memory representation to
2340  /// the LLVM value representation.
2341  llvm::Value *EmitLoadOfScalar(llvm::Value *Addr, bool Volatile,
2342  unsigned Alignment, QualType Ty,
2343  SourceLocation Loc,
2344  llvm::MDNode *TBAAInfo = nullptr,
2345  QualType TBAABaseTy = QualType(),
2346  uint64_t TBAAOffset = 0);
2347 
2348  /// EmitLoadOfScalar - Load a scalar value from an address, taking
2349  /// care to appropriately convert from the memory representation to
2350  /// the LLVM value representation. The l-value must be a simple
2351  /// l-value.
2353 
2354  /// EmitStoreOfScalar - Store a scalar value to an address, taking
2355  /// care to appropriately convert from the memory representation to
2356  /// the LLVM value representation.
2358  bool Volatile, unsigned Alignment, QualType Ty,
2359  llvm::MDNode *TBAAInfo = nullptr, bool isInit = false,
2360  QualType TBAABaseTy = QualType(),
2361  uint64_t TBAAOffset = 0);
2362 
2363  /// EmitStoreOfScalar - Store a scalar value to an address, taking
2364  /// care to appropriately convert from the memory representation to
2365  /// the LLVM value representation. The l-value must be a simple
2366  /// l-value. The isInit flag indicates whether this is an initialization.
2367  /// If so, atomic qualifiers are ignored and the store is always non-atomic.
2368  void EmitStoreOfScalar(llvm::Value *value, LValue lvalue, bool isInit=false);
2369 
2370  /// EmitLoadOfLValue - Given an expression that represents a value lvalue,
2371  /// this method emits the address of the lvalue, then loads the result as an
2372  /// rvalue, returning the rvalue.
2377 
2378  /// EmitStoreThroughLValue - Store the specified rvalue into the specified
2379  /// lvalue, where both are guaranteed to the have the same type, and that type
2380  /// is 'Ty'.
2381  void EmitStoreThroughLValue(RValue Src, LValue Dst, bool isInit = false);
2384 
2385  /// EmitStoreThroughBitfieldLValue - Store Src into Dst with same constraints
2386  /// as EmitStoreThroughLValue.
2387  ///
2388  /// \param Result [out] - If non-null, this will be set to a Value* for the
2389  /// bit-field contents after the store, appropriate for use as the result of
2390  /// an assignment to the bit-field.
2392  llvm::Value **Result=nullptr);
2393 
2394  /// Emit an l-value for an assignment (simple or compound) of complex type.
2398  llvm::Value *&Result);
2399 
2400  // Note: only available for agg return types
2403  // Note: only available for agg return types
2405  // Note: only available for agg return types
2408  LValue EmitReadRegister(const VarDecl *VD);
2414  bool Accessed = false);
2416  LValue EmitMemberExpr(const MemberExpr *E);
2421  LValue EmitCastLValue(const CastExpr *E);
2424 
2426 
2428 
2430  llvm::PointerIntPair<llvm::Constant*, 1, bool> ValueAndIsReference;
2431  ConstantEmission(llvm::Constant *C, bool isReference)
2432  : ValueAndIsReference(C, isReference) {}
2433  public:
2435  static ConstantEmission forReference(llvm::Constant *C) {
2436  return ConstantEmission(C, true);
2437  }
2438  static ConstantEmission forValue(llvm::Constant *C) {
2439  return ConstantEmission(C, false);
2440  }
2441 
2442  explicit operator bool() const {
2443  return ValueAndIsReference.getOpaqueValue() != nullptr;
2444  }
2445 
2446  bool isReference() const { return ValueAndIsReference.getInt(); }
2448  assert(isReference());
2449  return CGF.MakeNaturalAlignAddrLValue(ValueAndIsReference.getPointer(),
2450  refExpr->getType());
2451  }
2452 
2453  llvm::Constant *getValue() const {
2454  assert(!isReference());
2455  return ValueAndIsReference.getPointer();
2456  }
2457  };
2458 
2459  ConstantEmission tryEmitAsConstant(DeclRefExpr *refExpr);
2460 
2464 
2465  llvm::Value *EmitIvarOffset(const ObjCInterfaceDecl *Interface,
2466  const ObjCIvarDecl *Ivar);
2469 
2470  /// EmitLValueForFieldInitialization - Like EmitLValueForField, except that
2471  /// if the Field is a reference, this will return the address of the reference
2472  /// and not the address of the value stored in the reference.
2474  const FieldDecl* Field);
2475 
2477  llvm::Value* Base, const ObjCIvarDecl *Ivar,
2478  unsigned CVRQualifiers);
2479 
2485 
2491  void EmitDeclRefExprDbgValue(const DeclRefExpr *E, llvm::Constant *Init);
2492 
2493  //===--------------------------------------------------------------------===//
2494  // Scalar Expression Emission
2495  //===--------------------------------------------------------------------===//
2496 
2497  /// EmitCall - Generate a call of the given function, expecting the given
2498  /// result type, and using the given argument list which specifies both the
2499  /// LLVM arguments and the types they were derived from.
2500  ///
2501  /// \param TargetDecl - If given, the decl of the function in a direct call;
2502  /// used to set attributes on the call (noreturn, etc.).
2503  RValue EmitCall(const CGFunctionInfo &FnInfo,
2504  llvm::Value *Callee,
2506  const CallArgList &Args,
2507  const Decl *TargetDecl = nullptr,
2508  llvm::Instruction **callOrInvoke = nullptr);
2509 
2510  RValue EmitCall(QualType FnType, llvm::Value *Callee, const CallExpr *E,
2512  const Decl *TargetDecl = nullptr,
2513  llvm::Value *Chain = nullptr);
2514  RValue EmitCallExpr(const CallExpr *E,
2516 
2517  llvm::CallInst *EmitRuntimeCall(llvm::Value *callee,
2518  const Twine &name = "");
2519  llvm::CallInst *EmitRuntimeCall(llvm::Value *callee,
2521  const Twine &name = "");
2522  llvm::CallInst *EmitNounwindRuntimeCall(llvm::Value *callee,
2523  const Twine &name = "");
2524  llvm::CallInst *EmitNounwindRuntimeCall(llvm::Value *callee,
2526  const Twine &name = "");
2527 
2528  llvm::CallSite EmitCallOrInvoke(llvm::Value *Callee,
2530  const Twine &Name = "");
2531  llvm::CallSite EmitCallOrInvoke(llvm::Value *Callee,
2532  const Twine &Name = "");
2533  llvm::CallSite EmitRuntimeCallOrInvoke(llvm::Value *callee,
2535  const Twine &name = "");
2536  llvm::CallSite EmitRuntimeCallOrInvoke(llvm::Value *callee,
2537  const Twine &name = "");
2539  ArrayRef<llvm::Value*> args);
2540 
2542  NestedNameSpecifier *Qual,
2543  llvm::Type *Ty);
2544 
2546  CXXDtorType Type,
2547  const CXXRecordDecl *RD);
2548 
2549  RValue
2552  llvm::Value *ImplicitParam,
2553  QualType ImplicitParamTy, const CallExpr *E);
2556  llvm::Value *ImplicitParam,
2557  QualType ImplicitParamTy, const CallExpr *E,
2558  StructorType Type);
2562  const CXXMethodDecl *MD,
2564  bool HasQualifier,
2565  NestedNameSpecifier *Qualifier,
2566  bool IsArrow, const Expr *Base);
2567  // Compute the object pointer.
2570 
2572  const CXXMethodDecl *MD,
2574 
2577 
2578 
2580  unsigned BuiltinID, const CallExpr *E,
2582 
2584 
2585  /// EmitTargetBuiltinExpr - Emit the given builtin call. Returns 0 if the call
2586  /// is unhandled by the current target.
2587  llvm::Value *EmitTargetBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
2588 
2590  const llvm::CmpInst::Predicate Fp,
2591  const llvm::CmpInst::Predicate Ip,
2592  const llvm::Twine &Name = "");
2593  llvm::Value *EmitARMBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
2594 
2595  llvm::Value *EmitCommonNeonBuiltinExpr(unsigned BuiltinID,
2596  unsigned LLVMIntrinsic,
2597  unsigned AltLLVMIntrinsic,
2598  const char *NameHint,
2599  unsigned Modifier,
2600  const CallExpr *E,
2602  llvm::Value *Align = nullptr);
2603  llvm::Function *LookupNeonLLVMIntrinsic(unsigned IntrinsicID,
2604  unsigned Modifier, llvm::Type *ArgTy,
2605  const CallExpr *E);
2606  llvm::Value *EmitNeonCall(llvm::Function *F,
2608  const char *name,
2609  unsigned shift = 0, bool rightshift = false);
2610  llvm::Value *EmitNeonSplat(llvm::Value *V, llvm::Constant *Idx);
2611  llvm::Value *EmitNeonShiftVector(llvm::Value *V, llvm::Type *Ty,
2612  bool negateForRightShift);
2614  llvm::Type *Ty, bool usgn, const char *name);
2615  // Helper functions for EmitAArch64BuiltinExpr.
2618  llvm::Value *EmitAArch64BuiltinExpr(unsigned BuiltinID, const CallExpr *E);
2619 
2621  llvm::Value *EmitX86BuiltinExpr(unsigned BuiltinID, const CallExpr *E);
2622  llvm::Value *EmitPPCBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
2623  llvm::Value *EmitAMDGPUBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
2624  llvm::Value *EmitSystemZBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
2625  llvm::Value *EmitNVPTXBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
2626 
2633  const ObjCMethodDecl *MethodWithObjects);
2636  ReturnValueSlot Return = ReturnValueSlot());
2637 
2638  /// Retrieves the default cleanup kind for an ARC cleanup.
2639  /// Except under -fobjc-arc-eh, ARC cleanups are normal-only.
2641  return CGM.getCodeGenOpts().ObjCAutoRefCountExceptions
2643  }
2644 
2645  // ARC primitives.
2646  void EmitARCInitWeak(llvm::Value *value, llvm::Value *addr);
2647  void EmitARCDestroyWeak(llvm::Value *addr);
2651  bool ignored);
2652  void EmitARCCopyWeak(llvm::Value *dst, llvm::Value *src);
2653  void EmitARCMoveWeak(llvm::Value *dst, llvm::Value *src);
2657  bool resultIgnored);
2659  bool resultIgnored);
2662  llvm::Value *EmitARCRetainBlock(llvm::Value *value, bool mandatory);
2664  void EmitARCRelease(llvm::Value *value, ARCPreciseLifetime_t precise);
2669 
2670  std::pair<LValue,llvm::Value*>
2672  std::pair<LValue,llvm::Value*>
2673  EmitARCStoreStrong(const BinaryOperator *e, bool ignored);
2674 
2676 
2680 
2684 
2686 
2690 
2696 
2697  /// \brief Emits a reference binding to the passed in expression.
2699 
2700  //===--------------------------------------------------------------------===//
2701  // Expression Emission
2702  //===--------------------------------------------------------------------===//
2703 
2704  // Expressions are broken into three classes: scalar, complex, aggregate.
2705 
2706  /// EmitScalarExpr - Emit the computation of the specified expression of LLVM
2707  /// scalar type, returning the result.
2708  llvm::Value *EmitScalarExpr(const Expr *E , bool IgnoreResultAssign = false);
2709 
2710  /// EmitScalarConversion - Emit a conversion from the specified type to the
2711  /// specified destination type, both of which are LLVM scalar types.
2713  QualType DstTy);
2714 
2715  /// EmitComplexToScalarConversion - Emit a conversion from the specified
2716  /// complex type to the specified destination type, where the destination type
2717  /// is an LLVM scalar type.
2719  QualType DstTy);
2720 
2721 
2722  /// EmitAggExpr - Emit the computation of the specified expression
2723  /// of aggregate type. The result is computed into the given slot,
2724  /// which may be null to indicate that the value is not needed.
2725  void EmitAggExpr(const Expr *E, AggValueSlot AS);
2726 
2727  /// EmitAggExprToLValue - Emit the computation of the specified expression of
2728  /// aggregate type into a temporary LValue.
2729  LValue EmitAggExprToLValue(const Expr *E);
2730 
2731  /// EmitGCMemmoveCollectable - Emit special API for structs with object
2732  /// pointers.
2733  void EmitGCMemmoveCollectable(llvm::Value *DestPtr, llvm::Value *SrcPtr,
2734  QualType Ty);
2735 
2736  /// EmitExtendGCLifetime - Given a pointer to an Objective-C object,
2737  /// make sure it survives garbage collection until this point.
2738  void EmitExtendGCLifetime(llvm::Value *object);
2739 
2740  /// EmitComplexExpr - Emit the computation of the specified expression of
2741  /// complex type, returning the result.
2743  bool IgnoreReal = false,
2744  bool IgnoreImag = false);
2745 
2746  /// EmitComplexExprIntoLValue - Emit the given expression of complex
2747  /// type and place its result into the specified l-value.
2748  void EmitComplexExprIntoLValue(const Expr *E, LValue dest, bool isInit);
2749 
2750  /// EmitStoreOfComplex - Store a complex number into the specified l-value.
2751  void EmitStoreOfComplex(ComplexPairTy V, LValue dest, bool isInit);
2752 
2753  /// EmitLoadOfComplex - Load a complex number from the specified l-value.
2755 
2756  /// AddInitializerToStaticVarDecl - Add the initializer for 'D' to the
2757  /// global variable that has already been created for it. If the initializer
2758  /// has a different type than GV does, this may free GV and return a different
2759  /// one. Otherwise it just returns GV.
2760  llvm::GlobalVariable *
2762  llvm::GlobalVariable *GV);
2763 
2764 
2765  /// EmitCXXGlobalVarDeclInit - Create the initializer for a C++
2766  /// variable with global storage.
2767  void EmitCXXGlobalVarDeclInit(const VarDecl &D, llvm::Constant *DeclPtr,
2768  bool PerformInit);
2769 
2770  llvm::Constant *createAtExitStub(const VarDecl &VD, llvm::Constant *Dtor,
2771  llvm::Constant *Addr);
2772 
2773  /// Call atexit() with a function that passes the given argument to
2774  /// the given function.
2775  void registerGlobalDtorWithAtExit(const VarDecl &D, llvm::Constant *fn,
2776  llvm::Constant *addr);
2777 
2778  /// Emit code in this function to perform a guarded variable
2779  /// initialization. Guarded initializations are used when it's not
2780  /// possible to prove that an initialization will be done exactly
2781  /// once, e.g. with a static local variable or a static data member
2782  /// of a class template.
2783  void EmitCXXGuardedInit(const VarDecl &D, llvm::GlobalVariable *DeclPtr,
2784  bool PerformInit);
2785 
2786  /// GenerateCXXGlobalInitFunc - Generates code for initializing global
2787  /// variables.
2788  void GenerateCXXGlobalInitFunc(llvm::Function *Fn,
2789  ArrayRef<llvm::Function *> CXXThreadLocals,
2790  llvm::GlobalVariable *Guard = nullptr);
2791 
2792  /// GenerateCXXGlobalDtorsFunc - Generates code for destroying global
2793  /// variables.
2794  void GenerateCXXGlobalDtorsFunc(llvm::Function *Fn,
2795  const std::vector<std::pair<llvm::WeakVH,
2796  llvm::Constant*> > &DtorsAndObjects);
2797 
2798  void GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn,
2799  const VarDecl *D,
2800  llvm::GlobalVariable *Addr,
2801  bool PerformInit);
2802 
2803  void EmitCXXConstructExpr(const CXXConstructExpr *E, AggValueSlot Dest);
2804 
2806  const Expr *Exp);
2807 
2809  if (E->getNumObjects() == 0) return;
2811  }
2813 
2814  void EmitCXXThrowExpr(const CXXThrowExpr *E, bool KeepInsertionPoint = true);
2815 
2816  void EmitLambdaExpr(const LambdaExpr *E, AggValueSlot Dest);
2817 
2818  RValue EmitAtomicExpr(AtomicExpr *E, llvm::Value *Dest = nullptr);
2819 
2820  //===--------------------------------------------------------------------===//
2821  // Annotations Emission
2822  //===--------------------------------------------------------------------===//
2823 
2824  /// Emit an annotation call (intrinsic or builtin).
2826  llvm::Value *AnnotatedVal,
2827  StringRef AnnotationStr,
2828  SourceLocation Location);
2829 
2830  /// Emit local annotations for the local variable V, declared by D.
2831  void EmitVarAnnotations(const VarDecl *D, llvm::Value *V);
2832 
2833  /// Emit field annotations for the given field & value. Returns the
2834  /// annotation result.
2836 
2837  //===--------------------------------------------------------------------===//
2838  // Internal Helpers
2839  //===--------------------------------------------------------------------===//
2840 
2841  /// ContainsLabel - Return true if the statement contains a label in it. If
2842  /// this statement is not executed normally, it not containing a label means
2843  /// that we can just remove the code.
2844  static bool ContainsLabel(const Stmt *S, bool IgnoreCaseStmts = false);
2845 
2846  /// containsBreak - Return true if the statement contains a break out of it.
2847  /// If the statement (recursively) contains a switch or loop with a break
2848  /// inside of it, this is fine.
2849  static bool containsBreak(const Stmt *S);
2850 
2851  /// ConstantFoldsToSimpleInteger - If the specified expression does not fold
2852  /// to a constant, or if it does but contains a label, return false. If it
2853  /// constant folds return true and set the boolean result in Result.
2854  bool ConstantFoldsToSimpleInteger(const Expr *Cond, bool &Result);
2855 
2856  /// ConstantFoldsToSimpleInteger - If the specified expression does not fold
2857  /// to a constant, or if it does but contains a label, return false. If it
2858  /// constant folds return true and set the folded value.
2859  bool ConstantFoldsToSimpleInteger(const Expr *Cond, llvm::APSInt &Result);
2860 
2861  /// EmitBranchOnBoolExpr - Emit a branch on a boolean condition (e.g. for an
2862  /// if statement) to the specified blocks. Based on the condition, this might
2863  /// try to simplify the codegen of the conditional based on the branch.
2864  /// TrueCount should be the number of times we expect the condition to
2865  /// evaluate to true based on PGO data.
2866  void EmitBranchOnBoolExpr(const Expr *Cond, llvm::BasicBlock *TrueBlock,
2867  llvm::BasicBlock *FalseBlock, uint64_t TrueCount);
2868 
2869  /// \brief Emit a description of a type in a format suitable for passing to
2870  /// a runtime sanitizer handler.
2871  llvm::Constant *EmitCheckTypeDescriptor(QualType T);
2872 
2873  /// \brief Convert a value into a format suitable for passing to a runtime
2874  /// sanitizer handler.
2876 
2877  /// \brief Emit a description of a source location in a format suitable for
2878  /// passing to a runtime sanitizer handler.
2879  llvm::Constant *EmitCheckSourceLocation(SourceLocation Loc);
2880 
2881  /// \brief Create a basic block that will call a handler function in a
2882  /// sanitizer runtime with the provided arguments, and create a conditional
2883  /// branch to it.
2884  void EmitCheck(ArrayRef<std::pair<llvm::Value *, SanitizerMask>> Checked,
2885  StringRef CheckName, ArrayRef<llvm::Constant *> StaticArgs,
2886  ArrayRef<llvm::Value *> DynamicArgs);
2887 
2888  /// \brief Create a basic block that will call the trap intrinsic, and emit a
2889  /// conditional branch to it, for the -ftrapv checks.
2890  void EmitTrapCheck(llvm::Value *Checked);
2891 
2892  /// \brief Emit a call to trap or debugtrap and attach function attribute
2893  /// "trap-func-name" if specified.
2894  llvm::CallInst *EmitTrapCall(llvm::Intrinsic::ID IntrID);
2895 
2896  /// \brief Create a check for a function parameter that may potentially be
2897  /// declared as non-null.
2898  void EmitNonNullArgCheck(RValue RV, QualType ArgType, SourceLocation ArgLoc,
2899  const FunctionDecl *FD, unsigned ParmNum);
2900 
2901  /// EmitCallArg - Emit a single call argument.
2902  void EmitCallArg(CallArgList &args, const Expr *E, QualType ArgType);
2903 
2904  /// EmitDelegateCallArg - We are performing a delegate call; that
2905  /// is, the current function is delegating to another one. Produce
2906  /// a r-value suitable for passing the given parameter.
2907  void EmitDelegateCallArg(CallArgList &args, const VarDecl *param,
2908  SourceLocation loc);
2909 
2910  /// SetFPAccuracy - Set the minimum required accuracy of the given floating
2911  /// point operation, expressed as the maximum relative error in ulp.
2912  void SetFPAccuracy(llvm::Value *Val, float Accuracy);
2913 
2914 private:
2915  llvm::MDNode *getRangeForLoadFromType(QualType Ty);
2916  void EmitReturnOfRValue(RValue RV, QualType Ty);
2917 
2918  void deferPlaceholderReplacement(llvm::Instruction *Old, llvm::Value *New);
2919 
2921  DeferredReplacements;
2922 
2923  /// ExpandTypeFromArgs - Reconstruct a structure of type \arg Ty
2924  /// from function arguments into \arg Dst. See ABIArgInfo::Expand.
2925  ///
2926  /// \param AI - The first function argument of the expansion.
2927  void ExpandTypeFromArgs(QualType Ty, LValue Dst,
2929 
2930  /// ExpandTypeToArgs - Expand an RValue \arg RV, with the LLVM type for \arg
2931  /// Ty, into individual arguments on the provided vector \arg IRCallArgs,
2932  /// starting at index \arg IRCallArgPos. See ABIArgInfo::Expand.
2933  void ExpandTypeToArgs(QualType Ty, RValue RV, llvm::FunctionType *IRFuncTy,
2934  SmallVectorImpl<llvm::Value *> &IRCallArgs,
2935  unsigned &IRCallArgPos);
2936 
2937  llvm::Value* EmitAsmInput(const TargetInfo::ConstraintInfo &Info,
2938  const Expr *InputExpr, std::string &ConstraintStr);
2939 
2940  llvm::Value* EmitAsmInputLValue(const TargetInfo::ConstraintInfo &Info,
2941  LValue InputValue, QualType InputType,
2942  std::string &ConstraintStr,
2943  SourceLocation Loc);
2944 
2945 public:
2946 #ifndef NDEBUG
2947  // Determine whether the given argument is an Objective-C method
2948  // that may have type parameters in its signature.
2949  static bool isObjCMethodWithTypeParams(const ObjCMethodDecl *method) {
2950  const DeclContext *dc = method->getDeclContext();
2951  if (const ObjCInterfaceDecl *classDecl= dyn_cast<ObjCInterfaceDecl>(dc)) {
2952  return classDecl->getTypeParamListAsWritten();
2953  }
2954 
2955  if (const ObjCCategoryDecl *catDecl = dyn_cast<ObjCCategoryDecl>(dc)) {
2956  return catDecl->getTypeParamList();
2957  }
2958 
2959  return false;
2960  }
2961 
2962  template<typename T>
2963  static bool isObjCMethodWithTypeParams(const T *) { return false; }
2964 #endif
2965 
2966  /// EmitCallArgs - Emit call arguments for a function.
2967  template <typename T>
2968  void EmitCallArgs(CallArgList &Args, const T *CallArgTypeInfo,
2971  const FunctionDecl *CalleeDecl = nullptr,
2972  unsigned ParamsToSkip = 0) {
2973  SmallVector<QualType, 16> ArgTypes;
2974  CallExpr::const_arg_iterator Arg = ArgBeg;
2975 
2976  assert((ParamsToSkip == 0 || CallArgTypeInfo) &&
2977  "Can't skip parameters if type info is not provided");
2978  if (CallArgTypeInfo) {
2979 #ifndef NDEBUG
2980  bool isGenericMethod = isObjCMethodWithTypeParams(CallArgTypeInfo);
2981 #endif
2982 
2983  // First, use the argument types that the type info knows about
2984  for (auto I = CallArgTypeInfo->param_type_begin() + ParamsToSkip,
2985  E = CallArgTypeInfo->param_type_end();
2986  I != E; ++I, ++Arg) {
2987  assert(Arg != ArgEnd && "Running over edge of argument list!");
2988  assert((isGenericMethod ||
2989  ((*I)->isVariablyModifiedType() ||
2990  (*I).getNonReferenceType()->isObjCRetainableType() ||
2991  getContext()
2992  .getCanonicalType((*I).getNonReferenceType())
2993  .getTypePtr() ==
2994  getContext()
2995  .getCanonicalType(Arg->getType())
2996  .getTypePtr())) &&
2997  "type mismatch in call argument!");
2998  ArgTypes.push_back(*I);
2999  }
3000  }
3001 
3002  // Either we've emitted all the call args, or we have a call to variadic
3003  // function.
3004  assert(
3005  (Arg == ArgEnd || !CallArgTypeInfo || CallArgTypeInfo->isVariadic()) &&
3006  "Extra arguments in non-variadic function!");
3007 
3008  // If we still have any arguments, emit them using the type of the argument.
3009  for (; Arg != ArgEnd; ++Arg)
3010  ArgTypes.push_back(getVarArgType(*Arg));
3011 
3012  EmitCallArgs(Args, ArgTypes, ArgBeg, ArgEnd, CalleeDecl, ParamsToSkip);
3013  }
3014 
3015  void EmitCallArgs(CallArgList &Args, ArrayRef<QualType> ArgTypes,
3018  const FunctionDecl *CalleeDecl = nullptr,
3019  unsigned ParamsToSkip = 0);
3020 
3021 private:
3022  QualType getVarArgType(const Expr *Arg);
3023 
3024  const TargetCodeGenInfo &getTargetHooks() const {
3025  return CGM.getTargetCodeGenInfo();
3026  }
3027 
3028  void EmitDeclMetadata();
3029 
3030  CodeGenModule::ByrefHelpers *
3031  buildByrefHelpers(llvm::StructType &byrefType,
3032  const AutoVarEmission &emission);
3033 
3034  void AddObjCARCExceptionMetadata(llvm::Instruction *Inst);
3035 
3036  /// GetPointeeAlignment - Given an expression with a pointer type, emit the
3037  /// value and compute our best estimate of the alignment of the pointee.
3038  std::pair<llvm::Value*, unsigned> EmitPointerWithAlignment(const Expr *Addr);
3039 
3040  llvm::Value *GetValueForARMHint(unsigned BuiltinID);
3041 };
3042 
3043 /// Helper class with most of the code for saving a value for a
3044 /// conditional expression cleanup.
3046  typedef llvm::PointerIntPair<llvm::Value*, 1, bool> saved_type;
3047 
3048  /// Answer whether the given value needs extra work to be saved.
3049  static bool needsSaving(llvm::Value *value) {
3050  // If it's not an instruction, we don't need to save.
3051  if (!isa<llvm::Instruction>(value)) return false;
3052 
3053  // If it's an instruction in the entry block, we don't need to save.
3054  llvm::BasicBlock *block = cast<llvm::Instruction>(value)->getParent();
3055  return (block != &block->getParent()->getEntryBlock());
3056  }
3057 
3058  /// Try to save the given value.
3060  if (!needsSaving(value)) return saved_type(value, false);
3061 
3062  // Otherwise we need an alloca.
3063  llvm::Value *alloca =
3064  CGF.CreateTempAlloca(value->getType(), "cond-cleanup.save");
3065  CGF.Builder.CreateStore(value, alloca);
3066 
3067  return saved_type(alloca, true);
3068  }
3069 
3071  if (!value.getInt()) return value.getPointer();
3072  return CGF.Builder.CreateLoad(value.getPointer());
3073  }
3074 };
3075 
3076 /// A partial specialization of DominatingValue for llvm::Values that
3077 /// might be llvm::Instructions.
3078 template <class T> struct DominatingPointer<T,true> : DominatingLLVMValue {
3079  typedef T *type;
3080  static type restore(CodeGenFunction &CGF, saved_type value) {
3081  return static_cast<T*>(DominatingLLVMValue::restore(CGF, value));
3082  }
3083 };
3084 
3085 /// A specialization of DominatingValue for RValue.
3086 template <> struct DominatingValue<RValue> {
3087  typedef RValue type;
3088  class saved_type {
3089  enum Kind { ScalarLiteral, ScalarAddress, AggregateLiteral,
3090  AggregateAddress, ComplexAddress };
3091 
3092  llvm::Value *Value;
3093  Kind K;
3094  saved_type(llvm::Value *v, Kind k) : Value(v), K(k) {}
3095 
3096  public:
3097  static bool needsSaving(RValue value);
3098  static saved_type save(CodeGenFunction &CGF, RValue value);
3099  RValue restore(CodeGenFunction &CGF);
3100 
3101  // implementations in CGExprCXX.cpp
3102  };
3103 
3104  static bool needsSaving(type value) {
3105  return saved_type::needsSaving(value);
3106  }
3107  static saved_type save(CodeGenFunction &CGF, type value) {
3108  return saved_type::save(CGF, value);
3109  }
3110  static type restore(CodeGenFunction &CGF, saved_type value) {
3111  return value.restore(CGF);
3112  }
3113 };
3114 
3115 } // end namespace CodeGen
3116 } // end namespace clang
3117 
3118 #endif
void enterNonTrivialFullExpression(const ExprWithCleanups *E)
Definition: CGBlocks.cpp:647
A call to an overloaded operator written using operator syntax.
Definition: ExprCXX.h:54
void EmitInitializerForField(FieldDecl *Field, LValue LHS, Expr *Init, ArrayRef< VarDecl * > ArrayIndexes)
Definition: CGClass.cpp:629
void EnterDtorCleanups(const CXXDestructorDecl *Dtor, CXXDtorType Type)
Emit all code that comes at the end of class's destructor. This is to call destructors on members and...
Definition: CGClass.cpp:1564
void EmitIndirectGotoStmt(const IndirectGotoStmt &S)
Definition: CGStmt.cpp:499
This represents '#pragma omp master' directive.
Definition: StmtOpenMP.h:989
SourceLocation getEnd() const
llvm::Value * GetAddrOfBlockDecl(const VarDecl *var, bool ByRef)
Definition: CGBlocks.cpp:1001
virtual void EmitBody(CodeGenFunction &CGF, const Stmt *S)
Emit the captured statement body.
This represents '#pragma omp task' directive.
Definition: StmtOpenMP.h:1295
llvm::Constant * GenerateCopyHelperFunction(const CGBlockInfo &blockInfo)
Definition: CGBlocks.cpp:1301
llvm::Value * EmitARCStoreStrong(LValue lvalue, llvm::Value *value, bool resultIgnored)
Definition: CGObjC.cpp:2096
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
Definition: ASTMatchers.h:1110
void ActivateCleanupBlock(EHScopeStack::stable_iterator Cleanup, llvm::Instruction *DominatingIP)
Activate a cleanup that was created in an inactivated state.
Definition: CGCleanup.cpp:1123
void EmitOMPTaskwaitDirective(const OMPTaskwaitDirective &S)
llvm::Value * EmitAArch64CompareBuiltinExpr(llvm::Value *Op, llvm::Type *Ty, const llvm::CmpInst::Predicate Fp, const llvm::CmpInst::Predicate Ip, const llvm::Twine &Name="")
Definition: CGBuiltin.cpp:3194
void EmitGCMemmoveCollectable(llvm::Value *DestPtr, llvm::Value *SrcPtr, QualType Ty)
void EmitDelegateCXXConstructorCall(const CXXConstructorDecl *Ctor, CXXCtorType CtorType, const FunctionArgList &Args, SourceLocation Loc)
Definition: CGClass.cpp:1864
LValue EmitComplexCompoundAssignmentLValue(const CompoundAssignOperator *E)
void EmitStaticVarDecl(const VarDecl &D, llvm::GlobalValue::LinkageTypes Linkage)
Definition: CGDecl.cpp:340
llvm::Value * EmitARCRetainAutoreleaseScalarExpr(const Expr *expr)
Definition: CGObjC.cpp:2747
void EmitARCMoveWeak(llvm::Value *dst, llvm::Value *src)
Definition: CGObjC.cpp:2249
Destroyer * getDestroyer(QualType::DestructionKind destructionKind)
Definition: CGDecl.cpp:1356
void EmitVTablePtrCheckForCall(const CXXMethodDecl *MD, llvm::Value *VTable, CFITypeCheckKind TCK, SourceLocation Loc)
Definition: CGClass.cpp:2165
void EmitSEHLeaveStmt(const SEHLeaveStmt &S)
void GenerateCapturedStmtFunctionProlog(const CapturedStmt &S)
void EmitExtendGCLifetime(llvm::Value *object)
Definition: CGObjC.cpp:2867
void EmitCtorPrologue(const CXXConstructorDecl *CD, CXXCtorType Type, FunctionArgList &Args)
Definition: CGClass.cpp:1236
void EmitOMPReductionClauseFinal(const OMPExecutableDirective &D)
Emit final update of reduction values to original variables at the end of the directive.
llvm::Type * ConvertTypeForMem(QualType T)
void EmitBranchOnBoolExpr(const Expr *Cond, llvm::BasicBlock *TrueBlock, llvm::BasicBlock *FalseBlock, uint64_t TrueCount)
void EmitAnyExprToExn(const Expr *E, llvm::Value *Addr)
void EmitVarDecl(const VarDecl &D)
Definition: CGDecl.cpp:129
llvm::Value * EmitARCExtendBlockObject(const Expr *expr)
Definition: CGObjC.cpp:2764
void EmitGotoStmt(const GotoStmt &S)
Definition: CGStmt.cpp:488
LValue EmitStmtExprLValue(const StmtExpr *E)
Definition: CGExpr.cpp:3349
void EmitAttributedStmt(const AttributedStmt &S)
Definition: CGStmt.cpp:468
llvm::Constant * EmitCheckTypeDescriptor(QualType T)
Emit a description of a type in a format suitable for passing to a runtime sanitizer handler...
Definition: CGExpr.cpp:2135
void InitializeVTablePointers(BaseSubobject Base, const CXXRecordDecl *NearestVBase, CharUnits OffsetFromNearestVBase, bool BaseIsNonVirtualPrimaryBase, const CXXRecordDecl *VTableClass, VisitedVirtualBasesSetTy &VBases)
Definition: CGClass.cpp:2049
llvm::Value * EmitNVPTXBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition: CGBuiltin.cpp:7082
llvm::LLVMContext & getLLVMContext()
void EmitFunctionInstrumentation(const char *Fn)
LValue EmitObjCIsaExpr(const ObjCIsaExpr *E)
LValue EmitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *E)
Definition: CGExpr.cpp:335
void EmitCXXTryStmt(const CXXTryStmt &S)
const TargetInfo & getTarget() const
void EmitStoreThroughGlobalRegLValue(RValue Src, LValue Dst)
Store of global named registers are always calls to intrinsics.
Definition: CGExpr.cpp:1706
llvm::Value * EmitARCLoadWeak(llvm::Value *addr)
Definition: CGObjC.cpp:2187
void EmitNonNullArgCheck(RValue RV, QualType ArgType, SourceLocation ArgLoc, const FunctionDecl *FD, unsigned ParmNum)
Create a check for a function parameter that may potentially be declared as non-null.
Definition: CGCall.cpp:2783
llvm::AllocaInst * CreateTempAlloca(llvm::Type *Ty, const Twine &Name="tmp")
Definition: CGExpr.cpp:57
OpaqueValueMapping(CodeGenFunction &CGF, const AbstractConditionalOperator *op)
This represents '#pragma omp for simd' directive.
Definition: StmtOpenMP.h:765
Checking the 'this' pointer for a constructor call.
void emitAutoVarTypeCleanup(const AutoVarEmission &emission, QualType::DestructionKind dtorKind)
Enter a destroy cleanup for the given local variable.
Definition: CGDecl.cpp:1249
RValue EmitPseudoObjectRValue(const PseudoObjectExpr *e, AggValueSlot slot=AggValueSlot::ignored())
Definition: CGExpr.cpp:3570
void EmitOMPCopy(CodeGenFunction &CGF, QualType OriginalType, llvm::Value *DestAddr, llvm::Value *SrcAddr, const VarDecl *DestVD, const VarDecl *SrcVD, const Expr *Copy)
Emit proper copying of data from one variable to another.
llvm::Value * LoadCXXStructorImplicitParam()
const Decl * CurCodeDecl
CurCodeDecl - This is the inner-most code context, which includes blocks.
static saved_type save(CodeGenFunction &CGF, llvm::Value *value)
Try to save the given value.
static bool classof(const CGCapturedStmtInfo *)
Represents an attribute applied to a statement.
Definition: Stmt.h:833
llvm::Value * EmitCompoundStmt(const CompoundStmt &S, bool GetLast=false, AggValueSlot AVS=AggValueSlot::ignored())
Definition: CGStmt.cpp:275
void EmitAutoVarDecl(const VarDecl &D)
Definition: CGDecl.cpp:847
const llvm::DataLayout & getDataLayout() const
void EmitOMPOrderedDirective(const OMPOrderedDirective &S)
static Destroyer destroyARCStrongPrecise
LValue EmitBinaryOperatorLValue(const BinaryOperator *E)
Definition: CGExpr.cpp:3188
Represents Objective-C's @throw statement.
Definition: StmtObjC.h:313
void EmitStoreThroughLValue(RValue Src, LValue Dst, bool isInit=false)
Definition: CGExpr.cpp:1469
void EmitComplexExprIntoLValue(const Expr *E, LValue dest, bool isInit)
bool typeIsSuitableForInlineAtomic(QualType Ty, bool IsVolatile) const
Definition: CGAtomic.cpp:1204
CGCapturedStmtInfo(const CapturedStmt &S, CapturedRegionKind K=CR_Default)
LValue EmitOpaqueValueLValue(const OpaqueValueExpr *e)
Definition: CGExpr.cpp:3082
void GenerateObjCSetter(ObjCImplementationDecl *IMP, const ObjCPropertyImplDecl *PID)
Generate an Objective-C property setter function.
Definition: CGObjC.cpp:1292
void EmitSEHExceptionCodeSave(CodeGenFunction &ParentCGF, llvm::Value *ParentFP, llvm::Value *EntryEBP)
void GenerateCode(GlobalDecl GD, llvm::Function *Fn, const CGFunctionInfo &FnInfo)
void SpecialInitFn(CodeGenFunction &Init, const VarDecl &D, llvm::Value *Address)
bool sanitizePerformTypeCheck() const
Whether any type-checking sanitizers are enabled. If false, calls to EmitTypeCheck can be skipped...
Definition: CGExpr.cpp:482
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1075
RValue EmitCXXMemberCallExpr(const CXXMemberCallExpr *E, ReturnValueSlot ReturnValue)
Definition: CGExprCXX.cpp:106
bool addPrivate(const VarDecl *LocalVD, const std::function< llvm::Value *()> &PrivateGen)
Registers LocalVD variable as a private and apply PrivateGen function for it to generate correspondin...
DominatingValue< T >::saved_type saveValueInCond(T value)
CGCapturedStmtInfo(CapturedRegionKind K=CR_Default)
llvm::Value * EmitObjCMRRAutoreleasePoolPush()
Definition: CGObjC.cpp:2301
llvm::Function * GenerateVarArgsThunk(llvm::Function *Fn, const CGFunctionInfo &FnInfo, GlobalDecl GD, const ThunkInfo &Thunk)
Definition: CGVTables.cpp:142
llvm::Constant * GenerateObjCAtomicSetterCopyHelperFunction(const ObjCPropertyImplDecl *PID)
Definition: CGObjC.cpp:2886
This represents '#pragma omp parallel for' directive.
Definition: StmtOpenMP.h:1102
const LangOptions & getLangOpts() const
LValue EmitLValueForFieldInitialization(LValue Base, const FieldDecl *Field)
Definition: CGExpr.cpp:2794
llvm::Value * EmitARCRetainNonBlock(llvm::Value *value)
Definition: CGObjC.cpp:1933
void EmitCXXDestructorCall(const CXXDestructorDecl *D, CXXDtorType Type, bool ForVirtualBase, bool Delegating, llvm::Value *This)
Definition: CGClass.cpp:1950
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2147
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
Definition: ExprCXX.h:3746
static bool needsSaving(llvm::Value *value)
Answer whether the given value needs extra work to be saved.
static type restore(CodeGenFunction &CGF, saved_type value)
void EmitAtomicStore(RValue rvalue, LValue lvalue, bool isInit)
Definition: CGAtomic.cpp:1640
void EmitOMPAggregateAssign(llvm::Value *DestAddr, llvm::Value *SrcAddr, QualType OriginalType, const llvm::function_ref< void(llvm::Value *, llvm::Value *)> &CopyGen)
Perform element by element copying of arrays with type OriginalType from SrcAddr to DestAddr using co...
static OpaqueValueMappingData bind(CodeGenFunction &CGF, const OpaqueValueExpr *ov, const RValue &rv)
llvm::Value * EmitCommonNeonBuiltinExpr(unsigned BuiltinID, unsigned LLVMIntrinsic, unsigned AltLLVMIntrinsic, const char *NameHint, unsigned Modifier, const CallExpr *E, SmallVectorImpl< llvm::Value * > &Ops, llvm::Value *Align=nullptr)
Definition: CGBuiltin.cpp:2744
LValue EmitCXXUuidofLValue(const CXXUuidofExpr *E)
Definition: CGExpr.cpp:3272
const CXXBaseSpecifier *const * path_const_iterator
Definition: Expr.h:2726
void EmitOMPParallelForSimdDirective(const OMPParallelForSimdDirective &S)
void pushIrregularPartialArrayCleanup(llvm::Value *arrayBegin, llvm::Value *arrayEndPointer, QualType elementType, Destroyer *destroyer)
Definition: CGDecl.cpp:1598
static saved_type save(CodeGenFunction &CGF, type value)
Definition: EHScopeStack.h:60
void EmitOMPCriticalDirective(const OMPCriticalDirective &S)
LValue EmitObjCEncodeExprLValue(const ObjCEncodeExpr *E)
Definition: CGExpr.cpp:2104
RAII object to set/unset CodeGenFunction::IsSanitizerScope.
LValue EmitObjCSelectorLValue(const ObjCSelectorExpr *E)
Definition: CGExpr.cpp:3305
uint64_t getProfileCount(const Stmt *S)
Get the profiler's count for the given statement.
llvm::Value * EmitObjCAutoreleasePoolPush()
Definition: CGObjC.cpp:2266
field_iterator field_begin() const
Definition: Decl.cpp:3629
llvm::Value * GetVTTParameter(GlobalDecl GD, bool ForVirtualBase, bool Delegating)
Definition: CGClass.cpp:297
llvm::Value * EmitBlockCopyAndAutorelease(llvm::Value *Block, QualType Ty)
Definition: CGObjC.cpp:3061
void EmitLabel(const LabelDecl *D)
Definition: CGStmt.cpp:413
llvm::CallInst * EmitTrapCall(llvm::Intrinsic::ID IntrID)
Emit a call to trap or debugtrap and attach function attribute "trap-func-name" if specified...
Definition: CGExpr.cpp:2418
void EmitVariablyModifiedType(QualType Ty)
LValue EmitComplexAssignmentLValue(const BinaryOperator *E)
Emit an l-value for an assignment (simple or compound) of complex type.
void setCurrentProfileCount(uint64_t Count)
Set the profiler's current count.
void pushFullExprCleanup(CleanupKind kind, As...A)
static ConstantEmission forValue(llvm::Constant *C)
bool IsSanitizerScope
True if CodeGen currently emits code implementing sanitizer checks.
llvm::BasicBlock * EmitLandingPad()
Emits a landing pad for the current EH stack.
void pushCleanupTuple(CleanupKind Kind, std::tuple< As...> A)
Push a lazily-created cleanup on the stack. Tuple version.
Definition: EHScopeStack.h:269
capture_iterator capture_begin()
Retrieve an iterator pointing to the first capture.
Definition: Stmt.h:2151
RValue EmitCUDAKernelCallExpr(const CUDAKernelCallExpr *E, ReturnValueSlot ReturnValue)
Definition: CGExprCXX.cpp:345
A C++ throw-expression (C++ [except.throw]).
Definition: ExprCXX.h:808
llvm::Value * EmitARMBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition: CGBuiltin.cpp:3380
void EmitAggregateCopyCtor(llvm::Value *DestPtr, llvm::Value *SrcPtr, QualType DestTy, QualType SrcTy)
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have...
Definition: Linkage.h:25
Defines the clang::Expr interface and subclasses for C++ expressions.
static void destroyBlockInfos(CGBlockInfo *info)
Destroy a chain of block layouts.
Definition: CGBlocks.cpp:674
void SimplifyForwardingBlocks(llvm::BasicBlock *BB)
Definition: CGStmt.cpp:326
void emitImplicitAssignmentOperatorBody(FunctionArgList &Args)
Definition: CGClass.cpp:1482
llvm::Value * EmitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E)
Definition: CGObjC.cpp:231
void EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst, llvm::Value **Result=nullptr)
Definition: CGExpr.cpp:1560
EHScopeStack::stable_iterator PrologueCleanupDepth
llvm::Value * getNormalCleanupDestSlot()
Definition: CGCleanup.cpp:1157
llvm::Value * EmitObjCThrowOperand(const Expr *expr)
Definition: CGObjC.cpp:2782
JumpDest getJumpDestForLabel(const LabelDecl *S)
Definition: CGStmt.cpp:402
void EmitBoundsCheck(const Expr *E, const Expr *Base, llvm::Value *Index, QualType IndexType, bool Accessed)
Emit a check that Base points into an array object, which we can access at index Index. Accessed should be false if we this expression is used as an lvalue, for instance in "&Arr[Idx]".
Definition: CGExpr.cpp:700
llvm::DenseMap< const VarDecl *, FieldDecl * > LambdaCaptureFields
An object to manage conditionally-evaluated expressions.
PeepholeProtection protectFromPeepholes(RValue rvalue)
llvm::BasicBlock * getTerminateHandler()
void EmitCXXForRangeStmt(const CXXForRangeStmt &S, ArrayRef< const Attr * > Attrs=None)
Definition: CGStmt.cpp:936
void EmitOMPSimdDirective(const OMPSimdDirective &S)
llvm::Value * EmitCXXNewExpr(const CXXNewExpr *E)
Definition: CGExprCXX.cpp:1258
llvm::Value * EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV, bool isInc, bool isPre)
void emitByrefStructureInit(const AutoVarEmission &emission)
Definition: CGBlocks.cpp:2127
CGBlockInfo * FirstBlockInfo
FirstBlockInfo - The head of a singly-linked-list of block layouts.
LValue EmitScalarCompoundAssignWithComplex(const CompoundAssignOperator *E, llvm::Value *&Result)
void EmitCallArgs(CallArgList &Args, const T *CallArgTypeInfo, CallExpr::const_arg_iterator ArgBeg, CallExpr::const_arg_iterator ArgEnd, const FunctionDecl *CalleeDecl=nullptr, unsigned ParamsToSkip=0)
EmitCallArgs - Emit call arguments for a function.
void setScopeDepth(EHScopeStack::stable_iterator depth)
void EmitFunctionEpilog(const CGFunctionInfo &FI, bool EmitRetDbgLoc, SourceLocation EndLoc)
Definition: CGCall.cpp:2333
This represents '#pragma omp parallel' directive.
Definition: StmtOpenMP.h:219
LValue EmitObjCIvarRefLValue(const ObjCIvarRefExpr *E)
Definition: CGExpr.cpp:3324
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:89
LValue EmitLValueForLambdaField(const FieldDecl *Field)
Definition: CGExpr.cpp:2671
void EmitExprAsInit(const Expr *init, const ValueDecl *D, LValue lvalue, bool capturedByInit)
Definition: CGDecl.cpp:1211
std::pair< LValue, llvm::Value * > EmitARCStoreAutoreleasing(const BinaryOperator *e)
Definition: CGObjC.cpp:2830
llvm::Value * EmitObjCExtendObjectLifetime(QualType T, llvm::Value *Ptr)
Definition: CGObjC.cpp:1767
RValue EmitReferenceBindingToExpr(const Expr *E)
Emits a reference binding to the passed in expression.
Definition: CGExpr.cpp:442
llvm::SmallPtrSet< const CXXRecordDecl *, 4 > VisitedVirtualBasesSetTy
The scope used to remap some variables as private in the OpenMP loop body (or other captured region e...
LValue EmitCXXBindTemporaryLValue(const CXXBindTemporaryExpr *E)
Definition: CGExpr.cpp:3277
llvm::Value * EmitARCRetainAutoreleaseReturnValue(llvm::Value *value)
Definition: CGObjC.cpp:2150
An RAII object to set (and then clear) a mapping for an OpaqueValueExpr.
void EmitNewArrayInitializer(const CXXNewExpr *E, QualType elementType, llvm::Type *ElementTy, llvm::Value *NewPtr, llvm::Value *NumElements, llvm::Value *AllocSizeWithoutCookie)
Definition: CGExprCXX.cpp:788
llvm::CallInst * EmitRuntimeCall(llvm::Value *callee, const Twine &name="")
llvm::Value * EmitObjCProduceObject(QualType T, llvm::Value *Ptr)
Definition: CGObjC.cpp:1740
void EmitARCInitWeak(llvm::Value *value, llvm::Value *addr)
Definition: CGObjC.cpp:2214
void InsertHelper(llvm::Instruction *I, const llvm::Twine &Name, llvm::BasicBlock *BB, llvm::BasicBlock::iterator InsertPt) const
CGBuilder insert helper. This function is called after an instruction is created using Builder...
void EmitAtomicUpdate(LValue LVal, llvm::AtomicOrdering AO, const llvm::function_ref< RValue(RValue)> &UpdateOp, bool IsVolatile)
Definition: CGAtomic.cpp:1743
void EmitVTablePtrCheck(const CXXRecordDecl *RD, llvm::Value *VTable, CFITypeCheckKind TCK, SourceLocation Loc)
Definition: CGClass.cpp:2228
void GenerateCXXGlobalDtorsFunc(llvm::Function *Fn, const std::vector< std::pair< llvm::WeakVH, llvm::Constant * > > &DtorsAndObjects)
Definition: CGDeclCXX.cpp:550
llvm::Value * EmitARCAutoreleaseReturnValue(llvm::Value *value)
Definition: CGObjC.cpp:2140
llvm::Value * SEHInfo
Value returned by __exception_info intrinsic.
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
Definition: CharUnits.h:53
llvm::CallSite EmitCallOrInvoke(llvm::Value *Callee, ArrayRef< llvm::Value * > Args, const Twine &Name="")
Definition: CGCall.cpp:3069
void GenerateObjCCtorDtorMethod(ObjCImplementationDecl *IMP, ObjCMethodDecl *MD, bool ctor)
Definition: CGObjC.cpp:1373
virtual const FieldDecl * lookup(const VarDecl *VD) const
Lookup the captured field decl for a variable.
Defines some OpenMP-specific enums and functions.
This represents '#pragma omp barrier' directive.
Definition: StmtOpenMP.h:1395
CleanupKind getCleanupKind(QualType::DestructionKind kind)
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:48
The this pointer adjustment as well as an optional return adjustment for a thunk. ...
Definition: ABI.h:179
llvm::Value * EmitObjCBoxedExpr(const ObjCBoxedExpr *E)
Definition: CGObjC.cpp:61
This is a common base class for loop directives ('omp simd', 'omp for', 'omp for simd' etc...
Definition: StmtOpenMP.h:268
RValue EmitLoadOfExtVectorElementLValue(LValue V)
Definition: CGExpr.cpp:1391
void EmitAggregateAssign(llvm::Value *DestPtr, llvm::Value *SrcPtr, QualType EltTy)
This represents '#pragma omp critical' directive.
Definition: StmtOpenMP.h:1036
LValue EmitLambdaLValue(const LambdaExpr *E)
Definition: CGExpr.cpp:3286
void GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn, const VarDecl *D, llvm::GlobalVariable *Addr, bool PerformInit)
Emit the code necessary to initialize the given global variable.
Definition: CGDeclCXX.cpp:471
llvm::Value * EmitScalarConversion(llvm::Value *Src, QualType SrcTy, QualType DstTy)
void EmitLambdaDelegatingInvokeBody(const CXXMethodDecl *MD)
Definition: CGClass.cpp:2431
RValue EmitAnyExprToTemp(const Expr *E)
Definition: CGExpr.cpp:138
ComplexPairTy EmitLoadOfComplex(LValue src, SourceLocation loc)
EmitLoadOfComplex - Load a complex number from the specified l-value.
void EmitARCDestroyStrong(llvm::Value *addr, ARCPreciseLifetime_t precise)
Definition: CGObjC.cpp:2053
bool EmitOMPLastprivateClauseInit(const OMPExecutableDirective &D, OMPPrivateScope &PrivateScope)
Emit initial code for lastprivate variables. If some variable is not also firstprivate, then the default initialization is used. Otherwise initialization of this variable is performed by EmitOMPFirstprivateClause method.
RValue EmitAnyExpr(const Expr *E, AggValueSlot aggSlot=AggValueSlot::ignored(), bool ignoreResult=false)
Definition: CGExpr.cpp:119
void EmitNoreturnRuntimeCallOrInvoke(llvm::Value *callee, ArrayRef< llvm::Value * > args)
Emits a call or invoke to the given noreturn runtime function.
Definition: CGCall.cpp:3024
const RValue & getOpaqueRValueMapping(const OpaqueValueExpr *e)
LValue MakeAddrLValue(llvm::Value *V, QualType T, CharUnits Alignment=CharUnits())
void EmitSynthesizedCXXCopyCtor(llvm::Value *Dest, llvm::Value *Src, const Expr *Exp)
Definition: CGExprCXX.cpp:466
Describes an C or C++ initializer list.
Definition: Expr.h:3759
A class controlling the emission of a finally block.
llvm::Value * BuildVector(ArrayRef< llvm::Value * > Ops)
Definition: CGBuiltin.cpp:6048
BinaryOperatorKind
llvm::Value * EmitObjCStringLiteral(const ObjCStringLiteral *E)
Emits an instance of NSConstantString representing the object.
Definition: CGObjC.cpp:47
static bool hasScalarEvaluationKind(QualType T)
void Destroyer(CodeGenFunction &CGF, llvm::Value *addr, QualType ty)
RValue EmitCall(const CGFunctionInfo &FnInfo, llvm::Value *Callee, ReturnValueSlot ReturnValue, const CallArgList &Args, const Decl *TargetDecl=nullptr, llvm::Instruction **callOrInvoke=nullptr)
Definition: CGCall.cpp:3106
llvm::Value * GetVTablePtr(llvm::Value *This, llvm::Type *Ty)
Definition: CGClass.cpp:2122
bool IvarTypeWithAggrGCObjects(QualType Ty)
Definition: CGObjC.cpp:1416
void EmitDoStmt(const DoStmt &S, ArrayRef< const Attr * > Attrs=None)
Definition: CGStmt.cpp:775
void ExitSEHTryStmt(const SEHTryStmt &S)
void pushRegularPartialArrayCleanup(llvm::Value *arrayBegin, llvm::Value *arrayEnd, QualType elementType, Destroyer *destroyer)
Definition: CGDecl.cpp:1613
CGCapturedStmtRAII(CodeGenFunction &CGF, CGCapturedStmtInfo *NewCapturedStmtInfo)
void EmitOMPCancellationPointDirective(const OMPCancellationPointDirective &S)
LexicalScope(CodeGenFunction &CGF, SourceRange Range)
Enter a new cleanup scope.
llvm::Constant * BuildDescriptorBlockDecl(const BlockExpr *, const CGBlockInfo &Info, llvm::StructType *, llvm::Constant *BlockVarLayout)
RAII for correct setting/restoring of CapturedStmtInfo.
llvm::Value * EmitBlockLiteral(const BlockExpr *)
Emit a block literal expression in the current function.
Definition: CGBlocks.cpp:684
void EmitOMPLastprivateClauseFinal(const OMPExecutableDirective &D, llvm::Value *IsLastIterCond=nullptr)
Emit final copying of lastprivate values to original variables at the end of the worksharing or simd ...
void EmitContinueStmt(const ContinueStmt &S)
Definition: CGStmt.cpp:1124
void EmitOMPTargetDirective(const OMPTargetDirective &S)
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:2918
bool needsEHCleanup(QualType::DestructionKind kind)
static OpaqueValueMappingData bind(CodeGenFunction &CGF, const OpaqueValueExpr *ov, const LValue &lv)
void registerGlobalDtorWithAtExit(const VarDecl &D, llvm::Constant *fn, llvm::Constant *addr)
Register a global destructor using the C atexit runtime function.
Definition: CGDeclCXX.cpp:219
llvm::Value * GetAddressOfBaseClass(llvm::Value *Value, const CXXRecordDecl *Derived, CastExpr::path_const_iterator PathBegin, CastExpr::path_const_iterator PathEnd, bool NullCheckValue, SourceLocation Loc)
Definition: CGClass.cpp:136
void pushDestroy(QualType::DestructionKind dtorKind, llvm::Value *addr, QualType type)
Definition: CGDecl.cpp:1381
llvm::Value * getObjectAddress(CodeGenFunction &CGF) const
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > IL, Expr *Step, Expr *CalcStep)
Creates clause with a list of variables VL and a linear step Step.
void EmitSwitchStmt(const SwitchStmt &S)
Definition: CGStmt.cpp:1513
std::string getNameAsString() const
Definition: Decl.h:183
This represents '#pragma omp cancellation point' directive.
Definition: StmtOpenMP.h:1885
bool isObviouslyBranchWithoutCleanups(JumpDest Dest) const
Definition: CGCleanup.cpp:915
llvm::Value * EmitDynamicCast(llvm::Value *V, const CXXDynamicCastExpr *DCE)
Definition: CGExprCXX.cpp:1761
llvm::BasicBlock * getInvokeDestImpl()
void incrementProfileCounter(const Stmt *S)
Increment the profiler's counter for the given statement.
LValue EmitCXXConstructLValue(const CXXConstructExpr *E)
Definition: CGExpr.cpp:3254
llvm::Function * GenerateSEHFinallyFunction(CodeGenFunction &ParentCGF, const SEHFinallyStmt &Finally)
LValue EmitUnaryOpLValue(const UnaryOperator *E)
Definition: CGExpr.cpp:2039
void EmitStmt(const Stmt *S)
Definition: CGStmt.cpp:45
void EmitOMPParallelDirective(const OMPParallelDirective &S)
llvm::BasicBlock * createBasicBlock(const Twine &name="", llvm::Function *parent=nullptr, llvm::BasicBlock *before=nullptr)
createBasicBlock - Create an LLVM basic block.
llvm::Value * EmitARCRetainScalarExpr(const Expr *expr)
Definition: CGObjC.cpp:2731
This represents '#pragma omp teams' directive.
Definition: StmtOpenMP.h:1828
void EmitIgnoredExpr(const Expr *E)
EmitIgnoredExpr - Emit an expression in a context which ignores the result.
Definition: CGExpr.cpp:107
void EmitAtomicInit(Expr *E, LValue lvalue)
Definition: CGAtomic.cpp:1750
llvm::Function * EmitCapturedStmt(const CapturedStmt &S, CapturedRegionKind K)
Definition: CGStmt.cpp:2177
void EmitDeleteCall(const FunctionDecl *DeleteFD, llvm::Value *Ptr, QualType DeleteTy)
Definition: CGExprCXX.cpp:1393
Enums/classes describing ABI related information about constructors, destructors and thunks...
LValue EmitObjCMessageExprLValue(const ObjCMessageExpr *E)
Definition: CGExpr.cpp:3292
bool requiresCleanups() const
Determine whether this scope requires any cleanups.
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1032
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1343
GlobalDecl CurGD
CurGD - The GlobalDecl for the current function being compiled.
void EmitDefaultStmt(const DefaultStmt &S)
Definition: CGStmt.cpp:1300
RValue EmitBuiltinExpr(const FunctionDecl *FD, unsigned BuiltinID, const CallExpr *E, ReturnValueSlot ReturnValue)
Definition: CGBuiltin.cpp:259
static bool ContainsLabel(const Stmt *S, bool IgnoreCaseStmts=false)
llvm::Value * EmitExtVectorElementLValue(LValue V)
Generates lvalue for partial ext_vector access.
Definition: CGExpr.cpp:1422
llvm::DebugLoc EmitReturnBlock()
Emit the unified return block, trying to avoid its emission when possible.
const RecordDecl * getCapturedRecordDecl() const
Retrieve the record declaration for captured variables.
Definition: Stmt.h:2126
llvm::Function * generateDestroyHelper(llvm::Constant *addr, QualType type, Destroyer *destroyer, bool useEHCleanupForArray, const VarDecl *VD)
Definition: CGDeclCXX.cpp:576
void EmitCaseStmtRange(const CaseStmt &S)
Definition: CGStmt.cpp:1139
llvm::Type * BuildByRefType(const VarDecl *var)
Definition: CGBlocks.cpp:2036
Represents an ObjC class declaration.
Definition: DeclObjC.h:851
JumpDest getJumpDestInCurrentScope(StringRef Name=StringRef())
llvm::Value * EmitARCRetainAutoreleasedReturnValue(llvm::Value *value)
Definition: CGObjC.cpp:1974
llvm::Value * EmitCheckValue(llvm::Value *V)
Convert a value into a format suitable for passing to a runtime sanitizer handler.
Definition: CGExpr.cpp:2178
void EmitCallArg(CallArgList &args, const Expr *E, QualType ArgType)
EmitCallArg - Emit a single call argument.
Definition: CGCall.cpp:2883
Checking the operand of a load. Must be suitably sized and aligned.
llvm::Value * EmitARCRetainAutoreleaseNonBlock(llvm::Value *value)
Definition: CGObjC.cpp:2179
~LexicalScope()
Exit this cleanup scope, emitting any accumulated cleanups.
Represents the this expression in C++.
Definition: ExprCXX.h:770
LValue EmitLValueForField(LValue Base, const FieldDecl *Field)
Definition: CGExpr.cpp:2680
void EmitDeclRefExprDbgValue(const DeclRefExpr *E, llvm::Constant *Init)
llvm::CallSite EmitRuntimeCallOrInvoke(llvm::Value *callee, ArrayRef< llvm::Value * > args, const Twine &name="")
Emits a call or invoke instruction to the given runtime function.
Definition: CGCall.cpp:3052
LValue EmitExtVectorElementExpr(const ExtVectorElementExpr *E)
Definition: CGExpr.cpp:2587
RValue EmitObjCMessageExpr(const ObjCMessageExpr *E, ReturnValueSlot Return=ReturnValueSlot())
Definition: CGObjC.cpp:315
void GenerateCXXGlobalInitFunc(llvm::Function *Fn, ArrayRef< llvm::Function * > CXXThreadLocals, llvm::GlobalVariable *Guard=nullptr)
Definition: CGDeclCXX.cpp:499
void EmitCXXConstructExpr(const CXXConstructExpr *E, AggValueSlot Dest)
Definition: CGExprCXX.cpp:394
CleanupKind Kind
The kind of cleanup to push: a value from the CleanupKind enumeration.
void EmitCheck(ArrayRef< std::pair< llvm::Value *, SanitizerMask >> Checked, StringRef CheckName, ArrayRef< llvm::Constant * > StaticArgs, ArrayRef< llvm::Value * > DynamicArgs)
Create a basic block that will call a handler function in a sanitizer runtime with the provided argum...
Definition: CGExpr.cpp:2295
AutoVarEmission EmitAutoVarAlloca(const VarDecl &var)
Definition: CGDecl.cpp:885
std::pair< llvm::Value *, llvm::Value * > ComplexPairTy
llvm::CallInst * EmitNounwindRuntimeCall(llvm::Value *callee, const Twine &name="")
void EmitOMPParallelSectionsDirective(const OMPParallelSectionsDirective &S)
Describes the capture of either a variable, or 'this', or variable-length array type.
Definition: Stmt.h:2001
llvm::Value * EmitCXXUuidofExpr(const CXXUuidofExpr *E)
Definition: CGExpr.cpp:3267
RValue EmitAtomicExpr(AtomicExpr *E, llvm::Value *Dest=nullptr)
Definition: CGAtomic.cpp:673
void emitDestroy(llvm::Value *addr, QualType type, Destroyer *destroyer, bool useEHCleanupForArray)
Definition: CGDecl.cpp:1432
const CodeGen::CGBlockInfo * BlockInfo
llvm::Function * GenerateBlockFunction(GlobalDecl GD, const CGBlockInfo &Info, const DeclMapTy &ldm, bool IsLambdaConversionToBlock)
Definition: CGBlocks.cpp:1107
This represents '#pragma omp taskgroup' directive.
Definition: StmtOpenMP.h:1483
const TargetCodeGenInfo & getTargetCodeGenInfo()
void PushDestructorCleanup(QualType T, llvm::Value *Addr)
Definition: CGClass.cpp:1980
CGBlockInfo - Information to generate a block literal.
Definition: CGBlocks.h:144
unsigned getNumObjects() const
Definition: ExprCXX.h:2799
ASTContext * Context
void EmitDelegateCallArg(CallArgList &args, const VarDecl *param, SourceLocation loc)
Definition: CGCall.cpp:2499
VAArgExpr, used for the builtin function __builtin_va_arg.
Definition: Expr.h:3670
ID
Defines the set of possible language-specific address spaces.
Definition: AddressSpaces.h:27
Exposes information about the current target.
virtual StringRef getHelperName() const
Get the name of the capture helper.
void EmitCXXGuardedInit(const VarDecl &D, llvm::GlobalVariable *DeclPtr, bool PerformInit)
Definition: CGDeclCXX.cpp:237
int * Depth
LValue EmitInitListLValue(const InitListExpr *E)
Definition: CGExpr.cpp:2843
static TypeEvaluationKind getEvaluationKind(QualType T)
void EmitStoreThroughExtVectorComponentLValue(RValue Src, LValue Dst)
Definition: CGExpr.cpp:1631
CXXDtorType
C++ destructor types.
Definition: ABI.h:34
llvm::BasicBlock * EHResumeBlock
EHResumeBlock - Unified block containing a call to llvm.eh.resume.
llvm::Value * EmitARCStoreWeak(llvm::Value *value, llvm::Value *addr, bool ignored)
Definition: CGObjC.cpp:2202
void InitTempAlloca(llvm::AllocaInst *Alloca, llvm::Value *Value)
InitTempAlloca - Provide an initial value for the given alloca.
Definition: CGExpr.cpp:64
llvm::Value * EmitARCLoadWeakRetained(llvm::Value *addr)
i8* @objc_loadWeakRetained(i8** addr)
Definition: CGObjC.cpp:2194
void EmitCapturedLocals(CodeGenFunction &ParentCGF, const Stmt *OutlinedStmt, bool IsFilter)
void enter(CodeGenFunction &CGF, const Stmt *Finally, llvm::Constant *beginCatchFn, llvm::Constant *endCatchFn, llvm::Constant *rethrowFn)
llvm::Value * GenerateCapturedStmtArgument(const CapturedStmt &S)
Definition: CGStmt.cpp:2193
void EmitAutoVarInit(const AutoVarEmission &emission)
Definition: CGDecl.cpp:1100
bool CanDevirtualizeMemberFunctionCall(const Expr *Base, const CXXMethodDecl *MD)
Definition: CGClass.cpp:2300
Enters a new scope for capturing cleanups, all of which will be executed once the scope is exited...
LValue EmitCXXTypeidLValue(const CXXTypeidExpr *E)
Definition: CGExpr.cpp:3263
void EmitCaseStmt(const CaseStmt &S)
Definition: CGStmt.cpp:1217
llvm::Function * GenerateSEHFilterFunction(CodeGenFunction &ParentCGF, const SEHExceptStmt &Except)
RValue EmitCXXMemberOrOperatorCall(const CXXMethodDecl *MD, llvm::Value *Callee, ReturnValueSlot ReturnValue, llvm::Value *This, llvm::Value *ImplicitParam, QualType ImplicitParamTy, const CallExpr *E)
Definition: CGExprCXX.cpp:72
llvm::Value * GetAddrOfLocalVar(const VarDecl *VD)
GetAddrOfLocalVar - Return the address of a local variable.
void pushCallObjectDeleteCleanup(const FunctionDecl *OperatorDelete, llvm::Value *CompletePtr, QualType ElementType)
Definition: CGExprCXX.cpp:1443
void GenerateObjCMethod(const ObjCMethodDecl *OMD)
Definition: CGObjC.cpp:524
OpaqueValueMapping(CodeGenFunction &CGF, const OpaqueValueExpr *opaqueValue, RValue rvalue)
void EmitOMPTeamsDirective(const OMPTeamsDirective &S)
void ForceCleanup()
Force the emission of cleanups now, instead of waiting until this object is destroyed.
static bool isObjCMethodWithTypeParams(const ObjCMethodDecl *method)
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2358
llvm::Constant * GenerateDestroyHelperFunction(const CGBlockInfo &blockInfo)
Definition: CGBlocks.cpp:1478
llvm::Value * emitArrayLength(const ArrayType *arrayType, QualType &baseType, llvm::Value *&addr)
void SetFPAccuracy(llvm::Value *Val, float Accuracy)
Definition: CGExpr.cpp:3486
AggValueSlot CreateAggTemp(QualType T, const Twine &Name="tmp")
llvm::AllocaInst * NormalCleanupDest
i32s containing the indexes of the cleanup destinations.
#define bool
Definition: stdbool.h:31
unsigned Size
The size of the following cleanup object.
DeclContext * getDeclContext()
Definition: DeclBase.h:381
void EmitSEHTryStmt(const SEHTryStmt &S)
ASTContext & getContext() const
llvm::Value * EmitToMemory(llvm::Value *Value, QualType Ty)
Definition: CGExpr.cpp:1219
llvm::BasicBlock * getBlock() const
Represents Objective-C's @synchronized statement.
Definition: StmtObjC.h:262
ObjCSelectorExpr used for @selector in Objective-C.
Definition: ExprObjC.h:396
EHScopeStack::stable_iterator getScopeDepth() const
llvm::Value * EmitCompoundStmtWithoutScope(const CompoundStmt &S, bool GetLast=false, AggValueSlot AVS=AggValueSlot::ignored())
Definition: CGStmt.cpp:287
void EmitOMPLinearClauseInit(const OMPLoopDirective &D)
Emit initial code for linear variables. Creates private copies and initializes them with the values a...
void generateObjCSetterBody(const ObjCImplementationDecl *classImpl, const ObjCPropertyImplDecl *propImpl, llvm::Constant *AtomicHelperFn)
Definition: CGObjC.cpp:1111
~OMPPrivateScope()
Exit scope - all the mapped variables are restored.
llvm::Value * getExceptionFromSlot()
void EmitAsanPrologueOrEpilogue(bool Prologue)
Definition: CGClass.cpp:734
llvm::Value * EmitARCAutorelease(llvm::Value *value)
Definition: CGObjC.cpp:2131
stable_iterator stable_begin() const
Definition: EHScopeStack.h:364
std::pair< llvm::Type *, unsigned > getByRefValueLLVMField(const ValueDecl *VD) const
Definition: CGBlocks.cpp:2005
llvm::LLVMContext & getLLVMContext()
llvm::BasicBlock * GetIndirectGotoBlock()
void EmitLambdaExpr(const LambdaExpr *E, AggValueSlot Dest)
Definition: CGExprCXX.cpp:1841
RValue EmitCXXMemberOrOperatorMemberCallExpr(const CallExpr *CE, const CXXMethodDecl *MD, ReturnValueSlot ReturnValue, bool HasQualifier, NestedNameSpecifier *Qualifier, bool IsArrow, const Expr *Base)
Definition: CGExprCXX.cpp:132
void AllocateBlockDecl(const DeclRefExpr *E)
std::pair< bool, RValue > EmitOMPAtomicSimpleUpdateExpr(LValue X, RValue E, BinaryOperatorKind BO, bool IsXLHSInRHSPart, llvm::AtomicOrdering AO, SourceLocation Loc, const llvm::function_ref< RValue(RValue)> &CommonGen)
Emit atomic update code for constructs: X = X BO E or X = E BO E.
This represents '#pragma omp for' directive.
Definition: StmtOpenMP.h:701
void EmitConstructorBody(FunctionArgList &Args)
EmitConstructorBody - Emits the body of the current constructor.
Definition: CGClass.cpp:797
void EmitOMPMasterDirective(const OMPMasterDirective &S)
llvm::Function * GenerateCapturedStmtFunction(const CapturedStmt &S)
Creates the outlined function for a CapturedStmt.
Definition: CGStmt.cpp:2200
LValue MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T)
An expression that sends a message to the given Objective-C object or class.
Definition: ExprObjC.h:858
ComplexPairTy EmitComplexPrePostIncDec(const UnaryOperator *E, LValue LV, bool isInc, bool isPre)
Definition: CGExpr.cpp:729
JumpDest(llvm::BasicBlock *Block, EHScopeStack::stable_iterator Depth, unsigned Index)
void ResolveBranchFixups(llvm::BasicBlock *Target)
Definition: CGCleanup.cpp:349
void EmitForwardingCallToLambda(const CXXMethodDecl *LambdaCallOperator, CallArgList &CallArgs)
Definition: CGClass.cpp:2364
void EmitMCountInstrumentation()
EmitMCountInstrumentation - Emit call to .mcount.
void EmitOMPBarrierDirective(const OMPBarrierDirective &S)
void EmitLambdaToBlockPointerBody(FunctionArgList &Args)
Definition: CGClass.cpp:2420
llvm::Value * EmitCastToVoidPtr(llvm::Value *value)
Emit a cast to void* in the appropriate address space.
Definition: CGExpr.cpp:43
SmallVector< llvm::Value *, 1 > SEHCodeSlotStack
ConstantEmission tryEmitAsConstant(DeclRefExpr *refExpr)
Definition: CGExpr.cpp:994
This represents '#pragma omp cancel' directive.
Definition: StmtOpenMP.h:1943
RunCleanupsScope(CodeGenFunction &CGF)
Enter a new cleanup scope.
RValue EmitLoadOfGlobalRegLValue(LValue LV)
Load of global gamed gegisters are always calls to intrinsics.
Definition: CGExpr.cpp:1444
void EmitCXXGlobalVarDeclInit(const VarDecl &D, llvm::Constant *DeclPtr, bool PerformInit)
Definition: CGDeclCXX.cpp:135
bool isGLValue() const
Definition: Expr.h:253
void setBeforeOutermostConditional(llvm::Value *value, llvm::Value *addr)
RValue EmitAtomicLoad(LValue LV, SourceLocation SL, AggValueSlot Slot=AggValueSlot::ignored())
Definition: CGAtomic.cpp:1212
llvm::IRBuilder< PreserveNames, llvm::ConstantFolder, CGBuilderInserterTy > CGBuilderTy
Definition: CGBuilder.h:49
do v
Definition: arm_acle.h:77
void generateThunk(llvm::Function *Fn, const CGFunctionInfo &FnInfo, GlobalDecl GD, const ThunkInfo &Thunk)
Generate a thunk for the given method.
Definition: CGVTables.cpp:382
llvm::Value * EmitX86BuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition: CGBuiltin.cpp:6073
This represents '#pragma omp flush' directive.
Definition: StmtOpenMP.h:1534
void EmitParmDecl(const VarDecl &D, llvm::Value *Arg, bool ArgIsPointer, unsigned ArgNo)
EmitParmDecl - Emit a ParmVarDecl or an ImplicitParamDecl.
Definition: CGDecl.cpp:1659
This represents '#pragma omp parallel for simd' directive.
Definition: StmtOpenMP.h:1169
void EmitDeclStmt(const DeclStmt &S)
Definition: CGStmt.cpp:1102
llvm::Value * EmitAMDGPUBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition: CGBuiltin.cpp:6770
void EmitAnyExprToMem(const Expr *E, llvm::Value *Location, Qualifiers Quals, bool IsInitializer)
Definition: CGExpr.cpp:148
llvm::BasicBlock * getEHDispatchBlock(EHScopeStack::stable_iterator scope)
llvm::Value * EmitPPCBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition: CGBuiltin.cpp:6535
void EmitAlignmentAssumption(llvm::Value *PtrValue, unsigned Alignment, llvm::Value *OffsetValue=nullptr)
void enterByrefCleanup(const AutoVarEmission &emission)
Definition: CGBlocks.cpp:2258
void EmitOMPFlushDirective(const OMPFlushDirective &S)
OMPPrivateScope(CodeGenFunction &CGF)
Enter a new OpenMP private scope.
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
Definition: ExprCXX.h:269
#define false
Definition: stdbool.h:33
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
llvm::GlobalVariable * AddInitializerToStaticVarDecl(const VarDecl &D, llvm::GlobalVariable *GV)
Definition: CGDecl.cpp:281
Kind
This captures a statement into a function. For example, the following pragma annotated compound state...
Definition: Stmt.h:1989
LValue EmitVAArgExprLValue(const VAArgExpr *E)
Definition: CGExpr.cpp:3249
void EmitCXXConstructorCall(const CXXConstructorDecl *D, CXXCtorType Type, bool ForVirtualBase, bool Delegating, llvm::Value *This, const CXXConstructExpr *E)
Definition: CGClass.cpp:1774
llvm::Value * EmitCXXTypeidExpr(const CXXTypeidExpr *E)
Definition: CGExprCXX.cpp:1722
llvm::AllocaInst * CreateIRTemp(QualType T, const Twine &Name="tmp")
Definition: CGExpr.cpp:71
ASTContext & getContext() const
This represents '#pragma omp single' directive.
Definition: StmtOpenMP.h:934
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
bool LValueIsSuitableForInlineAtomic(LValue Src)
Definition: CGAtomic.cpp:1193
llvm::Value * EmitObjCArrayLiteral(const ObjCArrayLiteral *E)
Definition: CGObjC.cpp:227
void EmitARCIntrinsicUse(ArrayRef< llvm::Value * > values)
Definition: CGObjC.cpp:1774
void EmitOMPForDirective(const OMPForDirective &S)
void EmitARCRelease(llvm::Value *value, ARCPreciseLifetime_t precise)
Definition: CGObjC.cpp:2021
LValue EmitDeclRefLValue(const DeclRefExpr *E)
Definition: CGExpr.cpp:1928
void EmitAggregateCopy(llvm::Value *DestPtr, llvm::Value *SrcPtr, QualType EltTy, bool isVolatile=false, CharUnits Alignment=CharUnits::Zero(), bool isAssignment=false)
Definition: CGExprAgg.cpp:1425
std::pair< RValue, llvm::Value * > EmitAtomicCompareExchange(LValue Obj, RValue Expected, RValue Desired, SourceLocation Loc, llvm::AtomicOrdering Success=llvm::SequentiallyConsistent, llvm::AtomicOrdering Failure=llvm::SequentiallyConsistent, bool IsWeak=false, AggValueSlot Slot=AggValueSlot::ignored())
Definition: CGAtomic.cpp:1725
Represents a C++ temporary.
Definition: ExprCXX.h:1001
llvm::Value * EvaluateExprAsBool(const Expr *E)
Definition: CGExpr.cpp:91
LValue EmitCheckedLValue(const Expr *E, TypeCheckKind TCK)
Same as EmitLValue but additionally we generate checking code to guard against undefined behavior...
Definition: CGExpr.cpp:804
~RunCleanupsScope()
Exit this cleanup scope, emitting any accumulated cleanups.
llvm::Value * EmitFromMemory(llvm::Value *Value, QualType Ty)
Definition: CGExpr.cpp:1233
llvm::BasicBlock * getUnreachableBlock()
This is a basic class for representing single OpenMP executable directive.
Definition: StmtOpenMP.h:33
bool IndirectObjCSetterArg(const CGFunctionInfo &FI)
Definition: CGObjC.cpp:1408
SmallVector< llvm::Value *, 8 > ObjCEHValueStack
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
Definition: ExprCXX.h:1623
void EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S)
Definition: CGObjC.cpp:1439
bool ConstantFoldsToSimpleInteger(const Expr *Cond, bool &Result)
LValue EmitAggExprToLValue(const Expr *E)
Definition: CGExprAgg.cpp:1415
void DeactivateCleanupBlock(EHScopeStack::stable_iterator Cleanup, llvm::Instruction *DominatingIP)
Deactive a cleanup that was created in an active state.
Definition: CGCleanup.cpp:1135
void EmitCallAndReturnForThunk(llvm::Value *Callee, const ThunkInfo *Thunk)
Definition: CGVTables.cpp:241
OpenMPDirectiveKind
OpenMP directives.
Definition: OpenMPKinds.h:23
An aggregate value slot.
Definition: CGValue.h:363
llvm::Constant * createAtExitStub(const VarDecl &VD, llvm::Constant *Dtor, llvm::Constant *Addr)
Definition: CGDeclCXX.cpp:188
llvm::Value * EmitLifetimeStart(uint64_t Size, llvm::Value *Addr)
Definition: CGDecl.cpp:856
LValue EmitUnsupportedLValue(const Expr *E, const char *Name)
Definition: CGExpr.cpp:797
llvm::Value * EmitAArch64BuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition: CGBuiltin.cpp:4168
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1717
void EmitARCCopyWeak(llvm::Value *dst, llvm::Value *src)
Definition: CGObjC.cpp:2258
static type restore(CodeGenFunction &CGF, saved_type value)
llvm::Value * EmitVAListRef(const Expr *E)
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
void EmitNullInitialization(llvm::Value *DestPtr, QualType Ty)
This represents '#pragma omp taskwait' directive.
Definition: StmtOpenMP.h:1439
void EmitOMPTaskgroupDirective(const OMPTaskgroupDirective &S)
SanitizerSet SanOpts
Sanitizers enabled for this function.
void pushEHDestroy(QualType::DestructionKind dtorKind, llvm::Value *addr, QualType type)
Definition: CGDecl.cpp:1371
bool isTrivialInitializer(const Expr *Init)
Determine whether the given initializer is trivial in the sense that it requires no code to be genera...
Definition: CGDecl.cpp:1087
llvm::Value * EmitNeonCall(llvm::Function *F, SmallVectorImpl< llvm::Value * > &O, const char *name, unsigned shift=0, bool rightshift=false)
Definition: CGBuiltin.cpp:1926
const CodeGenOptions & getCodeGenOpts() const
LValue getReferenceLValue(CodeGenFunction &CGF, Expr *refExpr) const
bool hasVolatileMember() const
Definition: Decl.h:3302
TypeCheckKind
Situations in which we might emit a check for the suitability of a pointer or glvalue.
void pushCleanupAfterFullExpr(CleanupKind Kind, As...A)
Queue a cleanup to be pushed after finishing the current full-expression.
void EmitOMPSingleDirective(const OMPSingleDirective &S)
static LValue MakeAddr(llvm::Value *address, QualType type, CharUnits alignment, ASTContext &Context, llvm::MDNode *TBAAInfo=nullptr)
Definition: CGValue.h:295
void StartFunction(GlobalDecl GD, QualType RetTy, llvm::Function *Fn, const CGFunctionInfo &FnInfo, const FunctionArgList &Args, SourceLocation Loc=SourceLocation(), SourceLocation StartLoc=SourceLocation())
Emit code for the start of a function.
const LangOptions & getLangOpts() const
llvm::BasicBlock * getEHResumeBlock(bool isCleanup)
llvm::AllocaInst * CreateMemTemp(QualType T, const Twine &Name="tmp")
Definition: CGExpr.cpp:80
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of captures.
Definition: Stmt.h:2156
This represents '#pragma omp target' directive.
Definition: StmtOpenMP.h:1771
SourceLocation getBegin() const
void EmitOMPForSimdDirective(const OMPForSimdDirective &S)
LValue EmitPointerToDataMemberBinaryExpr(const BinaryOperator *E)
Definition: CGExpr.cpp:3451
void EmitOMPAtomicDirective(const OMPAtomicDirective &S)
JumpDest getJumpDestInCurrentScope(llvm::BasicBlock *Target)
void EmitOMPSectionDirective(const OMPSectionDirective &S)
void EmitOMPSectionsDirective(const OMPSectionsDirective &S)
RValue EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E, ReturnValueSlot ReturnValue)
Definition: CGExprCXX.cpp:285
llvm::Function * GenerateCapturedStmtFunctionEpilog(const CapturedStmt &S)
This represents '#pragma omp ordered' directive.
Definition: StmtOpenMP.h:1589
static llvm::Value * restore(CodeGenFunction &CGF, saved_type value)
void EmitForStmt(const ForStmt &S, ArrayRef< const Attr * > Attrs=None)
Definition: CGStmt.cpp:837
RValue EmitCallExpr(const CallExpr *E, ReturnValueSlot ReturnValue=ReturnValueSlot())
Definition: CGExpr.cpp:3107
LValue EmitReadRegister(const VarDecl *VD)
llvm::Value * vectorWrapScalar8(llvm::Value *Op)
Definition: CGBuiltin.cpp:4159
RValue EmitBuiltinNewDeleteCall(const FunctionProtoType *Type, const Expr *Arg, bool IsDelete)
Definition: CGExprCXX.cpp:1087
llvm::Value * EmitARCRetain(QualType type, llvm::Value *value)
Definition: CGObjC.cpp:1924
const CGFunctionInfo * CurFnInfo
void EmitStartEHSpec(const Decl *D)
EmitStartEHSpec - Emit the start of the exception spec.
static ConstantEmission forReference(llvm::Constant *C)
void enterFullExpression(const ExprWithCleanups *E)
void EmitDecl(const Decl &D)
Definition: CGDecl.cpp:35
llvm::Value * recoverAddrOfEscapedLocal(CodeGenFunction &ParentCGF, llvm::Value *ParentVar, llvm::Value *ParentFP)
static Destroyer destroyARCStrongImprecise
void FinishFunction(SourceLocation EndLoc=SourceLocation())
CXXCtorType
C++ constructor types.
Definition: ABI.h:25
void EmitARCDestroyWeak(llvm::Value *addr)
Definition: CGObjC.cpp:2232
void EmitObjCMRRAutoreleasePoolPop(llvm::Value *Ptr)
Definition: CGObjC.cpp:2326
RValue convertTempToRValue(llvm::Value *addr, QualType type, SourceLocation Loc)
Definition: CGExpr.cpp:3471
JumpDest getOMPCancelDestination(OpenMPDirectiveKind Kind)
llvm::Value * EmitScalarExpr(const Expr *E, bool IgnoreResultAssign=false)
llvm::Value * EmitFieldAnnotations(const FieldDecl *D, llvm::Value *V)
QualType getType() const
Definition: Expr.h:125
void EmitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt &S)
Definition: CGObjC.cpp:1733
llvm::Value * EmitNeonRShiftImm(llvm::Value *Vec, llvm::Value *Amt, llvm::Type *Ty, bool usgn, const char *name)
Definition: CGBuiltin.cpp:1950
Expr * getCommon() const
getCommon - Return the common expression, written to the left of the condition. The opaque value will...
Definition: Expr.h:3298
void EmitOMPTaskyieldDirective(const OMPTaskyieldDirective &S)
void EmitVTablePtrCheckForCast(QualType T, llvm::Value *Derived, bool MayBeNull, CFITypeCheckKind TCK, SourceLocation Loc)
Derived is the presumed address of an object of type T after a cast. If T is a polymorphic class type...
Definition: CGClass.cpp:2176
LValue InitCapturedStruct(const CapturedStmt &S)
Definition: CGStmt.cpp:2150
[C99 6.4.2.2] - A predefined identifier such as func.
Definition: Expr.h:1174
RValue EmitUnsupportedRValue(const Expr *E, const char *Name)
Definition: CGExpr.cpp:791
Represents a delete expression for memory deallocation and destructor calls, e.g. "delete[] pArray"...
Definition: ExprCXX.h:1819
void GenerateObjCGetter(ObjCImplementationDecl *IMP, const ObjCPropertyImplDecl *PID)
GenerateObjCGetter - Synthesize an Objective-C property getter function.
Definition: CGObjC.cpp:763
llvm::Value * GetAddressOfDirectBaseInCompleteClass(llvm::Value *Value, const CXXRecordDecl *Derived, const CXXRecordDecl *Base, bool BaseIsVirtual)
Definition: CGClass.cpp:82
void EmitObjCAutoreleasePoolPop(llvm::Value *Ptr)
Definition: CGObjC.cpp:2279
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Definition: ASTMatchers.h:1639
static AggValueSlot ignored()
Definition: CGValue.h:409
CodeGenFunction::ComplexPairTy ComplexPairTy
void EmitOMPParallelForDirective(const OMPParallelForDirective &S)
This represents '#pragma omp section' directive.
Definition: StmtOpenMP.h:885
llvm::Value * EmitAnnotationCall(llvm::Value *AnnotationFn, llvm::Value *AnnotatedVal, StringRef AnnotationStr, SourceLocation Location)
Emit an annotation call (intrinsic or builtin).
void EmitOMPPrivateClause(const OMPExecutableDirective &D, OMPPrivateScope &PrivateScope)
LValue EmitCallExprLValue(const CallExpr *E)
Definition: CGExpr.cpp:3236
LValue EmitPseudoObjectLValue(const PseudoObjectExpr *e)
Definition: CGExpr.cpp:3575
This represents '#pragma omp simd' directive.
Definition: StmtOpenMP.h:636
void EmitDelegatingCXXConstructorCall(const CXXConstructorDecl *Ctor, const FunctionArgList &Args)
Definition: CGClass.cpp:1923
void emitArrayDestroy(llvm::Value *begin, llvm::Value *end, QualType type, Destroyer *destroyer, bool checkZeroLength, bool useEHCleanup)
Definition: CGDecl.cpp:1467
QualType TypeOfSelfObject()
TypeOfSelfObject - Return type of object that this self represents.
Definition: CGObjC.cpp:1431
Header for data within LifetimeExtendedCleanupStack.
Checking the destination of a store. Must be suitably sized and aligned.
bool EmitOMPFirstprivateClause(const OMPExecutableDirective &D, OMPPrivateScope &PrivateScope)
void EmitOMPCancelDirective(const OMPCancelDirective &S)
llvm::SmallVector< char, 256 > LifetimeExtendedCleanupStack
llvm::Constant * GenerateObjCAtomicGetterCopyHelperFunction(const ObjCPropertyImplDecl *PID)
Definition: CGObjC.cpp:2963
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
Definition: ASTContext.h:1855
bool isSEHTryScope() const
Returns true inside SEH __try blocks.
This represents '#pragma omp atomic' directive.
Definition: StmtOpenMP.h:1637
void EmitObjCAtThrowStmt(const ObjCAtThrowStmt &S)
Definition: CGObjC.cpp:1729
void EmitStoreOfScalar(llvm::Value *Value, llvm::Value *Addr, bool Volatile, unsigned Alignment, QualType Ty, llvm::MDNode *TBAAInfo=nullptr, bool isInit=false, QualType TBAABaseTy=QualType(), uint64_t TBAAOffset=0)
Definition: CGExpr.cpp:1244
void EmitTypeCheck(TypeCheckKind TCK, SourceLocation Loc, llvm::Value *V, QualType Type, CharUnits Alignment=CharUnits::Zero(), bool SkipNullCheck=false)
Emit a check that V is the address of storage of the appropriate size and alignment for an object of ...
Definition: CGExpr.cpp:489
void EmitAggExpr(const Expr *E, AggValueSlot AS)
Definition: CGExprAgg.cpp:1403
JumpDest ReturnBlock
ReturnBlock - Unified return block.
static bool hasAggregateEvaluationKind(QualType T)
llvm::Value * EmitNeonSplat(llvm::Value *V, llvm::Constant *Idx)
Definition: CGBuiltin.cpp:1920
void EmitAutoVarCleanups(const AutoVarEmission &emission)
Definition: CGDecl.cpp:1306
llvm::Value * EmitComplexToScalarConversion(ComplexPairTy Src, QualType SrcTy, QualType DstTy)
API for captured statement code generation.
static saved_type save(CodeGenFunction &CGF, type value)
void EmitSynthesizedCXXCopyCtorCall(const CXXConstructorDecl *D, llvm::Value *This, llvm::Value *Src, const CXXConstructExpr *E)
Definition: CGClass.cpp:1826
static bool isObjCMethodWithTypeParams(const T *)
llvm::Type * ConvertType(const TypeDecl *T)
const LValue & getOpaqueLValueMapping(const OpaqueValueExpr *e)
FieldConstructionScope(CodeGenFunction &CGF, llvm::Value *This)
void EmitBlockWithFallThrough(llvm::BasicBlock *BB, const Stmt *S)
llvm::Value * vectorWrapScalar16(llvm::Value *Op)
Definition: CGBuiltin.cpp:4150
const T * getAs() const
Definition: Type.h:5555
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition: Expr.h:2066
Represents Objective-C's collection statement.
Definition: StmtObjC.h:24
OpaqueValueExpr * getOpaqueValue() const
getOpaqueValue - Return the opaque value placeholder.
Definition: Expr.h:3301
void EmitStoreOfComplex(ComplexPairTy V, LValue dest, bool isInit)
EmitStoreOfComplex - Store a complex number into the specified l-value.
RValue GetUndefRValue(QualType Ty)
GetUndefRValue - Get an appropriate 'undef' rvalue for the given type.
Definition: CGExpr.cpp:765
Implements C++ ABI-specific code generation functions.
Definition: CGCXXABI.h:42
LValue EmitArraySubscriptExpr(const ArraySubscriptExpr *E, bool Accessed=false)
Definition: CGExpr.cpp:2445
llvm::Value * BuildBlockByrefAddress(llvm::Value *BaseAddr, const VarDecl *V)
Definition: CGBlocks.cpp:2011
A stack of loop information corresponding to loop nesting levels. This stack can be used to prepare a...
Definition: CGLoopInfo.h:82
void EmitAsmStmt(const AsmStmt &S)
Definition: CGStmt.cpp:1811
llvm::Value * EmitNeonShiftVector(llvm::Value *V, llvm::Type *Ty, bool negateForRightShift)
Definition: CGBuiltin.cpp:1940
Represents a call to a CUDA kernel function.
Definition: ExprCXX.h:155
RValue EmitRValueForField(LValue LV, const FieldDecl *FD, SourceLocation Loc)
Definition: CGExpr.cpp:3087
void EmitLambdaStaticInvokeFunction(const CXXMethodDecl *MD)
Definition: CGClass.cpp:2461
llvm::AssertingVH< llvm::Instruction > AllocaInsertPt
bool isFunctionType() const
Definition: Type.h:5229
LValue EmitLValueForIvar(QualType ObjectTy, llvm::Value *Base, const ObjCIvarDecl *Ivar, unsigned CVRQualifiers)
Definition: CGExpr.cpp:3316
OpenMPScheduleClauseKind
OpenMP attributes for 'schedule' clause.
Definition: OpenMPKinds.h:58
void EmitScalarInit(const Expr *init, const ValueDecl *D, LValue lvalue, bool capturedByInit)
Definition: CGDecl.cpp:604
llvm::Value * EmitIvarOffset(const ObjCInterfaceDecl *Interface, const ObjCIvarDecl *Ivar)
Definition: CGExpr.cpp:3311
llvm::Value * EmitARCRetainAutorelease(QualType type, llvm::Value *value)
Definition: CGObjC.cpp:2162
LValue EmitCastLValue(const CastExpr *E)
Definition: CGExpr.cpp:2945
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
Definition: CGStmt.cpp:348
void EnterCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock=false)
void EmitCXXTemporary(const CXXTemporary *Temporary, QualType TempType, llvm::Value *Ptr)
Emits all the code to cause the given temporary to be cleaned up.
Definition: CGCleanup.cpp:1165
ARCPreciseLifetime_t
Does an ARC strong l-value have precise lifetime?
Definition: CGValue.h:102
ComplexPairTy EmitComplexExpr(const Expr *E, bool IgnoreReal=false, bool IgnoreImag=false)
RValue EmitCXXStructorCall(const CXXMethodDecl *MD, llvm::Value *Callee, ReturnValueSlot ReturnValue, llvm::Value *This, llvm::Value *ImplicitParam, QualType ImplicitParamTy, const CallExpr *E, StructorType Type)
Definition: CGExprCXX.cpp:85
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition: ExprObjC.h:474
void EmitFunctionBody(FunctionArgList &Args, const Stmt *Body)
void StartThunk(llvm::Function *Fn, GlobalDecl GD, const CGFunctionInfo &FnInfo)
Definition: CGVTables.cpp:206
LValue EmitConditionalOperatorLValue(const AbstractConditionalOperator *E)
Definition: CGExpr.cpp:2867
void EmitStopPoint(const Stmt *S)
EmitStopPoint - Emit a debug stoppoint if we are emitting debug info.
Definition: CGStmt.cpp:35
void InitializeVTablePointer(BaseSubobject Base, const CXXRecordDecl *NearestVBase, CharUnits OffsetFromNearestVBase, const CXXRecordDecl *VTableClass)
Definition: CGClass.cpp:1991
static OpaqueValueMappingData bind(CodeGenFunction &CGF, const OpaqueValueExpr *ov, const Expr *e)
X
Definition: SemaDecl.cpp:11429
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...
void EmitCXXAggrConstructorCall(const CXXConstructorDecl *D, const ConstantArrayType *ArrayTy, llvm::Value *ArrayPtr, const CXXConstructExpr *E, bool ZeroInitialization=false)
Definition: CGClass.cpp:1656
void unprotectFromPeepholes(PeepholeProtection protection)
void EmitOMPReductionClauseInit(const OMPExecutableDirective &D, OMPPrivateScope &PrivateScope)
Emit initial code for reduction variables. Creates reduction copies and initializes them with the val...
llvm::Value * BuildAppleKextVirtualCall(const CXXMethodDecl *MD, NestedNameSpecifier *Qual, llvm::Type *Ty)
Definition: CGCXX.cpp:280
void ErrorUnsupported(const Stmt *S, const char *Type)
Represents a C++ struct/union/class.
Definition: DeclCXX.h:285
void EmitIfStmt(const IfStmt &S)
Definition: CGStmt.cpp:520
llvm::Value * EmitObjCCollectionLiteral(const Expr *E, const ObjCMethodDecl *MethodWithObjects)
Definition: CGObjC.cpp:115
void EmitBranch(llvm::BasicBlock *Block)
Definition: CGStmt.cpp:368
llvm::PointerIntPair< llvm::Value *, 1, bool > saved_type
llvm::BasicBlock * getInvokeDest()
void EmitReturnStmt(const ReturnStmt &S)
Definition: CGStmt.cpp:1027
llvm::Function * LookupNeonLLVMIntrinsic(unsigned IntrinsicID, unsigned Modifier, llvm::Type *ArgTy, const CallExpr *E)
Definition: CGBuiltin.cpp:2642
llvm::BasicBlock * getTerminateLandingPad()
getTerminateLandingPad - Return a landing pad that just calls terminate.
llvm::Type * ConvertType(QualType T)
void EmitFunctionProlog(const CGFunctionInfo &FI, llvm::Function *Fn, const FunctionArgList &Args)
Definition: CGCall.cpp:1762
void PopCleanupBlocks(EHScopeStack::stable_iterator OldCleanupStackSize)
Takes the old cleanup stack size and emits the cleanup blocks that have been added.
Definition: CGCleanup.cpp:388
void EmitCXXDeleteExpr(const CXXDeleteExpr *E)
Definition: CGExprCXX.cpp:1610
LValue EmitLValue(const Expr *E)
Definition: CGExpr.cpp:831
void EmitTrapCheck(llvm::Value *Checked)
Create a basic block that will call the trap intrinsic, and emit a conditional branch to it...
Definition: CGExpr.cpp:2398
void EmitLabelStmt(const LabelStmt &S)
Definition: CGStmt.cpp:463
unsigned kind
All of the diagnostics that can be emitted by the frontend.
Definition: DiagnosticIDs.h:43
Represents Objective-C's @try ... @catch ... @finally statement.
Definition: StmtObjC.h:154
llvm::Value * EmitSEHAbnormalTermination()
LValue EmitCompoundLiteralLValue(const CompoundLiteralExpr *E)
Definition: CGExpr.cpp:2824
bool AutoreleaseResult
In ARC, whether we should autorelease the return value.
RValue EmitLoadOfLValue(LValue V, SourceLocation Loc)
Definition: CGExpr.cpp:1316
llvm::Value * EmitARCRetainBlock(llvm::Value *value, bool mandatory)
Definition: CGObjC.cpp:1945
LValue EmitPredefinedLValue(const PredefinedExpr *E)
Definition: CGExpr.cpp:2109
llvm::Value * EmitARCStoreStrongCall(llvm::Value *addr, llvm::Value *value, bool resultIgnored)
Definition: CGObjC.cpp:2069
std::pair< llvm::Value *, QualType > getVLASize(const VariableArrayType *vla)
void generateObjCGetterBody(const ObjCImplementationDecl *classImpl, const ObjCPropertyImplDecl *propImpl, const ObjCMethodDecl *GetterMothodDecl, llvm::Constant *AtomicHelperFn)
Definition: CGObjC.cpp:833
Defines the clang::TargetInfo interface.
void ForceCleanup()
Force the emission of cleanups now, instead of waiting until this object is destroyed.
bool EmitOMPCopyinClause(const OMPExecutableDirective &D)
Emit code for copyin clause in D directive. The next code is generated at the start of outlined funct...
void StartObjCMethod(const ObjCMethodDecl *MD, const ObjCContainerDecl *CD)
Definition: CGObjC.cpp:484
llvm::MDNode * getTBAAInfo(QualType QTy)
void StartBlock(const char *N)
LValue EmitCompoundAssignmentLValue(const CompoundAssignOperator *E)
void EnterSEHTryStmt(const SEHTryStmt &S)
void startOutlinedSEHHelper(CodeGenFunction &ParentCGF, bool IsFilter, const Stmt *OutlinedStmt)
CGCapturedStmtInfo * CapturedStmtInfo
RValue EmitLoadOfBitfieldLValue(LValue LV)
Definition: CGExpr.cpp:1357
void pushStackRestore(CleanupKind kind, llvm::Value *SPMem)
Definition: CGDecl.cpp:1397
void EmitObjCAutoreleasePoolCleanup(llvm::Value *Ptr)
Definition: CGObjC.cpp:2373
This represents '#pragma omp sections' directive.
Definition: StmtOpenMP.h:830
LValue EmitMemberExpr(const MemberExpr *E)
Definition: CGExpr.cpp:2640
stable_iterator getInnermostNormalCleanup() const
Definition: EHScopeStack.h:340
llvm::Value * EmitVAArg(llvm::Value *VAListAddr, QualType Ty)
Definition: CGCall.cpp:3625
void EmitOMPInnerLoop(const Stmt &S, bool RequiresCleanup, const Expr *LoopCond, const Expr *IncExpr, const llvm::function_ref< void(CodeGenFunction &)> &BodyGen, const llvm::function_ref< void(CodeGenFunction &)> &PostIncGen)
Emit inner loop of the worksharing/simd construct.
A reference to a declared variable, function, enum, etc. [C99 6.5.1p2].
Definition: Expr.h:899
RValue EmitBlockCallExpr(const CallExpr *E, ReturnValueSlot ReturnValue)
Definition: CGBlocks.cpp:953
void EmitDestructorBody(FunctionArgList &Args)
EmitDestructorBody - Emits the body of the current destructor.
Definition: CGClass.cpp:1390
bool EmitSimpleStmt(const Stmt *S)
Definition: CGStmt.cpp:252
void ExitCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock=false)
llvm::Value * EmitLoadOfScalar(llvm::Value *Addr, bool Volatile, unsigned Alignment, QualType Ty, SourceLocation Loc, llvm::MDNode *TBAAInfo=nullptr, QualType TBAABaseTy=QualType(), uint64_t TBAAOffset=0)
Definition: CGExpr.cpp:1120
void EmitLifetimeEnd(llvm::Value *Size, llvm::Value *Addr)
Definition: CGDecl.cpp:875
CapturedRegionKind
The different kinds of captured statement.
Definition: CapturedStmt.h:17
void EmitBranchThroughCleanup(JumpDest Dest)
Definition: CGCleanup.cpp:940
void EmitEndEHSpec(const Decl *D)
EmitEndEHSpec - Emit the end of the exception spec.
static AggValueSlot forAddr(llvm::Value *addr, CharUnits align, Qualifiers quals, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, IsAliased_t isAliased, IsZeroed_t isZeroed=IsNotZeroed)
Definition: CGValue.h:424
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:2213
llvm::Value * GetAddressOfDerivedClass(llvm::Value *Value, const CXXRecordDecl *Derived, CastExpr::path_const_iterator PathBegin, CastExpr::path_const_iterator PathEnd, bool NullCheckValue)
Definition: CGClass.cpp:240
void AllocateBlockCXXThisPointer(const CXXThisExpr *E)
llvm::Value * LoadObjCSelf()
Definition: CGObjC.cpp:1424
#define true
Definition: stdbool.h:32
CodeGenTypes & getTypes() const
void pushLifetimeExtendedDestroy(CleanupKind kind, llvm::Value *addr, QualType type, Destroyer *destroyer, bool useEHCleanupForArray)
Definition: CGDecl.cpp:1401
A trivial tuple used to represent a source range.
AggValueSlot CreateInAllocaTmp(QualType T, const Twine &Name="inalloca")
void EmitObjCAtTryStmt(const ObjCAtTryStmt &S)
Definition: CGObjC.cpp:1725
llvm::BlockAddress * GetAddrOfLabel(const LabelDecl *L)
void EmitWhileStmt(const WhileStmt &S, ArrayRef< const Attr * > Attrs=None)
Definition: CGStmt.cpp:687
This represents '#pragma omp taskyield' directive.
Definition: StmtOpenMP.h:1351
void EmitVarAnnotations(const VarDecl *D, llvm::Value *V)
Emit local annotations for the local variable V, declared by D.
llvm::Value * EmitObjCConsumeObject(QualType T, llvm::Value *Ptr)
Definition: CGObjC.cpp:1759
This represents '#pragma omp parallel sections' directive.
Definition: StmtOpenMP.h:1237
void EmitBlockAfterUses(llvm::BasicBlock *BB)
Definition: CGStmt.cpp:385
void EmitBreakStmt(const BreakStmt &S)
Definition: CGStmt.cpp:1112
RValue EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E, const CXXMethodDecl *MD, ReturnValueSlot ReturnValue)
Definition: CGExprCXX.cpp:335
void EmitObjCAutoreleasePoolStmt(const ObjCAutoreleasePoolStmt &S)
Definition: CGObjC.cpp:2839
static bool containsBreak(const Stmt *S)
bool requiresLandingPad() const
Definition: EHScopeStack.h:329
OpaqueValueMapping(CodeGenFunction &CGF, const OpaqueValueExpr *opaqueValue, LValue lvalue)
void PopCleanupBlock(bool FallThroughIsBranchThrough=false)
Definition: CGCleanup.cpp:583
Represents Objective-C's @autoreleasepool Statement.
Definition: StmtObjC.h:345
LValue EmitStringLiteralLValue(const StringLiteral *E)
Definition: CGExpr.cpp:2099
void EmitOMPTaskDirective(const OMPTaskDirective &S)
void EmitCondBrHints(llvm::LLVMContext &Context, llvm::BranchInst *CondBr, ArrayRef< const Attr * > Attrs)
Definition: CGStmt.cpp:593
void EmitCXXThrowExpr(const CXXThrowExpr *E, bool KeepInsertionPoint=true)
llvm::Value * EmitTargetBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition: CGBuiltin.cpp:1859
void BuildBlockRelease(llvm::Value *DeclPtr, BlockFieldFlags flags)
Definition: CGBlocks.cpp:2233
llvm::SmallVector< const JumpDest *, 2 > SEHTryEpilogueStack
llvm::Value * EmitSystemZBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition: CGBuiltin.cpp:6857
bool Privatize()
Privatizes local variables previously registered as private. Registration is separate from the actual...
void EmitMustTailThunk(const CXXMethodDecl *MD, llvm::Value *AdjustedThisPtr, llvm::Value *Callee)
Emit a musttail call for a thunk with a potentially adjusted this pointer.
Definition: CGVTables.cpp:326
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Definition: Type.h:5043
llvm::Value * EmitObjCSelectorExpr(const ObjCSelectorExpr *E)
Emit a selector.
Definition: CGObjC.cpp:237
llvm::Value * BuildAppleKextVirtualDestructorCall(const CXXDestructorDecl *DD, CXXDtorType Type, const CXXRecordDecl *RD)
Definition: CGCXX.cpp:301
llvm::Value * EmitObjCProtocolExpr(const ObjCProtocolExpr *E)
Definition: CGObjC.cpp:245
static unsigned getAccessedFieldNo(unsigned Idx, const llvm::Constant *Elts)
Definition: CGExpr.cpp:464