clang  3.9.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/ExprOpenMP.h"
28 #include "clang/AST/Type.h"
29 #include "clang/Basic/ABI.h"
32 #include "clang/Basic/TargetInfo.h"
34 #include "llvm/ADT/ArrayRef.h"
35 #include "llvm/ADT/DenseMap.h"
36 #include "llvm/ADT/SmallVector.h"
37 #include "llvm/IR/ValueHandle.h"
38 #include "llvm/Support/Debug.h"
39 #include "llvm/Transforms/Utils/SanitizerStats.h"
40 
41 namespace llvm {
42 class BasicBlock;
43 class LLVMContext;
44 class MDNode;
45 class Module;
46 class SwitchInst;
47 class Twine;
48 class Value;
49 class CallSite;
50 }
51 
52 namespace clang {
53 class ASTContext;
54 class BlockDecl;
55 class CXXDestructorDecl;
56 class CXXForRangeStmt;
57 class CXXTryStmt;
58 class Decl;
59 class LabelDecl;
60 class EnumConstantDecl;
61 class FunctionDecl;
62 class FunctionProtoType;
63 class LabelStmt;
64 class ObjCContainerDecl;
65 class ObjCInterfaceDecl;
66 class ObjCIvarDecl;
67 class ObjCMethodDecl;
68 class ObjCImplementationDecl;
69 class ObjCPropertyImplDecl;
70 class TargetInfo;
71 class VarDecl;
72 class ObjCForCollectionStmt;
73 class ObjCAtTryStmt;
74 class ObjCAtThrowStmt;
75 class ObjCAtSynchronizedStmt;
76 class ObjCAutoreleasePoolStmt;
77 
78 namespace CodeGen {
79 class CodeGenTypes;
80 class CGFunctionInfo;
81 class CGRecordLayout;
82 class CGBlockInfo;
83 class CGCXXABI;
84 class BlockByrefHelpers;
85 class BlockByrefInfo;
86 class BlockFlags;
87 class BlockFieldFlags;
88 class RegionCodeGenTy;
89 class TargetCodeGenInfo;
90 struct OMPTaskDataTy;
91 
92 /// The kind of evaluation to perform on values of a particular
93 /// type. Basically, is the code in CGExprScalar, CGExprComplex, or
94 /// CGExprAgg?
95 ///
96 /// TODO: should vectors maybe be split out into their own thing?
101 };
102 
103 /// CodeGenFunction - This class organizes the per-function state that is used
104 /// while generating LLVM code.
106  CodeGenFunction(const CodeGenFunction &) = delete;
107  void operator=(const CodeGenFunction &) = delete;
108 
109  friend class CGCXXABI;
110 public:
111  /// A jump destination is an abstract label, branching to which may
112  /// require a jump out through normal cleanups.
113  struct JumpDest {
114  JumpDest() : Block(nullptr), ScopeDepth(), Index(0) {}
115  JumpDest(llvm::BasicBlock *Block,
117  unsigned Index)
118  : Block(Block), ScopeDepth(Depth), Index(Index) {}
119 
120  bool isValid() const { return Block != nullptr; }
121  llvm::BasicBlock *getBlock() const { return Block; }
122  EHScopeStack::stable_iterator getScopeDepth() const { return ScopeDepth; }
123  unsigned getDestIndex() const { return Index; }
124 
125  // This should be used cautiously.
127  ScopeDepth = depth;
128  }
129 
130  private:
131  llvm::BasicBlock *Block;
133  unsigned Index;
134  };
135 
136  CodeGenModule &CGM; // Per-module state.
138 
139  typedef std::pair<llvm::Value *, llvm::Value *> ComplexPairTy;
142 
143  /// \brief CGBuilder insert helper. This function is called after an
144  /// instruction is created using Builder.
145  void InsertHelper(llvm::Instruction *I, const llvm::Twine &Name,
146  llvm::BasicBlock *BB,
147  llvm::BasicBlock::iterator InsertPt) const;
148 
149  /// CurFuncDecl - Holds the Decl for the current outermost
150  /// non-closure context.
152  /// CurCodeDecl - This is the inner-most code context, which includes blocks.
156  llvm::Function *CurFn;
157 
158  /// CurGD - The GlobalDecl for the current function being compiled.
160 
161  /// PrologueCleanupDepth - The cleanup depth enclosing all the
162  /// cleanups associated with the parameters.
164 
165  /// ReturnBlock - Unified return block.
167 
168  /// ReturnValue - The temporary alloca to hold the return
169  /// value. This is invalid iff the function has no return value.
171 
172  /// AllocaInsertPoint - This is an instruction in the entry block before which
173  /// we prefer to insert allocas.
174  llvm::AssertingVH<llvm::Instruction> AllocaInsertPt;
175 
176  /// \brief API for captured statement code generation.
178  public:
180  : Kind(K), ThisValue(nullptr), CXXThisFieldDecl(nullptr) {}
183  : Kind(K), ThisValue(nullptr), CXXThisFieldDecl(nullptr) {
184 
188  E = S.capture_end();
189  I != E; ++I, ++Field) {
190  if (I->capturesThis())
191  CXXThisFieldDecl = *Field;
192  else if (I->capturesVariable())
193  CaptureFields[I->getCapturedVar()] = *Field;
194  else if (I->capturesVariableByCopy())
195  CaptureFields[I->getCapturedVar()] = *Field;
196  }
197  }
198 
199  virtual ~CGCapturedStmtInfo();
200 
201  CapturedRegionKind getKind() const { return Kind; }
202 
203  virtual void setContextValue(llvm::Value *V) { ThisValue = V; }
204  // \brief Retrieve the value of the context parameter.
205  virtual llvm::Value *getContextValue() const { return ThisValue; }
206 
207  /// \brief Lookup the captured field decl for a variable.
208  virtual const FieldDecl *lookup(const VarDecl *VD) const {
209  return CaptureFields.lookup(VD);
210  }
211 
212  bool isCXXThisExprCaptured() const { return getThisFieldDecl() != nullptr; }
213  virtual FieldDecl *getThisFieldDecl() const { return CXXThisFieldDecl; }
214 
215  static bool classof(const CGCapturedStmtInfo *) {
216  return true;
217  }
218 
219  /// \brief Emit the captured statement body.
220  virtual void EmitBody(CodeGenFunction &CGF, const Stmt *S) {
222  CGF.EmitStmt(S);
223  }
224 
225  /// \brief Get the name of the capture helper.
226  virtual StringRef getHelperName() const { return "__captured_stmt"; }
227 
228  private:
229  /// \brief The kind of captured statement being generated.
231 
232  /// \brief Keep the map between VarDecl and FieldDecl.
233  llvm::SmallDenseMap<const VarDecl *, FieldDecl *> CaptureFields;
234 
235  /// \brief The base address of the captured record, passed in as the first
236  /// argument of the parallel region function.
237  llvm::Value *ThisValue;
238 
239  /// \brief Captured 'this' type.
240  FieldDecl *CXXThisFieldDecl;
241  };
243 
244  /// \brief RAII for correct setting/restoring of CapturedStmtInfo.
246  private:
247  CodeGenFunction &CGF;
248  CGCapturedStmtInfo *PrevCapturedStmtInfo;
249  public:
251  CGCapturedStmtInfo *NewCapturedStmtInfo)
252  : CGF(CGF), PrevCapturedStmtInfo(CGF.CapturedStmtInfo) {
253  CGF.CapturedStmtInfo = NewCapturedStmtInfo;
254  }
255  ~CGCapturedStmtRAII() { CGF.CapturedStmtInfo = PrevCapturedStmtInfo; }
256  };
257 
258  /// \brief Sanitizers enabled for this function.
260 
261  /// \brief True if CodeGen currently emits code implementing sanitizer checks.
263 
264  /// \brief RAII object to set/unset CodeGenFunction::IsSanitizerScope.
266  CodeGenFunction *CGF;
267  public:
269  ~SanitizerScope();
270  };
271 
272  /// In C++, whether we are code generating a thunk. This controls whether we
273  /// should emit cleanups.
275 
276  /// In ARC, whether we should autorelease the return value.
278 
279  /// Whether we processed a Microsoft-style asm block during CodeGen. These can
280  /// potentially set the return value.
282 
283  const FunctionDecl *CurSEHParent = nullptr;
284 
285  /// True if the current function is an outlined SEH helper. This can be a
286  /// finally block or filter expression.
288 
291 
292  llvm::DenseMap<const VarDecl *, FieldDecl *> LambdaCaptureFields;
294 
295  /// \brief A mapping from NRVO variables to the flags used to indicate
296  /// when the NRVO has been applied to this variable.
297  llvm::DenseMap<const VarDecl *, llvm::Value *> NRVOFlags;
298 
302 
303  llvm::Instruction *CurrentFuncletPad = nullptr;
304 
305  class CallLifetimeEnd final : public EHScopeStack::Cleanup {
306  llvm::Value *Addr;
307  llvm::Value *Size;
308 
309  public:
311  : Addr(addr.getPointer()), Size(size) {}
312 
313  void Emit(CodeGenFunction &CGF, Flags flags) override {
314  CGF.EmitLifetimeEnd(Size, Addr);
315  }
316  };
317 
318  /// Header for data within LifetimeExtendedCleanupStack.
320  /// The size of the following cleanup object.
321  unsigned Size;
322  /// The kind of cleanup to push: a value from the CleanupKind enumeration.
324 
325  size_t getSize() const { return Size; }
326  CleanupKind getKind() const { return Kind; }
327  };
328 
329  /// i32s containing the indexes of the cleanup destinations.
330  llvm::AllocaInst *NormalCleanupDest;
331 
333 
334  /// FirstBlockInfo - The head of a singly-linked-list of block layouts.
336 
337  /// EHResumeBlock - Unified block containing a call to llvm.eh.resume.
338  llvm::BasicBlock *EHResumeBlock;
339 
340  /// The exception slot. All landing pads write the current exception pointer
341  /// into this alloca.
343 
344  /// The selector slot. Under the MandatoryCleanup model, all landing pads
345  /// write the current selector value into this alloca.
346  llvm::AllocaInst *EHSelectorSlot;
347 
348  /// A stack of exception code slots. Entering an __except block pushes a slot
349  /// on the stack and leaving pops one. The __exception_code() intrinsic loads
350  /// a value from the top of the stack.
352 
353  /// Value returned by __exception_info intrinsic.
354  llvm::Value *SEHInfo = nullptr;
355 
356  /// Emits a landing pad for the current EH stack.
357  llvm::BasicBlock *EmitLandingPad();
358 
359  llvm::BasicBlock *getInvokeDestImpl();
360 
361  template <class T>
363  return DominatingValue<T>::save(*this, value);
364  }
365 
366 public:
367  /// ObjCEHValueStack - Stack of Objective-C exception values, used for
368  /// rethrows.
370 
371  /// A class controlling the emission of a finally block.
372  class FinallyInfo {
373  /// Where the catchall's edge through the cleanup should go.
374  JumpDest RethrowDest;
375 
376  /// A function to call to enter the catch.
377  llvm::Constant *BeginCatchFn;
378 
379  /// An i1 variable indicating whether or not the @finally is
380  /// running for an exception.
381  llvm::AllocaInst *ForEHVar;
382 
383  /// An i8* variable into which the exception pointer to rethrow
384  /// has been saved.
385  llvm::AllocaInst *SavedExnVar;
386 
387  public:
388  void enter(CodeGenFunction &CGF, const Stmt *Finally,
389  llvm::Constant *beginCatchFn, llvm::Constant *endCatchFn,
390  llvm::Constant *rethrowFn);
391  void exit(CodeGenFunction &CGF);
392  };
393 
394  /// Returns true inside SEH __try blocks.
395  bool isSEHTryScope() const { return !SEHTryEpilogueStack.empty(); }
396 
397  /// Returns true while emitting a cleanuppad.
398  bool isCleanupPadScope() const {
399  return CurrentFuncletPad && isa<llvm::CleanupPadInst>(CurrentFuncletPad);
400  }
401 
402  /// pushFullExprCleanup - Push a cleanup to be run at the end of the
403  /// current full-expression. Safe against the possibility that
404  /// we're currently inside a conditionally-evaluated expression.
405  template <class T, class... As>
407  // If we're not in a conditional branch, or if none of the
408  // arguments requires saving, then use the unconditional cleanup.
409  if (!isInConditionalBranch())
410  return EHStack.pushCleanup<T>(kind, A...);
411 
412  // Stash values in a tuple so we can guarantee the order of saves.
413  typedef std::tuple<typename DominatingValue<As>::saved_type...> SavedTuple;
414  SavedTuple Saved{saveValueInCond(A)...};
415 
416  typedef EHScopeStack::ConditionalCleanup<T, As...> CleanupType;
417  EHStack.pushCleanupTuple<CleanupType>(kind, Saved);
419  }
420 
421  /// \brief Queue a cleanup to be pushed after finishing the current
422  /// full-expression.
423  template <class T, class... As>
425  assert(!isInConditionalBranch() && "can't defer conditional cleanup");
426 
427  LifetimeExtendedCleanupHeader Header = { sizeof(T), Kind };
428 
429  size_t OldSize = LifetimeExtendedCleanupStack.size();
431  LifetimeExtendedCleanupStack.size() + sizeof(Header) + Header.Size);
432 
433  static_assert(sizeof(Header) % llvm::AlignOf<T>::Alignment == 0,
434  "Cleanup will be allocated on misaligned address");
435  char *Buffer = &LifetimeExtendedCleanupStack[OldSize];
437  new (Buffer + sizeof(Header)) T(A...);
438  }
439 
440  /// Set up the last cleaup that was pushed as a conditional
441  /// full-expression cleanup.
442  void initFullExprCleanup();
443 
444  /// PushDestructorCleanup - Push a cleanup to call the
445  /// complete-object destructor of an object of the given type at the
446  /// given address. Does nothing if T is not a C++ class type with a
447  /// non-trivial destructor.
448  void PushDestructorCleanup(QualType T, Address Addr);
449 
450  /// PushDestructorCleanup - Push a cleanup to call the
451  /// complete-object variant of the given destructor on the object at
452  /// the given address.
453  void PushDestructorCleanup(const CXXDestructorDecl *Dtor, Address Addr);
454 
455  /// PopCleanupBlock - Will pop the cleanup entry on the stack and
456  /// process all branch fixups.
457  void PopCleanupBlock(bool FallThroughIsBranchThrough = false);
458 
459  /// DeactivateCleanupBlock - Deactivates the given cleanup block.
460  /// The block cannot be reactivated. Pops it if it's the top of the
461  /// stack.
462  ///
463  /// \param DominatingIP - An instruction which is known to
464  /// dominate the current IP (if set) and which lies along
465  /// all paths of execution between the current IP and the
466  /// the point at which the cleanup comes into scope.
468  llvm::Instruction *DominatingIP);
469 
470  /// ActivateCleanupBlock - Activates an initially-inactive cleanup.
471  /// Cannot be used to resurrect a deactivated cleanup.
472  ///
473  /// \param DominatingIP - An instruction which is known to
474  /// dominate the current IP (if set) and which lies along
475  /// all paths of execution between the current IP and the
476  /// the point at which the cleanup comes into scope.
478  llvm::Instruction *DominatingIP);
479 
480  /// \brief Enters a new scope for capturing cleanups, all of which
481  /// will be executed once the scope is exited.
483  EHScopeStack::stable_iterator CleanupStackDepth;
484  size_t LifetimeExtendedCleanupStackSize;
485  bool OldDidCallStackSave;
486  protected:
488  private:
489 
490  RunCleanupsScope(const RunCleanupsScope &) = delete;
491  void operator=(const RunCleanupsScope &) = delete;
492 
493  protected:
495 
496  public:
497  /// \brief Enter a new cleanup scope.
499  : PerformCleanup(true), CGF(CGF)
500  {
501  CleanupStackDepth = CGF.EHStack.stable_begin();
502  LifetimeExtendedCleanupStackSize =
503  CGF.LifetimeExtendedCleanupStack.size();
504  OldDidCallStackSave = CGF.DidCallStackSave;
505  CGF.DidCallStackSave = false;
506  }
507 
508  /// \brief Exit this cleanup scope, emitting any accumulated
509  /// cleanups.
511  if (PerformCleanup) {
512  CGF.DidCallStackSave = OldDidCallStackSave;
513  CGF.PopCleanupBlocks(CleanupStackDepth,
514  LifetimeExtendedCleanupStackSize);
515  }
516  }
517 
518  /// \brief Determine whether this scope requires any cleanups.
519  bool requiresCleanups() const {
520  return CGF.EHStack.stable_begin() != CleanupStackDepth;
521  }
522 
523  /// \brief Force the emission of cleanups now, instead of waiting
524  /// until this object is destroyed.
525  void ForceCleanup() {
526  assert(PerformCleanup && "Already forced cleanup");
527  CGF.DidCallStackSave = OldDidCallStackSave;
528  CGF.PopCleanupBlocks(CleanupStackDepth,
529  LifetimeExtendedCleanupStackSize);
530  PerformCleanup = false;
531  }
532  };
533 
535  SourceRange Range;
537  LexicalScope *ParentScope;
538 
539  LexicalScope(const LexicalScope &) = delete;
540  void operator=(const LexicalScope &) = delete;
541 
542  public:
543  /// \brief Enter a new cleanup scope.
545  : RunCleanupsScope(CGF), Range(Range), ParentScope(CGF.CurLexicalScope) {
546  CGF.CurLexicalScope = this;
547  if (CGDebugInfo *DI = CGF.getDebugInfo())
548  DI->EmitLexicalBlockStart(CGF.Builder, Range.getBegin());
549  }
550 
551  void addLabel(const LabelDecl *label) {
552  assert(PerformCleanup && "adding label to dead scope?");
553  Labels.push_back(label);
554  }
555 
556  /// \brief Exit this cleanup scope, emitting any accumulated
557  /// cleanups.
559  if (CGDebugInfo *DI = CGF.getDebugInfo())
560  DI->EmitLexicalBlockEnd(CGF.Builder, Range.getEnd());
561 
562  // If we should perform a cleanup, force them now. Note that
563  // this ends the cleanup scope before rescoping any labels.
564  if (PerformCleanup) {
565  ApplyDebugLocation DL(CGF, Range.getEnd());
566  ForceCleanup();
567  }
568  }
569 
570  /// \brief Force the emission of cleanups now, instead of waiting
571  /// until this object is destroyed.
572  void ForceCleanup() {
573  CGF.CurLexicalScope = ParentScope;
575 
576  if (!Labels.empty())
577  rescopeLabels();
578  }
579 
580  void rescopeLabels();
581  };
582 
583  typedef llvm::DenseMap<const Decl *, Address> DeclMapTy;
584 
585  /// \brief The scope used to remap some variables as private in the OpenMP
586  /// loop body (or other captured region emitted without outlining), and to
587  /// restore old vars back on exit.
589  DeclMapTy SavedLocals;
590  DeclMapTy SavedPrivates;
591 
592  private:
593  OMPPrivateScope(const OMPPrivateScope &) = delete;
594  void operator=(const OMPPrivateScope &) = delete;
595 
596  public:
597  /// \brief Enter a new OpenMP private scope.
599 
600  /// \brief Registers \a LocalVD variable as a private and apply \a
601  /// PrivateGen function for it to generate corresponding private variable.
602  /// \a PrivateGen returns an address of the generated private variable.
603  /// \return true if the variable is registered as private, false if it has
604  /// been privatized already.
605  bool
606  addPrivate(const VarDecl *LocalVD,
607  llvm::function_ref<Address()> PrivateGen) {
608  assert(PerformCleanup && "adding private to dead scope");
609 
610  // Only save it once.
611  if (SavedLocals.count(LocalVD)) return false;
612 
613  // Copy the existing local entry to SavedLocals.
614  auto it = CGF.LocalDeclMap.find(LocalVD);
615  if (it != CGF.LocalDeclMap.end()) {
616  SavedLocals.insert({LocalVD, it->second});
617  } else {
618  SavedLocals.insert({LocalVD, Address::invalid()});
619  }
620 
621  // Generate the private entry.
622  Address Addr = PrivateGen();
623  QualType VarTy = LocalVD->getType();
624  if (VarTy->isReferenceType()) {
625  Address Temp = CGF.CreateMemTemp(VarTy);
626  CGF.Builder.CreateStore(Addr.getPointer(), Temp);
627  Addr = Temp;
628  }
629  SavedPrivates.insert({LocalVD, Addr});
630 
631  return true;
632  }
633 
634  /// \brief Privatizes local variables previously registered as private.
635  /// Registration is separate from the actual privatization to allow
636  /// initializers use values of the original variables, not the private one.
637  /// This is important, for example, if the private variable is a class
638  /// variable initialized by a constructor that references other private
639  /// variables. But at initialization original variables must be used, not
640  /// private copies.
641  /// \return true if at least one variable was privatized, false otherwise.
642  bool Privatize() {
643  copyInto(SavedPrivates, CGF.LocalDeclMap);
644  SavedPrivates.clear();
645  return !SavedLocals.empty();
646  }
647 
648  void ForceCleanup() {
650  copyInto(SavedLocals, CGF.LocalDeclMap);
651  SavedLocals.clear();
652  }
653 
654  /// \brief Exit scope - all the mapped variables are restored.
656  if (PerformCleanup)
657  ForceCleanup();
658  }
659 
660  /// Checks if the global variable is captured in current function.
661  bool isGlobalVarCaptured(const VarDecl *VD) const {
662  return !VD->isLocalVarDeclOrParm() && CGF.LocalDeclMap.count(VD) > 0;
663  }
664 
665  private:
666  /// Copy all the entries in the source map over the corresponding
667  /// entries in the destination, which must exist.
668  static void copyInto(const DeclMapTy &src, DeclMapTy &dest) {
669  for (auto &pair : src) {
670  if (!pair.second.isValid()) {
671  dest.erase(pair.first);
672  continue;
673  }
674 
675  auto it = dest.find(pair.first);
676  if (it != dest.end()) {
677  it->second = pair.second;
678  } else {
679  dest.insert(pair);
680  }
681  }
682  }
683  };
684 
685  /// \brief Takes the old cleanup stack size and emits the cleanup blocks
686  /// that have been added.
687  void PopCleanupBlocks(EHScopeStack::stable_iterator OldCleanupStackSize);
688 
689  /// \brief Takes the old cleanup stack size and emits the cleanup blocks
690  /// that have been added, then adds all lifetime-extended cleanups from
691  /// the given position to the stack.
692  void PopCleanupBlocks(EHScopeStack::stable_iterator OldCleanupStackSize,
693  size_t OldLifetimeExtendedStackSize);
694 
695  void ResolveBranchFixups(llvm::BasicBlock *Target);
696 
697  /// The given basic block lies in the current EH scope, but may be a
698  /// target of a potentially scope-crossing jump; get a stable handle
699  /// to which we can perform this jump later.
701  return JumpDest(Target,
704  }
705 
706  /// The given basic block lies in the current EH scope, but may be a
707  /// target of a potentially scope-crossing jump; get a stable handle
708  /// to which we can perform this jump later.
709  JumpDest getJumpDestInCurrentScope(StringRef Name = StringRef()) {
711  }
712 
713  /// EmitBranchThroughCleanup - Emit a branch from the current insert
714  /// block through the normal cleanup handling code (if any) and then
715  /// on to \arg Dest.
716  void EmitBranchThroughCleanup(JumpDest Dest);
717 
718  /// isObviouslyBranchWithoutCleanups - Return true if a branch to the
719  /// specified destination obviously has no cleanups to run. 'false' is always
720  /// a conservatively correct answer for this method.
721  bool isObviouslyBranchWithoutCleanups(JumpDest Dest) const;
722 
723  /// popCatchScope - Pops the catch scope at the top of the EHScope
724  /// stack, emitting any required code (other than the catch handlers
725  /// themselves).
726  void popCatchScope();
727 
728  llvm::BasicBlock *getEHResumeBlock(bool isCleanup);
729  llvm::BasicBlock *getEHDispatchBlock(EHScopeStack::stable_iterator scope);
730  llvm::BasicBlock *getMSVCDispatchBlock(EHScopeStack::stable_iterator scope);
731 
732  /// An object to manage conditionally-evaluated expressions.
734  llvm::BasicBlock *StartBB;
735 
736  public:
738  : StartBB(CGF.Builder.GetInsertBlock()) {}
739 
740  void begin(CodeGenFunction &CGF) {
741  assert(CGF.OutermostConditional != this);
742  if (!CGF.OutermostConditional)
743  CGF.OutermostConditional = this;
744  }
745 
746  void end(CodeGenFunction &CGF) {
747  assert(CGF.OutermostConditional != nullptr);
748  if (CGF.OutermostConditional == this)
749  CGF.OutermostConditional = nullptr;
750  }
751 
752  /// Returns a block which will be executed prior to each
753  /// evaluation of the conditional code.
754  llvm::BasicBlock *getStartingBlock() const {
755  return StartBB;
756  }
757  };
758 
759  /// isInConditionalBranch - Return true if we're currently emitting
760  /// one branch or the other of a conditional expression.
761  bool isInConditionalBranch() const { return OutermostConditional != nullptr; }
762 
764  assert(isInConditionalBranch());
765  llvm::BasicBlock *block = OutermostConditional->getStartingBlock();
766  auto store = new llvm::StoreInst(value, addr.getPointer(), &block->back());
767  store->setAlignment(addr.getAlignment().getQuantity());
768  }
769 
770  /// An RAII object to record that we're evaluating a statement
771  /// expression.
773  CodeGenFunction &CGF;
774 
775  /// We have to save the outermost conditional: cleanups in a
776  /// statement expression aren't conditional just because the
777  /// StmtExpr is.
778  ConditionalEvaluation *SavedOutermostConditional;
779 
780  public:
782  : CGF(CGF), SavedOutermostConditional(CGF.OutermostConditional) {
783  CGF.OutermostConditional = nullptr;
784  }
785 
787  CGF.OutermostConditional = SavedOutermostConditional;
788  CGF.EnsureInsertPoint();
789  }
790  };
791 
792  /// An object which temporarily prevents a value from being
793  /// destroyed by aggressive peephole optimizations that assume that
794  /// all uses of a value have been realized in the IR.
796  llvm::Instruction *Inst;
797  friend class CodeGenFunction;
798 
799  public:
800  PeepholeProtection() : Inst(nullptr) {}
801  };
802 
803  /// A non-RAII class containing all the information about a bound
804  /// opaque value. OpaqueValueMapping, below, is a RAII wrapper for
805  /// this which makes individual mappings very simple; using this
806  /// class directly is useful when you have a variable number of
807  /// opaque values or don't want the RAII functionality for some
808  /// reason.
810  const OpaqueValueExpr *OpaqueValue;
811  bool BoundLValue;
813 
815  bool boundLValue)
816  : OpaqueValue(ov), BoundLValue(boundLValue) {}
817  public:
818  OpaqueValueMappingData() : OpaqueValue(nullptr) {}
819 
820  static bool shouldBindAsLValue(const Expr *expr) {
821  // gl-values should be bound as l-values for obvious reasons.
822  // Records should be bound as l-values because IR generation
823  // always keeps them in memory. Expressions of function type
824  // act exactly like l-values but are formally required to be
825  // r-values in C.
826  return expr->isGLValue() ||
827  expr->getType()->isFunctionType() ||
829  }
830 
832  const OpaqueValueExpr *ov,
833  const Expr *e) {
834  if (shouldBindAsLValue(ov))
835  return bind(CGF, ov, CGF.EmitLValue(e));
836  return bind(CGF, ov, CGF.EmitAnyExpr(e));
837  }
838 
840  const OpaqueValueExpr *ov,
841  const LValue &lv) {
842  assert(shouldBindAsLValue(ov));
843  CGF.OpaqueLValues.insert(std::make_pair(ov, lv));
844  return OpaqueValueMappingData(ov, true);
845  }
846 
848  const OpaqueValueExpr *ov,
849  const RValue &rv) {
850  assert(!shouldBindAsLValue(ov));
851  CGF.OpaqueRValues.insert(std::make_pair(ov, rv));
852 
853  OpaqueValueMappingData data(ov, false);
854 
855  // Work around an extremely aggressive peephole optimization in
856  // EmitScalarConversion which assumes that all other uses of a
857  // value are extant.
858  data.Protection = CGF.protectFromPeepholes(rv);
859 
860  return data;
861  }
862 
863  bool isValid() const { return OpaqueValue != nullptr; }
864  void clear() { OpaqueValue = nullptr; }
865 
866  void unbind(CodeGenFunction &CGF) {
867  assert(OpaqueValue && "no data to unbind!");
868 
869  if (BoundLValue) {
870  CGF.OpaqueLValues.erase(OpaqueValue);
871  } else {
872  CGF.OpaqueRValues.erase(OpaqueValue);
873  CGF.unprotectFromPeepholes(Protection);
874  }
875  }
876  };
877 
878  /// An RAII object to set (and then clear) a mapping for an OpaqueValueExpr.
880  CodeGenFunction &CGF;
882 
883  public:
884  static bool shouldBindAsLValue(const Expr *expr) {
886  }
887 
888  /// Build the opaque value mapping for the given conditional
889  /// operator if it's the GNU ?: extension. This is a common
890  /// enough pattern that the convenience operator is really
891  /// helpful.
892  ///
894  const AbstractConditionalOperator *op) : CGF(CGF) {
895  if (isa<ConditionalOperator>(op))
896  // Leave Data empty.
897  return;
898 
899  const BinaryConditionalOperator *e = cast<BinaryConditionalOperator>(op);
901  e->getCommon());
902  }
903 
905  const OpaqueValueExpr *opaqueValue,
906  LValue lvalue)
907  : CGF(CGF), Data(OpaqueValueMappingData::bind(CGF, opaqueValue, lvalue)) {
908  }
909 
911  const OpaqueValueExpr *opaqueValue,
912  RValue rvalue)
913  : CGF(CGF), Data(OpaqueValueMappingData::bind(CGF, opaqueValue, rvalue)) {
914  }
915 
916  void pop() {
917  Data.unbind(CGF);
918  Data.clear();
919  }
920 
922  if (Data.isValid()) Data.unbind(CGF);
923  }
924  };
925 
926 private:
927  CGDebugInfo *DebugInfo;
928  bool DisableDebugInfo;
929 
930  /// DidCallStackSave - Whether llvm.stacksave has been called. Used to avoid
931  /// calling llvm.stacksave for multiple VLAs in the same scope.
932  bool DidCallStackSave;
933 
934  /// IndirectBranch - The first time an indirect goto is seen we create a block
935  /// with an indirect branch. Every time we see the address of a label taken,
936  /// we add the label to the indirect goto. Every subsequent indirect goto is
937  /// codegen'd as a jump to the IndirectBranch's basic block.
938  llvm::IndirectBrInst *IndirectBranch;
939 
940  /// LocalDeclMap - This keeps track of the LLVM allocas or globals for local C
941  /// decls.
942  DeclMapTy LocalDeclMap;
943 
944  /// SizeArguments - If a ParmVarDecl had the pass_object_size attribute, this
945  /// will contain a mapping from said ParmVarDecl to its implicit "object_size"
946  /// parameter.
947  llvm::SmallDenseMap<const ParmVarDecl *, const ImplicitParamDecl *, 2>
948  SizeArguments;
949 
950  /// Track escaped local variables with auto storage. Used during SEH
951  /// outlining to produce a call to llvm.localescape.
952  llvm::DenseMap<llvm::AllocaInst *, int> EscapedLocals;
953 
954  /// LabelMap - This keeps track of the LLVM basic block for each C label.
955  llvm::DenseMap<const LabelDecl*, JumpDest> LabelMap;
956 
957  // BreakContinueStack - This keeps track of where break and continue
958  // statements should jump to.
959  struct BreakContinue {
960  BreakContinue(JumpDest Break, JumpDest Continue)
961  : BreakBlock(Break), ContinueBlock(Continue) {}
962 
963  JumpDest BreakBlock;
964  JumpDest ContinueBlock;
965  };
966  SmallVector<BreakContinue, 8> BreakContinueStack;
967 
968  CodeGenPGO PGO;
969 
970  /// Calculate branch weights appropriate for PGO data
971  llvm::MDNode *createProfileWeights(uint64_t TrueCount, uint64_t FalseCount);
972  llvm::MDNode *createProfileWeights(ArrayRef<uint64_t> Weights);
973  llvm::MDNode *createProfileWeightsForLoop(const Stmt *Cond,
974  uint64_t LoopCount);
975 
976 public:
977  /// Increment the profiler's counter for the given statement.
980  PGO.emitCounterIncrement(Builder, S);
981  PGO.setCurrentStmt(S);
982  }
983 
984  /// Get the profiler's count for the given statement.
985  uint64_t getProfileCount(const Stmt *S) {
986  Optional<uint64_t> Count = PGO.getStmtCount(S);
987  if (!Count.hasValue())
988  return 0;
989  return *Count;
990  }
991 
992  /// Set the profiler's current count.
993  void setCurrentProfileCount(uint64_t Count) {
994  PGO.setCurrentRegionCount(Count);
995  }
996 
997  /// Get the profiler's current count. This is generally the count for the most
998  /// recently incremented counter.
1000  return PGO.getCurrentRegionCount();
1001  }
1002 
1003 private:
1004 
1005  /// SwitchInsn - This is nearest current switch instruction. It is null if
1006  /// current context is not in a switch.
1007  llvm::SwitchInst *SwitchInsn;
1008  /// The branch weights of SwitchInsn when doing instrumentation based PGO.
1009  SmallVector<uint64_t, 16> *SwitchWeights;
1010 
1011  /// CaseRangeBlock - This block holds if condition check for last case
1012  /// statement range in current switch instruction.
1013  llvm::BasicBlock *CaseRangeBlock;
1014 
1015  /// OpaqueLValues - Keeps track of the current set of opaque value
1016  /// expressions.
1017  llvm::DenseMap<const OpaqueValueExpr *, LValue> OpaqueLValues;
1018  llvm::DenseMap<const OpaqueValueExpr *, RValue> OpaqueRValues;
1019 
1020  // VLASizeMap - This keeps track of the associated size for each VLA type.
1021  // We track this by the size expression rather than the type itself because
1022  // in certain situations, like a const qualifier applied to an VLA typedef,
1023  // multiple VLA types can share the same size expression.
1024  // FIXME: Maybe this could be a stack of maps that is pushed/popped as we
1025  // enter/leave scopes.
1026  llvm::DenseMap<const Expr*, llvm::Value*> VLASizeMap;
1027 
1028  /// A block containing a single 'unreachable' instruction. Created
1029  /// lazily by getUnreachableBlock().
1030  llvm::BasicBlock *UnreachableBlock;
1031 
1032  /// Counts of the number return expressions in the function.
1033  unsigned NumReturnExprs;
1034 
1035  /// Count the number of simple (constant) return expressions in the function.
1036  unsigned NumSimpleReturnExprs;
1037 
1038  /// The last regular (non-return) debug location (breakpoint) in the function.
1039  SourceLocation LastStopPoint;
1040 
1041 public:
1042  /// A scope within which we are constructing the fields of an object which
1043  /// might use a CXXDefaultInitExpr. This stashes away a 'this' value to use
1044  /// if we need to evaluate a CXXDefaultInitExpr within the evaluation.
1046  public:
1048  : CGF(CGF), OldCXXDefaultInitExprThis(CGF.CXXDefaultInitExprThis) {
1049  CGF.CXXDefaultInitExprThis = This;
1050  }
1052  CGF.CXXDefaultInitExprThis = OldCXXDefaultInitExprThis;
1053  }
1054 
1055  private:
1056  CodeGenFunction &CGF;
1057  Address OldCXXDefaultInitExprThis;
1058  };
1059 
1060  /// The scope of a CXXDefaultInitExpr. Within this scope, the value of 'this'
1061  /// is overridden to be the object under construction.
1063  public:
1065  : CGF(CGF), OldCXXThisValue(CGF.CXXThisValue),
1066  OldCXXThisAlignment(CGF.CXXThisAlignment) {
1067  CGF.CXXThisValue = CGF.CXXDefaultInitExprThis.getPointer();
1068  CGF.CXXThisAlignment = CGF.CXXDefaultInitExprThis.getAlignment();
1069  }
1071  CGF.CXXThisValue = OldCXXThisValue;
1072  CGF.CXXThisAlignment = OldCXXThisAlignment;
1073  }
1074 
1075  public:
1079  };
1080 
1082  public:
1084  : CGF(CGF), OldCurGD(CGF.CurGD), OldCurFuncDecl(CGF.CurFuncDecl),
1085  OldCurCodeDecl(CGF.CurCodeDecl),
1086  OldCXXABIThisDecl(CGF.CXXABIThisDecl),
1087  OldCXXABIThisValue(CGF.CXXABIThisValue),
1088  OldCXXThisValue(CGF.CXXThisValue),
1089  OldCXXABIThisAlignment(CGF.CXXABIThisAlignment),
1090  OldCXXThisAlignment(CGF.CXXThisAlignment),
1091  OldReturnValue(CGF.ReturnValue), OldFnRetTy(CGF.FnRetTy),
1092  OldCXXInheritedCtorInitExprArgs(
1093  std::move(CGF.CXXInheritedCtorInitExprArgs)) {
1094  CGF.CurGD = GD;
1095  CGF.CurFuncDecl = CGF.CurCodeDecl =
1096  cast<CXXConstructorDecl>(GD.getDecl());
1097  CGF.CXXABIThisDecl = nullptr;
1098  CGF.CXXABIThisValue = nullptr;
1099  CGF.CXXThisValue = nullptr;
1100  CGF.CXXABIThisAlignment = CharUnits();
1101  CGF.CXXThisAlignment = CharUnits();
1102  CGF.ReturnValue = Address::invalid();
1103  CGF.FnRetTy = QualType();
1104  CGF.CXXInheritedCtorInitExprArgs.clear();
1105  }
1107  CGF.CurGD = OldCurGD;
1108  CGF.CurFuncDecl = OldCurFuncDecl;
1109  CGF.CurCodeDecl = OldCurCodeDecl;
1110  CGF.CXXABIThisDecl = OldCXXABIThisDecl;
1111  CGF.CXXABIThisValue = OldCXXABIThisValue;
1112  CGF.CXXThisValue = OldCXXThisValue;
1113  CGF.CXXABIThisAlignment = OldCXXABIThisAlignment;
1114  CGF.CXXThisAlignment = OldCXXThisAlignment;
1115  CGF.ReturnValue = OldReturnValue;
1116  CGF.FnRetTy = OldFnRetTy;
1117  CGF.CXXInheritedCtorInitExprArgs =
1118  std::move(OldCXXInheritedCtorInitExprArgs);
1119  }
1120 
1121  private:
1122  CodeGenFunction &CGF;
1123  GlobalDecl OldCurGD;
1124  const Decl *OldCurFuncDecl;
1125  const Decl *OldCurCodeDecl;
1126  ImplicitParamDecl *OldCXXABIThisDecl;
1127  llvm::Value *OldCXXABIThisValue;
1128  llvm::Value *OldCXXThisValue;
1129  CharUnits OldCXXABIThisAlignment;
1130  CharUnits OldCXXThisAlignment;
1131  Address OldReturnValue;
1132  QualType OldFnRetTy;
1133  CallArgList OldCXXInheritedCtorInitExprArgs;
1134  };
1135 
1136 private:
1137  /// CXXThisDecl - When generating code for a C++ member function,
1138  /// this will hold the implicit 'this' declaration.
1139  ImplicitParamDecl *CXXABIThisDecl;
1140  llvm::Value *CXXABIThisValue;
1141  llvm::Value *CXXThisValue;
1142  CharUnits CXXABIThisAlignment;
1143  CharUnits CXXThisAlignment;
1144 
1145  /// The value of 'this' to use when evaluating CXXDefaultInitExprs within
1146  /// this expression.
1147  Address CXXDefaultInitExprThis = Address::invalid();
1148 
1149  /// The values of function arguments to use when evaluating
1150  /// CXXInheritedCtorInitExprs within this context.
1151  CallArgList CXXInheritedCtorInitExprArgs;
1152 
1153  /// CXXStructorImplicitParamDecl - When generating code for a constructor or
1154  /// destructor, this will hold the implicit argument (e.g. VTT).
1155  ImplicitParamDecl *CXXStructorImplicitParamDecl;
1156  llvm::Value *CXXStructorImplicitParamValue;
1157 
1158  /// OutermostConditional - Points to the outermost active
1159  /// conditional control. This is used so that we know if a
1160  /// temporary should be destroyed conditionally.
1161  ConditionalEvaluation *OutermostConditional;
1162 
1163  /// The current lexical scope.
1164  LexicalScope *CurLexicalScope;
1165 
1166  /// The current source location that should be used for exception
1167  /// handling code.
1168  SourceLocation CurEHLocation;
1169 
1170  /// BlockByrefInfos - For each __block variable, contains
1171  /// information about the layout of the variable.
1172  llvm::DenseMap<const ValueDecl *, BlockByrefInfo> BlockByrefInfos;
1173 
1174  llvm::BasicBlock *TerminateLandingPad;
1175  llvm::BasicBlock *TerminateHandler;
1176  llvm::BasicBlock *TrapBB;
1177 
1178  /// Add a kernel metadata node to the named metadata node 'opencl.kernels'.
1179  /// In the kernel metadata node, reference the kernel function and metadata
1180  /// nodes for its optional attribute qualifiers (OpenCL 1.1 6.7.2):
1181  /// - A node for the vec_type_hint(<type>) qualifier contains string
1182  /// "vec_type_hint", an undefined value of the <type> data type,
1183  /// and a Boolean that is true if the <type> is integer and signed.
1184  /// - A node for the work_group_size_hint(X,Y,Z) qualifier contains string
1185  /// "work_group_size_hint", and three 32-bit integers X, Y and Z.
1186  /// - A node for the reqd_work_group_size(X,Y,Z) qualifier contains string
1187  /// "reqd_work_group_size", and three 32-bit integers X, Y and Z.
1188  void EmitOpenCLKernelMetadata(const FunctionDecl *FD,
1189  llvm::Function *Fn);
1190 
1191 public:
1192  CodeGenFunction(CodeGenModule &cgm, bool suppressNewContext=false);
1193  ~CodeGenFunction();
1194 
1195  CodeGenTypes &getTypes() const { return CGM.getTypes(); }
1196  ASTContext &getContext() const { return CGM.getContext(); }
1198  if (DisableDebugInfo)
1199  return nullptr;
1200  return DebugInfo;
1201  }
1202  void disableDebugInfo() { DisableDebugInfo = true; }
1203  void enableDebugInfo() { DisableDebugInfo = false; }
1204 
1206  return CGM.getCodeGenOpts().OptimizationLevel == 0;
1207  }
1208 
1209  const LangOptions &getLangOpts() const { return CGM.getLangOpts(); }
1210 
1211  /// Returns a pointer to the function's exception object and selector slot,
1212  /// which is assigned in every landing pad.
1215 
1216  /// Returns the contents of the function's exception object and selector
1217  /// slots.
1220 
1222 
1223  llvm::BasicBlock *getUnreachableBlock() {
1224  if (!UnreachableBlock) {
1225  UnreachableBlock = createBasicBlock("unreachable");
1226  new llvm::UnreachableInst(getLLVMContext(), UnreachableBlock);
1227  }
1228  return UnreachableBlock;
1229  }
1230 
1231  llvm::BasicBlock *getInvokeDest() {
1232  if (!EHStack.requiresLandingPad()) return nullptr;
1233  return getInvokeDestImpl();
1234  }
1235 
1236  bool currentFunctionUsesSEHTry() const { return CurSEHParent != nullptr; }
1237 
1238  const TargetInfo &getTarget() const { return Target; }
1239  llvm::LLVMContext &getLLVMContext() { return CGM.getLLVMContext(); }
1240 
1241  //===--------------------------------------------------------------------===//
1242  // Cleanups
1243  //===--------------------------------------------------------------------===//
1244 
1245  typedef void Destroyer(CodeGenFunction &CGF, Address addr, QualType ty);
1246 
1248  Address arrayEndPointer,
1249  QualType elementType,
1250  CharUnits elementAlignment,
1251  Destroyer *destroyer);
1253  llvm::Value *arrayEnd,
1254  QualType elementType,
1255  CharUnits elementAlignment,
1256  Destroyer *destroyer);
1257 
1258  void pushDestroy(QualType::DestructionKind dtorKind,
1259  Address addr, QualType type);
1261  Address addr, QualType type);
1263  Destroyer *destroyer, bool useEHCleanupForArray);
1265  QualType type, Destroyer *destroyer,
1266  bool useEHCleanupForArray);
1267  void pushCallObjectDeleteCleanup(const FunctionDecl *OperatorDelete,
1268  llvm::Value *CompletePtr,
1269  QualType ElementType);
1271  void emitDestroy(Address addr, QualType type, Destroyer *destroyer,
1272  bool useEHCleanupForArray);
1273  llvm::Function *generateDestroyHelper(Address addr, QualType type,
1274  Destroyer *destroyer,
1275  bool useEHCleanupForArray,
1276  const VarDecl *VD);
1278  QualType elementType, CharUnits elementAlign,
1279  Destroyer *destroyer,
1280  bool checkZeroLength, bool useEHCleanup);
1281 
1283 
1284  /// Determines whether an EH cleanup is required to destroy a type
1285  /// with the given destruction kind.
1287  switch (kind) {
1288  case QualType::DK_none:
1289  return false;
1292  return getLangOpts().Exceptions;
1294  return getLangOpts().Exceptions &&
1295  CGM.getCodeGenOpts().ObjCAutoRefCountExceptions;
1296  }
1297  llvm_unreachable("bad destruction kind");
1298  }
1299 
1301  return (needsEHCleanup(kind) ? NormalAndEHCleanup : NormalCleanup);
1302  }
1303 
1304  //===--------------------------------------------------------------------===//
1305  // Objective-C
1306  //===--------------------------------------------------------------------===//
1307 
1308  void GenerateObjCMethod(const ObjCMethodDecl *OMD);
1309 
1310  void StartObjCMethod(const ObjCMethodDecl *MD, const ObjCContainerDecl *CD);
1311 
1312  /// GenerateObjCGetter - Synthesize an Objective-C property getter function.
1314  const ObjCPropertyImplDecl *PID);
1315  void generateObjCGetterBody(const ObjCImplementationDecl *classImpl,
1316  const ObjCPropertyImplDecl *propImpl,
1317  const ObjCMethodDecl *GetterMothodDecl,
1318  llvm::Constant *AtomicHelperFn);
1319 
1321  ObjCMethodDecl *MD, bool ctor);
1322 
1323  /// GenerateObjCSetter - Synthesize an Objective-C property setter function
1324  /// for the given property.
1326  const ObjCPropertyImplDecl *PID);
1327  void generateObjCSetterBody(const ObjCImplementationDecl *classImpl,
1328  const ObjCPropertyImplDecl *propImpl,
1329  llvm::Constant *AtomicHelperFn);
1330 
1331  //===--------------------------------------------------------------------===//
1332  // Block Bits
1333  //===--------------------------------------------------------------------===//
1334 
1337  static void destroyBlockInfos(CGBlockInfo *info);
1338 
1339  llvm::Function *GenerateBlockFunction(GlobalDecl GD,
1340  const CGBlockInfo &Info,
1341  const DeclMapTy &ldm,
1342  bool IsLambdaConversionToBlock);
1343 
1344  llvm::Constant *GenerateCopyHelperFunction(const CGBlockInfo &blockInfo);
1345  llvm::Constant *GenerateDestroyHelperFunction(const CGBlockInfo &blockInfo);
1347  const ObjCPropertyImplDecl *PID);
1349  const ObjCPropertyImplDecl *PID);
1351 
1352  void BuildBlockRelease(llvm::Value *DeclPtr, BlockFieldFlags flags);
1353 
1354  class AutoVarEmission;
1355 
1356  void emitByrefStructureInit(const AutoVarEmission &emission);
1357  void enterByrefCleanup(const AutoVarEmission &emission);
1358 
1359  void setBlockContextParameter(const ImplicitParamDecl *D, unsigned argNum,
1360  llvm::Value *ptr);
1361 
1363  Address GetAddrOfBlockDecl(const VarDecl *var, bool ByRef);
1364 
1365  /// BuildBlockByrefAddress - Computes the location of the
1366  /// data in a variable which is declared as __block.
1367  Address emitBlockByrefAddress(Address baseAddr, const VarDecl *V,
1368  bool followForward = true);
1370  const BlockByrefInfo &info,
1371  bool followForward,
1372  const llvm::Twine &name);
1373 
1374  const BlockByrefInfo &getBlockByrefInfo(const VarDecl *var);
1375 
1377 
1378  void GenerateCode(GlobalDecl GD, llvm::Function *Fn,
1379  const CGFunctionInfo &FnInfo);
1380  /// \brief Emit code for the start of a function.
1381  /// \param Loc The location to be associated with the function.
1382  /// \param StartLoc The location of the function body.
1383  void StartFunction(GlobalDecl GD,
1384  QualType RetTy,
1385  llvm::Function *Fn,
1386  const CGFunctionInfo &FnInfo,
1387  const FunctionArgList &Args,
1389  SourceLocation StartLoc = SourceLocation());
1390 
1392  void EmitDestructorBody(FunctionArgList &Args);
1394  void EmitFunctionBody(FunctionArgList &Args, const Stmt *Body);
1395  void EmitBlockWithFallThrough(llvm::BasicBlock *BB, const Stmt *S);
1396 
1397  void EmitForwardingCallToLambda(const CXXMethodDecl *LambdaCallOperator,
1398  CallArgList &CallArgs);
1403  void EmitAsanPrologueOrEpilogue(bool Prologue);
1404 
1405  /// \brief Emit the unified return block, trying to avoid its emission when
1406  /// possible.
1407  /// \return The debug location of the user written return statement if the
1408  /// return block is is avoided.
1409  llvm::DebugLoc EmitReturnBlock();
1410 
1411  /// FinishFunction - Complete IR generation of the current function. It is
1412  /// legal to call this function even if there is no current insertion point.
1414 
1415  void StartThunk(llvm::Function *Fn, GlobalDecl GD,
1416  const CGFunctionInfo &FnInfo);
1417 
1418  void EmitCallAndReturnForThunk(llvm::Value *Callee, const ThunkInfo *Thunk);
1419 
1420  void FinishThunk();
1421 
1422  /// Emit a musttail call for a thunk with a potentially adjusted this pointer.
1423  void EmitMustTailThunk(const CXXMethodDecl *MD, llvm::Value *AdjustedThisPtr,
1424  llvm::Value *Callee);
1425 
1426  /// Generate a thunk for the given method.
1427  void generateThunk(llvm::Function *Fn, const CGFunctionInfo &FnInfo,
1428  GlobalDecl GD, const ThunkInfo &Thunk);
1429 
1430  llvm::Function *GenerateVarArgsThunk(llvm::Function *Fn,
1431  const CGFunctionInfo &FnInfo,
1432  GlobalDecl GD, const ThunkInfo &Thunk);
1433 
1435  FunctionArgList &Args);
1436 
1437  void EmitInitializerForField(FieldDecl *Field, LValue LHS, Expr *Init,
1438  ArrayRef<VarDecl *> ArrayIndexes);
1439 
1440  /// Struct with all informations about dynamic [sub]class needed to set vptr.
1441  struct VPtr {
1446  };
1447 
1448  /// Initialize the vtable pointer of the given subobject.
1449  void InitializeVTablePointer(const VPtr &vptr);
1450 
1452 
1453  typedef llvm::SmallPtrSet<const CXXRecordDecl *, 4> VisitedVirtualBasesSetTy;
1454  VPtrsVector getVTablePointers(const CXXRecordDecl *VTableClass);
1455 
1456  void getVTablePointers(BaseSubobject Base, const CXXRecordDecl *NearestVBase,
1457  CharUnits OffsetFromNearestVBase,
1458  bool BaseIsNonVirtualPrimaryBase,
1459  const CXXRecordDecl *VTableClass,
1460  VisitedVirtualBasesSetTy &VBases, VPtrsVector &vptrs);
1461 
1462  void InitializeVTablePointers(const CXXRecordDecl *ClassDecl);
1463 
1464  /// GetVTablePtr - Return the Value of the vtable pointer member pointed
1465  /// to by This.
1466  llvm::Value *GetVTablePtr(Address This, llvm::Type *VTableTy,
1467  const CXXRecordDecl *VTableClass);
1468 
1475  };
1476 
1477  /// \brief Derived is the presumed address of an object of type T after a
1478  /// cast. If T is a polymorphic class type, emit a check that the virtual
1479  /// table for Derived belongs to a class derived from T.
1481  bool MayBeNull, CFITypeCheckKind TCK,
1482  SourceLocation Loc);
1483 
1484  /// EmitVTablePtrCheckForCall - Virtual method MD is being called via VTable.
1485  /// If vptr CFI is enabled, emit a check that VTable is valid.
1486  void EmitVTablePtrCheckForCall(const CXXRecordDecl *RD, llvm::Value *VTable,
1487  CFITypeCheckKind TCK, SourceLocation Loc);
1488 
1489  /// EmitVTablePtrCheck - Emit a check that VTable is a valid virtual table for
1490  /// RD using llvm.type.test.
1491  void EmitVTablePtrCheck(const CXXRecordDecl *RD, llvm::Value *VTable,
1492  CFITypeCheckKind TCK, SourceLocation Loc);
1493 
1494  /// If whole-program virtual table optimization is enabled, emit an assumption
1495  /// that VTable is a member of RD's type identifier. Or, if vptr CFI is
1496  /// enabled, emit a check that VTable is a member of RD's type identifier.
1498  llvm::Value *VTable, SourceLocation Loc);
1499 
1500  /// Returns whether we should perform a type checked load when loading a
1501  /// virtual function for virtual calls to members of RD. This is generally
1502  /// true when both vcall CFI and whole-program-vtables are enabled.
1504 
1505  /// Emit a type checked load from the given vtable.
1507  uint64_t VTableByteOffset);
1508 
1509  /// CanDevirtualizeMemberFunctionCalls - Checks whether virtual calls on given
1510  /// expr can be devirtualized.
1512  const CXXMethodDecl *MD);
1513 
1514  /// EnterDtorCleanups - Enter the cleanups necessary to complete the
1515  /// given phase of destruction for a destructor. The end result
1516  /// should call destructors on members and base classes in reverse
1517  /// order of their construction.
1519 
1520  /// ShouldInstrumentFunction - Return true if the current function should be
1521  /// instrumented with __cyg_profile_func_* calls
1522  bool ShouldInstrumentFunction();
1523 
1524  /// ShouldXRayInstrument - Return true if the current function should be
1525  /// instrumented with XRay nop sleds.
1526  bool ShouldXRayInstrumentFunction() const;
1527 
1528  /// EmitFunctionInstrumentation - Emit LLVM code to call the specified
1529  /// instrumentation function with the current function and the call site, if
1530  /// function instrumentation is enabled.
1531  void EmitFunctionInstrumentation(const char *Fn);
1532 
1533  /// EmitMCountInstrumentation - Emit call to .mcount.
1535 
1536  /// EmitFunctionProlog - Emit the target specific LLVM code to load the
1537  /// arguments for the given function. This is also responsible for naming the
1538  /// LLVM function arguments.
1539  void EmitFunctionProlog(const CGFunctionInfo &FI,
1540  llvm::Function *Fn,
1541  const FunctionArgList &Args);
1542 
1543  /// EmitFunctionEpilog - Emit the target specific LLVM code to return the
1544  /// given temporary.
1545  void EmitFunctionEpilog(const CGFunctionInfo &FI, bool EmitRetDbgLoc,
1546  SourceLocation EndLoc);
1547 
1548  /// EmitStartEHSpec - Emit the start of the exception spec.
1549  void EmitStartEHSpec(const Decl *D);
1550 
1551  /// EmitEndEHSpec - Emit the end of the exception spec.
1552  void EmitEndEHSpec(const Decl *D);
1553 
1554  /// getTerminateLandingPad - Return a landing pad that just calls terminate.
1555  llvm::BasicBlock *getTerminateLandingPad();
1556 
1557  /// getTerminateHandler - Return a handler (not a landing pad, just
1558  /// a catch handler) that just calls terminate. This is used when
1559  /// a terminate scope encloses a try.
1560  llvm::BasicBlock *getTerminateHandler();
1561 
1565  return ConvertType(getContext().getTypeDeclType(T));
1566  }
1567 
1568  /// LoadObjCSelf - Load the value of self. This function is only valid while
1569  /// generating code for an Objective-C method.
1571 
1572  /// TypeOfSelfObject - Return type of object that this self represents.
1574 
1575  /// hasAggregateLLVMType - Return true if the specified AST type will map into
1576  /// an aggregate LLVM type or is void.
1578 
1580  return getEvaluationKind(T) == TEK_Scalar;
1581  }
1582 
1584  return getEvaluationKind(T) == TEK_Aggregate;
1585  }
1586 
1587  /// createBasicBlock - Create an LLVM basic block.
1588  llvm::BasicBlock *createBasicBlock(const Twine &name = "",
1589  llvm::Function *parent = nullptr,
1590  llvm::BasicBlock *before = nullptr) {
1591 #ifdef NDEBUG
1592  return llvm::BasicBlock::Create(getLLVMContext(), "", parent, before);
1593 #else
1594  return llvm::BasicBlock::Create(getLLVMContext(), name, parent, before);
1595 #endif
1596  }
1597 
1598  /// getBasicBlockForLabel - Return the LLVM basicblock that the specified
1599  /// label maps to.
1600  JumpDest getJumpDestForLabel(const LabelDecl *S);
1601 
1602  /// SimplifyForwardingBlocks - If the given basic block is only a branch to
1603  /// another basic block, simplify it. This assumes that no other code could
1604  /// potentially reference the basic block.
1605  void SimplifyForwardingBlocks(llvm::BasicBlock *BB);
1606 
1607  /// EmitBlock - Emit the given block \arg BB and set it as the insert point,
1608  /// adding a fall-through branch from the current insert block if
1609  /// necessary. It is legal to call this function even if there is no current
1610  /// insertion point.
1611  ///
1612  /// IsFinished - If true, indicates that the caller has finished emitting
1613  /// branches to the given block and does not expect to emit code into it. This
1614  /// means the block can be ignored if it is unreachable.
1615  void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false);
1616 
1617  /// EmitBlockAfterUses - Emit the given block somewhere hopefully
1618  /// near its uses, and leave the insertion point in it.
1619  void EmitBlockAfterUses(llvm::BasicBlock *BB);
1620 
1621  /// EmitBranch - Emit a branch to the specified basic block from the current
1622  /// insert block, taking care to avoid creation of branches from dummy
1623  /// blocks. It is legal to call this function even if there is no current
1624  /// insertion point.
1625  ///
1626  /// This function clears the current insertion point. The caller should follow
1627  /// calls to this function with calls to Emit*Block prior to generation new
1628  /// code.
1629  void EmitBranch(llvm::BasicBlock *Block);
1630 
1631  /// HaveInsertPoint - True if an insertion point is defined. If not, this
1632  /// indicates that the current code being emitted is unreachable.
1633  bool HaveInsertPoint() const {
1634  return Builder.GetInsertBlock() != nullptr;
1635  }
1636 
1637  /// EnsureInsertPoint - Ensure that an insertion point is defined so that
1638  /// emitted IR has a place to go. Note that by definition, if this function
1639  /// creates a block then that block is unreachable; callers may do better to
1640  /// detect when no insertion point is defined and simply skip IR generation.
1642  if (!HaveInsertPoint())
1644  }
1645 
1646  /// ErrorUnsupported - Print out an error that codegen doesn't support the
1647  /// specified stmt yet.
1648  void ErrorUnsupported(const Stmt *S, const char *Type);
1649 
1650  //===--------------------------------------------------------------------===//
1651  // Helpers
1652  //===--------------------------------------------------------------------===//
1653 
1655  AlignmentSource AlignSource = AlignmentSource::Type) {
1656  return LValue::MakeAddr(Addr, T, getContext(), AlignSource,
1657  CGM.getTBAAInfo(T));
1658  }
1659 
1661  AlignmentSource AlignSource = AlignmentSource::Type) {
1662  return LValue::MakeAddr(Address(V, Alignment), T, getContext(),
1663  AlignSource, CGM.getTBAAInfo(T));
1664  }
1665 
1669  AlignmentSource *Source = nullptr,
1670  bool forPointeeType = false);
1672  AlignmentSource *Source = nullptr);
1673 
1675  AlignmentSource *Source = nullptr);
1677 
1678  Address EmitLoadOfPointer(Address Ptr, const PointerType *PtrTy,
1679  AlignmentSource *Source = nullptr);
1681 
1682  /// CreateTempAlloca - This creates a alloca and inserts it into the entry
1683  /// block. The caller is responsible for setting an appropriate alignment on
1684  /// the alloca.
1685  llvm::AllocaInst *CreateTempAlloca(llvm::Type *Ty,
1686  const Twine &Name = "tmp");
1688  const Twine &Name = "tmp");
1689 
1690  /// CreateDefaultAlignedTempAlloca - This creates an alloca with the
1691  /// default ABI alignment of the given LLVM type.
1692  ///
1693  /// IMPORTANT NOTE: This is *not* generally the right alignment for
1694  /// any given AST type that happens to have been lowered to the
1695  /// given IR type. This should only ever be used for function-local,
1696  /// IR-driven manipulations like saving and restoring a value. Do
1697  /// not hand this address off to arbitrary IRGen routines, and especially
1698  /// do not pass it as an argument to a function that might expect a
1699  /// properly ABI-aligned value.
1701  const Twine &Name = "tmp");
1702 
1703  /// InitTempAlloca - Provide an initial value for the given alloca which
1704  /// will be observable at all locations in the function.
1705  ///
1706  /// The address should be something that was returned from one of
1707  /// the CreateTempAlloca or CreateMemTemp routines, and the
1708  /// initializer must be valid in the entry block (i.e. it must
1709  /// either be a constant or an argument value).
1710  void InitTempAlloca(Address Alloca, llvm::Value *Value);
1711 
1712  /// CreateIRTemp - Create a temporary IR object of the given type, with
1713  /// appropriate alignment. This routine should only be used when an temporary
1714  /// value needs to be stored into an alloca (for example, to avoid explicit
1715  /// PHI construction), but the type is the IR type, not the type appropriate
1716  /// for storing in memory.
1717  ///
1718  /// That is, this is exactly equivalent to CreateMemTemp, but calling
1719  /// ConvertType instead of ConvertTypeForMem.
1720  Address CreateIRTemp(QualType T, const Twine &Name = "tmp");
1721 
1722  /// CreateMemTemp - Create a temporary memory object of the given type, with
1723  /// appropriate alignment.
1724  Address CreateMemTemp(QualType T, const Twine &Name = "tmp");
1725  Address CreateMemTemp(QualType T, CharUnits Align, const Twine &Name = "tmp");
1726 
1727  /// CreateAggTemp - Create a temporary memory object for the given
1728  /// aggregate type.
1729  AggValueSlot CreateAggTemp(QualType T, const Twine &Name = "tmp") {
1731  T.getQualifiers(),
1735  }
1736 
1737  /// Emit a cast to void* in the appropriate address space.
1739 
1740  /// EvaluateExprAsBool - Perform the usual unary conversions on the specified
1741  /// expression and compare the result against zero, returning an Int1Ty value.
1743 
1744  /// EmitIgnoredExpr - Emit an expression in a context which ignores the result.
1745  void EmitIgnoredExpr(const Expr *E);
1746 
1747  /// EmitAnyExpr - Emit code to compute the specified expression which can have
1748  /// any type. The result is returned as an RValue struct. If this is an
1749  /// aggregate expression, the aggloc/agglocvolatile arguments indicate where
1750  /// the result should be returned.
1751  ///
1752  /// \param ignoreResult True if the resulting value isn't used.
1753  RValue EmitAnyExpr(const Expr *E,
1754  AggValueSlot aggSlot = AggValueSlot::ignored(),
1755  bool ignoreResult = false);
1756 
1757  // EmitVAListRef - Emit a "reference" to a va_list; this is either the address
1758  // or the value of the expression, depending on how va_list is defined.
1759  Address EmitVAListRef(const Expr *E);
1760 
1761  /// Emit a "reference" to a __builtin_ms_va_list; this is
1762  /// always the value of the expression, because a __builtin_ms_va_list is a
1763  /// pointer to a char.
1764  Address EmitMSVAListRef(const Expr *E);
1765 
1766  /// EmitAnyExprToTemp - Similary to EmitAnyExpr(), however, the result will
1767  /// always be accessible even if no aggregate location is provided.
1768  RValue EmitAnyExprToTemp(const Expr *E);
1769 
1770  /// EmitAnyExprToMem - Emits the code necessary to evaluate an
1771  /// arbitrary expression into the given memory location.
1772  void EmitAnyExprToMem(const Expr *E, Address Location,
1773  Qualifiers Quals, bool IsInitializer);
1774 
1775  void EmitAnyExprToExn(const Expr *E, Address Addr);
1776 
1777  /// EmitExprAsInit - Emits the code necessary to initialize a
1778  /// location in memory with the given initializer.
1779  void EmitExprAsInit(const Expr *init, const ValueDecl *D, LValue lvalue,
1780  bool capturedByInit);
1781 
1782  /// hasVolatileMember - returns true if aggregate type has a volatile
1783  /// member.
1785  if (const RecordType *RT = T->getAs<RecordType>()) {
1786  const RecordDecl *RD = cast<RecordDecl>(RT->getDecl());
1787  return RD->hasVolatileMember();
1788  }
1789  return false;
1790  }
1791  /// EmitAggregateCopy - Emit an aggregate assignment.
1792  ///
1793  /// The difference to EmitAggregateCopy is that tail padding is not copied.
1794  /// This is required for correctness when assigning non-POD structures in C++.
1795  void EmitAggregateAssign(Address DestPtr, Address SrcPtr,
1796  QualType EltTy) {
1797  bool IsVolatile = hasVolatileMember(EltTy);
1798  EmitAggregateCopy(DestPtr, SrcPtr, EltTy, IsVolatile, true);
1799  }
1800 
1801  void EmitAggregateCopyCtor(Address DestPtr, Address SrcPtr,
1802  QualType DestTy, QualType SrcTy) {
1803  EmitAggregateCopy(DestPtr, SrcPtr, SrcTy, /*IsVolatile=*/false,
1804  /*IsAssignment=*/false);
1805  }
1806 
1807  /// EmitAggregateCopy - Emit an aggregate copy.
1808  ///
1809  /// \param isVolatile - True iff either the source or the destination is
1810  /// volatile.
1811  /// \param isAssignment - If false, allow padding to be copied. This often
1812  /// yields more efficient.
1813  void EmitAggregateCopy(Address DestPtr, Address SrcPtr,
1814  QualType EltTy, bool isVolatile=false,
1815  bool isAssignment = false);
1816 
1817  /// GetAddrOfLocalVar - Return the address of a local variable.
1819  auto it = LocalDeclMap.find(VD);
1820  assert(it != LocalDeclMap.end() &&
1821  "Invalid argument to GetAddrOfLocalVar(), no decl!");
1822  return it->second;
1823  }
1824 
1825  /// getOpaqueLValueMapping - Given an opaque value expression (which
1826  /// must be mapped to an l-value), return its mapping.
1829 
1831  it = OpaqueLValues.find(e);
1832  assert(it != OpaqueLValues.end() && "no mapping for opaque value!");
1833  return it->second;
1834  }
1835 
1836  /// getOpaqueRValueMapping - Given an opaque value expression (which
1837  /// must be mapped to an r-value), return its mapping.
1840 
1842  it = OpaqueRValues.find(e);
1843  assert(it != OpaqueRValues.end() && "no mapping for opaque value!");
1844  return it->second;
1845  }
1846 
1847  /// getAccessedFieldNo - Given an encoded value and a result number, return
1848  /// the input field number being accessed.
1849  static unsigned getAccessedFieldNo(unsigned Idx, const llvm::Constant *Elts);
1850 
1851  llvm::BlockAddress *GetAddrOfLabel(const LabelDecl *L);
1852  llvm::BasicBlock *GetIndirectGotoBlock();
1853 
1854  /// EmitNullInitialization - Generate code to set a value of the given type to
1855  /// null, If the type contains data member pointers, they will be initialized
1856  /// to -1 in accordance with the Itanium C++ ABI.
1857  void EmitNullInitialization(Address DestPtr, QualType Ty);
1858 
1859  /// Emits a call to an LLVM variable-argument intrinsic, either
1860  /// \c llvm.va_start or \c llvm.va_end.
1861  /// \param ArgValue A reference to the \c va_list as emitted by either
1862  /// \c EmitVAListRef or \c EmitMSVAListRef.
1863  /// \param IsStart If \c true, emits a call to \c llvm.va_start; otherwise,
1864  /// calls \c llvm.va_end.
1865  llvm::Value *EmitVAStartEnd(llvm::Value *ArgValue, bool IsStart);
1866 
1867  /// Generate code to get an argument from the passed in pointer
1868  /// and update it accordingly.
1869  /// \param VE The \c VAArgExpr for which to generate code.
1870  /// \param VAListAddr Receives a reference to the \c va_list as emitted by
1871  /// either \c EmitVAListRef or \c EmitMSVAListRef.
1872  /// \returns A pointer to the argument.
1873  // FIXME: We should be able to get rid of this method and use the va_arg
1874  // instruction in LLVM instead once it works well enough.
1875  Address EmitVAArg(VAArgExpr *VE, Address &VAListAddr);
1876 
1877  /// emitArrayLength - Compute the length of an array, even if it's a
1878  /// VLA, and drill down to the base element type.
1879  llvm::Value *emitArrayLength(const ArrayType *arrayType,
1880  QualType &baseType,
1881  Address &addr);
1882 
1883  /// EmitVLASize - Capture all the sizes for the VLA expressions in
1884  /// the given variably-modified type and store them in the VLASizeMap.
1885  ///
1886  /// This function can be called with a null (unreachable) insert point.
1888 
1889  /// getVLASize - Returns an LLVM value that corresponds to the size,
1890  /// in non-variably-sized elements, of a variable length array type,
1891  /// plus that largest non-variably-sized element type. Assumes that
1892  /// the type has already been emitted with EmitVariablyModifiedType.
1893  std::pair<llvm::Value*,QualType> getVLASize(const VariableArrayType *vla);
1894  std::pair<llvm::Value*,QualType> getVLASize(QualType vla);
1895 
1896  /// LoadCXXThis - Load the value of 'this'. This function is only valid while
1897  /// generating code for an C++ member function.
1899  assert(CXXThisValue && "no 'this' value for this function");
1900  return CXXThisValue;
1901  }
1903 
1904  /// LoadCXXVTT - Load the VTT parameter to base constructors/destructors have
1905  /// virtual bases.
1906  // FIXME: Every place that calls LoadCXXVTT is something
1907  // that needs to be abstracted properly.
1909  assert(CXXStructorImplicitParamValue && "no VTT value for this function");
1910  return CXXStructorImplicitParamValue;
1911  }
1912 
1913  /// GetAddressOfBaseOfCompleteClass - Convert the given pointer to a
1914  /// complete class to the given direct base.
1915  Address
1917  const CXXRecordDecl *Derived,
1918  const CXXRecordDecl *Base,
1919  bool BaseIsVirtual);
1920 
1921  static bool ShouldNullCheckClassCastValue(const CastExpr *Cast);
1922 
1923  /// GetAddressOfBaseClass - This function will add the necessary delta to the
1924  /// load of 'this' and returns address of the base class.
1926  const CXXRecordDecl *Derived,
1929  bool NullCheckValue, SourceLocation Loc);
1930 
1932  const CXXRecordDecl *Derived,
1935  bool NullCheckValue);
1936 
1937  /// GetVTTParameter - Return the VTT parameter that should be passed to a
1938  /// base constructor/destructor with virtual bases.
1939  /// FIXME: VTTs are Itanium ABI-specific, so the definition should move
1940  /// to ItaniumCXXABI.cpp together with all the references to VTT.
1941  llvm::Value *GetVTTParameter(GlobalDecl GD, bool ForVirtualBase,
1942  bool Delegating);
1943 
1945  CXXCtorType CtorType,
1946  const FunctionArgList &Args,
1947  SourceLocation Loc);
1948  // It's important not to confuse this and the previous function. Delegating
1949  // constructors are the C++0x feature. The constructor delegate optimization
1950  // is used to reduce duplication in the base and complete consturctors where
1951  // they are substantially the same.
1953  const FunctionArgList &Args);
1954 
1955  /// Emit a call to an inheriting constructor (that is, one that invokes a
1956  /// constructor inherited from a base class) by inlining its definition. This
1957  /// is necessary if the ABI does not support forwarding the arguments to the
1958  /// base class constructor (because they're variadic or similar).
1960  CXXCtorType CtorType,
1961  bool ForVirtualBase,
1962  bool Delegating,
1963  CallArgList &Args);
1964 
1965  /// Emit a call to a constructor inherited from a base class, passing the
1966  /// current constructor's arguments along unmodified (without even making
1967  /// a copy).
1969  bool ForVirtualBase, Address This,
1970  bool InheritedFromVBase,
1971  const CXXInheritedCtorInitExpr *E);
1972 
1974  bool ForVirtualBase, bool Delegating,
1975  Address This, const CXXConstructExpr *E);
1976 
1978  bool ForVirtualBase, bool Delegating,
1979  Address This, CallArgList &Args);
1980 
1981  /// Emit assumption load for all bases. Requires to be be called only on
1982  /// most-derived class and not under construction of the object.
1983  void EmitVTableAssumptionLoads(const CXXRecordDecl *ClassDecl, Address This);
1984 
1985  /// Emit assumption that vptr load == global vtable.
1986  void EmitVTableAssumptionLoad(const VPtr &vptr, Address This);
1987 
1989  Address This, Address Src,
1990  const CXXConstructExpr *E);
1991 
1993  const ArrayType *ArrayTy,
1994  Address ArrayPtr,
1995  const CXXConstructExpr *E,
1996  bool ZeroInitialization = false);
1997 
1999  llvm::Value *NumElements,
2000  Address ArrayPtr,
2001  const CXXConstructExpr *E,
2002  bool ZeroInitialization = false);
2003 
2005 
2007  bool ForVirtualBase, bool Delegating,
2008  Address This);
2009 
2010  void EmitNewArrayInitializer(const CXXNewExpr *E, QualType elementType,
2011  llvm::Type *ElementTy, Address NewPtr,
2012  llvm::Value *NumElements,
2013  llvm::Value *AllocSizeWithoutCookie);
2014 
2015  void EmitCXXTemporary(const CXXTemporary *Temporary, QualType TempType,
2016  Address Ptr);
2017 
2018  llvm::Value *EmitLifetimeStart(uint64_t Size, llvm::Value *Addr);
2019  void EmitLifetimeEnd(llvm::Value *Size, llvm::Value *Addr);
2020 
2022  void EmitCXXDeleteExpr(const CXXDeleteExpr *E);
2023 
2024  void EmitDeleteCall(const FunctionDecl *DeleteFD, llvm::Value *Ptr,
2025  QualType DeleteTy);
2026 
2028  const Expr *Arg, bool IsDelete);
2029 
2033 
2034  /// \brief Situations in which we might emit a check for the suitability of a
2035  /// pointer or glvalue.
2037  /// Checking the operand of a load. Must be suitably sized and aligned.
2039  /// Checking the destination of a store. Must be suitably sized and aligned.
2041  /// Checking the bound value in a reference binding. Must be suitably sized
2042  /// and aligned, but is not required to refer to an object (until the
2043  /// reference is used), per core issue 453.
2045  /// Checking the object expression in a non-static data member access. Must
2046  /// be an object within its lifetime.
2048  /// Checking the 'this' pointer for a call to a non-static member function.
2049  /// Must be an object within its lifetime.
2051  /// Checking the 'this' pointer for a constructor call.
2053  /// Checking the operand of a static_cast to a derived pointer type. Must be
2054  /// null or an object within its lifetime.
2056  /// Checking the operand of a static_cast to a derived reference type. Must
2057  /// be an object within its lifetime.
2059  /// Checking the operand of a cast to a base object. Must be suitably sized
2060  /// and aligned.
2062  /// Checking the operand of a cast to a virtual base object. Must be an
2063  /// object within its lifetime.
2065  };
2066 
2067  /// \brief Whether any type-checking sanitizers are enabled. If \c false,
2068  /// calls to EmitTypeCheck can be skipped.
2069  bool sanitizePerformTypeCheck() const;
2070 
2071  /// \brief Emit a check that \p V is the address of storage of the
2072  /// appropriate size and alignment for an object of type \p Type.
2074  QualType Type, CharUnits Alignment = CharUnits::Zero(),
2075  bool SkipNullCheck = false);
2076 
2077  /// \brief Emit a check that \p Base points into an array object, which
2078  /// we can access at index \p Index. \p Accessed should be \c false if we
2079  /// this expression is used as an lvalue, for instance in "&Arr[Idx]".
2080  void EmitBoundsCheck(const Expr *E, const Expr *Base, llvm::Value *Index,
2081  QualType IndexType, bool Accessed);
2082 
2084  bool isInc, bool isPre);
2086  bool isInc, bool isPre);
2087 
2088  void EmitAlignmentAssumption(llvm::Value *PtrValue, unsigned Alignment,
2089  llvm::Value *OffsetValue = nullptr) {
2090  Builder.CreateAlignmentAssumption(CGM.getDataLayout(), PtrValue, Alignment,
2091  OffsetValue);
2092  }
2093 
2094  //===--------------------------------------------------------------------===//
2095  // Declaration Emission
2096  //===--------------------------------------------------------------------===//
2097 
2098  /// EmitDecl - Emit a declaration.
2099  ///
2100  /// This function can be called with a null (unreachable) insert point.
2101  void EmitDecl(const Decl &D);
2102 
2103  /// EmitVarDecl - Emit a local variable declaration.
2104  ///
2105  /// This function can be called with a null (unreachable) insert point.
2106  void EmitVarDecl(const VarDecl &D);
2107 
2108  void EmitScalarInit(const Expr *init, const ValueDecl *D, LValue lvalue,
2109  bool capturedByInit);
2110  void EmitScalarInit(llvm::Value *init, LValue lvalue);
2111 
2112  typedef void SpecialInitFn(CodeGenFunction &Init, const VarDecl &D,
2113  llvm::Value *Address);
2114 
2115  /// \brief Determine whether the given initializer is trivial in the sense
2116  /// that it requires no code to be generated.
2117  bool isTrivialInitializer(const Expr *Init);
2118 
2119  /// EmitAutoVarDecl - Emit an auto variable declaration.
2120  ///
2121  /// This function can be called with a null (unreachable) insert point.
2122  void EmitAutoVarDecl(const VarDecl &D);
2123 
2125  friend class CodeGenFunction;
2126 
2127  const VarDecl *Variable;
2128 
2129  /// The address of the alloca. Invalid if the variable was emitted
2130  /// as a global constant.
2131  Address Addr;
2132 
2133  llvm::Value *NRVOFlag;
2134 
2135  /// True if the variable is a __block variable.
2136  bool IsByRef;
2137 
2138  /// True if the variable is of aggregate type and has a constant
2139  /// initializer.
2140  bool IsConstantAggregate;
2141 
2142  /// Non-null if we should use lifetime annotations.
2143  llvm::Value *SizeForLifetimeMarkers;
2144 
2145  struct Invalid {};
2146  AutoVarEmission(Invalid) : Variable(nullptr), Addr(Address::invalid()) {}
2147 
2148  AutoVarEmission(const VarDecl &variable)
2149  : Variable(&variable), Addr(Address::invalid()), NRVOFlag(nullptr),
2150  IsByRef(false), IsConstantAggregate(false),
2151  SizeForLifetimeMarkers(nullptr) {}
2152 
2153  bool wasEmittedAsGlobal() const { return !Addr.isValid(); }
2154 
2155  public:
2156  static AutoVarEmission invalid() { return AutoVarEmission(Invalid()); }
2157 
2158  bool useLifetimeMarkers() const {
2159  return SizeForLifetimeMarkers != nullptr;
2160  }
2162  assert(useLifetimeMarkers());
2163  return SizeForLifetimeMarkers;
2164  }
2165 
2166  /// Returns the raw, allocated address, which is not necessarily
2167  /// the address of the object itself.
2169  return Addr;
2170  }
2171 
2172  /// Returns the address of the object within this declaration.
2173  /// Note that this does not chase the forwarding pointer for
2174  /// __block decls.
2176  if (!IsByRef) return Addr;
2177 
2178  return CGF.emitBlockByrefAddress(Addr, Variable, /*forward*/ false);
2179  }
2180  };
2181  AutoVarEmission EmitAutoVarAlloca(const VarDecl &var);
2182  void EmitAutoVarInit(const AutoVarEmission &emission);
2183  void EmitAutoVarCleanups(const AutoVarEmission &emission);
2184  void emitAutoVarTypeCleanup(const AutoVarEmission &emission,
2185  QualType::DestructionKind dtorKind);
2186 
2187  void EmitStaticVarDecl(const VarDecl &D,
2188  llvm::GlobalValue::LinkageTypes Linkage);
2189 
2190  class ParamValue {
2191  llvm::Value *Value;
2192  unsigned Alignment;
2193  ParamValue(llvm::Value *V, unsigned A) : Value(V), Alignment(A) {}
2194  public:
2196  return ParamValue(value, 0);
2197  }
2199  assert(!addr.getAlignment().isZero());
2200  return ParamValue(addr.getPointer(), addr.getAlignment().getQuantity());
2201  }
2202 
2203  bool isIndirect() const { return Alignment != 0; }
2204  llvm::Value *getAnyValue() const { return Value; }
2205 
2207  assert(!isIndirect());
2208  return Value;
2209  }
2210 
2212  assert(isIndirect());
2213  return Address(Value, CharUnits::fromQuantity(Alignment));
2214  }
2215  };
2216 
2217  /// EmitParmDecl - Emit a ParmVarDecl or an ImplicitParamDecl.
2218  void EmitParmDecl(const VarDecl &D, ParamValue Arg, unsigned ArgNo);
2219 
2220  /// protectFromPeepholes - Protect a value that we're intending to
2221  /// store to the side, but which will probably be used later, from
2222  /// aggressive peepholing optimizations that might delete it.
2223  ///
2224  /// Pass the result to unprotectFromPeepholes to declare that
2225  /// protection is no longer required.
2226  ///
2227  /// There's no particular reason why this shouldn't apply to
2228  /// l-values, it's just that no existing peepholes work on pointers.
2229  PeepholeProtection protectFromPeepholes(RValue rvalue);
2230  void unprotectFromPeepholes(PeepholeProtection protection);
2231 
2232  //===--------------------------------------------------------------------===//
2233  // Statement Emission
2234  //===--------------------------------------------------------------------===//
2235 
2236  /// EmitStopPoint - Emit a debug stoppoint if we are emitting debug info.
2237  void EmitStopPoint(const Stmt *S);
2238 
2239  /// EmitStmt - Emit the code for the statement \arg S. It is legal to call
2240  /// this function even if there is no current insertion point.
2241  ///
2242  /// This function may clear the current insertion point; callers should use
2243  /// EnsureInsertPoint if they wish to subsequently generate code without first
2244  /// calling EmitBlock, EmitBranch, or EmitStmt.
2245  void EmitStmt(const Stmt *S);
2246 
2247  /// EmitSimpleStmt - Try to emit a "simple" statement which does not
2248  /// necessarily require an insertion point or debug information; typically
2249  /// because the statement amounts to a jump or a container of other
2250  /// statements.
2251  ///
2252  /// \return True if the statement was handled.
2253  bool EmitSimpleStmt(const Stmt *S);
2254 
2255  Address EmitCompoundStmt(const CompoundStmt &S, bool GetLast = false,
2258  bool GetLast = false,
2259  AggValueSlot AVS =
2261 
2262  /// EmitLabel - Emit the block for the given label. It is legal to call this
2263  /// function even if there is no current insertion point.
2264  void EmitLabel(const LabelDecl *D); // helper for EmitLabelStmt.
2265 
2266  void EmitLabelStmt(const LabelStmt &S);
2267  void EmitAttributedStmt(const AttributedStmt &S);
2268  void EmitGotoStmt(const GotoStmt &S);
2269  void EmitIndirectGotoStmt(const IndirectGotoStmt &S);
2270  void EmitIfStmt(const IfStmt &S);
2271 
2272  void EmitWhileStmt(const WhileStmt &S,
2273  ArrayRef<const Attr *> Attrs = None);
2274  void EmitDoStmt(const DoStmt &S, ArrayRef<const Attr *> Attrs = None);
2275  void EmitForStmt(const ForStmt &S,
2276  ArrayRef<const Attr *> Attrs = None);
2277  void EmitReturnStmt(const ReturnStmt &S);
2278  void EmitDeclStmt(const DeclStmt &S);
2279  void EmitBreakStmt(const BreakStmt &S);
2280  void EmitContinueStmt(const ContinueStmt &S);
2281  void EmitSwitchStmt(const SwitchStmt &S);
2282  void EmitDefaultStmt(const DefaultStmt &S);
2283  void EmitCaseStmt(const CaseStmt &S);
2284  void EmitCaseStmtRange(const CaseStmt &S);
2285  void EmitAsmStmt(const AsmStmt &S);
2286 
2288  void EmitObjCAtTryStmt(const ObjCAtTryStmt &S);
2289  void EmitObjCAtThrowStmt(const ObjCAtThrowStmt &S);
2292 
2293  void EnterCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock = false);
2294  void ExitCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock = false);
2295 
2296  void EmitCXXTryStmt(const CXXTryStmt &S);
2297  void EmitSEHTryStmt(const SEHTryStmt &S);
2298  void EmitSEHLeaveStmt(const SEHLeaveStmt &S);
2299  void EnterSEHTryStmt(const SEHTryStmt &S);
2300  void ExitSEHTryStmt(const SEHTryStmt &S);
2301 
2302  void startOutlinedSEHHelper(CodeGenFunction &ParentCGF, bool IsFilter,
2303  const Stmt *OutlinedStmt);
2304 
2305  llvm::Function *GenerateSEHFilterFunction(CodeGenFunction &ParentCGF,
2306  const SEHExceptStmt &Except);
2307 
2308  llvm::Function *GenerateSEHFinallyFunction(CodeGenFunction &ParentCGF,
2309  const SEHFinallyStmt &Finally);
2310 
2311  void EmitSEHExceptionCodeSave(CodeGenFunction &ParentCGF,
2312  llvm::Value *ParentFP,
2313  llvm::Value *EntryEBP);
2317 
2318  /// Scan the outlined statement for captures from the parent function. For
2319  /// each capture, mark the capture as escaped and emit a call to
2320  /// llvm.localrecover. Insert the localrecover result into the LocalDeclMap.
2321  void EmitCapturedLocals(CodeGenFunction &ParentCGF, const Stmt *OutlinedStmt,
2322  bool IsFilter);
2323 
2324  /// Recovers the address of a local in a parent function. ParentVar is the
2325  /// address of the variable used in the immediate parent function. It can
2326  /// either be an alloca or a call to llvm.localrecover if there are nested
2327  /// outlined functions. ParentFP is the frame pointer of the outermost parent
2328  /// frame.
2330  Address ParentVar,
2331  llvm::Value *ParentFP);
2332 
2333  void EmitCXXForRangeStmt(const CXXForRangeStmt &S,
2334  ArrayRef<const Attr *> Attrs = None);
2335 
2336  /// Returns calculated size of the specified type.
2339  llvm::Function *EmitCapturedStmt(const CapturedStmt &S, CapturedRegionKind K);
2340  llvm::Function *GenerateCapturedStmtFunction(const CapturedStmt &S);
2342  llvm::Function *GenerateOpenMPCapturedStmtFunction(const CapturedStmt &S);
2344  SmallVectorImpl<llvm::Value *> &CapturedVars);
2345  void emitOMPSimpleStore(LValue LVal, RValue RVal, QualType RValTy,
2346  SourceLocation Loc);
2347  /// \brief Perform element by element copying of arrays with type \a
2348  /// OriginalType from \a SrcAddr to \a DestAddr using copying procedure
2349  /// generated by \a CopyGen.
2350  ///
2351  /// \param DestAddr Address of the destination array.
2352  /// \param SrcAddr Address of the source array.
2353  /// \param OriginalType Type of destination and source arrays.
2354  /// \param CopyGen Copying procedure that copies value of single array element
2355  /// to another single array element.
2357  Address DestAddr, Address SrcAddr, QualType OriginalType,
2358  const llvm::function_ref<void(Address, Address)> &CopyGen);
2359  /// \brief Emit proper copying of data from one variable to another.
2360  ///
2361  /// \param OriginalType Original type of the copied variables.
2362  /// \param DestAddr Destination address.
2363  /// \param SrcAddr Source address.
2364  /// \param DestVD Destination variable used in \a CopyExpr (for arrays, has
2365  /// type of the base array element).
2366  /// \param SrcVD Source variable used in \a CopyExpr (for arrays, has type of
2367  /// the base array element).
2368  /// \param Copy Actual copygin expression for copying data from \a SrcVD to \a
2369  /// DestVD.
2370  void EmitOMPCopy(QualType OriginalType,
2371  Address DestAddr, Address SrcAddr,
2372  const VarDecl *DestVD, const VarDecl *SrcVD,
2373  const Expr *Copy);
2374  /// \brief Emit atomic update code for constructs: \a X = \a X \a BO \a E or
2375  /// \a X = \a E \a BO \a E.
2376  ///
2377  /// \param X Value to be updated.
2378  /// \param E Update value.
2379  /// \param BO Binary operation for update operation.
2380  /// \param IsXLHSInRHSPart true if \a X is LHS in RHS part of the update
2381  /// expression, false otherwise.
2382  /// \param AO Atomic ordering of the generated atomic instructions.
2383  /// \param CommonGen Code generator for complex expressions that cannot be
2384  /// expressed through atomicrmw instruction.
2385  /// \returns <true, OldAtomicValue> if simple 'atomicrmw' instruction was
2386  /// generated, <false, RValue::get(nullptr)> otherwise.
2387  std::pair<bool, RValue> EmitOMPAtomicSimpleUpdateExpr(
2388  LValue X, RValue E, BinaryOperatorKind BO, bool IsXLHSInRHSPart,
2389  llvm::AtomicOrdering AO, SourceLocation Loc,
2390  const llvm::function_ref<RValue(RValue)> &CommonGen);
2392  OMPPrivateScope &PrivateScope);
2394  OMPPrivateScope &PrivateScope);
2395  /// \brief Emit code for copyin clause in \a D directive. The next code is
2396  /// generated at the start of outlined functions for directives:
2397  /// \code
2398  /// threadprivate_var1 = master_threadprivate_var1;
2399  /// operator=(threadprivate_var2, master_threadprivate_var2);
2400  /// ...
2401  /// __kmpc_barrier(&loc, global_tid);
2402  /// \endcode
2403  ///
2404  /// \param D OpenMP directive possibly with 'copyin' clause(s).
2405  /// \returns true if at least one copyin variable is found, false otherwise.
2407  /// \brief Emit initial code for lastprivate variables. If some variable is
2408  /// not also firstprivate, then the default initialization is used. Otherwise
2409  /// initialization of this variable is performed by EmitOMPFirstprivateClause
2410  /// method.
2411  ///
2412  /// \param D Directive that may have 'lastprivate' directives.
2413  /// \param PrivateScope Private scope for capturing lastprivate variables for
2414  /// proper codegen in internal captured statement.
2415  ///
2416  /// \returns true if there is at least one lastprivate variable, false
2417  /// otherwise.
2419  OMPPrivateScope &PrivateScope);
2420  /// \brief Emit final copying of lastprivate values to original variables at
2421  /// the end of the worksharing or simd directive.
2422  ///
2423  /// \param D Directive that has at least one 'lastprivate' directives.
2424  /// \param IsLastIterCond Boolean condition that must be set to 'i1 true' if
2425  /// it is the last iteration of the loop code in associated directive, or to
2426  /// 'i1 false' otherwise. If this item is nullptr, no final check is required.
2428  bool NoFinals,
2429  llvm::Value *IsLastIterCond = nullptr);
2430  /// Emit initial code for linear clauses.
2431  void EmitOMPLinearClause(const OMPLoopDirective &D,
2432  CodeGenFunction::OMPPrivateScope &PrivateScope);
2433  /// Emit final code for linear clauses.
2434  /// \param CondGen Optional conditional code for final part of codegen for
2435  /// linear clause.
2437  const OMPLoopDirective &D,
2438  const llvm::function_ref<llvm::Value *(CodeGenFunction &)> &CondGen);
2439  /// \brief Emit initial code for reduction variables. Creates reduction copies
2440  /// and initializes them with the values according to OpenMP standard.
2441  ///
2442  /// \param D Directive (possibly) with the 'reduction' clause.
2443  /// \param PrivateScope Private scope for capturing reduction variables for
2444  /// proper codegen in internal captured statement.
2445  ///
2447  OMPPrivateScope &PrivateScope);
2448  /// \brief Emit final update of reduction values to original variables at
2449  /// the end of the directive.
2450  ///
2451  /// \param D Directive that has at least one 'reduction' directives.
2453  /// \brief Emit initial code for linear variables. Creates private copies
2454  /// and initializes them with the values according to OpenMP standard.
2455  ///
2456  /// \param D Directive (possibly) with the 'linear' clause.
2458 
2459  typedef const llvm::function_ref<void(CodeGenFunction & /*CGF*/,
2460  llvm::Value * /*OutlinedFn*/,
2461  const OMPTaskDataTy & /*Data*/)>
2464  const RegionCodeGenTy &BodyGen,
2465  const TaskGenTy &TaskGen, OMPTaskDataTy &Data);
2466 
2468  void EmitOMPSimdDirective(const OMPSimdDirective &S);
2469  void EmitOMPForDirective(const OMPForDirective &S);
2479  void EmitOMPTaskDirective(const OMPTaskDirective &S);
2493  void
2496  void
2511 
2512  /// Emit outlined function for the target directive.
2513  static std::pair<llvm::Function * /*OutlinedFn*/,
2514  llvm::Constant * /*OutlinedFnID*/>
2516  const OMPTargetDirective &S,
2517  StringRef ParentName,
2518  bool IsOffloadEntry);
2519  /// \brief Emit inner loop of the worksharing/simd construct.
2520  ///
2521  /// \param S Directive, for which the inner loop must be emitted.
2522  /// \param RequiresCleanup true, if directive has some associated private
2523  /// variables.
2524  /// \param LoopCond Bollean condition for loop continuation.
2525  /// \param IncExpr Increment expression for loop control variable.
2526  /// \param BodyGen Generator for the inner body of the inner loop.
2527  /// \param PostIncGen Genrator for post-increment code (required for ordered
2528  /// loop directvies).
2529  void EmitOMPInnerLoop(
2530  const Stmt &S, bool RequiresCleanup, const Expr *LoopCond,
2531  const Expr *IncExpr,
2532  const llvm::function_ref<void(CodeGenFunction &)> &BodyGen,
2533  const llvm::function_ref<void(CodeGenFunction &)> &PostIncGen);
2534 
2536  /// Emit initial code for loop counters of loop-based directives.
2538  OMPPrivateScope &LoopScope);
2539 
2540 private:
2541  /// Helpers for the OpenMP loop directives.
2542  void EmitOMPLoopBody(const OMPLoopDirective &D, JumpDest LoopExit);
2543  void EmitOMPSimdInit(const OMPLoopDirective &D, bool IsMonotonic = false);
2544  void EmitOMPSimdFinal(
2545  const OMPLoopDirective &D,
2546  const llvm::function_ref<llvm::Value *(CodeGenFunction &)> &CondGen);
2547  /// \brief Emit code for the worksharing loop-based directive.
2548  /// \return true, if this construct has any lastprivate clause, false -
2549  /// otherwise.
2550  bool EmitOMPWorksharingLoop(const OMPLoopDirective &S);
2551  void EmitOMPOuterLoop(bool IsMonotonic, bool DynamicOrOrdered,
2552  const OMPLoopDirective &S, OMPPrivateScope &LoopScope, bool Ordered,
2553  Address LB, Address UB, Address ST, Address IL, llvm::Value *Chunk);
2554  void EmitOMPForOuterLoop(const OpenMPScheduleTy &ScheduleKind,
2555  bool IsMonotonic, const OMPLoopDirective &S,
2556  OMPPrivateScope &LoopScope, bool Ordered, Address LB,
2557  Address UB, Address ST, Address IL,
2558  llvm::Value *Chunk);
2559  void EmitOMPDistributeOuterLoop(
2560  OpenMPDistScheduleClauseKind ScheduleKind,
2561  const OMPDistributeDirective &S, OMPPrivateScope &LoopScope,
2562  Address LB, Address UB, Address ST, Address IL, llvm::Value *Chunk);
2563  /// \brief Emit code for sections directive.
2564  void EmitSections(const OMPExecutableDirective &S);
2565 
2566 public:
2567 
2568  //===--------------------------------------------------------------------===//
2569  // LValue Expression Emission
2570  //===--------------------------------------------------------------------===//
2571 
2572  /// GetUndefRValue - Get an appropriate 'undef' rvalue for the given type.
2574 
2575  /// EmitUnsupportedRValue - Emit a dummy r-value using the type of E
2576  /// and issue an ErrorUnsupported style diagnostic (using the
2577  /// provided Name).
2579  const char *Name);
2580 
2581  /// EmitUnsupportedLValue - Emit a dummy l-value using the type of E and issue
2582  /// an ErrorUnsupported style diagnostic (using the provided Name).
2584  const char *Name);
2585 
2586  /// EmitLValue - Emit code to compute a designator that specifies the location
2587  /// of the expression.
2588  ///
2589  /// This can return one of two things: a simple address or a bitfield
2590  /// reference. In either case, the LLVM Value* in the LValue structure is
2591  /// guaranteed to be an LLVM pointer type.
2592  ///
2593  /// If this returns a bitfield reference, nothing about the pointee type of
2594  /// the LLVM value is known: For example, it may not be a pointer to an
2595  /// integer.
2596  ///
2597  /// If this returns a normal address, and if the lvalue's C type is fixed
2598  /// size, this method guarantees that the returned pointer type will point to
2599  /// an LLVM type of the same size of the lvalue's type. If the lvalue has a
2600  /// variable length type, this is not possible.
2601  ///
2602  LValue EmitLValue(const Expr *E);
2603 
2604  /// \brief Same as EmitLValue but additionally we generate checking code to
2605  /// guard against undefined behavior. This is only suitable when we know
2606  /// that the address will be used to access the object.
2607  LValue EmitCheckedLValue(const Expr *E, TypeCheckKind TCK);
2608 
2610  SourceLocation Loc);
2611 
2612  void EmitAtomicInit(Expr *E, LValue lvalue);
2613 
2615 
2618 
2620  llvm::AtomicOrdering AO, bool IsVolatile = false,
2622 
2623  void EmitAtomicStore(RValue rvalue, LValue lvalue, bool isInit);
2624 
2625  void EmitAtomicStore(RValue rvalue, LValue lvalue, llvm::AtomicOrdering AO,
2626  bool IsVolatile, bool isInit);
2627 
2628  std::pair<RValue, llvm::Value *> EmitAtomicCompareExchange(
2629  LValue Obj, RValue Expected, RValue Desired, SourceLocation Loc,
2630  llvm::AtomicOrdering Success =
2631  llvm::AtomicOrdering::SequentiallyConsistent,
2632  llvm::AtomicOrdering Failure =
2633  llvm::AtomicOrdering::SequentiallyConsistent,
2634  bool IsWeak = false, AggValueSlot Slot = AggValueSlot::ignored());
2635 
2636  void EmitAtomicUpdate(LValue LVal, llvm::AtomicOrdering AO,
2637  const llvm::function_ref<RValue(RValue)> &UpdateOp,
2638  bool IsVolatile);
2639 
2640  /// EmitToMemory - Change a scalar value from its value
2641  /// representation to its in-memory representation.
2643 
2644  /// EmitFromMemory - Change a scalar value from its memory
2645  /// representation to its value representation.
2647 
2648  /// EmitLoadOfScalar - Load a scalar value from an address, taking
2649  /// care to appropriately convert from the memory representation to
2650  /// the LLVM value representation.
2651  llvm::Value *EmitLoadOfScalar(Address Addr, bool Volatile, QualType Ty,
2652  SourceLocation Loc,
2653  AlignmentSource AlignSource =
2655  llvm::MDNode *TBAAInfo = nullptr,
2656  QualType TBAABaseTy = QualType(),
2657  uint64_t TBAAOffset = 0,
2658  bool isNontemporal = false);
2659 
2660  /// EmitLoadOfScalar - Load a scalar value from an address, taking
2661  /// care to appropriately convert from the memory representation to
2662  /// the LLVM value representation. The l-value must be a simple
2663  /// l-value.
2665 
2666  /// EmitStoreOfScalar - Store a scalar value to an address, taking
2667  /// care to appropriately convert from the memory representation to
2668  /// the LLVM value representation.
2670  bool Volatile, QualType Ty,
2671  AlignmentSource AlignSource = AlignmentSource::Type,
2672  llvm::MDNode *TBAAInfo = nullptr, bool isInit = false,
2673  QualType TBAABaseTy = QualType(),
2674  uint64_t TBAAOffset = 0, bool isNontemporal = false);
2675 
2676  /// EmitStoreOfScalar - Store a scalar value to an address, taking
2677  /// care to appropriately convert from the memory representation to
2678  /// the LLVM value representation. The l-value must be a simple
2679  /// l-value. The isInit flag indicates whether this is an initialization.
2680  /// If so, atomic qualifiers are ignored and the store is always non-atomic.
2681  void EmitStoreOfScalar(llvm::Value *value, LValue lvalue, bool isInit=false);
2682 
2683  /// EmitLoadOfLValue - Given an expression that represents a value lvalue,
2684  /// this method emits the address of the lvalue, then loads the result as an
2685  /// rvalue, returning the rvalue.
2690 
2691  /// EmitStoreThroughLValue - Store the specified rvalue into the specified
2692  /// lvalue, where both are guaranteed to the have the same type, and that type
2693  /// is 'Ty'.
2694  void EmitStoreThroughLValue(RValue Src, LValue Dst, bool isInit = false);
2697 
2698  /// EmitStoreThroughBitfieldLValue - Store Src into Dst with same constraints
2699  /// as EmitStoreThroughLValue.
2700  ///
2701  /// \param Result [out] - If non-null, this will be set to a Value* for the
2702  /// bit-field contents after the store, appropriate for use as the result of
2703  /// an assignment to the bit-field.
2705  llvm::Value **Result=nullptr);
2706 
2707  /// Emit an l-value for an assignment (simple or compound) of complex type.
2711  llvm::Value *&Result);
2712 
2713  // Note: only available for agg return types
2716  // Note: only available for agg return types
2718  // Note: only available for agg return types
2726  bool Accessed = false);
2728  bool IsLowerBound = true);
2730  LValue EmitMemberExpr(const MemberExpr *E);
2735  LValue EmitCastLValue(const CastExpr *E);
2738 
2740 
2742 
2743  Address EmitArrayToPointerDecay(const Expr *Array,
2744  AlignmentSource *AlignSource = nullptr);
2745 
2747  llvm::PointerIntPair<llvm::Constant*, 1, bool> ValueAndIsReference;
2748  ConstantEmission(llvm::Constant *C, bool isReference)
2749  : ValueAndIsReference(C, isReference) {}
2750  public:
2752  static ConstantEmission forReference(llvm::Constant *C) {
2753  return ConstantEmission(C, true);
2754  }
2755  static ConstantEmission forValue(llvm::Constant *C) {
2756  return ConstantEmission(C, false);
2757  }
2758 
2759  explicit operator bool() const {
2760  return ValueAndIsReference.getOpaqueValue() != nullptr;
2761  }
2762 
2763  bool isReference() const { return ValueAndIsReference.getInt(); }
2765  assert(isReference());
2766  return CGF.MakeNaturalAlignAddrLValue(ValueAndIsReference.getPointer(),
2767  refExpr->getType());
2768  }
2769 
2770  llvm::Constant *getValue() const {
2771  assert(!isReference());
2772  return ValueAndIsReference.getPointer();
2773  }
2774  };
2775 
2776  ConstantEmission tryEmitAsConstant(DeclRefExpr *refExpr);
2777 
2781 
2782  llvm::Value *EmitIvarOffset(const ObjCInterfaceDecl *Interface,
2783  const ObjCIvarDecl *Ivar);
2786 
2787  /// EmitLValueForFieldInitialization - Like EmitLValueForField, except that
2788  /// if the Field is a reference, this will return the address of the reference
2789  /// and not the address of the value stored in the reference.
2791  const FieldDecl* Field);
2792 
2794  llvm::Value* Base, const ObjCIvarDecl *Ivar,
2795  unsigned CVRQualifiers);
2796 
2802 
2808  void EmitDeclRefExprDbgValue(const DeclRefExpr *E, llvm::Constant *Init);
2809 
2810  //===--------------------------------------------------------------------===//
2811  // Scalar Expression Emission
2812  //===--------------------------------------------------------------------===//
2813 
2814  /// EmitCall - Generate a call of the given function, expecting the given
2815  /// result type, and using the given argument list which specifies both the
2816  /// LLVM arguments and the types they were derived from.
2817  RValue EmitCall(const CGFunctionInfo &FnInfo, llvm::Value *Callee,
2819  CGCalleeInfo CalleeInfo = CGCalleeInfo(),
2820  llvm::Instruction **callOrInvoke = nullptr);
2821 
2822  RValue EmitCall(QualType FnType, llvm::Value *Callee, const CallExpr *E,
2823  ReturnValueSlot ReturnValue,
2824  CGCalleeInfo CalleeInfo = CGCalleeInfo(),
2825  llvm::Value *Chain = nullptr);
2826  RValue EmitCallExpr(const CallExpr *E,
2827  ReturnValueSlot ReturnValue = ReturnValueSlot());
2828 
2829  void checkTargetFeatures(const CallExpr *E, const FunctionDecl *TargetDecl);
2830 
2831  llvm::CallInst *EmitRuntimeCall(llvm::Value *callee,
2832  const Twine &name = "");
2833  llvm::CallInst *EmitRuntimeCall(llvm::Value *callee,
2835  const Twine &name = "");
2836  llvm::CallInst *EmitNounwindRuntimeCall(llvm::Value *callee,
2837  const Twine &name = "");
2838  llvm::CallInst *EmitNounwindRuntimeCall(llvm::Value *callee,
2840  const Twine &name = "");
2841 
2842  llvm::CallSite EmitCallOrInvoke(llvm::Value *Callee,
2844  const Twine &Name = "");
2845  llvm::CallSite EmitRuntimeCallOrInvoke(llvm::Value *callee,
2847  const Twine &name = "");
2848  llvm::CallSite EmitRuntimeCallOrInvoke(llvm::Value *callee,
2849  const Twine &name = "");
2851  ArrayRef<llvm::Value*> args);
2852 
2854  NestedNameSpecifier *Qual,
2855  llvm::Type *Ty);
2856 
2858  CXXDtorType Type,
2859  const CXXRecordDecl *RD);
2860 
2861  RValue
2863  ReturnValueSlot ReturnValue, llvm::Value *This,
2864  llvm::Value *ImplicitParam,
2865  QualType ImplicitParamTy, const CallExpr *E);
2867  llvm::Value *This, llvm::Value *ImplicitParam,
2868  QualType ImplicitParamTy, const CallExpr *E,
2869  StructorType Type);
2871  ReturnValueSlot ReturnValue);
2873  const CXXMethodDecl *MD,
2874  ReturnValueSlot ReturnValue,
2875  bool HasQualifier,
2876  NestedNameSpecifier *Qualifier,
2877  bool IsArrow, const Expr *Base);
2878  // Compute the object pointer.
2880  llvm::Value *memberPtr,
2881  const MemberPointerType *memberPtrType,
2882  AlignmentSource *AlignSource = nullptr);
2884  ReturnValueSlot ReturnValue);
2885 
2887  const CXXMethodDecl *MD,
2888  ReturnValueSlot ReturnValue);
2889 
2891  ReturnValueSlot ReturnValue);
2892 
2894  ReturnValueSlot ReturnValue);
2895 
2897  unsigned BuiltinID, const CallExpr *E,
2898  ReturnValueSlot ReturnValue);
2899 
2900  RValue EmitBlockCallExpr(const CallExpr *E, ReturnValueSlot ReturnValue);
2901 
2902  /// EmitTargetBuiltinExpr - Emit the given builtin call. Returns 0 if the call
2903  /// is unhandled by the current target.
2904  llvm::Value *EmitTargetBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
2905 
2907  const llvm::CmpInst::Predicate Fp,
2908  const llvm::CmpInst::Predicate Ip,
2909  const llvm::Twine &Name = "");
2910  llvm::Value *EmitARMBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
2911 
2912  llvm::Value *EmitCommonNeonBuiltinExpr(unsigned BuiltinID,
2913  unsigned LLVMIntrinsic,
2914  unsigned AltLLVMIntrinsic,
2915  const char *NameHint,
2916  unsigned Modifier,
2917  const CallExpr *E,
2919  Address PtrOp0, Address PtrOp1);
2920  llvm::Function *LookupNeonLLVMIntrinsic(unsigned IntrinsicID,
2921  unsigned Modifier, llvm::Type *ArgTy,
2922  const CallExpr *E);
2923  llvm::Value *EmitNeonCall(llvm::Function *F,
2925  const char *name,
2926  unsigned shift = 0, bool rightshift = false);
2927  llvm::Value *EmitNeonSplat(llvm::Value *V, llvm::Constant *Idx);
2929  bool negateForRightShift);
2931  llvm::Type *Ty, bool usgn, const char *name);
2933  llvm::Value *EmitAArch64BuiltinExpr(unsigned BuiltinID, const CallExpr *E);
2934 
2936  llvm::Value *EmitX86BuiltinExpr(unsigned BuiltinID, const CallExpr *E);
2937  llvm::Value *EmitPPCBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
2938  llvm::Value *EmitAMDGPUBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
2939  llvm::Value *EmitSystemZBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
2940  llvm::Value *EmitNVPTXBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
2941  llvm::Value *EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
2942  const CallExpr *E);
2943 
2950  const ObjCMethodDecl *MethodWithObjects);
2953  ReturnValueSlot Return = ReturnValueSlot());
2954 
2955  /// Retrieves the default cleanup kind for an ARC cleanup.
2956  /// Except under -fobjc-arc-eh, ARC cleanups are normal-only.
2958  return CGM.getCodeGenOpts().ObjCAutoRefCountExceptions
2960  }
2961 
2962  // ARC primitives.
2963  void EmitARCInitWeak(Address addr, llvm::Value *value);
2964  void EmitARCDestroyWeak(Address addr);
2967  llvm::Value *EmitARCStoreWeak(Address addr, llvm::Value *value, bool ignored);
2968  void EmitARCCopyWeak(Address dst, Address src);
2969  void EmitARCMoveWeak(Address dst, Address src);
2973  bool resultIgnored);
2975  bool resultIgnored);
2978  llvm::Value *EmitARCRetainBlock(llvm::Value *value, bool mandatory);
2980  void EmitARCRelease(llvm::Value *value, ARCPreciseLifetime_t precise);
2986 
2987  std::pair<LValue,llvm::Value*>
2989  std::pair<LValue,llvm::Value*>
2990  EmitARCStoreStrong(const BinaryOperator *e, bool ignored);
2991  std::pair<LValue,llvm::Value*>
2992  EmitARCStoreUnsafeUnretained(const BinaryOperator *e, bool ignored);
2993 
2997 
3000  bool allowUnsafeClaim);
3004 
3006 
3010 
3016 
3017  /// \brief Emits a reference binding to the passed in expression.
3019 
3020  //===--------------------------------------------------------------------===//
3021  // Expression Emission
3022  //===--------------------------------------------------------------------===//
3023 
3024  // Expressions are broken into three classes: scalar, complex, aggregate.
3025 
3026  /// EmitScalarExpr - Emit the computation of the specified expression of LLVM
3027  /// scalar type, returning the result.
3028  llvm::Value *EmitScalarExpr(const Expr *E , bool IgnoreResultAssign = false);
3029 
3030  /// Emit a conversion from the specified type to the specified destination
3031  /// type, both of which are LLVM scalar types.
3033  QualType DstTy, SourceLocation Loc);
3034 
3035  /// Emit a conversion from the specified complex type to the specified
3036  /// destination type, where the destination type is an LLVM scalar type.
3038  QualType DstTy,
3039  SourceLocation Loc);
3040 
3041  /// EmitAggExpr - Emit the computation of the specified expression
3042  /// of aggregate type. The result is computed into the given slot,
3043  /// which may be null to indicate that the value is not needed.
3044  void EmitAggExpr(const Expr *E, AggValueSlot AS);
3045 
3046  /// EmitAggExprToLValue - Emit the computation of the specified expression of
3047  /// aggregate type into a temporary LValue.
3048  LValue EmitAggExprToLValue(const Expr *E);
3049 
3050  /// EmitExtendGCLifetime - Given a pointer to an Objective-C object,
3051  /// make sure it survives garbage collection until this point.
3052  void EmitExtendGCLifetime(llvm::Value *object);
3053 
3054  /// EmitComplexExpr - Emit the computation of the specified expression of
3055  /// complex type, returning the result.
3057  bool IgnoreReal = false,
3058  bool IgnoreImag = false);
3059 
3060  /// EmitComplexExprIntoLValue - Emit the given expression of complex
3061  /// type and place its result into the specified l-value.
3062  void EmitComplexExprIntoLValue(const Expr *E, LValue dest, bool isInit);
3063 
3064  /// EmitStoreOfComplex - Store a complex number into the specified l-value.
3065  void EmitStoreOfComplex(ComplexPairTy V, LValue dest, bool isInit);
3066 
3067  /// EmitLoadOfComplex - Load a complex number from the specified l-value.
3069 
3070  Address emitAddrOfRealComponent(Address complex, QualType complexType);
3071  Address emitAddrOfImagComponent(Address complex, QualType complexType);
3072 
3073  /// AddInitializerToStaticVarDecl - Add the initializer for 'D' to the
3074  /// global variable that has already been created for it. If the initializer
3075  /// has a different type than GV does, this may free GV and return a different
3076  /// one. Otherwise it just returns GV.
3077  llvm::GlobalVariable *
3079  llvm::GlobalVariable *GV);
3080 
3081 
3082  /// EmitCXXGlobalVarDeclInit - Create the initializer for a C++
3083  /// variable with global storage.
3084  void EmitCXXGlobalVarDeclInit(const VarDecl &D, llvm::Constant *DeclPtr,
3085  bool PerformInit);
3086 
3087  llvm::Constant *createAtExitStub(const VarDecl &VD, llvm::Constant *Dtor,
3088  llvm::Constant *Addr);
3089 
3090  /// Call atexit() with a function that passes the given argument to
3091  /// the given function.
3092  void registerGlobalDtorWithAtExit(const VarDecl &D, llvm::Constant *fn,
3093  llvm::Constant *addr);
3094 
3095  /// Emit code in this function to perform a guarded variable
3096  /// initialization. Guarded initializations are used when it's not
3097  /// possible to prove that an initialization will be done exactly
3098  /// once, e.g. with a static local variable or a static data member
3099  /// of a class template.
3100  void EmitCXXGuardedInit(const VarDecl &D, llvm::GlobalVariable *DeclPtr,
3101  bool PerformInit);
3102 
3103  /// GenerateCXXGlobalInitFunc - Generates code for initializing global
3104  /// variables.
3105  void GenerateCXXGlobalInitFunc(llvm::Function *Fn,
3106  ArrayRef<llvm::Function *> CXXThreadLocals,
3107  Address Guard = Address::invalid());
3108 
3109  /// GenerateCXXGlobalDtorsFunc - Generates code for destroying global
3110  /// variables.
3111  void GenerateCXXGlobalDtorsFunc(llvm::Function *Fn,
3112  const std::vector<std::pair<llvm::WeakVH,
3113  llvm::Constant*> > &DtorsAndObjects);
3114 
3115  void GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn,
3116  const VarDecl *D,
3117  llvm::GlobalVariable *Addr,
3118  bool PerformInit);
3119 
3120  void EmitCXXConstructExpr(const CXXConstructExpr *E, AggValueSlot Dest);
3121 
3122  void EmitSynthesizedCXXCopyCtor(Address Dest, Address Src, const Expr *Exp);
3123 
3125  if (E->getNumObjects() == 0) return;
3127  }
3129 
3130  void EmitCXXThrowExpr(const CXXThrowExpr *E, bool KeepInsertionPoint = true);
3131 
3132  void EmitLambdaExpr(const LambdaExpr *E, AggValueSlot Dest);
3133 
3135 
3136  //===--------------------------------------------------------------------===//
3137  // Annotations Emission
3138  //===--------------------------------------------------------------------===//
3139 
3140  /// Emit an annotation call (intrinsic or builtin).
3142  llvm::Value *AnnotatedVal,
3143  StringRef AnnotationStr,
3144  SourceLocation Location);
3145 
3146  /// Emit local annotations for the local variable V, declared by D.
3147  void EmitVarAnnotations(const VarDecl *D, llvm::Value *V);
3148 
3149  /// Emit field annotations for the given field & value. Returns the
3150  /// annotation result.
3152 
3153  //===--------------------------------------------------------------------===//
3154  // Internal Helpers
3155  //===--------------------------------------------------------------------===//
3156 
3157  /// ContainsLabel - Return true if the statement contains a label in it. If
3158  /// this statement is not executed normally, it not containing a label means
3159  /// that we can just remove the code.
3160  static bool ContainsLabel(const Stmt *S, bool IgnoreCaseStmts = false);
3161 
3162  /// containsBreak - Return true if the statement contains a break out of it.
3163  /// If the statement (recursively) contains a switch or loop with a break
3164  /// inside of it, this is fine.
3165  static bool containsBreak(const Stmt *S);
3166 
3167  /// ConstantFoldsToSimpleInteger - If the specified expression does not fold
3168  /// to a constant, or if it does but contains a label, return false. If it
3169  /// constant folds return true and set the boolean result in Result.
3170  bool ConstantFoldsToSimpleInteger(const Expr *Cond, bool &Result,
3171  bool AllowLabels = false);
3172 
3173  /// ConstantFoldsToSimpleInteger - If the specified expression does not fold
3174  /// to a constant, or if it does but contains a label, return false. If it
3175  /// constant folds return true and set the folded value.
3176  bool ConstantFoldsToSimpleInteger(const Expr *Cond, llvm::APSInt &Result,
3177  bool AllowLabels = false);
3178 
3179  /// EmitBranchOnBoolExpr - Emit a branch on a boolean condition (e.g. for an
3180  /// if statement) to the specified blocks. Based on the condition, this might
3181  /// try to simplify the codegen of the conditional based on the branch.
3182  /// TrueCount should be the number of times we expect the condition to
3183  /// evaluate to true based on PGO data.
3184  void EmitBranchOnBoolExpr(const Expr *Cond, llvm::BasicBlock *TrueBlock,
3185  llvm::BasicBlock *FalseBlock, uint64_t TrueCount);
3186 
3187  /// \brief Emit a description of a type in a format suitable for passing to
3188  /// a runtime sanitizer handler.
3189  llvm::Constant *EmitCheckTypeDescriptor(QualType T);
3190 
3191  /// \brief Convert a value into a format suitable for passing to a runtime
3192  /// sanitizer handler.
3194 
3195  /// \brief Emit a description of a source location in a format suitable for
3196  /// passing to a runtime sanitizer handler.
3197  llvm::Constant *EmitCheckSourceLocation(SourceLocation Loc);
3198 
3199  /// \brief Create a basic block that will call a handler function in a
3200  /// sanitizer runtime with the provided arguments, and create a conditional
3201  /// branch to it.
3202  void EmitCheck(ArrayRef<std::pair<llvm::Value *, SanitizerMask>> Checked,
3203  StringRef CheckName, ArrayRef<llvm::Constant *> StaticArgs,
3204  ArrayRef<llvm::Value *> DynamicArgs);
3205 
3206  /// \brief Emit a slow path cross-DSO CFI check which calls __cfi_slowpath
3207  /// if Cond if false.
3209  llvm::ConstantInt *TypeId, llvm::Value *Ptr,
3210  ArrayRef<llvm::Constant *> StaticArgs);
3211 
3212  /// \brief Create a basic block that will call the trap intrinsic, and emit a
3213  /// conditional branch to it, for the -ftrapv checks.
3214  void EmitTrapCheck(llvm::Value *Checked);
3215 
3216  /// \brief Emit a call to trap or debugtrap and attach function attribute
3217  /// "trap-func-name" if specified.
3218  llvm::CallInst *EmitTrapCall(llvm::Intrinsic::ID IntrID);
3219 
3220  /// \brief Emit a cross-DSO CFI failure handling function.
3221  void EmitCfiCheckFail();
3222 
3223  /// \brief Create a check for a function parameter that may potentially be
3224  /// declared as non-null.
3225  void EmitNonNullArgCheck(RValue RV, QualType ArgType, SourceLocation ArgLoc,
3226  const FunctionDecl *FD, unsigned ParmNum);
3227 
3228  /// EmitCallArg - Emit a single call argument.
3229  void EmitCallArg(CallArgList &args, const Expr *E, QualType ArgType);
3230 
3231  /// EmitDelegateCallArg - We are performing a delegate call; that
3232  /// is, the current function is delegating to another one. Produce
3233  /// a r-value suitable for passing the given parameter.
3234  void EmitDelegateCallArg(CallArgList &args, const VarDecl *param,
3235  SourceLocation loc);
3236 
3237  /// SetFPAccuracy - Set the minimum required accuracy of the given floating
3238  /// point operation, expressed as the maximum relative error in ulp.
3239  void SetFPAccuracy(llvm::Value *Val, float Accuracy);
3240 
3241 private:
3242  llvm::MDNode *getRangeForLoadFromType(QualType Ty);
3243  void EmitReturnOfRValue(RValue RV, QualType Ty);
3244 
3245  void deferPlaceholderReplacement(llvm::Instruction *Old, llvm::Value *New);
3246 
3248  DeferredReplacements;
3249 
3250  /// Set the address of a local variable.
3251  void setAddrOfLocalVar(const VarDecl *VD, Address Addr) {
3252  assert(!LocalDeclMap.count(VD) && "Decl already exists in LocalDeclMap!");
3253  LocalDeclMap.insert({VD, Addr});
3254  }
3255 
3256  /// ExpandTypeFromArgs - Reconstruct a structure of type \arg Ty
3257  /// from function arguments into \arg Dst. See ABIArgInfo::Expand.
3258  ///
3259  /// \param AI - The first function argument of the expansion.
3260  void ExpandTypeFromArgs(QualType Ty, LValue Dst,
3262 
3263  /// ExpandTypeToArgs - Expand an RValue \arg RV, with the LLVM type for \arg
3264  /// Ty, into individual arguments on the provided vector \arg IRCallArgs,
3265  /// starting at index \arg IRCallArgPos. See ABIArgInfo::Expand.
3266  void ExpandTypeToArgs(QualType Ty, RValue RV, llvm::FunctionType *IRFuncTy,
3267  SmallVectorImpl<llvm::Value *> &IRCallArgs,
3268  unsigned &IRCallArgPos);
3269 
3270  llvm::Value* EmitAsmInput(const TargetInfo::ConstraintInfo &Info,
3271  const Expr *InputExpr, std::string &ConstraintStr);
3272 
3273  llvm::Value* EmitAsmInputLValue(const TargetInfo::ConstraintInfo &Info,
3274  LValue InputValue, QualType InputType,
3275  std::string &ConstraintStr,
3276  SourceLocation Loc);
3277 
3278  /// \brief Attempts to statically evaluate the object size of E. If that
3279  /// fails, emits code to figure the size of E out for us. This is
3280  /// pass_object_size aware.
3281  llvm::Value *evaluateOrEmitBuiltinObjectSize(const Expr *E, unsigned Type,
3282  llvm::IntegerType *ResType);
3283 
3284  /// \brief Emits the size of E, as required by __builtin_object_size. This
3285  /// function is aware of pass_object_size parameters, and will act accordingly
3286  /// if E is a parameter with the pass_object_size attribute.
3287  llvm::Value *emitBuiltinObjectSize(const Expr *E, unsigned Type,
3288  llvm::IntegerType *ResType);
3289 
3290 public:
3291 #ifndef NDEBUG
3292  // Determine whether the given argument is an Objective-C method
3293  // that may have type parameters in its signature.
3294  static bool isObjCMethodWithTypeParams(const ObjCMethodDecl *method) {
3295  const DeclContext *dc = method->getDeclContext();
3296  if (const ObjCInterfaceDecl *classDecl= dyn_cast<ObjCInterfaceDecl>(dc)) {
3297  return classDecl->getTypeParamListAsWritten();
3298  }
3299 
3300  if (const ObjCCategoryDecl *catDecl = dyn_cast<ObjCCategoryDecl>(dc)) {
3301  return catDecl->getTypeParamList();
3302  }
3303 
3304  return false;
3305  }
3306 
3307  template<typename T>
3308  static bool isObjCMethodWithTypeParams(const T *) { return false; }
3309 #endif
3310 
3311  /// EmitCallArgs - Emit call arguments for a function.
3312  template <typename T>
3313  void EmitCallArgs(CallArgList &Args, const T *CallArgTypeInfo,
3314  llvm::iterator_range<CallExpr::const_arg_iterator> ArgRange,
3315  const FunctionDecl *CalleeDecl = nullptr,
3316  unsigned ParamsToSkip = 0) {
3317  SmallVector<QualType, 16> ArgTypes;
3318  CallExpr::const_arg_iterator Arg = ArgRange.begin();
3319 
3320  assert((ParamsToSkip == 0 || CallArgTypeInfo) &&
3321  "Can't skip parameters if type info is not provided");
3322  if (CallArgTypeInfo) {
3323 #ifndef NDEBUG
3324  bool isGenericMethod = isObjCMethodWithTypeParams(CallArgTypeInfo);
3325 #endif
3326 
3327  // First, use the argument types that the type info knows about
3328  for (auto I = CallArgTypeInfo->param_type_begin() + ParamsToSkip,
3329  E = CallArgTypeInfo->param_type_end();
3330  I != E; ++I, ++Arg) {
3331  assert(Arg != ArgRange.end() && "Running over edge of argument list!");
3332  assert((isGenericMethod ||
3333  ((*I)->isVariablyModifiedType() ||
3334  (*I).getNonReferenceType()->isObjCRetainableType() ||
3335  getContext()
3336  .getCanonicalType((*I).getNonReferenceType())
3337  .getTypePtr() ==
3338  getContext()
3339  .getCanonicalType((*Arg)->getType())
3340  .getTypePtr())) &&
3341  "type mismatch in call argument!");
3342  ArgTypes.push_back(*I);
3343  }
3344  }
3345 
3346  // Either we've emitted all the call args, or we have a call to variadic
3347  // function.
3348  assert((Arg == ArgRange.end() || !CallArgTypeInfo ||
3349  CallArgTypeInfo->isVariadic()) &&
3350  "Extra arguments in non-variadic function!");
3351 
3352  // If we still have any arguments, emit them using the type of the argument.
3353  for (auto *A : llvm::make_range(Arg, ArgRange.end()))
3354  ArgTypes.push_back(getVarArgType(A));
3355 
3356  EmitCallArgs(Args, ArgTypes, ArgRange, CalleeDecl, ParamsToSkip);
3357  }
3358 
3359  void EmitCallArgs(CallArgList &Args, ArrayRef<QualType> ArgTypes,
3360  llvm::iterator_range<CallExpr::const_arg_iterator> ArgRange,
3361  const FunctionDecl *CalleeDecl = nullptr,
3362  unsigned ParamsToSkip = 0);
3363 
3364  /// EmitPointerWithAlignment - Given an expression with a pointer
3365  /// type, emit the value and compute our best estimate of the
3366  /// alignment of the pointee.
3367  ///
3368  /// Note that this function will conservatively fall back on the type
3369  /// when it doesn't
3370  ///
3371  /// \param Source - If non-null, this will be initialized with
3372  /// information about the source of the alignment. Note that this
3373  /// function will conservatively fall back on the type when it
3374  /// doesn't recognize the expression, which means that sometimes
3375  ///
3376  /// a worst-case One
3377  /// reasonable way to use this information is when there's a
3378  /// language guarantee that the pointer must be aligned to some
3379  /// stricter value, and we're simply trying to ensure that
3380  /// sufficiently obvious uses of under-aligned objects don't get
3381  /// miscompiled; for example, a placement new into the address of
3382  /// a local variable. In such a case, it's quite reasonable to
3383  /// just ignore the returned alignment when it isn't from an
3384  /// explicit source.
3386  AlignmentSource *Source = nullptr);
3387 
3388  void EmitSanitizerStatReport(llvm::SanitizerStatKind SSK);
3389 
3390 private:
3391  QualType getVarArgType(const Expr *Arg);
3392 
3393  const TargetCodeGenInfo &getTargetHooks() const {
3394  return CGM.getTargetCodeGenInfo();
3395  }
3396 
3397  void EmitDeclMetadata();
3398 
3399  BlockByrefHelpers *buildByrefHelpers(llvm::StructType &byrefType,
3400  const AutoVarEmission &emission);
3401 
3402  void AddObjCARCExceptionMetadata(llvm::Instruction *Inst);
3403 
3404  llvm::Value *GetValueForARMHint(unsigned BuiltinID);
3405 };
3406 
3407 /// Helper class with most of the code for saving a value for a
3408 /// conditional expression cleanup.
3410  typedef llvm::PointerIntPair<llvm::Value*, 1, bool> saved_type;
3411 
3412  /// Answer whether the given value needs extra work to be saved.
3413  static bool needsSaving(llvm::Value *value) {
3414  // If it's not an instruction, we don't need to save.
3415  if (!isa<llvm::Instruction>(value)) return false;
3416 
3417  // If it's an instruction in the entry block, we don't need to save.
3418  llvm::BasicBlock *block = cast<llvm::Instruction>(value)->getParent();
3419  return (block != &block->getParent()->getEntryBlock());
3420  }
3421 
3422  /// Try to save the given value.
3424  if (!needsSaving(value)) return saved_type(value, false);
3425 
3426  // Otherwise, we need an alloca.
3427  auto align = CharUnits::fromQuantity(
3428  CGF.CGM.getDataLayout().getPrefTypeAlignment(value->getType()));
3429  Address alloca =
3430  CGF.CreateTempAlloca(value->getType(), align, "cond-cleanup.save");
3431  CGF.Builder.CreateStore(value, alloca);
3432 
3433  return saved_type(alloca.getPointer(), true);
3434  }
3435 
3437  // If the value says it wasn't saved, trust that it's still dominating.
3438  if (!value.getInt()) return value.getPointer();
3439 
3440  // Otherwise, it should be an alloca instruction, as set up in save().
3441  auto alloca = cast<llvm::AllocaInst>(value.getPointer());
3442  return CGF.Builder.CreateAlignedLoad(alloca, alloca->getAlignment());
3443  }
3444 };
3445 
3446 /// A partial specialization of DominatingValue for llvm::Values that
3447 /// might be llvm::Instructions.
3448 template <class T> struct DominatingPointer<T,true> : DominatingLLVMValue {
3449  typedef T *type;
3450  static type restore(CodeGenFunction &CGF, saved_type value) {
3451  return static_cast<T*>(DominatingLLVMValue::restore(CGF, value));
3452  }
3453 };
3454 
3455 /// A specialization of DominatingValue for Address.
3456 template <> struct DominatingValue<Address> {
3457  typedef Address type;
3458 
3459  struct saved_type {
3462  };
3463 
3464  static bool needsSaving(type value) {
3466  }
3467  static saved_type save(CodeGenFunction &CGF, type value) {
3468  return { DominatingLLVMValue::save(CGF, value.getPointer()),
3469  value.getAlignment() };
3470  }
3471  static type restore(CodeGenFunction &CGF, saved_type value) {
3472  return Address(DominatingLLVMValue::restore(CGF, value.SavedValue),
3473  value.Alignment);
3474  }
3475 };
3476 
3477 /// A specialization of DominatingValue for RValue.
3478 template <> struct DominatingValue<RValue> {
3479  typedef RValue type;
3480  class saved_type {
3481  enum Kind { ScalarLiteral, ScalarAddress, AggregateLiteral,
3482  AggregateAddress, ComplexAddress };
3483 
3484  llvm::Value *Value;
3485  unsigned K : 3;
3486  unsigned Align : 29;
3487  saved_type(llvm::Value *v, Kind k, unsigned a = 0)
3488  : Value(v), K(k), Align(a) {}
3489 
3490  public:
3491  static bool needsSaving(RValue value);
3492  static saved_type save(CodeGenFunction &CGF, RValue value);
3493  RValue restore(CodeGenFunction &CGF);
3494 
3495  // implementations in CGCleanup.cpp
3496  };
3497 
3498  static bool needsSaving(type value) {
3499  return saved_type::needsSaving(value);
3500  }
3501  static saved_type save(CodeGenFunction &CGF, type value) {
3502  return saved_type::save(CGF, value);
3503  }
3504  static type restore(CodeGenFunction &CGF, saved_type value) {
3505  return value.restore(CGF);
3506  }
3507 };
3508 
3509 } // end namespace CodeGen
3510 } // end namespace clang
3511 
3512 #endif
void enterNonTrivialFullExpression(const ExprWithCleanups *E)
Enter a full-expression with a non-trivial number of objects to clean up.
Definition: CGBlocks.cpp:642
A call to an overloaded operator written using operator syntax.
Definition: ExprCXX.h:52
void EmitInitializerForField(FieldDecl *Field, LValue LHS, Expr *Init, ArrayRef< VarDecl * > ArrayIndexes)
Definition: CGClass.cpp:753
ReturnValueSlot - Contains the address where the return value of a function can be stored...
Definition: CGCall.h:151
void EnterDtorCleanups(const CXXDestructorDecl *Dtor, CXXDtorType Type)
EnterDtorCleanups - Enter the cleanups necessary to complete the given phase of destruction for a des...
Definition: CGClass.cpp:1807
std::pair< RValue, llvm::Value * > EmitAtomicCompareExchange(LValue Obj, RValue Expected, RValue Desired, SourceLocation Loc, llvm::AtomicOrdering Success=llvm::AtomicOrdering::SequentiallyConsistent, llvm::AtomicOrdering Failure=llvm::AtomicOrdering::SequentiallyConsistent, bool IsWeak=false, AggValueSlot Slot=AggValueSlot::ignored())
Emit a compare-and-exchange op for atomic type.
Definition: CGAtomic.cpp:1791
This represents '#pragma omp distribute simd' composite directive.
Definition: StmtOpenMP.h:2966
Information about the layout of a __block variable.
Definition: CGBlocks.h:144
void EmitIndirectGotoStmt(const IndirectGotoStmt &S)
Definition: CGStmt.cpp:549
This represents '#pragma omp master' directive.
Definition: StmtOpenMP.h:1181
SourceLocation getEnd() const
virtual void EmitBody(CodeGenFunction &CGF, const Stmt *S)
Emit the captured statement body.
Address EmitLoadOfReference(Address Ref, const ReferenceType *RefTy, AlignmentSource *Source=nullptr)
Definition: CGExpr.cpp:1958
This represents '#pragma omp task' directive.
Definition: StmtOpenMP.h:1521
llvm::Constant * GenerateCopyHelperFunction(const CGBlockInfo &blockInfo)
Generate the copy-helper function for a block closure object: static void block_copy_helper(block_t *...
Definition: CGBlocks.cpp:1331
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
Definition: Decl.h:1561
llvm::Value * EmitARCStoreStrong(LValue lvalue, llvm::Value *value, bool resultIgnored)
Store into a strong object.
Definition: CGObjC.cpp:2119
void GenerateCXXGlobalInitFunc(llvm::Function *Fn, ArrayRef< llvm::Function * > CXXThreadLocals, Address Guard=Address::invalid())
GenerateCXXGlobalInitFunc - Generates code for initializing global variables.
Definition: CGDeclCXX.cpp:523
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
Definition: ASTMatchers.h:1367
LValue MakeNaturalAlignPointeeAddrLValue(llvm::Value *V, QualType T)
Given a value of type T* that may not be to a complete object, construct an l-value with the natural ...
void ActivateCleanupBlock(EHScopeStack::stable_iterator Cleanup, llvm::Instruction *DominatingIP)
ActivateCleanupBlock - Activates an initially-inactive cleanup.
Definition: CGCleanup.cpp:1181
llvm::Value * EmitARCReclaimReturnedObject(const Expr *e, bool allowUnsafeClaim)
Definition: CGObjC.cpp:2534
void EmitCallArgs(CallArgList &Args, const T *CallArgTypeInfo, llvm::iterator_range< CallExpr::const_arg_iterator > ArgRange, const FunctionDecl *CalleeDecl=nullptr, unsigned ParamsToSkip=0)
EmitCallArgs - Emit call arguments for a function.
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:3761
void EmitDelegateCXXConstructorCall(const CXXConstructorDecl *Ctor, CXXCtorType CtorType, const FunctionArgList &Args, SourceLocation Loc)
Definition: CGClass.cpp:2314
LValue EmitComplexCompoundAssignmentLValue(const CompoundAssignOperator *E)
void EmitStaticVarDecl(const VarDecl &D, llvm::GlobalValue::LinkageTypes Linkage)
Definition: CGDecl.cpp:352
llvm::Value * EmitARCRetainAutoreleaseScalarExpr(const Expr *expr)
Definition: CGObjC.cpp:2936
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:2179
Scheduling data for loop-based OpenMP directives.
Definition: OpenMPKinds.h:124
Destroyer * getDestroyer(QualType::DestructionKind destructionKind)
Definition: CGDecl.cpp:1429
A (possibly-)qualified type.
Definition: Type.h:598
void EmitSEHLeaveStmt(const SEHLeaveStmt &S)
void EmitExtendGCLifetime(llvm::Value *object)
EmitExtendGCLifetime - Given a pointer to an Objective-C object, make sure it survives garbage collec...
Definition: CGObjC.cpp:3146
void EmitCtorPrologue(const CXXConstructorDecl *CD, CXXCtorType Type, FunctionArgList &Args)
EmitCtorPrologue - This routine generates necessary code to initialize base classes and non-static da...
Definition: CGClass.cpp:1352
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)
EmitBranchOnBoolExpr - Emit a branch on a boolean condition (e.g.
void EmitVarDecl(const VarDecl &D)
EmitVarDecl - Emit a local variable declaration.
Definition: CGDecl.cpp:140
llvm::Value * EmitARCExtendBlockObject(const Expr *expr)
Definition: CGObjC.cpp:2953
void EmitGotoStmt(const GotoStmt &S)
Definition: CGStmt.cpp:538
LValue EmitStmtExprLValue(const StmtExpr *E)
Definition: CGExpr.cpp:3977
Address getAllocatedAddress() const
Returns the raw, allocated address, which is not necessarily the address of the object itself...
void EmitAttributedStmt(const AttributedStmt &S)
Definition: CGStmt.cpp:518
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:2310
AlignmentSource
The source of the alignment of an l-value; an expression of confidence in the alignment actually matc...
Definition: CGValue.h:125
void EmitOMPDistributeDirective(const OMPDistributeDirective &S)
llvm::Value * EmitNVPTXBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition: CGBuiltin.cpp:7942
llvm::LLVMContext & getLLVMContext()
void EmitFunctionInstrumentation(const char *Fn)
EmitFunctionInstrumentation - Emit LLVM code to call the specified instrumentation function with the ...
LValue EmitObjCIsaExpr(const ObjCIsaExpr *E)
void EmitARCDestroyWeak(Address addr)
void @objc_destroyWeak(i8** addr) Essentially objc_storeWeak(addr, nil).
Definition: CGObjC.cpp:2255
LValue EmitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *E)
Definition: CGExpr.cpp:351
void EmitOMPAggregateAssign(Address DestAddr, Address SrcAddr, QualType OriginalType, const llvm::function_ref< void(Address, Address)> &CopyGen)
Perform element by element copying of arrays with type OriginalType from SrcAddr to DestAddr using co...
void EmitCXXTryStmt(const CXXTryStmt &S)
FieldConstructionScope(CodeGenFunction &CGF, Address This)
bool isInConditionalBranch() const
isInConditionalBranch - Return true if we're currently emitting one branch or the other of a conditio...
void EmitNewArrayInitializer(const CXXNewExpr *E, QualType elementType, llvm::Type *ElementTy, Address NewPtr, llvm::Value *NumElements, llvm::Value *AllocSizeWithoutCookie)
Definition: CGExprCXX.cpp:831
const TargetInfo & getTarget() const
IfStmt - This represents an if/then/else.
Definition: Stmt.h:881
void EmitStoreThroughGlobalRegLValue(RValue Src, LValue Dst)
Store of global named registers are always calls to intrinsics.
Definition: CGExpr.cpp:1820
Address GetAddressOfDirectBaseInCompleteClass(Address Value, const CXXRecordDecl *Derived, const CXXRecordDecl *Base, bool BaseIsVirtual)
GetAddressOfBaseOfCompleteClass - Convert the given pointer to a complete class to the given direct b...
Definition: CGClass.cpp:197
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:3148
llvm::AllocaInst * CreateTempAlloca(llvm::Type *Ty, const Twine &Name="tmp")
CreateTempAlloca - This creates a alloca and inserts it into the entry block.
Definition: CGExpr.cpp:69
C Language Family Type Representation.
Address GetAddressOfDerivedClass(Address Value, const CXXRecordDecl *Derived, CastExpr::path_const_iterator PathBegin, CastExpr::path_const_iterator PathEnd, bool NullCheckValue)
Definition: CGClass.cpp:368
OpaqueValueMapping(CodeGenFunction &CGF, const AbstractConditionalOperator *op)
Build the opaque value mapping for the given conditional operator if it's the GNU ...
This represents '#pragma omp for simd' directive.
Definition: StmtOpenMP.h:931
Checking the 'this' pointer for a constructor call.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Definition: CharUnits.h:179
Address EmitVAArg(VAArgExpr *VE, Address &VAListAddr)
Generate code to get an argument from the passed in pointer and update it accordingly.
Definition: CGCall.cpp:4133
void emitAutoVarTypeCleanup(const AutoVarEmission &emission, QualType::DestructionKind dtorKind)
Enter a destroy cleanup for the given local variable.
Definition: CGDecl.cpp:1325
RValue EmitPseudoObjectRValue(const PseudoObjectExpr *e, AggValueSlot slot=AggValueSlot::ignored())
Definition: CGExpr.cpp:4256
const Decl * CurCodeDecl
CurCodeDecl - This is the inner-most code context, which includes blocks.
llvm::Value * getTypeSize(QualType Ty)
Returns calculated size of the specified type.
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:830
void EmitAutoVarDecl(const VarDecl &D)
EmitAutoVarDecl - Emit an auto variable declaration.
Definition: CGDecl.cpp:904
const llvm::DataLayout & getDataLayout() const
void EmitOMPOrderedDirective(const OMPOrderedDirective &S)
static Destroyer destroyARCStrongPrecise
llvm::Value * LoadCXXThis()
LoadCXXThis - Load the value of 'this'.
bool isGlobalVarCaptured(const VarDecl *VD) const
Checks if the global variable is captured in current function.
The base class of the type hierarchy.
Definition: Type.h:1281
void pushLifetimeExtendedDestroy(CleanupKind kind, Address addr, QualType type, Destroyer *destroyer, bool useEHCleanupForArray)
Definition: CGDecl.cpp:1474
LValue EmitBinaryOperatorLValue(const BinaryOperator *E)
Definition: CGExpr.cpp:3811
Represents Objective-C's @throw statement.
Definition: StmtObjC.h:313
void EmitStoreThroughLValue(RValue Src, LValue Dst, bool isInit=false)
EmitStoreThroughLValue - Store the specified rvalue into the specified lvalue, where both are guarant...
Definition: CGExpr.cpp:1593
void EmitComplexExprIntoLValue(const Expr *E, LValue dest, bool isInit)
EmitComplexExprIntoLValue - Emit the given expression of complex type and place its result into the s...
bool ShouldInstrumentFunction()
ShouldInstrumentFunction - Return true if the current function should be instrumented with __cyg_prof...
CGCapturedStmtInfo(const CapturedStmt &S, CapturedRegionKind K=CR_Default)
LValue EmitOpaqueValueLValue(const OpaqueValueExpr *e)
Definition: CGExpr.cpp:3704
void GenerateObjCSetter(ObjCImplementationDecl *IMP, const ObjCPropertyImplDecl *PID)
GenerateObjCSetter - Synthesize an Objective-C property setter function for the given property...
Definition: CGObjC.cpp:1321
Address GenerateCapturedStmtArgument(const CapturedStmt &S)
Definition: CGStmt.cpp:2188
std::unique_ptr< llvm::MemoryBuffer > Buffer
void EmitSEHExceptionCodeSave(CodeGenFunction &ParentCGF, llvm::Value *ParentFP, llvm::Value *EntryEBP)
void GenerateCode(GlobalDecl GD, llvm::Function *Fn, const CGFunctionInfo &FnInfo)
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition: Type.h:2456
void SpecialInitFn(CodeGenFunction &Init, const VarDecl &D, llvm::Value *Address)
Address EmitArrayToPointerDecay(const Expr *Array, AlignmentSource *AlignSource=nullptr)
Definition: CGExpr.cpp:2763
bool sanitizePerformTypeCheck() const
Whether any type-checking sanitizers are enabled.
Definition: CGExpr.cpp:525
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1162
RValue EmitCXXMemberCallExpr(const CXXMemberCallExpr *E, ReturnValueSlot ReturnValue)
Definition: CGExprCXX.cpp:106
DominatingValue< T >::saved_type saveValueInCond(T value)
CGCapturedStmtInfo(CapturedRegionKind K=CR_Default)
void EmitARCCopyWeak(Address dst, Address src)
void @objc_copyWeak(i8** dest, i8** src) Disregards the current value in dest.
Definition: CGObjC.cpp:2281
void EmitCfiCheckFail()
Emit a cross-DSO CFI failure handling function.
Definition: CGExpr.cpp:2653
llvm::Value * EmitObjCMRRAutoreleasePoolPush()
Produce the code to do an MRR version objc_autoreleasepool_push.
Definition: CGObjC.cpp:2324
llvm::Function * GenerateVarArgsThunk(llvm::Function *Fn, const CGFunctionInfo &FnInfo, GlobalDecl GD, const ThunkInfo &Thunk)
Definition: CGVTables.cpp:144
llvm::Constant * GenerateObjCAtomicSetterCopyHelperFunction(const ObjCPropertyImplDecl *PID)
GenerateObjCAtomicSetterCopyHelperFunction - Given a c++ object type with non-trivial copy assignment...
Definition: CGObjC.cpp:3165
This represents '#pragma omp parallel for' directive.
Definition: StmtOpenMP.h:1302
const LangOptions & getLangOpts() const
LValue EmitLValueForFieldInitialization(LValue Base, const FieldDecl *Field)
EmitLValueForFieldInitialization - Like EmitLValueForField, except that if the Field is a reference...
Definition: CGExpr.cpp:3422
llvm::Value * EmitARCRetainNonBlock(llvm::Value *value)
Retain the given object, with normal retain semantics.
Definition: CGObjC.cpp:1940
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2187
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
Definition: ExprCXX.h:3962
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:1706
bool ConstantFoldsToSimpleInteger(const Expr *Cond, bool &Result, bool AllowLabels=false)
ConstantFoldsToSimpleInteger - If the specified expression does not fold to a constant, or if it does but contains a label, return false.
static OpaqueValueMappingData bind(CodeGenFunction &CGF, const OpaqueValueExpr *ov, const RValue &rv)
void EmitOMPCopy(QualType OriginalType, Address DestAddr, Address SrcAddr, const VarDecl *DestVD, const VarDecl *SrcVD, const Expr *Copy)
Emit proper copying of data from one variable to another.
LValue EmitCXXUuidofLValue(const CXXUuidofExpr *E)
Definition: CGExpr.cpp:3897
const CXXBaseSpecifier *const * path_const_iterator
Definition: Expr.h:2697
void EmitOMPParallelForSimdDirective(const OMPParallelForSimdDirective &S)
This represents '#pragma omp target exit data' directive.
Definition: StmtOpenMP.h:2191
Address GetAddrOfLocalVar(const VarDecl *VD)
GetAddrOfLocalVar - Return the address of a local variable.
TypeEvaluationKind
The kind of evaluation to perform on values of a particular type.
llvm::Function * GenerateOpenMPCapturedStmtFunction(const CapturedStmt &S)
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Definition: Decl.h:768
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:2279
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
Definition: ExprObjC.h:1383
CompoundLiteralExpr - [C99 6.5.2.5].
Definition: Expr.h:2562
RAII object to set/unset CodeGenFunction::IsSanitizerScope.
LValue EmitObjCSelectorLValue(const ObjCSelectorExpr *E)
Definition: CGExpr.cpp:3934
uint64_t getProfileCount(const Stmt *S)
Get the profiler's count for the given statement.
llvm::Value * EmitObjCAutoreleasePoolPush()
Produce the code to do a objc_autoreleasepool_push.
Definition: CGObjC.cpp:2289
field_iterator field_begin() const
Definition: Decl.cpp:3767
llvm::Value * GetVTTParameter(GlobalDecl GD, bool ForVirtualBase, bool Delegating)
GetVTTParameter - Return the VTT parameter that should be passed to a base constructor/destructor wit...
Definition: CGClass.cpp:425
This class gathers all debug information during compilation and is responsible for emitting to llvm g...
Definition: CGDebugInfo.h:52
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:113
llvm::Value * EmitBlockCopyAndAutorelease(llvm::Value *Block, QualType Ty)
Definition: CGObjC.cpp:3345
void EmitLabel(const LabelDecl *D)
EmitLabel - Emit the block for the given label.
Definition: CGStmt.cpp:463
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:2752
void EmitVariablyModifiedType(QualType Ty)
EmitVLASize - Capture all the sizes for the VLA expressions in the given variably-modified type and s...
CharUnits getNaturalTypeAlignment(QualType T, AlignmentSource *Source=nullptr, bool forPointeeType=false)
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)
pushFullExprCleanup - Push a cleanup to be run at the end of the current full-expression.
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:283
capture_iterator capture_begin()
Retrieve an iterator pointing to the first capture.
Definition: Stmt.h:2148
RValue EmitCUDAKernelCallExpr(const CUDAKernelCallExpr *E, ReturnValueSlot ReturnValue)
Definition: CGExprCXX.cpp:347
void EmitOMPLastprivateClauseFinal(const OMPExecutableDirective &D, bool NoFinals, llvm::Value *IsLastIterCond=nullptr)
Emit final copying of lastprivate values to original variables at the end of the worksharing or simd ...
A C++ throw-expression (C++ [except.throw]).
Definition: ExprCXX.h:913
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
Definition: ExprCXX.h:2936
llvm::Value * EmitARMBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition: CGBuiltin.cpp:3955
iterator begin() const
Definition: Type.h:4235
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:669
void SimplifyForwardingBlocks(llvm::BasicBlock *BB)
SimplifyForwardingBlocks - If the given basic block is only a branch to another basic block...
Definition: CGStmt.cpp:375
void emitImplicitAssignmentOperatorBody(FunctionArgList &Args)
Definition: CGClass.cpp:1597
llvm::Value * EmitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E)
Definition: CGObjC.cpp:229
void EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst, llvm::Value **Result=nullptr)
EmitStoreThroughBitfieldLValue - Store Src into Dst with same constraints as EmitStoreThroughLValue.
Definition: CGExpr.cpp:1682
Address emitAddrOfImagComponent(Address complex, QualType complexType)
The collection of all-type qualifiers we support.
Definition: Type.h:117
EHScopeStack::stable_iterator PrologueCleanupDepth
PrologueCleanupDepth - The cleanup depth enclosing all the cleanups associated with the parameters...
A jump destination is an abstract label, branching to which may require a jump out through normal cle...
llvm::Value * EmitObjCThrowOperand(const Expr *expr)
Definition: CGObjC.cpp:2971
LabelStmt - Represents a label, which has a substatement.
Definition: Stmt.h:789
void EmitOMPTaskLoopSimdDirective(const OMPTaskLoopSimdDirective &S)
JumpDest getJumpDestForLabel(const LabelDecl *S)
getBasicBlockForLabel - Return the LLVM basicblock that the specified label maps to.
Definition: CGStmt.cpp:452
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.
Definition: CGExpr.cpp:743
RecordDecl - Represents a struct/union/class.
Definition: Decl.h:3253
void popCatchScope()
popCatchScope - Pops the catch scope at the top of the EHScope stack, emitting any required code (oth...
llvm::Value * EmitCommonNeonBuiltinExpr(unsigned BuiltinID, unsigned LLVMIntrinsic, unsigned AltLLVMIntrinsic, const char *NameHint, unsigned Modifier, const CallExpr *E, SmallVectorImpl< llvm::Value * > &Ops, Address PtrOp0, Address PtrOp1)
Definition: CGBuiltin.cpp:3335
llvm::DenseMap< const VarDecl *, FieldDecl * > LambdaCaptureFields
An object to manage conditionally-evaluated expressions.
PeepholeProtection protectFromPeepholes(RValue rvalue)
protectFromPeepholes - Protect a value that we're intending to store to the side, but which will prob...
llvm::BasicBlock * getTerminateHandler()
getTerminateHandler - Return a handler (not a landing pad, just a catch handler) that just calls term...
void EmitCXXForRangeStmt(const CXXForRangeStmt &S, ArrayRef< const Attr * > Attrs=None)
Definition: CGStmt.cpp:891
bool requiresLandingPad() const
Definition: CGCleanup.cpp:160
bool ShouldXRayInstrumentFunction() const
ShouldXRayInstrument - Return true if the current function should be instrumented with XRay nop sleds...
void EmitOMPSimdDirective(const OMPSimdDirective &S)
llvm::Value * EmitCXXNewExpr(const CXXNewExpr *E)
Definition: CGExprCXX.cpp:1316
void emitDestroy(Address addr, QualType type, Destroyer *destroyer, bool useEHCleanupForArray)
emitDestroy - Immediately perform the destruction of the given object.
Definition: CGDecl.cpp:1505
ConditionalCleanup stores the saved form of its parameters, then restores them and performs the clean...
Definition: EHScopeStack.h:198
llvm::Value * EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV, bool isInc, bool isPre)
void emitByrefStructureInit(const AutoVarEmission &emission)
Initialize the structural components of a __block variable, i.e.
Definition: CGBlocks.cpp:2153
CGBlockInfo * FirstBlockInfo
FirstBlockInfo - The head of a singly-linked-list of block layouts.
LValue EmitScalarCompoundAssignWithComplex(const CompoundAssignOperator *E, llvm::Value *&Result)
void setScopeDepth(EHScopeStack::stable_iterator depth)
void EmitFunctionEpilog(const CGFunctionInfo &FI, bool EmitRetDbgLoc, SourceLocation EndLoc)
EmitFunctionEpilog - Emit the target specific LLVM code to return the given temporary.
Definition: CGCall.cpp:2664
This represents '#pragma omp parallel' directive.
Definition: StmtOpenMP.h:231
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
Definition: Type.h:4549
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
LValue EmitObjCIvarRefLValue(const ObjCIvarRefExpr *E)
Definition: CGExpr.cpp:3953
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:92
LValue EmitLValueForLambdaField(const FieldDecl *Field)
Given that we are currently emitting a lambda, emit an l-value for one of its members.
Definition: CGExpr.cpp:3274
void EmitExprAsInit(const Expr *init, const ValueDecl *D, LValue lvalue, bool capturedByInit)
EmitExprAsInit - Emits the code necessary to initialize a location in memory with the given initializ...
Definition: CGDecl.cpp:1287
std::pair< LValue, llvm::Value * > EmitARCStoreAutoreleasing(const BinaryOperator *e)
Definition: CGObjC.cpp:3109
llvm::Value * EmitDynamicCast(Address V, const CXXDynamicCastExpr *DCE)
Definition: CGExprCXX.cpp:1855
llvm::Value * EmitObjCExtendObjectLifetime(QualType T, llvm::Value *Ptr)
Definition: CGObjC.cpp:1776
void EmitOMPTaskLoopBasedDirective(const OMPLoopDirective &S)
RValue EmitReferenceBindingToExpr(const Expr *E)
Emits a reference binding to the passed in expression.
Definition: CGExpr.cpp:485
llvm::SmallPtrSet< const CXXRecordDecl *, 4 > VisitedVirtualBasesSetTy
void EmitSynthesizedCXXCopyCtorCall(const CXXConstructorDecl *D, Address This, Address Src, const CXXConstructExpr *E)
Definition: CGClass.cpp:2290
The scope used to remap some variables as private in the OpenMP loop body (or other captured region e...
SmallVector< Address, 1 > SEHCodeSlotStack
A stack of exception code slots.
LValue EmitCXXBindTemporaryLValue(const CXXBindTemporaryExpr *E)
Definition: CGExpr.cpp:3903
bool isReferenceType() const
Definition: Type.h:5491
llvm::Value * EmitARCRetainAutoreleaseReturnValue(llvm::Value *value)
Do a fused retain/autorelease of the given object.
Definition: CGObjC.cpp:2173
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
Definition: Decl.h:2293
bool ShouldEmitVTableTypeCheckedLoad(const CXXRecordDecl *RD)
Returns whether we should perform a type checked load when loading a virtual function for virtual cal...
Definition: CGClass.cpp:2772
void rescopeLabels()
Change the cleanup scope of the labels in this lexical scope to match the scope of the enclosing cont...
Definition: CGStmt.cpp:491
An RAII object to set (and then clear) a mapping for an OpaqueValueExpr.
const FunctionDecl * CurSEHParent
LValue EmitOMPArraySectionExpr(const OMPArraySectionExpr *E, bool IsLowerBound=true)
Definition: CGExpr.cpp:3033
llvm::CallInst * EmitRuntimeCall(llvm::Value *callee, const Twine &name="")
void InsertHelper(llvm::Instruction *I, const llvm::Twine &Name, llvm::BasicBlock *BB, llvm::BasicBlock::iterator InsertPt) const
CGBuilder insert helper.
void pushEHDestroy(QualType::DestructionKind dtorKind, Address addr, QualType type)
pushEHDestroy - Push the standard destructor for the given type as an EH-only cleanup.
Definition: CGDecl.cpp:1444
Helper class with most of the code for saving a value for a conditional expression cleanup...
void EmitAtomicUpdate(LValue LVal, llvm::AtomicOrdering AO, const llvm::function_ref< RValue(RValue)> &UpdateOp, bool IsVolatile)
Definition: CGAtomic.cpp:1809
void EmitVTablePtrCheck(const CXXRecordDecl *RD, llvm::Value *VTable, CFITypeCheckKind TCK, SourceLocation Loc)
EmitVTablePtrCheck - Emit a check that VTable is a valid virtual table for RD using llvm...
Definition: CGClass.cpp:2688
void EmitOMPPrivateLoopCounters(const OMPLoopDirective &S, OMPPrivateScope &LoopScope)
Emit initial code for loop counters of loop-based directives.
void GenerateCXXGlobalDtorsFunc(llvm::Function *Fn, const std::vector< std::pair< llvm::WeakVH, llvm::Constant * > > &DtorsAndObjects)
GenerateCXXGlobalDtorsFunc - Generates code for destroying global variables.
Definition: CGDeclCXX.cpp:574
llvm::Value * EmitARCAutoreleaseReturnValue(llvm::Value *value)
Autorelease the given object.
Definition: CGObjC.cpp:2163
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="")
Emits a call or invoke instruction to the given function, depending on the current state of the EH st...
Definition: CGCall.cpp:3467
void GenerateObjCCtorDtorMethod(ObjCImplementationDecl *IMP, ObjCMethodDecl *MD, bool ctor)
Definition: CGObjC.cpp:1402
virtual const FieldDecl * lookup(const VarDecl *VD) const
Lookup the captured field decl for a variable.
Defines some OpenMP-specific enums and functions.
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Definition: Expr.h:4509
A metaprogramming class for ensuring that a value will dominate an arbitrary position in a function...
Definition: EHScopeStack.h:66
RValue EmitCall(const CGFunctionInfo &FnInfo, llvm::Value *Callee, ReturnValueSlot ReturnValue, const CallArgList &Args, CGCalleeInfo CalleeInfo=CGCalleeInfo(), llvm::Instruction **callOrInvoke=nullptr)
EmitCall - Generate a call of the given function, expecting the given result type, and using the given argument list which specifies both the LLVM arguments and the types they were derived from.
Definition: CGCall.cpp:3507
This represents '#pragma omp barrier' directive.
Definition: StmtOpenMP.h:1633
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
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp, [NSNumber numberWithInt:42]];.
Definition: ExprObjC.h:144
The this pointer adjustment as well as an optional return adjustment for a thunk. ...
Definition: ABI.h:179
void InitTempAlloca(Address Alloca, llvm::Value *Value)
InitTempAlloca - Provide an initial value for the given alloca which will be observable at all locati...
Definition: CGExpr.cpp:85
Address getExceptionSlot()
Returns a pointer to the function's exception object and selector slot, which is assigned in every la...
llvm::Value * EmitObjCBoxedExpr(const ObjCBoxedExpr *E)
EmitObjCBoxedExpr - This routine generates code to call the appropriate expression boxing method...
Definition: CGObjC.cpp:60
This is a common base class for loop directives ('omp simd', 'omp for', 'omp for simd' etc...
Definition: StmtOpenMP.h:293
RValue EmitLoadOfExtVectorElementLValue(LValue V)
Definition: CGExpr.cpp:1517
const Decl * getDecl() const
Definition: GlobalDecl.h:62
This represents '#pragma omp critical' directive.
Definition: StmtOpenMP.h:1228
LValue EmitLambdaLValue(const LambdaExpr *E)
Definition: CGExpr.cpp:3913
void EmitCXXConstructorCall(const CXXConstructorDecl *D, CXXCtorType Type, bool ForVirtualBase, bool Delegating, Address This, const CXXConstructExpr *E)
Definition: CGClass.cpp:2046
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:495
void EmitLambdaDelegatingInvokeBody(const CXXMethodDecl *MD)
Definition: CGClass.cpp:2965
RValue EmitAnyExprToTemp(const Expr *E)
EmitAnyExprToTemp - Similary to EmitAnyExpr(), however, the result will always be accessible even if ...
Definition: CGExpr.cpp:159
ComplexPairTy EmitLoadOfComplex(LValue src, SourceLocation loc)
EmitLoadOfComplex - Load a complex number from the specified l-value.
void EmitOMPDistributeParallelForSimdDirective(const OMPDistributeParallelForSimdDirective &S)
bool EmitOMPLastprivateClauseInit(const OMPExecutableDirective &D, OMPPrivateScope &PrivateScope)
Emit initial code for lastprivate variables.
Address CreateIRTemp(QualType T, const Twine &Name="tmp")
CreateIRTemp - Create a temporary IR object of the given type, with appropriate alignment.
Definition: CGExpr.cpp:93
RValue EmitAnyExpr(const Expr *E, AggValueSlot aggSlot=AggValueSlot::ignored(), bool ignoreResult=false)
EmitAnyExpr - Emit code to compute the specified expression which can have any type.
Definition: CGExpr.cpp:140
void EmitNoreturnRuntimeCallOrInvoke(llvm::Value *callee, ArrayRef< llvm::Value * > args)
Emits a call or invoke to the given noreturn runtime function.
Definition: CGCall.cpp:3425
const RValue & getOpaqueRValueMapping(const OpaqueValueExpr *e)
getOpaqueRValueMapping - Given an opaque value expression (which must be mapped to an r-value)...
OpenMPDistScheduleClauseKind
OpenMP attributes for 'dist_schedule' clause.
Definition: OpenMPKinds.h:100
llvm::BasicBlock * getStartingBlock() const
Returns a block which will be executed prior to each evaluation of the conditional code...
llvm::Value * EmitARCStoreStrongCall(Address addr, llvm::Value *value, bool resultIgnored)
Store into a strong object.
Definition: CGObjC.cpp:2093
IndirectGotoStmt - This represents an indirect goto.
Definition: Stmt.h:1258
void EmitInheritedCXXConstructorCall(const CXXConstructorDecl *D, bool ForVirtualBase, Address This, bool InheritedFromVBase, const CXXInheritedCtorInitExpr *E)
Emit a call to a constructor inherited from a base class, passing the current constructor's arguments...
Definition: CGClass.cpp:2172
Describes an C or C++ initializer list.
Definition: Expr.h:3746
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Definition: ExprCXX.h:575
This represents '#pragma omp distribute parallel for' composite directive.
Definition: StmtOpenMP.h:2827
void pushRegularPartialArrayCleanup(llvm::Value *arrayBegin, llvm::Value *arrayEnd, QualType elementType, CharUnits elementAlignment, Destroyer *destroyer)
pushRegularPartialArrayCleanup - Push an EH cleanup to destroy already-constructed elements of the gi...
Definition: CGDecl.cpp:1699
A class controlling the emission of a finally block.
Address emitAddrOfRealComponent(Address complex, QualType complexType)
llvm::Value * BuildVector(ArrayRef< llvm::Value * > Ops)
Definition: CGBuiltin.cpp:6542
BinaryOperatorKind
llvm::Value * EmitObjCStringLiteral(const ObjCStringLiteral *E)
Emits an instance of NSConstantString representing the object.
Definition: CGObjC.cpp:46
static bool hasScalarEvaluationKind(QualType T)
Address GetAddrOfBlockDecl(const VarDecl *var, bool ByRef)
Definition: CGBlocks.cpp:1010
ForStmt - This represents a 'for (init;cond;inc)' stmt.
Definition: Stmt.h:1153
InlinedInheritingConstructorScope(CodeGenFunction &CGF, GlobalDecl GD)
ObjCContainerDecl - Represents a container for method declarations.
Definition: DeclObjC.h:901
void emitOMPSimpleStore(LValue LVal, RValue RVal, QualType RValTy, SourceLocation Loc)
void EmitDoStmt(const DoStmt &S, ArrayRef< const Attr * > Attrs=None)
Definition: CGStmt.cpp:733
CharUnits - This is an opaque type for sizes expressed in character units.
Definition: CharUnits.h:38
void EmitTypeMetadataCodeForVCall(const CXXRecordDecl *RD, llvm::Value *VTable, SourceLocation Loc)
If whole-program virtual table optimization is enabled, emit an assumption that VTable is a member of...
Definition: CGClass.cpp:2612
void EmitARCDestroyStrong(Address addr, ARCPreciseLifetime_t precise)
Destroy a __strong variable.
Definition: CGObjC.cpp:2079
bool isLocalVarDeclOrParm() const
Similar to isLocalVarDecl but also includes parameters.
Definition: Decl.h:1036
void ExitSEHTryStmt(const SEHTryStmt &S)
CGCapturedStmtRAII(CodeGenFunction &CGF, CGCapturedStmtInfo *NewCapturedStmtInfo)
void EmitOMPCancellationPointDirective(const OMPCancellationPointDirective &S)
LexicalScope(CodeGenFunction &CGF, SourceRange Range)
Enter a new cleanup scope.
RAII for correct setting/restoring of CapturedStmtInfo.
llvm::Value * EmitBlockLiteral(const BlockExpr *)
Emit a block literal expression in the current function.
Definition: CGBlocks.cpp:679
void EmitContinueStmt(const ContinueStmt &S)
Definition: CGStmt.cpp:1075
void EmitOMPTargetDirective(const OMPTargetDirective &S)
TypeDecl - Represents a declaration of a type.
Definition: Decl.h:2569
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:2897
bool needsEHCleanup(QualType::DestructionKind kind)
Determines whether an EH cleanup is required to destroy a type with the given destruction kind...
llvm::Value * EmitARCUnsafeUnretainedScalarExpr(const Expr *expr)
EmitARCUnsafeUnretainedScalarExpr - Semantically equivalent to immediately releasing the resut of Emi...
Definition: CGObjC.cpp:3047
static OpaqueValueMappingData bind(CodeGenFunction &CGF, const OpaqueValueExpr *ov, const LValue &lv)
void registerGlobalDtorWithAtExit(const VarDecl &D, llvm::Constant *fn, llvm::Constant *addr)
Call atexit() with a function that passes the given argument to the given function.
Definition: CGDeclCXX.cpp:227
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
Definition: StmtCXX.h:128
bool IsOutlinedSEHHelper
True if the current function is an outlined SEH helper.
void EmitOMPTargetUpdateDirective(const OMPTargetUpdateDirective &S)
void EmitSwitchStmt(const SwitchStmt &S)
Definition: CGStmt.cpp:1472
This represents '#pragma omp cancellation point' directive.
Definition: StmtOpenMP.h:2446
bool isObviouslyBranchWithoutCleanups(JumpDest Dest) const
isObviouslyBranchWithoutCleanups - Return true if a branch to the specified destination obviously has...
Definition: CGCleanup.cpp:972
void EmitAggregateAssign(Address DestPtr, Address SrcPtr, QualType EltTy)
EmitAggregateCopy - Emit an aggregate assignment.
llvm::Value * EmitARCLoadWeak(Address addr)
i8* @objc_loadWeak(i8** addr) Essentially objc_autorelease(objc_loadWeakRetained(addr)).
Definition: CGObjC.cpp:2210
ObjCStringLiteral, used for Objective-C string literals i.e.
Definition: ExprObjC.h:29
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:3878
void initFullExprCleanup()
Set up the last cleaup that was pushed as a conditional full-expression cleanup.
Definition: CGCleanup.cpp:285
llvm::Function * GenerateSEHFinallyFunction(CodeGenFunction &ParentCGF, const SEHFinallyStmt &Finally)
LValue EmitUnaryOpLValue(const UnaryOperator *E)
Definition: CGExpr.cpp:2212
A stack of scopes which respond to exceptions, including cleanups and catch blocks.
Definition: EHScopeStack.h:100
void EmitStmt(const Stmt *S)
EmitStmt - Emit the code for the statement.
Definition: CGStmt.cpp:48
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)
EmitARCRetainScalarExpr - Semantically equivalent to EmitARCRetainObject(e->getType(), EmitScalarExpr(e)), but making a best-effort attempt to peephole expressions that naturally produce retained objects.
Definition: CGObjC.cpp:2920
This represents '#pragma omp teams' directive.
Definition: StmtOpenMP.h:2389
void EmitIgnoredExpr(const Expr *E)
EmitIgnoredExpr - Emit an expression in a context which ignores the result.
Definition: CGExpr.cpp:128
Denotes a cleanup that should run when a scope is exited using normal control flow (falling off the e...
Definition: EHScopeStack.h:85
void EmitAtomicInit(Expr *E, LValue lvalue)
Definition: CGAtomic.cpp:1816
llvm::Function * EmitCapturedStmt(const CapturedStmt &S, CapturedRegionKind K)
Generate an outlined function for the body of a CapturedStmt, store any captured variables into the c...
Definition: CGStmt.cpp:2173
void EmitDeleteCall(const FunctionDecl *DeleteFD, llvm::Value *Ptr, QualType DeleteTy)
Definition: CGExprCXX.cpp:1487
Enums/classes describing ABI related information about constructors, destructors and thunks...
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition: Expr.h:2632
LValue EmitObjCMessageExprLValue(const ObjCMessageExpr *E)
Definition: CGExpr.cpp:3920
bool requiresCleanups() const
Determine whether this scope requires any cleanups.
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1119
RValue EmitAtomicExpr(AtomicExpr *E)
Definition: CGAtomic.cpp:661
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1503
iterator end() const
GlobalDecl CurGD
CurGD - The GlobalDecl for the current function being compiled.
void EmitDefaultStmt(const DefaultStmt &S)
Definition: CGStmt.cpp:1251
RValue EmitBuiltinExpr(const FunctionDecl *FD, unsigned BuiltinID, const CallExpr *E, ReturnValueSlot ReturnValue)
Definition: CGBuiltin.cpp:465
static bool ContainsLabel(const Stmt *S, bool IgnoreCaseStmts=false)
ContainsLabel - Return true if the statement contains a label in it.
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:2123
void EmitCaseStmtRange(const CaseStmt &S)
EmitCaseStmtRange - If case statement range is not too big then add multiple cases to switch instruct...
Definition: CGStmt.cpp:1090
uint64_t getCurrentProfileCount()
Get the profiler's current count.
CallLifetimeEnd(Address addr, llvm::Value *size)
Represents an ObjC class declaration.
Definition: DeclObjC.h:1091
RValue convertTempToRValue(Address addr, QualType type, SourceLocation Loc)
Given the address of a temporary variable, produce an r-value of its type.
Definition: CGExpr.cpp:4156
Checking the operand of a cast to a virtual base object.
JumpDest getJumpDestInCurrentScope(StringRef Name=StringRef())
The given basic block lies in the current EH scope, but may be a target of a potentially scope-crossi...
bool isValid() const
Definition: Address.h:36
detail::InMemoryDirectory::const_iterator I
llvm::AllocaInst * EHSelectorSlot
The selector slot.
QualType getType() const
Definition: Decl.h:599
llvm::Value * EmitARCRetainAutoreleasedReturnValue(llvm::Value *value)
Retain the given object which is the result of a function call.
Definition: CGObjC.cpp:2023
static bool ShouldNullCheckClassCastValue(const CastExpr *Cast)
llvm::Value * EmitCheckValue(llvm::Value *V)
Convert a value into a format suitable for passing to a runtime sanitizer handler.
Definition: CGExpr.cpp:2353
void EmitCallArg(CallArgList &args, const Expr *E, QualType ArgType)
EmitCallArg - Emit a single call argument.
Definition: CGCall.cpp:3264
Checking the operand of a load. Must be suitably sized and aligned.
llvm::Value * EmitARCRetainAutoreleaseNonBlock(llvm::Value *value)
Do a fused retain/autorelease of the given object.
Definition: CGObjC.cpp:2202
~LexicalScope()
Exit this cleanup scope, emitting any accumulated cleanups.
LValue EmitLValueForField(LValue Base, const FieldDecl *Field)
Definition: CGExpr.cpp:3310
void EmitDeclRefExprDbgValue(const DeclRefExpr *E, llvm::Constant *Init)
Checking the 'this' pointer for a call to a non-static member function.
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Definition: DeclObjC.h:2655
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:3456
This represents '#pragma omp target parallel for simd' directive.
Definition: StmtOpenMP.h:3034
LValue MakeAddrLValue(Address Addr, QualType T, AlignmentSource AlignSource=AlignmentSource::Type)
LValue EmitExtVectorElementExpr(const ExtVectorElementExpr *E)
Definition: CGExpr.cpp:3186
OpenMP 4.0 [2.4, Array Sections].
Definition: ExprOpenMP.h:45
RValue EmitObjCMessageExpr(const ObjCMessageExpr *E, ReturnValueSlot Return=ReturnValueSlot())
Definition: CGObjC.cpp:341
void EmitCXXConstructExpr(const CXXConstructExpr *E, AggValueSlot Dest)
Definition: CGExprCXX.cpp:440
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:2497
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:551
AutoVarEmission EmitAutoVarAlloca(const VarDecl &var)
EmitAutoVarAlloca - Emit the alloca and debug information for a local variable.
Definition: CGDecl.cpp:953
std::pair< llvm::Value *, llvm::Value * > ComplexPairTy
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3073
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:2019
const CodeGen::CGBlockInfo * BlockInfo
llvm::Function * GenerateBlockFunction(GlobalDecl GD, const CGBlockInfo &Info, const DeclMapTy &ldm, bool IsLambdaConversionToBlock)
Definition: CGBlocks.cpp:1148
This represents '#pragma omp taskgroup' directive.
Definition: StmtOpenMP.h:1721
const TargetCodeGenInfo & getTargetCodeGenInfo()
CGBlockInfo - Information to generate a block literal.
Definition: CGBlocks.h:153
void EmitAnyExprToMem(const Expr *E, Address Location, Qualifiers Quals, bool IsInitializer)
EmitAnyExprToMem - Emits the code necessary to evaluate an arbitrary expression into the given memory...
Definition: CGExpr.cpp:169
unsigned getNumObjects() const
Definition: ExprCXX.h:2969
RValue - This trivial value class is used to represent the result of an expression that is evaluated...
Definition: CGValue.h:38
void EmitSanitizerStatReport(llvm::SanitizerStatKind SSK)
bool addPrivate(const VarDecl *LocalVD, llvm::function_ref< Address()> PrivateGen)
Registers LocalVD variable as a private and apply PrivateGen function for it to generate correspondin...
CleanupKind getARCCleanupKind()
Retrieves the default cleanup kind for an ARC cleanup.
void EmitDelegateCallArg(CallArgList &args, const VarDecl *param, SourceLocation loc)
EmitDelegateCallArg - We are performing a delegate call; that is, the current function is delegating ...
Definition: CGCall.cpp:2881
Represents a call to the builtin function __builtin_va_arg.
Definition: Expr.h:3655
Address CreateDefaultAlignTempAlloca(llvm::Type *Ty, const Twine &Name="tmp")
CreateDefaultAlignedTempAlloca - This creates an alloca with the default ABI alignment of the given L...
Definition: CGExpr.cpp:78
llvm::Value * ExceptionSlot
The exception slot.
This represents '#pragma omp distribute' directive.
Definition: StmtOpenMP.h:2700
LValue MakeAddrLValue(llvm::Value *V, QualType T, CharUnits Alignment, AlignmentSource AlignSource=AlignmentSource::Type)
llvm::Value * EmitVAStartEnd(llvm::Value *ArgValue, bool IsStart)
Emits a call to an LLVM variable-argument intrinsic, either llvm.va_start or llvm.va_end.
Definition: CGBuiltin.cpp:390
Exposes information about the current target.
llvm::Value * EmitARCStoreWeak(Address addr, llvm::Value *value, bool ignored)
i8* @objc_storeWeak(i8** addr, i8* value) Returns value.
Definition: CGObjC.cpp:2225
virtual StringRef getHelperName() const
Get the name of the capture helper.
void EmitCXXGuardedInit(const VarDecl &D, llvm::GlobalVariable *DeclPtr, bool PerformInit)
Emit code in this function to perform a guarded variable initialization.
Definition: CGDeclCXX.cpp:245
int * Depth
llvm::Value * GetVTablePtr(Address This, llvm::Type *VTableTy, const CXXRecordDecl *VTableClass)
GetVTablePtr - Return the Value of the vtable pointer member pointed to by This.
Definition: CGClass.cpp:2563
LValue EmitInitListLValue(const InitListExpr *E)
Definition: CGExpr.cpp:3459
static TypeEvaluationKind getEvaluationKind(QualType T)
hasAggregateLLVMType - Return true if the specified AST type will map into an aggregate LLVM type or ...
void EmitStoreThroughExtVectorComponentLValue(RValue Src, LValue Dst)
Definition: CGExpr.cpp:1749
CXXDtorType
C++ destructor types.
Definition: ABI.h:34
llvm::Value * getPointer() const
Definition: Address.h:38
llvm::BasicBlock * EHResumeBlock
EHResumeBlock - Unified block containing a call to llvm.eh.resume.
void EmitCapturedLocals(CodeGenFunction &ParentCGF, const Stmt *OutlinedStmt, bool IsFilter)
Scan the outlined statement for captures from the parent function.
friend class ASTContext
Definition: Type.h:4178
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Definition: Decl.h:590
llvm::Function * generateDestroyHelper(Address addr, QualType type, Destroyer *destroyer, bool useEHCleanupForArray, const VarDecl *VD)
generateDestroyHelper - Generates a helper function which, when invoked, destroys the given object...
Definition: CGDeclCXX.cpp:601
Expr - This represents one expression.
Definition: Expr.h:105
void enter(CodeGenFunction &CGF, const Stmt *Finally, llvm::Constant *beginCatchFn, llvm::Constant *endCatchFn, llvm::Constant *rethrowFn)
Enters a finally block for an implementation using zero-cost exceptions.
void EmitARCMoveWeak(Address dst, Address src)
void @objc_moveWeak(i8** dest, i8** src) Disregards the current value in dest.
Definition: CGObjC.cpp:2272
void EmitAutoVarInit(const AutoVarEmission &emission)
Definition: CGDecl.cpp:1178
static Address invalid()
Definition: Address.h:35
bool CanDevirtualizeMemberFunctionCall(const Expr *Base, const CXXMethodDecl *MD)
CanDevirtualizeMemberFunctionCalls - Checks whether virtual calls on given expr can be devirtualized...
Definition: CGClass.cpp:2834
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:3888
llvm::Value * EmitComplexToScalarConversion(ComplexPairTy Src, QualType SrcTy, QualType DstTy, SourceLocation Loc)
Emit a conversion from the specified complex type to the specified destination type, where the destination type is an LLVM scalar type.
void EmitCaseStmt(const CaseStmt &S)
Definition: CGStmt.cpp:1168
void EmitStoreOfScalar(llvm::Value *Value, Address Addr, bool Volatile, QualType Ty, AlignmentSource AlignSource=AlignmentSource::Type, llvm::MDNode *TBAAInfo=nullptr, bool isInit=false, QualType TBAABaseTy=QualType(), uint64_t TBAAOffset=0, bool isNontemporal=false)
EmitStoreOfScalar - Store a scalar value to an address, taking care to appropriately convert from the...
Definition: CGExpr.cpp:1374
llvm::Function * GenerateSEHFilterFunction(CodeGenFunction &ParentCGF, const SEHExceptStmt &Except)
Create a stub filter function that will ultimately hold the code of the filter expression.
RValue EmitCXXMemberOrOperatorCall(const CXXMethodDecl *MD, llvm::Value *Callee, ReturnValueSlot ReturnValue, llvm::Value *This, llvm::Value *ImplicitParam, QualType ImplicitParamTy, const CallExpr *E)
Definition: CGExprCXX.cpp:73
static ParamValue forIndirect(Address addr)
void pushCallObjectDeleteCleanup(const FunctionDecl *OperatorDelete, llvm::Value *CompletePtr, QualType ElementType)
Definition: CGExprCXX.cpp:1537
void GenerateObjCMethod(const ObjCMethodDecl *OMD)
Generate an Objective-C method.
Definition: CGObjC.cpp:558
OpaqueValueMapping(CodeGenFunction &CGF, const OpaqueValueExpr *opaqueValue, RValue rvalue)
void EmitOMPTeamsDirective(const OMPTeamsDirective &S)
void EmitVTableAssumptionLoad(const VPtr &vptr, Address This)
Emit assumption that vptr load == global vtable.
Definition: CGClass.cpp:2261
void ForceCleanup()
Force the emission of cleanups now, instead of waiting until this object is destroyed.
void EmitCXXAggrConstructorCall(const CXXConstructorDecl *D, const ArrayType *ArrayTy, Address ArrayPtr, const CXXConstructExpr *E, bool ZeroInitialization=false)
EmitCXXAggrConstructorCall - Emit a loop to call a particular constructor for each of several members...
Definition: CGClass.cpp:1917
static bool isObjCMethodWithTypeParams(const ObjCMethodDecl *method)
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:4567
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2414
Address EmitCompoundStmt(const CompoundStmt &S, bool GetLast=false, AggValueSlot AVS=AggValueSlot::ignored())
EmitCompoundStmt - Emit a compound statement {..} node.
Definition: CGStmt.cpp:324
llvm::Constant * GenerateDestroyHelperFunction(const CGBlockInfo &blockInfo)
Generate the destroy-helper function for a block closure object: static void block_destroy_helper(blo...
Definition: CGBlocks.cpp:1510
static saved_type save(CodeGenFunction &CGF, type value)
void SetFPAccuracy(llvm::Value *Val, float Accuracy)
SetFPAccuracy - Set the minimum required accuracy of the given floating point operation, expressed as the maximum relative error in ulp.
Definition: CGExpr.cpp:4171
AggValueSlot CreateAggTemp(QualType T, const Twine &Name="tmp")
CreateAggTemp - Create a temporary memory object for the given aggregate type.
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.
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
Definition: ExprObjC.h:257
void EmitSEHTryStmt(const SEHTryStmt &S)
ASTContext & getContext() const
CharUnits getNaturalPointeeTypeAlignment(QualType T, AlignmentSource *Source=nullptr)
llvm::Value * EmitToMemory(llvm::Value *Value, QualType Ty)
EmitToMemory - Change a scalar value from its value representation to its in-memory representation...
Definition: CGExpr.cpp:1349
llvm::BasicBlock * getBlock() const
Represents Objective-C's @synchronized statement.
Definition: StmtObjC.h:262
ObjCSelectorExpr used for @selector in Objective-C.
Definition: ExprObjC.h:397
EHScopeStack::stable_iterator getScopeDepth() const
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
Definition: CharUnits.h:63
CXXTryStmt - A C++ try block, including all handlers.
Definition: StmtCXX.h:65
void EmitOMPLinearClauseInit(const OMPLoopDirective &D)
Emit initial code for linear variables.
void generateObjCSetterBody(const ObjCImplementationDecl *classImpl, const ObjCPropertyImplDecl *propImpl, llvm::Constant *AtomicHelperFn)
Definition: CGObjC.cpp:1145
~OMPPrivateScope()
Exit scope - all the mapped variables are restored.
static LValue MakeAddr(Address address, QualType type, ASTContext &Context, AlignmentSource alignSource, llvm::MDNode *TBAAInfo=nullptr)
Definition: CGValue.h:371
llvm::Value * getExceptionFromSlot()
Returns the contents of the function's exception object and selector slots.
void EmitAsanPrologueOrEpilogue(bool Prologue)
Definition: CGClass.cpp:854
llvm::Value * EmitARCAutorelease(llvm::Value *value)
Autorelease the given object.
Definition: CGObjC.cpp:2154
stable_iterator stable_begin() const
Create a stable reference to the top of the EH stack.
Definition: EHScopeStack.h:379
llvm::LLVMContext & getLLVMContext()
llvm::BasicBlock * GetIndirectGotoBlock()
void EmitLambdaExpr(const LambdaExpr *E, AggValueSlot Dest)
Definition: CGExprCXX.cpp:1938
An RAII object to record that we're evaluating a statement expression.
RValue EmitCXXMemberOrOperatorMemberCallExpr(const CallExpr *CE, const CXXMethodDecl *MD, ReturnValueSlot ReturnValue, bool HasQualifier, NestedNameSpecifier *Qualifier, bool IsArrow, const Expr *Base)
Definition: CGExprCXX.cpp:132
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:854
void EmitConstructorBody(FunctionArgList &Args)
EmitConstructorBody - Emits the body of the current constructor.
Definition: CGClass.cpp:917
Address EmitPointerWithAlignment(const Expr *Addr, AlignmentSource *Source=nullptr)
EmitPointerWithAlignment - Given an expression with a pointer type, emit the value and compute our be...
Definition: CGExpr.cpp:820
void EmitOMPMasterDirective(const OMPMasterDirective &S)
static std::pair< llvm::Function *, llvm::Constant * > EmitOMPTargetDirectiveOutlinedFunction(CodeGenModule &CGM, const OMPTargetDirective &S, StringRef ParentName, bool IsOffloadEntry)
Emit outlined function for the target directive.
llvm::Function * GenerateCapturedStmtFunction(const CapturedStmt &S)
Creates the outlined function for a CapturedStmt.
Definition: CGStmt.cpp:2195
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
Definition: Stmt.h:1366
LValue MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T)
An expression that sends a message to the given Objective-C object or class.
Definition: ExprObjC.h:860
ComplexPairTy EmitComplexPrePostIncDec(const UnaryOperator *E, LValue LV, bool isInc, bool isPre)
Definition: CGExpr.cpp:772
JumpDest(llvm::BasicBlock *Block, EHScopeStack::stable_iterator Depth, unsigned Index)
Address EmitLoadOfPointer(Address Ptr, const PointerType *PtrTy, AlignmentSource *Source=nullptr)
Definition: CGExpr.cpp:1974
void ResolveBranchFixups(llvm::BasicBlock *Target)
Definition: CGCleanup.cpp:382
void EmitForwardingCallToLambda(const CXXMethodDecl *LambdaCallOperator, CallArgList &CallArgs)
Definition: CGClass.cpp:2898
void EmitMCountInstrumentation()
EmitMCountInstrumentation - Emit call to .mcount.
void EmitAggregateCopyCtor(Address DestPtr, Address SrcPtr, QualType DestTy, QualType SrcTy)
An object which temporarily prevents a value from being destroyed by aggressive peephole optimization...
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
Definition: Expr.h:1668
void EmitOMPBarrierDirective(const OMPBarrierDirective &S)
void EmitLambdaToBlockPointerBody(FunctionArgList &Args)
Definition: CGClass.cpp:2954
llvm::Value * EmitCastToVoidPtr(llvm::Value *value)
Emit a cast to void* in the appropriate address space.
Definition: CGExpr.cpp:46
void emitArrayDestroy(llvm::Value *begin, llvm::Value *end, QualType elementType, CharUnits elementAlign, Destroyer *destroyer, bool checkZeroLength, bool useEHCleanup)
emitArrayDestroy - Destroys all the elements of the given array, beginning from last to first...
Definition: CGDecl.cpp:1544
ConstantEmission tryEmitAsConstant(DeclRefExpr *refExpr)
Try to emit a reference to the given value without producing it as an l-value.
Definition: CGExpr.cpp:1135
This represents '#pragma omp cancel' directive.
Definition: StmtOpenMP.h:2504
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:1568
void EmitCXXGlobalVarDeclInit(const VarDecl &D, llvm::Constant *DeclPtr, bool PerformInit)
EmitCXXGlobalVarDeclInit - Create the initializer for a C++ variable with global storage.
Definition: CGDeclCXX.cpp:140
bool isGLValue() const
Definition: Expr.h:250
static AggValueSlot forAddr(Address addr, Qualifiers quals, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, IsAliased_t isAliased, IsZeroed_t isZeroed=IsNotZeroed)
forAddr - Make a slot for an aggregate value.
Definition: CGValue.h:502
RValue EmitAtomicLoad(LValue LV, SourceLocation SL, AggValueSlot Slot=AggValueSlot::ignored())
Definition: CGAtomic.cpp:1284
do v
Definition: arm_acle.h:78
void generateThunk(llvm::Function *Fn, const CGFunctionInfo &FnInfo, GlobalDecl GD, const ThunkInfo &Thunk)
Generate a thunk for the given method.
Definition: CGVTables.cpp:396
llvm::Value * EmitX86BuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition: CGBuiltin.cpp:6679
GlobalDecl - represents a global declaration.
Definition: GlobalDecl.h:29
This represents '#pragma omp flush' directive.
Definition: StmtOpenMP.h:1772
This represents '#pragma omp parallel for simd' directive.
Definition: StmtOpenMP.h:1382
DoStmt - This represents a 'do/while' stmt.
Definition: Stmt.h:1102
AsmStmt is the base class for GCCAsmStmt and MSAsmStmt.
Definition: Stmt.h:1414
void EmitDeclStmt(const DeclStmt &S)
Definition: CGStmt.cpp:1053
llvm::Value * EmitAMDGPUBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition: CGBuiltin.cpp:7587
LValue EmitLoadOfPointerLValue(Address Ptr, const PointerType *PtrTy)
Definition: CGExpr.cpp:1982
llvm::BasicBlock * getEHDispatchBlock(EHScopeStack::stable_iterator scope)
The l-value was considered opaque, so the alignment was determined from a type.
llvm::Value * EmitPPCBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition: CGBuiltin.cpp:7370
void EmitAlignmentAssumption(llvm::Value *PtrValue, unsigned Alignment, llvm::Value *OffsetValue=nullptr)
void setBlockContextParameter(const ImplicitParamDecl *D, unsigned argNum, llvm::Value *ptr)
Definition: CGBlocks.cpp:1109
void enterByrefCleanup(const AutoVarEmission &emission)
Enter a cleanup to destroy a __block variable.
Definition: CGBlocks.cpp:2286
This represents '#pragma omp target enter data' directive.
Definition: StmtOpenMP.h:2132
void EmitOMPFlushDirective(const OMPFlushDirective &S)
OMPPrivateScope(CodeGenFunction &CGF)
Enter a new OpenMP private scope.
bool HaveInsertPoint() const
HaveInsertPoint - True if an insertion point is defined.
Address recoverAddrOfEscapedLocal(CodeGenFunction &ParentCGF, Address ParentVar, llvm::Value *ParentFP)
Recovers the address of a local in a parent function.
llvm::SmallVector< VPtr, 4 > VPtrsVector
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
Definition: ExprCXX.h:290
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
Definition: Expr.h:848
bool SawAsmBlock
Whether we processed a Microsoft-style asm block during CodeGen.
#define false
Definition: stdbool.h:33
llvm::GlobalVariable * AddInitializerToStaticVarDecl(const VarDecl &D, llvm::GlobalVariable *GV)
AddInitializerToStaticVarDecl - Add the initializer for 'D' to the global variable that has already b...
Definition: CGDecl.cpp:292
Kind
This captures a statement into a function.
Definition: Stmt.h:2006
Represents a call to an inherited base class constructor from an inheriting constructor.
Definition: ExprCXX.h:1325
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition: Expr.h:4679
LValue EmitVAArgExprLValue(const VAArgExpr *E)
Definition: CGExpr.cpp:3873
ConstExprIterator const_arg_iterator
Definition: Expr.h:2238
llvm::Value * EmitCXXTypeidExpr(const CXXTypeidExpr *E)
Definition: CGExprCXX.cpp:1816
void PushDestructorCleanup(QualType T, Address Addr)
PushDestructorCleanup - Push a cleanup to call the complete-object destructor of an object of the giv...
Definition: CGClass.cpp:2421
ASTContext & getContext() const
void pushDestroy(QualType::DestructionKind dtorKind, Address addr, QualType type)
pushDestroy - Push the standard destructor for the given type as at least a normal cleanup...
Definition: CGDecl.cpp:1454
This represents '#pragma omp single' directive.
Definition: StmtOpenMP.h:1126
Encodes a location in the source.
bool LValueIsSuitableForInlineAtomic(LValue Src)
An LValue is a candidate for having its loads and stores be made atomic if we are operating under /vo...
Definition: CGAtomic.cpp:1271
llvm::Value * EmitObjCArrayLiteral(const ObjCArrayLiteral *E)
Definition: CGObjC.cpp:225
void EnsureInsertPoint()
EnsureInsertPoint - Ensure that an insertion point is defined so that emitted IR has a place to go...
void EmitARCIntrinsicUse(ArrayRef< llvm::Value * > values)
Given a number of pointers, inform the optimizer that they're being intrinsically used up until this ...
Definition: CGObjC.cpp:1783
void EmitOMPForDirective(const OMPForDirective &S)
void EmitARCRelease(llvm::Value *value, ARCPreciseLifetime_t precise)
Release the given object.
Definition: CGObjC.cpp:2047
LValue EmitDeclRefLValue(const DeclRefExpr *E)
Definition: CGExpr.cpp:2072
std::pair< LValue, llvm::Value * > EmitARCStoreUnsafeUnretained(const BinaryOperator *e, bool ignored)
Definition: CGObjC.cpp:3059
const TemplateArgument * iterator
Definition: Type.h:4233
A saved depth on the scope stack.
Definition: EHScopeStack.h:107
Represents a C++ temporary.
Definition: ExprCXX.h:1088
llvm::Value * EvaluateExprAsBool(const Expr *E)
EvaluateExprAsBool - Perform the usual unary conversions on the specified expression and compare the ...
Definition: CGExpr.cpp:110
LValue EmitCheckedLValue(const Expr *E, TypeCheckKind TCK)
Same as EmitLValue but additionally we generate checking code to guard against undefined behavior...
Definition: CGExpr.cpp:943
~RunCleanupsScope()
Exit this cleanup scope, emitting any accumulated cleanups.
llvm::Value * EmitFromMemory(llvm::Value *Value, QualType Ty)
EmitFromMemory - Change a scalar value from its memory representation to its value representation...
Definition: CGExpr.cpp:1363
llvm::BasicBlock * getUnreachableBlock()
void setBeforeOutermostConditional(llvm::Value *value, Address addr)
This is a basic class for representing single OpenMP executable directive.
Definition: StmtOpenMP.h:33
llvm::Value * EmitLoadOfScalar(Address Addr, bool Volatile, QualType Ty, SourceLocation Loc, AlignmentSource AlignSource=AlignmentSource::Type, llvm::MDNode *TBAAInfo=nullptr, QualType TBAABaseTy=QualType(), uint64_t TBAAOffset=0, bool isNontemporal=false)
EmitLoadOfScalar - Load a scalar value from an address, taking care to appropriately convert from the...
Definition: CGExpr.cpp:1262
void EmitVTableAssumptionLoads(const CXXRecordDecl *ClassDecl, Address This)
Emit assumption load for all bases.
Definition: CGClass.cpp:2282
SmallVector< llvm::Value *, 8 > ObjCEHValueStack
ObjCEHValueStack - Stack of Objective-C exception values, used for rethrows.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
Definition: ExprCXX.h:1804
void EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S)
Definition: CGObjC.cpp:1452
const std::string ID
llvm::Value * EmitARCUnsafeClaimAutoreleasedReturnValue(llvm::Value *value)
Claim a possibly-autoreleased return value at +0.
Definition: CGObjC.cpp:2038
Represents a call to a member function that may be written either with member call syntax (e...
Definition: ExprCXX.h:121
bool isCleanupPadScope() const
Returns true while emitting a cleanuppad.
LValue EmitAggExprToLValue(const Expr *E)
EmitAggExprToLValue - Emit the computation of the specified expression of aggregate type into a tempo...
Definition: CGExprAgg.cpp:1449
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PL, ArrayRef< Expr * > IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
void DeactivateCleanupBlock(EHScopeStack::stable_iterator Cleanup, llvm::Instruction *DominatingIP)
DeactivateCleanupBlock - Deactivates the given cleanup block.
Definition: CGCleanup.cpp:1193
void EmitCallAndReturnForThunk(llvm::Value *Callee, const ThunkInfo *Thunk)
Definition: CGVTables.cpp:254
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
Definition: Stmt.h:443
Checking the operand of a cast to a base object.
OpenMPDirectiveKind
OpenMP directives.
Definition: OpenMPKinds.h:23
LabelDecl - Represents the declaration of a label.
Definition: Decl.h:424
An aggregate value slot.
Definition: CGValue.h:441
llvm::Constant * createAtExitStub(const VarDecl &VD, llvm::Constant *Dtor, llvm::Constant *Addr)
Create a stub function, suitable for being passed to atexit, which passes the given address to the gi...
Definition: CGDeclCXX.cpp:194
const BlockByrefInfo & getBlockByrefInfo(const VarDecl *var)
BuildByrefInfo - This routine changes a __block variable declared as T x into:
Definition: CGBlocks.cpp:2065
llvm::Value * EmitLifetimeStart(uint64_t Size, llvm::Value *Addr)
Emit a lifetime.begin marker if some criteria are satisfied.
Definition: CGDecl.cpp:930
A scoped helper to set the current debug location to the specified location or preferred location of ...
Definition: CGDebugInfo.h:539
void EmitOMPLinearClauseFinal(const OMPLoopDirective &D, const llvm::function_ref< llvm::Value *(CodeGenFunction &)> &CondGen)
Emit final code for linear clauses.
LValue EmitUnsupportedLValue(const Expr *E, const char *Name)
EmitUnsupportedLValue - Emit a dummy l-value using the type of E and issue an ErrorUnsupported style ...
Definition: CGExpr.cpp:935
llvm::Value * EmitAArch64BuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition: CGBuiltin.cpp:4785
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1736
static type restore(CodeGenFunction &CGF, saved_type value)
OpenMPLinearClauseKind Modifier
Modifier of 'linear' clause.
Definition: OpenMPClause.h:262
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
This represents '#pragma omp taskwait' directive.
Definition: StmtOpenMP.h:1677
void EmitOMPTaskgroupDirective(const OMPTaskgroupDirective &S)
SanitizerSet SanOpts
Sanitizers enabled for this function.
void EmitOMPTargetParallelForSimdDirective(const OMPTargetParallelForSimdDirective &S)
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2171
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:1164
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load, __atomic_store, and __atomic_compare_exchange_*, for the similarly-named C++11 instructions, and __c11 variants for <stdatomic.h>.
Definition: Expr.h:4804
void EmitCXXTemporary(const CXXTemporary *Temporary, QualType TempType, Address Ptr)
Emits all the code to cause the given temporary to be cleaned up.
Definition: CGCleanup.cpp:1223
llvm::Value * EmitNeonCall(llvm::Function *F, SmallVectorImpl< llvm::Value * > &O, const char *name, unsigned shift=0, bool rightshift=false)
Definition: CGBuiltin.cpp:2573
ObjCProtocolExpr used for protocol expression in Objective-C.
Definition: ExprObjC.h:441
const CodeGenOptions & getCodeGenOpts() const
LValue getReferenceLValue(CodeGenFunction &CGF, Expr *refExpr) const
bool hasVolatileMember() const
Definition: Decl.h:3328
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)
An aligned address.
Definition: Address.h:25
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)
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of captures.
Definition: Stmt.h:2153
This represents '#pragma omp target' directive.
Definition: StmtOpenMP.h:2016
SourceLocation getBegin() const
void EmitOMPForSimdDirective(const OMPForSimdDirective &S)
llvm::Instruction * CurrentFuncletPad
LValue EmitPointerToDataMemberBinaryExpr(const BinaryOperator *E)
Definition: CGExpr.cpp:4133
void EmitOMPAtomicDirective(const OMPAtomicDirective &S)
JumpDest getJumpDestInCurrentScope(llvm::BasicBlock *Target)
The given basic block lies in the current EH scope, but may be a target of a potentially scope-crossi...
void EmitOMPSectionDirective(const OMPSectionDirective &S)
void EmitOMPSectionsDirective(const OMPSectionsDirective &S)
RValue EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E, ReturnValueSlot ReturnValue)
Definition: CGExprCXX.cpp:285
TargetCodeGenInfo - This class organizes various target-specific codegeneration issues, like target-specific attributes, builtins and so on.
Checking the object expression in a non-static data member access.
This represents '#pragma omp ordered' directive.
Definition: StmtOpenMP.h:1827
void EmitParmDecl(const VarDecl &D, ParamValue Arg, unsigned ArgNo)
EmitParmDecl - Emit a ParmVarDecl or an ImplicitParamDecl.
Definition: CGDecl.cpp:1747
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Definition: Expr.h:3380
static ParamValue forDirect(llvm::Value *value)
static llvm::Value * restore(CodeGenFunction &CGF, saved_type value)
void EmitForStmt(const ForStmt &S, ArrayRef< const Attr * > Attrs=None)
Definition: CGStmt.cpp:793
void EmitOMPDistributeLoop(const OMPDistributeDirective &S)
This represents '#pragma omp target update' directive.
Definition: StmtOpenMP.h:2768
ObjCBoxedExpr - used for generalized expression boxing.
Definition: ExprObjC.h:94
void EmitOMPTaskLoopDirective(const OMPTaskLoopDirective &S)
RValue EmitCallExpr(const CallExpr *E, ReturnValueSlot ReturnValue=ReturnValueSlot())
Definition: CGExpr.cpp:3733
RValue EmitBuiltinNewDeleteCall(const FunctionProtoType *Type, const Expr *Arg, bool IsDelete)
Definition: CGExprCXX.cpp:1145
llvm::Value * EmitARCRetain(QualType type, llvm::Value *value)
Produce the code to do a retain.
Definition: CGObjC.cpp:1931
Address EmitMSVAListRef(const Expr *E)
Emit a "reference" to a __builtin_ms_va_list; this is always the value of the expression, because a __builtin_ms_va_list is a pointer to a char.
const CGFunctionInfo * CurFnInfo
void EmitStartEHSpec(const Decl *D)
EmitStartEHSpec - Emit the start of the exception spec.
void Emit(CodeGenFunction &CGF, Flags flags) override
Emit the cleanup.
void EmitInlinedInheritingCXXConstructorCall(const CXXConstructorDecl *Ctor, CXXCtorType CtorType, bool ForVirtualBase, bool Delegating, CallArgList &Args)
Emit a call to an inheriting constructor (that is, one that invokes a constructor inherited from a ba...
Definition: CGClass.cpp:2219
static ConstantEmission forReference(llvm::Constant *C)
void enterFullExpression(const ExprWithCleanups *E)
void EmitDecl(const Decl &D)
EmitDecl - Emit a declaration.
Definition: CGDecl.cpp:38
static Destroyer destroyARCStrongImprecise
void FinishFunction(SourceLocation EndLoc=SourceLocation())
FinishFunction - Complete IR generation of the current function.
CXXCtorType
C++ constructor types.
Definition: ABI.h:25
void EmitObjCMRRAutoreleasePoolPop(llvm::Value *Ptr)
Produce the code to do a primitive release.
Definition: CGObjC.cpp:2349
CompoundAssignOperator - For compound assignments (e.g.
Definition: Expr.h:3092
void InitializeVTablePointer(const VPtr &vptr)
Initialize the vtable pointer of the given subobject.
Definition: CGClass.cpp:2431
Address EmitVAListRef(const Expr *E)
JumpDest getOMPCancelDestination(OpenMPDirectiveKind Kind)
llvm::Value * EmitScalarExpr(const Expr *E, bool IgnoreResultAssign=false)
EmitScalarExpr - Emit the computation of the specified expression of LLVM scalar type, returning the result.
FunctionArgList - Type for representing both the decl and type of parameters to a function...
Definition: CGCall.h:146
QualType getType() const
Definition: Expr.h:126
llvm::BasicBlock * getMSVCDispatchBlock(EHScopeStack::stable_iterator scope)
void GenerateOpenMPCapturedVars(const CapturedStmt &S, SmallVectorImpl< llvm::Value * > &CapturedVars)
void EmitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt &S)
Definition: CGObjC.cpp:1749
CGFunctionInfo - Class to encapsulate the information about a function definition.
llvm::Value * EmitNeonRShiftImm(llvm::Value *Vec, llvm::Value *Amt, llvm::Type *Ty, bool usgn, const char *name)
Definition: CGBuiltin.cpp:2594
CharUnits getAlignment() const
Return the alignment of this pointer.
Definition: Address.h:67
Expr * getCommon() const
getCommon - Return the common expression, written to the left of the condition.
Definition: Expr.h:3280
This class organizes the cross-function state that is used while generating LLVM code.
Class provides a way to call simple version of codegen for OpenMP region, or an advanced with possibl...
Address getObjectAddress(CodeGenFunction &CGF) const
Returns the address of the object within this declaration.
void EmitCXXDestructorCall(const CXXDestructorDecl *D, CXXDtorType Type, bool ForVirtualBase, bool Delegating, Address This)
Definition: CGClass.cpp:2391
uint64_t SanitizerMask
Definition: Sanitizers.h:24
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.
Definition: CGClass.cpp:2643
LValue InitCapturedStruct(const CapturedStmt &S)
Definition: CGStmt.cpp:2146
[C99 6.4.2.2] - A predefined identifier such as func.
Definition: Expr.h:1160
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1135
Address EmitFieldAnnotations(const FieldDecl *D, Address V)
Emit field annotations for the given field & value.
RValue EmitUnsupportedRValue(const Expr *E, const char *Name)
EmitUnsupportedRValue - Emit a dummy r-value using the type of E and issue an ErrorUnsupported style ...
Definition: CGExpr.cpp:929
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
Definition: ExprCXX.h:2008
void GenerateObjCGetter(ObjCImplementationDecl *IMP, const ObjCPropertyImplDecl *PID)
GenerateObjCGetter - Synthesize an Objective-C property getter function.
Definition: CGObjC.cpp:795
bool isZero() const
isZero - Test whether the quantity equals zero.
Definition: CharUnits.h:116
void EmitOMPTargetParallelDirective(const OMPTargetParallelDirective &S)
void EmitObjCAutoreleasePoolPop(llvm::Value *Ptr)
Produce the code to do a primitive release.
Definition: CGObjC.cpp:2302
Address CreateMemTemp(QualType T, const Twine &Name="tmp")
CreateMemTemp - Create a temporary memory object of the given type, with appropriate alignment...
Definition: CGExpr.cpp:98
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Definition: ASTMatchers.h:1983
static AggValueSlot ignored()
ignored - Returns an aggregate value slot indicating that the aggregate value is being ignored...
Definition: CGValue.h:487
CodeGenFunction::ComplexPairTy ComplexPairTy
void EmitOMPParallelForDirective(const OMPParallelForDirective &S)
llvm::Value * EmitARCLoadWeakRetained(Address addr)
i8* @objc_loadWeakRetained(i8** addr)
Definition: CGObjC.cpp:2217
void EmitAnyExprToExn(const Expr *E, Address Addr)
This represents '#pragma omp section' directive.
Definition: StmtOpenMP.h:1064
A scope within which we are constructing the fields of an object which might use a CXXDefaultInitExpr...
llvm::Value * EmitAnnotationCall(llvm::Value *AnnotationFn, llvm::Value *AnnotatedVal, StringRef AnnotationStr, SourceLocation Location)
Emit an annotation call (intrinsic or builtin).
llvm::Value * EmitWebAssemblyBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition: CGBuiltin.cpp:8078
llvm::LoadInst * CreateAlignedLoad(llvm::Value *Addr, CharUnits Align, const llvm::Twine &Name="")
Definition: CGBuilder.h:91
void EmitOMPPrivateClause(const OMPExecutableDirective &D, OMPPrivateScope &PrivateScope)
void EmitOMPTargetParallelForDirective(const OMPTargetParallelForDirective &S)
Checking the bound value in a reference binding.
LValue EmitCallExprLValue(const CallExpr *E)
Definition: CGExpr.cpp:3859
LValue EmitPseudoObjectLValue(const PseudoObjectExpr *e)
Definition: CGExpr.cpp:4261
This represents '#pragma omp simd' directive.
Definition: StmtOpenMP.h:789
void EmitDelegatingCXXConstructorCall(const CXXConstructorDecl *Ctor, const FunctionArgList &Args)
Definition: CGClass.cpp:2366
void InitializeVTablePointers(const CXXRecordDecl *ClassDecl)
Definition: CGClass.cpp:2549
void EmitOMPLinearClause(const OMPLoopDirective &D, CodeGenFunction::OMPPrivateScope &PrivateScope)
Emit initial code for linear clauses.
QualType TypeOfSelfObject()
TypeOfSelfObject - Return type of object that this self represents.
Definition: CGObjC.cpp:1444
Header for data within LifetimeExtendedCleanupStack.
Checking the destination of a store. Must be suitably sized and aligned.
detail::InMemoryDirectory::const_iterator E
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition: Type.h:2401
void EmitAggregateCopy(Address DestPtr, Address SrcPtr, QualType EltTy, bool isVolatile=false, bool isAssignment=false)
EmitAggregateCopy - Emit an aggregate copy.
Definition: CGExprAgg.cpp:1459
bool EmitOMPFirstprivateClause(const OMPExecutableDirective &D, OMPPrivateScope &PrivateScope)
void EmitOMPCancelDirective(const OMPCancelDirective &S)
llvm::SmallVector< char, 256 > LifetimeExtendedCleanupStack
llvm::StoreInst * CreateStore(llvm::Value *Val, Address Addr, bool IsVolatile=false)
Definition: CGBuilder.h:113
llvm::Constant * GenerateObjCAtomicGetterCopyHelperFunction(const ObjCPropertyImplDecl *PID)
Definition: CGObjC.cpp:3244
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
Definition: ASTContext.h:1966
bool isSEHTryScope() const
Returns true inside SEH __try blocks.
This represents '#pragma omp atomic' directive.
Definition: StmtOpenMP.h:1882
void EmitObjCAtThrowStmt(const ObjCAtThrowStmt &S)
Definition: CGObjC.cpp:1745
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
Definition: DeclBase.h:1473
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:532
void EmitAggExpr(const Expr *E, AggValueSlot AS)
EmitAggExpr - Emit the computation of the specified expression of aggregate type. ...
Definition: CGExprAgg.cpp:1437
Represents a __leave statement.
Definition: Stmt.h:1972
JumpDest ReturnBlock
ReturnBlock - Unified return block.
llvm::DenseMap< const Decl *, Address > DeclMapTy
Checking the operand of a static_cast to a derived reference type.
static bool hasAggregateEvaluationKind(QualType T)
llvm::Value * EmitNeonSplat(llvm::Value *V, llvm::Constant *Idx)
Definition: CGBuiltin.cpp:2567
SwitchStmt - This represents a 'switch' stmt.
Definition: Stmt.h:957
void EmitAutoVarCleanups(const AutoVarEmission &emission)
Definition: CGDecl.cpp:1382
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2461
API for captured statement code generation.
static saved_type save(CodeGenFunction &CGF, type value)
static bool isObjCMethodWithTypeParams(const T *)
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:3707
llvm::Type * ConvertType(const TypeDecl *T)
const LValue & getOpaqueLValueMapping(const OpaqueValueExpr *e)
getOpaqueLValueMapping - Given an opaque value expression (which must be mapped to an l-value)...
void EmitBlockWithFallThrough(llvm::BasicBlock *BB, const Stmt *S)
When instrumenting to collect profile data, the counts for some blocks such as switch cases need to n...
llvm::Value * vectorWrapScalar16(llvm::Value *Op)
Definition: CGBuiltin.cpp:4776
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:5818
Checking the operand of a static_cast to a derived pointer type.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition: Expr.h:2063
Represents Objective-C's collection statement.
Definition: StmtObjC.h:24
AbstractConditionalOperator - An abstract base class for ConditionalOperator and BinaryConditionalOpe...
Definition: Expr.h:3128
OpaqueValueExpr * getOpaqueValue() const
getOpaqueValue - Return the opaque value placeholder.
Definition: Expr.h:3283
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:903
Implements C++ ABI-specific code generation functions.
Definition: CGCXXABI.h:43
ObjCEncodeExpr, used for @encode in Objective-C.
Definition: ExprObjC.h:355
LValue EmitArraySubscriptExpr(const ArraySubscriptExpr *E, bool Accessed=false)
Definition: CGExpr.cpp:2869
Address EmitCXXMemberDataPointerAddress(const Expr *E, Address base, llvm::Value *memberPtr, const MemberPointerType *memberPtrType, AlignmentSource *AlignSource=nullptr)
Emit the address of a field using a member data pointer.
Definition: CGClass.cpp:129
A stack of loop information corresponding to loop nesting levels.
Definition: CGLoopInfo.h:94
void EmitAsmStmt(const AsmStmt &S)
Definition: CGStmt.cpp:1791
llvm::Value * EmitNeonShiftVector(llvm::Value *V, llvm::Type *Ty, bool negateForRightShift)
Definition: CGBuiltin.cpp:2587
This class organizes the cross-module state that is used while lowering AST types to LLVM types...
Definition: CodeGenTypes.h:120
void EmitOMPTaskBasedDirective(const OMPExecutableDirective &S, const RegionCodeGenTy &BodyGen, const TaskGenTy &TaskGen, OMPTaskDataTy &Data)
Represents a call to a CUDA kernel function.
Definition: ExprCXX.h:160
RValue EmitRValueForField(LValue LV, const FieldDecl *FD, SourceLocation Loc)
Definition: CGExpr.cpp:3709
void EmitLambdaStaticInvokeFunction(const CXXMethodDecl *MD)
Definition: CGClass.cpp:2995
llvm::AssertingVH< llvm::Instruction > AllocaInsertPt
AllocaInsertPoint - This is an instruction in the entry block before which we prefer to insert alloca...
bool isFunctionType() const
Definition: Type.h:5479
LValue EmitLValueForIvar(QualType ObjectTy, llvm::Value *Base, const ObjCIvarDecl *Ivar, unsigned CVRQualifiers)
Definition: CGExpr.cpp:3945
LValue EmitLoadOfReferenceLValue(Address Ref, const ReferenceType *RefTy)
Definition: CGExpr.cpp:1967
QualType BuildFunctionArgList(GlobalDecl GD, FunctionArgList &Args)
void EmitScalarInit(const Expr *init, const ValueDecl *D, LValue lvalue, bool capturedByInit)
Definition: CGDecl.cpp:660
Base for LValueReferenceType and RValueReferenceType.
Definition: Type.h:2319
void EmitSynthesizedCXXCopyCtor(Address Dest, Address Src, const Expr *Exp)
Definition: CGExprCXX.cpp:512
bool hasProfileClangInstr() const
Check if Clang profile instrumenation is on.
llvm::Value * EmitIvarOffset(const ObjCInterfaceDecl *Interface, const ObjCIvarDecl *Ivar)
Definition: CGExpr.cpp:3940
llvm::Value * EmitARCRetainAutorelease(QualType type, llvm::Value *value)
Do a fused retain/autorelease of the given object.
Definition: CGObjC.cpp:2185
LValue EmitCastLValue(const CastExpr *E)
EmitCastLValue - Casts are never lvalues unless that cast is to a reference type. ...
Definition: CGExpr.cpp:3564
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
EmitBlock - Emit the given block.
Definition: CGStmt.cpp:397
void EmitOMPTargetEnterDataDirective(const OMPTargetEnterDataDirective &S)
void EmitARCInitWeak(Address addr, llvm::Value *value)
i8* @objc_initWeak(i8** addr, i8* value) Returns value.
Definition: CGObjC.cpp:2237
void EnterCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock=false)
void checkTargetFeatures(const CallExpr *E, const FunctionDecl *TargetDecl)
llvm::Value * LoadCXXVTT()
LoadCXXVTT - Load the VTT parameter to base constructors/destructors have virtual bases...
ARCPreciseLifetime_t
Does an ARC strong l-value have precise lifetime?
Definition: CGValue.h:119
ComplexPairTy EmitComplexExpr(const Expr *E, bool IgnoreReal=false, bool IgnoreImag=false)
EmitComplexExpr - Emit the computation of the specified expression of complex type, returning the result.
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition: ExprObjC.h:479
void EmitFunctionBody(FunctionArgList &Args, const Stmt *Body)
void StartThunk(llvm::Function *Fn, GlobalDecl GD, const CGFunctionInfo &FnInfo)
Definition: CGVTables.cpp:208
LValue EmitConditionalOperatorLValue(const AbstractConditionalOperator *E)
Definition: CGExpr.cpp:3483
void EmitOMPDistributeSimdDirective(const OMPDistributeSimdDirective &S)
VPtrsVector getVTablePointers(const CXXRecordDecl *VTableClass)
Definition: CGClass.cpp:2481
const Decl * CurFuncDecl
CurFuncDecl - Holds the Decl for the current outermost non-closure context.
void EmitStopPoint(const Stmt *S)
EmitStopPoint - Emit a debug stoppoint if we are emitting debug info.
Definition: CGStmt.cpp:38
GotoStmt - This represents a direct goto.
Definition: Stmt.h:1224
static OpaqueValueMappingData bind(CodeGenFunction &CGF, const OpaqueValueExpr *ov, const Expr *e)
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
Definition: SemaDecl.cpp:12171
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...
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition: Expr.h:2315
void unprotectFromPeepholes(PeepholeProtection protection)
void EmitOMPReductionClauseInit(const OMPExecutableDirective &D, OMPPrivateScope &PrivateScope)
Emit initial code for reduction variables.
A non-RAII class containing all the information about a bound opaque value.
llvm::Value * BuildAppleKextVirtualCall(const CXXMethodDecl *MD, NestedNameSpecifier *Qual, llvm::Type *Ty)
BuildAppleKextVirtualCall - This routine is to support gcc's kext ABI making indirect call to virtual...
Definition: CGCXX.cpp:289
This represents '#pragma omp target parallel' directive.
Definition: StmtOpenMP.h:2249
void ErrorUnsupported(const Stmt *S, const char *Type)
ErrorUnsupported - Print out an error that codegen doesn't support the specified stmt yet...
RValue EmitCUDADevicePrintfCallExpr(const CallExpr *E, ReturnValueSlot ReturnValue)
Represents a C++ struct/union/class.
Definition: DeclCXX.h:263
void EmitIfStmt(const IfStmt &S)
Definition: CGStmt.cpp:570
llvm::Value * EmitObjCCollectionLiteral(const Expr *E, const ObjCMethodDecl *MethodWithObjects)
Definition: CGObjC.cpp:113
ContinueStmt - This represents a continue.
Definition: Stmt.h:1302
void EmitBranch(llvm::BasicBlock *Block)
EmitBranch - Emit a branch to the specified basic block from the current insert block, taking care to avoid creation of branches from dummy blocks.
Definition: CGStmt.cpp:417
llvm::PointerIntPair< llvm::Value *, 1, bool > saved_type
llvm::BasicBlock * getInvokeDest()
void EmitReturnStmt(const ReturnStmt &S)
EmitReturnStmt - Note that due to GCC extensions, this can have an operand if the function returns vo...
Definition: CGStmt.cpp:981
llvm::Function * LookupNeonLLVMIntrinsic(unsigned IntrinsicID, unsigned Modifier, llvm::Type *ArgTy, const CallExpr *E)
Definition: CGBuiltin.cpp:3233
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
Definition: Expr.h:3240
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)
EmitFunctionProlog - Emit the target specific LLVM code to load the arguments for the given function...
Definition: CGCall.cpp:2072
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1849
static type restore(CodeGenFunction &CGF, saved_type value)
WhileStmt - This represents a 'while' stmt.
Definition: Stmt.h:1047
void PopCleanupBlocks(EHScopeStack::stable_iterator OldCleanupStackSize)
Takes the old cleanup stack size and emits the cleanup blocks that have been added.
Definition: CGCleanup.cpp:421
void EmitCXXDeleteExpr(const CXXDeleteExpr *E)
Definition: CGExprCXX.cpp:1704
LValue EmitLValue(const Expr *E)
EmitLValue - Emit code to compute a designator that specifies the location of the expression...
Definition: CGExpr.cpp:970
Address ReturnValue
ReturnValue - The temporary alloca to hold the return value.
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:2732
void pushStackRestore(CleanupKind kind, Address SPMem)
Definition: CGDecl.cpp:1470
void EmitLabelStmt(const LabelStmt &S)
Definition: CGStmt.cpp:513
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:3440
bool AutoreleaseResult
In ARC, whether we should autorelease the return value.
RValue EmitLoadOfLValue(LValue V, SourceLocation Loc)
EmitLoadOfLValue - Given an expression that represents a value lvalue, this method emits the address ...
Definition: CGExpr.cpp:1440
llvm::Value * EmitARCRetainBlock(llvm::Value *value, bool mandatory)
Retain the given block, with _Block_copy semantics.
Definition: CGObjC.cpp:1952
This represents '#pragma omp taskloop simd' directive.
Definition: StmtOpenMP.h:2634
LValue EmitPredefinedLValue(const PredefinedExpr *E)
Definition: CGExpr.cpp:2284
std::pair< llvm::Value *, QualType > getVLASize(const VariableArrayType *vla)
getVLASize - Returns an LLVM value that corresponds to the size, in non-variably-sized elements...
void generateObjCGetterBody(const ObjCImplementationDecl *classImpl, const ObjCPropertyImplDecl *propImpl, const ObjCMethodDecl *GetterMothodDecl, llvm::Constant *AtomicHelperFn)
Definition: CGObjC.cpp:863
void EmitVTablePtrCheckForCall(const CXXRecordDecl *RD, llvm::Value *VTable, CFITypeCheckKind TCK, SourceLocation Loc)
EmitVTablePtrCheckForCall - Virtual method MD is being called via VTable.
Definition: CGClass.cpp:2633
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1466
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.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2148
Address EmitCXXUuidofExpr(const CXXUuidofExpr *E)
Definition: CGExpr.cpp:3892
void StartObjCMethod(const ObjCMethodDecl *MD, const ObjCContainerDecl *CD)
StartObjCMethod - Begin emission of an ObjCMethod.
Definition: CGObjC.cpp:518
llvm::MDNode * getTBAAInfo(QualType QTy)
Address EmitExtVectorElementLValue(LValue V)
Generates lvalue for partial ext_vector access.
Definition: CGExpr.cpp:1546
LValue EmitCompoundAssignmentLValue(const CompoundAssignOperator *E)
void EnterSEHTryStmt(const SEHTryStmt &S)
void startOutlinedSEHHelper(CodeGenFunction &ParentCGF, bool IsFilter, const Stmt *OutlinedStmt)
Arrange a function prototype that can be called by Windows exception handling personalities.
CGCapturedStmtInfo * CapturedStmtInfo
llvm::Value * EmitScalarConversion(llvm::Value *Src, QualType SrcTy, QualType DstTy, SourceLocation Loc)
Emit a conversion from the specified type to the specified destination type, both of which are LLVM s...
RValue EmitLoadOfBitfieldLValue(LValue LV)
Definition: CGExpr.cpp:1486
const llvm::function_ref< void(CodeGenFunction &, llvm::Value *, const OMPTaskDataTy &)> TaskGenTy
void EmitObjCAutoreleasePoolCleanup(llvm::Value *Ptr)
Definition: CGObjC.cpp:2396
This represents '#pragma omp sections' directive.
Definition: StmtOpenMP.h:996
LValue EmitMemberExpr(const MemberExpr *E)
Definition: CGExpr.cpp:3242
Struct with all informations about dynamic [sub]class needed to set vptr.
bool hasVolatileMember(QualType T)
hasVolatileMember - returns true if aggregate type has a volatile member.
stable_iterator getInnermostNormalCleanup() const
Returns the innermost normal cleanup on the stack, or stable_end() if there are no normal cleanups...
Definition: EHScopeStack.h:356
This represents '#pragma omp target data' directive.
Definition: StmtOpenMP.h:2074
void EmitOMPTargetExitDataDirective(const OMPTargetExitDataDirective &S)
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:932
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.
RValue EmitBlockCallExpr(const CallExpr *E, ReturnValueSlot ReturnValue)
Definition: CGBlocks.cpp:963
void EmitDestructorBody(FunctionArgList &Args)
EmitDestructorBody - Emits the body of the current destructor.
Definition: CGClass.cpp:1502
bool EmitSimpleStmt(const Stmt *S)
EmitSimpleStmt - Try to emit a "simple" statement which does not necessarily require an insertion poi...
Definition: CGStmt.cpp:301
void EmitCfiSlowPathCheck(SanitizerMask Kind, llvm::Value *Cond, llvm::ConstantInt *TypeId, llvm::Value *Ptr, ArrayRef< llvm::Constant * > StaticArgs)
Emit a slow path cross-DSO CFI check which calls __cfi_slowpath if Cond if false. ...
Definition: CGExpr.cpp:2602
void ExitCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock=false)
This structure provides a set of types that are commonly used during IR emission. ...
BreakStmt - This represents a break.
Definition: Stmt.h:1328
void EmitOMPTargetDataDirective(const OMPTargetDataDirective &S)
void EmitLifetimeEnd(llvm::Value *Size, llvm::Value *Addr)
Definition: CGDecl.cpp:943
CapturedRegionKind
The different kinds of captured statement.
Definition: CapturedStmt.h:17
void EmitBranchThroughCleanup(JumpDest Dest)
EmitBranchThroughCleanup - Emit a branch from the current insert block through the normal cleanup han...
Definition: CGCleanup.cpp:997
void EmitEndEHSpec(const Decl *D)
EmitEndEHSpec - Emit the end of the exception spec.
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:2388
Address EmitCompoundStmtWithoutScope(const CompoundStmt &S, bool GetLast=false, AggValueSlot AVS=AggValueSlot::ignored())
Definition: CGStmt.cpp:336
void EmitOMPDistributeParallelForDirective(const OMPDistributeParallelForDirective &S)
llvm::Value * LoadObjCSelf()
LoadObjCSelf - Load the value of self.
Definition: CGObjC.cpp:1437
#define true
Definition: stdbool.h:32
CodeGenTypes & getTypes() const
A trivial tuple used to represent a source range.
void EmitObjCAtTryStmt(const ObjCAtTryStmt &S)
Definition: CGObjC.cpp:1741
LValue - This represents an lvalue references.
Definition: CGValue.h:152
llvm::BlockAddress * GetAddrOfLabel(const LabelDecl *L)
void EmitWhileStmt(const WhileStmt &S, ArrayRef< const Attr * > Attrs=None)
Definition: CGStmt.cpp:647
This represents '#pragma omp taskyield' directive.
Definition: StmtOpenMP.h:1589
Information for lazily generating a cleanup.
Definition: EHScopeStack.h:147
void EmitVarAnnotations(const VarDecl *D, llvm::Value *V)
Emit local annotations for the local variable V, declared by D.
This represents '#pragma omp distribute parallel for simd' composite directive.
Definition: StmtOpenMP.h:2897
llvm::Value * EmitObjCConsumeObject(QualType T, llvm::Value *Ptr)
Produce the code for a CK_ARCConsumeObject.
Definition: CGObjC.cpp:1768
Represents a C array with a specified size that is not an integer-constant-expression.
Definition: Type.h:2607
This represents '#pragma omp parallel sections' directive.
Definition: StmtOpenMP.h:1450
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition: ExprCXX.h:784
bool CurFuncIsThunk
In C++, whether we are code generating a thunk.
void EmitBlockAfterUses(llvm::BasicBlock *BB)
EmitBlockAfterUses - Emit the given block somewhere hopefully near its uses, and leave the insertion ...
Definition: CGStmt.cpp:434
void EmitBreakStmt(const BreakStmt &S)
Definition: CGStmt.cpp:1063
llvm::Value * emitArrayLength(const ArrayType *arrayType, QualType &baseType, Address &addr)
emitArrayLength - Compute the length of an array, even if it's a VLA, and drill down to the base elem...
RValue EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E, const CXXMethodDecl *MD, ReturnValueSlot ReturnValue)
Definition: CGExprCXX.cpp:337
void EmitObjCAutoreleasePoolStmt(const ObjCAutoreleasePoolStmt &S)
Definition: CGObjC.cpp:3118
static bool containsBreak(const Stmt *S)
containsBreak - Return true if the statement contains a break out of it.
Address GetAddressOfBaseClass(Address Value, const CXXRecordDecl *Derived, CastExpr::path_const_iterator PathBegin, CastExpr::path_const_iterator PathEnd, bool NullCheckValue, SourceLocation Loc)
GetAddressOfBaseClass - This function will add the necessary delta to the load of 'this' and returns ...
Definition: CGClass.cpp:265
CallArgList - Type for representing both the value and type of arguments in a call.
Definition: CGCall.h:56
OpaqueValueMapping(CodeGenFunction &CGF, const OpaqueValueExpr *opaqueValue, LValue lvalue)
void PopCleanupBlock(bool FallThroughIsBranchThrough=false)
PopCleanupBlock - Will pop the cleanup entry on the stack and process all branch fixups.
Definition: CGCleanup.cpp:603
Represents Objective-C's @autoreleasepool Statement.
Definition: StmtObjC.h:345
LValue EmitStringLiteralLValue(const StringLiteral *E)
Definition: CGExpr.cpp:2274
void EmitOMPTaskDirective(const OMPTaskDirective &S)
Address emitBlockByrefAddress(Address baseAddr, const VarDecl *V, bool followForward=true)
BuildBlockByrefAddress - Computes the location of the data in a variable which is declared as __block...
Definition: CGBlocks.cpp:2028
CGCalleeInfo - Class to encapsulate the information about a callee to be used during the generation o...
void EmitCXXThrowExpr(const CXXThrowExpr *E, bool KeepInsertionPoint=true)
llvm::Value * EmitVTableTypeCheckedLoad(const CXXRecordDecl *RD, llvm::Value *VTable, uint64_t VTableByteOffset)
Emit a type checked load from the given vtable.
Definition: CGClass.cpp:2783
This represents '#pragma omp target parallel for' directive.
Definition: StmtOpenMP.h:2309
llvm::Value * EmitTargetBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
EmitTargetBuiltinExpr - Emit the given builtin call.
Definition: CGBuiltin.cpp:2511
void pushIrregularPartialArrayCleanup(llvm::Value *arrayBegin, Address arrayEndPointer, QualType elementType, CharUnits elementAlignment, Destroyer *destroyer)
pushIrregularPartialArrayCleanup - Push an EH cleanup to destroy already-constructed elements of the ...
Definition: CGDecl.cpp:1682
void EmitNullInitialization(Address DestPtr, QualType Ty)
EmitNullInitialization - Generate code to set a value of the given type to null, If the type contains...
void BuildBlockRelease(llvm::Value *DeclPtr, BlockFieldFlags flags)
Definition: CGBlocks.cpp:2260
llvm::SmallVector< const JumpDest *, 2 > SEHTryEpilogueStack
llvm::Value * EmitSystemZBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition: CGBuiltin.cpp:7717
bool Privatize()
Privatizes local variables previously registered as private.
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:341
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Definition: Type.h:5286
llvm::Value * EmitObjCSelectorExpr(const ObjCSelectorExpr *E)
Emit a selector.
Definition: CGObjC.cpp:235
void Destroyer(CodeGenFunction &CGF, Address addr, QualType ty)
llvm::Value * BuildAppleKextVirtualDestructorCall(const CXXDestructorDecl *DD, CXXDtorType Type, const CXXRecordDecl *RD)
BuildVirtualCall - This routine makes indirect vtable call for call to virtual destructors.
Definition: CGCXX.cpp:310
llvm::Value * EmitObjCProtocolExpr(const ObjCProtocolExpr *E)
Definition: CGObjC.cpp:243
static unsigned getAccessedFieldNo(unsigned Idx, const llvm::Constant *Elts)
getAccessedFieldNo - Given an encoded value and a result number, return the input field number being ...
Definition: CGExpr.cpp:507
This represents '#pragma omp taskloop' directive.
Definition: StmtOpenMP.h:2569