clang  5.0.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 "VarBypassDetector.h"
25 #include "clang/AST/CharUnits.h"
26 #include "clang/AST/ExprCXX.h"
27 #include "clang/AST/ExprObjC.h"
28 #include "clang/AST/ExprOpenMP.h"
29 #include "clang/AST/Type.h"
30 #include "clang/Basic/ABI.h"
33 #include "clang/Basic/TargetInfo.h"
35 #include "llvm/ADT/ArrayRef.h"
36 #include "llvm/ADT/DenseMap.h"
37 #include "llvm/ADT/SmallVector.h"
38 #include "llvm/IR/ValueHandle.h"
39 #include "llvm/Support/Debug.h"
40 #include "llvm/Transforms/Utils/SanitizerStats.h"
41 
42 namespace llvm {
43 class BasicBlock;
44 class LLVMContext;
45 class MDNode;
46 class Module;
47 class SwitchInst;
48 class Twine;
49 class Value;
50 class CallSite;
51 }
52 
53 namespace clang {
54 class ASTContext;
55 class BlockDecl;
56 class CXXDestructorDecl;
57 class CXXForRangeStmt;
58 class CXXTryStmt;
59 class Decl;
60 class LabelDecl;
61 class EnumConstantDecl;
62 class FunctionDecl;
63 class FunctionProtoType;
64 class LabelStmt;
65 class ObjCContainerDecl;
66 class ObjCInterfaceDecl;
67 class ObjCIvarDecl;
68 class ObjCMethodDecl;
69 class ObjCImplementationDecl;
70 class ObjCPropertyImplDecl;
71 class TargetInfo;
72 class VarDecl;
73 class ObjCForCollectionStmt;
74 class ObjCAtTryStmt;
75 class ObjCAtThrowStmt;
76 class ObjCAtSynchronizedStmt;
77 class ObjCAutoreleasePoolStmt;
78 
79 namespace CodeGen {
80 class CodeGenTypes;
81 class CGCallee;
82 class CGFunctionInfo;
83 class CGRecordLayout;
84 class CGBlockInfo;
85 class CGCXXABI;
86 class BlockByrefHelpers;
87 class BlockByrefInfo;
88 class BlockFlags;
89 class BlockFieldFlags;
90 class RegionCodeGenTy;
91 class TargetCodeGenInfo;
92 struct OMPTaskDataTy;
93 struct CGCoroData;
94 
95 /// The kind of evaluation to perform on values of a particular
96 /// type. Basically, is the code in CGExprScalar, CGExprComplex, or
97 /// CGExprAgg?
98 ///
99 /// TODO: should vectors maybe be split out into their own thing?
104 };
105 
106 #define LIST_SANITIZER_CHECKS \
107  SANITIZER_CHECK(AddOverflow, add_overflow, 0) \
108  SANITIZER_CHECK(BuiltinUnreachable, builtin_unreachable, 0) \
109  SANITIZER_CHECK(CFICheckFail, cfi_check_fail, 0) \
110  SANITIZER_CHECK(DivremOverflow, divrem_overflow, 0) \
111  SANITIZER_CHECK(DynamicTypeCacheMiss, dynamic_type_cache_miss, 0) \
112  SANITIZER_CHECK(FloatCastOverflow, float_cast_overflow, 0) \
113  SANITIZER_CHECK(FunctionTypeMismatch, function_type_mismatch, 0) \
114  SANITIZER_CHECK(LoadInvalidValue, load_invalid_value, 0) \
115  SANITIZER_CHECK(MissingReturn, missing_return, 0) \
116  SANITIZER_CHECK(MulOverflow, mul_overflow, 0) \
117  SANITIZER_CHECK(NegateOverflow, negate_overflow, 0) \
118  SANITIZER_CHECK(NullabilityArg, nullability_arg, 0) \
119  SANITIZER_CHECK(NullabilityReturn, nullability_return, 1) \
120  SANITIZER_CHECK(NonnullArg, nonnull_arg, 0) \
121  SANITIZER_CHECK(NonnullReturn, nonnull_return, 1) \
122  SANITIZER_CHECK(OutOfBounds, out_of_bounds, 0) \
123  SANITIZER_CHECK(PointerOverflow, pointer_overflow, 0) \
124  SANITIZER_CHECK(ShiftOutOfBounds, shift_out_of_bounds, 0) \
125  SANITIZER_CHECK(SubOverflow, sub_overflow, 0) \
126  SANITIZER_CHECK(TypeMismatch, type_mismatch, 1) \
127  SANITIZER_CHECK(VLABoundNotPositive, vla_bound_not_positive, 0)
128 
130 #define SANITIZER_CHECK(Enum, Name, Version) Enum,
132 #undef SANITIZER_CHECK
133 };
134 
135 /// CodeGenFunction - This class organizes the per-function state that is used
136 /// while generating LLVM code.
138  CodeGenFunction(const CodeGenFunction &) = delete;
139  void operator=(const CodeGenFunction &) = delete;
140 
141  friend class CGCXXABI;
142 public:
143  /// A jump destination is an abstract label, branching to which may
144  /// require a jump out through normal cleanups.
145  struct JumpDest {
146  JumpDest() : Block(nullptr), ScopeDepth(), Index(0) {}
147  JumpDest(llvm::BasicBlock *Block,
149  unsigned Index)
150  : Block(Block), ScopeDepth(Depth), Index(Index) {}
151 
152  bool isValid() const { return Block != nullptr; }
153  llvm::BasicBlock *getBlock() const { return Block; }
154  EHScopeStack::stable_iterator getScopeDepth() const { return ScopeDepth; }
155  unsigned getDestIndex() const { return Index; }
156 
157  // This should be used cautiously.
159  ScopeDepth = depth;
160  }
161 
162  private:
163  llvm::BasicBlock *Block;
165  unsigned Index;
166  };
167 
168  CodeGenModule &CGM; // Per-module state.
170 
171  typedef std::pair<llvm::Value *, llvm::Value *> ComplexPairTy;
174 
175  // Stores variables for which we can't generate correct lifetime markers
176  // because of jumps.
178 
179  // CodeGen lambda for loops and support for ordered clause
180  typedef llvm::function_ref<void(CodeGenFunction &, const OMPLoopDirective &,
181  JumpDest)>
183  typedef llvm::function_ref<void(CodeGenFunction &, SourceLocation,
184  const unsigned, const bool)>
186 
187  // Codegen lambda for loop bounds in worksharing loop constructs
188  typedef llvm::function_ref<std::pair<LValue, LValue>(
191 
192  // Codegen lambda for loop bounds in dispatch-based loop implementation
193  typedef llvm::function_ref<std::pair<llvm::Value *, llvm::Value *>(
195  Address UB)>
197 
198  /// \brief CGBuilder insert helper. This function is called after an
199  /// instruction is created using Builder.
200  void InsertHelper(llvm::Instruction *I, const llvm::Twine &Name,
201  llvm::BasicBlock *BB,
202  llvm::BasicBlock::iterator InsertPt) const;
203 
204  /// CurFuncDecl - Holds the Decl for the current outermost
205  /// non-closure context.
207  /// CurCodeDecl - This is the inner-most code context, which includes blocks.
211  llvm::Function *CurFn;
212 
213  // Holds coroutine data if the current function is a coroutine. We use a
214  // wrapper to manage its lifetime, so that we don't have to define CGCoroData
215  // in this header.
216  struct CGCoroInfo {
217  std::unique_ptr<CGCoroData> Data;
218  CGCoroInfo();
219  ~CGCoroInfo();
220  };
222 
223  /// CurGD - The GlobalDecl for the current function being compiled.
225 
226  /// PrologueCleanupDepth - The cleanup depth enclosing all the
227  /// cleanups associated with the parameters.
229 
230  /// ReturnBlock - Unified return block.
232 
233  /// ReturnValue - The temporary alloca to hold the return
234  /// value. This is invalid iff the function has no return value.
236 
237  /// Return true if a label was seen in the current scope.
239  if (CurLexicalScope)
240  return CurLexicalScope->hasLabels();
241  return !LabelMap.empty();
242  }
243 
244  /// AllocaInsertPoint - This is an instruction in the entry block before which
245  /// we prefer to insert allocas.
246  llvm::AssertingVH<llvm::Instruction> AllocaInsertPt;
247 
248  /// \brief API for captured statement code generation.
250  public:
252  : Kind(K), ThisValue(nullptr), CXXThisFieldDecl(nullptr) {}
255  : Kind(K), ThisValue(nullptr), CXXThisFieldDecl(nullptr) {
256 
260  E = S.capture_end();
261  I != E; ++I, ++Field) {
262  if (I->capturesThis())
263  CXXThisFieldDecl = *Field;
264  else if (I->capturesVariable())
265  CaptureFields[I->getCapturedVar()] = *Field;
266  else if (I->capturesVariableByCopy())
267  CaptureFields[I->getCapturedVar()] = *Field;
268  }
269  }
270 
271  virtual ~CGCapturedStmtInfo();
272 
273  CapturedRegionKind getKind() const { return Kind; }
274 
275  virtual void setContextValue(llvm::Value *V) { ThisValue = V; }
276  // \brief Retrieve the value of the context parameter.
277  virtual llvm::Value *getContextValue() const { return ThisValue; }
278 
279  /// \brief Lookup the captured field decl for a variable.
280  virtual const FieldDecl *lookup(const VarDecl *VD) const {
281  return CaptureFields.lookup(VD);
282  }
283 
284  bool isCXXThisExprCaptured() const { return getThisFieldDecl() != nullptr; }
285  virtual FieldDecl *getThisFieldDecl() const { return CXXThisFieldDecl; }
286 
287  static bool classof(const CGCapturedStmtInfo *) {
288  return true;
289  }
290 
291  /// \brief Emit the captured statement body.
292  virtual void EmitBody(CodeGenFunction &CGF, const Stmt *S) {
294  CGF.EmitStmt(S);
295  }
296 
297  /// \brief Get the name of the capture helper.
298  virtual StringRef getHelperName() const { return "__captured_stmt"; }
299 
300  private:
301  /// \brief The kind of captured statement being generated.
303 
304  /// \brief Keep the map between VarDecl and FieldDecl.
305  llvm::SmallDenseMap<const VarDecl *, FieldDecl *> CaptureFields;
306 
307  /// \brief The base address of the captured record, passed in as the first
308  /// argument of the parallel region function.
309  llvm::Value *ThisValue;
310 
311  /// \brief Captured 'this' type.
312  FieldDecl *CXXThisFieldDecl;
313  };
315 
316  /// \brief RAII for correct setting/restoring of CapturedStmtInfo.
318  private:
319  CodeGenFunction &CGF;
320  CGCapturedStmtInfo *PrevCapturedStmtInfo;
321  public:
323  CGCapturedStmtInfo *NewCapturedStmtInfo)
324  : CGF(CGF), PrevCapturedStmtInfo(CGF.CapturedStmtInfo) {
325  CGF.CapturedStmtInfo = NewCapturedStmtInfo;
326  }
327  ~CGCapturedStmtRAII() { CGF.CapturedStmtInfo = PrevCapturedStmtInfo; }
328  };
329 
330  /// An abstract representation of regular/ObjC call/message targets.
332  /// The function declaration of the callee.
333  const Decl *CalleeDecl;
334 
335  public:
336  AbstractCallee() : CalleeDecl(nullptr) {}
337  AbstractCallee(const FunctionDecl *FD) : CalleeDecl(FD) {}
338  AbstractCallee(const ObjCMethodDecl *OMD) : CalleeDecl(OMD) {}
339  bool hasFunctionDecl() const {
340  return dyn_cast_or_null<FunctionDecl>(CalleeDecl);
341  }
342  const Decl *getDecl() const { return CalleeDecl; }
343  unsigned getNumParams() const {
344  if (const auto *FD = dyn_cast<FunctionDecl>(CalleeDecl))
345  return FD->getNumParams();
346  return cast<ObjCMethodDecl>(CalleeDecl)->param_size();
347  }
348  const ParmVarDecl *getParamDecl(unsigned I) const {
349  if (const auto *FD = dyn_cast<FunctionDecl>(CalleeDecl))
350  return FD->getParamDecl(I);
351  return *(cast<ObjCMethodDecl>(CalleeDecl)->param_begin() + I);
352  }
353  };
354 
355  /// \brief Sanitizers enabled for this function.
357 
358  /// \brief True if CodeGen currently emits code implementing sanitizer checks.
360 
361  /// \brief RAII object to set/unset CodeGenFunction::IsSanitizerScope.
363  CodeGenFunction *CGF;
364  public:
366  ~SanitizerScope();
367  };
368 
369  /// In C++, whether we are code generating a thunk. This controls whether we
370  /// should emit cleanups.
372 
373  /// In ARC, whether we should autorelease the return value.
375 
376  /// Whether we processed a Microsoft-style asm block during CodeGen. These can
377  /// potentially set the return value.
379 
380  const FunctionDecl *CurSEHParent = nullptr;
381 
382  /// True if the current function is an outlined SEH helper. This can be a
383  /// finally block or filter expression.
385 
388 
389  llvm::DenseMap<const VarDecl *, FieldDecl *> LambdaCaptureFields;
391 
392  /// \brief A mapping from NRVO variables to the flags used to indicate
393  /// when the NRVO has been applied to this variable.
394  llvm::DenseMap<const VarDecl *, llvm::Value *> NRVOFlags;
395 
399 
400  llvm::Instruction *CurrentFuncletPad = nullptr;
401 
402  class CallLifetimeEnd final : public EHScopeStack::Cleanup {
403  llvm::Value *Addr;
404  llvm::Value *Size;
405 
406  public:
408  : Addr(addr.getPointer()), Size(size) {}
409 
410  void Emit(CodeGenFunction &CGF, Flags flags) override {
411  CGF.EmitLifetimeEnd(Size, Addr);
412  }
413  };
414 
415  /// Header for data within LifetimeExtendedCleanupStack.
417  /// The size of the following cleanup object.
418  unsigned Size;
419  /// The kind of cleanup to push: a value from the CleanupKind enumeration.
421 
422  size_t getSize() const { return Size; }
423  CleanupKind getKind() const { return Kind; }
424  };
425 
426  /// i32s containing the indexes of the cleanup destinations.
427  llvm::AllocaInst *NormalCleanupDest;
428 
430 
431  /// FirstBlockInfo - The head of a singly-linked-list of block layouts.
433 
434  /// EHResumeBlock - Unified block containing a call to llvm.eh.resume.
435  llvm::BasicBlock *EHResumeBlock;
436 
437  /// The exception slot. All landing pads write the current exception pointer
438  /// into this alloca.
440 
441  /// The selector slot. Under the MandatoryCleanup model, all landing pads
442  /// write the current selector value into this alloca.
443  llvm::AllocaInst *EHSelectorSlot;
444 
445  /// A stack of exception code slots. Entering an __except block pushes a slot
446  /// on the stack and leaving pops one. The __exception_code() intrinsic loads
447  /// a value from the top of the stack.
449 
450  /// Value returned by __exception_info intrinsic.
451  llvm::Value *SEHInfo = nullptr;
452 
453  /// Emits a landing pad for the current EH stack.
454  llvm::BasicBlock *EmitLandingPad();
455 
456  llvm::BasicBlock *getInvokeDestImpl();
457 
458  template <class T>
460  return DominatingValue<T>::save(*this, value);
461  }
462 
463 public:
464  /// ObjCEHValueStack - Stack of Objective-C exception values, used for
465  /// rethrows.
467 
468  /// A class controlling the emission of a finally block.
469  class FinallyInfo {
470  /// Where the catchall's edge through the cleanup should go.
471  JumpDest RethrowDest;
472 
473  /// A function to call to enter the catch.
474  llvm::Constant *BeginCatchFn;
475 
476  /// An i1 variable indicating whether or not the @finally is
477  /// running for an exception.
478  llvm::AllocaInst *ForEHVar;
479 
480  /// An i8* variable into which the exception pointer to rethrow
481  /// has been saved.
482  llvm::AllocaInst *SavedExnVar;
483 
484  public:
485  void enter(CodeGenFunction &CGF, const Stmt *Finally,
486  llvm::Constant *beginCatchFn, llvm::Constant *endCatchFn,
487  llvm::Constant *rethrowFn);
488  void exit(CodeGenFunction &CGF);
489  };
490 
491  /// Returns true inside SEH __try blocks.
492  bool isSEHTryScope() const { return !SEHTryEpilogueStack.empty(); }
493 
494  /// Returns true while emitting a cleanuppad.
495  bool isCleanupPadScope() const {
496  return CurrentFuncletPad && isa<llvm::CleanupPadInst>(CurrentFuncletPad);
497  }
498 
499  /// pushFullExprCleanup - Push a cleanup to be run at the end of the
500  /// current full-expression. Safe against the possibility that
501  /// we're currently inside a conditionally-evaluated expression.
502  template <class T, class... As>
504  // If we're not in a conditional branch, or if none of the
505  // arguments requires saving, then use the unconditional cleanup.
506  if (!isInConditionalBranch())
507  return EHStack.pushCleanup<T>(kind, A...);
508 
509  // Stash values in a tuple so we can guarantee the order of saves.
510  typedef std::tuple<typename DominatingValue<As>::saved_type...> SavedTuple;
511  SavedTuple Saved{saveValueInCond(A)...};
512 
513  typedef EHScopeStack::ConditionalCleanup<T, As...> CleanupType;
514  EHStack.pushCleanupTuple<CleanupType>(kind, Saved);
516  }
517 
518  /// \brief Queue a cleanup to be pushed after finishing the current
519  /// full-expression.
520  template <class T, class... As>
522  assert(!isInConditionalBranch() && "can't defer conditional cleanup");
523 
524  LifetimeExtendedCleanupHeader Header = { sizeof(T), Kind };
525 
526  size_t OldSize = LifetimeExtendedCleanupStack.size();
528  LifetimeExtendedCleanupStack.size() + sizeof(Header) + Header.Size);
529 
530  static_assert(sizeof(Header) % alignof(T) == 0,
531  "Cleanup will be allocated on misaligned address");
532  char *Buffer = &LifetimeExtendedCleanupStack[OldSize];
534  new (Buffer + sizeof(Header)) T(A...);
535  }
536 
537  /// Set up the last cleaup that was pushed as a conditional
538  /// full-expression cleanup.
539  void initFullExprCleanup();
540 
541  /// PushDestructorCleanup - Push a cleanup to call the
542  /// complete-object destructor of an object of the given type at the
543  /// given address. Does nothing if T is not a C++ class type with a
544  /// non-trivial destructor.
545  void PushDestructorCleanup(QualType T, Address Addr);
546 
547  /// PushDestructorCleanup - Push a cleanup to call the
548  /// complete-object variant of the given destructor on the object at
549  /// the given address.
550  void PushDestructorCleanup(const CXXDestructorDecl *Dtor, Address Addr);
551 
552  /// PopCleanupBlock - Will pop the cleanup entry on the stack and
553  /// process all branch fixups.
554  void PopCleanupBlock(bool FallThroughIsBranchThrough = false);
555 
556  /// DeactivateCleanupBlock - Deactivates the given cleanup block.
557  /// The block cannot be reactivated. Pops it if it's the top of the
558  /// stack.
559  ///
560  /// \param DominatingIP - An instruction which is known to
561  /// dominate the current IP (if set) and which lies along
562  /// all paths of execution between the current IP and the
563  /// the point at which the cleanup comes into scope.
565  llvm::Instruction *DominatingIP);
566 
567  /// ActivateCleanupBlock - Activates an initially-inactive cleanup.
568  /// Cannot be used to resurrect a deactivated cleanup.
569  ///
570  /// \param DominatingIP - An instruction which is known to
571  /// dominate the current IP (if set) and which lies along
572  /// all paths of execution between the current IP and the
573  /// the point at which the cleanup comes into scope.
575  llvm::Instruction *DominatingIP);
576 
577  /// \brief Enters a new scope for capturing cleanups, all of which
578  /// will be executed once the scope is exited.
580  EHScopeStack::stable_iterator CleanupStackDepth;
581  size_t LifetimeExtendedCleanupStackSize;
582  bool OldDidCallStackSave;
583  protected:
585  private:
586 
587  RunCleanupsScope(const RunCleanupsScope &) = delete;
588  void operator=(const RunCleanupsScope &) = delete;
589 
590  protected:
592 
593  public:
594  /// \brief Enter a new cleanup scope.
596  : PerformCleanup(true), CGF(CGF)
597  {
598  CleanupStackDepth = CGF.EHStack.stable_begin();
599  LifetimeExtendedCleanupStackSize =
600  CGF.LifetimeExtendedCleanupStack.size();
601  OldDidCallStackSave = CGF.DidCallStackSave;
602  CGF.DidCallStackSave = false;
603  }
604 
605  /// \brief Exit this cleanup scope, emitting any accumulated cleanups.
607  if (PerformCleanup)
608  ForceCleanup();
609  }
610 
611  /// \brief Determine whether this scope requires any cleanups.
612  bool requiresCleanups() const {
613  return CGF.EHStack.stable_begin() != CleanupStackDepth;
614  }
615 
616  /// \brief Force the emission of cleanups now, instead of waiting
617  /// until this object is destroyed.
618  /// \param ValuesToReload - A list of values that need to be available at
619  /// the insertion point after cleanup emission. If cleanup emission created
620  /// a shared cleanup block, these value pointers will be rewritten.
621  /// Otherwise, they not will be modified.
622  void ForceCleanup(std::initializer_list<llvm::Value**> ValuesToReload = {}) {
623  assert(PerformCleanup && "Already forced cleanup");
624  CGF.DidCallStackSave = OldDidCallStackSave;
625  CGF.PopCleanupBlocks(CleanupStackDepth, LifetimeExtendedCleanupStackSize,
626  ValuesToReload);
627  PerformCleanup = false;
628  }
629  };
630 
632  SourceRange Range;
634  LexicalScope *ParentScope;
635 
636  LexicalScope(const LexicalScope &) = delete;
637  void operator=(const LexicalScope &) = delete;
638 
639  public:
640  /// \brief Enter a new cleanup scope.
642  : RunCleanupsScope(CGF), Range(Range), ParentScope(CGF.CurLexicalScope) {
643  CGF.CurLexicalScope = this;
644  if (CGDebugInfo *DI = CGF.getDebugInfo())
645  DI->EmitLexicalBlockStart(CGF.Builder, Range.getBegin());
646  }
647 
648  void addLabel(const LabelDecl *label) {
649  assert(PerformCleanup && "adding label to dead scope?");
650  Labels.push_back(label);
651  }
652 
653  /// \brief Exit this cleanup scope, emitting any accumulated
654  /// cleanups.
656  if (CGDebugInfo *DI = CGF.getDebugInfo())
657  DI->EmitLexicalBlockEnd(CGF.Builder, Range.getEnd());
658 
659  // If we should perform a cleanup, force them now. Note that
660  // this ends the cleanup scope before rescoping any labels.
661  if (PerformCleanup) {
662  ApplyDebugLocation DL(CGF, Range.getEnd());
663  ForceCleanup();
664  }
665  }
666 
667  /// \brief Force the emission of cleanups now, instead of waiting
668  /// until this object is destroyed.
669  void ForceCleanup() {
670  CGF.CurLexicalScope = ParentScope;
672 
673  if (!Labels.empty())
674  rescopeLabels();
675  }
676 
677  bool hasLabels() const {
678  return !Labels.empty();
679  }
680 
681  void rescopeLabels();
682  };
683 
684  typedef llvm::DenseMap<const Decl *, Address> DeclMapTy;
685 
686  /// \brief The scope used to remap some variables as private in the OpenMP
687  /// loop body (or other captured region emitted without outlining), and to
688  /// restore old vars back on exit.
690  DeclMapTy SavedLocals;
691  DeclMapTy SavedPrivates;
692 
693  private:
694  OMPPrivateScope(const OMPPrivateScope &) = delete;
695  void operator=(const OMPPrivateScope &) = delete;
696 
697  public:
698  /// \brief Enter a new OpenMP private scope.
700 
701  /// \brief Registers \a LocalVD variable as a private and apply \a
702  /// PrivateGen function for it to generate corresponding private variable.
703  /// \a PrivateGen returns an address of the generated private variable.
704  /// \return true if the variable is registered as private, false if it has
705  /// been privatized already.
706  bool
707  addPrivate(const VarDecl *LocalVD,
708  llvm::function_ref<Address()> PrivateGen) {
709  assert(PerformCleanup && "adding private to dead scope");
710 
711  // Only save it once.
712  if (SavedLocals.count(LocalVD)) return false;
713 
714  // Copy the existing local entry to SavedLocals.
715  auto it = CGF.LocalDeclMap.find(LocalVD);
716  if (it != CGF.LocalDeclMap.end()) {
717  SavedLocals.insert({LocalVD, it->second});
718  } else {
719  SavedLocals.insert({LocalVD, Address::invalid()});
720  }
721 
722  // Generate the private entry.
723  Address Addr = PrivateGen();
724  QualType VarTy = LocalVD->getType();
725  if (VarTy->isReferenceType()) {
726  Address Temp = CGF.CreateMemTemp(VarTy);
727  CGF.Builder.CreateStore(Addr.getPointer(), Temp);
728  Addr = Temp;
729  }
730  SavedPrivates.insert({LocalVD, Addr});
731 
732  return true;
733  }
734 
735  /// \brief Privatizes local variables previously registered as private.
736  /// Registration is separate from the actual privatization to allow
737  /// initializers use values of the original variables, not the private one.
738  /// This is important, for example, if the private variable is a class
739  /// variable initialized by a constructor that references other private
740  /// variables. But at initialization original variables must be used, not
741  /// private copies.
742  /// \return true if at least one variable was privatized, false otherwise.
743  bool Privatize() {
744  copyInto(SavedPrivates, CGF.LocalDeclMap);
745  SavedPrivates.clear();
746  return !SavedLocals.empty();
747  }
748 
749  void ForceCleanup() {
751  copyInto(SavedLocals, CGF.LocalDeclMap);
752  SavedLocals.clear();
753  }
754 
755  /// \brief Exit scope - all the mapped variables are restored.
757  if (PerformCleanup)
758  ForceCleanup();
759  }
760 
761  /// Checks if the global variable is captured in current function.
762  bool isGlobalVarCaptured(const VarDecl *VD) const {
763  return !VD->isLocalVarDeclOrParm() && CGF.LocalDeclMap.count(VD) > 0;
764  }
765 
766  private:
767  /// Copy all the entries in the source map over the corresponding
768  /// entries in the destination, which must exist.
769  static void copyInto(const DeclMapTy &src, DeclMapTy &dest) {
770  for (auto &pair : src) {
771  if (!pair.second.isValid()) {
772  dest.erase(pair.first);
773  continue;
774  }
775 
776  auto it = dest.find(pair.first);
777  if (it != dest.end()) {
778  it->second = pair.second;
779  } else {
780  dest.insert(pair);
781  }
782  }
783  }
784  };
785 
786  /// \brief Takes the old cleanup stack size and emits the cleanup blocks
787  /// that have been added.
788  void
789  PopCleanupBlocks(EHScopeStack::stable_iterator OldCleanupStackSize,
790  std::initializer_list<llvm::Value **> ValuesToReload = {});
791 
792  /// \brief Takes the old cleanup stack size and emits the cleanup blocks
793  /// that have been added, then adds all lifetime-extended cleanups from
794  /// the given position to the stack.
795  void
796  PopCleanupBlocks(EHScopeStack::stable_iterator OldCleanupStackSize,
797  size_t OldLifetimeExtendedStackSize,
798  std::initializer_list<llvm::Value **> ValuesToReload = {});
799 
800  void ResolveBranchFixups(llvm::BasicBlock *Target);
801 
802  /// The given basic block lies in the current EH scope, but may be a
803  /// target of a potentially scope-crossing jump; get a stable handle
804  /// to which we can perform this jump later.
806  return JumpDest(Target,
809  }
810 
811  /// The given basic block lies in the current EH scope, but may be a
812  /// target of a potentially scope-crossing jump; get a stable handle
813  /// to which we can perform this jump later.
814  JumpDest getJumpDestInCurrentScope(StringRef Name = StringRef()) {
816  }
817 
818  /// EmitBranchThroughCleanup - Emit a branch from the current insert
819  /// block through the normal cleanup handling code (if any) and then
820  /// on to \arg Dest.
821  void EmitBranchThroughCleanup(JumpDest Dest);
822 
823  /// isObviouslyBranchWithoutCleanups - Return true if a branch to the
824  /// specified destination obviously has no cleanups to run. 'false' is always
825  /// a conservatively correct answer for this method.
826  bool isObviouslyBranchWithoutCleanups(JumpDest Dest) const;
827 
828  /// popCatchScope - Pops the catch scope at the top of the EHScope
829  /// stack, emitting any required code (other than the catch handlers
830  /// themselves).
831  void popCatchScope();
832 
833  llvm::BasicBlock *getEHResumeBlock(bool isCleanup);
834  llvm::BasicBlock *getEHDispatchBlock(EHScopeStack::stable_iterator scope);
835  llvm::BasicBlock *getMSVCDispatchBlock(EHScopeStack::stable_iterator scope);
836 
837  /// An object to manage conditionally-evaluated expressions.
839  llvm::BasicBlock *StartBB;
840 
841  public:
843  : StartBB(CGF.Builder.GetInsertBlock()) {}
844 
845  void begin(CodeGenFunction &CGF) {
846  assert(CGF.OutermostConditional != this);
847  if (!CGF.OutermostConditional)
848  CGF.OutermostConditional = this;
849  }
850 
851  void end(CodeGenFunction &CGF) {
852  assert(CGF.OutermostConditional != nullptr);
853  if (CGF.OutermostConditional == this)
854  CGF.OutermostConditional = nullptr;
855  }
856 
857  /// Returns a block which will be executed prior to each
858  /// evaluation of the conditional code.
859  llvm::BasicBlock *getStartingBlock() const {
860  return StartBB;
861  }
862  };
863 
864  /// isInConditionalBranch - Return true if we're currently emitting
865  /// one branch or the other of a conditional expression.
866  bool isInConditionalBranch() const { return OutermostConditional != nullptr; }
867 
869  assert(isInConditionalBranch());
870  llvm::BasicBlock *block = OutermostConditional->getStartingBlock();
871  auto store = new llvm::StoreInst(value, addr.getPointer(), &block->back());
872  store->setAlignment(addr.getAlignment().getQuantity());
873  }
874 
875  /// An RAII object to record that we're evaluating a statement
876  /// expression.
878  CodeGenFunction &CGF;
879 
880  /// We have to save the outermost conditional: cleanups in a
881  /// statement expression aren't conditional just because the
882  /// StmtExpr is.
883  ConditionalEvaluation *SavedOutermostConditional;
884 
885  public:
887  : CGF(CGF), SavedOutermostConditional(CGF.OutermostConditional) {
888  CGF.OutermostConditional = nullptr;
889  }
890 
892  CGF.OutermostConditional = SavedOutermostConditional;
893  CGF.EnsureInsertPoint();
894  }
895  };
896 
897  /// An object which temporarily prevents a value from being
898  /// destroyed by aggressive peephole optimizations that assume that
899  /// all uses of a value have been realized in the IR.
901  llvm::Instruction *Inst;
902  friend class CodeGenFunction;
903 
904  public:
905  PeepholeProtection() : Inst(nullptr) {}
906  };
907 
908  /// A non-RAII class containing all the information about a bound
909  /// opaque value. OpaqueValueMapping, below, is a RAII wrapper for
910  /// this which makes individual mappings very simple; using this
911  /// class directly is useful when you have a variable number of
912  /// opaque values or don't want the RAII functionality for some
913  /// reason.
915  const OpaqueValueExpr *OpaqueValue;
916  bool BoundLValue;
918 
920  bool boundLValue)
921  : OpaqueValue(ov), BoundLValue(boundLValue) {}
922  public:
923  OpaqueValueMappingData() : OpaqueValue(nullptr) {}
924 
925  static bool shouldBindAsLValue(const Expr *expr) {
926  // gl-values should be bound as l-values for obvious reasons.
927  // Records should be bound as l-values because IR generation
928  // always keeps them in memory. Expressions of function type
929  // act exactly like l-values but are formally required to be
930  // r-values in C.
931  return expr->isGLValue() ||
932  expr->getType()->isFunctionType() ||
934  }
935 
937  const OpaqueValueExpr *ov,
938  const Expr *e) {
939  if (shouldBindAsLValue(ov))
940  return bind(CGF, ov, CGF.EmitLValue(e));
941  return bind(CGF, ov, CGF.EmitAnyExpr(e));
942  }
943 
945  const OpaqueValueExpr *ov,
946  const LValue &lv) {
947  assert(shouldBindAsLValue(ov));
948  CGF.OpaqueLValues.insert(std::make_pair(ov, lv));
949  return OpaqueValueMappingData(ov, true);
950  }
951 
953  const OpaqueValueExpr *ov,
954  const RValue &rv) {
955  assert(!shouldBindAsLValue(ov));
956  CGF.OpaqueRValues.insert(std::make_pair(ov, rv));
957 
958  OpaqueValueMappingData data(ov, false);
959 
960  // Work around an extremely aggressive peephole optimization in
961  // EmitScalarConversion which assumes that all other uses of a
962  // value are extant.
963  data.Protection = CGF.protectFromPeepholes(rv);
964 
965  return data;
966  }
967 
968  bool isValid() const { return OpaqueValue != nullptr; }
969  void clear() { OpaqueValue = nullptr; }
970 
971  void unbind(CodeGenFunction &CGF) {
972  assert(OpaqueValue && "no data to unbind!");
973 
974  if (BoundLValue) {
975  CGF.OpaqueLValues.erase(OpaqueValue);
976  } else {
977  CGF.OpaqueRValues.erase(OpaqueValue);
978  CGF.unprotectFromPeepholes(Protection);
979  }
980  }
981  };
982 
983  /// An RAII object to set (and then clear) a mapping for an OpaqueValueExpr.
985  CodeGenFunction &CGF;
987 
988  public:
989  static bool shouldBindAsLValue(const Expr *expr) {
991  }
992 
993  /// Build the opaque value mapping for the given conditional
994  /// operator if it's the GNU ?: extension. This is a common
995  /// enough pattern that the convenience operator is really
996  /// helpful.
997  ///
999  const AbstractConditionalOperator *op) : CGF(CGF) {
1000  if (isa<ConditionalOperator>(op))
1001  // Leave Data empty.
1002  return;
1003 
1004  const BinaryConditionalOperator *e = cast<BinaryConditionalOperator>(op);
1006  e->getCommon());
1007  }
1008 
1009  /// Build the opaque value mapping for an OpaqueValueExpr whose source
1010  /// expression is set to the expression the OVE represents.
1012  : CGF(CGF) {
1013  if (OV) {
1014  assert(OV->getSourceExpr() && "wrong form of OpaqueValueMapping used "
1015  "for OVE with no source expression");
1016  Data = OpaqueValueMappingData::bind(CGF, OV, OV->getSourceExpr());
1017  }
1018  }
1019 
1021  const OpaqueValueExpr *opaqueValue,
1022  LValue lvalue)
1023  : CGF(CGF), Data(OpaqueValueMappingData::bind(CGF, opaqueValue, lvalue)) {
1024  }
1025 
1027  const OpaqueValueExpr *opaqueValue,
1028  RValue rvalue)
1029  : CGF(CGF), Data(OpaqueValueMappingData::bind(CGF, opaqueValue, rvalue)) {
1030  }
1031 
1032  void pop() {
1033  Data.unbind(CGF);
1034  Data.clear();
1035  }
1036 
1038  if (Data.isValid()) Data.unbind(CGF);
1039  }
1040  };
1041 
1042 private:
1043  CGDebugInfo *DebugInfo;
1044  bool DisableDebugInfo;
1045 
1046  /// DidCallStackSave - Whether llvm.stacksave has been called. Used to avoid
1047  /// calling llvm.stacksave for multiple VLAs in the same scope.
1048  bool DidCallStackSave;
1049 
1050  /// IndirectBranch - The first time an indirect goto is seen we create a block
1051  /// with an indirect branch. Every time we see the address of a label taken,
1052  /// we add the label to the indirect goto. Every subsequent indirect goto is
1053  /// codegen'd as a jump to the IndirectBranch's basic block.
1054  llvm::IndirectBrInst *IndirectBranch;
1055 
1056  /// LocalDeclMap - This keeps track of the LLVM allocas or globals for local C
1057  /// decls.
1058  DeclMapTy LocalDeclMap;
1059 
1060  /// SizeArguments - If a ParmVarDecl had the pass_object_size attribute, this
1061  /// will contain a mapping from said ParmVarDecl to its implicit "object_size"
1062  /// parameter.
1063  llvm::SmallDenseMap<const ParmVarDecl *, const ImplicitParamDecl *, 2>
1064  SizeArguments;
1065 
1066  /// Track escaped local variables with auto storage. Used during SEH
1067  /// outlining to produce a call to llvm.localescape.
1068  llvm::DenseMap<llvm::AllocaInst *, int> EscapedLocals;
1069 
1070  /// LabelMap - This keeps track of the LLVM basic block for each C label.
1071  llvm::DenseMap<const LabelDecl*, JumpDest> LabelMap;
1072 
1073  // BreakContinueStack - This keeps track of where break and continue
1074  // statements should jump to.
1075  struct BreakContinue {
1076  BreakContinue(JumpDest Break, JumpDest Continue)
1077  : BreakBlock(Break), ContinueBlock(Continue) {}
1078 
1079  JumpDest BreakBlock;
1080  JumpDest ContinueBlock;
1081  };
1082  SmallVector<BreakContinue, 8> BreakContinueStack;
1083 
1084  /// Handles cancellation exit points in OpenMP-related constructs.
1085  class OpenMPCancelExitStack {
1086  /// Tracks cancellation exit point and join point for cancel-related exit
1087  /// and normal exit.
1088  struct CancelExit {
1089  CancelExit() = default;
1090  CancelExit(OpenMPDirectiveKind Kind, JumpDest ExitBlock,
1091  JumpDest ContBlock)
1092  : Kind(Kind), ExitBlock(ExitBlock), ContBlock(ContBlock) {}
1094  /// true if the exit block has been emitted already by the special
1095  /// emitExit() call, false if the default codegen is used.
1096  bool HasBeenEmitted = false;
1097  JumpDest ExitBlock;
1098  JumpDest ContBlock;
1099  };
1100 
1101  SmallVector<CancelExit, 8> Stack;
1102 
1103  public:
1104  OpenMPCancelExitStack() : Stack(1) {}
1105  ~OpenMPCancelExitStack() = default;
1106  /// Fetches the exit block for the current OpenMP construct.
1107  JumpDest getExitBlock() const { return Stack.back().ExitBlock; }
1108  /// Emits exit block with special codegen procedure specific for the related
1109  /// OpenMP construct + emits code for normal construct cleanup.
1110  void emitExit(CodeGenFunction &CGF, OpenMPDirectiveKind Kind,
1111  const llvm::function_ref<void(CodeGenFunction &)> &CodeGen) {
1112  if (Stack.back().Kind == Kind && getExitBlock().isValid()) {
1113  assert(CGF.getOMPCancelDestination(Kind).isValid());
1114  assert(CGF.HaveInsertPoint());
1115  assert(!Stack.back().HasBeenEmitted);
1116  auto IP = CGF.Builder.saveAndClearIP();
1117  CGF.EmitBlock(Stack.back().ExitBlock.getBlock());
1118  CodeGen(CGF);
1119  CGF.EmitBranchThroughCleanup(Stack.back().ContBlock);
1120  CGF.Builder.restoreIP(IP);
1121  Stack.back().HasBeenEmitted = true;
1122  }
1123  CodeGen(CGF);
1124  }
1125  /// Enter the cancel supporting \a Kind construct.
1126  /// \param Kind OpenMP directive that supports cancel constructs.
1127  /// \param HasCancel true, if the construct has inner cancel directive,
1128  /// false otherwise.
1129  void enter(CodeGenFunction &CGF, OpenMPDirectiveKind Kind, bool HasCancel) {
1130  Stack.push_back({Kind,
1131  HasCancel ? CGF.getJumpDestInCurrentScope("cancel.exit")
1132  : JumpDest(),
1133  HasCancel ? CGF.getJumpDestInCurrentScope("cancel.cont")
1134  : JumpDest()});
1135  }
1136  /// Emits default exit point for the cancel construct (if the special one
1137  /// has not be used) + join point for cancel/normal exits.
1138  void exit(CodeGenFunction &CGF) {
1139  if (getExitBlock().isValid()) {
1140  assert(CGF.getOMPCancelDestination(Stack.back().Kind).isValid());
1141  bool HaveIP = CGF.HaveInsertPoint();
1142  if (!Stack.back().HasBeenEmitted) {
1143  if (HaveIP)
1144  CGF.EmitBranchThroughCleanup(Stack.back().ContBlock);
1145  CGF.EmitBlock(Stack.back().ExitBlock.getBlock());
1146  CGF.EmitBranchThroughCleanup(Stack.back().ContBlock);
1147  }
1148  CGF.EmitBlock(Stack.back().ContBlock.getBlock());
1149  if (!HaveIP) {
1150  CGF.Builder.CreateUnreachable();
1151  CGF.Builder.ClearInsertionPoint();
1152  }
1153  }
1154  Stack.pop_back();
1155  }
1156  };
1157  OpenMPCancelExitStack OMPCancelStack;
1158 
1159  /// Controls insertion of cancellation exit blocks in worksharing constructs.
1160  class OMPCancelStackRAII {
1161  CodeGenFunction &CGF;
1162 
1163  public:
1164  OMPCancelStackRAII(CodeGenFunction &CGF, OpenMPDirectiveKind Kind,
1165  bool HasCancel)
1166  : CGF(CGF) {
1167  CGF.OMPCancelStack.enter(CGF, Kind, HasCancel);
1168  }
1169  ~OMPCancelStackRAII() { CGF.OMPCancelStack.exit(CGF); }
1170  };
1171 
1172  CodeGenPGO PGO;
1173 
1174  /// Calculate branch weights appropriate for PGO data
1175  llvm::MDNode *createProfileWeights(uint64_t TrueCount, uint64_t FalseCount);
1176  llvm::MDNode *createProfileWeights(ArrayRef<uint64_t> Weights);
1177  llvm::MDNode *createProfileWeightsForLoop(const Stmt *Cond,
1178  uint64_t LoopCount);
1179 
1180 public:
1181  /// Increment the profiler's counter for the given statement by \p StepV.
1182  /// If \p StepV is null, the default increment is 1.
1183  void incrementProfileCounter(const Stmt *S, llvm::Value *StepV = nullptr) {
1185  PGO.emitCounterIncrement(Builder, S, StepV);
1186  PGO.setCurrentStmt(S);
1187  }
1188 
1189  /// Get the profiler's count for the given statement.
1190  uint64_t getProfileCount(const Stmt *S) {
1191  Optional<uint64_t> Count = PGO.getStmtCount(S);
1192  if (!Count.hasValue())
1193  return 0;
1194  return *Count;
1195  }
1196 
1197  /// Set the profiler's current count.
1198  void setCurrentProfileCount(uint64_t Count) {
1199  PGO.setCurrentRegionCount(Count);
1200  }
1201 
1202  /// Get the profiler's current count. This is generally the count for the most
1203  /// recently incremented counter.
1205  return PGO.getCurrentRegionCount();
1206  }
1207 
1208 private:
1209 
1210  /// SwitchInsn - This is nearest current switch instruction. It is null if
1211  /// current context is not in a switch.
1212  llvm::SwitchInst *SwitchInsn;
1213  /// The branch weights of SwitchInsn when doing instrumentation based PGO.
1214  SmallVector<uint64_t, 16> *SwitchWeights;
1215 
1216  /// CaseRangeBlock - This block holds if condition check for last case
1217  /// statement range in current switch instruction.
1218  llvm::BasicBlock *CaseRangeBlock;
1219 
1220  /// OpaqueLValues - Keeps track of the current set of opaque value
1221  /// expressions.
1222  llvm::DenseMap<const OpaqueValueExpr *, LValue> OpaqueLValues;
1223  llvm::DenseMap<const OpaqueValueExpr *, RValue> OpaqueRValues;
1224 
1225  // VLASizeMap - This keeps track of the associated size for each VLA type.
1226  // We track this by the size expression rather than the type itself because
1227  // in certain situations, like a const qualifier applied to an VLA typedef,
1228  // multiple VLA types can share the same size expression.
1229  // FIXME: Maybe this could be a stack of maps that is pushed/popped as we
1230  // enter/leave scopes.
1231  llvm::DenseMap<const Expr*, llvm::Value*> VLASizeMap;
1232 
1233  /// A block containing a single 'unreachable' instruction. Created
1234  /// lazily by getUnreachableBlock().
1235  llvm::BasicBlock *UnreachableBlock;
1236 
1237  /// Counts of the number return expressions in the function.
1238  unsigned NumReturnExprs;
1239 
1240  /// Count the number of simple (constant) return expressions in the function.
1241  unsigned NumSimpleReturnExprs;
1242 
1243  /// The last regular (non-return) debug location (breakpoint) in the function.
1244  SourceLocation LastStopPoint;
1245 
1246 public:
1247  /// A scope within which we are constructing the fields of an object which
1248  /// might use a CXXDefaultInitExpr. This stashes away a 'this' value to use
1249  /// if we need to evaluate a CXXDefaultInitExpr within the evaluation.
1251  public:
1253  : CGF(CGF), OldCXXDefaultInitExprThis(CGF.CXXDefaultInitExprThis) {
1254  CGF.CXXDefaultInitExprThis = This;
1255  }
1257  CGF.CXXDefaultInitExprThis = OldCXXDefaultInitExprThis;
1258  }
1259 
1260  private:
1261  CodeGenFunction &CGF;
1262  Address OldCXXDefaultInitExprThis;
1263  };
1264 
1265  /// The scope of a CXXDefaultInitExpr. Within this scope, the value of 'this'
1266  /// is overridden to be the object under construction.
1268  public:
1270  : CGF(CGF), OldCXXThisValue(CGF.CXXThisValue),
1271  OldCXXThisAlignment(CGF.CXXThisAlignment) {
1272  CGF.CXXThisValue = CGF.CXXDefaultInitExprThis.getPointer();
1273  CGF.CXXThisAlignment = CGF.CXXDefaultInitExprThis.getAlignment();
1274  }
1276  CGF.CXXThisValue = OldCXXThisValue;
1277  CGF.CXXThisAlignment = OldCXXThisAlignment;
1278  }
1279 
1280  public:
1284  };
1285 
1286  /// The scope of an ArrayInitLoopExpr. Within this scope, the value of the
1287  /// current loop index is overridden.
1289  public:
1291  : CGF(CGF), OldArrayInitIndex(CGF.ArrayInitIndex) {
1292  CGF.ArrayInitIndex = Index;
1293  }
1295  CGF.ArrayInitIndex = OldArrayInitIndex;
1296  }
1297 
1298  private:
1299  CodeGenFunction &CGF;
1300  llvm::Value *OldArrayInitIndex;
1301  };
1302 
1304  public:
1306  : CGF(CGF), OldCurGD(CGF.CurGD), OldCurFuncDecl(CGF.CurFuncDecl),
1307  OldCurCodeDecl(CGF.CurCodeDecl),
1308  OldCXXABIThisDecl(CGF.CXXABIThisDecl),
1309  OldCXXABIThisValue(CGF.CXXABIThisValue),
1310  OldCXXThisValue(CGF.CXXThisValue),
1311  OldCXXABIThisAlignment(CGF.CXXABIThisAlignment),
1312  OldCXXThisAlignment(CGF.CXXThisAlignment),
1313  OldReturnValue(CGF.ReturnValue), OldFnRetTy(CGF.FnRetTy),
1314  OldCXXInheritedCtorInitExprArgs(
1315  std::move(CGF.CXXInheritedCtorInitExprArgs)) {
1316  CGF.CurGD = GD;
1317  CGF.CurFuncDecl = CGF.CurCodeDecl =
1318  cast<CXXConstructorDecl>(GD.getDecl());
1319  CGF.CXXABIThisDecl = nullptr;
1320  CGF.CXXABIThisValue = nullptr;
1321  CGF.CXXThisValue = nullptr;
1322  CGF.CXXABIThisAlignment = CharUnits();
1323  CGF.CXXThisAlignment = CharUnits();
1324  CGF.ReturnValue = Address::invalid();
1325  CGF.FnRetTy = QualType();
1326  CGF.CXXInheritedCtorInitExprArgs.clear();
1327  }
1329  CGF.CurGD = OldCurGD;
1330  CGF.CurFuncDecl = OldCurFuncDecl;
1331  CGF.CurCodeDecl = OldCurCodeDecl;
1332  CGF.CXXABIThisDecl = OldCXXABIThisDecl;
1333  CGF.CXXABIThisValue = OldCXXABIThisValue;
1334  CGF.CXXThisValue = OldCXXThisValue;
1335  CGF.CXXABIThisAlignment = OldCXXABIThisAlignment;
1336  CGF.CXXThisAlignment = OldCXXThisAlignment;
1337  CGF.ReturnValue = OldReturnValue;
1338  CGF.FnRetTy = OldFnRetTy;
1339  CGF.CXXInheritedCtorInitExprArgs =
1340  std::move(OldCXXInheritedCtorInitExprArgs);
1341  }
1342 
1343  private:
1344  CodeGenFunction &CGF;
1345  GlobalDecl OldCurGD;
1346  const Decl *OldCurFuncDecl;
1347  const Decl *OldCurCodeDecl;
1348  ImplicitParamDecl *OldCXXABIThisDecl;
1349  llvm::Value *OldCXXABIThisValue;
1350  llvm::Value *OldCXXThisValue;
1351  CharUnits OldCXXABIThisAlignment;
1352  CharUnits OldCXXThisAlignment;
1353  Address OldReturnValue;
1354  QualType OldFnRetTy;
1355  CallArgList OldCXXInheritedCtorInitExprArgs;
1356  };
1357 
1358 private:
1359  /// CXXThisDecl - When generating code for a C++ member function,
1360  /// this will hold the implicit 'this' declaration.
1361  ImplicitParamDecl *CXXABIThisDecl;
1362  llvm::Value *CXXABIThisValue;
1363  llvm::Value *CXXThisValue;
1364  CharUnits CXXABIThisAlignment;
1365  CharUnits CXXThisAlignment;
1366 
1367  /// The value of 'this' to use when evaluating CXXDefaultInitExprs within
1368  /// this expression.
1369  Address CXXDefaultInitExprThis = Address::invalid();
1370 
1371  /// The current array initialization index when evaluating an
1372  /// ArrayInitIndexExpr within an ArrayInitLoopExpr.
1373  llvm::Value *ArrayInitIndex = nullptr;
1374 
1375  /// The values of function arguments to use when evaluating
1376  /// CXXInheritedCtorInitExprs within this context.
1377  CallArgList CXXInheritedCtorInitExprArgs;
1378 
1379  /// CXXStructorImplicitParamDecl - When generating code for a constructor or
1380  /// destructor, this will hold the implicit argument (e.g. VTT).
1381  ImplicitParamDecl *CXXStructorImplicitParamDecl;
1382  llvm::Value *CXXStructorImplicitParamValue;
1383 
1384  /// OutermostConditional - Points to the outermost active
1385  /// conditional control. This is used so that we know if a
1386  /// temporary should be destroyed conditionally.
1387  ConditionalEvaluation *OutermostConditional;
1388 
1389  /// The current lexical scope.
1390  LexicalScope *CurLexicalScope;
1391 
1392  /// The current source location that should be used for exception
1393  /// handling code.
1394  SourceLocation CurEHLocation;
1395 
1396  /// BlockByrefInfos - For each __block variable, contains
1397  /// information about the layout of the variable.
1398  llvm::DenseMap<const ValueDecl *, BlockByrefInfo> BlockByrefInfos;
1399 
1400  /// Used by -fsanitize=nullability-return to determine whether the return
1401  /// value can be checked.
1402  llvm::Value *RetValNullabilityPrecondition = nullptr;
1403 
1404  /// Check if -fsanitize=nullability-return instrumentation is required for
1405  /// this function.
1406  bool requiresReturnValueNullabilityCheck() const {
1407  return RetValNullabilityPrecondition;
1408  }
1409 
1410  /// Used to store precise source locations for return statements by the
1411  /// runtime return value checks.
1412  Address ReturnLocation = Address::invalid();
1413 
1414  /// Check if the return value of this function requires sanitization.
1415  bool requiresReturnValueCheck() const {
1416  return requiresReturnValueNullabilityCheck() ||
1417  (SanOpts.has(SanitizerKind::ReturnsNonnullAttribute) &&
1418  CurCodeDecl && CurCodeDecl->getAttr<ReturnsNonNullAttr>());
1419  }
1420 
1421  llvm::BasicBlock *TerminateLandingPad;
1422  llvm::BasicBlock *TerminateHandler;
1423  llvm::BasicBlock *TrapBB;
1424 
1425  /// True if we need emit the life-time markers.
1426  const bool ShouldEmitLifetimeMarkers;
1427 
1428  /// Add OpenCL kernel arg metadata and the kernel attribute meatadata to
1429  /// the function metadata.
1430  void EmitOpenCLKernelMetadata(const FunctionDecl *FD,
1431  llvm::Function *Fn);
1432 
1433 public:
1434  CodeGenFunction(CodeGenModule &cgm, bool suppressNewContext=false);
1435  ~CodeGenFunction();
1436 
1437  CodeGenTypes &getTypes() const { return CGM.getTypes(); }
1438  ASTContext &getContext() const { return CGM.getContext(); }
1440  if (DisableDebugInfo)
1441  return nullptr;
1442  return DebugInfo;
1443  }
1444  void disableDebugInfo() { DisableDebugInfo = true; }
1445  void enableDebugInfo() { DisableDebugInfo = false; }
1446 
1448  return CGM.getCodeGenOpts().OptimizationLevel == 0;
1449  }
1450 
1451  const LangOptions &getLangOpts() const { return CGM.getLangOpts(); }
1452 
1453  /// Returns a pointer to the function's exception object and selector slot,
1454  /// which is assigned in every landing pad.
1457 
1458  /// Returns the contents of the function's exception object and selector
1459  /// slots.
1462 
1464 
1465  llvm::BasicBlock *getUnreachableBlock() {
1466  if (!UnreachableBlock) {
1467  UnreachableBlock = createBasicBlock("unreachable");
1468  new llvm::UnreachableInst(getLLVMContext(), UnreachableBlock);
1469  }
1470  return UnreachableBlock;
1471  }
1472 
1473  llvm::BasicBlock *getInvokeDest() {
1474  if (!EHStack.requiresLandingPad()) return nullptr;
1475  return getInvokeDestImpl();
1476  }
1477 
1478  bool currentFunctionUsesSEHTry() const { return CurSEHParent != nullptr; }
1479 
1480  const TargetInfo &getTarget() const { return Target; }
1481  llvm::LLVMContext &getLLVMContext() { return CGM.getLLVMContext(); }
1483  return CGM.getTargetCodeGenInfo();
1484  }
1485 
1486  //===--------------------------------------------------------------------===//
1487  // Cleanups
1488  //===--------------------------------------------------------------------===//
1489 
1490  typedef void Destroyer(CodeGenFunction &CGF, Address addr, QualType ty);
1491 
1493  Address arrayEndPointer,
1494  QualType elementType,
1495  CharUnits elementAlignment,
1496  Destroyer *destroyer);
1498  llvm::Value *arrayEnd,
1499  QualType elementType,
1500  CharUnits elementAlignment,
1501  Destroyer *destroyer);
1502 
1503  void pushDestroy(QualType::DestructionKind dtorKind,
1504  Address addr, QualType type);
1506  Address addr, QualType type);
1508  Destroyer *destroyer, bool useEHCleanupForArray);
1510  QualType type, Destroyer *destroyer,
1511  bool useEHCleanupForArray);
1512  void pushCallObjectDeleteCleanup(const FunctionDecl *OperatorDelete,
1513  llvm::Value *CompletePtr,
1514  QualType ElementType);
1516  void emitDestroy(Address addr, QualType type, Destroyer *destroyer,
1517  bool useEHCleanupForArray);
1518  llvm::Function *generateDestroyHelper(Address addr, QualType type,
1519  Destroyer *destroyer,
1520  bool useEHCleanupForArray,
1521  const VarDecl *VD);
1522  void emitArrayDestroy(llvm::Value *begin, llvm::Value *end,
1523  QualType elementType, CharUnits elementAlign,
1524  Destroyer *destroyer,
1525  bool checkZeroLength, bool useEHCleanup);
1526 
1528 
1529  /// Determines whether an EH cleanup is required to destroy a type
1530  /// with the given destruction kind.
1532  switch (kind) {
1533  case QualType::DK_none:
1534  return false;
1537  return getLangOpts().Exceptions;
1539  return getLangOpts().Exceptions &&
1540  CGM.getCodeGenOpts().ObjCAutoRefCountExceptions;
1541  }
1542  llvm_unreachable("bad destruction kind");
1543  }
1544 
1546  return (needsEHCleanup(kind) ? NormalAndEHCleanup : NormalCleanup);
1547  }
1548 
1549  //===--------------------------------------------------------------------===//
1550  // Objective-C
1551  //===--------------------------------------------------------------------===//
1552 
1553  void GenerateObjCMethod(const ObjCMethodDecl *OMD);
1554 
1555  void StartObjCMethod(const ObjCMethodDecl *MD, const ObjCContainerDecl *CD);
1556 
1557  /// GenerateObjCGetter - Synthesize an Objective-C property getter function.
1559  const ObjCPropertyImplDecl *PID);
1560  void generateObjCGetterBody(const ObjCImplementationDecl *classImpl,
1561  const ObjCPropertyImplDecl *propImpl,
1562  const ObjCMethodDecl *GetterMothodDecl,
1563  llvm::Constant *AtomicHelperFn);
1564 
1566  ObjCMethodDecl *MD, bool ctor);
1567 
1568  /// GenerateObjCSetter - Synthesize an Objective-C property setter function
1569  /// for the given property.
1571  const ObjCPropertyImplDecl *PID);
1572  void generateObjCSetterBody(const ObjCImplementationDecl *classImpl,
1573  const ObjCPropertyImplDecl *propImpl,
1574  llvm::Constant *AtomicHelperFn);
1575 
1576  //===--------------------------------------------------------------------===//
1577  // Block Bits
1578  //===--------------------------------------------------------------------===//
1579 
1581  static void destroyBlockInfos(CGBlockInfo *info);
1582 
1583  llvm::Function *GenerateBlockFunction(GlobalDecl GD,
1584  const CGBlockInfo &Info,
1585  const DeclMapTy &ldm,
1586  bool IsLambdaConversionToBlock);
1587 
1588  llvm::Constant *GenerateCopyHelperFunction(const CGBlockInfo &blockInfo);
1589  llvm::Constant *GenerateDestroyHelperFunction(const CGBlockInfo &blockInfo);
1591  const ObjCPropertyImplDecl *PID);
1593  const ObjCPropertyImplDecl *PID);
1595 
1596  void BuildBlockRelease(llvm::Value *DeclPtr, BlockFieldFlags flags);
1597 
1598  class AutoVarEmission;
1599 
1600  void emitByrefStructureInit(const AutoVarEmission &emission);
1601  void enterByrefCleanup(const AutoVarEmission &emission);
1602 
1603  void setBlockContextParameter(const ImplicitParamDecl *D, unsigned argNum,
1604  llvm::Value *ptr);
1605 
1607  Address GetAddrOfBlockDecl(const VarDecl *var, bool ByRef);
1608 
1609  /// BuildBlockByrefAddress - Computes the location of the
1610  /// data in a variable which is declared as __block.
1611  Address emitBlockByrefAddress(Address baseAddr, const VarDecl *V,
1612  bool followForward = true);
1614  const BlockByrefInfo &info,
1615  bool followForward,
1616  const llvm::Twine &name);
1617 
1618  const BlockByrefInfo &getBlockByrefInfo(const VarDecl *var);
1619 
1621 
1622  void GenerateCode(GlobalDecl GD, llvm::Function *Fn,
1623  const CGFunctionInfo &FnInfo);
1624  /// \brief Emit code for the start of a function.
1625  /// \param Loc The location to be associated with the function.
1626  /// \param StartLoc The location of the function body.
1627  void StartFunction(GlobalDecl GD,
1628  QualType RetTy,
1629  llvm::Function *Fn,
1630  const CGFunctionInfo &FnInfo,
1631  const FunctionArgList &Args,
1633  SourceLocation StartLoc = SourceLocation());
1634 
1635  static bool IsConstructorDelegationValid(const CXXConstructorDecl *Ctor);
1636 
1638  void EmitDestructorBody(FunctionArgList &Args);
1640  void EmitFunctionBody(FunctionArgList &Args, const Stmt *Body);
1641  void EmitBlockWithFallThrough(llvm::BasicBlock *BB, const Stmt *S);
1642 
1643  void EmitForwardingCallToLambda(const CXXMethodDecl *LambdaCallOperator,
1644  CallArgList &CallArgs);
1649  void EmitAsanPrologueOrEpilogue(bool Prologue);
1650 
1651  /// \brief Emit the unified return block, trying to avoid its emission when
1652  /// possible.
1653  /// \return The debug location of the user written return statement if the
1654  /// return block is is avoided.
1655  llvm::DebugLoc EmitReturnBlock();
1656 
1657  /// FinishFunction - Complete IR generation of the current function. It is
1658  /// legal to call this function even if there is no current insertion point.
1660 
1661  void StartThunk(llvm::Function *Fn, GlobalDecl GD,
1662  const CGFunctionInfo &FnInfo);
1663 
1664  void EmitCallAndReturnForThunk(llvm::Constant *Callee,
1665  const ThunkInfo *Thunk);
1666 
1667  void FinishThunk();
1668 
1669  /// Emit a musttail call for a thunk with a potentially adjusted this pointer.
1670  void EmitMustTailThunk(const CXXMethodDecl *MD, llvm::Value *AdjustedThisPtr,
1671  llvm::Value *Callee);
1672 
1673  /// Generate a thunk for the given method.
1674  void generateThunk(llvm::Function *Fn, const CGFunctionInfo &FnInfo,
1675  GlobalDecl GD, const ThunkInfo &Thunk);
1676 
1677  llvm::Function *GenerateVarArgsThunk(llvm::Function *Fn,
1678  const CGFunctionInfo &FnInfo,
1679  GlobalDecl GD, const ThunkInfo &Thunk);
1680 
1682  FunctionArgList &Args);
1683 
1684  void EmitInitializerForField(FieldDecl *Field, LValue LHS, Expr *Init);
1685 
1686  /// Struct with all informations about dynamic [sub]class needed to set vptr.
1687  struct VPtr {
1692  };
1693 
1694  /// Initialize the vtable pointer of the given subobject.
1695  void InitializeVTablePointer(const VPtr &vptr);
1696 
1698 
1699  typedef llvm::SmallPtrSet<const CXXRecordDecl *, 4> VisitedVirtualBasesSetTy;
1700  VPtrsVector getVTablePointers(const CXXRecordDecl *VTableClass);
1701 
1702  void getVTablePointers(BaseSubobject Base, const CXXRecordDecl *NearestVBase,
1703  CharUnits OffsetFromNearestVBase,
1704  bool BaseIsNonVirtualPrimaryBase,
1705  const CXXRecordDecl *VTableClass,
1706  VisitedVirtualBasesSetTy &VBases, VPtrsVector &vptrs);
1707 
1708  void InitializeVTablePointers(const CXXRecordDecl *ClassDecl);
1709 
1710  /// GetVTablePtr - Return the Value of the vtable pointer member pointed
1711  /// to by This.
1712  llvm::Value *GetVTablePtr(Address This, llvm::Type *VTableTy,
1713  const CXXRecordDecl *VTableClass);
1714 
1721  };
1722 
1723  /// \brief Derived is the presumed address of an object of type T after a
1724  /// cast. If T is a polymorphic class type, emit a check that the virtual
1725  /// table for Derived belongs to a class derived from T.
1727  bool MayBeNull, CFITypeCheckKind TCK,
1728  SourceLocation Loc);
1729 
1730  /// EmitVTablePtrCheckForCall - Virtual method MD is being called via VTable.
1731  /// If vptr CFI is enabled, emit a check that VTable is valid.
1732  void EmitVTablePtrCheckForCall(const CXXRecordDecl *RD, llvm::Value *VTable,
1733  CFITypeCheckKind TCK, SourceLocation Loc);
1734 
1735  /// EmitVTablePtrCheck - Emit a check that VTable is a valid virtual table for
1736  /// RD using llvm.type.test.
1737  void EmitVTablePtrCheck(const CXXRecordDecl *RD, llvm::Value *VTable,
1738  CFITypeCheckKind TCK, SourceLocation Loc);
1739 
1740  /// If whole-program virtual table optimization is enabled, emit an assumption
1741  /// that VTable is a member of RD's type identifier. Or, if vptr CFI is
1742  /// enabled, emit a check that VTable is a member of RD's type identifier.
1744  llvm::Value *VTable, SourceLocation Loc);
1745 
1746  /// Returns whether we should perform a type checked load when loading a
1747  /// virtual function for virtual calls to members of RD. This is generally
1748  /// true when both vcall CFI and whole-program-vtables are enabled.
1750 
1751  /// Emit a type checked load from the given vtable.
1753  uint64_t VTableByteOffset);
1754 
1755  /// EnterDtorCleanups - Enter the cleanups necessary to complete the
1756  /// given phase of destruction for a destructor. The end result
1757  /// should call destructors on members and base classes in reverse
1758  /// order of their construction.
1760 
1761  /// ShouldInstrumentFunction - Return true if the current function should be
1762  /// instrumented with __cyg_profile_func_* calls
1763  bool ShouldInstrumentFunction();
1764 
1765  /// ShouldXRayInstrument - Return true if the current function should be
1766  /// instrumented with XRay nop sleds.
1767  bool ShouldXRayInstrumentFunction() const;
1768 
1769  /// EmitFunctionInstrumentation - Emit LLVM code to call the specified
1770  /// instrumentation function with the current function and the call site, if
1771  /// function instrumentation is enabled.
1772  void EmitFunctionInstrumentation(const char *Fn);
1773 
1774  /// EmitMCountInstrumentation - Emit call to .mcount.
1776 
1777  /// EmitFunctionProlog - Emit the target specific LLVM code to load the
1778  /// arguments for the given function. This is also responsible for naming the
1779  /// LLVM function arguments.
1780  void EmitFunctionProlog(const CGFunctionInfo &FI,
1781  llvm::Function *Fn,
1782  const FunctionArgList &Args);
1783 
1784  /// EmitFunctionEpilog - Emit the target specific LLVM code to return the
1785  /// given temporary.
1786  void EmitFunctionEpilog(const CGFunctionInfo &FI, bool EmitRetDbgLoc,
1787  SourceLocation EndLoc);
1788 
1789  /// Emit a test that checks if the return value \p RV is nonnull.
1791 
1792  /// EmitStartEHSpec - Emit the start of the exception spec.
1793  void EmitStartEHSpec(const Decl *D);
1794 
1795  /// EmitEndEHSpec - Emit the end of the exception spec.
1796  void EmitEndEHSpec(const Decl *D);
1797 
1798  /// getTerminateLandingPad - Return a landing pad that just calls terminate.
1799  llvm::BasicBlock *getTerminateLandingPad();
1800 
1801  /// getTerminateHandler - Return a handler (not a landing pad, just
1802  /// a catch handler) that just calls terminate. This is used when
1803  /// a terminate scope encloses a try.
1804  llvm::BasicBlock *getTerminateHandler();
1805 
1809  return ConvertType(getContext().getTypeDeclType(T));
1810  }
1811 
1812  /// LoadObjCSelf - Load the value of self. This function is only valid while
1813  /// generating code for an Objective-C method.
1815 
1816  /// TypeOfSelfObject - Return type of object that this self represents.
1818 
1819  /// hasAggregateLLVMType - Return true if the specified AST type will map into
1820  /// an aggregate LLVM type or is void.
1822 
1824  return getEvaluationKind(T) == TEK_Scalar;
1825  }
1826 
1828  return getEvaluationKind(T) == TEK_Aggregate;
1829  }
1830 
1831  /// createBasicBlock - Create an LLVM basic block.
1832  llvm::BasicBlock *createBasicBlock(const Twine &name = "",
1833  llvm::Function *parent = nullptr,
1834  llvm::BasicBlock *before = nullptr) {
1835 #ifdef NDEBUG
1836  return llvm::BasicBlock::Create(getLLVMContext(), "", parent, before);
1837 #else
1838  return llvm::BasicBlock::Create(getLLVMContext(), name, parent, before);
1839 #endif
1840  }
1841 
1842  /// getBasicBlockForLabel - Return the LLVM basicblock that the specified
1843  /// label maps to.
1844  JumpDest getJumpDestForLabel(const LabelDecl *S);
1845 
1846  /// SimplifyForwardingBlocks - If the given basic block is only a branch to
1847  /// another basic block, simplify it. This assumes that no other code could
1848  /// potentially reference the basic block.
1849  void SimplifyForwardingBlocks(llvm::BasicBlock *BB);
1850 
1851  /// EmitBlock - Emit the given block \arg BB and set it as the insert point,
1852  /// adding a fall-through branch from the current insert block if
1853  /// necessary. It is legal to call this function even if there is no current
1854  /// insertion point.
1855  ///
1856  /// IsFinished - If true, indicates that the caller has finished emitting
1857  /// branches to the given block and does not expect to emit code into it. This
1858  /// means the block can be ignored if it is unreachable.
1859  void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false);
1860 
1861  /// EmitBlockAfterUses - Emit the given block somewhere hopefully
1862  /// near its uses, and leave the insertion point in it.
1863  void EmitBlockAfterUses(llvm::BasicBlock *BB);
1864 
1865  /// EmitBranch - Emit a branch to the specified basic block from the current
1866  /// insert block, taking care to avoid creation of branches from dummy
1867  /// blocks. It is legal to call this function even if there is no current
1868  /// insertion point.
1869  ///
1870  /// This function clears the current insertion point. The caller should follow
1871  /// calls to this function with calls to Emit*Block prior to generation new
1872  /// code.
1873  void EmitBranch(llvm::BasicBlock *Block);
1874 
1875  /// HaveInsertPoint - True if an insertion point is defined. If not, this
1876  /// indicates that the current code being emitted is unreachable.
1877  bool HaveInsertPoint() const {
1878  return Builder.GetInsertBlock() != nullptr;
1879  }
1880 
1881  /// EnsureInsertPoint - Ensure that an insertion point is defined so that
1882  /// emitted IR has a place to go. Note that by definition, if this function
1883  /// creates a block then that block is unreachable; callers may do better to
1884  /// detect when no insertion point is defined and simply skip IR generation.
1886  if (!HaveInsertPoint())
1888  }
1889 
1890  /// ErrorUnsupported - Print out an error that codegen doesn't support the
1891  /// specified stmt yet.
1892  void ErrorUnsupported(const Stmt *S, const char *Type);
1893 
1894  //===--------------------------------------------------------------------===//
1895  // Helpers
1896  //===--------------------------------------------------------------------===//
1897 
1899  LValueBaseInfo BaseInfo =
1901  return LValue::MakeAddr(Addr, T, getContext(), BaseInfo,
1902  CGM.getTBAAInfo(T));
1903  }
1904 
1906  LValueBaseInfo BaseInfo =
1908  return LValue::MakeAddr(Address(V, Alignment), T, getContext(),
1909  BaseInfo, CGM.getTBAAInfo(T));
1910  }
1911 
1915  LValueBaseInfo *BaseInfo = nullptr,
1916  bool forPointeeType = false);
1918  LValueBaseInfo *BaseInfo = nullptr);
1919 
1921  LValueBaseInfo *BaseInfo = nullptr);
1923 
1924  Address EmitLoadOfPointer(Address Ptr, const PointerType *PtrTy,
1925  LValueBaseInfo *BaseInfo = nullptr);
1927 
1928  /// CreateTempAlloca - This creates an alloca and inserts it into the entry
1929  /// block if \p ArraySize is nullptr, otherwise inserts it at the current
1930  /// insertion point of the builder. The caller is responsible for setting an
1931  /// appropriate alignment on
1932  /// the alloca.
1933  ///
1934  /// \p ArraySize is the number of array elements to be allocated if it
1935  /// is not nullptr.
1936  ///
1937  /// LangAS::Default is the address space of pointers to local variables and
1938  /// temporaries, as exposed in the source language. In certain
1939  /// configurations, this is not the same as the alloca address space, and a
1940  /// cast is needed to lift the pointer from the alloca AS into
1941  /// LangAS::Default. This can happen when the target uses a restricted
1942  /// address space for the stack but the source language requires
1943  /// LangAS::Default to be a generic address space. The latter condition is
1944  /// common for most programming languages; OpenCL is an exception in that
1945  /// LangAS::Default is the private address space, which naturally maps
1946  /// to the stack.
1947  ///
1948  /// Because the address of a temporary is often exposed to the program in
1949  /// various ways, this function will perform the cast by default. The cast
1950  /// may be avoided by passing false as \p CastToDefaultAddrSpace; this is
1951  /// more efficient if the caller knows that the address will not be exposed.
1952  llvm::AllocaInst *CreateTempAlloca(llvm::Type *Ty, const Twine &Name = "tmp",
1953  llvm::Value *ArraySize = nullptr);
1955  const Twine &Name = "tmp",
1956  llvm::Value *ArraySize = nullptr,
1957  bool CastToDefaultAddrSpace = true);
1958 
1959  /// CreateDefaultAlignedTempAlloca - This creates an alloca with the
1960  /// default ABI alignment of the given LLVM type.
1961  ///
1962  /// IMPORTANT NOTE: This is *not* generally the right alignment for
1963  /// any given AST type that happens to have been lowered to the
1964  /// given IR type. This should only ever be used for function-local,
1965  /// IR-driven manipulations like saving and restoring a value. Do
1966  /// not hand this address off to arbitrary IRGen routines, and especially
1967  /// do not pass it as an argument to a function that might expect a
1968  /// properly ABI-aligned value.
1970  const Twine &Name = "tmp");
1971 
1972  /// InitTempAlloca - Provide an initial value for the given alloca which
1973  /// will be observable at all locations in the function.
1974  ///
1975  /// The address should be something that was returned from one of
1976  /// the CreateTempAlloca or CreateMemTemp routines, and the
1977  /// initializer must be valid in the entry block (i.e. it must
1978  /// either be a constant or an argument value).
1979  void InitTempAlloca(Address Alloca, llvm::Value *Value);
1980 
1981  /// CreateIRTemp - Create a temporary IR object of the given type, with
1982  /// appropriate alignment. This routine should only be used when an temporary
1983  /// value needs to be stored into an alloca (for example, to avoid explicit
1984  /// PHI construction), but the type is the IR type, not the type appropriate
1985  /// for storing in memory.
1986  ///
1987  /// That is, this is exactly equivalent to CreateMemTemp, but calling
1988  /// ConvertType instead of ConvertTypeForMem.
1989  Address CreateIRTemp(QualType T, const Twine &Name = "tmp");
1990 
1991  /// CreateMemTemp - Create a temporary memory object of the given type, with
1992  /// appropriate alignment. Cast it to the default address space if
1993  /// \p CastToDefaultAddrSpace is true.
1994  Address CreateMemTemp(QualType T, const Twine &Name = "tmp",
1995  bool CastToDefaultAddrSpace = true);
1996  Address CreateMemTemp(QualType T, CharUnits Align, const Twine &Name = "tmp",
1997  bool CastToDefaultAddrSpace = true);
1998 
1999  /// CreateAggTemp - Create a temporary memory object for the given
2000  /// aggregate type.
2001  AggValueSlot CreateAggTemp(QualType T, const Twine &Name = "tmp") {
2003  T.getQualifiers(),
2007  }
2008 
2009  /// Emit a cast to void* in the appropriate address space.
2011 
2012  /// EvaluateExprAsBool - Perform the usual unary conversions on the specified
2013  /// expression and compare the result against zero, returning an Int1Ty value.
2015 
2016  /// EmitIgnoredExpr - Emit an expression in a context which ignores the result.
2017  void EmitIgnoredExpr(const Expr *E);
2018 
2019  /// EmitAnyExpr - Emit code to compute the specified expression which can have
2020  /// any type. The result is returned as an RValue struct. If this is an
2021  /// aggregate expression, the aggloc/agglocvolatile arguments indicate where
2022  /// the result should be returned.
2023  ///
2024  /// \param ignoreResult True if the resulting value isn't used.
2025  RValue EmitAnyExpr(const Expr *E,
2026  AggValueSlot aggSlot = AggValueSlot::ignored(),
2027  bool ignoreResult = false);
2028 
2029  // EmitVAListRef - Emit a "reference" to a va_list; this is either the address
2030  // or the value of the expression, depending on how va_list is defined.
2031  Address EmitVAListRef(const Expr *E);
2032 
2033  /// Emit a "reference" to a __builtin_ms_va_list; this is
2034  /// always the value of the expression, because a __builtin_ms_va_list is a
2035  /// pointer to a char.
2036  Address EmitMSVAListRef(const Expr *E);
2037 
2038  /// EmitAnyExprToTemp - Similarly to EmitAnyExpr(), however, the result will
2039  /// always be accessible even if no aggregate location is provided.
2040  RValue EmitAnyExprToTemp(const Expr *E);
2041 
2042  /// EmitAnyExprToMem - Emits the code necessary to evaluate an
2043  /// arbitrary expression into the given memory location.
2044  void EmitAnyExprToMem(const Expr *E, Address Location,
2045  Qualifiers Quals, bool IsInitializer);
2046 
2047  void EmitAnyExprToExn(const Expr *E, Address Addr);
2048 
2049  /// EmitExprAsInit - Emits the code necessary to initialize a
2050  /// location in memory with the given initializer.
2051  void EmitExprAsInit(const Expr *init, const ValueDecl *D, LValue lvalue,
2052  bool capturedByInit);
2053 
2054  /// hasVolatileMember - returns true if aggregate type has a volatile
2055  /// member.
2057  if (const RecordType *RT = T->getAs<RecordType>()) {
2058  const RecordDecl *RD = cast<RecordDecl>(RT->getDecl());
2059  return RD->hasVolatileMember();
2060  }
2061  return false;
2062  }
2063  /// EmitAggregateCopy - Emit an aggregate assignment.
2064  ///
2065  /// The difference to EmitAggregateCopy is that tail padding is not copied.
2066  /// This is required for correctness when assigning non-POD structures in C++.
2067  void EmitAggregateAssign(Address DestPtr, Address SrcPtr,
2068  QualType EltTy) {
2069  bool IsVolatile = hasVolatileMember(EltTy);
2070  EmitAggregateCopy(DestPtr, SrcPtr, EltTy, IsVolatile, true);
2071  }
2072 
2073  void EmitAggregateCopyCtor(Address DestPtr, Address SrcPtr,
2074  QualType DestTy, QualType SrcTy) {
2075  EmitAggregateCopy(DestPtr, SrcPtr, SrcTy, /*IsVolatile=*/false,
2076  /*IsAssignment=*/false);
2077  }
2078 
2079  /// EmitAggregateCopy - Emit an aggregate copy.
2080  ///
2081  /// \param isVolatile - True iff either the source or the destination is
2082  /// volatile.
2083  /// \param isAssignment - If false, allow padding to be copied. This often
2084  /// yields more efficient.
2085  void EmitAggregateCopy(Address DestPtr, Address SrcPtr,
2086  QualType EltTy, bool isVolatile=false,
2087  bool isAssignment = false);
2088 
2089  /// GetAddrOfLocalVar - Return the address of a local variable.
2091  auto it = LocalDeclMap.find(VD);
2092  assert(it != LocalDeclMap.end() &&
2093  "Invalid argument to GetAddrOfLocalVar(), no decl!");
2094  return it->second;
2095  }
2096 
2097  /// getOpaqueLValueMapping - Given an opaque value expression (which
2098  /// must be mapped to an l-value), return its mapping.
2101 
2102  llvm::DenseMap<const OpaqueValueExpr*,LValue>::iterator
2103  it = OpaqueLValues.find(e);
2104  assert(it != OpaqueLValues.end() && "no mapping for opaque value!");
2105  return it->second;
2106  }
2107 
2108  /// getOpaqueRValueMapping - Given an opaque value expression (which
2109  /// must be mapped to an r-value), return its mapping.
2112 
2113  llvm::DenseMap<const OpaqueValueExpr*,RValue>::iterator
2114  it = OpaqueRValues.find(e);
2115  assert(it != OpaqueRValues.end() && "no mapping for opaque value!");
2116  return it->second;
2117  }
2118 
2119  /// Get the index of the current ArrayInitLoopExpr, if any.
2120  llvm::Value *getArrayInitIndex() { return ArrayInitIndex; }
2121 
2122  /// getAccessedFieldNo - Given an encoded value and a result number, return
2123  /// the input field number being accessed.
2124  static unsigned getAccessedFieldNo(unsigned Idx, const llvm::Constant *Elts);
2125 
2126  llvm::BlockAddress *GetAddrOfLabel(const LabelDecl *L);
2127  llvm::BasicBlock *GetIndirectGotoBlock();
2128 
2129  /// Check if \p E is a C++ "this" pointer wrapped in value-preserving casts.
2130  static bool IsWrappedCXXThis(const Expr *E);
2131 
2132  /// EmitNullInitialization - Generate code to set a value of the given type to
2133  /// null, If the type contains data member pointers, they will be initialized
2134  /// to -1 in accordance with the Itanium C++ ABI.
2135  void EmitNullInitialization(Address DestPtr, QualType Ty);
2136 
2137  /// Emits a call to an LLVM variable-argument intrinsic, either
2138  /// \c llvm.va_start or \c llvm.va_end.
2139  /// \param ArgValue A reference to the \c va_list as emitted by either
2140  /// \c EmitVAListRef or \c EmitMSVAListRef.
2141  /// \param IsStart If \c true, emits a call to \c llvm.va_start; otherwise,
2142  /// calls \c llvm.va_end.
2143  llvm::Value *EmitVAStartEnd(llvm::Value *ArgValue, bool IsStart);
2144 
2145  /// Generate code to get an argument from the passed in pointer
2146  /// and update it accordingly.
2147  /// \param VE The \c VAArgExpr for which to generate code.
2148  /// \param VAListAddr Receives a reference to the \c va_list as emitted by
2149  /// either \c EmitVAListRef or \c EmitMSVAListRef.
2150  /// \returns A pointer to the argument.
2151  // FIXME: We should be able to get rid of this method and use the va_arg
2152  // instruction in LLVM instead once it works well enough.
2153  Address EmitVAArg(VAArgExpr *VE, Address &VAListAddr);
2154 
2155  /// emitArrayLength - Compute the length of an array, even if it's a
2156  /// VLA, and drill down to the base element type.
2157  llvm::Value *emitArrayLength(const ArrayType *arrayType,
2158  QualType &baseType,
2159  Address &addr);
2160 
2161  /// EmitVLASize - Capture all the sizes for the VLA expressions in
2162  /// the given variably-modified type and store them in the VLASizeMap.
2163  ///
2164  /// This function can be called with a null (unreachable) insert point.
2166 
2167  /// getVLASize - Returns an LLVM value that corresponds to the size,
2168  /// in non-variably-sized elements, of a variable length array type,
2169  /// plus that largest non-variably-sized element type. Assumes that
2170  /// the type has already been emitted with EmitVariablyModifiedType.
2171  std::pair<llvm::Value*,QualType> getVLASize(const VariableArrayType *vla);
2172  std::pair<llvm::Value*,QualType> getVLASize(QualType vla);
2173 
2174  /// LoadCXXThis - Load the value of 'this'. This function is only valid while
2175  /// generating code for an C++ member function.
2177  assert(CXXThisValue && "no 'this' value for this function");
2178  return CXXThisValue;
2179  }
2181 
2182  /// LoadCXXVTT - Load the VTT parameter to base constructors/destructors have
2183  /// virtual bases.
2184  // FIXME: Every place that calls LoadCXXVTT is something
2185  // that needs to be abstracted properly.
2187  assert(CXXStructorImplicitParamValue && "no VTT value for this function");
2188  return CXXStructorImplicitParamValue;
2189  }
2190 
2191  /// GetAddressOfBaseOfCompleteClass - Convert the given pointer to a
2192  /// complete class to the given direct base.
2193  Address
2195  const CXXRecordDecl *Derived,
2196  const CXXRecordDecl *Base,
2197  bool BaseIsVirtual);
2198 
2199  static bool ShouldNullCheckClassCastValue(const CastExpr *Cast);
2200 
2201  /// GetAddressOfBaseClass - This function will add the necessary delta to the
2202  /// load of 'this' and returns address of the base class.
2204  const CXXRecordDecl *Derived,
2207  bool NullCheckValue, SourceLocation Loc);
2208 
2210  const CXXRecordDecl *Derived,
2213  bool NullCheckValue);
2214 
2215  /// GetVTTParameter - Return the VTT parameter that should be passed to a
2216  /// base constructor/destructor with virtual bases.
2217  /// FIXME: VTTs are Itanium ABI-specific, so the definition should move
2218  /// to ItaniumCXXABI.cpp together with all the references to VTT.
2219  llvm::Value *GetVTTParameter(GlobalDecl GD, bool ForVirtualBase,
2220  bool Delegating);
2221 
2223  CXXCtorType CtorType,
2224  const FunctionArgList &Args,
2225  SourceLocation Loc);
2226  // It's important not to confuse this and the previous function. Delegating
2227  // constructors are the C++0x feature. The constructor delegate optimization
2228  // is used to reduce duplication in the base and complete consturctors where
2229  // they are substantially the same.
2231  const FunctionArgList &Args);
2232 
2233  /// Emit a call to an inheriting constructor (that is, one that invokes a
2234  /// constructor inherited from a base class) by inlining its definition. This
2235  /// is necessary if the ABI does not support forwarding the arguments to the
2236  /// base class constructor (because they're variadic or similar).
2238  CXXCtorType CtorType,
2239  bool ForVirtualBase,
2240  bool Delegating,
2241  CallArgList &Args);
2242 
2243  /// Emit a call to a constructor inherited from a base class, passing the
2244  /// current constructor's arguments along unmodified (without even making
2245  /// a copy).
2247  bool ForVirtualBase, Address This,
2248  bool InheritedFromVBase,
2249  const CXXInheritedCtorInitExpr *E);
2250 
2252  bool ForVirtualBase, bool Delegating,
2253  Address This, const CXXConstructExpr *E);
2254 
2256  bool ForVirtualBase, bool Delegating,
2257  Address This, CallArgList &Args);
2258 
2259  /// Emit assumption load for all bases. Requires to be be called only on
2260  /// most-derived class and not under construction of the object.
2261  void EmitVTableAssumptionLoads(const CXXRecordDecl *ClassDecl, Address This);
2262 
2263  /// Emit assumption that vptr load == global vtable.
2264  void EmitVTableAssumptionLoad(const VPtr &vptr, Address This);
2265 
2267  Address This, Address Src,
2268  const CXXConstructExpr *E);
2269 
2271  const ArrayType *ArrayTy,
2272  Address ArrayPtr,
2273  const CXXConstructExpr *E,
2274  bool ZeroInitialization = false);
2275 
2277  llvm::Value *NumElements,
2278  Address ArrayPtr,
2279  const CXXConstructExpr *E,
2280  bool ZeroInitialization = false);
2281 
2283 
2285  bool ForVirtualBase, bool Delegating,
2286  Address This);
2287 
2288  void EmitNewArrayInitializer(const CXXNewExpr *E, QualType elementType,
2289  llvm::Type *ElementTy, Address NewPtr,
2290  llvm::Value *NumElements,
2291  llvm::Value *AllocSizeWithoutCookie);
2292 
2293  void EmitCXXTemporary(const CXXTemporary *Temporary, QualType TempType,
2294  Address Ptr);
2295 
2296  llvm::Value *EmitLifetimeStart(uint64_t Size, llvm::Value *Addr);
2297  void EmitLifetimeEnd(llvm::Value *Size, llvm::Value *Addr);
2298 
2300  void EmitCXXDeleteExpr(const CXXDeleteExpr *E);
2301 
2302  void EmitDeleteCall(const FunctionDecl *DeleteFD, llvm::Value *Ptr,
2303  QualType DeleteTy, llvm::Value *NumElements = nullptr,
2304  CharUnits CookieSize = CharUnits());
2305 
2307  const Expr *Arg, bool IsDelete);
2308 
2312 
2313  /// \brief Situations in which we might emit a check for the suitability of a
2314  /// pointer or glvalue.
2316  /// Checking the operand of a load. Must be suitably sized and aligned.
2318  /// Checking the destination of a store. Must be suitably sized and aligned.
2320  /// Checking the bound value in a reference binding. Must be suitably sized
2321  /// and aligned, but is not required to refer to an object (until the
2322  /// reference is used), per core issue 453.
2324  /// Checking the object expression in a non-static data member access. Must
2325  /// be an object within its lifetime.
2327  /// Checking the 'this' pointer for a call to a non-static member function.
2328  /// Must be an object within its lifetime.
2330  /// Checking the 'this' pointer for a constructor call.
2332  /// Checking the operand of a static_cast to a derived pointer type. Must be
2333  /// null or an object within its lifetime.
2335  /// Checking the operand of a static_cast to a derived reference type. Must
2336  /// be an object within its lifetime.
2338  /// Checking the operand of a cast to a base object. Must be suitably sized
2339  /// and aligned.
2341  /// Checking the operand of a cast to a virtual base object. Must be an
2342  /// object within its lifetime.
2344  /// Checking the value assigned to a _Nonnull pointer. Must not be null.
2346  };
2347 
2348  /// \brief Whether any type-checking sanitizers are enabled. If \c false,
2349  /// calls to EmitTypeCheck can be skipped.
2350  bool sanitizePerformTypeCheck() const;
2351 
2352  /// \brief Emit a check that \p V is the address of storage of the
2353  /// appropriate size and alignment for an object of type \p Type.
2355  QualType Type, CharUnits Alignment = CharUnits::Zero(),
2356  SanitizerSet SkippedChecks = SanitizerSet());
2357 
2358  /// \brief Emit a check that \p Base points into an array object, which
2359  /// we can access at index \p Index. \p Accessed should be \c false if we
2360  /// this expression is used as an lvalue, for instance in "&Arr[Idx]".
2361  void EmitBoundsCheck(const Expr *E, const Expr *Base, llvm::Value *Index,
2362  QualType IndexType, bool Accessed);
2363 
2365  bool isInc, bool isPre);
2367  bool isInc, bool isPre);
2368 
2369  void EmitAlignmentAssumption(llvm::Value *PtrValue, unsigned Alignment,
2370  llvm::Value *OffsetValue = nullptr) {
2371  Builder.CreateAlignmentAssumption(CGM.getDataLayout(), PtrValue, Alignment,
2372  OffsetValue);
2373  }
2374 
2375  /// Converts Location to a DebugLoc, if debug information is enabled.
2376  llvm::DebugLoc SourceLocToDebugLoc(SourceLocation Location);
2377 
2378 
2379  //===--------------------------------------------------------------------===//
2380  // Declaration Emission
2381  //===--------------------------------------------------------------------===//
2382 
2383  /// EmitDecl - Emit a declaration.
2384  ///
2385  /// This function can be called with a null (unreachable) insert point.
2386  void EmitDecl(const Decl &D);
2387 
2388  /// EmitVarDecl - Emit a local variable declaration.
2389  ///
2390  /// This function can be called with a null (unreachable) insert point.
2391  void EmitVarDecl(const VarDecl &D);
2392 
2393  void EmitScalarInit(const Expr *init, const ValueDecl *D, LValue lvalue,
2394  bool capturedByInit);
2395 
2396  typedef void SpecialInitFn(CodeGenFunction &Init, const VarDecl &D,
2397  llvm::Value *Address);
2398 
2399  /// \brief Determine whether the given initializer is trivial in the sense
2400  /// that it requires no code to be generated.
2401  bool isTrivialInitializer(const Expr *Init);
2402 
2403  /// EmitAutoVarDecl - Emit an auto variable declaration.
2404  ///
2405  /// This function can be called with a null (unreachable) insert point.
2406  void EmitAutoVarDecl(const VarDecl &D);
2407 
2409  friend class CodeGenFunction;
2410 
2411  const VarDecl *Variable;
2412 
2413  /// The address of the alloca. Invalid if the variable was emitted
2414  /// as a global constant.
2415  Address Addr;
2416 
2417  llvm::Value *NRVOFlag;
2418 
2419  /// True if the variable is a __block variable.
2420  bool IsByRef;
2421 
2422  /// True if the variable is of aggregate type and has a constant
2423  /// initializer.
2424  bool IsConstantAggregate;
2425 
2426  /// Non-null if we should use lifetime annotations.
2427  llvm::Value *SizeForLifetimeMarkers;
2428 
2429  struct Invalid {};
2430  AutoVarEmission(Invalid) : Variable(nullptr), Addr(Address::invalid()) {}
2431 
2432  AutoVarEmission(const VarDecl &variable)
2433  : Variable(&variable), Addr(Address::invalid()), NRVOFlag(nullptr),
2434  IsByRef(false), IsConstantAggregate(false),
2435  SizeForLifetimeMarkers(nullptr) {}
2436 
2437  bool wasEmittedAsGlobal() const { return !Addr.isValid(); }
2438 
2439  public:
2440  static AutoVarEmission invalid() { return AutoVarEmission(Invalid()); }
2441 
2442  bool useLifetimeMarkers() const {
2443  return SizeForLifetimeMarkers != nullptr;
2444  }
2446  assert(useLifetimeMarkers());
2447  return SizeForLifetimeMarkers;
2448  }
2449 
2450  /// Returns the raw, allocated address, which is not necessarily
2451  /// the address of the object itself.
2453  return Addr;
2454  }
2455 
2456  /// Returns the address of the object within this declaration.
2457  /// Note that this does not chase the forwarding pointer for
2458  /// __block decls.
2460  if (!IsByRef) return Addr;
2461 
2462  return CGF.emitBlockByrefAddress(Addr, Variable, /*forward*/ false);
2463  }
2464  };
2465  AutoVarEmission EmitAutoVarAlloca(const VarDecl &var);
2466  void EmitAutoVarInit(const AutoVarEmission &emission);
2467  void EmitAutoVarCleanups(const AutoVarEmission &emission);
2468  void emitAutoVarTypeCleanup(const AutoVarEmission &emission,
2469  QualType::DestructionKind dtorKind);
2470 
2471  void EmitStaticVarDecl(const VarDecl &D,
2472  llvm::GlobalValue::LinkageTypes Linkage);
2473 
2474  class ParamValue {
2475  llvm::Value *Value;
2476  unsigned Alignment;
2477  ParamValue(llvm::Value *V, unsigned A) : Value(V), Alignment(A) {}
2478  public:
2480  return ParamValue(value, 0);
2481  }
2483  assert(!addr.getAlignment().isZero());
2484  return ParamValue(addr.getPointer(), addr.getAlignment().getQuantity());
2485  }
2486 
2487  bool isIndirect() const { return Alignment != 0; }
2488  llvm::Value *getAnyValue() const { return Value; }
2489 
2491  assert(!isIndirect());
2492  return Value;
2493  }
2494 
2496  assert(isIndirect());
2497  return Address(Value, CharUnits::fromQuantity(Alignment));
2498  }
2499  };
2500 
2501  /// EmitParmDecl - Emit a ParmVarDecl or an ImplicitParamDecl.
2502  void EmitParmDecl(const VarDecl &D, ParamValue Arg, unsigned ArgNo);
2503 
2504  /// protectFromPeepholes - Protect a value that we're intending to
2505  /// store to the side, but which will probably be used later, from
2506  /// aggressive peepholing optimizations that might delete it.
2507  ///
2508  /// Pass the result to unprotectFromPeepholes to declare that
2509  /// protection is no longer required.
2510  ///
2511  /// There's no particular reason why this shouldn't apply to
2512  /// l-values, it's just that no existing peepholes work on pointers.
2513  PeepholeProtection protectFromPeepholes(RValue rvalue);
2514  void unprotectFromPeepholes(PeepholeProtection protection);
2515 
2517  llvm::Value *OffsetValue = nullptr) {
2518  Builder.CreateAlignmentAssumption(CGM.getDataLayout(), PtrValue, Alignment,
2519  OffsetValue);
2520  }
2521 
2522  //===--------------------------------------------------------------------===//
2523  // Statement Emission
2524  //===--------------------------------------------------------------------===//
2525 
2526  /// EmitStopPoint - Emit a debug stoppoint if we are emitting debug info.
2527  void EmitStopPoint(const Stmt *S);
2528 
2529  /// EmitStmt - Emit the code for the statement \arg S. It is legal to call
2530  /// this function even if there is no current insertion point.
2531  ///
2532  /// This function may clear the current insertion point; callers should use
2533  /// EnsureInsertPoint if they wish to subsequently generate code without first
2534  /// calling EmitBlock, EmitBranch, or EmitStmt.
2535  void EmitStmt(const Stmt *S);
2536 
2537  /// EmitSimpleStmt - Try to emit a "simple" statement which does not
2538  /// necessarily require an insertion point or debug information; typically
2539  /// because the statement amounts to a jump or a container of other
2540  /// statements.
2541  ///
2542  /// \return True if the statement was handled.
2543  bool EmitSimpleStmt(const Stmt *S);
2544 
2545  Address EmitCompoundStmt(const CompoundStmt &S, bool GetLast = false,
2548  bool GetLast = false,
2549  AggValueSlot AVS =
2551 
2552  /// EmitLabel - Emit the block for the given label. It is legal to call this
2553  /// function even if there is no current insertion point.
2554  void EmitLabel(const LabelDecl *D); // helper for EmitLabelStmt.
2555 
2556  void EmitLabelStmt(const LabelStmt &S);
2557  void EmitAttributedStmt(const AttributedStmt &S);
2558  void EmitGotoStmt(const GotoStmt &S);
2559  void EmitIndirectGotoStmt(const IndirectGotoStmt &S);
2560  void EmitIfStmt(const IfStmt &S);
2561 
2562  void EmitWhileStmt(const WhileStmt &S,
2563  ArrayRef<const Attr *> Attrs = None);
2564  void EmitDoStmt(const DoStmt &S, ArrayRef<const Attr *> Attrs = None);
2565  void EmitForStmt(const ForStmt &S,
2566  ArrayRef<const Attr *> Attrs = None);
2567  void EmitReturnStmt(const ReturnStmt &S);
2568  void EmitDeclStmt(const DeclStmt &S);
2569  void EmitBreakStmt(const BreakStmt &S);
2570  void EmitContinueStmt(const ContinueStmt &S);
2571  void EmitSwitchStmt(const SwitchStmt &S);
2572  void EmitDefaultStmt(const DefaultStmt &S);
2573  void EmitCaseStmt(const CaseStmt &S);
2574  void EmitCaseStmtRange(const CaseStmt &S);
2575  void EmitAsmStmt(const AsmStmt &S);
2576 
2578  void EmitObjCAtTryStmt(const ObjCAtTryStmt &S);
2579  void EmitObjCAtThrowStmt(const ObjCAtThrowStmt &S);
2582 
2583  void EmitCoroutineBody(const CoroutineBodyStmt &S);
2584  void EmitCoreturnStmt(const CoreturnStmt &S);
2586  AggValueSlot aggSlot = AggValueSlot::ignored(),
2587  bool ignoreResult = false);
2590  AggValueSlot aggSlot = AggValueSlot::ignored(),
2591  bool ignoreResult = false);
2593  RValue EmitCoroutineIntrinsic(const CallExpr *E, unsigned int IID);
2594 
2595  void EnterCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock = false);
2596  void ExitCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock = false);
2597 
2598  void EmitCXXTryStmt(const CXXTryStmt &S);
2599  void EmitSEHTryStmt(const SEHTryStmt &S);
2600  void EmitSEHLeaveStmt(const SEHLeaveStmt &S);
2601  void EnterSEHTryStmt(const SEHTryStmt &S);
2602  void ExitSEHTryStmt(const SEHTryStmt &S);
2603 
2604  void startOutlinedSEHHelper(CodeGenFunction &ParentCGF, bool IsFilter,
2605  const Stmt *OutlinedStmt);
2606 
2607  llvm::Function *GenerateSEHFilterFunction(CodeGenFunction &ParentCGF,
2608  const SEHExceptStmt &Except);
2609 
2610  llvm::Function *GenerateSEHFinallyFunction(CodeGenFunction &ParentCGF,
2611  const SEHFinallyStmt &Finally);
2612 
2613  void EmitSEHExceptionCodeSave(CodeGenFunction &ParentCGF,
2614  llvm::Value *ParentFP,
2615  llvm::Value *EntryEBP);
2619 
2620  /// Scan the outlined statement for captures from the parent function. For
2621  /// each capture, mark the capture as escaped and emit a call to
2622  /// llvm.localrecover. Insert the localrecover result into the LocalDeclMap.
2623  void EmitCapturedLocals(CodeGenFunction &ParentCGF, const Stmt *OutlinedStmt,
2624  bool IsFilter);
2625 
2626  /// Recovers the address of a local in a parent function. ParentVar is the
2627  /// address of the variable used in the immediate parent function. It can
2628  /// either be an alloca or a call to llvm.localrecover if there are nested
2629  /// outlined functions. ParentFP is the frame pointer of the outermost parent
2630  /// frame.
2632  Address ParentVar,
2633  llvm::Value *ParentFP);
2634 
2635  void EmitCXXForRangeStmt(const CXXForRangeStmt &S,
2636  ArrayRef<const Attr *> Attrs = None);
2637 
2638  /// Returns calculated size of the specified type.
2641  llvm::Function *EmitCapturedStmt(const CapturedStmt &S, CapturedRegionKind K);
2642  llvm::Function *GenerateCapturedStmtFunction(const CapturedStmt &S);
2644  llvm::Function *GenerateOpenMPCapturedStmtFunction(const CapturedStmt &S);
2646  SmallVectorImpl<llvm::Value *> &CapturedVars);
2647  void emitOMPSimpleStore(LValue LVal, RValue RVal, QualType RValTy,
2648  SourceLocation Loc);
2649  /// \brief Perform element by element copying of arrays with type \a
2650  /// OriginalType from \a SrcAddr to \a DestAddr using copying procedure
2651  /// generated by \a CopyGen.
2652  ///
2653  /// \param DestAddr Address of the destination array.
2654  /// \param SrcAddr Address of the source array.
2655  /// \param OriginalType Type of destination and source arrays.
2656  /// \param CopyGen Copying procedure that copies value of single array element
2657  /// to another single array element.
2659  Address DestAddr, Address SrcAddr, QualType OriginalType,
2660  const llvm::function_ref<void(Address, Address)> &CopyGen);
2661  /// \brief Emit proper copying of data from one variable to another.
2662  ///
2663  /// \param OriginalType Original type of the copied variables.
2664  /// \param DestAddr Destination address.
2665  /// \param SrcAddr Source address.
2666  /// \param DestVD Destination variable used in \a CopyExpr (for arrays, has
2667  /// type of the base array element).
2668  /// \param SrcVD Source variable used in \a CopyExpr (for arrays, has type of
2669  /// the base array element).
2670  /// \param Copy Actual copygin expression for copying data from \a SrcVD to \a
2671  /// DestVD.
2672  void EmitOMPCopy(QualType OriginalType,
2673  Address DestAddr, Address SrcAddr,
2674  const VarDecl *DestVD, const VarDecl *SrcVD,
2675  const Expr *Copy);
2676  /// \brief Emit atomic update code for constructs: \a X = \a X \a BO \a E or
2677  /// \a X = \a E \a BO \a E.
2678  ///
2679  /// \param X Value to be updated.
2680  /// \param E Update value.
2681  /// \param BO Binary operation for update operation.
2682  /// \param IsXLHSInRHSPart true if \a X is LHS in RHS part of the update
2683  /// expression, false otherwise.
2684  /// \param AO Atomic ordering of the generated atomic instructions.
2685  /// \param CommonGen Code generator for complex expressions that cannot be
2686  /// expressed through atomicrmw instruction.
2687  /// \returns <true, OldAtomicValue> if simple 'atomicrmw' instruction was
2688  /// generated, <false, RValue::get(nullptr)> otherwise.
2689  std::pair<bool, RValue> EmitOMPAtomicSimpleUpdateExpr(
2690  LValue X, RValue E, BinaryOperatorKind BO, bool IsXLHSInRHSPart,
2691  llvm::AtomicOrdering AO, SourceLocation Loc,
2692  const llvm::function_ref<RValue(RValue)> &CommonGen);
2694  OMPPrivateScope &PrivateScope);
2696  OMPPrivateScope &PrivateScope);
2698  const OMPClause &C, OMPPrivateScope &PrivateScope,
2699  const llvm::DenseMap<const ValueDecl *, Address> &CaptureDeviceAddrMap);
2700  /// \brief Emit code for copyin clause in \a D directive. The next code is
2701  /// generated at the start of outlined functions for directives:
2702  /// \code
2703  /// threadprivate_var1 = master_threadprivate_var1;
2704  /// operator=(threadprivate_var2, master_threadprivate_var2);
2705  /// ...
2706  /// __kmpc_barrier(&loc, global_tid);
2707  /// \endcode
2708  ///
2709  /// \param D OpenMP directive possibly with 'copyin' clause(s).
2710  /// \returns true if at least one copyin variable is found, false otherwise.
2712  /// \brief Emit initial code for lastprivate variables. If some variable is
2713  /// not also firstprivate, then the default initialization is used. Otherwise
2714  /// initialization of this variable is performed by EmitOMPFirstprivateClause
2715  /// method.
2716  ///
2717  /// \param D Directive that may have 'lastprivate' directives.
2718  /// \param PrivateScope Private scope for capturing lastprivate variables for
2719  /// proper codegen in internal captured statement.
2720  ///
2721  /// \returns true if there is at least one lastprivate variable, false
2722  /// otherwise.
2724  OMPPrivateScope &PrivateScope);
2725  /// \brief Emit final copying of lastprivate values to original variables at
2726  /// the end of the worksharing or simd directive.
2727  ///
2728  /// \param D Directive that has at least one 'lastprivate' directives.
2729  /// \param IsLastIterCond Boolean condition that must be set to 'i1 true' if
2730  /// it is the last iteration of the loop code in associated directive, or to
2731  /// 'i1 false' otherwise. If this item is nullptr, no final check is required.
2733  bool NoFinals,
2734  llvm::Value *IsLastIterCond = nullptr);
2735  /// Emit initial code for linear clauses.
2736  void EmitOMPLinearClause(const OMPLoopDirective &D,
2737  CodeGenFunction::OMPPrivateScope &PrivateScope);
2738  /// Emit final code for linear clauses.
2739  /// \param CondGen Optional conditional code for final part of codegen for
2740  /// linear clause.
2742  const OMPLoopDirective &D,
2743  const llvm::function_ref<llvm::Value *(CodeGenFunction &)> &CondGen);
2744  /// \brief Emit initial code for reduction variables. Creates reduction copies
2745  /// and initializes them with the values according to OpenMP standard.
2746  ///
2747  /// \param D Directive (possibly) with the 'reduction' clause.
2748  /// \param PrivateScope Private scope for capturing reduction variables for
2749  /// proper codegen in internal captured statement.
2750  ///
2752  OMPPrivateScope &PrivateScope);
2753  /// \brief Emit final update of reduction values to original variables at
2754  /// the end of the directive.
2755  ///
2756  /// \param D Directive that has at least one 'reduction' directives.
2757  /// \param ReductionKind The kind of reduction to perform.
2759  const OpenMPDirectiveKind ReductionKind);
2760  /// \brief Emit initial code for linear variables. Creates private copies
2761  /// and initializes them with the values according to OpenMP standard.
2762  ///
2763  /// \param D Directive (possibly) with the 'linear' clause.
2765 
2766  typedef const llvm::function_ref<void(CodeGenFunction & /*CGF*/,
2767  llvm::Value * /*OutlinedFn*/,
2768  const OMPTaskDataTy & /*Data*/)>
2771  const RegionCodeGenTy &BodyGen,
2772  const TaskGenTy &TaskGen, OMPTaskDataTy &Data);
2773 
2775  void EmitOMPSimdDirective(const OMPSimdDirective &S);
2776  void EmitOMPForDirective(const OMPForDirective &S);
2786  void EmitOMPTaskDirective(const OMPTaskDirective &S);
2800  void
2803  void
2819  void
2834 
2835  /// Emit device code for the target directive.
2837  StringRef ParentName,
2838  const OMPTargetDirective &S);
2839  static void
2840  EmitOMPTargetParallelDeviceFunction(CodeGenModule &CGM, StringRef ParentName,
2841  const OMPTargetParallelDirective &S);
2842  static void
2843  EmitOMPTargetTeamsDeviceFunction(CodeGenModule &CGM, StringRef ParentName,
2844  const OMPTargetTeamsDirective &S);
2845  /// \brief Emit inner loop of the worksharing/simd construct.
2846  ///
2847  /// \param S Directive, for which the inner loop must be emitted.
2848  /// \param RequiresCleanup true, if directive has some associated private
2849  /// variables.
2850  /// \param LoopCond Bollean condition for loop continuation.
2851  /// \param IncExpr Increment expression for loop control variable.
2852  /// \param BodyGen Generator for the inner body of the inner loop.
2853  /// \param PostIncGen Genrator for post-increment code (required for ordered
2854  /// loop directvies).
2855  void EmitOMPInnerLoop(
2856  const Stmt &S, bool RequiresCleanup, const Expr *LoopCond,
2857  const Expr *IncExpr,
2858  const llvm::function_ref<void(CodeGenFunction &)> &BodyGen,
2859  const llvm::function_ref<void(CodeGenFunction &)> &PostIncGen);
2860 
2862  /// Emit initial code for loop counters of loop-based directives.
2864  OMPPrivateScope &LoopScope);
2865 
2866  /// Helper for the OpenMP loop directives.
2867  void EmitOMPLoopBody(const OMPLoopDirective &D, JumpDest LoopExit);
2868 
2869  /// \brief Emit code for the worksharing loop-based directive.
2870  /// \return true, if this construct has any lastprivate clause, false -
2871  /// otherwise.
2872  bool EmitOMPWorksharingLoop(const OMPLoopDirective &S, Expr *EUB,
2873  const CodeGenLoopBoundsTy &CodeGenLoopBounds,
2874  const CodeGenDispatchBoundsTy &CGDispatchBounds);
2875 
2876 private:
2877  /// Helpers for blocks
2879 
2880  /// Helpers for the OpenMP loop directives.
2881  void EmitOMPSimdInit(const OMPLoopDirective &D, bool IsMonotonic = false);
2882  void EmitOMPSimdFinal(
2883  const OMPLoopDirective &D,
2884  const llvm::function_ref<llvm::Value *(CodeGenFunction &)> &CondGen);
2885 
2886  void EmitOMPDistributeLoop(const OMPLoopDirective &S,
2887  const CodeGenLoopTy &CodeGenLoop, Expr *IncExpr);
2888 
2889  /// struct with the values to be passed to the OpenMP loop-related functions
2890  struct OMPLoopArguments {
2891  /// loop lower bound
2892  Address LB = Address::invalid();
2893  /// loop upper bound
2894  Address UB = Address::invalid();
2895  /// loop stride
2896  Address ST = Address::invalid();
2897  /// isLastIteration argument for runtime functions
2898  Address IL = Address::invalid();
2899  /// Chunk value generated by sema
2900  llvm::Value *Chunk = nullptr;
2901  /// EnsureUpperBound
2902  Expr *EUB = nullptr;
2903  /// IncrementExpression
2904  Expr *IncExpr = nullptr;
2905  /// Loop initialization
2906  Expr *Init = nullptr;
2907  /// Loop exit condition
2908  Expr *Cond = nullptr;
2909  /// Update of LB after a whole chunk has been executed
2910  Expr *NextLB = nullptr;
2911  /// Update of UB after a whole chunk has been executed
2912  Expr *NextUB = nullptr;
2913  OMPLoopArguments() = default;
2914  OMPLoopArguments(Address LB, Address UB, Address ST, Address IL,
2915  llvm::Value *Chunk = nullptr, Expr *EUB = nullptr,
2916  Expr *IncExpr = nullptr, Expr *Init = nullptr,
2917  Expr *Cond = nullptr, Expr *NextLB = nullptr,
2918  Expr *NextUB = nullptr)
2919  : LB(LB), UB(UB), ST(ST), IL(IL), Chunk(Chunk), EUB(EUB),
2920  IncExpr(IncExpr), Init(Init), Cond(Cond), NextLB(NextLB),
2921  NextUB(NextUB) {}
2922  };
2923  void EmitOMPOuterLoop(bool DynamicOrOrdered, bool IsMonotonic,
2924  const OMPLoopDirective &S, OMPPrivateScope &LoopScope,
2925  const OMPLoopArguments &LoopArgs,
2926  const CodeGenLoopTy &CodeGenLoop,
2927  const CodeGenOrderedTy &CodeGenOrdered);
2928  void EmitOMPForOuterLoop(const OpenMPScheduleTy &ScheduleKind,
2929  bool IsMonotonic, const OMPLoopDirective &S,
2930  OMPPrivateScope &LoopScope, bool Ordered,
2931  const OMPLoopArguments &LoopArgs,
2932  const CodeGenDispatchBoundsTy &CGDispatchBounds);
2933  void EmitOMPDistributeOuterLoop(OpenMPDistScheduleClauseKind ScheduleKind,
2934  const OMPLoopDirective &S,
2935  OMPPrivateScope &LoopScope,
2936  const OMPLoopArguments &LoopArgs,
2937  const CodeGenLoopTy &CodeGenLoopContent);
2938  /// \brief Emit code for sections directive.
2939  void EmitSections(const OMPExecutableDirective &S);
2940 
2941 public:
2942 
2943  //===--------------------------------------------------------------------===//
2944  // LValue Expression Emission
2945  //===--------------------------------------------------------------------===//
2946 
2947  /// GetUndefRValue - Get an appropriate 'undef' rvalue for the given type.
2948  RValue GetUndefRValue(QualType Ty);
2949 
2950  /// EmitUnsupportedRValue - Emit a dummy r-value using the type of E
2951  /// and issue an ErrorUnsupported style diagnostic (using the
2952  /// provided Name).
2953  RValue EmitUnsupportedRValue(const Expr *E,
2954  const char *Name);
2955 
2956  /// EmitUnsupportedLValue - Emit a dummy l-value using the type of E and issue
2957  /// an ErrorUnsupported style diagnostic (using the provided Name).
2958  LValue EmitUnsupportedLValue(const Expr *E,
2959  const char *Name);
2960 
2961  /// EmitLValue - Emit code to compute a designator that specifies the location
2962  /// of the expression.
2963  ///
2964  /// This can return one of two things: a simple address or a bitfield
2965  /// reference. In either case, the LLVM Value* in the LValue structure is
2966  /// guaranteed to be an LLVM pointer type.
2967  ///
2968  /// If this returns a bitfield reference, nothing about the pointee type of
2969  /// the LLVM value is known: For example, it may not be a pointer to an
2970  /// integer.
2971  ///
2972  /// If this returns a normal address, and if the lvalue's C type is fixed
2973  /// size, this method guarantees that the returned pointer type will point to
2974  /// an LLVM type of the same size of the lvalue's type. If the lvalue has a
2975  /// variable length type, this is not possible.
2976  ///
2977  LValue EmitLValue(const Expr *E);
2978 
2979  /// \brief Same as EmitLValue but additionally we generate checking code to
2980  /// guard against undefined behavior. This is only suitable when we know
2981  /// that the address will be used to access the object.
2982  LValue EmitCheckedLValue(const Expr *E, TypeCheckKind TCK);
2983 
2984  RValue convertTempToRValue(Address addr, QualType type,
2985  SourceLocation Loc);
2986 
2987  void EmitAtomicInit(Expr *E, LValue lvalue);
2988 
2989  bool LValueIsSuitableForInlineAtomic(LValue Src);
2990 
2991  RValue EmitAtomicLoad(LValue LV, SourceLocation SL,
2992  AggValueSlot Slot = AggValueSlot::ignored());
2993 
2994  RValue EmitAtomicLoad(LValue lvalue, SourceLocation loc,
2995  llvm::AtomicOrdering AO, bool IsVolatile = false,
2996  AggValueSlot slot = AggValueSlot::ignored());
2997 
2998  void EmitAtomicStore(RValue rvalue, LValue lvalue, bool isInit);
2999 
3000  void EmitAtomicStore(RValue rvalue, LValue lvalue, llvm::AtomicOrdering AO,
3001  bool IsVolatile, bool isInit);
3002 
3003  std::pair<RValue, llvm::Value *> EmitAtomicCompareExchange(
3004  LValue Obj, RValue Expected, RValue Desired, SourceLocation Loc,
3005  llvm::AtomicOrdering Success =
3006  llvm::AtomicOrdering::SequentiallyConsistent,
3007  llvm::AtomicOrdering Failure =
3008  llvm::AtomicOrdering::SequentiallyConsistent,
3009  bool IsWeak = false, AggValueSlot Slot = AggValueSlot::ignored());
3010 
3011  void EmitAtomicUpdate(LValue LVal, llvm::AtomicOrdering AO,
3012  const llvm::function_ref<RValue(RValue)> &UpdateOp,
3013  bool IsVolatile);
3014 
3015  /// EmitToMemory - Change a scalar value from its value
3016  /// representation to its in-memory representation.
3018 
3019  /// EmitFromMemory - Change a scalar value from its memory
3020  /// representation to its value representation.
3022 
3023  /// Check if the scalar \p Value is within the valid range for the given
3024  /// type \p Ty.
3025  ///
3026  /// Returns true if a check is needed (even if the range is unknown).
3028  SourceLocation Loc);
3029 
3030  /// EmitLoadOfScalar - Load a scalar value from an address, taking
3031  /// care to appropriately convert from the memory representation to
3032  /// the LLVM value representation.
3033  llvm::Value *EmitLoadOfScalar(Address Addr, bool Volatile, QualType Ty,
3034  SourceLocation Loc,
3035  LValueBaseInfo BaseInfo =
3036  LValueBaseInfo(AlignmentSource::Type),
3037  llvm::MDNode *TBAAInfo = nullptr,
3038  QualType TBAABaseTy = QualType(),
3039  uint64_t TBAAOffset = 0,
3040  bool isNontemporal = false);
3041 
3042  /// EmitLoadOfScalar - Load a scalar value from an address, taking
3043  /// care to appropriately convert from the memory representation to
3044  /// the LLVM value representation. The l-value must be a simple
3045  /// l-value.
3046  llvm::Value *EmitLoadOfScalar(LValue lvalue, SourceLocation Loc);
3047 
3048  /// EmitStoreOfScalar - Store a scalar value to an address, taking
3049  /// care to appropriately convert from the memory representation to
3050  /// the LLVM value representation.
3051  void EmitStoreOfScalar(llvm::Value *Value, Address Addr,
3052  bool Volatile, QualType Ty,
3053  LValueBaseInfo BaseInfo =
3054  LValueBaseInfo(AlignmentSource::Type),
3055  llvm::MDNode *TBAAInfo = nullptr, bool isInit = false,
3056  QualType TBAABaseTy = QualType(),
3057  uint64_t TBAAOffset = 0, bool isNontemporal = false);
3058 
3059  /// EmitStoreOfScalar - Store a scalar value to an address, taking
3060  /// care to appropriately convert from the memory representation to
3061  /// the LLVM value representation. The l-value must be a simple
3062  /// l-value. The isInit flag indicates whether this is an initialization.
3063  /// If so, atomic qualifiers are ignored and the store is always non-atomic.
3064  void EmitStoreOfScalar(llvm::Value *value, LValue lvalue, bool isInit=false);
3065 
3066  /// EmitLoadOfLValue - Given an expression that represents a value lvalue,
3067  /// this method emits the address of the lvalue, then loads the result as an
3068  /// rvalue, returning the rvalue.
3069  RValue EmitLoadOfLValue(LValue V, SourceLocation Loc);
3070  RValue EmitLoadOfExtVectorElementLValue(LValue V);
3071  RValue EmitLoadOfBitfieldLValue(LValue LV, SourceLocation Loc);
3072  RValue EmitLoadOfGlobalRegLValue(LValue LV);
3073 
3074  /// EmitStoreThroughLValue - Store the specified rvalue into the specified
3075  /// lvalue, where both are guaranteed to the have the same type, and that type
3076  /// is 'Ty'.
3077  void EmitStoreThroughLValue(RValue Src, LValue Dst, bool isInit = false);
3078  void EmitStoreThroughExtVectorComponentLValue(RValue Src, LValue Dst);
3079  void EmitStoreThroughGlobalRegLValue(RValue Src, LValue Dst);
3080 
3081  /// EmitStoreThroughBitfieldLValue - Store Src into Dst with same constraints
3082  /// as EmitStoreThroughLValue.
3083  ///
3084  /// \param Result [out] - If non-null, this will be set to a Value* for the
3085  /// bit-field contents after the store, appropriate for use as the result of
3086  /// an assignment to the bit-field.
3087  void EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst,
3088  llvm::Value **Result=nullptr);
3089 
3090  /// Emit an l-value for an assignment (simple or compound) of complex type.
3094  llvm::Value *&Result);
3095 
3096  // Note: only available for agg return types
3097  LValue EmitBinaryOperatorLValue(const BinaryOperator *E);
3099  // Note: only available for agg return types
3100  LValue EmitCallExprLValue(const CallExpr *E);
3101  // Note: only available for agg return types
3102  LValue EmitVAArgExprLValue(const VAArgExpr *E);
3103  LValue EmitDeclRefLValue(const DeclRefExpr *E);
3104  LValue EmitStringLiteralLValue(const StringLiteral *E);
3105  LValue EmitObjCEncodeExprLValue(const ObjCEncodeExpr *E);
3106  LValue EmitPredefinedLValue(const PredefinedExpr *E);
3107  LValue EmitUnaryOpLValue(const UnaryOperator *E);
3109  bool Accessed = false);
3111  bool IsLowerBound = true);
3113  LValue EmitMemberExpr(const MemberExpr *E);
3114  LValue EmitObjCIsaExpr(const ObjCIsaExpr *E);
3116  LValue EmitInitListLValue(const InitListExpr *E);
3118  LValue EmitCastLValue(const CastExpr *E);
3120  LValue EmitOpaqueValueLValue(const OpaqueValueExpr *e);
3121 
3122  Address EmitExtVectorElementLValue(LValue V);
3123 
3124  RValue EmitRValueForField(LValue LV, const FieldDecl *FD, SourceLocation Loc);
3125 
3126  Address EmitArrayToPointerDecay(const Expr *Array,
3127  LValueBaseInfo *BaseInfo = nullptr);
3128 
3130  llvm::PointerIntPair<llvm::Constant*, 1, bool> ValueAndIsReference;
3131  ConstantEmission(llvm::Constant *C, bool isReference)
3132  : ValueAndIsReference(C, isReference) {}
3133  public:
3135  static ConstantEmission forReference(llvm::Constant *C) {
3136  return ConstantEmission(C, true);
3137  }
3138  static ConstantEmission forValue(llvm::Constant *C) {
3139  return ConstantEmission(C, false);
3140  }
3141 
3142  explicit operator bool() const {
3143  return ValueAndIsReference.getOpaqueValue() != nullptr;
3144  }
3145 
3146  bool isReference() const { return ValueAndIsReference.getInt(); }
3148  assert(isReference());
3149  return CGF.MakeNaturalAlignAddrLValue(ValueAndIsReference.getPointer(),
3150  refExpr->getType());
3151  }
3152 
3153  llvm::Constant *getValue() const {
3154  assert(!isReference());
3155  return ValueAndIsReference.getPointer();
3156  }
3157  };
3158 
3159  ConstantEmission tryEmitAsConstant(DeclRefExpr *refExpr);
3160 
3164 
3165  llvm::Value *EmitIvarOffset(const ObjCInterfaceDecl *Interface,
3166  const ObjCIvarDecl *Ivar);
3169 
3170  /// EmitLValueForFieldInitialization - Like EmitLValueForField, except that
3171  /// if the Field is a reference, this will return the address of the reference
3172  /// and not the address of the value stored in the reference.
3174  const FieldDecl* Field);
3175 
3177  llvm::Value* Base, const ObjCIvarDecl *Ivar,
3178  unsigned CVRQualifiers);
3179 
3185 
3191  void EmitDeclRefExprDbgValue(const DeclRefExpr *E, const APValue &Init);
3192 
3193  //===--------------------------------------------------------------------===//
3194  // Scalar Expression Emission
3195  //===--------------------------------------------------------------------===//
3196 
3197  /// EmitCall - Generate a call of the given function, expecting the given
3198  /// result type, and using the given argument list which specifies both the
3199  /// LLVM arguments and the types they were derived from.
3200  RValue EmitCall(const CGFunctionInfo &CallInfo, const CGCallee &Callee,
3202  llvm::Instruction **callOrInvoke = nullptr);
3203 
3204  RValue EmitCall(QualType FnType, const CGCallee &Callee, const CallExpr *E,
3206  llvm::Value *Chain = nullptr);
3207  RValue EmitCallExpr(const CallExpr *E,
3210  CGCallee EmitCallee(const Expr *E);
3211 
3212  void checkTargetFeatures(const CallExpr *E, const FunctionDecl *TargetDecl);
3213 
3214  llvm::CallInst *EmitRuntimeCall(llvm::Value *callee,
3215  const Twine &name = "");
3216  llvm::CallInst *EmitRuntimeCall(llvm::Value *callee,
3218  const Twine &name = "");
3219  llvm::CallInst *EmitNounwindRuntimeCall(llvm::Value *callee,
3220  const Twine &name = "");
3221  llvm::CallInst *EmitNounwindRuntimeCall(llvm::Value *callee,
3223  const Twine &name = "");
3224 
3225  llvm::CallSite EmitCallOrInvoke(llvm::Value *Callee,
3227  const Twine &Name = "");
3228  llvm::CallSite EmitRuntimeCallOrInvoke(llvm::Value *callee,
3230  const Twine &name = "");
3231  llvm::CallSite EmitRuntimeCallOrInvoke(llvm::Value *callee,
3232  const Twine &name = "");
3234  ArrayRef<llvm::Value*> args);
3235 
3237  NestedNameSpecifier *Qual,
3238  llvm::Type *Ty);
3239 
3241  CXXDtorType Type,
3242  const CXXRecordDecl *RD);
3243 
3244  RValue
3246  const CGCallee &Callee,
3248  llvm::Value *ImplicitParam,
3249  QualType ImplicitParamTy, const CallExpr *E,
3250  CallArgList *RtlArgs);
3252  const CGCallee &Callee,
3253  llvm::Value *This, llvm::Value *ImplicitParam,
3254  QualType ImplicitParamTy, const CallExpr *E,
3255  StructorType Type);
3259  const CXXMethodDecl *MD,
3261  bool HasQualifier,
3262  NestedNameSpecifier *Qualifier,
3263  bool IsArrow, const Expr *Base);
3264  // Compute the object pointer.
3266  llvm::Value *memberPtr,
3267  const MemberPointerType *memberPtrType,
3268  LValueBaseInfo *BaseInfo = nullptr);
3271 
3273  const CXXMethodDecl *MD,
3276 
3279 
3282 
3284  unsigned BuiltinID, const CallExpr *E,
3286 
3288 
3289  /// EmitTargetBuiltinExpr - Emit the given builtin call. Returns 0 if the call
3290  /// is unhandled by the current target.
3291  llvm::Value *EmitTargetBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
3292 
3294  const llvm::CmpInst::Predicate Fp,
3295  const llvm::CmpInst::Predicate Ip,
3296  const llvm::Twine &Name = "");
3297  llvm::Value *EmitARMBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
3298 
3299  llvm::Value *EmitCommonNeonBuiltinExpr(unsigned BuiltinID,
3300  unsigned LLVMIntrinsic,
3301  unsigned AltLLVMIntrinsic,
3302  const char *NameHint,
3303  unsigned Modifier,
3304  const CallExpr *E,
3306  Address PtrOp0, Address PtrOp1);
3307  llvm::Function *LookupNeonLLVMIntrinsic(unsigned IntrinsicID,
3308  unsigned Modifier, llvm::Type *ArgTy,
3309  const CallExpr *E);
3310  llvm::Value *EmitNeonCall(llvm::Function *F,
3312  const char *name,
3313  unsigned shift = 0, bool rightshift = false);
3314  llvm::Value *EmitNeonSplat(llvm::Value *V, llvm::Constant *Idx);
3316  bool negateForRightShift);
3318  llvm::Type *Ty, bool usgn, const char *name);
3320  llvm::Value *EmitAArch64BuiltinExpr(unsigned BuiltinID, const CallExpr *E);
3321 
3323  llvm::Value *EmitX86BuiltinExpr(unsigned BuiltinID, const CallExpr *E);
3324  llvm::Value *EmitPPCBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
3325  llvm::Value *EmitAMDGPUBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
3326  llvm::Value *EmitSystemZBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
3327  llvm::Value *EmitNVPTXBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
3328  llvm::Value *EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
3329  const CallExpr *E);
3330 
3331 private:
3332  enum class MSVCIntrin;
3333 
3334 public:
3335  llvm::Value *EmitMSVCBuiltinExpr(MSVCIntrin BuiltinID, const CallExpr *E);
3336 
3338 
3345  const ObjCMethodDecl *MethodWithObjects);
3348  ReturnValueSlot Return = ReturnValueSlot());
3349 
3350  /// Retrieves the default cleanup kind for an ARC cleanup.
3351  /// Except under -fobjc-arc-eh, ARC cleanups are normal-only.
3353  return CGM.getCodeGenOpts().ObjCAutoRefCountExceptions
3355  }
3356 
3357  // ARC primitives.
3358  void EmitARCInitWeak(Address addr, llvm::Value *value);
3359  void EmitARCDestroyWeak(Address addr);
3362  llvm::Value *EmitARCStoreWeak(Address addr, llvm::Value *value, bool ignored);
3363  void EmitARCCopyWeak(Address dst, Address src);
3364  void EmitARCMoveWeak(Address dst, Address src);
3368  bool resultIgnored);
3370  bool resultIgnored);
3373  llvm::Value *EmitARCRetainBlock(llvm::Value *value, bool mandatory);
3375  void EmitARCRelease(llvm::Value *value, ARCPreciseLifetime_t precise);
3381 
3382  std::pair<LValue,llvm::Value*>
3384  std::pair<LValue,llvm::Value*>
3385  EmitARCStoreStrong(const BinaryOperator *e, bool ignored);
3386  std::pair<LValue,llvm::Value*>
3387  EmitARCStoreUnsafeUnretained(const BinaryOperator *e, bool ignored);
3388 
3392 
3395  bool allowUnsafeClaim);
3399 
3401 
3406 
3412 
3413  /// \brief Emits a reference binding to the passed in expression.
3415 
3416  //===--------------------------------------------------------------------===//
3417  // Expression Emission
3418  //===--------------------------------------------------------------------===//
3419 
3420  // Expressions are broken into three classes: scalar, complex, aggregate.
3421 
3422  /// EmitScalarExpr - Emit the computation of the specified expression of LLVM
3423  /// scalar type, returning the result.
3424  llvm::Value *EmitScalarExpr(const Expr *E , bool IgnoreResultAssign = false);
3425 
3426  /// Emit a conversion from the specified type to the specified destination
3427  /// type, both of which are LLVM scalar types.
3429  QualType DstTy, SourceLocation Loc);
3430 
3431  /// Emit a conversion from the specified complex type to the specified
3432  /// destination type, where the destination type is an LLVM scalar type.
3434  QualType DstTy,
3435  SourceLocation Loc);
3436 
3437  /// EmitAggExpr - Emit the computation of the specified expression
3438  /// of aggregate type. The result is computed into the given slot,
3439  /// which may be null to indicate that the value is not needed.
3440  void EmitAggExpr(const Expr *E, AggValueSlot AS);
3441 
3442  /// EmitAggExprToLValue - Emit the computation of the specified expression of
3443  /// aggregate type into a temporary LValue.
3444  LValue EmitAggExprToLValue(const Expr *E);
3445 
3446  /// EmitExtendGCLifetime - Given a pointer to an Objective-C object,
3447  /// make sure it survives garbage collection until this point.
3448  void EmitExtendGCLifetime(llvm::Value *object);
3449 
3450  /// EmitComplexExpr - Emit the computation of the specified expression of
3451  /// complex type, returning the result.
3453  bool IgnoreReal = false,
3454  bool IgnoreImag = false);
3455 
3456  /// EmitComplexExprIntoLValue - Emit the given expression of complex
3457  /// type and place its result into the specified l-value.
3458  void EmitComplexExprIntoLValue(const Expr *E, LValue dest, bool isInit);
3459 
3460  /// EmitStoreOfComplex - Store a complex number into the specified l-value.
3461  void EmitStoreOfComplex(ComplexPairTy V, LValue dest, bool isInit);
3462 
3463  /// EmitLoadOfComplex - Load a complex number from the specified l-value.
3465 
3466  Address emitAddrOfRealComponent(Address complex, QualType complexType);
3467  Address emitAddrOfImagComponent(Address complex, QualType complexType);
3468 
3469  /// AddInitializerToStaticVarDecl - Add the initializer for 'D' to the
3470  /// global variable that has already been created for it. If the initializer
3471  /// has a different type than GV does, this may free GV and return a different
3472  /// one. Otherwise it just returns GV.
3473  llvm::GlobalVariable *
3475  llvm::GlobalVariable *GV);
3476 
3477 
3478  /// EmitCXXGlobalVarDeclInit - Create the initializer for a C++
3479  /// variable with global storage.
3480  void EmitCXXGlobalVarDeclInit(const VarDecl &D, llvm::Constant *DeclPtr,
3481  bool PerformInit);
3482 
3483  llvm::Constant *createAtExitStub(const VarDecl &VD, llvm::Constant *Dtor,
3484  llvm::Constant *Addr);
3485 
3486  /// Call atexit() with a function that passes the given argument to
3487  /// the given function.
3488  void registerGlobalDtorWithAtExit(const VarDecl &D, llvm::Constant *fn,
3489  llvm::Constant *addr);
3490 
3491  /// Emit code in this function to perform a guarded variable
3492  /// initialization. Guarded initializations are used when it's not
3493  /// possible to prove that an initialization will be done exactly
3494  /// once, e.g. with a static local variable or a static data member
3495  /// of a class template.
3496  void EmitCXXGuardedInit(const VarDecl &D, llvm::GlobalVariable *DeclPtr,
3497  bool PerformInit);
3498 
3499  /// GenerateCXXGlobalInitFunc - Generates code for initializing global
3500  /// variables.
3501  void GenerateCXXGlobalInitFunc(llvm::Function *Fn,
3502  ArrayRef<llvm::Function *> CXXThreadLocals,
3503  Address Guard = Address::invalid());
3504 
3505  /// GenerateCXXGlobalDtorsFunc - Generates code for destroying global
3506  /// variables.
3508  llvm::Function *Fn,
3509  const std::vector<std::pair<llvm::WeakTrackingVH, llvm::Constant *>>
3510  &DtorsAndObjects);
3511 
3512  void GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn,
3513  const VarDecl *D,
3514  llvm::GlobalVariable *Addr,
3515  bool PerformInit);
3516 
3517  void EmitCXXConstructExpr(const CXXConstructExpr *E, AggValueSlot Dest);
3518 
3519  void EmitSynthesizedCXXCopyCtor(Address Dest, Address Src, const Expr *Exp);
3520 
3522  if (E->getNumObjects() == 0) return;
3524  }
3526 
3527  void EmitCXXThrowExpr(const CXXThrowExpr *E, bool KeepInsertionPoint = true);
3528 
3529  void EmitLambdaExpr(const LambdaExpr *E, AggValueSlot Dest);
3530 
3532 
3533  //===--------------------------------------------------------------------===//
3534  // Annotations Emission
3535  //===--------------------------------------------------------------------===//
3536 
3537  /// Emit an annotation call (intrinsic or builtin).
3539  llvm::Value *AnnotatedVal,
3540  StringRef AnnotationStr,
3541  SourceLocation Location);
3542 
3543  /// Emit local annotations for the local variable V, declared by D.
3544  void EmitVarAnnotations(const VarDecl *D, llvm::Value *V);
3545 
3546  /// Emit field annotations for the given field & value. Returns the
3547  /// annotation result.
3549 
3550  //===--------------------------------------------------------------------===//
3551  // Internal Helpers
3552  //===--------------------------------------------------------------------===//
3553 
3554  /// ContainsLabel - Return true if the statement contains a label in it. If
3555  /// this statement is not executed normally, it not containing a label means
3556  /// that we can just remove the code.
3557  static bool ContainsLabel(const Stmt *S, bool IgnoreCaseStmts = false);
3558 
3559  /// containsBreak - Return true if the statement contains a break out of it.
3560  /// If the statement (recursively) contains a switch or loop with a break
3561  /// inside of it, this is fine.
3562  static bool containsBreak(const Stmt *S);
3563 
3564  /// Determine if the given statement might introduce a declaration into the
3565  /// current scope, by being a (possibly-labelled) DeclStmt.
3566  static bool mightAddDeclToScope(const Stmt *S);
3567 
3568  /// ConstantFoldsToSimpleInteger - If the specified expression does not fold
3569  /// to a constant, or if it does but contains a label, return false. If it
3570  /// constant folds return true and set the boolean result in Result.
3571  bool ConstantFoldsToSimpleInteger(const Expr *Cond, bool &Result,
3572  bool AllowLabels = false);
3573 
3574  /// ConstantFoldsToSimpleInteger - If the specified expression does not fold
3575  /// to a constant, or if it does but contains a label, return false. If it
3576  /// constant folds return true and set the folded value.
3577  bool ConstantFoldsToSimpleInteger(const Expr *Cond, llvm::APSInt &Result,
3578  bool AllowLabels = false);
3579 
3580  /// EmitBranchOnBoolExpr - Emit a branch on a boolean condition (e.g. for an
3581  /// if statement) to the specified blocks. Based on the condition, this might
3582  /// try to simplify the codegen of the conditional based on the branch.
3583  /// TrueCount should be the number of times we expect the condition to
3584  /// evaluate to true based on PGO data.
3585  void EmitBranchOnBoolExpr(const Expr *Cond, llvm::BasicBlock *TrueBlock,
3586  llvm::BasicBlock *FalseBlock, uint64_t TrueCount);
3587 
3588  /// Given an assignment `*LHS = RHS`, emit a test that checks if \p RHS is
3589  /// nonnull, if \p LHS is marked _Nonnull.
3591 
3592  /// An enumeration which makes it easier to specify whether or not an
3593  /// operation is a subtraction.
3594  enum { NotSubtraction = false, IsSubtraction = true };
3595 
3596  /// Same as IRBuilder::CreateInBoundsGEP, but additionally emits a check to
3597  /// detect undefined behavior when the pointer overflow sanitizer is enabled.
3598  /// \p SignedIndices indicates whether any of the GEP indices are signed.
3599  /// \p IsSubtraction indicates whether the expression used to form the GEP
3600  /// is a subtraction.
3602  ArrayRef<llvm::Value *> IdxList,
3603  bool SignedIndices,
3604  bool IsSubtraction,
3605  SourceLocation Loc,
3606  const Twine &Name = "");
3607 
3608  /// \brief Emit a description of a type in a format suitable for passing to
3609  /// a runtime sanitizer handler.
3610  llvm::Constant *EmitCheckTypeDescriptor(QualType T);
3611 
3612  /// \brief Convert a value into a format suitable for passing to a runtime
3613  /// sanitizer handler.
3615 
3616  /// \brief Emit a description of a source location in a format suitable for
3617  /// passing to a runtime sanitizer handler.
3618  llvm::Constant *EmitCheckSourceLocation(SourceLocation Loc);
3619 
3620  /// \brief Create a basic block that will call a handler function in a
3621  /// sanitizer runtime with the provided arguments, and create a conditional
3622  /// branch to it.
3623  void EmitCheck(ArrayRef<std::pair<llvm::Value *, SanitizerMask>> Checked,
3624  SanitizerHandler Check, ArrayRef<llvm::Constant *> StaticArgs,
3625  ArrayRef<llvm::Value *> DynamicArgs);
3626 
3627  /// \brief Emit a slow path cross-DSO CFI check which calls __cfi_slowpath
3628  /// if Cond if false.
3630  llvm::ConstantInt *TypeId, llvm::Value *Ptr,
3631  ArrayRef<llvm::Constant *> StaticArgs);
3632 
3633  /// \brief Create a basic block that will call the trap intrinsic, and emit a
3634  /// conditional branch to it, for the -ftrapv checks.
3635  void EmitTrapCheck(llvm::Value *Checked);
3636 
3637  /// \brief Emit a call to trap or debugtrap and attach function attribute
3638  /// "trap-func-name" if specified.
3639  llvm::CallInst *EmitTrapCall(llvm::Intrinsic::ID IntrID);
3640 
3641  /// \brief Emit a stub for the cross-DSO CFI check function.
3642  void EmitCfiCheckStub();
3643 
3644  /// \brief Emit a cross-DSO CFI failure handling function.
3645  void EmitCfiCheckFail();
3646 
3647  /// \brief Create a check for a function parameter that may potentially be
3648  /// declared as non-null.
3649  void EmitNonNullArgCheck(RValue RV, QualType ArgType, SourceLocation ArgLoc,
3650  AbstractCallee AC, unsigned ParmNum);
3651 
3652  /// EmitCallArg - Emit a single call argument.
3653  void EmitCallArg(CallArgList &args, const Expr *E, QualType ArgType);
3654 
3655  /// EmitDelegateCallArg - We are performing a delegate call; that
3656  /// is, the current function is delegating to another one. Produce
3657  /// a r-value suitable for passing the given parameter.
3658  void EmitDelegateCallArg(CallArgList &args, const VarDecl *param,
3659  SourceLocation loc);
3660 
3661  /// SetFPAccuracy - Set the minimum required accuracy of the given floating
3662  /// point operation, expressed as the maximum relative error in ulp.
3663  void SetFPAccuracy(llvm::Value *Val, float Accuracy);
3664 
3665 private:
3666  llvm::MDNode *getRangeForLoadFromType(QualType Ty);
3667  void EmitReturnOfRValue(RValue RV, QualType Ty);
3668 
3669  void deferPlaceholderReplacement(llvm::Instruction *Old, llvm::Value *New);
3670 
3672  DeferredReplacements;
3673 
3674  /// Set the address of a local variable.
3675  void setAddrOfLocalVar(const VarDecl *VD, Address Addr) {
3676  assert(!LocalDeclMap.count(VD) && "Decl already exists in LocalDeclMap!");
3677  LocalDeclMap.insert({VD, Addr});
3678  }
3679 
3680  /// ExpandTypeFromArgs - Reconstruct a structure of type \arg Ty
3681  /// from function arguments into \arg Dst. See ABIArgInfo::Expand.
3682  ///
3683  /// \param AI - The first function argument of the expansion.
3684  void ExpandTypeFromArgs(QualType Ty, LValue Dst,
3685  SmallVectorImpl<llvm::Value *>::iterator &AI);
3686 
3687  /// ExpandTypeToArgs - Expand an RValue \arg RV, with the LLVM type for \arg
3688  /// Ty, into individual arguments on the provided vector \arg IRCallArgs,
3689  /// starting at index \arg IRCallArgPos. See ABIArgInfo::Expand.
3690  void ExpandTypeToArgs(QualType Ty, RValue RV, llvm::FunctionType *IRFuncTy,
3691  SmallVectorImpl<llvm::Value *> &IRCallArgs,
3692  unsigned &IRCallArgPos);
3693 
3694  llvm::Value* EmitAsmInput(const TargetInfo::ConstraintInfo &Info,
3695  const Expr *InputExpr, std::string &ConstraintStr);
3696 
3697  llvm::Value* EmitAsmInputLValue(const TargetInfo::ConstraintInfo &Info,
3698  LValue InputValue, QualType InputType,
3699  std::string &ConstraintStr,
3700  SourceLocation Loc);
3701 
3702  /// \brief Attempts to statically evaluate the object size of E. If that
3703  /// fails, emits code to figure the size of E out for us. This is
3704  /// pass_object_size aware.
3705  ///
3706  /// If EmittedExpr is non-null, this will use that instead of re-emitting E.
3707  llvm::Value *evaluateOrEmitBuiltinObjectSize(const Expr *E, unsigned Type,
3708  llvm::IntegerType *ResType,
3709  llvm::Value *EmittedE);
3710 
3711  /// \brief Emits the size of E, as required by __builtin_object_size. This
3712  /// function is aware of pass_object_size parameters, and will act accordingly
3713  /// if E is a parameter with the pass_object_size attribute.
3714  llvm::Value *emitBuiltinObjectSize(const Expr *E, unsigned Type,
3715  llvm::IntegerType *ResType,
3716  llvm::Value *EmittedE);
3717 
3718 public:
3719 #ifndef NDEBUG
3720  // Determine whether the given argument is an Objective-C method
3721  // that may have type parameters in its signature.
3722  static bool isObjCMethodWithTypeParams(const ObjCMethodDecl *method) {
3723  const DeclContext *dc = method->getDeclContext();
3724  if (const ObjCInterfaceDecl *classDecl= dyn_cast<ObjCInterfaceDecl>(dc)) {
3725  return classDecl->getTypeParamListAsWritten();
3726  }
3727 
3728  if (const ObjCCategoryDecl *catDecl = dyn_cast<ObjCCategoryDecl>(dc)) {
3729  return catDecl->getTypeParamList();
3730  }
3731 
3732  return false;
3733  }
3734 
3735  template<typename T>
3736  static bool isObjCMethodWithTypeParams(const T *) { return false; }
3737 #endif
3738 
3739  enum class EvaluationOrder {
3740  ///! No language constraints on evaluation order.
3741  Default,
3742  ///! Language semantics require left-to-right evaluation.
3744  ///! Language semantics require right-to-left evaluation.
3746  };
3747 
3748  /// EmitCallArgs - Emit call arguments for a function.
3749  template <typename T>
3750  void EmitCallArgs(CallArgList &Args, const T *CallArgTypeInfo,
3751  llvm::iterator_range<CallExpr::const_arg_iterator> ArgRange,
3753  unsigned ParamsToSkip = 0,
3755  SmallVector<QualType, 16> ArgTypes;
3756  CallExpr::const_arg_iterator Arg = ArgRange.begin();
3757 
3758  assert((ParamsToSkip == 0 || CallArgTypeInfo) &&
3759  "Can't skip parameters if type info is not provided");
3760  if (CallArgTypeInfo) {
3761 #ifndef NDEBUG
3762  bool isGenericMethod = isObjCMethodWithTypeParams(CallArgTypeInfo);
3763 #endif
3764 
3765  // First, use the argument types that the type info knows about
3766  for (auto I = CallArgTypeInfo->param_type_begin() + ParamsToSkip,
3767  E = CallArgTypeInfo->param_type_end();
3768  I != E; ++I, ++Arg) {
3769  assert(Arg != ArgRange.end() && "Running over edge of argument list!");
3770  assert((isGenericMethod ||
3771  ((*I)->isVariablyModifiedType() ||
3772  (*I).getNonReferenceType()->isObjCRetainableType() ||
3773  getContext()
3774  .getCanonicalType((*I).getNonReferenceType())
3775  .getTypePtr() ==
3776  getContext()
3777  .getCanonicalType((*Arg)->getType())
3778  .getTypePtr())) &&
3779  "type mismatch in call argument!");
3780  ArgTypes.push_back(*I);
3781  }
3782  }
3783 
3784  // Either we've emitted all the call args, or we have a call to variadic
3785  // function.
3786  assert((Arg == ArgRange.end() || !CallArgTypeInfo ||
3787  CallArgTypeInfo->isVariadic()) &&
3788  "Extra arguments in non-variadic function!");
3789 
3790  // If we still have any arguments, emit them using the type of the argument.
3791  for (auto *A : llvm::make_range(Arg, ArgRange.end()))
3792  ArgTypes.push_back(CallArgTypeInfo ? getVarArgType(A) : A->getType());
3793 
3794  EmitCallArgs(Args, ArgTypes, ArgRange, AC, ParamsToSkip, Order);
3795  }
3796 
3797  void EmitCallArgs(CallArgList &Args, ArrayRef<QualType> ArgTypes,
3798  llvm::iterator_range<CallExpr::const_arg_iterator> ArgRange,
3799  AbstractCallee AC = AbstractCallee(),
3800  unsigned ParamsToSkip = 0,
3802 
3803  /// EmitPointerWithAlignment - Given an expression with a pointer type,
3804  /// emit the value and compute our best estimate of the alignment of the
3805  /// pointee.
3806  ///
3807  /// \param BaseInfo - If non-null, this will be initialized with
3808  /// information about the source of the alignment and the may-alias
3809  /// attribute. Note that this function will conservatively fall back on
3810  /// the type when it doesn't recognize the expression and may-alias will
3811  /// be set to false.
3812  ///
3813  /// One reasonable way to use this information is when there's a language
3814  /// guarantee that the pointer must be aligned to some stricter value, and
3815  /// we're simply trying to ensure that sufficiently obvious uses of under-
3816  /// aligned objects don't get miscompiled; for example, a placement new
3817  /// into the address of a local variable. In such a case, it's quite
3818  /// reasonable to just ignore the returned alignment when it isn't from an
3819  /// explicit source.
3821  LValueBaseInfo *BaseInfo = nullptr);
3822 
3823  void EmitSanitizerStatReport(llvm::SanitizerStatKind SSK);
3824 
3825 private:
3826  QualType getVarArgType(const Expr *Arg);
3827 
3828  void EmitDeclMetadata();
3829 
3830  BlockByrefHelpers *buildByrefHelpers(llvm::StructType &byrefType,
3831  const AutoVarEmission &emission);
3832 
3833  void AddObjCARCExceptionMetadata(llvm::Instruction *Inst);
3834 
3835  llvm::Value *GetValueForARMHint(unsigned BuiltinID);
3836 };
3837 
3838 /// Helper class with most of the code for saving a value for a
3839 /// conditional expression cleanup.
3841  typedef llvm::PointerIntPair<llvm::Value*, 1, bool> saved_type;
3842 
3843  /// Answer whether the given value needs extra work to be saved.
3844  static bool needsSaving(llvm::Value *value) {
3845  // If it's not an instruction, we don't need to save.
3846  if (!isa<llvm::Instruction>(value)) return false;
3847 
3848  // If it's an instruction in the entry block, we don't need to save.
3849  llvm::BasicBlock *block = cast<llvm::Instruction>(value)->getParent();
3850  return (block != &block->getParent()->getEntryBlock());
3851  }
3852 
3853  /// Try to save the given value.
3855  if (!needsSaving(value)) return saved_type(value, false);
3856 
3857  // Otherwise, we need an alloca.
3858  auto align = CharUnits::fromQuantity(
3859  CGF.CGM.getDataLayout().getPrefTypeAlignment(value->getType()));
3860  Address alloca =
3861  CGF.CreateTempAlloca(value->getType(), align, "cond-cleanup.save");
3862  CGF.Builder.CreateStore(value, alloca);
3863 
3864  return saved_type(alloca.getPointer(), true);
3865  }
3866 
3868  // If the value says it wasn't saved, trust that it's still dominating.
3869  if (!value.getInt()) return value.getPointer();
3870 
3871  // Otherwise, it should be an alloca instruction, as set up in save().
3872  auto alloca = cast<llvm::AllocaInst>(value.getPointer());
3873  return CGF.Builder.CreateAlignedLoad(alloca, alloca->getAlignment());
3874  }
3875 };
3876 
3877 /// A partial specialization of DominatingValue for llvm::Values that
3878 /// might be llvm::Instructions.
3879 template <class T> struct DominatingPointer<T,true> : DominatingLLVMValue {
3880  typedef T *type;
3881  static type restore(CodeGenFunction &CGF, saved_type value) {
3882  return static_cast<T*>(DominatingLLVMValue::restore(CGF, value));
3883  }
3884 };
3885 
3886 /// A specialization of DominatingValue for Address.
3887 template <> struct DominatingValue<Address> {
3888  typedef Address type;
3889 
3890  struct saved_type {
3893  };
3894 
3895  static bool needsSaving(type value) {
3897  }
3898  static saved_type save(CodeGenFunction &CGF, type value) {
3899  return { DominatingLLVMValue::save(CGF, value.getPointer()),
3900  value.getAlignment() };
3901  }
3902  static type restore(CodeGenFunction &CGF, saved_type value) {
3903  return Address(DominatingLLVMValue::restore(CGF, value.SavedValue),
3904  value.Alignment);
3905  }
3906 };
3907 
3908 /// A specialization of DominatingValue for RValue.
3909 template <> struct DominatingValue<RValue> {
3910  typedef RValue type;
3911  class saved_type {
3912  enum Kind { ScalarLiteral, ScalarAddress, AggregateLiteral,
3913  AggregateAddress, ComplexAddress };
3914 
3915  llvm::Value *Value;
3916  unsigned K : 3;
3917  unsigned Align : 29;
3918  saved_type(llvm::Value *v, Kind k, unsigned a = 0)
3919  : Value(v), K(k), Align(a) {}
3920 
3921  public:
3922  static bool needsSaving(RValue value);
3923  static saved_type save(CodeGenFunction &CGF, RValue value);
3924  RValue restore(CodeGenFunction &CGF);
3925 
3926  // implementations in CGCleanup.cpp
3927  };
3928 
3929  static bool needsSaving(type value) {
3930  return saved_type::needsSaving(value);
3931  }
3932  static saved_type save(CodeGenFunction &CGF, type value) {
3933  return saved_type::save(CGF, value);
3934  }
3935  static type restore(CodeGenFunction &CGF, saved_type value) {
3936  return value.restore(CGF);
3937  }
3938 };
3939 
3940 } // end namespace CodeGen
3941 } // end namespace clang
3942 
3943 #endif
void enterNonTrivialFullExpression(const ExprWithCleanups *E)
Enter a full-expression with a non-trivial number of objects to clean up.
Definition: CGBlocks.cpp:663
A call to an overloaded operator written using operator syntax.
Definition: ExprCXX.h:52
ReturnValueSlot - Contains the address where the return value of a function can be stored...
Definition: CGCall.h:281
llvm::Value * getArrayInitIndex()
Get the index of the current ArrayInitLoopExpr, if any.
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:1708
bool EmitScalarRangeCheck(llvm::Value *Value, QualType Ty, SourceLocation Loc)
Check if the scalar Value is within the valid range for the given type Ty.
Definition: CGExpr.cpp:1390
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:3155
Information about the layout of a __block variable.
Definition: CGBlocks.h:140
void EmitIndirectGotoStmt(const IndirectGotoStmt &S)
Definition: CGStmt.cpp:588
This represents '#pragma omp master' directive.
Definition: StmtOpenMP.h:1364
SourceLocation getEnd() const
void EmitCoroutineBody(const CoroutineBodyStmt &S)
virtual void EmitBody(CodeGenFunction &CGF, const Stmt *S)
Emit the captured statement body.
This represents '#pragma omp task' directive.
Definition: StmtOpenMP.h:1704
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:1497
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
Definition: Decl.h:1618
llvm::Value * EmitARCStoreStrong(LValue lvalue, llvm::Value *value, bool resultIgnored)
Store into a strong object.
Definition: CGObjC.cpp:2162
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:1510
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:1218
llvm::Value * EmitARCReclaimReturnedObject(const Expr *e, bool allowUnsafeClaim)
Definition: CGObjC.cpp:2583
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:4213
void EmitDelegateCXXConstructorCall(const CXXConstructorDecl *Ctor, CXXCtorType CtorType, const FunctionArgList &Args, SourceLocation Loc)
Definition: CGClass.cpp:2225
void EmitReturnValueCheck(llvm::Value *RV)
Emit a test that checks if the return value RV is nonnull.
Definition: CGCall.cpp:2918
CGCallee 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:292
LValue EmitComplexCompoundAssignmentLValue(const CompoundAssignOperator *E)
void EmitStaticVarDecl(const VarDecl &D, llvm::GlobalValue::LinkageTypes Linkage)
Definition: CGDecl.cpp:368
llvm::Value * EmitARCRetainAutoreleaseScalarExpr(const Expr *expr)
Definition: CGObjC.cpp:2985
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:2224
Scheduling data for loop-based OpenMP directives.
Definition: OpenMPKinds.h:124
Destroyer * getDestroyer(QualType::DestructionKind destructionKind)
Definition: CGDecl.cpp:1451
A (possibly-)qualified type.
Definition: Type.h:616
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:3195
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:1239
llvm::Type * ConvertTypeForMem(QualType T)
const TargetCodeGenInfo & getTargetHooks() const
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:155
llvm::Value * EmitARCExtendBlockObject(const Expr *expr)
Definition: CGObjC.cpp:3002
void EmitGotoStmt(const GotoStmt &S)
Definition: CGStmt.cpp:577
LValue EmitStmtExprLValue(const StmtExpr *E)
Definition: CGExpr.cpp:4324
Address getAllocatedAddress() const
Returns the raw, allocated address, which is not necessarily the address of the object itself...
RValue EmitCoyieldExpr(const CoyieldExpr &E, AggValueSlot aggSlot=AggValueSlot::ignored(), bool ignoreResult=false)
void EmitAttributedStmt(const AttributedStmt &S)
Definition: CGStmt.cpp:557
The class detects jumps which bypass local variables declaration: goto L; int a; L: ...
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:2513
void EmitOMPDistributeDirective(const OMPDistributeDirective &S)
llvm::Value * EmitNVPTXBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition: CGBuiltin.cpp:9046
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:2298
LValue EmitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *E)
Definition: CGExpr.cpp:392
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)
Represents a 'co_return' statement in the C++ Coroutines TS.
Definition: StmtCXX.h:432
Stmt - This represents one statement.
Definition: Stmt.h:60
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:947
const TargetInfo & getTarget() const
IfStmt - This represents an if/then/else.
Definition: Stmt.h:905
void EmitStoreThroughGlobalRegLValue(RValue Src, LValue Dst)
Store of global named registers are always calls to intrinsics.
Definition: CGExpr.cpp:1984
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 EmitOMPTargetSimdDirective(const OMPTargetSimdDirective &S)
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:372
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:1114
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:4370
void emitAutoVarTypeCleanup(const AutoVarEmission &emission, QualType::DestructionKind dtorKind)
Enter a destroy cleanup for the given local variable.
Definition: CGDecl.cpp:1354
RValue EmitPseudoObjectRValue(const PseudoObjectExpr *e, AggValueSlot slot=AggValueSlot::ignored())
Definition: CGExpr.cpp:4630
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:81
This represents '#pragma omp teams distribute parallel for' composite directive.
Definition: StmtOpenMP.h:3566
void EmitTypeCheck(TypeCheckKind TCK, SourceLocation Loc, llvm::Value *V, QualType Type, CharUnits Alignment=CharUnits::Zero(), SanitizerSet SkippedChecks=SanitizerSet())
Emit a check that V is the address of storage of the appropriate size and alignment for an object of ...
Definition: CGExpr.cpp:578
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.
RValue EmitCoawaitExpr(const CoawaitExpr &E, AggValueSlot aggSlot=AggValueSlot::ignored(), bool ignoreResult=false)
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:854
llvm::Value * EmitMSVCBuiltinExpr(MSVCIntrin BuiltinID, const CallExpr *E)
Definition: CGBuiltin.cpp:499
void EmitAutoVarDecl(const VarDecl &D)
EmitAutoVarDecl - Emit an auto variable declaration.
Definition: CGDecl.cpp:921
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:1303
This represents '#pragma omp target teams distribute' combined directive.
Definition: StmtOpenMP.h:3693
void pushLifetimeExtendedDestroy(CleanupKind kind, Address addr, QualType type, Destroyer *destroyer, bool useEHCleanupForArray)
Definition: CGDecl.cpp:1496
LValue EmitBinaryOperatorLValue(const BinaryOperator *E)
Definition: CGExpr.cpp:4155
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:1749
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:4032
void GenerateObjCSetter(ObjCImplementationDecl *IMP, const ObjCPropertyImplDecl *PID)
GenerateObjCSetter - Synthesize an Objective-C property setter function for the given property...
Definition: CGObjC.cpp:1341
Address GenerateCapturedStmtArgument(const CapturedStmt &S)
Definition: CGStmt.cpp:2265
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:2497
void SpecialInitFn(CodeGenFunction &Init, const VarDecl &D, llvm::Value *Address)
bool sanitizePerformTypeCheck() const
Whether any type-checking sanitizers are enabled.
Definition: CGExpr.cpp:571
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1177
RValue EmitCXXMemberCallExpr(const CXXMemberCallExpr *E, ReturnValueSlot ReturnValue)
Definition: CGExprCXX.cpp:166
DominatingValue< T >::saved_type saveValueInCond(T value)
CGCapturedStmtInfo(CapturedRegionKind K=CR_Default)
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
void EmitARCCopyWeak(Address dst, Address src)
void @objc_copyWeak(i8** dest, i8** src) Disregards the current value in dest.
Definition: CGObjC.cpp:2324
void EmitCfiCheckFail()
Emit a cross-DSO CFI failure handling function.
Definition: CGExpr.cpp:2896
void ForceCleanup(std::initializer_list< llvm::Value ** > ValuesToReload={})
Force the emission of cleanups now, instead of waiting until this object is destroyed.
llvm::Value * EmitObjCMRRAutoreleasePoolPush()
Produce the code to do an MRR version objc_autoreleasepool_push.
Definition: CGObjC.cpp:2367
llvm::Function * GenerateVarArgsThunk(llvm::Function *Fn, const CGFunctionInfo &FnInfo, GlobalDecl GD, const ThunkInfo &Thunk)
Definition: CGVTables.cpp:142
CharUnits getNaturalTypeAlignment(QualType T, LValueBaseInfo *BaseInfo=nullptr, bool forPointeeType=false)
llvm::Constant * GenerateObjCAtomicSetterCopyHelperFunction(const ObjCPropertyImplDecl *PID)
GenerateObjCAtomicSetterCopyHelperFunction - Given a c++ object type with non-trivial copy assignment...
Definition: CGObjC.cpp:3214
This represents '#pragma omp parallel for' directive.
Definition: StmtOpenMP.h:1485
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:3739
llvm::Value * EmitARCRetainNonBlock(llvm::Value *value)
Retain the given object, with normal retain semantics.
Definition: CGObjC.cpp:1983
This represents '#pragma omp target teams distribute parallel for' combined directive.
Definition: StmtOpenMP.h:3761
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2329
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
Definition: ExprCXX.h:3946
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.
! Language semantics require left-to-right evaluation.
LValue EmitCXXUuidofLValue(const CXXUuidofExpr *E)
Definition: CGExpr.cpp:4243
const CXXBaseSpecifier *const * path_const_iterator
Definition: Expr.h:2766
void EmitOMPParallelForSimdDirective(const OMPParallelForSimdDirective &S)
This represents '#pragma omp target exit data' directive.
Definition: StmtOpenMP.h:2380
void GenerateCXXGlobalDtorsFunc(llvm::Function *Fn, const std::vector< std::pair< llvm::WeakTrackingVH, llvm::Constant * >> &DtorsAndObjects)
GenerateCXXGlobalDtorsFunc - Generates code for destroying global variables.
Definition: CGDeclCXX.cpp:574
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:758
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:2470
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:2628
RAII object to set/unset CodeGenFunction::IsSanitizerScope.
LValue EmitObjCSelectorLValue(const ObjCSelectorExpr *E)
Definition: CGExpr.cpp:4280
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:2332
Address EmitArrayToPointerDecay(const Expr *Array, LValueBaseInfo *BaseInfo=nullptr)
Definition: CGExpr.cpp:3007
field_iterator field_begin() const
Definition: Decl.cpp:3912
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:429
This class gathers all debug information during compilation and is responsible for emitting to llvm g...
Definition: CGDebugInfo.h:53
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:113
static bool mightAddDeclToScope(const Stmt *S)
Determine if the given statement might introduce a declaration into the current scope, by being a (possibly-labelled) DeclStmt.
void EmitNonNullArgCheck(RValue RV, QualType ArgType, SourceLocation ArgLoc, AbstractCallee AC, unsigned ParmNum)
Create a check for a function parameter that may potentially be declared as non-null.
Definition: CGCall.cpp:3283
llvm::Value * EmitBlockCopyAndAutorelease(llvm::Value *Block, QualType Ty)
Definition: CGObjC.cpp:3398
void EmitLabel(const LabelDecl *D)
EmitLabel - Emit the block for the given label.
Definition: CGStmt.cpp:502
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:2995
void EmitVariablyModifiedType(QualType Ty)
EmitVLASize - Capture all the sizes for the VLA expressions in the given variably-modified type and s...
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:2174
RValue EmitCUDAKernelCallExpr(const CUDAKernelCallExpr *E, ReturnValueSlot ReturnValue)
Definition: CGExprCXX.cpp:460
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:928
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
Definition: ExprCXX.h:2920
llvm::Value * EmitARMBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition: CGBuiltin.cpp:4407
ParmVarDecl - Represents a parameter to a function.
Definition: Decl.h:1434
void EmitOMPTeamsDistributeDirective(const OMPTeamsDistributeDirective &S)
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:690
void SimplifyForwardingBlocks(llvm::BasicBlock *BB)
SimplifyForwardingBlocks - If the given basic block is only a branch to another basic block...
Definition: CGStmt.cpp:414
void emitImplicitAssignmentOperatorBody(FunctionArgList &Args)
Definition: CGClass.cpp:1498
RValue EmitCXXMemberOrOperatorCall(const CXXMethodDecl *Method, const CGCallee &Callee, ReturnValueSlot ReturnValue, llvm::Value *This, llvm::Value *ImplicitParam, QualType ImplicitParamTy, const CallExpr *E, CallArgList *RtlArgs)
Definition: CGExprCXX.cpp:80
llvm::Value * EmitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E)
Definition: CGObjC.cpp:243
void EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst, llvm::Value **Result=nullptr)
EmitStoreThroughBitfieldLValue - Store Src into Dst with same constraints as EmitStoreThroughLValue.
Definition: CGExpr.cpp:1846
static void EmitOMPTargetParallelDeviceFunction(CodeGenModule &CGM, StringRef ParentName, const OMPTargetParallelDirective &S)
Address emitAddrOfImagComponent(Address complex, QualType complexType)
The collection of all-type qualifiers we support.
Definition: Type.h:118
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...
bool EmitOMPWorksharingLoop(const OMPLoopDirective &S, Expr *EUB, const CodeGenLoopBoundsTy &CodeGenLoopBounds, const CodeGenDispatchBoundsTy &CGDispatchBounds)
Emit code for the worksharing loop-based directive.
llvm::Value * EmitObjCThrowOperand(const Expr *expr)
Definition: CGObjC.cpp:3020
void EmitOMPTargetTeamsDistributeParallelForSimdDirective(const OMPTargetTeamsDistributeParallelForSimdDirective &S)
LabelStmt - Represents a label, which has a substatement.
Definition: Stmt.h:813
void EmitOMPTaskLoopSimdDirective(const OMPTaskLoopSimdDirective &S)
JumpDest getJumpDestForLabel(const LabelDecl *S)
getBasicBlockForLabel - Return the LLVM basicblock that the specified label maps to.
Definition: CGStmt.cpp:491
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:819
RecordDecl - Represents a struct/union/class.
Definition: Decl.h:3354
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:3786
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:935
bool requiresLandingPad() const
Definition: CGCleanup.cpp:159
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:1501
void emitDestroy(Address addr, QualType type, Destroyer *destroyer, bool useEHCleanupForArray)
emitDestroy - Immediately perform the destruction of the given object.
Definition: CGDecl.cpp:1527
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:2277
ArrayInitLoopExprScope(CodeGenFunction &CGF, llvm::Value *Index)
CGBlockInfo * FirstBlockInfo
FirstBlockInfo - The head of a singly-linked-list of block layouts.
LValue EmitScalarCompoundAssignWithComplex(const CompoundAssignOperator *E, llvm::Value *&Result)
void EmitCheck(ArrayRef< std::pair< llvm::Value *, SanitizerMask >> Checked, SanitizerHandler Check, 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:2719
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:2738
This represents '#pragma omp parallel' directive.
Definition: StmtOpenMP.h:251
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
LValue EmitObjCIvarRefLValue(const ObjCIvarRefExpr *E)
Definition: CGExpr.cpp:4300
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:128
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:3560
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:1316
std::pair< LValue, llvm::Value * > EmitARCStoreAutoreleasing(const BinaryOperator *e)
Definition: CGObjC.cpp:3158
CGCallee BuildAppleKextVirtualDestructorCall(const CXXDestructorDecl *DD, CXXDtorType Type, const CXXRecordDecl *RD)
BuildVirtualCall - This routine makes indirect vtable call for call to virtual destructors.
Definition: CGCXX.cpp:313
llvm::Value * EmitDynamicCast(Address V, const CXXDynamicCastExpr *DCE)
Definition: CGExprCXX.cpp:2072
llvm::Value * EmitObjCExtendObjectLifetime(QualType T, llvm::Value *Ptr)
Definition: CGObjC.cpp:1798
void EmitOMPTaskLoopBasedDirective(const OMPLoopDirective &S)
RValue EmitReferenceBindingToExpr(const Expr *E)
Emits a reference binding to the passed in expression.
Definition: CGExpr.cpp:531
llvm::SmallPtrSet< const CXXRecordDecl *, 4 > VisitedVirtualBasesSetTy
void EmitSynthesizedCXXCopyCtorCall(const CXXConstructorDecl *D, Address This, Address Src, const CXXConstructExpr *E)
Definition: CGClass.cpp:2201
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:4249
bool isReferenceType() const
Definition: Type.h:5721
llvm::Value * EmitARCRetainAutoreleaseReturnValue(llvm::Value *value)
Do a fused retain/autorelease of the given object.
Definition: CGObjC.cpp:2216
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
Definition: Decl.h:2366
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:2683
Address EmitLoadOfPointer(Address Ptr, const PointerType *PtrTy, LValueBaseInfo *BaseInfo=nullptr)
Definition: CGExpr.cpp:2138
void rescopeLabels()
Change the cleanup scope of the labels in this lexical scope to match the scope of the enclosing cont...
Definition: CGStmt.cpp:530
An RAII object to set (and then clear) a mapping for an OpaqueValueExpr.
const FunctionDecl * CurSEHParent
LValue EmitCoyieldLValue(const CoyieldExpr *E)
LValue EmitOMPArraySectionExpr(const OMPArraySectionExpr *E, bool IsLowerBound=true)
Definition: CGExpr.cpp:3310
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:1466
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:2599
void EmitOMPPrivateLoopCounters(const OMPLoopDirective &S, OMPPrivateScope &LoopScope)
Emit initial code for loop counters of loop-based directives.
llvm::Value * EmitARCAutoreleaseReturnValue(llvm::Value *value)
Autorelease the given object.
Definition: CGObjC.cpp:2206
This represents '#pragma omp target simd' directive.
Definition: StmtOpenMP.h:3291
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:3655
void GenerateObjCCtorDtorMethod(ObjCImplementationDecl *IMP, ObjCMethodDecl *MD, bool ctor)
Definition: CGObjC.cpp:1422
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:4759
A metaprogramming class for ensuring that a value will dominate an arbitrary position in a function...
Definition: EHScopeStack.h:66
This represents '#pragma omp barrier' directive.
Definition: StmtOpenMP.h:1816
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:110
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:313
RValue EmitLoadOfExtVectorElementLValue(LValue V)
Definition: CGExpr.cpp:1673
const Decl * getDecl() const
Definition: GlobalDecl.h:62
This represents '#pragma omp critical' directive.
Definition: StmtOpenMP.h:1411
LValue EmitLambdaLValue(const LambdaExpr *E)
Definition: CGExpr.cpp:4259
void EmitCXXConstructorCall(const CXXConstructorDecl *D, CXXCtorType Type, bool ForVirtualBase, bool Delegating, Address This, const CXXConstructExpr *E)
Definition: CGClass.cpp:1947
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:2786
RValue EmitAnyExprToTemp(const Expr *E)
EmitAnyExprToTemp - Similarly to EmitAnyExpr(), however, the result will always be accessible even if...
Definition: CGExpr.cpp:188
ComplexPairTy EmitLoadOfComplex(LValue src, SourceLocation loc)
EmitLoadOfComplex - Load a complex number from the specified l-value.
void EmitOMPDistributeParallelForSimdDirective(const OMPDistributeParallelForSimdDirective &S)
void EmitInitializerForField(FieldDecl *Field, LValue LHS, Expr *Init)
Definition: CGClass.cpp:655
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:118
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:169
T * getAttr() const
Definition: DeclBase.h:518
void EmitNoreturnRuntimeCallOrInvoke(llvm::Value *callee, ArrayRef< llvm::Value * > args)
Emits a call or invoke to the given noreturn runtime function.
Definition: CGCall.cpp:3613
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:2136
IndirectGotoStmt - This represents an indirect goto.
Definition: Stmt.h:1284
llvm::Value * EmitLoadOfScalar(Address Addr, bool Volatile, QualType Ty, SourceLocation Loc, LValueBaseInfo BaseInfo=LValueBaseInfo(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:1437
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:2081
Describes an C or C++ initializer list.
Definition: Expr.h:3848
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Definition: ExprCXX.h:590
This represents '#pragma omp distribute parallel for' composite directive.
Definition: StmtOpenMP.h:3016
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:1721
A class controlling the emission of a finally block.
Address emitAddrOfRealComponent(Address complex, QualType complexType)
This represents '#pragma omp teams distribute parallel for simd' composite directive.
Definition: StmtOpenMP.h:3495
llvm::Value * BuildVector(ArrayRef< llvm::Value * > Ops)
Definition: CGBuiltin.cpp:7075
BinaryOperatorKind
CharUnits getNaturalPointeeTypeAlignment(QualType T, LValueBaseInfo *BaseInfo=nullptr)
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:1064
void EmitOMPTargetTeamsDistributeSimdDirective(const OMPTargetTeamsDistributeSimdDirective &S)
ForStmt - This represents a 'for (init;cond;inc)' stmt.
Definition: Stmt.h:1179
InlinedInheritingConstructorScope(CodeGenFunction &CGF, GlobalDecl GD)
ObjCContainerDecl - Represents a container for method declarations.
Definition: DeclObjC.h:919
void emitOMPSimpleStore(LValue LVal, RValue RVal, QualType RValTy, SourceLocation Loc)
void EmitDoStmt(const DoStmt &S, ArrayRef< const Attr * > Attrs=None)
Definition: CGStmt.cpp:774
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:2523
void EmitARCDestroyStrong(Address addr, ARCPreciseLifetime_t precise)
Destroy a __strong variable.
Definition: CGObjC.cpp:2122
bool isLocalVarDeclOrParm() const
Similar to isLocalVarDecl but also includes parameters.
Definition: Decl.h:1043
llvm::function_ref< std::pair< LValue, LValue > CodeGenFunction &, const OMPExecutableDirective &S)> CodeGenLoopBoundsTy
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:700
void EmitOMPTeamsDistributeParallelForSimdDirective(const OMPTeamsDistributeParallelForSimdDirective &S)
void EmitContinueStmt(const ContinueStmt &S)
Definition: CGStmt.cpp:1132
void EmitOMPTargetDirective(const OMPTargetDirective &S)
TypeDecl - Represents a declaration of a type.
Definition: Decl.h:2642
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:2967
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:3096
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:229
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.
Address EmitLoadOfReference(Address Ref, const ReferenceType *RefTy, LValueBaseInfo *BaseInfo=nullptr)
Definition: CGExpr.cpp:2123
Address EmitCXXMemberDataPointerAddress(const Expr *E, Address base, llvm::Value *memberPtr, const MemberPointerType *memberPtrType, LValueBaseInfo *BaseInfo=nullptr)
Emit the address of a field using a member data pointer.
Definition: CGClass.cpp:129
void EmitOMPTargetUpdateDirective(const OMPTargetUpdateDirective &S)
void EmitSwitchStmt(const SwitchStmt &S)
Definition: CGStmt.cpp:1558
This represents '#pragma omp cancellation point' directive.
Definition: StmtOpenMP.h:2635
bool isObviouslyBranchWithoutCleanups(JumpDest Dest) const
isObviouslyBranchWithoutCleanups - Return true if a branch to the specified destination obviously has...
Definition: CGCleanup.cpp:1009
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:2253
ObjCStringLiteral, used for Objective-C string literals i.e.
Definition: ExprObjC.h:29
llvm::BasicBlock * getInvokeDestImpl()
LValue EmitCXXConstructLValue(const CXXConstructExpr *E)
Definition: CGExpr.cpp:4224
void initFullExprCleanup()
Set up the last cleaup that was pushed as a conditional full-expression cleanup.
Definition: CGCleanup.cpp:284
RValue EmitSimpleCallExpr(const CallExpr *E, ReturnValueSlot ReturnValue)
Emit a CallExpr without considering whether it might be a subclass.
Definition: CGExpr.cpp:4093
llvm::Function * GenerateSEHFinallyFunction(CodeGenFunction &ParentCGF, const SEHFinallyStmt &Finally)
void EmitDeleteCall(const FunctionDecl *DeleteFD, llvm::Value *Ptr, QualType DeleteTy, llvm::Value *NumElements=nullptr, CharUnits CookieSize=CharUnits())
Definition: CGExprCXX.cpp:1705
LValue EmitUnaryOpLValue(const UnaryOperator *E)
Definition: CGExpr.cpp:2400
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:2969
This represents '#pragma omp teams' directive.
Definition: StmtOpenMP.h:2578
void EmitIgnoredExpr(const Expr *E)
EmitIgnoredExpr - Emit an expression in a context which ignores the result.
Definition: CGExpr.cpp:157
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:2250
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:2701
LValue EmitObjCMessageExprLValue(const ObjCMessageExpr *E)
Definition: CGExpr.cpp:4266
bool requiresCleanups() const
Determine whether this scope requires any cleanups.
This represents '#pragma omp teams distribute simd' combined directive.
Definition: StmtOpenMP.h:3425
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1134
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:1519
GlobalDecl CurGD
CurGD - The GlobalDecl for the current function being compiled.
void EmitDefaultStmt(const DefaultStmt &S)
Definition: CGStmt.cpp:1308
RValue EmitBuiltinExpr(const FunctionDecl *FD, unsigned BuiltinID, const CallExpr *E, ReturnValueSlot ReturnValue)
Definition: CGBuiltin.cpp:644
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:2149
void EmitCaseStmtRange(const CaseStmt &S)
EmitCaseStmtRange - If case statement range is not too big then add multiple cases to switch instruct...
Definition: CGStmt.cpp:1147
void incrementProfileCounter(const Stmt *S, llvm::Value *StepV=nullptr)
Increment the profiler's counter for the given statement by StepV.
uint64_t getCurrentProfileCount()
Get the profiler's current count.
CallLifetimeEnd(Address addr, llvm::Value *size)
llvm::function_ref< std::pair< llvm::Value *, llvm::Value * > CodeGenFunction &, const OMPExecutableDirective &S, Address LB, Address UB)> CodeGenDispatchBoundsTy
llvm::AllocaInst * CreateTempAlloca(llvm::Type *Ty, const Twine &Name="tmp", llvm::Value *ArraySize=nullptr)
CreateTempAlloca - This creates an alloca and inserts it into the entry block if ArraySize is nullptr...
Definition: CGExpr.cpp:90
Represents an ObjC class declaration.
Definition: DeclObjC.h:1108
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:4529
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::Value * EmitCheckedInBoundsGEP(llvm::Value *Ptr, ArrayRef< llvm::Value * > IdxList, bool SignedIndices, bool IsSubtraction, SourceLocation Loc, const Twine &Name="")
Same as IRBuilder::CreateInBoundsGEP, but additionally emits a check to detect undefined behavior whe...
llvm::AllocaInst * EHSelectorSlot
The selector slot.
QualType getType() const
Definition: Decl.h:589
llvm::Value * EmitARCRetainAutoreleasedReturnValue(llvm::Value *value)
Retain the given object which is the result of a function call.
Definition: CGObjC.cpp:2066
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:2556
void EmitCallArg(CallArgList &args, const Expr *E, QualType ArgType)
EmitCallArg - Emit a single call argument.
Definition: CGCall.cpp:3453
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:2245
~LexicalScope()
Exit this cleanup scope, emitting any accumulated cleanups.
LValue EmitLValueForField(LValue Base, const FieldDecl *Field)
Definition: CGExpr.cpp:3615
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:2645
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:3644
This represents '#pragma omp target parallel for simd' directive.
Definition: StmtOpenMP.h:3223
LValue EmitExtVectorElementExpr(const ExtVectorElementExpr *E)
Definition: CGExpr.cpp:3466
OpenMP 4.0 [2.4, Array Sections].
Definition: ExprOpenMP.h:45
RValue EmitObjCMessageExpr(const ObjCMessageExpr *E, ReturnValueSlot Return=ReturnValueSlot())
Definition: CGObjC.cpp:355
Const iterator for iterating over Stmt * arrays that contain only Expr *.
Definition: Stmt.h:329
void EmitCXXConstructExpr(const CXXConstructExpr *E, AggValueSlot Dest)
Definition: CGExprCXX.cpp:553
CleanupKind Kind
The kind of cleanup to push: a value from the CleanupKind enumeration.
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Definition: ExprCXX.h:2113
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:575
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:3129
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:2045
void EmitAlignmentAssumption(llvm::Value *PtrValue, llvm::Value *Alignment, llvm::Value *OffsetValue=nullptr)
const CodeGen::CGBlockInfo * BlockInfo
llvm::Function * GenerateBlockFunction(GlobalDecl GD, const CGBlockInfo &Info, const DeclMapTy &ldm, bool IsLambdaConversionToBlock)
Definition: CGBlocks.cpp:1225
This represents '#pragma omp taskgroup' directive.
Definition: StmtOpenMP.h:1904
const TargetCodeGenInfo & getTargetCodeGenInfo()
CGBlockInfo - Information to generate a block literal.
Definition: CGBlocks.h:149
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:198
unsigned getNumObjects() const
Definition: ExprCXX.h:2953
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.
std::vector< bool > & Stack
void EmitOMPLoopBody(const OMPLoopDirective &D, JumpDest LoopExit)
Helper for the OpenMP loop directives.
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:3002
Represents a call to the builtin function __builtin_va_arg.
Definition: Expr.h:3754
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:103
llvm::Value * ExceptionSlot
The exception slot.
This represents '#pragma omp distribute' directive.
Definition: StmtOpenMP.h:2889
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:397
Exposes information about the current target.
Definition: TargetInfo.h:54
llvm::Value * EmitARCStoreWeak(Address addr, llvm::Value *value, bool ignored)
i8* @objc_storeWeak(i8** addr, i8* value) Returns value.
Definition: CGObjC.cpp:2268
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:248
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:2474
LValue EmitInitListLValue(const InitListExpr *E)
Definition: CGExpr.cpp:3780
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:1913
CXXDtorType
C++ destructor types.
Definition: ABI.h:34
llvm::Value * getPointer() const
Definition: Address.h:38
llvm::Value * EmitBuiltinAvailable(ArrayRef< llvm::Value * > Args)
Definition: CGObjC.cpp:3423
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.
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Definition: Decl.h:580
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:602
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:2315
void EmitAutoVarInit(const AutoVarEmission &emission)
Definition: CGDecl.cpp:1201
static Address invalid()
Definition: Address.h:35
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:4234
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.
llvm::function_ref< void(CodeGenFunction &, SourceLocation, const unsigned, const bool)> CodeGenOrderedTy
void EmitCaseStmt(const CaseStmt &S)
Definition: CGStmt.cpp:1225
RValue EmitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *E)
Definition: CGExprCXX.cpp:105
llvm::Function * GenerateSEHFilterFunction(CodeGenFunction &ParentCGF, const SEHExceptStmt &Except)
Create a stub filter function that will ultimately hold the code of the filter expression.
static ParamValue forIndirect(Address addr)
void pushCallObjectDeleteCleanup(const FunctionDecl *OperatorDelete, llvm::Value *CompletePtr, QualType ElementType)
Definition: CGExprCXX.cpp:1782
void GenerateObjCMethod(const ObjCMethodDecl *OMD)
Generate an Objective-C method.
Definition: CGObjC.cpp:572
OpaqueValueMapping(CodeGenFunction &CGF, const OpaqueValueExpr *opaqueValue, RValue rvalue)
void EmitCallArgs(CallArgList &Args, const T *CallArgTypeInfo, llvm::iterator_range< CallExpr::const_arg_iterator > ArgRange, AbstractCallee AC=AbstractCallee(), unsigned ParamsToSkip=0, EvaluationOrder Order=EvaluationOrder::Default)
EmitCallArgs - Emit call arguments for a function.
void EmitOMPTeamsDirective(const OMPTeamsDirective &S)
void EmitVTableAssumptionLoad(const VPtr &vptr, Address This)
Emit assumption that vptr load == global vtable.
Definition: CGClass.cpp:2172
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:1818
static bool isObjCMethodWithTypeParams(const ObjCMethodDecl *method)
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:4820
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2551
Address EmitCompoundStmt(const CompoundStmt &S, bool GetLast=false, AggValueSlot AVS=AggValueSlot::ignored())
EmitCompoundStmt - Emit a compound statement {..} node.
Definition: CGStmt.cpp:363
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:1674
This represents '#pragma omp target teams distribute parallel for simd' combined directive.
Definition: StmtOpenMP.h:3834
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:4545
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
DeclContext * getDeclContext()
Definition: DeclBase.h:416
void EmitSEHTryStmt(const SEHTryStmt &S)
ASTContext & getContext() const
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:1502
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:1163
~OMPPrivateScope()
Exit scope - all the mapped variables are restored.
llvm::Value * getExceptionFromSlot()
Returns the contents of the function's exception object and selector slots.
This represents '#pragma omp target teams distribute simd' combined directive.
Definition: StmtOpenMP.h:3907
void EmitAsanPrologueOrEpilogue(bool Prologue)
Definition: CGClass.cpp:740
llvm::Value * EmitARCAutorelease(llvm::Value *value)
Autorelease the given object.
Definition: CGObjC.cpp:2197
void EmitStoreOfScalar(llvm::Value *Value, Address Addr, bool Volatile, QualType Ty, LValueBaseInfo BaseInfo=LValueBaseInfo(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:1527
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 EmitNullabilityCheck(LValue LHS, llvm::Value *RHS, SourceLocation Loc)
Given an assignment *LHS = RHS, emit a test that checks if RHS is nonnull, if LHS is marked _Nonnull...
Definition: CGDecl.cpp:684
void EmitLambdaExpr(const LambdaExpr *E, AggValueSlot Dest)
Definition: CGExprCXX.cpp:2155
Checking the value assigned to a _Nonnull pointer. Must not be null.
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:192
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:1037
void EmitConstructorBody(FunctionArgList &Args)
EmitConstructorBody - Emits the body of the current constructor.
Definition: CGClass.cpp:803
void EmitOMPMasterDirective(const OMPMasterDirective &S)
llvm::Function * GenerateCapturedStmtFunction(const CapturedStmt &S)
Creates the outlined function for a CapturedStmt.
Definition: CGStmt.cpp:2272
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
Definition: Stmt.h:1392
This represents '#pragma omp target teams' directive.
Definition: StmtOpenMP.h:3634
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
Address EmitPointerWithAlignment(const Expr *Addr, LValueBaseInfo *BaseInfo=nullptr)
EmitPointerWithAlignment - Given an expression with a pointer type, emit the value and compute our be...
Definition: CGExpr.cpp:896
ComplexPairTy EmitComplexPrePostIncDec(const UnaryOperator *E, LValue LV, bool isInc, bool isPre)
Definition: CGExpr.cpp:848
JumpDest(llvm::BasicBlock *Block, EHScopeStack::stable_iterator Depth, unsigned Index)
void ResolveBranchFixups(llvm::BasicBlock *Target)
Definition: CGCleanup.cpp:381
void EmitForwardingCallToLambda(const CXXMethodDecl *LambdaCallOperator, CallArgList &CallArgs)
Definition: CGClass.cpp:2719
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:1714
void EmitOMPBarrierDirective(const OMPBarrierDirective &S)
void EmitLambdaToBlockPointerBody(FunctionArgList &Args)
Definition: CGClass.cpp:2775
llvm::Value * EmitCastToVoidPtr(llvm::Value *value)
Emit a cast to void* in the appropriate address space.
Definition: CGExpr.cpp:49
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:1566
ConstantEmission tryEmitAsConstant(DeclRefExpr *refExpr)
Try to emit a reference to the given value without producing it as an l-value.
Definition: CGExpr.cpp:1264
This represents '#pragma omp cancel' directive.
Definition: StmtOpenMP.h:2693
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:1724
void EmitCXXGlobalVarDeclInit(const VarDecl &D, llvm::Constant *DeclPtr, bool PerformInit)
EmitCXXGlobalVarDeclInit - Create the initializer for a C++ variable with global storage.
Definition: CGDeclCXX.cpp:142
bool isGLValue() const
Definition: Expr.h:251
RValue EmitLoadOfBitfieldLValue(LValue LV, SourceLocation Loc)
Definition: CGExpr.cpp:1641
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:517
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:399
llvm::Value * EmitX86BuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition: CGBuiltin.cpp:7251
GlobalDecl - represents a global declaration.
Definition: GlobalDecl.h:29
This represents '#pragma omp flush' directive.
Definition: StmtOpenMP.h:1961
This represents '#pragma omp parallel for simd' directive.
Definition: StmtOpenMP.h:1565
DoStmt - This represents a 'do/while' stmt.
Definition: Stmt.h:1128
AsmStmt is the base class for GCCAsmStmt and MSAsmStmt.
Definition: Stmt.h:1440
void EmitDeclStmt(const DeclStmt &S)
Definition: CGStmt.cpp:1110
llvm::Value * EmitAMDGPUBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition: CGBuiltin.cpp:8557
LValue EmitLoadOfPointerLValue(Address Ptr, const PointerType *PtrTy)
Definition: CGExpr.cpp:2147
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:8127
void EmitAlignmentAssumption(llvm::Value *PtrValue, unsigned Alignment, llvm::Value *OffsetValue=nullptr)
void setBlockContextParameter(const ImplicitParamDecl *D, unsigned argNum, llvm::Value *ptr)
Definition: CGBlocks.cpp:1182
llvm::function_ref< void(CodeGenFunction &, const OMPLoopDirective &, JumpDest)> CodeGenLoopTy
void enterByrefCleanup(const AutoVarEmission &emission)
Enter a cleanup to destroy a __block variable.
Definition: CGBlocks.cpp:2410
CGCallee EmitCallee(const Expr *E)
Definition: CGExpr.cpp:4108
This represents '#pragma omp target enter data' directive.
Definition: StmtOpenMP.h:2321
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:305
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
Definition: Expr.h:865
bool SawAsmBlock
Whether we processed a Microsoft-style asm block during CodeGen.
RValue EmitNVPTXDevicePrintfCallExpr(const CallExpr *E, ReturnValueSlot ReturnValue)
#define false
Definition: stdbool.h:33
MSVCIntrin
Definition: CGBuiltin.cpp:484
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:308
Kind
This captures a statement into a function.
Definition: Stmt.h:2032
Represents a call to an inherited base class constructor from an inheriting constructor.
Definition: ExprCXX.h:1340
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition: Expr.h:4938
LValue EmitVAArgExprLValue(const VAArgExpr *E)
Definition: CGExpr.cpp:4219
llvm::Value * EmitCXXTypeidExpr(const CXXTypeidExpr *E)
Definition: CGExprCXX.cpp:2033
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:2332
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:1476
This represents '#pragma omp single' directive.
Definition: StmtOpenMP.h:1309
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:239
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:1805
void EmitOMPForDirective(const OMPForDirective &S)
void EmitARCRelease(llvm::Value *value, ARCPreciseLifetime_t precise)
Release the given object.
Definition: CGObjC.cpp:2090
LValue EmitDeclRefLValue(const DeclRefExpr *E)
Definition: CGExpr.cpp:2251
std::pair< LValue, llvm::Value * > EmitARCStoreUnsafeUnretained(const BinaryOperator *e, bool ignored)
Definition: CGObjC.cpp:3108
A saved depth on the scope stack.
Definition: EHScopeStack.h:107
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Definition: Expr.h:923
Represents a C++ temporary.
Definition: ExprCXX.h:1103
llvm::Value * EvaluateExprAsBool(const Expr *E)
EvaluateExprAsBool - Perform the usual unary conversions on the specified expression and compare the ...
Definition: CGExpr.cpp:139
LValue EmitCheckedLValue(const Expr *E, TypeCheckKind TCK)
Same as EmitLValue but additionally we generate checking code to guard against undefined behavior...
Definition: CGExpr.cpp:1046
~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:1516
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
void EmitVTableAssumptionLoads(const CXXRecordDecl *ClassDecl, Address This)
Emit assumption load for all bases.
Definition: CGClass.cpp:2193
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:1780
void EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S)
Definition: CGObjC.cpp:1472
const std::string ID
llvm::Value * EmitARCUnsafeClaimAutoreleasedReturnValue(llvm::Value *value)
Claim a possibly-autoreleased return value at +0.
Definition: CGObjC.cpp:2081
Represents a call to a member function that may be written either with member call syntax (e...
Definition: ExprCXX.h:136
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:1551
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.
RValue EmitCoroutineIntrinsic(const CallExpr *E, unsigned int IID)
void DeactivateCleanupBlock(EHScopeStack::stable_iterator Cleanup, llvm::Instruction *DominatingIP)
DeactivateCleanupBlock - Deactivates the given cleanup block.
Definition: CGCleanup.cpp:1230
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
Definition: Stmt.h:467
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:414
An aggregate value slot.
Definition: CGValue.h:456
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:196
const BlockByrefInfo & getBlockByrefInfo(const VarDecl *var)
BuildByrefInfo - This routine changes a __block variable declared as T x into:
Definition: CGBlocks.cpp:2189
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:617
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:1015
llvm::Value * EmitAArch64BuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition: CGBuiltin.cpp:5301
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1903
static type restore(CodeGenFunction &CGF, saved_type value)
OpenMPLinearClauseKind Modifier
Modifier of 'linear' clause.
Definition: OpenMPClause.h:86
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
This represents '#pragma omp taskwait' directive.
Definition: StmtOpenMP.h:1860
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:2189
This is a basic class for representing single OpenMP clause.
Definition: OpenMPClause.h:33
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:1187
void EmitOMPTeamsDistributeSimdDirective(const OMPTeamsDistributeSimdDirective &S)
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:5070
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:1260
llvm::Value * EmitNeonCall(llvm::Function *F, SmallVectorImpl< llvm::Value * > &O, const char *name, unsigned shift=0, bool rightshift=false)
Definition: CGBuiltin.cpp:3024
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:3429
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.
void PopCleanupBlocks(EHScopeStack::stable_iterator OldCleanupStackSize, std::initializer_list< llvm::Value ** > ValuesToReload={})
Takes the old cleanup stack size and emits the cleanup blocks that have been added.
Definition: CGCleanup.cpp:420
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:2179
This represents '#pragma omp target' directive.
Definition: StmtOpenMP.h:2205
SourceLocation getBegin() const
void EmitOMPForSimdDirective(const OMPForSimdDirective &S)
All available information about a concrete callee.
Definition: CGCall.h:66
llvm::Instruction * CurrentFuncletPad
LValue EmitPointerToDataMemberBinaryExpr(const BinaryOperator *E)
Definition: CGExpr.cpp:4507
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:397
TargetCodeGenInfo - This class organizes various target-specific codegeneration issues, like target-specific attributes, builtins and so on.
Definition: TargetInfo.h:44
Checking the object expression in a non-static data member access.
This represents '#pragma omp ordered' directive.
Definition: StmtOpenMP.h:2016
void EmitParmDecl(const VarDecl &D, ParamValue Arg, unsigned ArgNo)
EmitParmDecl - Emit a ParmVarDecl or an ImplicitParamDecl.
Definition: CGDecl.cpp:1771
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Definition: Expr.h:3464
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:836
This represents '#pragma omp target update' directive.
Definition: StmtOpenMP.h:2957
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:4061
RValue EmitBuiltinNewDeleteCall(const FunctionProtoType *Type, const Expr *Arg, bool IsDelete)
Definition: CGExprCXX.cpp:1296
llvm::Value * EmitARCRetain(QualType type, llvm::Value *value)
Produce the code to do a retain.
Definition: CGObjC.cpp:1974
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:2128
static ConstantEmission forReference(llvm::Constant *C)
void enterFullExpression(const ExprWithCleanups *E)
void EmitDecl(const Decl &D)
EmitDecl - Emit a declaration.
Definition: CGDecl.cpp:40
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:2392
CompoundAssignOperator - For compound assignments (e.g.
Definition: Expr.h:3167
void InitializeVTablePointer(const VPtr &vptr)
Initialize the vtable pointer of the given subobject.
Definition: CGClass.cpp:2342
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.
! Language semantics require right-to-left evaluation.
FunctionArgList - Type for representing both the decl and type of parameters to a function...
Definition: CGCall.h:276
QualType getType() const
Definition: Expr.h:127
llvm::BasicBlock * getMSVCDispatchBlock(EHScopeStack::stable_iterator scope)
void GenerateOpenMPCapturedVars(const CapturedStmt &S, SmallVectorImpl< llvm::Value * > &CapturedVars)
void EmitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt &S)
Definition: CGObjC.cpp:1771
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:3045
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:3358
This class organizes the cross-function state that is used while generating LLVM code.
void EmitDeclRefExprDbgValue(const DeclRefExpr *E, const APValue &Init)
void EmitOMPTargetTeamsDirective(const OMPTargetTeamsDirective &S)
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:2302
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:2554
LValue InitCapturedStruct(const CapturedStmt &S)
Definition: CGStmt.cpp:2223
[C99 6.4.2.2] - A predefined identifier such as func.
Definition: Expr.h:1185
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1215
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:1009
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
Definition: ExprCXX.h:1992
void GenerateObjCGetter(ObjCImplementationDecl *IMP, const ObjCPropertyImplDecl *PID)
GenerateObjCGetter - Synthesize an Objective-C property getter function.
Definition: CGObjC.cpp:810
StringRef Name
Definition: USRFinder.cpp:123
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:2345
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Definition: ASTMatchers.h:2126
static AggValueSlot ignored()
ignored - Returns an aggregate value slot indicating that the aggregate value is being ignored...
Definition: CGValue.h:502
CodeGenFunction::ComplexPairTy ComplexPairTy
void EmitOMPParallelForDirective(const OMPParallelForDirective &S)
llvm::Value * EmitARCLoadWeakRetained(Address addr)
i8* @objc_loadWeakRetained(i8** addr)
Definition: CGObjC.cpp:2260
void EmitAnyExprToExn(const Expr *E, Address Addr)
This represents '#pragma omp section' directive.
Definition: StmtOpenMP.h:1247
This represents '#pragma omp teams distribute' directive.
Definition: StmtOpenMP.h:3357
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:9290
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:4205
LValue EmitPseudoObjectLValue(const PseudoObjectExpr *e)
Definition: CGExpr.cpp:4635
This represents '#pragma omp simd' directive.
Definition: StmtOpenMP.h:972
Represents a 'co_yield' expression.
Definition: ExprCXX.h:4276
void EmitDelegatingCXXConstructorCall(const CXXConstructorDecl *Ctor, const FunctionArgList &Args)
Definition: CGClass.cpp:2277
void InitializeVTablePointers(const CXXRecordDecl *ClassDecl)
Definition: CGClass.cpp:2460
void EmitOMPLinearClause(const OMPLoopDirective &D, CodeGenFunction::OMPPrivateScope &PrivateScope)
Emit initial code for linear clauses.
static LValue MakeAddr(Address address, QualType type, ASTContext &Context, LValueBaseInfo BaseInfo, llvm::MDNode *TBAAInfo=nullptr)
Definition: CGValue.h:386
void EmitOMPTeamsDistributeParallelForDirective(const OMPTeamsDistributeParallelForDirective &S)
QualType TypeOfSelfObject()
TypeOfSelfObject - Return type of object that this self represents.
Definition: CGObjC.cpp:1464
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:2442
void EmitAggregateCopy(Address DestPtr, Address SrcPtr, QualType EltTy, bool isVolatile=false, bool isAssignment=false)
EmitAggregateCopy - Emit an aggregate copy.
Definition: CGExprAgg.cpp:1561
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:108
llvm::Constant * GenerateObjCAtomicGetterCopyHelperFunction(const ObjCPropertyImplDecl *PID)
Definition: CGObjC.cpp:3295
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
Definition: ASTContext.h:2087
bool isSEHTryScope() const
Returns true inside SEH __try blocks.
This represents '#pragma omp atomic' directive.
Definition: StmtOpenMP.h:2071
void EmitObjCAtThrowStmt(const ObjCAtThrowStmt &S)
Definition: CGObjC.cpp:1767
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:1557
void EmitAggExpr(const Expr *E, AggValueSlot AS)
EmitAggExpr - Emit the computation of the specified expression of aggregate type. ...
Definition: CGExprAgg.cpp:1539
void EmitCoreturnStmt(const CoreturnStmt &S)
Represents a __leave statement.
Definition: Stmt.h:1998
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)
void EmitOMPReductionClauseFinal(const OMPExecutableDirective &D, const OpenMPDirectiveKind ReductionKind)
Emit final update of reduction values to original variables at the end of the directive.
llvm::Value * EmitNeonSplat(llvm::Value *V, llvm::Constant *Idx)
Definition: CGBuiltin.cpp:3018
SwitchStmt - This represents a 'switch' stmt.
Definition: Stmt.h:983
void EmitAutoVarCleanups(const AutoVarEmission &emission)
Definition: CGDecl.cpp:1411
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2448
API for captured statement code generation.
static saved_type save(CodeGenFunction &CGF, type value)
static bool isObjCMethodWithTypeParams(const T *)
Represents the body of a coroutine.
Definition: StmtCXX.h:299
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:3784
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:5292
llvm::DebugLoc SourceLocToDebugLoc(SourceLocation Location)
Converts Location to a DebugLoc, if debug information is enabled.
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:6042
Checking the operand of a static_cast to a derived pointer type.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition: Expr.h:2118
Represents Objective-C's collection statement.
Definition: StmtObjC.h:24
AbstractConditionalOperator - An abstract base class for ConditionalOperator and BinaryConditionalOpe...
Definition: Expr.h:3203
OpaqueValueExpr * getOpaqueValue() const
getOpaqueValue - Return the opaque value placeholder.
Definition: Expr.h:3361
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:983
Implements C++ ABI-specific code generation functions.
Definition: CGCXXABI.h:44
ObjCEncodeExpr, used for @encode in Objective-C.
Definition: ExprObjC.h:355
static void EmitOMPTargetTeamsDeviceFunction(CodeGenModule &CGM, StringRef ParentName, const OMPTargetTeamsDirective &S)
LValue EmitArraySubscriptExpr(const ArraySubscriptExpr *E, bool Accessed=false)
Definition: CGExpr.cpp:3118
A stack of loop information corresponding to loop nesting levels.
Definition: CGLoopInfo.h:93
void EmitAsmStmt(const AsmStmt &S)
Definition: CGStmt.cpp:1877
llvm::Value * EmitNeonShiftVector(llvm::Value *V, llvm::Type *Ty, bool negateForRightShift)
Definition: CGBuiltin.cpp:3038
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:175
Represents a 'co_await' expression.
Definition: ExprCXX.h:4199
RValue EmitRValueForField(LValue LV, const FieldDecl *FD, SourceLocation Loc)
Definition: CGExpr.cpp:4037
void EmitLambdaStaticInvokeFunction(const CXXMethodDecl *MD)
Definition: CGClass.cpp:2816
bool has(SanitizerMask K) const
Check if a certain (single) sanitizer is enabled.
Definition: Sanitizers.h:50
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:5709
LValue EmitLValueForIvar(QualType ObjectTy, llvm::Value *Base, const ObjCIvarDecl *Ivar, unsigned CVRQualifiers)
Definition: CGExpr.cpp:4292
LValue EmitLoadOfReferenceLValue(Address Ref, const ReferenceType *RefTy)
Definition: CGExpr.cpp:2131
QualType BuildFunctionArgList(GlobalDecl GD, FunctionArgList &Args)
void EmitScalarInit(const Expr *init, const ValueDecl *D, LValue lvalue, bool capturedByInit)
Definition: CGDecl.cpp:705
Base for LValueReferenceType and RValueReferenceType.
Definition: Type.h:2360
void EmitSynthesizedCXXCopyCtor(Address Dest, Address Src, const Expr *Exp)
Definition: CGExprCXX.cpp:625
bool hasProfileClangInstr() const
Check if Clang profile instrumenation is on.
llvm::Value * EmitIvarOffset(const ObjCInterfaceDecl *Interface, const ObjCIvarDecl *Ivar)
Definition: CGExpr.cpp:4287
llvm::Value * EmitARCRetainAutorelease(QualType type, llvm::Value *value)
Do a fused retain/autorelease of the given object.
Definition: CGObjC.cpp:2228
LValue EmitCastLValue(const CastExpr *E)
EmitCastLValue - Casts are never lvalues unless that cast is to a reference type. ...
Definition: CGExpr.cpp:3889
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
EmitBlock - Emit the given block.
Definition: CGStmt.cpp:436
void EmitOMPTargetEnterDataDirective(const OMPTargetEnterDataDirective &S)
void EmitARCInitWeak(Address addr, llvm::Value *value)
i8* @objc_initWeak(i8** addr, i8* value) Returns value.
Definition: CGObjC.cpp:2280
void EnterCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock=false)
void checkTargetFeatures(const CallExpr *E, const FunctionDecl *TargetDecl)
const ParmVarDecl * getParamDecl(unsigned I) const
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
Definition: APValue.h:38
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.
void EmitMCountInstrumentation()
EmitMCountInstrumentation - Emit call to .mcount.
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:206
LValue EmitConditionalOperatorLValue(const AbstractConditionalOperator *E)
Definition: CGExpr.cpp:3804
void EmitOMPDistributeSimdDirective(const OMPDistributeSimdDirective &S)
VPtrsVector getVTablePointers(const CXXRecordDecl *VTableClass)
Definition: CGClass.cpp:2392
const Decl * CurFuncDecl
CurFuncDecl - Holds the Decl for the current outermost non-closure context.
A pair of helper functions for a __block variable.
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:1250
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:13074
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:2378
void unprotectFromPeepholes(PeepholeProtection protection)
void EmitOMPReductionClauseInit(const OMPExecutableDirective &D, OMPPrivateScope &PrivateScope)
Emit initial code for reduction variables.
void EmitCallAndReturnForThunk(llvm::Constant *Callee, const ThunkInfo *Thunk)
Definition: CGVTables.cpp:255
A non-RAII class containing all the information about a bound opaque value.
This represents '#pragma omp target parallel' directive.
Definition: StmtOpenMP.h:2438
void EmitOMPTargetTeamsDistributeDirective(const OMPTargetTeamsDistributeDirective &S)
void ErrorUnsupported(const Stmt *S, const char *Type)
ErrorUnsupported - Print out an error that codegen doesn't support the specified stmt yet...
true
A convenience builder class for complex constant initializers, especially for anonymous global struct...
Represents a C++ struct/union/class.
Definition: DeclCXX.h:267
void EmitIfStmt(const IfStmt &S)
Definition: CGStmt.cpp:609
llvm::Value * EmitObjCCollectionLiteral(const Expr *E, const ObjCMethodDecl *MethodWithObjects)
Definition: CGObjC.cpp:113
ContinueStmt - This represents a continue.
Definition: Stmt.h:1328
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:456
llvm::PointerIntPair< llvm::Value *, 1, bool > saved_type
LValue EmitCoawaitLValue(const CoawaitExpr *E)
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:1026
llvm::Function * LookupNeonLLVMIntrinsic(unsigned IntrinsicID, unsigned Modifier, llvm::Type *ArgTy, const CallExpr *E)
Definition: CGBuiltin.cpp:3684
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
Definition: Expr.h:3318
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:2170
static bool IsConstructorDelegationValid(const CXXConstructorDecl *Ctor)
Checks whether the given constructor is a valid subject for the complete-to-base constructor delegati...
Definition: CGClass.cpp:692
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1866
LValue MakeAddrLValue(Address Addr, QualType T, LValueBaseInfo BaseInfo=LValueBaseInfo(AlignmentSource::Type))
static type restore(CodeGenFunction &CGF, saved_type value)
! No language constraints on evaluation order.
WhileStmt - This represents a 'while' stmt.
Definition: Stmt.h:1073
void EmitCXXDeleteExpr(const CXXDeleteExpr *E)
Definition: CGExprCXX.cpp:1921
void EmitOMPUseDevicePtrClause(const OMPClause &C, OMPPrivateScope &PrivateScope, const llvm::DenseMap< const ValueDecl *, Address > &CaptureDeviceAddrMap)
LValue EmitLValue(const Expr *E)
EmitLValue - Emit code to compute a designator that specifies the location of the expression...
Definition: CGExpr.cpp:1082
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:2975
void pushStackRestore(CleanupKind kind, Address SPMem)
Definition: CGDecl.cpp:1492
void EmitLabelStmt(const LabelStmt &S)
Definition: CGStmt.cpp:552
unsigned kind
All of the diagnostics that can be emitted by the frontend.
Definition: DiagnosticIDs.h:44
Represents Objective-C's @try ... @catch ... @finally statement.
Definition: StmtObjC.h:154
llvm::Value * EmitSEHAbnormalTermination()
LValue EmitCompoundLiteralLValue(const CompoundLiteralExpr *E)
Definition: CGExpr.cpp:3760
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:1595
llvm::Value * EmitARCRetainBlock(llvm::Value *value, bool mandatory)
Retain the given block, with _Block_copy semantics.
Definition: CGObjC.cpp:1995
This represents '#pragma omp taskloop simd' directive.
Definition: StmtOpenMP.h:2823
LValue EmitPredefinedLValue(const PredefinedExpr *E)
Definition: CGExpr.cpp:2476
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:879
void EmitVTablePtrCheckForCall(const CXXRecordDecl *RD, llvm::Value *VTable, CFITypeCheckKind TCK, SourceLocation Loc)
EmitVTablePtrCheckForCall - Virtual method MD is being called via VTable.
Definition: CGClass.cpp:2544
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1506
Defines the clang::TargetInfo interface.
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:2206
static bool IsWrappedCXXThis(const Expr *E)
Check if E is a C++ "this" pointer wrapped in value-preserving casts.
Definition: CGExpr.cpp:1023
Address EmitCXXUuidofExpr(const CXXUuidofExpr *E)
Definition: CGExpr.cpp:4238
void StartObjCMethod(const ObjCMethodDecl *MD, const ObjCContainerDecl *CD)
StartObjCMethod - Begin emission of an ObjCMethod.
Definition: CGObjC.cpp:532
llvm::MDNode * getTBAAInfo(QualType QTy)
Address EmitExtVectorElementLValue(LValue V)
Generates lvalue for partial ext_vector access.
Definition: CGExpr.cpp:1702
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...
const llvm::function_ref< void(CodeGenFunction &, llvm::Value *, const OMPTaskDataTy &)> TaskGenTy
void EmitObjCAutoreleasePoolCleanup(llvm::Value *Ptr)
Definition: CGObjC.cpp:2445
This represents '#pragma omp sections' directive.
Definition: StmtOpenMP.h:1179
LValue EmitMemberExpr(const MemberExpr *E)
Definition: CGExpr.cpp:3522
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:2263
void EmitOMPTargetExitDataDirective(const OMPTargetExitDataDirective &S)
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:953
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:995
void EmitDestructorBody(FunctionArgList &Args)
EmitDestructorBody - Emits the body of the current destructor.
Definition: CGClass.cpp:1389
bool EmitSimpleStmt(const Stmt *S)
EmitSimpleStmt - Try to emit a "simple" statement which does not necessarily require an insertion poi...
Definition: CGStmt.cpp:340
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:2827
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:1354
static void EmitOMPTargetDeviceFunction(CodeGenModule &CGM, StringRef ParentName, const OMPTargetDirective &S)
Emit device code for the target directive.
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:1034
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:2591
Address EmitCompoundStmtWithoutScope(const CompoundStmt &S, bool GetLast=false, AggValueSlot AVS=AggValueSlot::ignored())
Definition: CGStmt.cpp:375
void EmitOMPDistributeParallelForDirective(const OMPDistributeParallelForDirective &S)
llvm::Value * LoadObjCSelf()
LoadObjCSelf - Load the value of self.
Definition: CGObjC.cpp:1457
CodeGenTypes & getTypes() const
A trivial tuple used to represent a source range.
void EmitObjCAtTryStmt(const ObjCAtTryStmt &S)
Definition: CGObjC.cpp:1763
LValue - This represents an lvalue references.
Definition: CGValue.h:171
An abstract representation of regular/ObjC call/message targets.
llvm::BlockAddress * GetAddrOfLabel(const LabelDecl *L)
void EmitWhileStmt(const WhileStmt &S, ArrayRef< const Attr * > Attrs=None)
Definition: CGStmt.cpp:686
This represents '#pragma omp taskyield' directive.
Definition: StmtOpenMP.h:1772
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:3086
llvm::Value * EmitObjCConsumeObject(QualType T, llvm::Value *Ptr)
Produce the code for a CK_ARCConsumeObject.
Definition: CGObjC.cpp:1790
Represents a C array with a specified size that is not an integer-constant-expression.
Definition: Type.h:2648
This represents '#pragma omp parallel sections' directive.
Definition: StmtOpenMP.h:1633
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition: ExprCXX.h:799
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:473
void EmitCfiCheckStub()
Emit a stub for the cross-DSO CFI check function.
Definition: CGExpr.cpp:2873
LValue MakeAddrLValue(llvm::Value *V, QualType T, CharUnits Alignment, LValueBaseInfo BaseInfo=LValueBaseInfo(AlignmentSource::Type))
void EmitBreakStmt(const BreakStmt &S)
Definition: CGStmt.cpp:1120
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:450
void EmitObjCAutoreleasePoolStmt(const ObjCAutoreleasePoolStmt &S)
Definition: CGObjC.cpp:3167
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:182
OpaqueValueMapping(CodeGenFunction &CGF, const OpaqueValueExpr *opaqueValue, LValue lvalue)
Address CreateMemTemp(QualType T, const Twine &Name="tmp", bool CastToDefaultAddrSpace=true)
CreateMemTemp - Create a temporary memory object of the given type, with appropriate alignment...
Definition: CGExpr.cpp:123
void PopCleanupBlock(bool FallThroughIsBranchThrough=false)
PopCleanupBlock - Will pop the cleanup entry on the stack and process all branch fixups.
Definition: CGCleanup.cpp:640
Represents Objective-C's @autoreleasepool Statement.
Definition: StmtObjC.h:345
OpaqueValueMapping(CodeGenFunction &CGF, const OpaqueValueExpr *OV)
Build the opaque value mapping for an OpaqueValueExpr whose source expression is set to the expressio...
LValue EmitStringLiteralLValue(const StringLiteral *E)
Definition: CGExpr.cpp:2464
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:2152
void EmitCXXThrowExpr(const CXXThrowExpr *E, bool KeepInsertionPoint=true)
const NamedDecl * Result
Definition: USRFinder.cpp:70
llvm::Value * EmitVTableTypeCheckedLoad(const CXXRecordDecl *RD, llvm::Value *VTable, uint64_t VTableByteOffset)
Emit a type checked load from the given vtable.
Definition: CGClass.cpp:2694
This represents '#pragma omp target parallel for' directive.
Definition: StmtOpenMP.h:2498
llvm::Value * EmitTargetBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
EmitTargetBuiltinExpr - Emit the given builtin call.
Definition: CGBuiltin.cpp:2962
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:1704
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:2384
RValue EmitCall(const CGFunctionInfo &CallInfo, const CGCallee &Callee, ReturnValueSlot ReturnValue, const CallArgList &Args, 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:3695
llvm::SmallVector< const JumpDest *, 2 > SEHTryEpilogueStack
void EmitOMPTargetTeamsDistributeParallelForDirective(const OMPTargetTeamsDistributeParallelForDirective &S)
llvm::Value * EmitSystemZBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition: CGBuiltin.cpp:8725
bool Privatize()
Privatizes local variables previously registered as private.
bool hasLabelBeenSeenInCurrentScope() const
Return true if a label was seen in the current scope.
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:346
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Definition: Type.h:5516
llvm::Value * EmitObjCSelectorExpr(const ObjCSelectorExpr *E)
Emit a selector.
Definition: CGObjC.cpp:249
void Destroyer(CodeGenFunction &CGF, Address addr, QualType ty)
llvm::Value * EmitObjCProtocolExpr(const ObjCProtocolExpr *E)
Definition: CGObjC.cpp:257
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:553
This represents '#pragma omp taskloop' directive.
Definition: StmtOpenMP.h:2758