clang 24.0.0git
CodeGenFunction.h
Go to the documentation of this file.
1//===-- CodeGenFunction.h - Per-Function state for LLVM CodeGen -*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This is the internal per-function state used for llvm translation.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_LIB_CODEGEN_CODEGENFUNCTION_H
14#define LLVM_CLANG_LIB_CODEGEN_CODEGENFUNCTION_H
15
16#include "CGBuilder.h"
17#include "CGLoopInfo.h"
18#include "CGValue.h"
19#include "CodeGenModule.h"
20#include "EHScopeStack.h"
21#include "SanitizerHandler.h"
22#include "VarBypassDetector.h"
23#include "clang/AST/Attr.h"
24#include "clang/AST/CharUnits.h"
26#include "clang/AST/ExprCXX.h"
27#include "clang/AST/ExprObjC.h"
31#include "clang/AST/StmtSYCL.h"
32#include "clang/AST/Type.h"
33#include "clang/Basic/ABI.h"
40#include "llvm/ADT/ArrayRef.h"
41#include "llvm/ADT/DenseMap.h"
42#include "llvm/ADT/MapVector.h"
43#include "llvm/ADT/SmallVector.h"
44#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
45#include "llvm/IR/Instructions.h"
46#include "llvm/IR/ValueHandle.h"
47#include "llvm/Support/Debug.h"
48#include "llvm/Transforms/Utils/SanitizerStats.h"
49#include <optional>
50
51namespace llvm {
52class BasicBlock;
53class ConvergenceControlInst;
54class LLVMContext;
55class MDNode;
56class SwitchInst;
57class Twine;
58class Value;
59class CanonicalLoopInfo;
60} // namespace llvm
61
62namespace clang {
63class ASTContext;
66class CXXForRangeStmt;
67class CXXTryStmt;
68class Decl;
69class LabelDecl;
70class FunctionDecl;
72class LabelStmt;
75class ObjCIvarDecl;
76class ObjCMethodDecl;
79class TargetInfo;
80class VarDecl;
82class ObjCAtTryStmt;
83class ObjCAtThrowStmt;
86class OMPUseDevicePtrClause;
87class OMPUseDeviceAddrClause;
88class SVETypeFlags;
89class OMPExecutableDirective;
90
91namespace analyze_os_log {
93}
94
95namespace CodeGen {
96class CodeGenTypes;
97class CodeGenPGO;
98class CGCallee;
99class CGFunctionInfo;
100class CGBlockInfo;
101class CGCXXABI;
103class BlockByrefInfo;
104class BlockFieldFlags;
105class RegionCodeGenTy;
107struct OMPTaskDataTy;
108struct CGCoroData;
109
110// clang-format off
111/// The kind of evaluation to perform on values of a particular
112/// type. Basically, is the code in CGExprScalar, CGExprComplex, or
113/// CGExprAgg?
114///
115/// TODO: should vectors maybe be split out into their own thing?
121// clang-format on
122
123/// Helper class with most of the code for saving a value for a
124/// conditional expression cleanup.
126 struct saved_type {
127 llvm::Value *Value; // Original value if not saved, alloca if saved
128 llvm::Type *Type; // nullptr if not saved, element type if saved
129
131 saved_type(llvm::Value *V) : Value(V), Type(nullptr) {}
132 saved_type(llvm::AllocaInst *Alloca, llvm::Type *Ty)
133 : Value(Alloca), Type(Ty) {}
134
135 bool isSaved() const { return Type != nullptr; }
136 };
137
138 /// Answer whether the given value needs extra work to be saved.
139 static bool needsSaving(llvm::Value *value) {
140 if (!value)
141 return false;
142
143 // If it's not an instruction, we don't need to save.
144 if (!isa<llvm::Instruction>(value))
145 return false;
146
147 // If it's an instruction in the entry block, we don't need to save.
148 llvm::BasicBlock *block = cast<llvm::Instruction>(value)->getParent();
149 return (block != &block->getParent()->getEntryBlock());
150 }
151
152 static saved_type save(CodeGenFunction &CGF, llvm::Value *value);
153 static llvm::Value *restore(CodeGenFunction &CGF, saved_type value);
154};
155
156/// A partial specialization of DominatingValue for llvm::Values that
157/// might be llvm::Instructions.
158template <class T> struct DominatingPointer<T, true> : DominatingLLVMValue {
159 typedef T *type;
161 return static_cast<T *>(DominatingLLVMValue::restore(CGF, value));
162 }
163};
164
165/// A specialization of DominatingValue for Address.
166template <> struct DominatingValue<Address> {
167 typedef Address type;
168
176
177 static bool needsSaving(type value) {
180 return true;
181 return false;
182 }
183 static saved_type save(CodeGenFunction &CGF, type value) {
184 return {DominatingLLVMValue::save(CGF, value.getBasePointer()),
185 value.getElementType(), value.getAlignment(),
186 DominatingLLVMValue::save(CGF, value.getOffset()), value.getType()};
187 }
192 }
193};
194
195/// A specialization of DominatingValue for RValue.
196template <> struct DominatingValue<RValue> {
197 typedef RValue type;
198 class saved_type {
199 enum Kind {
200 ScalarLiteral,
201 ScalarAddress,
202 AggregateLiteral,
203 AggregateAddress,
204 ComplexAddress
205 };
206 union {
207 struct {
209 } Vals;
211 };
212 LLVM_PREFERRED_TYPE(Kind)
213 unsigned K : 3;
214
216 : Vals{Val1, DominatingLLVMValue::saved_type()}, K(K) {}
217
220 : Vals{Val1, Val2}, K(ComplexAddress) {}
221
222 saved_type(DominatingValue<Address>::saved_type AggregateAddr, unsigned K)
223 : AggregateAddr(AggregateAddr), K(K) {}
224
225 public:
226 static bool needsSaving(RValue value);
227 static saved_type save(CodeGenFunction &CGF, RValue value);
229
230 // implementations in CGCleanup.cpp
231 };
232
233 static bool needsSaving(type value) { return saved_type::needsSaving(value); }
234 static saved_type save(CodeGenFunction &CGF, type value) {
235 return saved_type::save(CGF, value);
236 }
238 return value.restore(CGF);
239 }
240};
241
242/// A scoped helper to set the current source atom group for
243/// CGDebugInfo::addInstToCurrentSourceAtom. A source atom is a source construct
244/// that is "interesting" for debug stepping purposes. We use an atom group
245/// number to track the instruction(s) that implement the functionality for the
246/// atom, plus backup instructions/source locations.
247class ApplyAtomGroup {
248 uint64_t OriginalAtom = 0;
249 CGDebugInfo *DI = nullptr;
250
251 ApplyAtomGroup(const ApplyAtomGroup &) = delete;
252 void operator=(const ApplyAtomGroup &) = delete;
253
254public:
255 ApplyAtomGroup(CGDebugInfo *DI);
257};
258
259/// CodeGenFunction - This class organizes the per-function state that is used
260/// while generating LLVM code.
261class CodeGenFunction : public CodeGenTypeCache {
262 CodeGenFunction(const CodeGenFunction &) = delete;
263 void operator=(const CodeGenFunction &) = delete;
264
265 friend class CGCXXABI;
267
268public:
269 /// A jump destination is an abstract label, branching to which may
270 /// require a jump out through normal cleanups.
271 struct JumpDest {
272 JumpDest() : Block(nullptr), Index(0) {}
273 JumpDest(llvm::BasicBlock *Block, EHScopeStack::stable_iterator Depth,
274 unsigned Index)
275 : Block(Block), ScopeDepth(Depth), Index(Index) {}
276
277 bool isValid() const { return Block != nullptr; }
278 llvm::BasicBlock *getBlock() const { return Block; }
279 EHScopeStack::stable_iterator getScopeDepth() const { return ScopeDepth; }
280 unsigned getDestIndex() const { return Index; }
281
282 // This should be used cautiously.
284 ScopeDepth = depth;
285 }
286
287 private:
288 llvm::BasicBlock *Block;
290 unsigned Index;
291 };
292
293 CodeGenModule &CGM; // Per-module state.
295
296 // For EH/SEH outlined funclets, this field points to parent's CGF
297 CodeGenFunction *ParentCGF = nullptr;
298
299 typedef std::pair<llvm::Value *, llvm::Value *> ComplexPairTy;
302
303 // Stores variables for which we can't generate correct lifetime markers
304 // because of jumps.
306
307 // Addresses of bypassed variables, for re-emitting their
308 // trivial-auto-var-init at a jump that re-enters their scope.
309 llvm::SmallDenseMap<const VarDecl *, Address, 4> BypassedVarInits;
310
311 // Jumps, like gotos or switches, that may bypass a declaration that has not
312 // been emitted yet. EmitAutoVarAlloca patches the init in before the jump
313 // once the alloca exists.
315 llvm::AssertingVH<llvm::BasicBlock> Block;
316 const Stmt *Source;
317 };
319
320 /// List of recently emitted OMPCanonicalLoops.
321 ///
322 /// Since OMPCanonicalLoops are nested inside other statements (in particular
323 /// CapturedStmt generated by OMPExecutableDirective and non-perfectly nested
324 /// loops), we cannot directly call OMPEmitOMPCanonicalLoop and receive its
325 /// llvm::CanonicalLoopInfo. Instead, we call EmitStmt and any
326 /// OMPEmitOMPCanonicalLoop called by it will add its CanonicalLoopInfo to
327 /// this stack when done. Entering a new loop requires clearing this list; it
328 /// either means we start parsing a new loop nest (in which case the previous
329 /// loop nest goes out of scope) or a second loop in the same level in which
330 /// case it would be ambiguous into which of the two (or more) loops the loop
331 /// nest would extend.
333
334 /// Stack to track the controlled convergence tokens.
336
337 /// Number of nested loop to be consumed by the last surrounding
338 /// loop-associated directive.
340
341 // CodeGen lambda for loops and support for ordered clause
342 typedef llvm::function_ref<void(CodeGenFunction &, const OMPLoopDirective &,
343 JumpDest)>
345 typedef llvm::function_ref<void(CodeGenFunction &, SourceLocation,
346 const unsigned, const bool)>
348
349 // Codegen lambda for loop bounds in worksharing loop constructs
350 typedef llvm::function_ref<std::pair<LValue, LValue>(
351 CodeGenFunction &, const OMPExecutableDirective &S)>
353
354 // Codegen lambda for loop bounds in dispatch-based loop implementation
355 typedef llvm::function_ref<std::pair<llvm::Value *, llvm::Value *>(
356 CodeGenFunction &, const OMPExecutableDirective &S, Address LB,
357 Address UB)>
359
360 /// CGBuilder insert helper. This function is called after an
361 /// instruction is created using Builder.
362 void InsertHelper(llvm::Instruction *I, const llvm::Twine &Name,
363 llvm::BasicBlock::iterator InsertPt) const;
364
365 /// CurFuncDecl - Holds the Decl for the current outermost
366 /// non-closure context.
367 const Decl *CurFuncDecl = nullptr;
368 /// CurCodeDecl - This is the inner-most code context, which includes blocks.
369 const Decl *CurCodeDecl = nullptr;
370 const CGFunctionInfo *CurFnInfo = nullptr;
372 llvm::Function *CurFn = nullptr;
373
374 /// If a cast expression is being visited, this holds the current cast's
375 /// expression.
376 const CastExpr *CurCast = nullptr;
377
378 /// Save Parameter Decl for coroutine.
380
381 // Holds coroutine data if the current function is a coroutine. We use a
382 // wrapper to manage its lifetime, so that we don't have to define CGCoroData
383 // in this header.
384 struct CGCoroInfo {
385 std::unique_ptr<CGCoroData> Data;
386 bool InSuspendBlock = false;
387 CGCoroInfo();
388 ~CGCoroInfo();
389 };
391
392 bool isCoroutine() const { return CurCoro.Data != nullptr; }
393
394 bool inSuspendBlock() const {
395 return isCoroutine() && CurCoro.InSuspendBlock;
396 }
397
398 // Holds FramePtr for await_suspend wrapper generation,
399 // so that __builtin_coro_frame call can be lowered
400 // directly to value of its second argument
402 llvm::Value *FramePtr = nullptr;
403 };
405
406 // Generates wrapper function for `llvm.coro.await.suspend.*` intrinisics.
407 // It encapsulates SuspendExpr in a function, to separate it's body
408 // from the main coroutine to avoid miscompilations. Intrinisic
409 // is lowered to this function call in CoroSplit pass
410 // Function signature is:
411 // <type> __await_suspend_wrapper_<name>(ptr %awaiter, ptr %hdl)
412 // where type is one of (void, i1, ptr)
413 llvm::Function *generateAwaitSuspendWrapper(Twine const &CoroName,
414 Twine const &SuspendPointName,
415 CoroutineSuspendExpr const &S);
416
417 /// CurGD - The GlobalDecl for the current function being compiled.
419
420 /// PrologueCleanupDepth - The cleanup depth enclosing all the
421 /// cleanups associated with the parameters.
423
424 /// ReturnBlock - Unified return block.
426
427 /// ReturnValue - The temporary alloca to hold the return
428 /// value. This is invalid iff the function has no return value.
430
431 /// ReturnValuePointer - The temporary alloca to hold a pointer to sret.
432 /// This is invalid if sret is not in use.
434
435 /// If a return statement is being visited, this holds the return statment's
436 /// result expression.
437 const Expr *RetExpr = nullptr;
438
439 /// Return true if a label was seen in the current scope.
441 if (CurLexicalScope)
442 return CurLexicalScope->hasLabels();
443 return !LabelMap.empty();
444 }
445
446 /// AllocaInsertPoint - This is an instruction in the entry block before which
447 /// we prefer to insert allocas.
448 llvm::AssertingVH<llvm::Instruction> AllocaInsertPt;
449
450private:
451 /// PostAllocaInsertPt - This is a place in the prologue where code can be
452 /// inserted that will be dominated by all the static allocas. This helps
453 /// achieve two things:
454 /// 1. Contiguity of all static allocas (within the prologue) is maintained.
455 /// 2. All other prologue code (which are dominated by static allocas) do
456 /// appear in the source order immediately after all static allocas.
457 ///
458 /// PostAllocaInsertPt will be lazily created when it is *really* required.
459 llvm::AssertingVH<llvm::Instruction> PostAllocaInsertPt = nullptr;
460
461public:
462 /// Return PostAllocaInsertPt. If it is not yet created, then insert it
463 /// immediately after AllocaInsertPt.
464 llvm::Instruction *getPostAllocaInsertPoint() {
465 if (!PostAllocaInsertPt) {
466 assert(AllocaInsertPt &&
467 "Expected static alloca insertion point at function prologue");
468 assert(AllocaInsertPt->getParent()->isEntryBlock() &&
469 "EBB should be entry block of the current code gen function");
470 PostAllocaInsertPt = AllocaInsertPt->clone();
471 PostAllocaInsertPt->setName("postallocapt");
472 PostAllocaInsertPt->insertAfter(AllocaInsertPt->getIterator());
473 }
474
475 return PostAllocaInsertPt;
476 }
477
478 // Try to preserve the source's name to make IR more readable.
479 llvm::Value *performAddrSpaceCast(llvm::Value *Src, llvm::Type *DestTy) {
480 return Builder.CreateAddrSpaceCast(
481 Src, DestTy, Src->hasName() ? Src->getName() + ".ascast" : "");
482 }
483
484 /// API for captured statement code generation.
486 public:
488 : Kind(K), ThisValue(nullptr), CXXThisFieldDecl(nullptr) {}
491 : Kind(K), ThisValue(nullptr), CXXThisFieldDecl(nullptr) {
492
494 S.getCapturedRecordDecl()->field_begin();
496 E = S.capture_end();
497 I != E; ++I, ++Field) {
498 if (I->capturesThis())
499 CXXThisFieldDecl = *Field;
500 else if (I->capturesVariable())
501 CaptureFields[I->getCapturedVar()->getCanonicalDecl()] = *Field;
502 else if (I->capturesVariableByCopy())
503 CaptureFields[I->getCapturedVar()->getCanonicalDecl()] = *Field;
504 }
505 }
506
507 virtual ~CGCapturedStmtInfo();
508
509 CapturedRegionKind getKind() const { return Kind; }
510
511 virtual void setContextValue(llvm::Value *V) { ThisValue = V; }
512 // Retrieve the value of the context parameter.
513 virtual llvm::Value *getContextValue() const { return ThisValue; }
514
515 /// Lookup the captured field decl for a variable.
516 virtual const FieldDecl *lookup(const VarDecl *VD) const {
517 return CaptureFields.lookup(VD->getCanonicalDecl());
518 }
519
520 bool isCXXThisExprCaptured() const { return getThisFieldDecl() != nullptr; }
521 virtual FieldDecl *getThisFieldDecl() const { return CXXThisFieldDecl; }
522
523 static bool classof(const CGCapturedStmtInfo *) { return true; }
524
525 /// Emit the captured statement body.
526 virtual void EmitBody(CodeGenFunction &CGF, const Stmt *S) {
528 CGF.EmitStmt(S);
529 }
530
531 /// Get the name of the capture helper.
532 virtual StringRef getHelperName() const { return "__captured_stmt"; }
533
534 /// Get the CaptureFields
535 llvm::SmallDenseMap<const VarDecl *, FieldDecl *> getCaptureFields() {
536 return CaptureFields;
537 }
538
539 private:
540 /// The kind of captured statement being generated.
542
543 /// Keep the map between VarDecl and FieldDecl.
544 llvm::SmallDenseMap<const VarDecl *, FieldDecl *> CaptureFields;
545
546 /// The base address of the captured record, passed in as the first
547 /// argument of the parallel region function.
548 llvm::Value *ThisValue;
549
550 /// Captured 'this' type.
551 FieldDecl *CXXThisFieldDecl;
552 };
554
555 /// RAII for correct setting/restoring of CapturedStmtInfo.
557 private:
558 CodeGenFunction &CGF;
559 CGCapturedStmtInfo *PrevCapturedStmtInfo;
560
561 public:
562 CGCapturedStmtRAII(CodeGenFunction &CGF,
563 CGCapturedStmtInfo *NewCapturedStmtInfo)
564 : CGF(CGF), PrevCapturedStmtInfo(CGF.CapturedStmtInfo) {
565 CGF.CapturedStmtInfo = NewCapturedStmtInfo;
566 }
567 ~CGCapturedStmtRAII() { CGF.CapturedStmtInfo = PrevCapturedStmtInfo; }
568 };
569
570 /// An abstract representation of regular/ObjC call/message targets.
572 /// The function declaration of the callee.
573 const Decl *CalleeDecl;
574
575 public:
576 AbstractCallee() : CalleeDecl(nullptr) {}
577 AbstractCallee(const FunctionDecl *FD) : CalleeDecl(FD) {}
578 AbstractCallee(const ObjCMethodDecl *OMD) : CalleeDecl(OMD) {}
579 bool hasFunctionDecl() const {
580 return isa_and_nonnull<FunctionDecl>(CalleeDecl);
581 }
582 const Decl *getDecl() const { return CalleeDecl; }
583 unsigned getNumParams() const {
584 if (const auto *FD = dyn_cast<FunctionDecl>(CalleeDecl))
585 return FD->getNumParams();
586 return cast<ObjCMethodDecl>(CalleeDecl)->param_size();
587 }
588 const ParmVarDecl *getParamDecl(unsigned I) const {
589 if (const auto *FD = dyn_cast<FunctionDecl>(CalleeDecl))
590 return FD->getParamDecl(I);
591 return *(cast<ObjCMethodDecl>(CalleeDecl)->param_begin() + I);
592 }
593 };
594
595 /// Sanitizers enabled for this function.
597
598 /// True if CodeGen currently emits code implementing sanitizer checks.
599 bool IsSanitizerScope = false;
600
601 /// RAII object to set/unset CodeGenFunction::IsSanitizerScope.
603 CodeGenFunction *CGF;
604
605 public:
606 SanitizerScope(CodeGenFunction *CGF);
608 };
609
610 /// In C++, whether we are code generating a thunk. This controls whether we
611 /// should emit cleanups.
612 bool CurFuncIsThunk = false;
613
614 /// In ARC, whether we should autorelease the return value.
615 bool AutoreleaseResult = false;
616
617 /// Whether we processed a Microsoft-style asm block during CodeGen. These can
618 /// potentially set the return value.
619 bool SawAsmBlock = false;
620
622
623 /// True if the current function is an outlined SEH helper. This can be a
624 /// finally block or filter expression.
626
627 /// True if CodeGen currently emits code inside presereved access index
628 /// region.
630
631 /// True if CodeGen currently emits the argument of
632 /// __builtin_preserve_field_info.
634
635 /// True if the current statement has nomerge attribute.
637
638 /// True if the current statement has noinline attribute.
640
641 /// True if the current statement has always_inline attribute.
643
644 /// True if the current statement has noconvergent attribute.
646
647 /// The mode string from the amdgpu_av attribute on the current statement,
648 /// or empty if the attribute is not present.
650
651 /// HLSL Branch attribute.
652 HLSLControlFlowHintAttr::Spelling HLSLControlFlowAttr =
653 HLSLControlFlowHintAttr::SpellingNotCalculated;
654
655 // The CallExpr within the current statement that the musttail attribute
656 // applies to. nullptr if there is no 'musttail' on the current statement.
657 const CallExpr *MustTailCall = nullptr;
658
659 /// Records the l-value that ScalarExprEmitter loads from when it emits a
660 /// specific expression. EmitArraySubscriptExpr sets this while emitting the
661 /// base of a 'counted_by' pointer subscript, so that the bounds check can
662 /// locate the count from the pointer field's address without re-emitting
663 /// (and so re-evaluating) the base. Capturing the l-value, instead of
664 /// emitting the load separately, keeps everything else the scalar load path
665 /// does (debug locations, 'align_value' assumptions, pseudo variables for
666 /// -fdebug-info-for-profiling, etc.).
668 /// The expression whose l-value is recorded.
669 const Expr *E;
670 /// The recorded l-value, set if \c E was loaded by ScalarExprEmitter.
671 std::optional<LValue> LV;
672 };
674
675 /// Returns true if a function must make progress, which means the
676 /// mustprogress attribute can be added.
678 if (CGM.getCodeGenOpts().getFiniteLoops() ==
680 return false;
681
682 // C++11 and later guarantees that a thread eventually will do one of the
683 // following (C++11 [intro.multithread]p24 and C++17 [intro.progress]p1):
684 // - terminate,
685 // - make a call to a library I/O function,
686 // - perform an access through a volatile glvalue, or
687 // - perform a synchronization operation or an atomic operation.
688 //
689 // Hence each function is 'mustprogress' in C++11 or later.
690 return getLangOpts().CPlusPlus11;
691 }
692
693 /// Returns true if a loop must make progress, which means the mustprogress
694 /// attribute can be added. \p HasConstantCond indicates whether the branch
695 /// condition is a known constant.
696 bool checkIfLoopMustProgress(const Expr *, bool HasEmptyBody);
697
699 llvm::Value *BlockPointer = nullptr;
700
701 llvm::DenseMap<const ValueDecl *, FieldDecl *> LambdaCaptureFields;
703
704 /// A mapping from NRVO variables to the flags used to indicate
705 /// when the NRVO has been applied to this variable.
706 llvm::DenseMap<const VarDecl *, llvm::Value *> NRVOFlags;
707
710
711 // A stack of cleanups which were added to EHStack but have to be deactivated
712 // later before being popped or emitted. These are usually deactivated on
713 // exiting a `CleanupDeactivationScope` scope. For instance, after a
714 // full-expr.
715 //
716 // These are specially useful for correctly emitting cleanups while
717 // encountering branches out of expression (through stmt-expr or coroutine
718 // suspensions).
724
725 // Enters a new scope for capturing cleanups which are deferred to be
726 // deactivated, all of which will be deactivated once the scope is exited.
728 CodeGenFunction &CGF;
735
737 assert(!Deactivated && "Deactivating already deactivated scope");
738 auto &Stack = CGF.DeferredDeactivationCleanupStack;
739 for (size_t I = Stack.size(); I > OldDeactivateCleanupStackSize; I--) {
740 CGF.DeactivateCleanupBlock(Stack[I - 1].Cleanup,
741 Stack[I - 1].DominatingIP);
742 Stack[I - 1].DominatingIP->eraseFromParent();
743 }
744 Stack.resize(OldDeactivateCleanupStackSize);
745 Deactivated = true;
746 }
747
749 if (Deactivated)
750 return;
752 }
753 };
754
756
757 llvm::Instruction *CurrentFuncletPad = nullptr;
758
759 class CallLifetimeEnd final : public EHScopeStack::Cleanup {
760 llvm::Value *Addr;
761
762 public:
763 CallLifetimeEnd(RawAddress addr) : Addr(addr.getPointer()) {}
764
765 void Emit(CodeGenFunction &CGF, Flags flags) override {
766 CGF.EmitLifetimeEnd(Addr);
767 }
768 };
769
770 // We are using objects of this 'cleanup' class to emit fake.use calls
771 // for -fextend-variable-liveness. They are placed at the end of a variable's
772 // scope analogous to lifetime markers.
773 class FakeUse final : public EHScopeStack::Cleanup {
774 Address Addr;
775
776 public:
777 FakeUse(Address addr) : Addr(addr) {}
778
779 void Emit(CodeGenFunction &CGF, Flags flags) override {
780 CGF.EmitFakeUse(Addr);
781 }
782 };
783
784 /// Header for data within LifetimeExtendedCleanupStack.
785 struct alignas(uint64_t) LifetimeExtendedCleanupHeader {
786 /// The size of the following cleanup object.
787 unsigned Size;
788 /// The kind of cleanup to push.
789 LLVM_PREFERRED_TYPE(CleanupKind)
791 /// Whether this is a conditional cleanup.
792 LLVM_PREFERRED_TYPE(bool)
793 unsigned IsConditional : 1;
794
795 size_t getSize() const { return Size; }
796 CleanupKind getKind() const { return (CleanupKind)Kind; }
797 bool isConditional() const { return IsConditional; }
798 };
799
800 /// i32s containing the indexes of the cleanup destinations.
802
804
805 /// EHResumeBlock - Unified block containing a call to llvm.eh.resume.
806 llvm::BasicBlock *EHResumeBlock = nullptr;
807
808 /// The exception slot. All landing pads write the current exception pointer
809 /// into this alloca.
810 llvm::Value *ExceptionSlot = nullptr;
811
812 /// The selector slot. Under the MandatoryCleanup model, all landing pads
813 /// write the current selector value into this alloca.
814 llvm::AllocaInst *EHSelectorSlot = nullptr;
815
816 /// A stack of exception code slots. Entering an __except block pushes a slot
817 /// on the stack and leaving pops one. The __exception_code() intrinsic loads
818 /// a value from the top of the stack.
820
821 /// Value returned by __exception_info intrinsic.
822 llvm::Value *SEHInfo = nullptr;
823
824 /// Emits a landing pad for the current EH stack.
825 llvm::BasicBlock *EmitLandingPad();
826
827 llvm::BasicBlock *getInvokeDestImpl();
828
829 /// Parent loop-based directive for scan directive.
831 llvm::BasicBlock *OMPBeforeScanBlock = nullptr;
832 llvm::BasicBlock *OMPAfterScanBlock = nullptr;
833 llvm::BasicBlock *OMPScanExitBlock = nullptr;
834 llvm::BasicBlock *OMPScanDispatch = nullptr;
835 bool OMPFirstScanLoop = false;
836
837 /// Manages parent directive for scan directives.
839 CodeGenFunction &CGF;
840 const OMPExecutableDirective *ParentLoopDirectiveForScan;
841
842 public:
844 CodeGenFunction &CGF,
845 const OMPExecutableDirective &ParentLoopDirectiveForScan)
846 : CGF(CGF),
847 ParentLoopDirectiveForScan(CGF.OMPParentLoopDirectiveForScan) {
848 CGF.OMPParentLoopDirectiveForScan = &ParentLoopDirectiveForScan;
849 }
851 CGF.OMPParentLoopDirectiveForScan = ParentLoopDirectiveForScan;
852 }
853 };
854
855 template <class T>
857 return DominatingValue<T>::save(*this, value);
858 }
859
861 public:
862 CGFPOptionsRAII(CodeGenFunction &CGF, FPOptions FPFeatures);
863 CGFPOptionsRAII(CodeGenFunction &CGF, const Expr *E);
865
866 private:
867 void ConstructorHelper(FPOptions FPFeatures);
868 CodeGenFunction &CGF;
869 FPOptions OldFPFeatures;
870 llvm::fp::ExceptionBehavior OldExcept;
871 llvm::RoundingMode OldRounding;
872 std::optional<CGBuilderTy::FastMathFlagGuard> FMFGuard;
873 };
875
877 public:
879 : CGM(CGM_), SavedAtomicOpts(CGM.getAtomicOpts()) {
880 CGM.setAtomicOpts(AO);
881 }
882 CGAtomicOptionsRAII(CodeGenModule &CGM_, const AtomicAttr *AA)
883 : CGM(CGM_), SavedAtomicOpts(CGM.getAtomicOpts()) {
884 if (!AA)
885 return;
886 AtomicOptions AO = SavedAtomicOpts;
887 for (auto Option : AA->atomicOptions()) {
888 switch (Option) {
889 case AtomicAttr::remote_memory:
890 AO.remote_memory = true;
891 break;
892 case AtomicAttr::no_remote_memory:
893 AO.remote_memory = false;
894 break;
895 case AtomicAttr::fine_grained_memory:
896 AO.fine_grained_memory = true;
897 break;
898 case AtomicAttr::no_fine_grained_memory:
899 AO.fine_grained_memory = false;
900 break;
901 case AtomicAttr::ignore_denormal_mode:
902 AO.ignore_denormal_mode = true;
903 break;
904 case AtomicAttr::no_ignore_denormal_mode:
905 AO.ignore_denormal_mode = false;
906 break;
907 }
908 }
909 CGM.setAtomicOpts(AO);
910 }
911
914 ~CGAtomicOptionsRAII() { CGM.setAtomicOpts(SavedAtomicOpts); }
915
916 private:
918 AtomicOptions SavedAtomicOpts;
919 };
920
921public:
922 /// ObjCEHValueStack - Stack of Objective-C exception values, used for
923 /// rethrows.
925
926 /// A class controlling the emission of a finally block.
928 /// Where the catchall's edge through the cleanup should go.
929 JumpDest RethrowDest;
930
931 /// A function to call to enter the catch.
932 llvm::FunctionCallee BeginCatchFn;
933
934 /// An i1 variable indicating whether or not the @finally is
935 /// running for an exception.
936 llvm::AllocaInst *ForEHVar = nullptr;
937
938 /// An i8* variable into which the exception pointer to rethrow
939 /// has been saved.
940 llvm::AllocaInst *SavedExnVar = nullptr;
941
942 public:
943 void enter(CodeGenFunction &CGF, const Stmt *Finally,
944 llvm::FunctionCallee beginCatchFn,
945 llvm::FunctionCallee endCatchFn, llvm::FunctionCallee rethrowFn);
946 void exit(CodeGenFunction &CGF);
947 };
948
949 /// Returns true inside SEH __try blocks.
950 bool isSEHTryScope() const { return !SEHTryEpilogueStack.empty(); }
951
952 /// Returns true while emitting a cleanuppad.
956
957 /// pushFullExprCleanup - Push a cleanup to be run at the end of the
958 /// current full-expression. Safe against the possibility that
959 /// we're currently inside a conditionally-evaluated expression.
960 template <class T, class... As>
962 // If we're not in a conditional branch, or if none of the
963 // arguments requires saving, then use the unconditional cleanup.
965 return EHStack.pushCleanup<T>(kind, A...);
966
967 // Stash values in a tuple so we can guarantee the order of saves.
968 typedef std::tuple<typename DominatingValue<As>::saved_type...> SavedTuple;
969 SavedTuple Saved{saveValueInCond(A)...};
970
971 typedef EHScopeStack::ConditionalCleanup<T, As...> CleanupType;
972 EHStack.pushCleanupTuple<CleanupType>(kind, Saved);
974 }
975
976 /// Queue a cleanup to be pushed after finishing the current full-expression,
977 /// potentially with an active flag.
978 template <class T, class... As>
982 Kind, RawAddress::invalid(), A...);
983
984 RawAddress ActiveFlag = createCleanupActiveFlag();
985 assert(!DominatingValue<Address>::needsSaving(ActiveFlag) &&
986 "cleanup active flag should never need saving");
987
988 typedef std::tuple<typename DominatingValue<As>::saved_type...> SavedTuple;
989 SavedTuple Saved{saveValueInCond(A)...};
990
991 typedef EHScopeStack::ConditionalCleanup<T, As...> CleanupType;
993 Saved);
994 }
995
996 template <class T, class... As>
998 RawAddress ActiveFlag, As... A) {
999 LifetimeExtendedCleanupHeader Header = {sizeof(T), Kind,
1000 ActiveFlag.isValid()};
1001
1002 size_t OldSize = LifetimeExtendedCleanupStack.size();
1004 LifetimeExtendedCleanupStack.size() + sizeof(Header) + Header.Size +
1005 (Header.IsConditional ? sizeof(ActiveFlag) : 0));
1006
1007 static_assert((alignof(LifetimeExtendedCleanupHeader) == alignof(T)) &&
1008 (alignof(T) == alignof(RawAddress)),
1009 "Cleanup will be allocated on misaligned address");
1010 char *Buffer = &LifetimeExtendedCleanupStack[OldSize];
1011 new (Buffer) LifetimeExtendedCleanupHeader(Header);
1012 new (Buffer + sizeof(Header)) T(A...);
1013 if (Header.IsConditional)
1014 new (Buffer + sizeof(Header) + sizeof(T)) RawAddress(ActiveFlag);
1015 }
1016
1017 // Push a cleanup onto EHStack and deactivate it later. It is usually
1018 // deactivated when exiting a `CleanupDeactivationScope` (for example: after a
1019 // full expression).
1020 template <class T, class... As>
1022 // Placeholder dominating IP for this cleanup.
1023 llvm::Instruction *DominatingIP =
1024 Builder.CreateFlagLoad(llvm::Constant::getNullValue(Int8PtrTy));
1025 EHStack.pushCleanup<T>(Kind, A...);
1027 {EHStack.stable_begin(), DominatingIP});
1028 }
1029
1030 /// Set up the last cleanup that was pushed as a conditional
1031 /// full-expression cleanup.
1035
1036 void initFullExprCleanupWithFlag(RawAddress ActiveFlag);
1038
1039 /// PushDestructorCleanup - Push a cleanup to call the
1040 /// complete-object destructor of an object of the given type at the
1041 /// given address. Does nothing if T is not a C++ class type with a
1042 /// non-trivial destructor.
1044
1045 /// PushDestructorCleanup - Push a cleanup to call the
1046 /// complete-object variant of the given destructor on the object at
1047 /// the given address.
1049 Address Addr);
1050
1051 /// PopCleanupBlock - Will pop the cleanup entry on the stack and
1052 /// process all branch fixups.
1053 void PopCleanupBlock(bool FallThroughIsBranchThrough = false,
1054 bool ForDeactivation = false);
1055
1056 /// DeactivateCleanupBlock - Deactivates the given cleanup block.
1057 /// The block cannot be reactivated. Pops it if it's the top of the
1058 /// stack.
1059 ///
1060 /// \param DominatingIP - An instruction which is known to
1061 /// dominate the current IP (if set) and which lies along
1062 /// all paths of execution between the current IP and the
1063 /// the point at which the cleanup comes into scope.
1065 llvm::Instruction *DominatingIP);
1066
1067 /// ActivateCleanupBlock - Activates an initially-inactive cleanup.
1068 /// Cannot be used to resurrect a deactivated cleanup.
1069 ///
1070 /// \param DominatingIP - An instruction which is known to
1071 /// dominate the current IP (if set) and which lies along
1072 /// all paths of execution between the current IP and the
1073 /// the point at which the cleanup comes into scope.
1075 llvm::Instruction *DominatingIP);
1076
1077 /// Enters a new scope for capturing cleanups, all of which
1078 /// will be executed once the scope is exited.
1079 class RunCleanupsScope {
1080 EHScopeStack::stable_iterator CleanupStackDepth, OldCleanupScopeDepth;
1081 size_t LifetimeExtendedCleanupStackSize;
1082 CleanupDeactivationScope DeactivateCleanups;
1083 bool OldDidCallStackSave;
1084
1085 protected:
1087
1088 private:
1089 RunCleanupsScope(const RunCleanupsScope &) = delete;
1090 void operator=(const RunCleanupsScope &) = delete;
1091
1092 protected:
1093 CodeGenFunction &CGF;
1094
1095 public:
1096 /// Enter a new cleanup scope.
1097 explicit RunCleanupsScope(CodeGenFunction &CGF)
1098 : DeactivateCleanups(CGF), PerformCleanup(true), CGF(CGF) {
1099 CleanupStackDepth = CGF.EHStack.stable_begin();
1100 LifetimeExtendedCleanupStackSize =
1101 CGF.LifetimeExtendedCleanupStack.size();
1102 OldDidCallStackSave = CGF.DidCallStackSave;
1103 CGF.DidCallStackSave = false;
1104 OldCleanupScopeDepth = CGF.CurrentCleanupScopeDepth;
1105 CGF.CurrentCleanupScopeDepth = CleanupStackDepth;
1106 }
1107
1108 /// Exit this cleanup scope, emitting any accumulated cleanups.
1110 if (PerformCleanup)
1111 ForceCleanup();
1112 }
1113
1114 /// Determine whether this scope requires any cleanups.
1115 bool requiresCleanups() const {
1116 return CGF.EHStack.stable_begin() != CleanupStackDepth;
1117 }
1118
1119 /// Force the emission of cleanups now, instead of waiting
1120 /// until this object is destroyed.
1121 /// \param ValuesToReload - A list of values that need to be available at
1122 /// the insertion point after cleanup emission. If cleanup emission created
1123 /// a shared cleanup block, these value pointers will be rewritten.
1124 /// Otherwise, they not will be modified.
1125 void
1126 ForceCleanup(std::initializer_list<llvm::Value **> ValuesToReload = {}) {
1127 assert(PerformCleanup && "Already forced cleanup");
1128 CGF.DidCallStackSave = OldDidCallStackSave;
1129 DeactivateCleanups.ForceDeactivate();
1130 CGF.PopCleanupBlocks(CleanupStackDepth, LifetimeExtendedCleanupStackSize,
1131 ValuesToReload);
1132 PerformCleanup = false;
1133 CGF.CurrentCleanupScopeDepth = OldCleanupScopeDepth;
1134 }
1135 };
1136
1137 // Cleanup stack depth of the RunCleanupsScope that was pushed most recently.
1140
1141 class LexicalScope : public RunCleanupsScope {
1142 SourceRange Range;
1144 LexicalScope *ParentScope;
1145
1146 LexicalScope(const LexicalScope &) = delete;
1147 void operator=(const LexicalScope &) = delete;
1148
1149 public:
1150 /// Enter a new cleanup scope.
1151 explicit LexicalScope(CodeGenFunction &CGF, SourceRange Range);
1152
1153 void addLabel(const LabelDecl *label) {
1154 assert(PerformCleanup && "adding label to dead scope?");
1155 Labels.push_back(label);
1156 }
1157
1158 /// Exit this cleanup scope, emitting any accumulated
1159 /// cleanups.
1160 ~LexicalScope();
1161
1162 /// Force the emission of cleanups now, instead of waiting
1163 /// until this object is destroyed.
1165 CGF.CurLexicalScope = ParentScope;
1167
1168 if (!Labels.empty())
1169 rescopeLabels();
1170 }
1171
1172 bool hasLabels() const { return !Labels.empty(); }
1173
1174 void rescopeLabels();
1175 };
1176
1177 typedef llvm::DenseMap<const Decl *, Address> DeclMapTy;
1178
1179 /// The class used to assign some variables some temporarily addresses.
1180 class OMPMapVars {
1181 DeclMapTy SavedLocals;
1182 DeclMapTy SavedTempAddresses;
1183 OMPMapVars(const OMPMapVars &) = delete;
1184 void operator=(const OMPMapVars &) = delete;
1185
1186 public:
1187 explicit OMPMapVars() = default;
1189 assert(SavedLocals.empty() && "Did not restored original addresses.");
1190 };
1191
1192 /// Sets the address of the variable \p LocalVD to be \p TempAddr in
1193 /// function \p CGF.
1194 /// \return true if at least one variable was set already, false otherwise.
1195 bool setVarAddr(CodeGenFunction &CGF, const ValueDecl *LocalVD,
1196 Address TempAddr) {
1197 LocalVD = cast<ValueDecl>(LocalVD->getCanonicalDecl());
1198
1199 // Only save it once.
1200 if (SavedLocals.count(LocalVD))
1201 return false;
1202
1203 // Copy the existing local entry to SavedLocals.
1204 auto it = CGF.LocalDeclMap.find(LocalVD);
1205 if (it != CGF.LocalDeclMap.end())
1206 SavedLocals.try_emplace(LocalVD, it->second);
1207 else
1208 SavedLocals.try_emplace(LocalVD, Address::invalid());
1209
1210 // Generate the private entry.
1211 QualType VarTy = LocalVD->getType();
1212 if (VarTy->isReferenceType()) {
1213 Address Temp = CGF.CreateMemTemp(VarTy);
1214 CGF.Builder.CreateStore(TempAddr.emitRawPointer(CGF), Temp);
1215 TempAddr = Temp;
1216 }
1217 if (const auto *BD = dyn_cast<BindingDecl>(LocalVD))
1218 CGF.OMPPrivatizedBindings.insert_or_assign(BD, TempAddr);
1219 SavedTempAddresses.try_emplace(LocalVD, TempAddr);
1220
1221 return true;
1222 }
1223
1224 /// Applies new addresses to the list of the variables.
1225 /// \return true if at least one variable is using new address, false
1226 /// otherwise.
1227 bool apply(CodeGenFunction &CGF) {
1228 copyInto(SavedTempAddresses, CGF.LocalDeclMap);
1229 SavedTempAddresses.clear();
1230 return !SavedLocals.empty();
1231 }
1232
1233 /// Restores original addresses of the variables.
1234 void restore(CodeGenFunction &CGF) {
1235 if (!SavedLocals.empty()) {
1236 copyInto(SavedLocals, CGF.LocalDeclMap);
1237 SavedLocals.clear();
1238 }
1239 }
1240
1241 private:
1242 /// Copy all the entries in the source map over the corresponding
1243 /// entries in the destination, which must exist.
1244 static void copyInto(const DeclMapTy &Src, DeclMapTy &Dest) {
1245 for (auto &[Decl, Addr] : Src) {
1246 if (!Addr.isValid())
1247 Dest.erase(Decl);
1248 else
1249 Dest.insert_or_assign(Decl, Addr);
1250 }
1251 }
1252 };
1253
1254 /// The scope used to remap some variables as private in the OpenMP loop body
1255 /// (or other captured region emitted without outlining), and to restore old
1256 /// vars back on exit.
1257 class OMPPrivateScope : public RunCleanupsScope {
1258 OMPMapVars MappedVars;
1259 OMPPrivateScope(const OMPPrivateScope &) = delete;
1260 void operator=(const OMPPrivateScope &) = delete;
1261 llvm::DenseMap<const BindingDecl *, Address> BindingChanges;
1262
1263 public:
1264 /// Enter a new OpenMP private scope.
1265 explicit OMPPrivateScope(CodeGenFunction &CGF) : RunCleanupsScope(CGF) {}
1266
1267 /// Registers \p LocalVD variable as a private with \p Addr as the address
1268 /// of the corresponding private variable. \p
1269 /// PrivateGen is the address of the generated private variable.
1270 /// \return true if the variable is registered as private, false if it has
1271 /// been privatized already.
1272 bool addPrivate(const ValueDecl *LocalVD, Address Addr) {
1273 assert(PerformCleanup && "adding private to dead scope");
1274 if (const auto *BD = dyn_cast<BindingDecl>(LocalVD->getCanonicalDecl())) {
1275 auto It = CGF.OMPPrivatizedBindings.find(BD);
1276 BindingChanges.insert({BD, It != CGF.OMPPrivatizedBindings.end()
1277 ? It->second
1278 : Address::invalid()});
1279 }
1280 return MappedVars.setVarAddr(CGF, LocalVD, Addr);
1281 }
1282
1283 /// Privatizes local variables previously registered as private.
1284 /// Registration is separate from the actual privatization to allow
1285 /// initializers use values of the original variables, not the private one.
1286 /// This is important, for example, if the private variable is a class
1287 /// variable initialized by a constructor that references other private
1288 /// variables. But at initialization original variables must be used, not
1289 /// private copies.
1290 /// \return true if at least one variable was privatized, false otherwise.
1291 bool Privatize() { return MappedVars.apply(CGF); }
1292
1297
1298 /// Exit scope - all the mapped variables are restored.
1300 if (PerformCleanup)
1301 ForceCleanup();
1302 for (auto &Change : BindingChanges) {
1303 if (Change.second.isValid()) {
1304 auto It = CGF.OMPPrivatizedBindings.find(Change.first);
1305 if (It != CGF.OMPPrivatizedBindings.end())
1306 It->second = Change.second;
1307 else
1308 CGF.OMPPrivatizedBindings.insert({Change.first, Change.second});
1309 } else {
1310 CGF.OMPPrivatizedBindings.erase(Change.first);
1311 }
1312 }
1313 }
1314
1315 /// Checks if the global variable is captured in current function.
1316 bool isGlobalVarCaptured(const VarDecl *VD) const {
1317 VD = VD->getCanonicalDecl();
1318 return !VD->isLocalVarDeclOrParm() && CGF.LocalDeclMap.count(VD) > 0;
1319 }
1320
1321 /// Restore all mapped variables w/o clean up. This is usefully when we want
1322 /// to reference the original variables but don't want the clean up because
1323 /// that could emit lifetime end too early, causing backend issue #56913.
1324 void restoreMap() { MappedVars.restore(CGF); }
1325 };
1326
1327 /// Save/restore original map of previously emitted local vars in case when we
1328 /// need to duplicate emission of the same code several times in the same
1329 /// function for OpenMP code.
1331 CodeGenFunction &CGF;
1332 DeclMapTy SavedMap;
1333
1334 public:
1335 OMPLocalDeclMapRAII(CodeGenFunction &CGF)
1336 : CGF(CGF), SavedMap(CGF.LocalDeclMap) {}
1337 ~OMPLocalDeclMapRAII() { SavedMap.swap(CGF.LocalDeclMap); }
1338 };
1339
1340 /// Takes the old cleanup stack size and emits the cleanup blocks
1341 /// that have been added.
1342 void
1344 std::initializer_list<llvm::Value **> ValuesToReload = {});
1345
1346 /// Takes the old cleanup stack size and emits the cleanup blocks
1347 /// that have been added, then adds all lifetime-extended cleanups from
1348 /// the given position to the stack.
1349 void
1350 PopCleanupBlocks(EHScopeStack::stable_iterator OldCleanupStackSize,
1351 size_t OldLifetimeExtendedStackSize,
1352 std::initializer_list<llvm::Value **> ValuesToReload = {});
1353
1354 void ResolveBranchFixups(llvm::BasicBlock *Target);
1355
1356 /// The given basic block lies in the current EH scope, but may be a
1357 /// target of a potentially scope-crossing jump; get a stable handle
1358 /// to which we can perform this jump later.
1360 return JumpDest(Target, EHStack.getInnermostNormalCleanup(),
1362 }
1363
1364 /// The given basic block lies in the current EH scope, but may be a
1365 /// target of a potentially scope-crossing jump; get a stable handle
1366 /// to which we can perform this jump later.
1367 JumpDest getJumpDestInCurrentScope(StringRef Name = StringRef()) {
1369 }
1370
1371 /// EmitBranchThroughCleanup - Emit a branch from the current insert
1372 /// block through the normal cleanup handling code (if any) and then
1373 /// on to \arg Dest.
1374 void EmitBranchThroughCleanup(JumpDest Dest);
1375
1376 /// isObviouslyBranchWithoutCleanups - Return true if a branch to the
1377 /// specified destination obviously has no cleanups to run. 'false' is always
1378 /// a conservatively correct answer for this method.
1379 bool isObviouslyBranchWithoutCleanups(JumpDest Dest) const;
1380
1381 /// popCatchScope - Pops the catch scope at the top of the EHScope
1382 /// stack, emitting any required code (other than the catch handlers
1383 /// themselves).
1384 void popCatchScope();
1385
1386 // This function should be called after emitting all catch clauses and none
1387 // of them were 'catch-all' clauses.
1388 // Because in wasm we merge all catch clauses into one big catchpad, in case
1389 // none of the types in catch handlers matches after we test against each of
1390 // them, we should unwind to the next EH enclosing scope. We generate a call
1391 // to rethrow function here to do that.
1392 void WasmEmitFallthroughRethrow(llvm::BasicBlock *WasmCatchStartBlock);
1393
1394 llvm::BasicBlock *getEHResumeBlock(bool isCleanup);
1395 llvm::BasicBlock *getEHDispatchBlock(EHScopeStack::stable_iterator scope);
1396 llvm::BasicBlock *
1398
1399 /// An object to manage conditionally-evaluated expressions.
1401 llvm::BasicBlock *StartBB;
1402
1403 public:
1404 ConditionalEvaluation(CodeGenFunction &CGF)
1405 : StartBB(CGF.Builder.GetInsertBlock()) {}
1406
1407 void begin(CodeGenFunction &CGF) {
1408 assert(CGF.OutermostConditional != this);
1409 if (!CGF.OutermostConditional)
1410 CGF.OutermostConditional = this;
1411 }
1412
1413 void end(CodeGenFunction &CGF) {
1414 assert(CGF.OutermostConditional != nullptr);
1415 if (CGF.OutermostConditional == this)
1416 CGF.OutermostConditional = nullptr;
1417 }
1418
1419 /// Returns a block which will be executed prior to each
1420 /// evaluation of the conditional code.
1421 llvm::BasicBlock *getStartingBlock() const { return StartBB; }
1422 };
1423
1424 /// isInConditionalBranch - Return true if we're currently emitting
1425 /// one branch or the other of a conditional expression.
1426 bool isInConditionalBranch() const { return OutermostConditional != nullptr; }
1427
1428 void setBeforeOutermostConditional(llvm::Value *value, Address addr,
1429 CodeGenFunction &CGF) {
1430 assert(isInConditionalBranch());
1431 llvm::BasicBlock *block = OutermostConditional->getStartingBlock();
1432 auto store = new llvm::StoreInst(value, addr.emitRawPointer(CGF),
1433 block->back().getIterator());
1434 store->setAlignment(addr.getAlignment().getAsAlign());
1435 }
1436
1437 /// An RAII object to record that we're evaluating a statement
1438 /// expression.
1440 CodeGenFunction &CGF;
1441
1442 /// We have to save the outermost conditional: cleanups in a
1443 /// statement expression aren't conditional just because the
1444 /// StmtExpr is.
1445 ConditionalEvaluation *SavedOutermostConditional;
1446
1447 public:
1448 StmtExprEvaluation(CodeGenFunction &CGF)
1449 : CGF(CGF), SavedOutermostConditional(CGF.OutermostConditional) {
1450 CGF.OutermostConditional = nullptr;
1451 }
1452
1454 CGF.OutermostConditional = SavedOutermostConditional;
1455 CGF.EnsureInsertPoint();
1456 }
1457 };
1458
1459 /// An object which temporarily prevents a value from being
1460 /// destroyed by aggressive peephole optimizations that assume that
1461 /// all uses of a value have been realized in the IR.
1463 llvm::Instruction *Inst = nullptr;
1464 friend class CodeGenFunction;
1465
1466 public:
1468 };
1469
1470 /// A non-RAII class containing all the information about a bound
1471 /// opaque value. OpaqueValueMapping, below, is a RAII wrapper for
1472 /// this which makes individual mappings very simple; using this
1473 /// class directly is useful when you have a variable number of
1474 /// opaque values or don't want the RAII functionality for some
1475 /// reason.
1476 class OpaqueValueMappingData {
1477 const OpaqueValueExpr *OpaqueValue;
1478 bool BoundLValue;
1480
1481 OpaqueValueMappingData(const OpaqueValueExpr *ov, bool boundLValue)
1482 : OpaqueValue(ov), BoundLValue(boundLValue) {}
1483
1484 public:
1486
1487 static bool shouldBindAsLValue(const Expr *expr) {
1488 // gl-values should be bound as l-values for obvious reasons.
1489 // Records should be bound as l-values because IR generation
1490 // always keeps them in memory. Expressions of function type
1491 // act exactly like l-values but are formally required to be
1492 // r-values in C.
1493 return expr->isGLValue() || expr->getType()->isFunctionType() ||
1494 hasAggregateEvaluationKind(expr->getType());
1495 }
1496
1498 bind(CodeGenFunction &CGF, const OpaqueValueExpr *ov, const Expr *e) {
1499 if (shouldBindAsLValue(ov))
1500 return bind(CGF, ov, CGF.EmitLValue(e));
1501 return bind(CGF, ov, CGF.EmitAnyExpr(e));
1502 }
1503
1505 bind(CodeGenFunction &CGF, const OpaqueValueExpr *ov, const LValue &lv) {
1506 assert(shouldBindAsLValue(ov));
1507 CGF.OpaqueLValues.insert(std::make_pair(ov, lv));
1508 return OpaqueValueMappingData(ov, true);
1509 }
1510
1512 bind(CodeGenFunction &CGF, const OpaqueValueExpr *ov, const RValue &rv) {
1513 assert(!shouldBindAsLValue(ov));
1514 CGF.OpaqueRValues.insert(std::make_pair(ov, rv));
1515
1516 OpaqueValueMappingData data(ov, false);
1517
1518 // Work around an extremely aggressive peephole optimization in
1519 // EmitScalarConversion which assumes that all other uses of a
1520 // value are extant.
1521 data.Protection = CGF.protectFromPeepholes(rv);
1522
1523 return data;
1524 }
1525
1526 bool isValid() const { return OpaqueValue != nullptr; }
1527 void clear() { OpaqueValue = nullptr; }
1528
1529 void unbind(CodeGenFunction &CGF) {
1530 assert(OpaqueValue && "no data to unbind!");
1531
1532 if (BoundLValue) {
1533 CGF.OpaqueLValues.erase(OpaqueValue);
1534 } else {
1535 CGF.OpaqueRValues.erase(OpaqueValue);
1536 CGF.unprotectFromPeepholes(Protection);
1537 }
1538 }
1539 };
1540
1541 /// An RAII object to set (and then clear) a mapping for an OpaqueValueExpr.
1543 CodeGenFunction &CGF;
1545
1546 public:
1550
1551 /// Build the opaque value mapping for the given conditional
1552 /// operator if it's the GNU ?: extension. This is a common
1553 /// enough pattern that the convenience operator is really
1554 /// helpful.
1555 ///
1556 OpaqueValueMapping(CodeGenFunction &CGF,
1558 : CGF(CGF) {
1560 // Leave Data empty.
1561 return;
1562
1565 e->getCommon());
1566 }
1567
1568 /// Build the opaque value mapping for an OpaqueValueExpr whose source
1569 /// expression is set to the expression the OVE represents.
1570 OpaqueValueMapping(CodeGenFunction &CGF, const OpaqueValueExpr *OV)
1571 : CGF(CGF) {
1572 if (OV) {
1573 assert(OV->getSourceExpr() && "wrong form of OpaqueValueMapping used "
1574 "for OVE with no source expression");
1575 Data = OpaqueValueMappingData::bind(CGF, OV, OV->getSourceExpr());
1576 }
1577 }
1578
1579 OpaqueValueMapping(CodeGenFunction &CGF, const OpaqueValueExpr *opaqueValue,
1580 LValue lvalue)
1581 : CGF(CGF),
1582 Data(OpaqueValueMappingData::bind(CGF, opaqueValue, lvalue)) {}
1583
1584 OpaqueValueMapping(CodeGenFunction &CGF, const OpaqueValueExpr *opaqueValue,
1585 RValue rvalue)
1586 : CGF(CGF),
1587 Data(OpaqueValueMappingData::bind(CGF, opaqueValue, rvalue)) {}
1588
1589 void pop() {
1590 Data.unbind(CGF);
1591 Data.clear();
1592 }
1593
1595 if (Data.isValid())
1596 Data.unbind(CGF);
1597 }
1598 };
1599
1600private:
1601 CGDebugInfo *DebugInfo;
1602 /// Used to create unique names for artificial VLA size debug info variables.
1603 unsigned VLAExprCounter = 0;
1604 bool DisableDebugInfo = false;
1605
1606 /// DidCallStackSave - Whether llvm.stacksave has been called. Used to avoid
1607 /// calling llvm.stacksave for multiple VLAs in the same scope.
1608 bool DidCallStackSave = false;
1609
1610 /// IndirectBranch - The first time an indirect goto is seen we create a block
1611 /// with an indirect branch. Every time we see the address of a label taken,
1612 /// we add the label to the indirect goto. Every subsequent indirect goto is
1613 /// codegen'd as a jump to the IndirectBranch's basic block.
1614 llvm::IndirectBrInst *IndirectBranch = nullptr;
1615
1616 /// LocalDeclMap - This keeps track of the LLVM allocas or globals for local C
1617 /// decls.
1618 DeclMapTy LocalDeclMap;
1619
1620 /// Lookup map for privatized BindingDecls.
1621 /// Used when BindingDecls are remapped during OpenMP outlining, since the
1622 /// remapped BindingDecl has a different pointer than the original.
1623 llvm::SmallDenseMap<const BindingDecl *, Address> OMPPrivatizedBindings;
1624
1625 // Keep track of the cleanups for callee-destructed parameters pushed to the
1626 // cleanup stack so that they can be deactivated later.
1627 llvm::DenseMap<const ParmVarDecl *, EHScopeStack::stable_iterator>
1628 CalleeDestructedParamCleanups;
1629
1630 /// SizeArguments - If a ParmVarDecl had the pass_object_size attribute, this
1631 /// will contain a mapping from said ParmVarDecl to its implicit "object_size"
1632 /// parameter.
1633 llvm::SmallDenseMap<const ParmVarDecl *, const ImplicitParamDecl *, 2>
1634 SizeArguments;
1635
1636 /// Track escaped local variables with auto storage. Used during SEH
1637 /// outlining to produce a call to llvm.localescape.
1638 llvm::DenseMap<llvm::AllocaInst *, int> EscapedLocals;
1639
1640 /// LabelMap - This keeps track of the LLVM basic block for each C label.
1641 llvm::DenseMap<const LabelDecl *, JumpDest> LabelMap;
1642
1643 // BreakContinueStack - This keeps track of where break and continue
1644 // statements should jump to.
1645 struct BreakContinue {
1646 BreakContinue(const Stmt &LoopOrSwitch, JumpDest Break, JumpDest Continue)
1647 : LoopOrSwitch(&LoopOrSwitch), BreakBlock(Break),
1648 ContinueBlock(Continue) {}
1649
1650 const Stmt *LoopOrSwitch;
1651 JumpDest BreakBlock;
1652 JumpDest ContinueBlock;
1653 };
1654 SmallVector<BreakContinue, 8> BreakContinueStack;
1655
1656 /// Handles cancellation exit points in OpenMP-related constructs.
1657 class OpenMPCancelExitStack {
1658 /// Tracks cancellation exit point and join point for cancel-related exit
1659 /// and normal exit.
1660 struct CancelExit {
1661 CancelExit() = default;
1662 CancelExit(OpenMPDirectiveKind Kind, JumpDest ExitBlock,
1663 JumpDest ContBlock)
1664 : Kind(Kind), ExitBlock(ExitBlock), ContBlock(ContBlock) {}
1665 OpenMPDirectiveKind Kind = llvm::omp::OMPD_unknown;
1666 /// true if the exit block has been emitted already by the special
1667 /// emitExit() call, false if the default codegen is used.
1668 bool HasBeenEmitted = false;
1669 JumpDest ExitBlock;
1670 JumpDest ContBlock;
1671 };
1672
1673 SmallVector<CancelExit, 8> Stack;
1674
1675 public:
1676 OpenMPCancelExitStack() : Stack(1) {}
1677 ~OpenMPCancelExitStack() = default;
1678 /// Fetches the exit block for the current OpenMP construct.
1679 JumpDest getExitBlock() const { return Stack.back().ExitBlock; }
1680 /// Emits exit block with special codegen procedure specific for the related
1681 /// OpenMP construct + emits code for normal construct cleanup.
1682 void emitExit(CodeGenFunction &CGF, OpenMPDirectiveKind Kind,
1683 const llvm::function_ref<void(CodeGenFunction &)> CodeGen) {
1684 if (Stack.back().Kind == Kind && getExitBlock().isValid()) {
1685 assert(CGF.getOMPCancelDestination(Kind).isValid());
1686 assert(CGF.HaveInsertPoint());
1687 assert(!Stack.back().HasBeenEmitted);
1688 auto IP = CGF.Builder.saveAndClearIP();
1689 CGF.EmitBlock(Stack.back().ExitBlock.getBlock());
1690 CodeGen(CGF);
1691 CGF.EmitBranch(Stack.back().ContBlock.getBlock());
1692 CGF.Builder.restoreIP(IP);
1693 Stack.back().HasBeenEmitted = true;
1694 }
1695 CodeGen(CGF);
1696 }
1697 /// Enter the cancel supporting \a Kind construct.
1698 /// \param Kind OpenMP directive that supports cancel constructs.
1699 /// \param HasCancel true, if the construct has inner cancel directive,
1700 /// false otherwise.
1701 void enter(CodeGenFunction &CGF, OpenMPDirectiveKind Kind, bool HasCancel) {
1702 Stack.push_back({Kind,
1703 HasCancel ? CGF.getJumpDestInCurrentScope("cancel.exit")
1704 : JumpDest(),
1705 HasCancel ? CGF.getJumpDestInCurrentScope("cancel.cont")
1706 : JumpDest()});
1707 }
1708 /// Emits default exit point for the cancel construct (if the special one
1709 /// has not be used) + join point for cancel/normal exits.
1710 void exit(CodeGenFunction &CGF) {
1711 if (getExitBlock().isValid()) {
1712 assert(CGF.getOMPCancelDestination(Stack.back().Kind).isValid());
1713 bool HaveIP = CGF.HaveInsertPoint();
1714 if (!Stack.back().HasBeenEmitted) {
1715 if (HaveIP)
1716 CGF.EmitBranchThroughCleanup(Stack.back().ContBlock);
1717 CGF.EmitBlock(Stack.back().ExitBlock.getBlock());
1718 CGF.EmitBranchThroughCleanup(Stack.back().ContBlock);
1719 }
1720 CGF.EmitBlock(Stack.back().ContBlock.getBlock());
1721 if (!HaveIP) {
1722 CGF.Builder.CreateUnreachable();
1723 CGF.Builder.ClearInsertionPoint();
1724 }
1725 }
1726 Stack.pop_back();
1727 }
1728 };
1729 OpenMPCancelExitStack OMPCancelStack;
1730
1731 /// Lower the Likelihood knowledge about the \p Cond via llvm.expect intrin.
1732 llvm::Value *emitCondLikelihoodViaExpectIntrinsic(llvm::Value *Cond,
1733 Stmt::Likelihood LH);
1734
1735 std::unique_ptr<CodeGenPGO> PGO;
1736
1737 /// Calculate branch weights appropriate for PGO data
1738 llvm::MDNode *createProfileWeights(uint64_t TrueCount,
1739 uint64_t FalseCount) const;
1740 llvm::MDNode *createProfileWeights(ArrayRef<uint64_t> Weights) const;
1741 llvm::MDNode *createProfileWeightsForLoop(const Stmt *Cond,
1742 uint64_t LoopCount) const;
1743
1744public:
1745 bool hasSkipCounter(const Stmt *S) const;
1746
1747 void markStmtAsUsed(bool Skipped, const Stmt *S);
1748 void markStmtMaybeUsed(const Stmt *S);
1749
1750 /// Used to specify which counter in a pair shall be incremented.
1751 /// For non-binary counters, a skip counter is derived as (Parent - Exec).
1752 /// In contrast for binary counters, a skip counter cannot be computed from
1753 /// the Parent counter. In such cases, dedicated SkipPath counters must be
1754 /// allocated and marked (incremented as binary counters). (Parent can be
1755 /// synthesized with (Exec + Skip) in simple cases)
1757 UseExecPath = 0, ///< Exec (true)
1758 UseSkipPath, ///< Skip (false)
1759 };
1760
1761 /// Increment the profiler's counter for the given statement by \p StepV.
1762 /// If \p StepV is null, the default increment is 1.
1763 void incrementProfileCounter(const Stmt *S, llvm::Value *StepV = nullptr) {
1764 incrementProfileCounter(UseExecPath, S, false, StepV);
1765 }
1766
1767 /// Emit increment of Counter.
1768 /// \param ExecSkip Use `Skipped` Counter if UseSkipPath is specified.
1769 /// \param S The Stmt that Counter is associated.
1770 /// \param UseBoth Mark both Exec/Skip as used. (for verification)
1771 /// \param StepV The offset Value for adding to Counter.
1772 void incrementProfileCounter(CounterForIncrement ExecSkip, const Stmt *S,
1773 bool UseBoth = false,
1774 llvm::Value *StepV = nullptr);
1775
1777 return (CGM.getCodeGenOpts().hasProfileClangInstr() &&
1778 CGM.getCodeGenOpts().MCDCCoverage &&
1779 !CurFn->hasFnAttribute(llvm::Attribute::NoProfile));
1780 }
1781
1782 /// Allocate a temp value on the stack that MCDC can use to track condition
1783 /// results.
1785
1786 bool isBinaryLogicalOp(const Expr *E) const {
1787 const BinaryOperator *BOp = dyn_cast<BinaryOperator>(E->IgnoreParens());
1788 return (BOp && BOp->isLogicalOp());
1789 }
1790
1791 bool isMCDCDecisionExpr(const Expr *E) const;
1792 bool isMCDCBranchExpr(const Expr *E) const;
1793
1794 /// Zero-init the MCDC temp value.
1795 void maybeResetMCDCCondBitmap(const Expr *E);
1796
1797 /// Increment the profiler's counter for the given expression by \p StepV.
1798 /// If \p StepV is null, the default increment is 1.
1800
1801 /// Update the MCDC temp value with the condition's evaluated result.
1802 void maybeUpdateMCDCCondBitmap(const Expr *E, llvm::Value *Val);
1803
1804 /// Get the profiler's count for the given statement.
1805 uint64_t getProfileCount(const Stmt *S);
1806
1807 /// Set the profiler's current count.
1808 void setCurrentProfileCount(uint64_t Count);
1809
1810 /// Get the profiler's current count. This is generally the count for the most
1811 /// recently incremented counter.
1813
1814 /// See CGDebugInfo::addInstToCurrentSourceAtom.
1815 void addInstToCurrentSourceAtom(llvm::Instruction *KeyInstruction,
1816 llvm::Value *Backup);
1817
1818 /// See CGDebugInfo::addInstToSpecificSourceAtom.
1819 void addInstToSpecificSourceAtom(llvm::Instruction *KeyInstruction,
1820 llvm::Value *Backup, uint64_t Atom);
1821
1822 /// Add \p KeyInstruction and an optional \p Backup instruction to a new atom
1823 /// group (See ApplyAtomGroup for more info).
1824 void addInstToNewSourceAtom(llvm::Instruction *KeyInstruction,
1825 llvm::Value *Backup);
1826
1827 /// Copy all PFP fields from SrcPtr to DestPtr while updating signatures,
1828 /// assuming that DestPtr was already memcpy'd from SrcPtr.
1829 void emitPFPPostCopyUpdates(Address DestPtr, Address SrcPtr, QualType Ty);
1830
1831private:
1832 /// SwitchInsn - This is nearest current switch instruction. It is null if
1833 /// current context is not in a switch.
1834 llvm::SwitchInst *SwitchInsn = nullptr;
1835 /// The branch weights of SwitchInsn when doing instrumentation based PGO.
1836 SmallVector<uint64_t, 16> *SwitchWeights = nullptr;
1837
1838 /// The likelihood attributes of the SwitchCase.
1839 SmallVector<Stmt::Likelihood, 16> *SwitchLikelihood = nullptr;
1840
1841 /// CaseRangeBlock - This block holds if condition check for last case
1842 /// statement range in current switch instruction.
1843 llvm::BasicBlock *CaseRangeBlock = nullptr;
1844
1845 /// OpaqueLValues - Keeps track of the current set of opaque value
1846 /// expressions.
1847 llvm::DenseMap<const OpaqueValueExpr *, LValue> OpaqueLValues;
1848 llvm::DenseMap<const OpaqueValueExpr *, RValue> OpaqueRValues;
1849
1850 // VLASizeMap - This keeps track of the associated size for each VLA type.
1851 // We track this by the size expression rather than the type itself because
1852 // in certain situations, like a const qualifier applied to an VLA typedef,
1853 // multiple VLA types can share the same size expression.
1854 // FIXME: Maybe this could be a stack of maps that is pushed/popped as we
1855 // enter/leave scopes.
1856 llvm::DenseMap<const Expr *, llvm::Value *> VLASizeMap;
1857
1858 /// A block containing a single 'unreachable' instruction. Created
1859 /// lazily by getUnreachableBlock().
1860 llvm::BasicBlock *UnreachableBlock = nullptr;
1861
1862 /// Counts of the number return expressions in the function.
1863 unsigned NumReturnExprs = 0;
1864
1865 /// Count the number of simple (constant) return expressions in the function.
1866 unsigned NumSimpleReturnExprs = 0;
1867
1868 /// The last regular (non-return) debug location (breakpoint) in the function.
1869 SourceLocation LastStopPoint;
1870
1871public:
1872 /// Source location information about the default argument or member
1873 /// initializer expression we're evaluating, if any.
1877
1878 /// A scope within which we are constructing the fields of an object which
1879 /// might use a CXXDefaultInitExpr. This stashes away a 'this' value to use
1880 /// if we need to evaluate a CXXDefaultInitExpr within the evaluation.
1882 public:
1883 FieldConstructionScope(CodeGenFunction &CGF, Address This)
1884 : CGF(CGF), OldCXXDefaultInitExprThis(CGF.CXXDefaultInitExprThis) {
1885 CGF.CXXDefaultInitExprThis = This;
1886 }
1888 CGF.CXXDefaultInitExprThis = OldCXXDefaultInitExprThis;
1889 }
1890
1891 private:
1892 CodeGenFunction &CGF;
1893 Address OldCXXDefaultInitExprThis;
1894 };
1895
1896 /// The scope of a CXXDefaultInitExpr. Within this scope, the value of 'this'
1897 /// is overridden to be the object under construction.
1899 public:
1901 : CGF(CGF), OldCXXThisValue(CGF.CXXThisValue),
1902 OldCXXThisAlignment(CGF.CXXThisAlignment),
1904 CGF.CXXThisValue = CGF.CXXDefaultInitExprThis.getBasePointer();
1905 CGF.CXXThisAlignment = CGF.CXXDefaultInitExprThis.getAlignment();
1906 }
1908 CGF.CXXThisValue = OldCXXThisValue;
1909 CGF.CXXThisAlignment = OldCXXThisAlignment;
1910 }
1911
1912 public:
1913 CodeGenFunction &CGF;
1914 llvm::Value *OldCXXThisValue;
1917 };
1918
1923
1924 /// The scope of an ArrayInitLoopExpr. Within this scope, the value of the
1925 /// current loop index is overridden.
1927 public:
1928 ArrayInitLoopExprScope(CodeGenFunction &CGF, llvm::Value *Index)
1929 : CGF(CGF), OldArrayInitIndex(CGF.ArrayInitIndex) {
1930 CGF.ArrayInitIndex = Index;
1931 }
1932 ~ArrayInitLoopExprScope() { CGF.ArrayInitIndex = OldArrayInitIndex; }
1933
1934 private:
1935 CodeGenFunction &CGF;
1936 llvm::Value *OldArrayInitIndex;
1937 };
1938
1940 public:
1942 : CGF(CGF), OldCurGD(CGF.CurGD), OldCurFuncDecl(CGF.CurFuncDecl),
1943 OldCurCodeDecl(CGF.CurCodeDecl),
1944 OldCXXABIThisDecl(CGF.CXXABIThisDecl),
1945 OldCXXABIThisValue(CGF.CXXABIThisValue),
1946 OldCXXThisValue(CGF.CXXThisValue),
1947 OldCXXABIThisAlignment(CGF.CXXABIThisAlignment),
1948 OldCXXThisAlignment(CGF.CXXThisAlignment),
1949 OldReturnValue(CGF.ReturnValue), OldFnRetTy(CGF.FnRetTy),
1950 OldCXXInheritedCtorInitExprArgs(
1951 std::move(CGF.CXXInheritedCtorInitExprArgs)) {
1952 CGF.CurGD = GD;
1953 CGF.CurFuncDecl = CGF.CurCodeDecl =
1955 CGF.CXXABIThisDecl = nullptr;
1956 CGF.CXXABIThisValue = nullptr;
1957 CGF.CXXThisValue = nullptr;
1958 CGF.CXXABIThisAlignment = CharUnits();
1959 CGF.CXXThisAlignment = CharUnits();
1960 CGF.ReturnValue = Address::invalid();
1961 CGF.FnRetTy = QualType();
1962 CGF.CXXInheritedCtorInitExprArgs.clear();
1963 }
1965 CGF.CurGD = OldCurGD;
1966 CGF.CurFuncDecl = OldCurFuncDecl;
1967 CGF.CurCodeDecl = OldCurCodeDecl;
1968 CGF.CXXABIThisDecl = OldCXXABIThisDecl;
1969 CGF.CXXABIThisValue = OldCXXABIThisValue;
1970 CGF.CXXThisValue = OldCXXThisValue;
1971 CGF.CXXABIThisAlignment = OldCXXABIThisAlignment;
1972 CGF.CXXThisAlignment = OldCXXThisAlignment;
1973 CGF.ReturnValue = OldReturnValue;
1974 CGF.FnRetTy = OldFnRetTy;
1975 CGF.CXXInheritedCtorInitExprArgs =
1976 std::move(OldCXXInheritedCtorInitExprArgs);
1977 }
1978
1979 private:
1980 CodeGenFunction &CGF;
1981 GlobalDecl OldCurGD;
1982 const Decl *OldCurFuncDecl;
1983 const Decl *OldCurCodeDecl;
1984 ImplicitParamDecl *OldCXXABIThisDecl;
1985 llvm::Value *OldCXXABIThisValue;
1986 llvm::Value *OldCXXThisValue;
1987 CharUnits OldCXXABIThisAlignment;
1988 CharUnits OldCXXThisAlignment;
1989 Address OldReturnValue;
1990 QualType OldFnRetTy;
1991 CallArgList OldCXXInheritedCtorInitExprArgs;
1992 };
1993
1994 // Helper class for the OpenMP IR Builder. Allows reusability of code used for
1995 // region body, and finalization codegen callbacks. This will class will also
1996 // contain privatization functions used by the privatization call backs
1997 //
1998 // TODO: this is temporary class for things that are being moved out of
1999 // CGOpenMPRuntime, new versions of current CodeGenFunction methods, or
2000 // utility function for use with the OMPBuilder. Once that move to use the
2001 // OMPBuilder is done, everything here will either become part of CodeGenFunc.
2002 // directly, or a new helper class that will contain functions used by both
2003 // this and the OMPBuilder
2004
2006
2010
2011 using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
2012
2013 /// Cleanup action for allocate support.
2014 class OMPAllocateCleanupTy final : public EHScopeStack::Cleanup {
2015
2016 private:
2017 llvm::CallInst *RTLFnCI;
2018
2019 public:
2020 OMPAllocateCleanupTy(llvm::CallInst *RLFnCI) : RTLFnCI(RLFnCI) {
2021 RLFnCI->removeFromParent();
2022 }
2023
2024 void Emit(CodeGenFunction &CGF, Flags /*flags*/) override {
2025 if (!CGF.HaveInsertPoint())
2026 return;
2027 CGF.Builder.Insert(RTLFnCI);
2028 }
2029 };
2030
2031 /// Returns address of the threadprivate variable for the current
2032 /// thread. This Also create any necessary OMP runtime calls.
2033 ///
2034 /// \param VD VarDecl for Threadprivate variable.
2035 /// \param VDAddr Address of the Vardecl
2036 /// \param Loc The location where the barrier directive was encountered
2037 static Address getAddrOfThreadPrivate(CodeGenFunction &CGF,
2038 const VarDecl *VD, Address VDAddr,
2039 SourceLocation Loc);
2040
2041 /// Gets the OpenMP-specific address of the local variable /p VD.
2042 static Address getAddressOfLocalVariable(CodeGenFunction &CGF,
2043 const VarDecl *VD);
2044 /// Get the platform-specific name separator.
2045 /// \param Parts different parts of the final name that needs separation
2046 /// \param FirstSeparator First separator used between the initial two
2047 /// parts of the name.
2048 /// \param Separator separator used between all of the rest consecutinve
2049 /// parts of the name
2050 static std::string getNameWithSeparators(ArrayRef<StringRef> Parts,
2051 StringRef FirstSeparator = ".",
2052 StringRef Separator = ".");
2053 /// Emit the Finalization for an OMP region
2054 /// \param CGF The Codegen function this belongs to
2055 /// \param IP Insertion point for generating the finalization code.
2056 static void FinalizeOMPRegion(CodeGenFunction &CGF, InsertPointTy IP) {
2057 CGBuilderTy::InsertPointGuard IPG(CGF.Builder);
2058 llvm::BasicBlock *IPBB = IP.getNodeParent();
2059 assert(IPBB->end() != IP &&
2060 "OpenMP IR Builder should cause terminated block!");
2061
2062 llvm::BasicBlock *DestBB = IPBB->getUniqueSuccessor();
2063 assert(DestBB && "Finalization block should have one successor!");
2064
2065 // erase and replace with cleanup branch.
2066 IPBB->getTerminator()->eraseFromParent();
2067 CGF.Builder.SetInsertPoint(IPBB);
2069 CGF.EmitBranchThroughCleanup(Dest);
2070 }
2071
2072 /// Emit the body of an OMP region
2073 /// \param CGF The Codegen function this belongs to
2074 /// \param RegionBodyStmt The body statement for the OpenMP region being
2075 /// generated
2076 /// \param AllocaIP Where to insert alloca instructions
2077 /// \param CodeGenIP Where to insert the region code
2078 /// \param RegionName Name to be used for new blocks
2079 static void EmitOMPInlinedRegionBody(CodeGenFunction &CGF,
2080 const Stmt *RegionBodyStmt,
2081 InsertPointTy AllocaIP,
2082 InsertPointTy CodeGenIP,
2083 Twine RegionName);
2084
2085 static void EmitCaptureStmt(CodeGenFunction &CGF,
2086 llvm::BasicBlock *CodeGenIPBB,
2087 llvm::BasicBlock &FiniBB, llvm::Function *Fn,
2089 if (llvm::Instruction *CodeGenIPBBTI = CodeGenIPBB->getTerminatorOrNull())
2090 CodeGenIPBBTI->eraseFromParent();
2091
2092 CGF.Builder.SetInsertPoint(CodeGenIPBB);
2093
2094 if (Fn->doesNotThrow())
2095 CGF.EmitNounwindRuntimeCall(Fn, Args);
2096 else
2097 CGF.EmitRuntimeCall(Fn, Args);
2098
2099 if (CGF.Builder.saveIP().isValid())
2100 CGF.Builder.CreateBr(&FiniBB);
2101 }
2102
2103 /// Emit the body of an OMP region that will be outlined in
2104 /// OpenMPIRBuilder::finalize().
2105 /// \param CGF The Codegen function this belongs to
2106 /// \param RegionBodyStmt The body statement for the OpenMP region being
2107 /// generated
2108 /// \param AllocaIP Where to insert alloca instructions
2109 /// \param CodeGenIP Where to insert the region code
2110 /// \param RegionName Name to be used for new blocks
2111 static void EmitOMPOutlinedRegionBody(CodeGenFunction &CGF,
2112 const Stmt *RegionBodyStmt,
2113 InsertPointTy AllocaIP,
2114 InsertPointTy CodeGenIP,
2115 Twine RegionName);
2116
2117 /// RAII for preserving necessary info during Outlined region body codegen.
2119
2120 llvm::AssertingVH<llvm::Instruction> OldAllocaIP;
2121 CodeGenFunction::JumpDest OldReturnBlock;
2122 CodeGenFunction &CGF;
2123
2124 public:
2125 OutlinedRegionBodyRAII(CodeGenFunction &cgf, InsertPointTy &AllocaIP,
2126 llvm::BasicBlock &RetBB)
2127 : CGF(cgf) {
2128 assert(AllocaIP.isValid() &&
2129 "Must specify Insertion point for allocas of outlined function");
2130 OldAllocaIP = CGF.AllocaInsertPt;
2131 CGF.AllocaInsertPt = &*AllocaIP;
2132
2133 OldReturnBlock = CGF.ReturnBlock;
2134 CGF.ReturnBlock = CGF.getJumpDestInCurrentScope(&RetBB);
2135 }
2136
2138 CGF.AllocaInsertPt = OldAllocaIP;
2139 CGF.ReturnBlock = OldReturnBlock;
2140 }
2141 };
2142
2143 /// RAII for preserving necessary info during inlined region body codegen.
2145
2146 llvm::AssertingVH<llvm::Instruction> OldAllocaIP;
2147 CodeGenFunction &CGF;
2148
2149 public:
2150 InlinedRegionBodyRAII(CodeGenFunction &cgf, InsertPointTy &AllocaIP,
2151 llvm::BasicBlock &FiniBB)
2152 : CGF(cgf) {
2153 // Alloca insertion block should be in the entry block of the containing
2154 // function so it expects an empty AllocaIP in which case will reuse the
2155 // old alloca insertion point, or a new AllocaIP in the same block as
2156 // the old one
2157 assert((!AllocaIP.isValid() ||
2158 CGF.AllocaInsertPt->getParent() == AllocaIP.getNodeParent()) &&
2159 "Insertion point should be in the entry block of containing "
2160 "function!");
2161 OldAllocaIP = CGF.AllocaInsertPt;
2162 if (AllocaIP.isValid())
2163 CGF.AllocaInsertPt = &*AllocaIP;
2164
2165 // TODO: Remove the call, after making sure the counter is not used by
2166 // the EHStack.
2167 // Since this is an inlined region, it should not modify the
2168 // ReturnBlock, and should reuse the one for the enclosing outlined
2169 // region. So, the JumpDest being return by the function is discarded
2170 (void)CGF.getJumpDestInCurrentScope(&FiniBB);
2171 }
2172
2173 ~InlinedRegionBodyRAII() { CGF.AllocaInsertPt = OldAllocaIP; }
2174 };
2175 };
2176
2177private:
2178 /// CXXThisDecl - When generating code for a C++ member function,
2179 /// this will hold the implicit 'this' declaration.
2180 ImplicitParamDecl *CXXABIThisDecl = nullptr;
2181 llvm::Value *CXXABIThisValue = nullptr;
2182 llvm::Value *CXXThisValue = nullptr;
2183 CharUnits CXXABIThisAlignment;
2184 CharUnits CXXThisAlignment;
2185
2186 /// The value of 'this' to use when evaluating CXXDefaultInitExprs within
2187 /// this expression.
2188 Address CXXDefaultInitExprThis = Address::invalid();
2189
2190 /// The current array initialization index when evaluating an
2191 /// ArrayInitIndexExpr within an ArrayInitLoopExpr.
2192 llvm::Value *ArrayInitIndex = nullptr;
2193
2194 /// The values of function arguments to use when evaluating
2195 /// CXXInheritedCtorInitExprs within this context.
2196 CallArgList CXXInheritedCtorInitExprArgs;
2197
2198 /// CXXStructorImplicitParamDecl - When generating code for a constructor or
2199 /// destructor, this will hold the implicit argument (e.g. VTT).
2200 ImplicitParamDecl *CXXStructorImplicitParamDecl = nullptr;
2201 llvm::Value *CXXStructorImplicitParamValue = nullptr;
2202
2203 /// OutermostConditional - Points to the outermost active
2204 /// conditional control. This is used so that we know if a
2205 /// temporary should be destroyed conditionally.
2206 ConditionalEvaluation *OutermostConditional = nullptr;
2207
2208 /// The current lexical scope.
2209 LexicalScope *CurLexicalScope = nullptr;
2210
2211 /// The current source location that should be used for exception
2212 /// handling code.
2213 SourceLocation CurEHLocation;
2214
2215 /// BlockByrefInfos - For each __block variable, contains
2216 /// information about the layout of the variable.
2217 llvm::DenseMap<const ValueDecl *, BlockByrefInfo> BlockByrefInfos;
2218
2219 /// Used by -fsanitize=nullability-return to determine whether the return
2220 /// value can be checked.
2221 llvm::Value *RetValNullabilityPrecondition = nullptr;
2222
2223 /// Check if -fsanitize=nullability-return instrumentation is required for
2224 /// this function.
2225 bool requiresReturnValueNullabilityCheck() const {
2226 return RetValNullabilityPrecondition;
2227 }
2228
2229 /// Used to store precise source locations for return statements by the
2230 /// runtime return value checks.
2231 Address ReturnLocation = Address::invalid();
2232
2233 /// Check if the return value of this function requires sanitization.
2234 bool requiresReturnValueCheck() const;
2235
2236 bool isInAllocaArgument(CGCXXABI &ABI, QualType Ty);
2237 bool hasInAllocaArg(const CXXMethodDecl *MD);
2238
2239 llvm::BasicBlock *TerminateLandingPad = nullptr;
2240 llvm::BasicBlock *TerminateHandler = nullptr;
2242
2243 /// Terminate funclets keyed by parent funclet pad.
2244 llvm::MapVector<llvm::Value *, llvm::BasicBlock *> TerminateFunclets;
2245
2246 /// Largest vector width used in ths function. Will be used to create a
2247 /// function attribute.
2248 unsigned LargestVectorWidth = 0;
2249
2250 /// True if we need emit the life-time markers. This is initially set in
2251 /// the constructor, but could be overwritten to true if this is a coroutine.
2252 bool ShouldEmitLifetimeMarkers;
2253
2254 /// Add OpenCL kernel arg metadata and the kernel attribute metadata to
2255 /// the function metadata.
2256 void EmitKernelMetadata(const FunctionDecl *FD, llvm::Function *Fn);
2257
2258public:
2259 CodeGenFunction(CodeGenModule &cgm, bool suppressNewContext = false);
2261
2262 CodeGenTypes &getTypes() const { return CGM.getTypes(); }
2263 ASTContext &getContext() const { return CGM.getContext(); }
2265 if (DisableDebugInfo)
2266 return nullptr;
2267 return DebugInfo;
2268 }
2269 void disableDebugInfo() { DisableDebugInfo = true; }
2270 void enableDebugInfo() { DisableDebugInfo = false; }
2271
2273 return CGM.getCodeGenOpts().OptimizationLevel == 0 &&
2274 !SanOpts.has(SanitizerKind::Thread);
2275 }
2276
2277 const LangOptions &getLangOpts() const { return CGM.getLangOpts(); }
2278
2279 /// Returns a pointer to the function's exception object and selector slot,
2280 /// which is assigned in every landing pad.
2283
2284 /// Returns the contents of the function's exception object and selector
2285 /// slots.
2286 llvm::Value *getExceptionFromSlot();
2287 llvm::Value *getSelectorFromSlot();
2288
2290
2291 llvm::BasicBlock *getUnreachableBlock() {
2292 if (!UnreachableBlock) {
2293 UnreachableBlock = createBasicBlock("unreachable");
2294 new llvm::UnreachableInst(getLLVMContext(), UnreachableBlock);
2295 }
2296 return UnreachableBlock;
2297 }
2298
2299 llvm::BasicBlock *getInvokeDest() {
2300 if (!EHStack.requiresLandingPad())
2301 return nullptr;
2302 return getInvokeDestImpl();
2303 }
2304
2305 bool currentFunctionUsesSEHTry() const { return !!CurSEHParent; }
2306
2307 const TargetInfo &getTarget() const { return Target; }
2308 llvm::LLVMContext &getLLVMContext() { return CGM.getLLVMContext(); }
2309
2310 /// Accessors for LocalDeclMap.
2311 DeclMapTy::iterator findLocalDecl(const Decl *D) {
2312 return LocalDeclMap.find(D);
2313 }
2314 DeclMapTy::iterator localDeclMapEnd() { return LocalDeclMap.end(); }
2315 std::pair<DeclMapTy::iterator, bool> insertLocalDecl(const Decl *D,
2316 Address Addr) {
2317 return LocalDeclMap.insert({D, Addr});
2318 }
2319 void eraseLocalDecl(const Decl *D) { LocalDeclMap.erase(D); }
2321 return CGM.getTargetCodeGenInfo();
2322 }
2323 const FunctionDecl *getCurrentFunctionDecl() const;
2324
2325 //===--------------------------------------------------------------------===//
2326 // Cleanups
2327 //===--------------------------------------------------------------------===//
2328
2329 typedef void Destroyer(CodeGenFunction &CGF, Address addr, QualType ty);
2330
2331 void pushIrregularPartialArrayCleanup(llvm::Value *arrayBegin,
2332 Address arrayEndPointer,
2333 QualType elementType,
2334 CharUnits elementAlignment,
2335 Destroyer *destroyer);
2336 void pushRegularPartialArrayCleanup(llvm::Value *arrayBegin,
2337 llvm::Value *arrayEnd,
2338 QualType elementType,
2339 CharUnits elementAlignment,
2340 Destroyer *destroyer);
2341
2342 void pushDestroy(QualType::DestructionKind dtorKind, Address addr,
2343 QualType type);
2345 QualType type);
2347 Destroyer *destroyer, bool useEHCleanupForArray);
2349 Address addr, QualType type);
2351 QualType type, Destroyer *destroyer,
2352 bool useEHCleanupForArray);
2354 QualType type, Destroyer *destroyer,
2355 bool useEHCleanupForArray);
2357 Address addr, QualType type);
2358 void pushCallObjectDeleteCleanup(const FunctionDecl *OperatorDelete,
2359 llvm::Value *CompletePtr,
2360 QualType ElementType);
2363 std::pair<llvm::Value *, llvm::Value *> AddrSizePair);
2364 void emitDestroy(Address addr, QualType type, Destroyer *destroyer,
2365 bool useEHCleanupForArray);
2366 llvm::Function *generateDestroyHelper(Address addr, QualType type,
2367 Destroyer *destroyer,
2368 bool useEHCleanupForArray,
2369 const VarDecl *VD);
2370 void emitArrayDestroy(llvm::Value *begin, llvm::Value *end,
2371 QualType elementType, CharUnits elementAlign,
2372 Destroyer *destroyer, bool checkZeroLength,
2373 bool useEHCleanup);
2374
2376
2377 /// Determines whether an EH cleanup is required to destroy a type
2378 /// with the given destruction kind.
2380 switch (kind) {
2381 case QualType::DK_none:
2382 return false;
2386 return getLangOpts().Exceptions;
2388 return getLangOpts().Exceptions &&
2389 CGM.getCodeGenOpts().ObjCAutoRefCountExceptions;
2390 }
2391 llvm_unreachable("bad destruction kind");
2392 }
2393
2397
2398 //===--------------------------------------------------------------------===//
2399 // Objective-C
2400 //===--------------------------------------------------------------------===//
2401
2402 void GenerateObjCMethod(const ObjCMethodDecl *OMD);
2403
2404 void StartObjCMethod(const ObjCMethodDecl *MD, const ObjCContainerDecl *CD);
2405
2406 /// GenerateObjCGetter - Synthesize an Objective-C property getter function.
2408 const ObjCPropertyImplDecl *PID);
2409 void generateObjCGetterBody(const ObjCImplementationDecl *classImpl,
2410 const ObjCPropertyImplDecl *propImpl,
2411 const ObjCMethodDecl *GetterMothodDecl,
2412 llvm::Constant *AtomicHelperFn);
2413
2415 ObjCMethodDecl *MD, bool ctor);
2416
2417 /// GenerateObjCSetter - Synthesize an Objective-C property setter function
2418 /// for the given property.
2420 const ObjCPropertyImplDecl *PID);
2421 void generateObjCSetterBody(const ObjCImplementationDecl *classImpl,
2422 const ObjCPropertyImplDecl *propImpl,
2423 llvm::Constant *AtomicHelperFn);
2424
2425 //===--------------------------------------------------------------------===//
2426 // Block Bits
2427 //===--------------------------------------------------------------------===//
2428
2429 /// Emit block literal.
2430 /// \return an LLVM value which is a pointer to a struct which contains
2431 /// information about the block, including the block invoke function, the
2432 /// captured variables, etc.
2433 llvm::Value *EmitBlockLiteral(const BlockExpr *);
2434
2435 llvm::Function *GenerateBlockFunction(GlobalDecl GD, const CGBlockInfo &Info,
2436 const DeclMapTy &ldm,
2437 bool IsLambdaConversionToBlock,
2438 bool BuildGlobalBlock);
2439
2440 /// Check if \p T is a C++ class that has a destructor that can throw.
2441 static bool cxxDestructorCanThrow(QualType T);
2442
2443 llvm::Constant *GenerateCopyHelperFunction(const CGBlockInfo &blockInfo);
2444 llvm::Constant *GenerateDestroyHelperFunction(const CGBlockInfo &blockInfo);
2445 llvm::Constant *
2447 llvm::Constant *
2449 llvm::Value *EmitBlockCopyAndAutorelease(llvm::Value *Block, QualType Ty);
2450
2451 void BuildBlockRelease(llvm::Value *DeclPtr, BlockFieldFlags flags,
2452 bool CanThrow);
2453
2454 class AutoVarEmission;
2455
2456 void emitByrefStructureInit(const AutoVarEmission &emission);
2457
2458 /// Enter a cleanup to destroy a __block variable. Note that this
2459 /// cleanup should be a no-op if the variable hasn't left the stack
2460 /// yet; if a cleanup is required for the variable itself, that needs
2461 /// to be done externally.
2462 ///
2463 /// \param Kind Cleanup kind.
2464 ///
2465 /// \param Addr When \p LoadBlockVarAddr is false, the address of the __block
2466 /// structure that will be passed to _Block_object_dispose. When
2467 /// \p LoadBlockVarAddr is true, the address of the field of the block
2468 /// structure that holds the address of the __block structure.
2469 ///
2470 /// \param Flags The flag that will be passed to _Block_object_dispose.
2471 ///
2472 /// \param LoadBlockVarAddr Indicates whether we need to emit a load from
2473 /// \p Addr to get the address of the __block structure.
2475 bool LoadBlockVarAddr, bool CanThrow);
2476
2477 void setBlockContextParameter(const ImplicitParamDecl *D, unsigned argNum,
2478 llvm::Value *ptr);
2479
2482
2483 /// BuildBlockByrefAddress - Computes the location of the
2484 /// data in a variable which is declared as __block.
2486 bool followForward = true);
2488 bool followForward, const llvm::Twine &name);
2489
2490 const BlockByrefInfo &getBlockByrefInfo(const VarDecl *var);
2491
2493
2494 void GenerateCode(GlobalDecl GD, llvm::Function *Fn,
2495 const CGFunctionInfo &FnInfo);
2496
2497 /// Annotate the function with an attribute that disables TSan checking at
2498 /// runtime.
2499 void markAsIgnoreThreadCheckingAtRuntime(llvm::Function *Fn);
2500
2501 /// Emit code for the start of a function.
2502 /// \param Loc The location to be associated with the function.
2503 /// \param StartLoc The location of the function body.
2504 void StartFunction(GlobalDecl GD, QualType RetTy, llvm::Function *Fn,
2505 const CGFunctionInfo &FnInfo, const FunctionArgList &Args,
2507 SourceLocation StartLoc = SourceLocation());
2508
2509 static bool IsConstructorDelegationValid(const CXXConstructorDecl *Ctor);
2510
2514 void EmitFunctionBody(const Stmt *Body);
2515 void EmitBlockWithFallThrough(llvm::BasicBlock *BB, const Stmt *S);
2516
2517 void EmitForwardingCallToLambda(const CXXMethodDecl *LambdaCallOperator,
2518 CallArgList &CallArgs,
2519 const CGFunctionInfo *CallOpFnInfo = nullptr,
2520 llvm::Constant *CallOpFn = nullptr);
2524 CallArgList &CallArgs);
2525 void EmitLambdaInAllocaImplFn(const CXXMethodDecl *CallOp,
2526 const CGFunctionInfo **ImplFnInfo,
2527 llvm::Function **ImplFn);
2530 EmitStoreThroughLValue(RValue::get(VLASizeMap[VAT->getSizeExpr()]), LV);
2531 }
2532 void EmitAsanPrologueOrEpilogue(bool Prologue);
2533
2534 /// Emit the unified return block, trying to avoid its emission when
2535 /// possible.
2536 /// \return The debug location of the user written return statement if the
2537 /// return block is avoided.
2538 llvm::DebugLoc EmitReturnBlock();
2539
2540 /// FinishFunction - Complete IR generation of the current function. It is
2541 /// legal to call this function even if there is no current insertion point.
2543
2544 void StartThunk(llvm::Function *Fn, GlobalDecl GD,
2545 const CGFunctionInfo &FnInfo, bool IsUnprototyped);
2546
2547 void EmitCallAndReturnForThunk(llvm::FunctionCallee Callee,
2548 const ThunkInfo *Thunk, bool IsUnprototyped);
2549
2550 void FinishThunk();
2551
2552 /// Start an Objective-C direct method thunk.
2554 llvm::Function *Fn,
2555 const CGFunctionInfo &FI);
2556
2557 /// Finish an Objective-C direct method thunk.
2559
2560 /// Emit a musttail call for a thunk with a potentially adjusted this pointer.
2561 void EmitMustTailThunk(GlobalDecl GD, llvm::Value *AdjustedThisPtr,
2562 llvm::FunctionCallee Callee);
2563
2564 /// Generate a thunk for the given method.
2565 void generateThunk(llvm::Function *Fn, const CGFunctionInfo &FnInfo,
2566 GlobalDecl GD, const ThunkInfo &Thunk,
2567 bool IsUnprototyped);
2568
2569 llvm::Function *GenerateVarArgsThunk(llvm::Function *Fn,
2570 const CGFunctionInfo &FnInfo,
2571 GlobalDecl GD, const ThunkInfo &Thunk);
2572
2574 FunctionArgList &Args);
2575
2576 void EmitInitializerForField(FieldDecl *Field, LValue LHS, Expr *Init);
2577
2578 /// Struct with all information about dynamic [sub]class needed to set vptr.
2585
2586 /// Initialize the vtable pointer of the given subobject.
2587 void InitializeVTablePointer(const VPtr &vptr);
2588
2590
2592 VPtrsVector getVTablePointers(const CXXRecordDecl *VTableClass);
2593
2594 void getVTablePointers(BaseSubobject Base, const CXXRecordDecl *NearestVBase,
2595 CharUnits OffsetFromNearestVBase,
2596 bool BaseIsNonVirtualPrimaryBase,
2597 const CXXRecordDecl *VTableClass,
2598 VisitedVirtualBasesSetTy &VBases, VPtrsVector &vptrs);
2599
2600 void InitializeVTablePointers(const CXXRecordDecl *ClassDecl);
2601
2602 // VTableTrapMode - whether we guarantee that loading the
2603 // vtable is guaranteed to trap on authentication failure,
2604 // even if the resulting vtable pointer is unused.
2605 enum class VTableAuthMode {
2608 UnsafeUbsanStrip // Should only be used for Vptr UBSan check
2609 };
2610 /// GetVTablePtr - Return the Value of the vtable pointer member pointed
2611 /// to by This.
2612 llvm::Value *
2613 GetVTablePtr(Address This, llvm::Type *VTableTy,
2614 const CXXRecordDecl *VTableClass,
2616
2626
2627 /// Derived is the presumed address of an object of type T after a
2628 /// cast. If T is a polymorphic class type, emit a check that the virtual
2629 /// table for Derived belongs to a class derived from T.
2630 void EmitVTablePtrCheckForCast(QualType T, Address Derived, bool MayBeNull,
2632
2633 /// EmitVTablePtrCheckForCall - Virtual method MD is being called via VTable.
2634 /// If vptr CFI is enabled, emit a check that VTable is valid.
2635 void EmitVTablePtrCheckForCall(const CXXRecordDecl *RD, llvm::Value *VTable,
2637
2638 /// EmitVTablePtrCheck - Emit a check that VTable is a valid virtual table for
2639 /// RD using llvm.type.test.
2640 void EmitVTablePtrCheck(const CXXRecordDecl *RD, llvm::Value *VTable,
2642
2643 /// Emit a CFI check failure handler or trap for a vtable type test result.
2644 void EmitVTableCheck(CFITypeCheckKind TCK, CanQualType T, llvm::Metadata *MD,
2645 llvm::Value *VTable, llvm::Value *TypeTest,
2646 SourceLocation Loc, bool UseCrossDsoSlowPath);
2647
2648 /// If whole-program virtual table optimization is enabled, emit an assumption
2649 /// that VTable is a member of RD's type identifier. Or, if vptr CFI is
2650 /// enabled, emit a check that VTable is a member of RD's type identifier.
2652 llvm::Value *VTable, SourceLocation Loc);
2653
2654 /// Returns whether we should perform a type checked load when loading a
2655 /// virtual function for virtual calls to members of RD. This is generally
2656 /// true when both vcall CFI and whole-program-vtables are enabled.
2658
2659 /// Emit a type checked load from the given vtable.
2660 llvm::Value *EmitVTableTypeCheckedLoad(const CXXRecordDecl *RD,
2661 llvm::Value *VTable,
2662 llvm::Type *VTableTy,
2663 uint64_t VTableByteOffset,
2664 SourceLocation Loc);
2665
2666 /// EnterDtorCleanups - Enter the cleanups necessary to complete the
2667 /// given phase of destruction for a destructor. The end result
2668 /// should call destructors on members and base classes in reverse
2669 /// order of their construction.
2671
2672 /// ShouldInstrumentFunction - Return true if the current function should be
2673 /// instrumented with __cyg_profile_func_* calls
2675
2676 /// ShouldSkipSanitizerInstrumentation - Return true if the current function
2677 /// should not be instrumented with sanitizers.
2679
2680 /// ShouldXRayInstrument - Return true if the current function should be
2681 /// instrumented with XRay nop sleds.
2682 bool ShouldXRayInstrumentFunction() const;
2683
2684 /// AlwaysEmitXRayCustomEvents - Return true if we must unconditionally emit
2685 /// XRay custom event handling calls.
2686 bool AlwaysEmitXRayCustomEvents() const;
2687
2688 /// AlwaysEmitXRayTypedEvents - Return true if clang must unconditionally emit
2689 /// XRay typed event handling calls.
2690 bool AlwaysEmitXRayTypedEvents() const;
2691
2692 /// Return a type hash constant for a function instrumented by
2693 /// -fsanitize=function.
2694 llvm::ConstantInt *getUBSanFunctionTypeHash(QualType T) const;
2695
2696 /// EmitFunctionProlog - Emit the target specific LLVM code to load the
2697 /// arguments for the given function. This is also responsible for naming the
2698 /// LLVM function arguments.
2699 void EmitFunctionProlog(const CGFunctionInfo &FI, llvm::Function *Fn,
2700 const FunctionArgList &Args);
2701
2702 /// EmitFunctionEpilog - Emit the target specific LLVM code to return the
2703 /// given temporary. Specify the source location atom group (Key Instructions
2704 /// debug info feature) for the `ret` using \p RetKeyInstructionsSourceAtom.
2705 /// If it's 0, the `ret` will get added to a new source atom group.
2706 void EmitFunctionEpilog(const CGFunctionInfo &FI, bool EmitRetDbgLoc,
2707 SourceLocation EndLoc,
2708 uint64_t RetKeyInstructionsSourceAtom);
2709
2710 /// Emit a test that checks if the return value \p RV is nonnull.
2711 void EmitReturnValueCheck(llvm::Value *RV);
2712
2713 /// EmitStartEHSpec - Emit the start of the exception spec.
2714 void EmitStartEHSpec(const Decl *D);
2715
2716 /// EmitEndEHSpec - Emit the end of the exception spec.
2717 void EmitEndEHSpec(const Decl *D);
2718
2719 /// getTerminateLandingPad - Return a landing pad that just calls terminate.
2720 llvm::BasicBlock *getTerminateLandingPad();
2721
2722 /// getTerminateLandingPad - Return a cleanup funclet that just calls
2723 /// terminate.
2724 llvm::BasicBlock *getTerminateFunclet();
2725
2726 /// getTerminateHandler - Return a handler (not a landing pad, just
2727 /// a catch handler) that just calls terminate. This is used when
2728 /// a terminate scope encloses a try.
2729 llvm::BasicBlock *getTerminateHandler();
2730
2731 llvm::Type *ConvertTypeForMem(QualType T);
2732 llvm::Type *ConvertType(QualType T);
2733 llvm::Type *convertTypeForLoadStore(QualType ASTTy,
2734 llvm::Type *LLVMTy = nullptr);
2735 llvm::Type *ConvertType(const TypeDecl *T) {
2736 return ConvertType(getContext().getTypeDeclType(T));
2737 }
2738
2739 /// LoadObjCSelf - Load the value of self. This function is only valid while
2740 /// generating code for an Objective-C method.
2741 llvm::Value *LoadObjCSelf();
2742
2743 /// TypeOfSelfObject - Return type of object that this self represents.
2745
2746 /// getEvaluationKind - Return the TypeEvaluationKind of QualType \c T.
2748
2750 return getEvaluationKind(T) == TEK_Scalar;
2751 }
2752
2756
2757 /// createBasicBlock - Create an LLVM basic block.
2758 llvm::BasicBlock *createBasicBlock(const Twine &name = "",
2759 llvm::Function *parent = nullptr,
2760 llvm::BasicBlock *before = nullptr) {
2761 return llvm::BasicBlock::Create(getLLVMContext(), name, parent, before);
2762 }
2763
2764 /// getBasicBlockForLabel - Return the LLVM basicblock that the specified
2765 /// label maps to.
2766 JumpDest getJumpDestForLabel(const LabelDecl *S);
2767
2768 /// SimplifyForwardingBlocks - If the given basic block is only a branch to
2769 /// another basic block, simplify it. This assumes that no other code could
2770 /// potentially reference the basic block.
2771 void SimplifyForwardingBlocks(llvm::BasicBlock *BB);
2772
2773 /// EmitBlock - Emit the given block \arg BB and set it as the insert point,
2774 /// adding a fall-through branch from the current insert block if
2775 /// necessary. It is legal to call this function even if there is no current
2776 /// insertion point.
2777 ///
2778 /// IsFinished - If true, indicates that the caller has finished emitting
2779 /// branches to the given block and does not expect to emit code into it. This
2780 /// means the block can be ignored if it is unreachable.
2781 void EmitBlock(llvm::BasicBlock *BB, bool IsFinished = false);
2782
2783 /// EmitBlockAfterUses - Emit the given block somewhere hopefully
2784 /// near its uses, and leave the insertion point in it.
2785 void EmitBlockAfterUses(llvm::BasicBlock *BB);
2786
2787 /// EmitBranch - Emit a branch to the specified basic block from the current
2788 /// insert block, taking care to avoid creation of branches from dummy
2789 /// blocks. It is legal to call this function even if there is no current
2790 /// insertion point.
2791 ///
2792 /// This function clears the current insertion point. The caller should follow
2793 /// calls to this function with calls to Emit*Block prior to generation new
2794 /// code.
2795 void EmitBranch(llvm::BasicBlock *Block);
2796
2797 /// HaveInsertPoint - True if an insertion point is defined. If not, this
2798 /// indicates that the current code being emitted is unreachable.
2799 bool HaveInsertPoint() const { return Builder.GetInsertBlock() != nullptr; }
2800
2801 /// EnsureInsertPoint - Ensure that an insertion point is defined so that
2802 /// emitted IR has a place to go. Note that by definition, if this function
2803 /// creates a block then that block is unreachable; callers may do better to
2804 /// detect when no insertion point is defined and simply skip IR generation.
2806 if (!HaveInsertPoint())
2808 }
2809
2810 /// ErrorUnsupported - Print out an error that codegen doesn't support the
2811 /// specified stmt yet.
2812 void ErrorUnsupported(const Stmt *S, const char *Type);
2813
2814 //===--------------------------------------------------------------------===//
2815 // Helpers
2816 //===--------------------------------------------------------------------===//
2817
2819 llvm::BasicBlock *LHSBlock,
2820 llvm::BasicBlock *RHSBlock,
2821 llvm::BasicBlock *MergeBlock,
2822 QualType MergedType) {
2823 Builder.SetInsertPoint(MergeBlock);
2824 llvm::PHINode *PtrPhi = Builder.CreatePHI(LHS.getType(), 2, "cond");
2825 PtrPhi->addIncoming(LHS.getBasePointer(), LHSBlock);
2826 PtrPhi->addIncoming(RHS.getBasePointer(), RHSBlock);
2827 LHS.replaceBasePointer(PtrPhi);
2828 LHS.setAlignment(std::min(LHS.getAlignment(), RHS.getAlignment()));
2829 return LHS;
2830 }
2831
2832 /// Construct an address with the natural alignment of T. If a pointer to T
2833 /// is expected to be signed, the pointer passed to this function must have
2834 /// been signed, and the returned Address will have the pointer authentication
2835 /// information needed to authenticate the signed pointer.
2837 llvm::Value *Ptr, QualType T, CharUnits Alignment = CharUnits::Zero(),
2838 bool ForPointeeType = false, LValueBaseInfo *BaseInfo = nullptr,
2839 TBAAAccessInfo *TBAAInfo = nullptr,
2840 KnownNonNull_t IsKnownNonNull = NotKnownNonNull) {
2841 if (Alignment.isZero())
2842 Alignment =
2843 CGM.getNaturalTypeAlignment(T, BaseInfo, TBAAInfo, ForPointeeType);
2844 return Address(Ptr, ConvertTypeForMem(T), Alignment,
2845 CGM.getPointerAuthInfoForPointeeType(T), /*Offset=*/nullptr,
2846 IsKnownNonNull);
2847 }
2848
2851 return MakeAddrLValue(Addr, T, LValueBaseInfo(Source),
2852 CGM.getTBAAAccessInfo(T));
2853 }
2854
2856 TBAAAccessInfo TBAAInfo) {
2857 return LValue::MakeAddr(Addr, T, getContext(), BaseInfo, TBAAInfo);
2858 }
2859
2860 LValue MakeAddrLValue(llvm::Value *V, QualType T, CharUnits Alignment,
2862 return MakeAddrLValue(makeNaturalAddressForPointer(V, T, Alignment), T,
2863 LValueBaseInfo(Source), CGM.getTBAAAccessInfo(T));
2864 }
2865
2866 /// Same as MakeAddrLValue above except that the pointer is known to be
2867 /// unsigned.
2868 LValue MakeRawAddrLValue(llvm::Value *V, QualType T, CharUnits Alignment,
2870 Address Addr(V, ConvertTypeForMem(T), Alignment);
2871 return LValue::MakeAddr(Addr, T, getContext(), LValueBaseInfo(Source),
2872 CGM.getTBAAAccessInfo(T));
2873 }
2874
2875 LValue
2881
2882 /// Given a value of type T* that may not be to a complete object, construct
2883 /// an l-value with the natural pointee alignment of T.
2885
2886 LValue
2887 MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T,
2888 KnownNonNull_t IsKnownNonNull = NotKnownNonNull);
2889
2890 /// Same as MakeNaturalAlignPointeeAddrLValue except that the pointer is known
2891 /// to be unsigned.
2893
2895
2897 LValueBaseInfo *PointeeBaseInfo = nullptr,
2898 TBAAAccessInfo *PointeeTBAAInfo = nullptr);
2900 LValue
2903 LValue RefLVal = MakeAddrLValue(RefAddr, RefTy, LValueBaseInfo(Source),
2904 CGM.getTBAAAccessInfo(RefTy));
2905 return EmitLoadOfReferenceLValue(RefLVal);
2906 }
2907
2908 /// Load a pointer with type \p PtrTy stored at address \p Ptr.
2909 /// Note that \p PtrTy is the type of the loaded pointer, not the addresses
2910 /// it is loaded from.
2911 Address EmitLoadOfPointer(Address Ptr, const PointerType *PtrTy,
2912 LValueBaseInfo *BaseInfo = nullptr,
2913 TBAAAccessInfo *TBAAInfo = nullptr);
2915
2916private:
2917 struct AllocaTracker {
2918 void Add(llvm::AllocaInst *I) { Allocas.push_back(I); }
2919 llvm::SmallVector<llvm::AllocaInst *> Take() { return std::move(Allocas); }
2920
2921 private:
2923 };
2924 AllocaTracker *Allocas = nullptr;
2925
2926 /// CGDecl helper.
2927 void emitStoresForConstant(const VarDecl &D, Address Loc, bool isVolatile,
2928 llvm::Constant *constant, bool IsAutoInit);
2929 /// CGDecl helper.
2930 void emitStoresForZeroInit(const VarDecl &D, Address Loc, bool isVolatile);
2931 /// CGDecl helper.
2932 void emitStoresForPatternInit(const VarDecl &D, Address Loc, bool isVolatile);
2933 /// CGDecl helper.
2934 void emitStoresForInitAfterBZero(llvm::Constant *Init, Address Loc,
2935 bool isVolatile, bool IsAutoInit);
2936
2937public:
2938 // Captures all the allocas created during the scope of its RAII object.
2940 AllocaTrackerRAII(CodeGenFunction &CGF)
2941 : CGF(CGF), OldTracker(CGF.Allocas) {
2942 CGF.Allocas = &Tracker;
2943 }
2944 ~AllocaTrackerRAII() { CGF.Allocas = OldTracker; }
2945
2946 llvm::SmallVector<llvm::AllocaInst *> Take() { return Tracker.Take(); }
2947
2948 private:
2949 CodeGenFunction &CGF;
2950 AllocaTracker *OldTracker;
2951 AllocaTracker Tracker;
2952 };
2953
2954private:
2955 /// If \p Alloca is not in the same address space as \p DestLangAS, insert an
2956 /// address space cast and return a new RawAddress based on this value.
2957 RawAddress MaybeCastStackAddressSpace(RawAddress Alloca, LangAS DestLangAS,
2958 llvm::Value *ArraySize = nullptr);
2959
2960public:
2961 /// CreateTempAlloca - This creates an alloca and inserts it into the entry
2962 /// block if \p ArraySize is nullptr, otherwise inserts it at the current
2963 /// insertion point of the builder. The caller is responsible for setting an
2964 /// appropriate alignment on the alloca.
2965 ///
2966 /// \p ArraySize is the number of array elements to be allocated if it
2967 /// is not nullptr.
2968 ///
2969 /// LangAS::Default is the address space of pointers to local variables and
2970 /// temporaries, as exposed in the source language. In certain
2971 /// configurations, this is not the same as the alloca address space, and a
2972 /// cast is needed to lift the pointer from the alloca AS into
2973 /// LangAS::Default. This can happen when the target uses a restricted
2974 /// address space for the stack but the source language requires
2975 /// LangAS::Default to be a generic address space. The latter condition is
2976 /// common for most programming languages; OpenCL is an exception in that
2977 /// LangAS::Default is the private address space, which naturally maps
2978 /// to the stack.
2979 ///
2980 /// Because the address of a temporary is often exposed to the program in
2981 /// various ways, this function will perform the cast. The original alloca
2982 /// instruction is returned through \p Alloca if it is not nullptr.
2983 ///
2984 /// The cast is not performed in CreateTempAllocaWithoutCast. This is
2985 /// more efficient if the caller knows that the address will not be exposed.
2986 llvm::AllocaInst *CreateTempAlloca(llvm::Type *Ty, const Twine &Name = "tmp",
2987 llvm::Value *ArraySize = nullptr);
2988
2989 /// CreateTempAlloca - This creates a alloca and inserts it into the entry
2990 /// block. The alloca is casted to the address space of \p UseAddrSpace if
2991 /// necessary.
2992 RawAddress CreateTempAlloca(llvm::Type *Ty, LangAS UseAddrSpace,
2993 CharUnits align, const Twine &Name = "tmp",
2994 llvm::Value *ArraySize = nullptr,
2995 RawAddress *Alloca = nullptr);
2996
2997 /// CreateTempAlloca - This creates a alloca and inserts it into the entry
2998 /// block. The alloca is casted to default address space if necessary.
2999 ///
3000 /// FIXME: This version should be removed, and context should provide the
3001 /// context use address space used instead of default.
3003 const Twine &Name = "tmp",
3004 llvm::Value *ArraySize = nullptr,
3005 RawAddress *Alloca = nullptr) {
3006 return CreateTempAlloca(Ty, LangAS::Default, align, Name, ArraySize,
3007 Alloca);
3008 }
3009
3010 RawAddress CreateTempAllocaWithoutCast(llvm::Type *Ty, CharUnits align,
3011 const Twine &Name = "tmp",
3012 llvm::Value *ArraySize = nullptr);
3013
3014 /// CreateDefaultAlignedTempAlloca - This creates an alloca with the
3015 /// default ABI alignment of the given LLVM type.
3016 ///
3017 /// IMPORTANT NOTE: This is *not* generally the right alignment for
3018 /// any given AST type that happens to have been lowered to the
3019 /// given IR type. This should only ever be used for function-local,
3020 /// IR-driven manipulations like saving and restoring a value. Do
3021 /// not hand this address off to arbitrary IRGen routines, and especially
3022 /// do not pass it as an argument to a function that might expect a
3023 /// properly ABI-aligned value.
3025 const Twine &Name = "tmp");
3026
3027 /// CreateIRTempWithoutCast - Create a temporary IR object of the given type,
3028 /// with appropriate alignment. This routine should only be used when an
3029 /// temporary value needs to be stored into an alloca (for example, to avoid
3030 /// explicit PHI construction), but the type is the IR type, not the type
3031 /// appropriate for storing in memory.
3032 ///
3033 /// That is, this is exactly equivalent to CreateMemTemp, but calling
3034 /// ConvertType instead of ConvertTypeForMem.
3035 RawAddress CreateIRTempWithoutCast(QualType T, const Twine &Name = "tmp");
3036
3037 /// CreateMemTemp - Create a temporary memory object of the given type, with
3038 /// appropriate alignmen and cast it to the default address space. Returns
3039 /// the original alloca instruction by \p Alloca if it is not nullptr.
3040 RawAddress CreateMemTemp(QualType T, const Twine &Name = "tmp",
3041 RawAddress *Alloca = nullptr);
3043 const Twine &Name = "tmp",
3044 RawAddress *Alloca = nullptr);
3045
3046 /// CreateMemTemp - Create a temporary memory object of the given type, with
3047 /// appropriate alignmen without casting it to the default address space.
3048 RawAddress CreateMemTempWithoutCast(QualType T, const Twine &Name = "tmp");
3050 const Twine &Name = "tmp");
3051
3052 /// CreateAggTemp - Create a temporary memory object for the given
3053 /// aggregate type.
3054 AggValueSlot CreateAggTemp(QualType T, const Twine &Name = "tmp",
3055 RawAddress *Alloca = nullptr) {
3056 RawAddress Addr = CreateMemTemp(T, Name, Alloca);
3057 return AggValueSlot::forAddr(
3058 Addr, T.getQualifiers(), AggValueSlot::IsNotDestructed,
3061 }
3062
3063 /// EvaluateExprAsBool - Perform the usual unary conversions on the specified
3064 /// expression and compare the result against zero, returning an Int1Ty value.
3065 llvm::Value *EvaluateExprAsBool(const Expr *E);
3066
3067 /// Retrieve the implicit cast expression of the rhs in a binary operator
3068 /// expression by passing pointers to Value and QualType
3069 /// This is used for implicit bitfield conversion checks, which
3070 /// must compare with the value before potential truncation.
3072 llvm::Value **Previous,
3073 QualType *SrcType);
3074
3075 /// Emit a check that an [implicit] conversion of a bitfield. It is not UB,
3076 /// so we use the value after conversion.
3077 void EmitBitfieldConversionCheck(llvm::Value *Src, QualType SrcType,
3078 llvm::Value *Dst, QualType DstType,
3079 const CGBitFieldInfo &Info,
3080 SourceLocation Loc);
3081
3082 /// EmitIgnoredExpr - Emit an expression in a context which ignores the
3083 /// result.
3084 void EmitIgnoredExpr(const Expr *E);
3085
3086 /// EmitAnyExpr - Emit code to compute the specified expression which can have
3087 /// any type. The result is returned as an RValue struct. If this is an
3088 /// aggregate expression, the aggloc/agglocvolatile arguments indicate where
3089 /// the result should be returned.
3090 ///
3091 /// \param ignoreResult True if the resulting value isn't used.
3092 RValue EmitAnyExpr(const Expr *E,
3094 bool ignoreResult = false);
3095
3096 // EmitVAListRef - Emit a "reference" to a va_list; this is either the address
3097 // or the value of the expression, depending on how va_list is defined.
3098 Address EmitVAListRef(const Expr *E);
3099
3100 /// Emit a "reference" to a __builtin_ms_va_list; this is
3101 /// always the value of the expression, because a __builtin_ms_va_list is a
3102 /// pointer to a char.
3103 Address EmitMSVAListRef(const Expr *E);
3104
3105 /// Emit a "reference" to a __builtin_zos_va_list; this is always the
3106 /// address of the expression, because a __builtin_zos_va_list is an
3107 /// array of pointer to a char.
3108 Address EmitZOSVAListRef(const Expr *E);
3109
3110 /// EmitAnyExprToTemp - Similarly to EmitAnyExpr(), however, the result will
3111 /// always be accessible even if no aggregate location is provided.
3112 RValue EmitAnyExprToTemp(const Expr *E);
3113
3114 /// EmitAnyExprToMem - Emits the code necessary to evaluate an
3115 /// arbitrary expression into the given memory location.
3116 void EmitAnyExprToMem(const Expr *E, Address Location, Qualifiers Quals,
3117 bool IsInitializer);
3118
3119 void EmitAnyExprToExn(const Expr *E, Address Addr);
3120
3121 /// EmitInitializationToLValue - Emit an initializer to an LValue.
3123 const Expr *E, LValue LV,
3125
3126 /// EmitExprAsInit - Emits the code necessary to initialize a
3127 /// location in memory with the given initializer.
3128 void EmitExprAsInit(const Expr *init, const ValueDecl *D, LValue lvalue,
3129 bool capturedByInit);
3130
3131 /// hasVolatileMember - returns true if aggregate type has a volatile
3132 /// member.
3134 if (const auto *RD = T->getAsRecordDecl())
3135 return RD->hasVolatileMember();
3136 return false;
3137 }
3138
3139 /// Determine whether a return value slot may overlap some other object.
3141 // FIXME: Assuming no overlap here breaks guaranteed copy elision for base
3142 // class subobjects. These cases may need to be revisited depending on the
3143 // resolution of the relevant core issue.
3145 }
3146
3147 /// Determine whether a field initialization may overlap some other object.
3149
3150 /// Determine whether a base class initialization may overlap some other
3151 /// object.
3153 const CXXRecordDecl *BaseRD,
3154 bool IsVirtual);
3155
3156 /// Emit an aggregate assignment.
3159 bool IsVolatile = hasVolatileMember(EltTy);
3160 EmitAggregateCopy(Dest, Src, EltTy, AggValueSlot::MayOverlap, IsVolatile);
3161 }
3162
3164 AggValueSlot::Overlap_t MayOverlap) {
3165 EmitAggregateCopy(Dest, Src, Src.getType(), MayOverlap);
3166 }
3167
3168 /// EmitAggregateCopy - Emit an aggregate copy.
3169 ///
3170 /// \param isVolatile \c true iff either the source or the destination is
3171 /// volatile.
3172 /// \param MayOverlap Whether the tail padding of the destination might be
3173 /// occupied by some other object. More efficient code can often be
3174 /// generated if not.
3175 void EmitAggregateCopy(LValue Dest, LValue Src, QualType EltTy,
3176 AggValueSlot::Overlap_t MayOverlap,
3177 bool isVolatile = false);
3178
3179 /// GetAddrOfLocalVar - Return the address of a local variable.
3181 auto it = LocalDeclMap.find(VD);
3182 assert(it != LocalDeclMap.end() &&
3183 "Invalid argument to GetAddrOfLocalVar(), no decl!");
3184 return it->second;
3185 }
3186
3187 /// Given an opaque value expression, return its LValue mapping if it exists,
3188 /// otherwise create one.
3190
3191 /// Given an opaque value expression, return its RValue mapping if it exists,
3192 /// otherwise create one.
3194
3195 /// isOpaqueValueEmitted - Return true if the opaque value expression has
3196 /// already been emitted.
3198
3199 /// Get the index of the current ArrayInitLoopExpr, if any.
3200 llvm::Value *getArrayInitIndex() { return ArrayInitIndex; }
3201
3202 /// getAccessedFieldNo - Given an encoded value and a result number, return
3203 /// the input field number being accessed.
3204 static unsigned getAccessedFieldNo(unsigned Idx, const llvm::Constant *Elts);
3205
3206 llvm::BlockAddress *GetAddrOfLabel(const LabelDecl *L);
3207 llvm::BasicBlock *GetIndirectGotoBlock();
3208
3209 /// Check if \p E is a C++ "this" pointer wrapped in value-preserving casts.
3210 static bool IsWrappedCXXThis(const Expr *E);
3211
3212 /// EmitNullInitialization - Generate code to set a value of the given type to
3213 /// null, If the type contains data member pointers, they will be initialized
3214 /// to -1 in accordance with the Itanium C++ ABI.
3215 void EmitNullInitialization(Address DestPtr, QualType Ty);
3216
3217 /// Emits a call to an LLVM variable-argument intrinsic, either
3218 /// \c llvm.va_start or \c llvm.va_end.
3219 /// \param ArgValue A reference to the \c va_list as emitted by either
3220 /// \c EmitVAListRef or \c EmitMSVAListRef.
3221 /// \param IsStart If \c true, emits a call to \c llvm.va_start; otherwise,
3222 /// calls \c llvm.va_end.
3223 llvm::Value *EmitVAStartEnd(llvm::Value *ArgValue, bool IsStart);
3224
3225 /// Generate code to get an argument from the passed in pointer
3226 /// and update it accordingly.
3227 /// \param VE The \c VAArgExpr for which to generate code.
3228 /// \param VAListAddr Receives a reference to the \c va_list as emitted by
3229 /// either \c EmitVAListRef or \c EmitMSVAListRef.
3230 /// \returns A pointer to the argument.
3231 // FIXME: We should be able to get rid of this method and use the va_arg
3232 // instruction in LLVM instead once it works well enough.
3233 RValue EmitVAArg(VAArgExpr *VE, Address &VAListAddr,
3235
3236 /// emitArrayLength - Compute the length of an array, even if it's a
3237 /// VLA, and drill down to the base element type.
3238 llvm::Value *emitArrayLength(const ArrayType *arrayType, QualType &baseType,
3239 Address &addr);
3240
3241 /// EmitVLASize - Capture all the sizes for the VLA expressions in
3242 /// the given variably-modified type and store them in the VLASizeMap.
3243 ///
3244 /// This function can be called with a null (unreachable) insert point.
3246
3248 llvm::Value *NumElts;
3250
3251 VlaSizePair(llvm::Value *NE, QualType T) : NumElts(NE), Type(T) {}
3252 };
3253
3254 /// Return the number of elements for a single dimension
3255 /// for the given array type.
3256 VlaSizePair getVLAElements1D(const VariableArrayType *vla);
3257 VlaSizePair getVLAElements1D(QualType vla);
3258
3259 /// Returns an LLVM value that corresponds to the size,
3260 /// in non-variably-sized elements, of a variable length array type,
3261 /// plus that largest non-variably-sized element type. Assumes that
3262 /// the type has already been emitted with EmitVariablyModifiedType.
3263 VlaSizePair getVLASize(const VariableArrayType *vla);
3264 VlaSizePair getVLASize(QualType vla);
3265
3266 /// LoadCXXThis - Load the value of 'this'. This function is only valid while
3267 /// generating code for an C++ member function.
3268 llvm::Value *LoadCXXThis() {
3269 assert(CXXThisValue && "no 'this' value for this function");
3270 return CXXThisValue;
3271 }
3273
3274 /// LoadCXXVTT - Load the VTT parameter to base constructors/destructors have
3275 /// virtual bases.
3276 // FIXME: Every place that calls LoadCXXVTT is something
3277 // that needs to be abstracted properly.
3278 llvm::Value *LoadCXXVTT() {
3279 assert(CXXStructorImplicitParamValue && "no VTT value for this function");
3280 return CXXStructorImplicitParamValue;
3281 }
3282
3283 /// GetAddressOfBaseOfCompleteClass - Convert the given pointer to a
3284 /// complete class to the given direct base.
3286 const CXXRecordDecl *Derived,
3287 const CXXRecordDecl *Base,
3288 bool BaseIsVirtual);
3289
3290 static bool ShouldNullCheckClassCastValue(const CastExpr *Cast);
3291
3292 /// GetAddressOfBaseClass - This function will add the necessary delta to the
3293 /// load of 'this' and returns address of the base class.
3297 bool NullCheckValue, SourceLocation Loc);
3298
3302 bool NullCheckValue);
3303
3304 /// GetVTTParameter - Return the VTT parameter that should be passed to a
3305 /// base constructor/destructor with virtual bases.
3306 /// FIXME: VTTs are Itanium ABI-specific, so the definition should move
3307 /// to ItaniumCXXABI.cpp together with all the references to VTT.
3308 llvm::Value *GetVTTParameter(GlobalDecl GD, bool ForVirtualBase,
3309 bool Delegating);
3310
3312 CXXCtorType CtorType,
3313 const FunctionArgList &Args,
3314 SourceLocation Loc);
3315 // It's important not to confuse this and the previous function. Delegating
3316 // constructors are the C++0x feature. The constructor delegate optimization
3317 // is used to reduce duplication in the base and complete consturctors where
3318 // they are substantially the same.
3320 const FunctionArgList &Args);
3321
3322 /// Emit a call to an inheriting constructor (that is, one that invokes a
3323 /// constructor inherited from a base class) by inlining its definition. This
3324 /// is necessary if the ABI does not support forwarding the arguments to the
3325 /// base class constructor (because they're variadic or similar).
3327 CXXCtorType CtorType,
3328 bool ForVirtualBase,
3329 bool Delegating,
3330 CallArgList &Args);
3331
3332 /// Emit a call to a constructor inherited from a base class, passing the
3333 /// current constructor's arguments along unmodified (without even making
3334 /// a copy).
3336 bool ForVirtualBase, Address This,
3337 bool InheritedFromVBase,
3338 const CXXInheritedCtorInitExpr *E);
3339
3341 bool ForVirtualBase, bool Delegating,
3342 AggValueSlot ThisAVS, const CXXConstructExpr *E);
3343
3345 bool ForVirtualBase, bool Delegating,
3346 Address This, CallArgList &Args,
3348 SourceLocation Loc, bool NewPointerIsChecked,
3349 llvm::CallBase **CallOrInvoke = nullptr);
3350
3351 /// Emit assumption load for all bases. Requires to be called only on
3352 /// most-derived class and not under construction of the object.
3353 void EmitVTableAssumptionLoads(const CXXRecordDecl *ClassDecl, Address This);
3354
3355 /// Emit assumption that vptr load == global vtable.
3356 void EmitVTableAssumptionLoad(const VPtr &vptr, Address This);
3357
3359 Address Src, const CXXConstructExpr *E);
3360
3362 const ArrayType *ArrayTy, Address ArrayPtr,
3363 const CXXConstructExpr *E,
3364 bool NewPointerIsChecked,
3365 bool ZeroInitialization = false);
3366
3368 llvm::Value *NumElements, Address ArrayPtr,
3369 const CXXConstructExpr *E,
3370 bool NewPointerIsChecked,
3371 bool ZeroInitialization = false);
3372
3374
3376 bool ForVirtualBase, bool Delegating, Address This,
3377 QualType ThisTy);
3378
3379 void EmitNewArrayInitializer(const CXXNewExpr *E, QualType elementType,
3380 llvm::Type *ElementTy, Address NewPtr,
3381 llvm::Value *NumElements,
3382 llvm::Value *AllocSizeWithoutCookie);
3383
3384 void EmitCXXTemporary(const CXXTemporary *Temporary, QualType TempType,
3385 Address Ptr);
3386
3387 void EmitSehCppScopeBegin();
3388 void EmitSehCppScopeEnd();
3389 void EmitSehTryScopeBegin();
3390 void EmitSehTryScopeEnd();
3391
3392 bool EmitLifetimeStart(llvm::Value *Addr);
3393 void EmitLifetimeEnd(llvm::Value *Addr);
3394
3395 llvm::Value *EmitCXXNewExpr(const CXXNewExpr *E);
3396 void EmitCXXDeleteExpr(const CXXDeleteExpr *E);
3397
3398 void EmitDeleteCall(const FunctionDecl *DeleteFD, llvm::Value *Ptr,
3399 QualType DeleteTy, llvm::Value *NumElements = nullptr,
3400 CharUnits CookieSize = CharUnits(),
3401 llvm::Constant *CalleeOverride = nullptr);
3402
3404 const CallExpr *TheCallExpr, bool IsDelete);
3405
3406 llvm::Value *EmitCXXTypeidExpr(const CXXTypeidExpr *E);
3407 llvm::Value *EmitDynamicCast(Address V, const CXXDynamicCastExpr *DCE);
3409
3410 /// Situations in which we might emit a check for the suitability of a
3411 /// pointer or glvalue. Needs to be kept in sync with ubsan_handlers.cpp in
3412 /// compiler-rt.
3414 /// Checking the operand of a load. Must be suitably sized and aligned.
3416 /// Checking the destination of a store. Must be suitably sized and aligned.
3418 /// Checking the bound value in a reference binding. Must be suitably sized
3419 /// and aligned, but is not required to refer to an object (until the
3420 /// reference is used), per core issue 453.
3422 /// Checking the object expression in a non-static data member access. Must
3423 /// be an object within its lifetime.
3425 /// Checking the 'this' pointer for a call to a non-static member function.
3426 /// Must be an object within its lifetime.
3428 /// Checking the 'this' pointer for a constructor call.
3430 /// Checking the operand of a static_cast to a derived pointer type. Must be
3431 /// null or an object within its lifetime.
3433 /// Checking the operand of a static_cast to a derived reference type. Must
3434 /// be an object within its lifetime.
3436 /// Checking the operand of a cast to a base object. Must be suitably sized
3437 /// and aligned.
3439 /// Checking the operand of a cast to a virtual base object. Must be an
3440 /// object within its lifetime.
3442 /// Checking the value assigned to a _Nonnull pointer. Must not be null.
3444 /// Checking the operand of a dynamic_cast or a typeid expression. Must be
3445 /// null or an object within its lifetime.
3447 };
3448
3449 /// Determine whether the pointer type check \p TCK permits null pointers.
3450 static bool isNullPointerAllowed(TypeCheckKind TCK);
3451
3452 /// Determine whether the pointer type check \p TCK requires a vptr check.
3453 static bool isVptrCheckRequired(TypeCheckKind TCK, QualType Ty);
3454
3455 /// Whether any type-checking sanitizers are enabled. If \c false,
3456 /// calls to EmitTypeCheck can be skipped.
3457 bool sanitizePerformTypeCheck() const;
3458
3460 QualType Type, SanitizerSet SkippedChecks = SanitizerSet(),
3461 llvm::Value *ArraySize = nullptr) {
3463 return;
3464 EmitTypeCheck(TCK, Loc, LV.emitRawPointer(*this), Type, LV.getAlignment(),
3465 SkippedChecks, ArraySize);
3466 }
3467
3469 QualType Type, CharUnits Alignment = CharUnits::Zero(),
3470 SanitizerSet SkippedChecks = SanitizerSet(),
3471 llvm::Value *ArraySize = nullptr) {
3473 return;
3474 EmitTypeCheck(TCK, Loc, Addr.emitRawPointer(*this), Type, Alignment,
3475 SkippedChecks, ArraySize);
3476 }
3477
3478 /// Emit a check that \p V is the address of storage of the
3479 /// appropriate size and alignment for an object of type \p Type
3480 /// (or if ArraySize is provided, for an array of that bound).
3481 void EmitTypeCheck(TypeCheckKind TCK, SourceLocation Loc, llvm::Value *V,
3482 QualType Type, CharUnits Alignment = CharUnits::Zero(),
3483 SanitizerSet SkippedChecks = SanitizerSet(),
3484 llvm::Value *ArraySize = nullptr);
3485
3486 /// Emit a check that \p Base points into an array object, which
3487 /// we can access at index \p Index. \p Accessed should be \c false if we
3488 /// this expression is used as an lvalue, for instance in "&Arr[Idx]".
3489 void EmitBoundsCheck(const Expr *ArrayExpr, const Expr *ArrayExprBase,
3490 llvm::Value *Index, QualType IndexType, bool Accessed);
3491 void EmitBoundsCheckImpl(const Expr *ArrayExpr, QualType ArrayBaseType,
3492 llvm::Value *IndexVal, QualType IndexType,
3493 llvm::Value *BoundsVal, QualType BoundsType,
3494 bool Accessed);
3495
3496 /// Returns debug info, with additional annotation if
3497 /// CGM.getCodeGenOpts().SanitizeAnnotateDebugInfo[Ordinal] is enabled for
3498 /// any of the ordinals.
3499 llvm::DILocation *
3501 SanitizerHandler Handler);
3502
3503 /// Build metadata used by the AllocToken instrumentation.
3504 llvm::MDNode *buildAllocToken(QualType AllocType);
3505 /// Emit and set additional metadata used by the AllocToken instrumentation.
3506 void EmitAllocToken(llvm::CallBase *CB, QualType AllocType);
3507 /// Build additional metadata used by the AllocToken instrumentation,
3508 /// inferring the type from an allocation call expression.
3509 llvm::MDNode *buildAllocToken(const CallExpr *E);
3510 /// Emit and set additional metadata used by the AllocToken instrumentation,
3511 /// inferring the type from an allocation call expression.
3512 void EmitAllocToken(llvm::CallBase *CB, const CallExpr *E);
3513
3514 llvm::Value *GetCountedByFieldExprGEP(const Expr *Base, const FieldDecl *FD,
3515 const FieldDecl *CountDecl);
3516
3517 /// Build an expression accessing the "counted_by" field.
3518 llvm::Value *EmitLoadOfCountedByField(const Expr *Base, const FieldDecl *FD,
3519 const FieldDecl *CountDecl);
3520
3521 // Emit bounds checking for flexible array and pointer members with the
3522 // counted_by attribute.
3523 void EmitCountedByBoundsChecking(const Expr *ArrayExpr, QualType ArrayType,
3524 Address ArrayInst, QualType IndexType,
3525 llvm::Value *IndexVal, bool Accessed,
3526 bool FlexibleArray);
3527
3528 llvm::Value *EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV,
3529 bool isInc, bool isPre);
3531 bool isInc, bool isPre);
3532
3533 /// Converts Location to a DebugLoc, if debug information is enabled.
3534 llvm::DebugLoc SourceLocToDebugLoc(SourceLocation Location);
3535
3536 //===--------------------------------------------------------------------===//
3537 // Declaration Emission
3538 //===--------------------------------------------------------------------===//
3539
3540 /// EmitDecl - Emit a declaration.
3541 ///
3542 /// This function can be called with a null (unreachable) insert point.
3543 void EmitDecl(const Decl &D, bool EvaluateConditionDecl = false);
3544
3545 /// EmitVarDecl - Emit a local variable declaration.
3546 ///
3547 /// This function can be called with a null (unreachable) insert point.
3548 void EmitVarDecl(const VarDecl &D);
3549
3550 void EmitScalarInit(const Expr *init, const ValueDecl *D, LValue lvalue,
3551 bool capturedByInit);
3552
3553 typedef void SpecialInitFn(CodeGenFunction &Init, const VarDecl &D,
3554 llvm::Value *Address);
3555
3556 /// Determine whether the given initializer is trivial in the sense
3557 /// that it requires no code to be generated.
3558 bool isTrivialInitializer(const Expr *Init);
3559
3560 /// EmitAutoVarDecl - Emit an auto variable declaration.
3561 ///
3562 /// This function can be called with a null (unreachable) insert point.
3563 void EmitAutoVarDecl(const VarDecl &D);
3564
3565 class AutoVarEmission {
3566 friend class CodeGenFunction;
3567
3568 const VarDecl *Variable;
3569
3570 /// The address of the alloca for languages with explicit address space
3571 /// (e.g. OpenCL) or alloca casted to generic pointer for address space
3572 /// agnostic languages (e.g. C++). Invalid if the variable was emitted
3573 /// as a global constant.
3574 Address Addr;
3575
3576 llvm::Value *NRVOFlag;
3577
3578 /// True if the variable is a __block variable that is captured by an
3579 /// escaping block.
3580 bool IsEscapingByRef;
3581
3582 /// If the variable is of aggregate type and has a constant initializer,
3583 /// a constant representing that initializer.
3584 llvm::Constant *ConstantAggregateInitializer;
3585
3586 /// True if lifetime markers should be used.
3587 bool UseLifetimeMarkers;
3588
3589 /// Address with original alloca instruction. Invalid if the variable was
3590 /// emitted as a global constant.
3591 RawAddress AllocaAddr;
3592
3593 struct Invalid {};
3595 : Variable(nullptr), Addr(Address::invalid()),
3596 AllocaAddr(RawAddress::invalid()) {}
3597
3598 AutoVarEmission(const VarDecl &variable)
3599 : Variable(&variable), Addr(Address::invalid()), NRVOFlag(nullptr),
3600 IsEscapingByRef(false), ConstantAggregateInitializer(nullptr),
3601 UseLifetimeMarkers(false), AllocaAddr(RawAddress::invalid()) {}
3602
3603 bool wasEmittedAsGlobal() const { return !Addr.isValid(); }
3604
3605 public:
3606 static AutoVarEmission invalid() { return AutoVarEmission(Invalid()); }
3607
3608 bool useLifetimeMarkers() const { return UseLifetimeMarkers; }
3609
3610 /// Returns the raw, allocated address, which is not necessarily
3611 /// the address of the object itself. It is casted to default
3612 /// address space for address space agnostic languages.
3613 Address getAllocatedAddress() const { return Addr; }
3614
3615 /// Returns the address for the original alloca instruction.
3616 RawAddress getOriginalAllocatedAddress() const { return AllocaAddr; }
3617
3618 /// Returns the address of the object within this declaration.
3619 /// Note that this does not chase the forwarding pointer for
3620 /// __block decls.
3622 if (!IsEscapingByRef)
3623 return Addr;
3624
3625 return CGF.emitBlockByrefAddress(Addr, Variable, /*forward*/ false);
3626 }
3627 };
3628 AutoVarEmission EmitAutoVarAlloca(const VarDecl &var);
3629 void EmitAutoVarInit(const AutoVarEmission &emission);
3630 void EmitAutoVarCleanups(const AutoVarEmission &emission);
3631 void emitAutoVarTypeCleanup(const AutoVarEmission &emission,
3632 QualType::DestructionKind dtorKind);
3633
3634 /// Re-emit trivial-auto-var-init stores for variables bypassed by the jump
3635 /// Source. No-op in a function containing a computed goto, where jump sources
3636 /// are unknown and a single function-scope init is used instead.
3637 void emitBypassedVarInitsForSource(const Stmt *Source);
3638
3639 void MaybeEmitDeferredVarDeclInit(const VarDecl *var);
3640
3641 /// Emits the alloca and debug information for the size expressions for each
3642 /// dimension of an array. It registers the association of its (1-dimensional)
3643 /// QualTypes and size expression's debug node, so that CGDebugInfo can
3644 /// reference this node when creating the DISubrange object to describe the
3645 /// array types.
3647 bool EmitDebugInfo);
3648
3649 void EmitStaticVarDecl(const VarDecl &D,
3650 llvm::GlobalValue::LinkageTypes Linkage);
3651
3652 class ParamValue {
3653 union {
3655 llvm::Value *Value;
3656 };
3657
3658 bool IsIndirect;
3659
3660 ParamValue(llvm::Value *V) : Value(V), IsIndirect(false) {}
3661 ParamValue(Address A) : Addr(A), IsIndirect(true) {}
3662
3663 public:
3664 static ParamValue forDirect(llvm::Value *value) {
3665 return ParamValue(value);
3666 }
3667 static ParamValue forIndirect(Address addr) {
3668 assert(!addr.getAlignment().isZero());
3669 return ParamValue(addr);
3670 }
3671
3672 bool isIndirect() const { return IsIndirect; }
3673 llvm::Value *getAnyValue() const {
3674 if (!isIndirect())
3675 return Value;
3676 assert(!Addr.hasOffset() && "unexpected offset");
3677 return Addr.getBasePointer();
3678 }
3679
3680 llvm::Value *getDirectValue() const {
3681 assert(!isIndirect());
3682 return Value;
3683 }
3684
3686 assert(isIndirect());
3687 return Addr;
3688 }
3689 };
3690
3691 /// EmitParmDecl - Emit a ParmVarDecl or an ImplicitParamDecl.
3692 void EmitParmDecl(const VarDecl &D, ParamValue Arg, unsigned ArgNo);
3693
3694 /// protectFromPeepholes - Protect a value that we're intending to
3695 /// store to the side, but which will probably be used later, from
3696 /// aggressive peepholing optimizations that might delete it.
3697 ///
3698 /// Pass the result to unprotectFromPeepholes to declare that
3699 /// protection is no longer required.
3700 ///
3701 /// There's no particular reason why this shouldn't apply to
3702 /// l-values, it's just that no existing peepholes work on pointers.
3703 PeepholeProtection protectFromPeepholes(RValue rvalue);
3704 void unprotectFromPeepholes(PeepholeProtection protection);
3705
3706 void emitAlignmentAssumptionCheck(llvm::Value *Ptr, QualType Ty,
3707 SourceLocation Loc,
3708 SourceLocation AssumptionLoc,
3709 llvm::Value *Alignment,
3710 llvm::Value *OffsetValue,
3711 llvm::Value *TheCheck,
3712 llvm::Instruction *Assumption);
3713
3714 void emitAlignmentAssumption(llvm::Value *PtrValue, QualType Ty,
3715 SourceLocation Loc, SourceLocation AssumptionLoc,
3716 llvm::Value *Alignment,
3717 llvm::Value *OffsetValue = nullptr);
3718
3719 void emitAlignmentAssumption(llvm::Value *PtrValue, const Expr *E,
3720 SourceLocation AssumptionLoc,
3721 llvm::Value *Alignment,
3722 llvm::Value *OffsetValue = nullptr);
3723
3724 //===--------------------------------------------------------------------===//
3725 // Statement Emission
3726 //===--------------------------------------------------------------------===//
3727
3728 /// EmitStopPoint - Emit a debug stoppoint if we are emitting debug info.
3729 void EmitStopPoint(const Stmt *S);
3730
3731 /// EmitStmt - Emit the code for the statement \arg S. It is legal to call
3732 /// this function even if there is no current insertion point.
3733 ///
3734 /// This function may clear the current insertion point; callers should use
3735 /// EnsureInsertPoint if they wish to subsequently generate code without first
3736 /// calling EmitBlock, EmitBranch, or EmitStmt.
3737 void EmitStmt(const Stmt *S, ArrayRef<const Attr *> Attrs = {});
3738
3739 /// EmitSimpleStmt - Try to emit a "simple" statement which does not
3740 /// necessarily require an insertion point or debug information; typically
3741 /// because the statement amounts to a jump or a container of other
3742 /// statements.
3743 ///
3744 /// \return True if the statement was handled.
3745 bool EmitSimpleStmt(const Stmt *S, ArrayRef<const Attr *> Attrs);
3746
3747 Address EmitCompoundStmt(const CompoundStmt &S, bool GetLast = false,
3748 AggValueSlot AVS = AggValueSlot::ignored());
3749 Address
3750 EmitCompoundStmtWithoutScope(const CompoundStmt &S, bool GetLast = false,
3751 AggValueSlot AVS = AggValueSlot::ignored());
3752
3753 /// EmitLabel - Emit the block for the given label. It is legal to call this
3754 /// function even if there is no current insertion point.
3755 void EmitLabel(const LabelDecl *D); // helper for EmitLabelStmt.
3756
3757 void EmitLabelStmt(const LabelStmt &S);
3758 void EmitAttributedStmt(const AttributedStmt &S);
3759 void EmitGotoStmt(const GotoStmt &S);
3761 void EmitIfStmt(const IfStmt &S);
3762
3763 void EmitWhileStmt(const WhileStmt &S, ArrayRef<const Attr *> Attrs = {});
3764 void EmitDoStmt(const DoStmt &S, ArrayRef<const Attr *> Attrs = {});
3765 void EmitForStmt(const ForStmt &S, ArrayRef<const Attr *> Attrs = {});
3766 void EmitReturnStmt(const ReturnStmt &S);
3767 void EmitDeclStmt(const DeclStmt &S);
3768 void EmitBreakStmt(const BreakStmt &S);
3769 void EmitContinueStmt(const ContinueStmt &S);
3770 void EmitSwitchStmt(const SwitchStmt &S);
3771 void EmitDefaultStmt(const DefaultStmt &S, ArrayRef<const Attr *> Attrs);
3772 void EmitCaseStmt(const CaseStmt &S, ArrayRef<const Attr *> Attrs);
3773 void EmitCaseStmtRange(const CaseStmt &S, ArrayRef<const Attr *> Attrs);
3774 void EmitDeferStmt(const DeferStmt &S);
3775 void EmitAsmStmt(const AsmStmt &S);
3776
3777 const BreakContinue *GetDestForLoopControlStmt(const LoopControlStmt &S);
3778
3779 void EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S);
3780 void EmitObjCAtTryStmt(const ObjCAtTryStmt &S);
3781 void EmitObjCAtThrowStmt(const ObjCAtThrowStmt &S);
3782 void EmitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt &S);
3783 void EmitObjCAutoreleasePoolStmt(const ObjCAutoreleasePoolStmt &S);
3784
3785 void EmitCoroutineBody(const CoroutineBodyStmt &S);
3786 void EmitCoreturnStmt(const CoreturnStmt &S);
3787 RValue EmitCoawaitExpr(const CoawaitExpr &E,
3788 AggValueSlot aggSlot = AggValueSlot::ignored(),
3789 bool ignoreResult = false);
3790 LValue EmitCoawaitLValue(const CoawaitExpr *E);
3791 RValue EmitCoyieldExpr(const CoyieldExpr &E,
3792 AggValueSlot aggSlot = AggValueSlot::ignored(),
3793 bool ignoreResult = false);
3794 LValue EmitCoyieldLValue(const CoyieldExpr *E);
3795 RValue EmitCoroutineIntrinsic(const CallExpr *E, unsigned int IID);
3796
3797 void EmitSYCLKernelCallStmt(const SYCLKernelCallStmt &S);
3798
3799 void EnterCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock = false);
3800 void ExitCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock = false);
3801
3802 void EmitCXXTryStmt(const CXXTryStmt &S);
3803 void EmitSEHTryStmt(const SEHTryStmt &S);
3804 void EmitSEHLeaveStmt(const SEHLeaveStmt &S);
3805 void EnterSEHTryStmt(const SEHTryStmt &S);
3806 void ExitSEHTryStmt(const SEHTryStmt &S);
3807 void VolatilizeTryBlocks(llvm::BasicBlock *BB,
3808 llvm::SmallPtrSet<llvm::BasicBlock *, 10> &V);
3809
3810 void pushSEHCleanup(CleanupKind kind, llvm::Function *FinallyFunc);
3811 void startOutlinedSEHHelper(CodeGenFunction &ParentCGF, bool IsFilter,
3812 const Stmt *OutlinedStmt);
3813
3814 llvm::Function *GenerateSEHFilterFunction(CodeGenFunction &ParentCGF,
3815 const SEHExceptStmt &Except);
3816
3817 llvm::Function *GenerateSEHFinallyFunction(CodeGenFunction &ParentCGF,
3818 const SEHFinallyStmt &Finally);
3819
3820 void EmitSEHExceptionCodeSave(CodeGenFunction &ParentCGF,
3821 llvm::Value *ParentFP, llvm::Value *EntryEBP);
3822 llvm::Value *EmitSEHExceptionCode();
3823 llvm::Value *EmitSEHExceptionInfo();
3824 llvm::Value *EmitSEHAbnormalTermination();
3825
3826 /// Emit simple code for OpenMP directives in Simd-only mode.
3827 void EmitSimpleOMPExecutableDirective(const OMPExecutableDirective &D);
3828
3829 /// Scan the outlined statement for captures from the parent function. For
3830 /// each capture, mark the capture as escaped and emit a call to
3831 /// llvm.localrecover. Insert the localrecover result into the LocalDeclMap.
3832 void EmitCapturedLocals(CodeGenFunction &ParentCGF, const Stmt *OutlinedStmt,
3833 bool IsFilter);
3834
3835 /// Recovers the address of a local in a parent function. ParentVar is the
3836 /// address of the variable used in the immediate parent function. It can
3837 /// either be an alloca or a call to llvm.localrecover if there are nested
3838 /// outlined functions. ParentFP is the frame pointer of the outermost parent
3839 /// frame.
3841 Address ParentVar, llvm::Value *ParentFP);
3842
3843 void EmitCXXForRangeStmt(const CXXForRangeStmt &S,
3844 ArrayRef<const Attr *> Attrs = {});
3845
3846 void
3847 EmitCXXExpansionStmtInstantiation(const CXXExpansionStmtInstantiation &S);
3848
3849 /// Controls insertion of cancellation exit blocks in worksharing constructs.
3851 CodeGenFunction &CGF;
3852
3853 public:
3854 OMPCancelStackRAII(CodeGenFunction &CGF, OpenMPDirectiveKind Kind,
3855 bool HasCancel)
3856 : CGF(CGF) {
3857 CGF.OMPCancelStack.enter(CGF, Kind, HasCancel);
3858 }
3859 ~OMPCancelStackRAII() { CGF.OMPCancelStack.exit(CGF); }
3860 };
3861
3862 /// Returns calculated size of the specified type.
3863 llvm::Value *getTypeSize(QualType Ty);
3865 llvm::Function *EmitCapturedStmt(const CapturedStmt &S, CapturedRegionKind K);
3866 llvm::Function *GenerateCapturedStmtFunction(const CapturedStmt &S);
3868 llvm::Function *
3870 const OMPExecutableDirective &D);
3871 llvm::Function *
3873 const OMPExecutableDirective &D);
3875 SmallVectorImpl<llvm::Value *> &CapturedVars);
3876 void emitOMPSimpleStore(LValue LVal, RValue RVal, QualType RValTy,
3877 SourceLocation Loc);
3878 /// Perform element by element copying of arrays with type \a
3879 /// OriginalType from \a SrcAddr to \a DestAddr using copying procedure
3880 /// generated by \a CopyGen.
3881 ///
3882 /// \param DestAddr Address of the destination array.
3883 /// \param SrcAddr Address of the source array.
3884 /// \param OriginalType Type of destination and source arrays.
3885 /// \param CopyGen Copying procedure that copies value of single array element
3886 /// to another single array element.
3888 Address DestAddr, Address SrcAddr, QualType OriginalType,
3889 const llvm::function_ref<void(Address, Address)> CopyGen);
3890 /// Emit proper copying of data from one variable to another.
3891 ///
3892 /// \param OriginalType Original type of the copied variables.
3893 /// \param DestAddr Destination address.
3894 /// \param SrcAddr Source address.
3895 /// \param DestVD Destination variable used in \a CopyExpr (for arrays, has
3896 /// type of the base array element).
3897 /// \param SrcVD Source variable used in \a CopyExpr (for arrays, has type of
3898 /// the base array element).
3899 /// \param Copy Actual copygin expression for copying data from \a SrcVD to \a
3900 /// DestVD.
3901 void EmitOMPCopy(QualType OriginalType, Address DestAddr, Address SrcAddr,
3902 const VarDecl *DestVD, const VarDecl *SrcVD,
3903 const Expr *Copy);
3904 /// Emit atomic update code for constructs: \a X = \a X \a BO \a E or
3905 /// \a X = \a E \a BO \a E.
3906 ///
3907 /// \param X Value to be updated.
3908 /// \param E Update value.
3909 /// \param BO Binary operation for update operation.
3910 /// \param IsXLHSInRHSPart true if \a X is LHS in RHS part of the update
3911 /// expression, false otherwise.
3912 /// \param AO Atomic ordering of the generated atomic instructions.
3913 /// \param CommonGen Code generator for complex expressions that cannot be
3914 /// expressed through atomicrmw instruction.
3915 /// \returns <true, OldAtomicValue> if simple 'atomicrmw' instruction was
3916 /// generated, <false, RValue::get(nullptr)> otherwise.
3917 std::pair<bool, RValue> EmitOMPAtomicSimpleUpdateExpr(
3918 LValue X, RValue E, BinaryOperatorKind BO, bool IsXLHSInRHSPart,
3919 llvm::AtomicOrdering AO, SourceLocation Loc,
3920 const llvm::function_ref<RValue(RValue)> CommonGen);
3922 OMPPrivateScope &PrivateScope);
3924 OMPPrivateScope &PrivateScope);
3926 const OMPUseDevicePtrClause &C, OMPPrivateScope &PrivateScope,
3927 const llvm::DenseMap<const ValueDecl *, llvm::Value *>
3928 CaptureDeviceAddrMap);
3930 const OMPUseDeviceAddrClause &C, OMPPrivateScope &PrivateScope,
3931 const llvm::DenseMap<const ValueDecl *, llvm::Value *>
3932 CaptureDeviceAddrMap);
3933 /// Emit code for copyin clause in \a D directive. The next code is
3934 /// generated at the start of outlined functions for directives:
3935 /// \code
3936 /// threadprivate_var1 = master_threadprivate_var1;
3937 /// operator=(threadprivate_var2, master_threadprivate_var2);
3938 /// ...
3939 /// __kmpc_barrier(&loc, global_tid);
3940 /// \endcode
3941 ///
3942 /// \param D OpenMP directive possibly with 'copyin' clause(s).
3943 /// \returns true if at least one copyin variable is found, false otherwise.
3945 /// Emit initial code for lastprivate variables. If some variable is
3946 /// not also firstprivate, then the default initialization is used. Otherwise
3947 /// initialization of this variable is performed by EmitOMPFirstprivateClause
3948 /// method.
3949 ///
3950 /// \param D Directive that may have 'lastprivate' directives.
3951 /// \param PrivateScope Private scope for capturing lastprivate variables for
3952 /// proper codegen in internal captured statement.
3953 ///
3954 /// \returns true if there is at least one lastprivate variable, false
3955 /// otherwise.
3957 OMPPrivateScope &PrivateScope);
3958 /// Emit final copying of lastprivate values to original variables at
3959 /// the end of the worksharing or simd directive.
3960 ///
3961 /// \param D Directive that has at least one 'lastprivate' directives.
3962 /// \param IsLastIterCond Boolean condition that must be set to 'i1 true' if
3963 /// it is the last iteration of the loop code in associated directive, or to
3964 /// 'i1 false' otherwise. If this item is nullptr, no final check is required.
3966 bool NoFinals,
3967 llvm::Value *IsLastIterCond = nullptr);
3968 /// Emit initial code for linear clauses.
3970 CodeGenFunction::OMPPrivateScope &PrivateScope);
3971 /// Emit final code for linear clauses.
3972 /// \param CondGen Optional conditional code for final part of codegen for
3973 /// linear clause.
3975 const OMPLoopDirective &D,
3976 const llvm::function_ref<llvm::Value *(CodeGenFunction &)> CondGen);
3977 /// Emit initial code for reduction variables. Creates reduction copies
3978 /// and initializes them with the values according to OpenMP standard.
3979 ///
3980 /// \param D Directive (possibly) with the 'reduction' clause.
3981 /// \param PrivateScope Private scope for capturing reduction variables for
3982 /// proper codegen in internal captured statement.
3983 ///
3985 OMPPrivateScope &PrivateScope,
3986 bool ForInscan = false);
3987 /// Emit final update of reduction values to original variables at
3988 /// the end of the directive.
3989 ///
3990 /// \param D Directive that has at least one 'reduction' directives.
3991 /// \param ReductionKind The kind of reduction to perform.
3993 const OpenMPDirectiveKind ReductionKind);
3994 /// Emit initial code for linear variables. Creates private copies
3995 /// and initializes them with the values according to OpenMP standard.
3996 ///
3997 /// \param D Directive (possibly) with the 'linear' clause.
3998 /// \return true if at least one linear variable is found that should be
3999 /// initialized with the value of the original variable, false otherwise.
4001
4002 typedef const llvm::function_ref<void(CodeGenFunction & /*CGF*/,
4003 llvm::Function * /*OutlinedFn*/,
4004 const OMPTaskDataTy & /*Data*/)>
4007 const OpenMPDirectiveKind CapturedRegion,
4008 const RegionCodeGenTy &BodyGen,
4009 const TaskGenTy &TaskGen, OMPTaskDataTy &Data);
4025 const RegionCodeGenTy &BodyGen,
4026 OMPTargetDataInfo &InputInfo);
4028 CodeGenFunction &CGF, const CapturedStmt *CS,
4029 OMPPrivateScope &Scope);
4031 void EmitOMPParallelDirective(const OMPParallelDirective &S);
4041 void EmitOMPForDirective(const OMPForDirective &S);
4063 void
4065 void
4074 void
4077 void
4085 void
4087 void
4105 /// Also emits 'target loop'.
4108 void
4133
4134 /// Emit device code for the target directive.
4136 StringRef ParentName,
4137 const OMPTargetDirective &S);
4138 static void
4141 /// Emit device code for the target parallel for directive.
4143 CodeGenModule &CGM, StringRef ParentName,
4145 /// Emit device code for the target parallel for simd directive.
4147 CodeGenModule &CGM, StringRef ParentName,
4149 /// Emit device code for the target teams directive.
4150 static void
4151 EmitOMPTargetTeamsDeviceFunction(CodeGenModule &CGM, StringRef ParentName,
4152 const OMPTargetTeamsDirective &S);
4153 /// Emit device code for the target teams distribute directive.
4155 CodeGenModule &CGM, StringRef ParentName,
4157 /// Emit device code for the target teams distribute simd directive.
4159 CodeGenModule &CGM, StringRef ParentName,
4161 /// Emit device code for the target simd and target loop directives.
4163 StringRef ParentName,
4164 const OMPLoopDirective &S);
4165 /// Emit device code for the target teams distribute parallel for simd
4166 /// directive.
4168 CodeGenModule &CGM, StringRef ParentName,
4170
4171 /// Emit device code for the target teams loop directive.
4173 CodeGenModule &CGM, StringRef ParentName,
4175
4176 /// Emit device code for the target parallel loop directive.
4178 CodeGenModule &CGM, StringRef ParentName,
4180
4182 CodeGenModule &CGM, StringRef ParentName,
4184
4185 /// Emit the Stmt \p S and return its topmost canonical loop, if any.
4186 /// TODO: The \p Depth paramter is not yet implemented and must be 1. In the
4187 /// future it is meant to be the number of loops expected in the loop nests
4188 /// (usually specified by the "collapse" clause) that are collapsed to a
4189 /// single loop by this function.
4190 llvm::CanonicalLoopInfo *EmitOMPCollapsedCanonicalLoopNest(const Stmt *S,
4191 int Depth);
4192
4193 /// Emit an OMPCanonicalLoop using the OpenMPIRBuilder.
4194 void EmitOMPCanonicalLoop(const OMPCanonicalLoop *S);
4195
4196 /// Emit inner loop of the worksharing/simd construct.
4197 ///
4198 /// \param S Directive, for which the inner loop must be emitted.
4199 /// \param RequiresCleanup true, if directive has some associated private
4200 /// variables.
4201 /// \param LoopCond Bollean condition for loop continuation.
4202 /// \param IncExpr Increment expression for loop control variable.
4203 /// \param BodyGen Generator for the inner body of the inner loop.
4204 /// \param PostIncGen Genrator for post-increment code (required for ordered
4205 /// loop directvies).
4206 void EmitOMPInnerLoop(
4207 const OMPExecutableDirective &S, bool RequiresCleanup,
4208 const Expr *LoopCond, const Expr *IncExpr,
4209 const llvm::function_ref<void(CodeGenFunction &)> BodyGen,
4210 const llvm::function_ref<void(CodeGenFunction &)> PostIncGen);
4211
4213 /// Emit initial code for loop counters of loop-based directives.
4215 OMPPrivateScope &LoopScope);
4216
4217 /// Helper for the OpenMP loop directives.
4218 void EmitOMPLoopBody(const OMPLoopDirective &D, JumpDest LoopExit);
4219
4220 /// Emit code for the worksharing loop-based directive.
4221 /// \return true, if this construct has any lastprivate clause, false -
4222 /// otherwise.
4223 bool EmitOMPWorksharingLoop(const OMPLoopDirective &S, Expr *EUB,
4224 const CodeGenLoopBoundsTy &CodeGenLoopBounds,
4225 const CodeGenDispatchBoundsTy &CGDispatchBounds);
4226
4227 /// Emit code for the distribute loop-based directive.
4229 const CodeGenLoopTy &CodeGenLoop, Expr *IncExpr);
4230
4231 /// Helpers for the OpenMP loop directives.
4232 void EmitOMPSimdInit(const OMPLoopDirective &D);
4233 void EmitOMPSimdFinal(
4234 const OMPLoopDirective &D,
4235 const llvm::function_ref<llvm::Value *(CodeGenFunction &)> CondGen);
4236
4237 /// Emits the lvalue for the expression with possibly captured variable.
4239
4240 /// Emits the original address for a structured binding.
4242
4243private:
4244 /// Helpers for blocks.
4245 llvm::Value *EmitBlockLiteral(const CGBlockInfo &Info);
4246
4247 /// struct with the values to be passed to the OpenMP loop-related functions
4248 struct OMPLoopArguments {
4249 /// loop lower bound
4251 /// loop upper bound
4253 /// loop stride
4255 /// isLastIteration argument for runtime functions
4257 /// Chunk value generated by sema
4258 llvm::Value *Chunk = nullptr;
4259 /// EnsureUpperBound
4260 Expr *EUB = nullptr;
4261 /// IncrementExpression
4262 Expr *IncExpr = nullptr;
4263 /// Loop initialization
4264 Expr *Init = nullptr;
4265 /// Loop exit condition
4266 Expr *Cond = nullptr;
4267 /// Update of LB after a whole chunk has been executed
4268 Expr *NextLB = nullptr;
4269 /// Update of UB after a whole chunk has been executed
4270 Expr *NextUB = nullptr;
4271 /// Distinguish between the for distribute and sections
4272 OpenMPDirectiveKind DKind = llvm::omp::OMPD_unknown;
4273 OMPLoopArguments() = default;
4274 OMPLoopArguments(Address LB, Address UB, Address ST, Address IL,
4275 llvm::Value *Chunk = nullptr, Expr *EUB = nullptr,
4276 Expr *IncExpr = nullptr, Expr *Init = nullptr,
4277 Expr *Cond = nullptr, Expr *NextLB = nullptr,
4278 Expr *NextUB = nullptr)
4279 : LB(LB), UB(UB), ST(ST), IL(IL), Chunk(Chunk), EUB(EUB),
4280 IncExpr(IncExpr), Init(Init), Cond(Cond), NextLB(NextLB),
4281 NextUB(NextUB) {}
4282 };
4283 void EmitOMPOuterLoop(bool DynamicOrOrdered, bool IsMonotonic,
4284 const OMPLoopDirective &S, OMPPrivateScope &LoopScope,
4285 const OMPLoopArguments &LoopArgs,
4286 const CodeGenLoopTy &CodeGenLoop,
4287 const CodeGenOrderedTy &CodeGenOrdered);
4288 void EmitOMPForOuterLoop(const OpenMPScheduleTy &ScheduleKind,
4289 bool IsMonotonic, const OMPLoopDirective &S,
4290 OMPPrivateScope &LoopScope, bool Ordered,
4291 const OMPLoopArguments &LoopArgs,
4292 const CodeGenDispatchBoundsTy &CGDispatchBounds);
4293 void EmitOMPDistributeOuterLoop(OpenMPDistScheduleClauseKind ScheduleKind,
4294 const OMPLoopDirective &S,
4295 OMPPrivateScope &LoopScope,
4296 const OMPLoopArguments &LoopArgs,
4297 const CodeGenLoopTy &CodeGenLoopContent);
4298 /// Emit code for sections directive.
4299 void EmitSections(const OMPExecutableDirective &S);
4300
4301public:
4302 //===--------------------------------------------------------------------===//
4303 // OpenACC Emission
4304 //===--------------------------------------------------------------------===//
4306 // TODO OpenACC: Implement this. It is currently implemented as a 'no-op',
4307 // simply emitting its structured block, but in the future we will implement
4308 // some sort of IR.
4309 if (S.getStructuredBlock())
4310 EmitStmt(S.getStructuredBlock());
4311 }
4312
4314 // TODO OpenACC: Implement this. It is currently implemented as a 'no-op',
4315 // simply emitting its loop, but in the future we will implement
4316 // some sort of IR.
4317 if (S.getLoop())
4318 EmitStmt(S.getLoop());
4319 }
4320
4322 // TODO OpenACC: Implement this. It is currently implemented as a 'no-op',
4323 // simply emitting its loop, but in the future we will implement
4324 // some sort of IR.
4325 if (S.getLoop())
4326 EmitStmt(S.getLoop());
4327 }
4328
4330 // TODO OpenACC: Implement this. It is currently implemented as a 'no-op',
4331 // simply emitting its structured block, but in the future we will implement
4332 // some sort of IR.
4333 if (S.getStructuredBlock())
4335 }
4336
4338 // TODO OpenACC: Implement this. It is currently implemented as a 'no-op',
4339 // but in the future we will implement some sort of IR.
4340 }
4341
4343 // TODO OpenACC: Implement this. It is currently implemented as a 'no-op',
4344 // but in the future we will implement some sort of IR.
4345 }
4346
4348 // TODO OpenACC: Implement this. It is currently implemented as a 'no-op',
4349 // simply emitting its structured block, but in the future we will implement
4350 // some sort of IR.
4351 if (S.getStructuredBlock())
4353 }
4354
4356 // TODO OpenACC: Implement this. It is currently implemented as a 'no-op',
4357 // but in the future we will implement some sort of IR.
4358 }
4359
4361 // TODO OpenACC: Implement this. It is currently implemented as a 'no-op',
4362 // but in the future we will implement some sort of IR.
4363 }
4364
4366 // TODO OpenACC: Implement this. It is currently implemented as a 'no-op',
4367 // but in the future we will implement some sort of IR.
4368 }
4369
4371 // TODO OpenACC: Implement this. It is currently implemented as a 'no-op',
4372 // but in the future we will implement some sort of IR.
4373 }
4374
4376 // TODO OpenACC: Implement this. It is currently implemented as a 'no-op',
4377 // but in the future we will implement some sort of IR.
4378 }
4379
4381 // TODO OpenACC: Implement this. It is currently implemented as a 'no-op',
4382 // simply emitting its associated stmt, but in the future we will implement
4383 // some sort of IR.
4384 if (S.getAssociatedStmt())
4386 }
4388 // TODO OpenACC: Implement this. It is currently implemented as a 'no-op',
4389 // but in the future we will implement some sort of IR.
4390 }
4391
4392 //===--------------------------------------------------------------------===//
4393 // LValue Expression Emission
4394 //===--------------------------------------------------------------------===//
4395
4396 /// Create a check that a scalar RValue is non-null.
4397 llvm::Value *EmitNonNullRValueCheck(RValue RV, QualType T);
4398
4399 /// GetUndefRValue - Get an appropriate 'undef' rvalue for the given type.
4401
4402 /// EmitUnsupportedRValue - Emit a dummy r-value using the type of E
4403 /// and issue an ErrorUnsupported style diagnostic (using the
4404 /// provided Name).
4405 RValue EmitUnsupportedRValue(const Expr *E, const char *Name);
4406
4407 /// EmitUnsupportedLValue - Emit a dummy l-value using the type of E and issue
4408 /// an ErrorUnsupported style diagnostic (using the provided Name).
4409 LValue EmitUnsupportedLValue(const Expr *E, const char *Name);
4410
4411 /// EmitLValue - Emit code to compute a designator that specifies the location
4412 /// of the expression.
4413 ///
4414 /// This can return one of two things: a simple address or a bitfield
4415 /// reference. In either case, the LLVM Value* in the LValue structure is
4416 /// guaranteed to be an LLVM pointer type.
4417 ///
4418 /// If this returns a bitfield reference, nothing about the pointee type of
4419 /// the LLVM value is known: For example, it may not be a pointer to an
4420 /// integer.
4421 ///
4422 /// If this returns a normal address, and if the lvalue's C type is fixed
4423 /// size, this method guarantees that the returned pointer type will point to
4424 /// an LLVM type of the same size of the lvalue's type. If the lvalue has a
4425 /// variable length type, this is not possible.
4426 ///
4427 LValue EmitLValue(const Expr *E,
4428 KnownNonNull_t IsKnownNonNull = NotKnownNonNull);
4429
4430private:
4431 LValue EmitLValueHelper(const Expr *E, KnownNonNull_t IsKnownNonNull);
4432
4433public:
4434 /// Same as EmitLValue but additionally we generate checking code to
4435 /// guard against undefined behavior. This is only suitable when we know
4436 /// that the address will be used to access the object.
4438
4440
4441 void EmitAtomicInit(Expr *E, LValue lvalue);
4442
4444
4447
4449 llvm::AtomicOrdering AO, bool IsVolatile = false,
4451
4452 void EmitAtomicStore(RValue rvalue, LValue lvalue, bool isInit);
4453
4454 void EmitAtomicStore(RValue rvalue, LValue lvalue, llvm::AtomicOrdering AO,
4455 bool IsVolatile, bool isInit);
4456
4457 std::pair<RValue, llvm::Value *> EmitAtomicCompareExchange(
4458 LValue Obj, RValue Expected, RValue Desired, SourceLocation Loc,
4459 llvm::AtomicOrdering Success =
4460 llvm::AtomicOrdering::SequentiallyConsistent,
4461 llvm::AtomicOrdering Failure =
4462 llvm::AtomicOrdering::SequentiallyConsistent,
4463 bool IsWeak = false, AggValueSlot Slot = AggValueSlot::ignored());
4464
4465 /// Emit an atomicrmw instruction, and applying relevant metadata when
4466 /// applicable.
4467 llvm::AtomicRMWInst *emitAtomicRMWInst(
4468 llvm::AtomicRMWInst::BinOp Op, Address Addr, llvm::Value *Val,
4469 llvm::AtomicOrdering Order = llvm::AtomicOrdering::SequentiallyConsistent,
4470 llvm::SyncScope::ID SSID = llvm::SyncScope::System,
4471 const AtomicExpr *AE = nullptr);
4472
4473 /// Emit a fence instruction, applying relevant target-specific metadata when
4474 /// applicable.
4475 llvm::FenceInst *
4476 emitAtomicFence(llvm::AtomicOrdering Order,
4477 llvm::SyncScope::ID SSID = llvm::SyncScope::System);
4478
4479 void EmitAtomicUpdate(LValue LVal, llvm::AtomicOrdering AO,
4480 const llvm::function_ref<RValue(RValue)> &UpdateOp,
4481 bool IsVolatile);
4482
4483 /// EmitToMemory - Change a scalar value from its value
4484 /// representation to its in-memory representation.
4485 llvm::Value *EmitToMemory(llvm::Value *Value, QualType Ty);
4486
4487 /// EmitFromMemory - Change a scalar value from its memory
4488 /// representation to its value representation.
4489 llvm::Value *EmitFromMemory(llvm::Value *Value, QualType Ty);
4490
4491 /// Check if the scalar \p Value is within the valid range for the given
4492 /// type \p Ty.
4493 ///
4494 /// Returns true if a check is needed (even if the range is unknown).
4495 bool EmitScalarRangeCheck(llvm::Value *Value, QualType Ty,
4496 SourceLocation Loc);
4497
4498 /// EmitLoadOfScalar - Load a scalar value from an address, taking
4499 /// care to appropriately convert from the memory representation to
4500 /// the LLVM value representation.
4501 llvm::Value *EmitLoadOfScalar(Address Addr, bool Volatile, QualType Ty,
4502 SourceLocation Loc,
4504 bool isNontemporal = false) {
4505 return EmitLoadOfScalar(Addr, Volatile, Ty, Loc, LValueBaseInfo(Source),
4506 CGM.getTBAAAccessInfo(Ty), isNontemporal);
4507 }
4508
4509 llvm::Value *EmitLoadOfScalar(Address Addr, bool Volatile, QualType Ty,
4510 SourceLocation Loc, LValueBaseInfo BaseInfo,
4511 TBAAAccessInfo TBAAInfo,
4512 bool isNontemporal = false);
4513
4514 /// EmitLoadOfScalar - Load a scalar value from an address, taking
4515 /// care to appropriately convert from the memory representation to
4516 /// the LLVM value representation. The l-value must be a simple
4517 /// l-value.
4518 llvm::Value *EmitLoadOfScalar(LValue lvalue, SourceLocation Loc);
4519
4520 /// EmitStoreOfScalar - Store a scalar value to an address, taking
4521 /// care to appropriately convert from the memory representation to
4522 /// the LLVM value representation.
4523 void EmitStoreOfScalar(llvm::Value *Value, Address Addr, bool Volatile,
4524 QualType Ty,
4526 bool isInit = false, bool isNontemporal = false) {
4527 EmitStoreOfScalar(Value, Addr, Volatile, Ty, LValueBaseInfo(Source),
4528 CGM.getTBAAAccessInfo(Ty), isInit, isNontemporal);
4529 }
4530
4531 void EmitStoreOfScalar(llvm::Value *Value, Address Addr, bool Volatile,
4532 QualType Ty, LValueBaseInfo BaseInfo,
4533 TBAAAccessInfo TBAAInfo, bool isInit = false,
4534 bool isNontemporal = false);
4535
4536 /// EmitStoreOfScalar - Store a scalar value to an address, taking
4537 /// care to appropriately convert from the memory representation to
4538 /// the LLVM value representation. The l-value must be a simple
4539 /// l-value. The isInit flag indicates whether this is an initialization.
4540 /// If so, atomic qualifiers are ignored and the store is always non-atomic.
4541 void EmitStoreOfScalar(llvm::Value *value, LValue lvalue,
4542 bool isInit = false);
4543
4544 /// EmitLoadOfLValue - Given an expression that represents a value lvalue,
4545 /// this method emits the address of the lvalue, then loads the result as an
4546 /// rvalue, returning the rvalue.
4551
4552 /// Like EmitLoadOfLValue but also handles complex and aggregate types.
4555 SourceLocation Loc = {});
4556
4557 /// EmitStoreThroughLValue - Store the specified rvalue into the specified
4558 /// lvalue, where both are guaranteed to the have the same type, and that type
4559 /// is 'Ty'.
4560 void EmitStoreThroughLValue(RValue Src, LValue Dst, bool isInit = false);
4561 void EmitStoreThroughExtVectorComponentLValue(RValue Src, LValue Dst);
4562 void EmitStoreThroughGlobalRegLValue(RValue Src, LValue Dst);
4563
4564 /// EmitStoreThroughBitfieldLValue - Store Src into Dst with same constraints
4565 /// as EmitStoreThroughLValue.
4566 ///
4567 /// \param Result [out] - If non-null, this will be set to a Value* for the
4568 /// bit-field contents after the store, appropriate for use as the result of
4569 /// an assignment to the bit-field.
4570 void EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst,
4571 llvm::Value **Result = nullptr);
4572
4573 /// Emit an l-value for an assignment (simple or compound) of complex type.
4577 llvm::Value *&Result);
4578
4579 // Note: only available for agg return types
4582 // Note: only available for agg return types
4583 LValue EmitCallExprLValue(const CallExpr *E,
4584 llvm::CallBase **CallOrInvoke = nullptr);
4585 // Note: only available for agg return types
4586 LValue EmitVAArgExprLValue(const VAArgExpr *E);
4587 LValue EmitDeclRefLValue(const DeclRefExpr *E);
4588 LValue EmitOMPCapturedBindingLValue(const BindingDecl *BD);
4589 LValue EmitStringLiteralLValue(const StringLiteral *E);
4591 LValue EmitPredefinedLValue(const PredefinedExpr *E);
4592 LValue EmitUnaryOpLValue(const UnaryOperator *E);
4594 bool Accessed = false);
4595 llvm::Value *EmitMatrixIndexExpr(const Expr *E);
4598 LValue EmitArraySectionExpr(const ArraySectionExpr *E,
4599 bool IsLowerBound = true);
4602 LValue EmitMemberExpr(const MemberExpr *E);
4603 LValue EmitObjCIsaExpr(const ObjCIsaExpr *E);
4605 LValue EmitInitListLValue(const InitListExpr *E);
4608 LValue EmitCastLValue(const CastExpr *E);
4610 LValue EmitOpaqueValueLValue(const OpaqueValueExpr *e);
4612
4613 std::pair<LValue, LValue> EmitHLSLOutArgLValues(const HLSLOutArgExpr *E,
4614 QualType Ty);
4615 LValue EmitHLSLOutArgExpr(const HLSLOutArgExpr *E, CallArgList &Args,
4616 QualType Ty, bool IsImplicitObject = false);
4617
4618 Address EmitExtVectorElementLValue(LValue V);
4619
4620 RValue EmitRValueForField(LValue LV, const FieldDecl *FD, SourceLocation Loc);
4621
4622 Address EmitArrayToPointerDecay(const Expr *Array,
4623 LValueBaseInfo *BaseInfo = nullptr,
4624 TBAAAccessInfo *TBAAInfo = nullptr);
4625
4626 class ConstantEmission {
4627 llvm::PointerIntPair<llvm::Constant *, 1, bool> ValueAndIsReference;
4628 ConstantEmission(llvm::Constant *C, bool isReference)
4629 : ValueAndIsReference(C, isReference) {}
4630
4631 public:
4633 static ConstantEmission forReference(llvm::Constant *C) {
4634 return ConstantEmission(C, true);
4635 }
4636 static ConstantEmission forValue(llvm::Constant *C) {
4637 return ConstantEmission(C, false);
4638 }
4639
4640 explicit operator bool() const {
4641 return ValueAndIsReference.getOpaqueValue() != nullptr;
4642 }
4643
4644 bool isReference() const { return ValueAndIsReference.getInt(); }
4645 LValue getReferenceLValue(CodeGenFunction &CGF, const Expr *RefExpr) const {
4646 assert(isReference());
4647 return CGF.MakeNaturalAlignAddrLValue(ValueAndIsReference.getPointer(),
4648 RefExpr->getType());
4649 }
4650
4651 llvm::Constant *getValue() const {
4652 assert(!isReference());
4653 return ValueAndIsReference.getPointer();
4654 }
4655 };
4656
4657 ConstantEmission tryEmitAsConstant(const DeclRefExpr *RefExpr);
4658 ConstantEmission tryEmitAsConstant(const MemberExpr *ME);
4659 llvm::Value *emitScalarConstant(const ConstantEmission &Constant, Expr *E);
4660
4664
4666 SmallVectorImpl<LValue> &AccessList);
4667
4668 llvm::Value *EmitIvarOffset(const ObjCInterfaceDecl *Interface,
4669 const ObjCIvarDecl *Ivar);
4671 const ObjCIvarDecl *Ivar);
4673 bool IsInBounds = true);
4676 llvm::Value *ThisValue);
4677
4678 /// EmitLValueForFieldInitialization - Like EmitLValueForField, except that
4679 /// if the Field is a reference, this will return the address of the reference
4680 /// and not the address of the value stored in the reference.
4682
4683 LValue EmitLValueForIvar(QualType ObjectTy, llvm::Value *Base,
4684 const ObjCIvarDecl *Ivar, unsigned CVRQualifiers);
4685
4690
4696 void EmitDeclRefExprDbgValue(const DeclRefExpr *E, const APValue &Init);
4697
4698 //===--------------------------------------------------------------------===//
4699 // Scalar Expression Emission
4700 //===--------------------------------------------------------------------===//
4701
4702 /// EmitCall - Generate a call of the given function, expecting the given
4703 /// result type, and using the given argument list which specifies both the
4704 /// LLVM arguments and the types they were derived from.
4705 RValue EmitCall(const CGFunctionInfo &CallInfo, const CGCallee &Callee,
4707 llvm::CallBase **CallOrInvoke, bool IsMustTail,
4708 SourceLocation Loc,
4709 bool IsVirtualFunctionPointerThunk = false);
4710 RValue EmitCall(const CGFunctionInfo &CallInfo, const CGCallee &Callee,
4712 llvm::CallBase **CallOrInvoke = nullptr,
4713 bool IsMustTail = false) {
4714 return EmitCall(CallInfo, Callee, ReturnValue, Args, CallOrInvoke,
4715 IsMustTail, SourceLocation());
4716 }
4717 RValue EmitCall(QualType FnType, const CGCallee &Callee, const CallExpr *E,
4718 ReturnValueSlot ReturnValue, llvm::Value *Chain = nullptr,
4719 llvm::CallBase **CallOrInvoke = nullptr,
4720 CGFunctionInfo const **ResolvedFnInfo = nullptr);
4721
4722 // If a Call or Invoke instruction was emitted for this CallExpr, this method
4723 // writes the pointer to `CallOrInvoke` if it's not null.
4724 RValue EmitCallExpr(const CallExpr *E,
4726 llvm::CallBase **CallOrInvoke = nullptr);
4728 llvm::CallBase **CallOrInvoke = nullptr);
4729 CGCallee EmitCallee(const Expr *E);
4730
4731 void checkTargetFeatures(const CallExpr *E, const FunctionDecl *TargetDecl);
4732 void checkTargetFeatures(SourceLocation Loc, const FunctionDecl *TargetDecl);
4733
4734 llvm::CallInst *EmitRuntimeCall(llvm::FunctionCallee callee,
4735 const Twine &name = "");
4736 llvm::CallInst *EmitRuntimeCall(llvm::FunctionCallee callee,
4738 const Twine &name = "",
4739 bool IsConvergent = false);
4740 llvm::CallInst *EmitIntrinsicCall(llvm::Intrinsic::ID ID,
4741 const Twine &Name = "");
4742 llvm::CallInst *EmitIntrinsicCall(llvm::Intrinsic::ID ID,
4744 const Twine &Name = "");
4745 llvm::CallInst *EmitIntrinsicCall(llvm::Intrinsic::ID ID,
4748 const Twine &Name = "");
4749 llvm::CallInst *EmitIntrinsicCall(llvm::Intrinsic::ID ID,
4751 llvm::Type *RetTy, const Twine &Name = "");
4752 llvm::CallInst *EmitNounwindRuntimeCall(llvm::FunctionCallee callee,
4753 const Twine &name = "");
4754 llvm::CallInst *EmitNounwindRuntimeCall(llvm::FunctionCallee callee,
4755 ArrayRef<Address> args,
4756 const Twine &name = "");
4757 llvm::CallInst *EmitNounwindRuntimeCall(llvm::FunctionCallee callee,
4759 const Twine &name = "");
4760
4762 getBundlesForFunclet(llvm::Value *Callee);
4763
4764 llvm::CallBase *EmitCallOrInvoke(llvm::FunctionCallee Callee,
4766 const Twine &Name = "");
4767 llvm::CallBase *EmitRuntimeCallOrInvoke(llvm::FunctionCallee callee,
4769 const Twine &name = "");
4770 llvm::CallBase *EmitRuntimeCallOrInvoke(llvm::FunctionCallee callee,
4771 const Twine &name = "");
4772 void EmitNoreturnRuntimeCallOrInvoke(llvm::FunctionCallee callee,
4774
4776 NestedNameSpecifier Qual, llvm::Type *Ty);
4777
4780 const CXXRecordDecl *RD);
4781
4782 bool isPointerKnownNonNull(const Expr *E);
4783 /// Check whether the underlying base pointer is a constant null.
4785
4786 /// Create the discriminator from the storage address and the entity hash.
4787 llvm::Value *EmitPointerAuthBlendDiscriminator(llvm::Value *StorageAddress,
4788 llvm::Value *Discriminator);
4790 llvm::Value *StorageAddress,
4791 GlobalDecl SchemaDecl,
4792 QualType SchemaType);
4793
4794 llvm::Value *EmitPointerAuthSign(const CGPointerAuthInfo &Info,
4795 llvm::Value *Pointer);
4796
4797 llvm::Value *EmitPointerAuthAuth(const CGPointerAuthInfo &Info,
4798 llvm::Value *Pointer);
4799
4800 llvm::Value *emitPointerAuthResign(llvm::Value *Pointer, QualType PointerType,
4801 const CGPointerAuthInfo &CurAuthInfo,
4802 const CGPointerAuthInfo &NewAuthInfo,
4803 bool IsKnownNonNull);
4804 llvm::Value *emitPointerAuthResignCall(llvm::Value *Pointer,
4805 const CGPointerAuthInfo &CurInfo,
4806 const CGPointerAuthInfo &NewInfo);
4807
4809 const CGPointerAuthInfo &Info,
4811
4813 Address StorageAddress);
4814 llvm::Value *EmitPointerAuthQualify(PointerAuthQualifier Qualifier,
4815 llvm::Value *Pointer, QualType ValueType,
4816 Address StorageAddress,
4817 bool IsKnownNonNull);
4818 llvm::Value *EmitPointerAuthQualify(PointerAuthQualifier Qualifier,
4819 const Expr *PointerExpr,
4820 Address StorageAddress);
4821 llvm::Value *EmitPointerAuthUnqualify(PointerAuthQualifier Qualifier,
4822 llvm::Value *Pointer,
4824 Address StorageAddress,
4825 bool IsKnownNonNull);
4827 Address DestField, Address SrcField);
4828
4829 std::pair<llvm::Value *, CGPointerAuthInfo>
4830 EmitOrigPointerRValue(const Expr *E);
4831
4832 llvm::Value *authPointerToPointerCast(llvm::Value *ResultPtr,
4833 QualType SourceType, QualType DestType);
4835 QualType DestType);
4836
4838
4839 llvm::Value *getAsNaturalPointerTo(Address Addr, QualType PointeeType) {
4840 return getAsNaturalAddressOf(Addr, PointeeType).getBasePointer();
4841 }
4842
4843 // Return the copy constructor name with the prefix "__copy_constructor_"
4844 // removed.
4845 static std::string getNonTrivialCopyConstructorStr(QualType QT,
4846 CharUnits Alignment,
4847 bool IsVolatile,
4848 ASTContext &Ctx);
4849
4850 // Return the destructor name with the prefix "__destructor_" removed.
4851 static std::string getNonTrivialDestructorStr(QualType QT,
4852 CharUnits Alignment,
4853 bool IsVolatile,
4854 ASTContext &Ctx);
4855
4856 // These functions emit calls to the special functions of non-trivial C
4857 // structs.
4860 void callCStructDestructor(LValue Dst);
4865
4867 const CXXMethodDecl *Method, const CGCallee &Callee,
4868 ReturnValueSlot ReturnValue, llvm::Value *This,
4869 llvm::Value *ImplicitParam, QualType ImplicitParamTy, const CallExpr *E,
4870 CallArgList *RtlArgs, llvm::CallBase **CallOrInvoke);
4871 RValue EmitCXXDestructorCall(GlobalDecl Dtor, const CGCallee &Callee,
4872 llvm::Value *This, QualType ThisTy,
4873 llvm::Value *ImplicitParam,
4874 QualType ImplicitParamTy, const CallExpr *E,
4875 llvm::CallBase **CallOrInvoke = nullptr);
4878 llvm::CallBase **CallOrInvoke = nullptr);
4880 const CallExpr *CE, const CXXMethodDecl *MD, ReturnValueSlot ReturnValue,
4881 bool HasQualifier, NestedNameSpecifier Qualifier, bool IsArrow,
4882 const Expr *Base, llvm::CallBase **CallOrInvoke);
4883 // Compute the object pointer.
4885 const Expr *E, Address base, llvm::Value *memberPtr,
4886 const MemberPointerType *memberPtrType, bool IsInBounds,
4887 LValueBaseInfo *BaseInfo = nullptr, TBAAAccessInfo *TBAAInfo = nullptr);
4890 llvm::CallBase **CallOrInvoke);
4891
4893 const CXXMethodDecl *MD,
4895 llvm::CallBase **CallOrInvoke);
4897
4900 llvm::CallBase **CallOrInvoke);
4901
4904
4905 RValue EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
4907
4908 RValue emitRotate(const CallExpr *E, bool IsRotateRight);
4909
4910 RValue emitStdcCountIntrinsic(const CallExpr *E, llvm::Intrinsic::ID IntID,
4911 bool InvertArg, bool IsPop = false);
4912 RValue emitStdcBitWidthMinus(const CallExpr *E, llvm::Intrinsic::ID IntID,
4913 bool IsPop);
4914 RValue emitStdcFirstBit(const CallExpr *E, llvm::Intrinsic::ID IntID,
4915 bool InvertArg);
4916
4917 /// Emit IR for __builtin_os_log_format.
4919
4920 /// Emit IR for __builtin_is_aligned.
4922 /// Emit IR for __builtin_align_up/__builtin_align_down.
4923 RValue EmitBuiltinAlignTo(const CallExpr *E, bool AlignUp);
4924
4925 llvm::Function *generateBuiltinOSLogHelperFunction(
4927 CharUnits BufferAlignment);
4928
4930 llvm::CallBase **CallOrInvoke);
4931
4932 /// EmitTargetBuiltinExpr - Emit the given builtin call. Returns 0 if the call
4933 /// is unhandled by the current target.
4934 llvm::Value *EmitTargetBuiltinExpr(unsigned BuiltinID, const CallExpr *E,
4936
4937 llvm::Value *
4938 EmitAArch64CompareBuiltinExpr(llvm::Value *Op, llvm::Type *Ty,
4939 const llvm::CmpInst::Predicate Pred,
4940 const llvm::Twine &Name = "");
4941 llvm::Value *EmitARMBuiltinExpr(unsigned BuiltinID, const CallExpr *E,
4943 llvm::Triple::ArchType Arch);
4944 llvm::Value *EmitARMMVEBuiltinExpr(unsigned BuiltinID, const CallExpr *E,
4946 llvm::Triple::ArchType Arch);
4947 llvm::Value *EmitARMCDEBuiltinExpr(unsigned BuiltinID, const CallExpr *E,
4949 llvm::Triple::ArchType Arch);
4950 llvm::Value *EmitCMSEClearRecord(llvm::Value *V, llvm::IntegerType *ITy,
4951 QualType RTy);
4952 llvm::Value *EmitCMSEClearRecord(llvm::Value *V, llvm::ArrayType *ATy,
4953 QualType RTy);
4954
4955 llvm::Value *
4956 EmitCommonNeonBuiltinExpr(unsigned BuiltinID, unsigned LLVMIntrinsic,
4957 unsigned AltLLVMIntrinsic, const char *NameHint,
4958 unsigned Modifier, const CallExpr *E,
4960 Address PtrOp1, llvm::Triple::ArchType Arch);
4961
4962 llvm::Function *LookupNeonLLVMIntrinsic(unsigned IntrinsicID,
4963 unsigned Modifier, llvm::Type *ArgTy,
4964 const CallExpr *E);
4965 llvm::Value *EmitNeonCall(llvm::Function *F,
4966 SmallVectorImpl<llvm::Value *> &O, const char *name,
4967 unsigned shift = 0, bool rightshift = false);
4968 llvm::Value *EmitFP8NeonCall(unsigned IID, ArrayRef<llvm::Type *> Tys,
4970 const CallExpr *E, const char *name);
4971 llvm::Value *EmitFP8NeonCvtCall(unsigned IID, llvm::Type *Ty0,
4972 llvm::Type *Ty1, bool Extract,
4974 const CallExpr *E, const char *name);
4975 llvm::Value *EmitFP8NeonFDOTCall(unsigned IID, bool ExtendLaneArg,
4976 llvm::Type *RetTy,
4978 const CallExpr *E, const char *name);
4979 llvm::Value *EmitFP8NeonFMLACall(unsigned IID, bool ExtendLaneArg,
4980 llvm::Type *RetTy,
4982 const CallExpr *E, const char *name);
4983 llvm::Value *EmitNeonSplat(llvm::Value *V, llvm::Constant *Idx,
4984 const llvm::ElementCount &Count);
4985 llvm::Value *EmitNeonSplat(llvm::Value *V, llvm::Constant *Idx);
4986 llvm::Value *EmitNeonShiftVector(llvm::Value *V, llvm::Type *Ty,
4987 bool negateForRightShift);
4988 llvm::Value *EmitNeonRShiftImm(llvm::Value *Vec, llvm::Value *Amt,
4989 llvm::Type *Ty, bool usgn, const char *name);
4990 llvm::Value *vectorWrapScalar16(llvm::Value *Op);
4991 /// SVEBuiltinMemEltTy - Returns the memory element type for this memory
4992 /// access builtin. Only required if it can't be inferred from the base
4993 /// pointer operand.
4994 llvm::Type *SVEBuiltinMemEltTy(const SVETypeFlags &TypeFlags);
4995
4997 getSVEOverloadTypes(const SVETypeFlags &TypeFlags, llvm::Type *ReturnType,
4999 llvm::Type *getEltType(const SVETypeFlags &TypeFlags);
5000 llvm::ScalableVectorType *getSVEType(const SVETypeFlags &TypeFlags);
5001 llvm::ScalableVectorType *getSVEPredType(const SVETypeFlags &TypeFlags);
5002 llvm::Value *EmitSVETupleSetOrGet(const SVETypeFlags &TypeFlags,
5004 llvm::Value *EmitSVETupleCreate(const SVETypeFlags &TypeFlags,
5005 llvm::Type *ReturnType,
5007 llvm::Value *EmitSVEDupX(llvm::Value *Scalar);
5008 llvm::Value *EmitSVEDupX(llvm::Value *Scalar, llvm::Type *Ty);
5009 llvm::Value *EmitSVEReinterpret(llvm::Value *Val, llvm::Type *Ty);
5010 llvm::Value *EmitSVEPMull(const SVETypeFlags &TypeFlags,
5012 unsigned BuiltinID);
5013 llvm::Value *EmitSVEMovl(const SVETypeFlags &TypeFlags,
5015 unsigned BuiltinID);
5016 llvm::Value *EmitSVEPredicateCast(llvm::Value *Pred,
5017 llvm::ScalableVectorType *VTy);
5018 llvm::Value *EmitSVEPredicateTupleCast(llvm::Value *PredTuple,
5019 llvm::StructType *Ty);
5020 llvm::Value *EmitSVEGatherLoad(const SVETypeFlags &TypeFlags,
5022 unsigned IntID);
5023 llvm::Value *EmitSVEScatterStore(const SVETypeFlags &TypeFlags,
5025 unsigned IntID);
5026 llvm::Value *EmitSVEMaskedLoad(const CallExpr *, llvm::Type *ReturnTy,
5028 unsigned BuiltinID, bool IsZExtReturn);
5029 llvm::Value *EmitSVEMaskedStore(const CallExpr *,
5031 unsigned BuiltinID);
5032 llvm::Value *EmitSVEPrefetchLoad(const SVETypeFlags &TypeFlags,
5034 unsigned BuiltinID);
5035 llvm::Value *EmitSVEGatherPrefetch(const SVETypeFlags &TypeFlags,
5037 unsigned IntID);
5038 llvm::Value *EmitSVEStructLoad(const SVETypeFlags &TypeFlags,
5040 unsigned IntID);
5041 llvm::Value *EmitSVEStructStore(const SVETypeFlags &TypeFlags,
5043 unsigned IntID);
5044 llvm::Value *EmitAArch64SVEBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
5045
5046 llvm::Value *EmitSMELd1St1(const SVETypeFlags &TypeFlags,
5048 unsigned IntID);
5049 llvm::Value *EmitSMEReadWrite(const SVETypeFlags &TypeFlags,
5051 unsigned IntID);
5052 llvm::Value *EmitSMEZero(const SVETypeFlags &TypeFlags,
5054 unsigned IntID);
5055 llvm::Value *EmitSMELdrStr(const SVETypeFlags &TypeFlags,
5057 unsigned IntID);
5058
5059 void GetAArch64SVEProcessedOperands(unsigned BuiltinID, const CallExpr *E,
5061 SVETypeFlags TypeFlags);
5062
5063 llvm::Value *EmitAArch64SMEBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
5064
5065 llvm::Value *EmitAArch64BuiltinExpr(unsigned BuiltinID, const CallExpr *E,
5066 llvm::Triple::ArchType Arch);
5067 llvm::Value *EmitBPFBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
5068
5069 llvm::Value *BuildVector(ArrayRef<llvm::Value *> Ops);
5070 llvm::Value *EmitX86BuiltinExpr(unsigned BuiltinID, const CallExpr *E);
5071 llvm::Value *EmitPPCBuiltinCpu(unsigned BuiltinID, llvm::Type *ReturnType,
5072 StringRef CPUStr);
5073 llvm::Value *EmitPPCBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
5074 llvm::Value *EmitAMDGPUBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
5075 llvm::Value *EmitHLSLBuiltinExpr(unsigned BuiltinID, const CallExpr *E,
5077
5078 // Returns a builtin function that the SPIR-V backend will expand into a spec
5079 // constant.
5080 llvm::Function *
5081 getSpecConstantFunction(const clang::QualType &SpecConstantType);
5082
5083 llvm::Value *EmitDirectXBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
5084 llvm::Value *EmitSPIRVBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
5085 llvm::Value *EmitScalarOrConstFoldImmArg(unsigned ICEArguments, unsigned Idx,
5086 const CallExpr *E);
5087 llvm::Value *EmitSystemZBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
5088 llvm::Value *EmitNVPTXBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
5089 llvm::Value *EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
5090 const CallExpr *E);
5091 llvm::Value *EmitHexagonBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
5092 llvm::Value *EmitAVRBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
5093 llvm::Value *EmitRISCVBuiltinExpr(unsigned BuiltinID, const CallExpr *E,
5095
5096 llvm::Value *EmitRISCVCpuSupports(const CallExpr *E);
5097 llvm::Value *EmitRISCVCpuSupports(ArrayRef<StringRef> FeaturesStrs);
5098 llvm::Value *EmitRISCVCpuInit();
5099 llvm::Value *EmitRISCVCpuIs(const CallExpr *E);
5100 llvm::Value *EmitRISCVCpuIs(StringRef CPUStr);
5101
5102 void AddAMDGPUFenceAddressSpaceMMRA(llvm::Instruction *Inst,
5103 const CallExpr *E);
5104 /// Attach the AMDGPU availability/visibility MMRA to \p Inst when the
5105 /// amdgpu_av attribute is active on the current statement.
5106 void AddAMDGPUAvailableVisibleMMRA(llvm::Instruction *Inst);
5107 void ProcessOrderScopeAMDGCN(llvm::Value *Order, llvm::Value *Scope,
5108 llvm::AtomicOrdering &AO,
5109 llvm::SyncScope::ID &SSID);
5110
5112 llvm::Value *EmitMSVCBuiltinExpr(MSVCIntrin BuiltinID, const CallExpr *E);
5113
5114 llvm::Value *EmitBuiltinAvailable(const VersionTuple &Version);
5115
5116 llvm::Value *EmitObjCProtocolExpr(const ObjCProtocolExpr *E);
5117 llvm::Value *EmitObjCStringLiteral(const ObjCStringLiteral *E);
5118 llvm::Value *EmitObjCBoxedExpr(const ObjCBoxedExpr *E);
5119 llvm::Value *EmitObjCArrayLiteral(const ObjCArrayLiteral *E);
5120 llvm::Value *EmitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E);
5121 llvm::Value *
5123 const ObjCMethodDecl *MethodWithObjects);
5124 llvm::Value *EmitObjCSelectorExpr(const ObjCSelectorExpr *E);
5126 ReturnValueSlot Return = ReturnValueSlot());
5127
5128 /// Retrieves the default cleanup kind for an ARC cleanup.
5129 /// Except under -fobjc-arc-eh, ARC cleanups are normal-only.
5131 return CGM.getCodeGenOpts().ObjCAutoRefCountExceptions ? NormalAndEHCleanup
5132 : NormalCleanup;
5133 }
5134
5135 // ARC primitives.
5136 void EmitARCInitWeak(Address addr, llvm::Value *value);
5137 void EmitARCDestroyWeak(Address addr);
5138 llvm::Value *EmitARCLoadWeak(Address addr);
5139 llvm::Value *EmitARCLoadWeakRetained(Address addr);
5140 llvm::Value *EmitARCStoreWeak(Address addr, llvm::Value *value, bool ignored);
5141 void emitARCCopyAssignWeak(QualType Ty, Address DstAddr, Address SrcAddr);
5142 void emitARCMoveAssignWeak(QualType Ty, Address DstAddr, Address SrcAddr);
5143 void EmitARCCopyWeak(Address dst, Address src);
5144 void EmitARCMoveWeak(Address dst, Address src);
5145 llvm::Value *EmitARCRetainAutorelease(QualType type, llvm::Value *value);
5146 llvm::Value *EmitARCRetainAutoreleaseNonBlock(llvm::Value *value);
5147 llvm::Value *EmitARCStoreStrong(LValue lvalue, llvm::Value *value,
5148 bool resultIgnored);
5149 llvm::Value *EmitARCStoreStrongCall(Address addr, llvm::Value *value,
5150 bool resultIgnored);
5151 llvm::Value *EmitARCRetain(QualType type, llvm::Value *value);
5152 llvm::Value *EmitARCRetainNonBlock(llvm::Value *value);
5153 llvm::Value *EmitARCRetainBlock(llvm::Value *value, bool mandatory);
5155 void EmitARCRelease(llvm::Value *value, ARCPreciseLifetime_t precise);
5156 llvm::Value *EmitARCAutorelease(llvm::Value *value);
5157 llvm::Value *EmitARCAutoreleaseReturnValue(llvm::Value *value);
5158 llvm::Value *EmitARCRetainAutoreleaseReturnValue(llvm::Value *value);
5159 llvm::Value *EmitARCRetainAutoreleasedReturnValue(llvm::Value *value);
5160 llvm::Value *EmitARCUnsafeClaimAutoreleasedReturnValue(llvm::Value *value);
5161
5162 llvm::Value *EmitObjCAutorelease(llvm::Value *value, llvm::Type *returnType);
5163 llvm::Value *EmitObjCRetainNonBlock(llvm::Value *value,
5164 llvm::Type *returnType);
5165 void EmitObjCRelease(llvm::Value *value, ARCPreciseLifetime_t precise);
5166
5167 std::pair<LValue, llvm::Value *>
5169 std::pair<LValue, llvm::Value *> EmitARCStoreStrong(const BinaryOperator *e,
5170 bool ignored);
5171 std::pair<LValue, llvm::Value *>
5172 EmitARCStoreUnsafeUnretained(const BinaryOperator *e, bool ignored);
5173
5174 llvm::Value *EmitObjCAlloc(llvm::Value *value, llvm::Type *returnType);
5175 llvm::Value *EmitObjCAllocWithZone(llvm::Value *value,
5176 llvm::Type *returnType);
5177 llvm::Value *EmitObjCAllocInit(llvm::Value *value, llvm::Type *resultType);
5178
5179 llvm::Value *EmitObjCThrowOperand(const Expr *expr);
5180 llvm::Value *EmitObjCConsumeObject(QualType T, llvm::Value *Ptr);
5181 llvm::Value *EmitObjCExtendObjectLifetime(QualType T, llvm::Value *Ptr);
5182
5183 llvm::Value *EmitARCExtendBlockObject(const Expr *expr);
5184 llvm::Value *EmitARCReclaimReturnedObject(const Expr *e,
5185 bool allowUnsafeClaim);
5186 llvm::Value *EmitARCRetainScalarExpr(const Expr *expr);
5187 llvm::Value *EmitARCRetainAutoreleaseScalarExpr(const Expr *expr);
5188 llvm::Value *EmitARCUnsafeUnretainedScalarExpr(const Expr *expr);
5189
5191
5193
5199
5200 void EmitObjCAutoreleasePoolPop(llvm::Value *Ptr);
5201 llvm::Value *EmitObjCAutoreleasePoolPush();
5202 llvm::Value *EmitObjCMRRAutoreleasePoolPush();
5203 void EmitObjCAutoreleasePoolCleanup(llvm::Value *Ptr);
5204 void EmitObjCMRRAutoreleasePoolPop(llvm::Value *Ptr);
5205
5206 /// Emits a reference binding to the passed in expression.
5208
5209 //===--------------------------------------------------------------------===//
5210 // Expression Emission
5211 //===--------------------------------------------------------------------===//
5212
5213 // Expressions are broken into three classes: scalar, complex, aggregate.
5214
5215 /// EmitScalarExpr - Emit the computation of the specified expression of LLVM
5216 /// scalar type, returning the result.
5217 llvm::Value *EmitScalarExpr(const Expr *E, bool IgnoreResultAssign = false);
5218
5219 /// Emit a conversion from the specified type to the specified destination
5220 /// type, both of which are LLVM scalar types.
5221 llvm::Value *EmitScalarConversion(llvm::Value *Src, QualType SrcTy,
5222 QualType DstTy, SourceLocation Loc);
5223
5224 /// Emit a conversion from the specified complex type to the specified
5225 /// destination type, where the destination type is an LLVM scalar type.
5227 QualType DstTy,
5228 SourceLocation Loc);
5229
5230 /// EmitAggExpr - Emit the computation of the specified expression
5231 /// of aggregate type. The result is computed into the given slot,
5232 /// which may be null to indicate that the value is not needed.
5233 void EmitAggExpr(const Expr *E, AggValueSlot AS);
5234
5235 /// EmitAggExprToLValue - Emit the computation of the specified expression of
5236 /// aggregate type into a temporary LValue.
5238
5240
5241 /// EmitAggFinalDestCopy - Emit copy of the specified aggregate into
5242 /// destination address.
5243 void EmitAggFinalDestCopy(QualType Type, AggValueSlot Dest, const LValue &Src,
5244 ExprValueKind SrcKind);
5245
5246 /// Create a store to \arg DstPtr from \arg Src, truncating the stored value
5247 /// to at most \arg DstSize bytes.
5248 void CreateCoercedStore(llvm::Value *Src, QualType SrcFETy, Address Dst,
5249 llvm::TypeSize DstSize, bool DstIsVolatile);
5250
5251 /// EmitExtendGCLifetime - Given a pointer to an Objective-C object,
5252 /// make sure it survives garbage collection until this point.
5253 void EmitExtendGCLifetime(llvm::Value *object);
5254
5255 /// EmitComplexExpr - Emit the computation of the specified expression of
5256 /// complex type, returning the result.
5257 ComplexPairTy EmitComplexExpr(const Expr *E, bool IgnoreReal = false,
5258 bool IgnoreImag = false);
5259
5260 /// EmitComplexExprIntoLValue - Emit the given expression of complex
5261 /// type and place its result into the specified l-value.
5262 void EmitComplexExprIntoLValue(const Expr *E, LValue dest, bool isInit);
5263
5264 /// EmitStoreOfComplex - Store a complex number into the specified l-value.
5265 void EmitStoreOfComplex(ComplexPairTy V, LValue dest, bool isInit);
5266
5267 /// EmitLoadOfComplex - Load a complex number from the specified l-value.
5269
5270 ComplexPairTy EmitPromotedComplexExpr(const Expr *E, QualType PromotionType);
5271 llvm::Value *EmitPromotedScalarExpr(const Expr *E, QualType PromotionType);
5274 QualType PromotionType);
5275
5278
5279 /// AddInitializerToStaticVarDecl - Add the initializer for 'D' to the
5280 /// global variable that has already been created for it. If the initializer
5281 /// has a different type than GV does, this may free GV and return a different
5282 /// one. Otherwise it just returns GV.
5283 llvm::GlobalVariable *AddInitializerToStaticVarDecl(const VarDecl &D,
5284 llvm::GlobalVariable *GV);
5285
5286 // Emit an @llvm.invariant.start call for the given memory region.
5287 void EmitInvariantStart(llvm::Constant *Addr, CharUnits Size);
5288
5289 /// EmitCXXGlobalVarDeclInit - Create the initializer for a C++
5290 /// variable with global storage.
5291 void EmitCXXGlobalVarDeclInit(const VarDecl &D, llvm::GlobalVariable *GV,
5292 bool PerformInit);
5293
5294 llvm::Constant *createAtExitStub(const VarDecl &VD, llvm::FunctionCallee Dtor,
5295 llvm::Constant *Addr);
5296
5297 llvm::Function *createTLSAtExitStub(const VarDecl &VD,
5298 llvm::FunctionCallee Dtor,
5299 llvm::Constant *Addr,
5300 llvm::FunctionCallee &AtExit);
5301
5302 /// Call atexit() with a function that passes the given argument to
5303 /// the given function.
5304 void registerGlobalDtorWithAtExit(const VarDecl &D, llvm::FunctionCallee fn,
5305 llvm::Constant *addr);
5306
5307 /// Registers the dtor using 'llvm.global_dtors' for platforms that do not
5308 /// support an 'atexit()' function.
5309 void registerGlobalDtorWithLLVM(const VarDecl &D, llvm::FunctionCallee fn,
5310 llvm::Constant *addr);
5311
5312 /// Call atexit() with function dtorStub.
5313 void registerGlobalDtorWithAtExit(llvm::Constant *dtorStub);
5314
5315 /// Call unatexit() with function dtorStub.
5316 llvm::Value *unregisterGlobalDtorWithUnAtExit(llvm::Constant *dtorStub);
5317
5318 /// Emit code in this function to perform a guarded variable
5319 /// initialization. Guarded initializations are used when it's not
5320 /// possible to prove that an initialization will be done exactly
5321 /// once, e.g. with a static local variable or a static data member
5322 /// of a class template.
5323 void EmitCXXGuardedInit(const VarDecl &D, llvm::GlobalVariable *DeclPtr,
5324 bool PerformInit);
5325
5327
5328 /// Emit a branch to select whether or not to perform guarded initialization.
5329 void EmitCXXGuardedInitBranch(llvm::Value *NeedsInit,
5330 llvm::BasicBlock *InitBlock,
5331 llvm::BasicBlock *NoInitBlock, GuardKind Kind,
5332 const VarDecl *D);
5333
5334 /// GenerateCXXGlobalInitFunc - Generates code for initializing global
5335 /// variables.
5336 void
5337 GenerateCXXGlobalInitFunc(llvm::Function *Fn,
5338 ArrayRef<llvm::Function *> CXXThreadLocals,
5340
5341 /// GenerateCXXGlobalCleanUpFunc - Generates code for cleaning up global
5342 /// variables.
5344 llvm::Function *Fn,
5345 ArrayRef<std::tuple<llvm::FunctionType *, llvm::WeakTrackingVH,
5346 llvm::Constant *>>
5347 DtorsOrStermFinalizers);
5348
5349 void GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn, const VarDecl *D,
5350 llvm::GlobalVariable *Addr,
5351 bool PerformInit);
5352
5354
5355 void EmitSynthesizedCXXCopyCtor(Address Dest, Address Src, const Expr *Exp);
5356
5357 void EmitCXXThrowExpr(const CXXThrowExpr *E, bool KeepInsertionPoint = true);
5358
5360
5361 void EmitFakeUse(Address Addr);
5362
5363 //===--------------------------------------------------------------------===//
5364 // Annotations Emission
5365 //===--------------------------------------------------------------------===//
5366
5367 /// Emit an annotation call (intrinsic).
5368 llvm::Value *EmitAnnotationCall(llvm::Function *AnnotationFn,
5369 llvm::Value *AnnotatedVal,
5370 StringRef AnnotationStr,
5371 SourceLocation Location,
5372 const AnnotateAttr *Attr);
5373
5374 /// Emit local annotations for the local variable V, declared by D.
5375 void EmitVarAnnotations(const VarDecl *D, llvm::Value *V);
5376
5377 /// Emit field annotations for the given field & value. Returns the
5378 /// annotation result.
5380
5381 //===--------------------------------------------------------------------===//
5382 // Internal Helpers
5383 //===--------------------------------------------------------------------===//
5384
5385 /// ContainsLabel - Return true if the statement contains a label in it. If
5386 /// this statement is not executed normally, it not containing a label means
5387 /// that we can just remove the code.
5388 static bool ContainsLabel(const Stmt *S, bool IgnoreCaseStmts = false);
5389
5390 /// containsBreak - Return true if the statement contains a break out of it.
5391 /// If the statement (recursively) contains a switch or loop with a break
5392 /// inside of it, this is fine.
5393 static bool containsBreak(const Stmt *S);
5394
5395 /// Determine if the given statement might introduce a declaration into the
5396 /// current scope, by being a (possibly-labelled) DeclStmt.
5397 static bool mightAddDeclToScope(const Stmt *S);
5398
5399 /// ConstantFoldsToSimpleInteger - If the specified expression does not fold
5400 /// to a constant, or if it does but contains a label, return false. If it
5401 /// constant folds return true and set the boolean result in Result.
5402 bool ConstantFoldsToSimpleInteger(const Expr *Cond, bool &Result,
5403 bool AllowLabels = false);
5404
5405 /// ConstantFoldsToSimpleInteger - If the specified expression does not fold
5406 /// to a constant, or if it does but contains a label, return false. If it
5407 /// constant folds return true and set the folded value.
5408 bool ConstantFoldsToSimpleInteger(const Expr *Cond, llvm::APSInt &Result,
5409 bool AllowLabels = false);
5410
5411 /// Ignore parentheses and logical-NOT to track conditions consistently.
5412 static const Expr *stripCond(const Expr *C);
5413
5414 /// isInstrumentedCondition - Determine whether the given condition is an
5415 /// instrumentable condition (i.e. no "&&" or "||").
5416 static bool isInstrumentedCondition(const Expr *C);
5417
5418 /// EmitBranchToCounterBlock - Emit a conditional branch to a new block that
5419 /// increments a profile counter based on the semantics of the given logical
5420 /// operator opcode. This is used to instrument branch condition coverage
5421 /// for logical operators.
5423 llvm::BasicBlock *TrueBlock,
5424 llvm::BasicBlock *FalseBlock,
5425 uint64_t TrueCount = 0,
5427 const Expr *CntrIdx = nullptr);
5428
5429 /// EmitBranchOnBoolExpr - Emit a branch on a boolean condition (e.g. for an
5430 /// if statement) to the specified blocks. Based on the condition, this might
5431 /// try to simplify the codegen of the conditional based on the branch.
5432 /// TrueCount should be the number of times we expect the condition to
5433 /// evaluate to true based on PGO data.
5434 void EmitBranchOnBoolExpr(const Expr *Cond, llvm::BasicBlock *TrueBlock,
5435 llvm::BasicBlock *FalseBlock, uint64_t TrueCount,
5437 const Expr *ConditionalOp = nullptr,
5438 const VarDecl *ConditionalDecl = nullptr);
5439
5440 /// Given an assignment `*LHS = RHS`, emit a test that checks if \p RHS is
5441 /// nonnull, if \p LHS is marked _Nonnull.
5442 void EmitNullabilityCheck(LValue LHS, llvm::Value *RHS, SourceLocation Loc);
5443
5444 /// An enumeration which makes it easier to specify whether or not an
5445 /// operation is a subtraction.
5446 enum { NotSubtraction = false, IsSubtraction = true };
5447
5448 /// Emit pointer + index arithmetic.
5449 llvm::Value *EmitPointerArithmetic(const BinaryOperator *BO,
5450 Expr *pointerOperand, llvm::Value *pointer,
5451 Expr *indexOperand, llvm::Value *index,
5452 bool isSubtraction);
5453
5454 /// Same as IRBuilder::CreateInBoundsGEP, but additionally emits a check to
5455 /// detect undefined behavior when the pointer overflow sanitizer is enabled.
5456 /// \p SignedIndices indicates whether any of the GEP indices are signed.
5457 /// \p IsSubtraction indicates whether the expression used to form the GEP
5458 /// is a subtraction.
5459 llvm::Value *EmitCheckedInBoundsGEP(llvm::Type *ElemTy, llvm::Value *Ptr,
5461 bool SignedIndices, bool IsSubtraction,
5462 SourceLocation Loc,
5463 const Twine &Name = "");
5464
5466 llvm::Type *elementType, bool SignedIndices,
5467 bool IsSubtraction, SourceLocation Loc,
5468 CharUnits Align, const Twine &Name = "");
5469
5470 /// Specifies which type of sanitizer check to apply when handling a
5471 /// particular builtin.
5479
5480 /// Emits an argument for a call to a builtin. If the builtin sanitizer is
5481 /// enabled, a runtime check specified by \p Kind is also emitted.
5482 llvm::Value *EmitCheckedArgForBuiltin(const Expr *E, BuiltinCheckKind Kind);
5483
5484 /// Emits an argument for a call to a `__builtin_assume`. If the builtin
5485 /// sanitizer is enabled, a runtime check is also emitted.
5486 llvm::Value *EmitCheckedArgForAssume(const Expr *E);
5487
5488 /// Emit a description of a type in a format suitable for passing to
5489 /// a runtime sanitizer handler.
5490 llvm::Constant *EmitCheckTypeDescriptor(QualType T);
5491
5492 /// Convert a value into a format suitable for passing to a runtime
5493 /// sanitizer handler.
5494 llvm::Value *EmitCheckValue(llvm::Value *V);
5495
5496 /// Emit a description of a source location in a format suitable for
5497 /// passing to a runtime sanitizer handler.
5498 llvm::Constant *EmitCheckSourceLocation(SourceLocation Loc);
5499
5500 void EmitKCFIOperandBundle(const CGCallee &Callee,
5502
5503 /// Create a basic block that will either trap or call a handler function in
5504 /// the UBSan runtime with the provided arguments, and create a conditional
5505 /// branch to it.
5506 void
5507 EmitCheck(ArrayRef<std::pair<llvm::Value *, SanitizerKind::SanitizerOrdinal>>
5508 Checked,
5510 ArrayRef<llvm::Value *> DynamicArgs,
5511 const TrapReason *TR = nullptr);
5512
5513 /// Emit a slow path cross-DSO CFI check which calls __cfi_slowpath
5514 /// if Cond if false.
5516 llvm::Value *Cond, llvm::ConstantInt *TypeId,
5517 llvm::Value *Ptr,
5518 ArrayRef<llvm::Constant *> StaticArgs);
5519
5520 /// Emit a reached-unreachable diagnostic if \p Loc is valid and runtime
5521 /// checking is enabled. Otherwise, just emit an unreachable instruction.
5523
5524 /// Create a basic block that will call the trap intrinsic, and emit a
5525 /// conditional branch to it, for the -ftrapv checks.
5526 void EmitTrapCheck(llvm::Value *Checked, SanitizerHandler CheckHandlerID,
5527 bool NoMerge = false, const TrapReason *TR = nullptr);
5528
5529 /// Emit a call to trap or debugtrap. If 'EnsureInsertPoint' is false, the
5530 /// IR builder need not have a valid insert point after this returns.
5531 llvm::CallInst *EmitTrapCall(llvm::Intrinsic::ID IntrID,
5532 bool EnsureInsertPoint = true);
5533
5534 /// Emit a call to '\@llvm.trap()' and clear the current insert point.
5536
5537 /// Emit a stub for the cross-DSO CFI check function.
5538 void EmitCfiCheckStub();
5539
5540 /// Emit a cross-DSO CFI failure handling function.
5541 void EmitCfiCheckFail();
5542
5543 /// Create a check for a function parameter that may potentially be
5544 /// declared as non-null.
5545 void EmitNonNullArgCheck(RValue RV, QualType ArgType, SourceLocation ArgLoc,
5546 AbstractCallee AC, unsigned ParmNum);
5547
5549 SourceLocation ArgLoc, AbstractCallee AC,
5550 unsigned ParmNum);
5551
5552 /// EmitWriteback - Emit callbacks for function.
5553 void EmitWritebacks(const CallArgList &Args);
5554
5555 /// EmitCallArg - Emit a single call argument.
5556 void EmitCallArg(CallArgList &args, const Expr *E, QualType ArgType);
5557
5558 /// EmitDelegateCallArg - We are performing a delegate call; that
5559 /// is, the current function is delegating to another one. Produce
5560 /// a r-value suitable for passing the given parameter.
5561 void EmitDelegateCallArg(CallArgList &args, const VarDecl *param,
5562 SourceLocation loc);
5563
5564 /// SetFPAccuracy - Set the minimum required accuracy of the given floating
5565 /// point operation, expressed as the maximum relative error in ulp.
5566 void SetFPAccuracy(llvm::Value *Val, float Accuracy);
5567
5568 /// Set the minimum required accuracy of the given sqrt operation
5569 /// based on CodeGenOpts.
5570 void SetSqrtFPAccuracy(llvm::Value *Val);
5571
5572 /// Set the minimum required accuracy of the given sqrt operation based on
5573 /// CodeGenOpts.
5574 void SetDivFPAccuracy(llvm::Value *Val);
5575
5576 /// Set the codegen fast-math flags.
5577 void SetFastMathFlags(FPOptions FPFeatures);
5578
5579 // Truncate or extend a boolean vector to the requested number of elements.
5580 llvm::Value *emitBoolVecConversion(llvm::Value *SrcVec,
5581 unsigned NumElementsDst,
5582 const llvm::Twine &Name = "");
5583
5584 void maybeAttachRangeForLoad(llvm::LoadInst *Load, QualType Ty,
5585 SourceLocation Loc);
5586
5587 // Emits a convergence_loop instruction for the given |BB|, with |ParentToken|
5588 // as it's parent convergence instr.
5589 llvm::ConvergenceControlInst *emitConvergenceLoopToken(llvm::BasicBlock *BB);
5590
5591private:
5592 // Adds a convergencectrl bundle with the current convergence token to
5593 // |Bundles|, if convergence tokens are used.
5594 void
5595 addConvergenceControlBundle(SmallVectorImpl<llvm::OperandBundleDef> &Bundles);
5596
5597 // Marks |Call| convergent if |IsConvergent| and its callee does not already
5598 // imply it.
5599 void setConvergentCallSite(llvm::CallBase *Call, bool IsConvergent);
5600
5601 // Find the convergence_entry instruction |F|, or emits ones if none exists.
5602 // Returns the convergence instruction.
5603 llvm::ConvergenceControlInst *
5604 getOrEmitConvergenceEntryToken(llvm::Function *F);
5605
5606private:
5607 llvm::MDNode *getRangeForLoadFromType(QualType Ty);
5608 void EmitReturnOfRValue(RValue RV, QualType Ty);
5609
5610 void deferPlaceholderReplacement(llvm::Instruction *Old, llvm::Value *New);
5611
5613 DeferredReplacements;
5614
5615 /// Set the address of a local variable.
5616 void setAddrOfLocalVar(const VarDecl *VD, Address Addr) {
5617 assert(!LocalDeclMap.count(VD) && "Decl already exists in LocalDeclMap!");
5618 LocalDeclMap.insert({VD, Addr});
5619 }
5620
5621 /// ExpandTypeFromArgs - Reconstruct a structure of type \arg Ty
5622 /// from function arguments into \arg Dst. See ABIArgInfo::Expand.
5623 ///
5624 /// \param AI - The first function argument of the expansion.
5625 void ExpandTypeFromArgs(QualType Ty, LValue Dst,
5626 llvm::Function::arg_iterator &AI);
5627
5628 /// ExpandTypeToArgs - Expand an CallArg \arg Arg, with the LLVM type for \arg
5629 /// Ty, into individual arguments on the provided vector \arg IRCallArgs,
5630 /// starting at index \arg IRCallArgPos. See ABIArgInfo::Expand.
5631 void ExpandTypeToArgs(QualType Ty, CallArg Arg, llvm::FunctionType *IRFuncTy,
5632 SmallVectorImpl<llvm::Value *> &IRCallArgs,
5633 unsigned &IRCallArgPos);
5634
5635 std::pair<llvm::Value *, llvm::Type *>
5636 EmitAsmInput(const TargetInfo::ConstraintInfo &Info, const Expr *InputExpr,
5637 std::string &ConstraintStr);
5638
5639 std::pair<llvm::Value *, llvm::Type *>
5640 EmitAsmInputLValue(const TargetInfo::ConstraintInfo &Info, LValue InputValue,
5641 QualType InputType, std::string &ConstraintStr,
5642 SourceLocation Loc);
5643
5644 /// Attempts to statically evaluate the object size of E. If that
5645 /// fails, emits code to figure the size of E out for us. This is
5646 /// pass_object_size aware.
5647 ///
5648 /// If EmittedExpr is non-null, this will use that instead of re-emitting E.
5649 llvm::Value *evaluateOrEmitBuiltinObjectSize(const Expr *E, unsigned Type,
5650 llvm::IntegerType *ResType,
5651 llvm::Value *EmittedE,
5652 bool IsDynamic);
5653
5654 /// Emits the size of E, as required by __builtin_object_size. This
5655 /// function is aware of pass_object_size parameters, and will act accordingly
5656 /// if E is a parameter with the pass_object_size attribute.
5657 llvm::Value *emitBuiltinObjectSize(const Expr *E, unsigned Type,
5658 llvm::IntegerType *ResType,
5659 llvm::Value *EmittedE, bool IsDynamic);
5660
5661 llvm::Value *emitCountedBySize(const Expr *E, llvm::Value *EmittedE,
5662 unsigned Type, llvm::IntegerType *ResType);
5663
5664 llvm::Value *emitCountedByMemberSize(const MemberExpr *E, const Expr *Idx,
5665 llvm::Value *EmittedE,
5666 QualType CastedArrayElementTy,
5667 unsigned Type,
5668 llvm::IntegerType *ResType);
5669
5670 llvm::Value *emitCountedByPointerSize(const ImplicitCastExpr *E,
5671 const Expr *Idx, llvm::Value *EmittedE,
5672 QualType CastedArrayElementTy,
5673 unsigned Type,
5674 llvm::IntegerType *ResType);
5675
5676 void emitZeroOrPatternForAutoVarInit(QualType type, const VarDecl &D,
5677 Address Loc);
5678 LangOptions::TrivialAutoVarInitKind getAutoVarInitKind(QualType Ty,
5679 const VarDecl &D);
5680
5681public:
5683
5684 // Wrapper for function prototype sources. Wraps either a FunctionProtoType or
5685 // an ObjCMethodDecl.
5687 llvm::PointerUnion<const FunctionProtoType *, const ObjCMethodDecl *> P;
5688
5691 };
5692
5693 void EmitCallArgs(CallArgList &Args, PrototypeWrapper Prototype,
5694 llvm::iterator_range<CallExpr::const_arg_iterator> ArgRange,
5695 AbstractCallee AC = AbstractCallee(),
5696 unsigned ParamsToSkip = 0,
5697 EvaluationOrder Order = EvaluationOrder::Default);
5698
5699 /// EmitPointerWithAlignment - Given an expression with a pointer type,
5700 /// emit the value and compute our best estimate of the alignment of the
5701 /// pointee.
5702 ///
5703 /// \param BaseInfo - If non-null, this will be initialized with
5704 /// information about the source of the alignment and the may-alias
5705 /// attribute. Note that this function will conservatively fall back on
5706 /// the type when it doesn't recognize the expression and may-alias will
5707 /// be set to false.
5708 ///
5709 /// One reasonable way to use this information is when there's a language
5710 /// guarantee that the pointer must be aligned to some stricter value, and
5711 /// we're simply trying to ensure that sufficiently obvious uses of under-
5712 /// aligned objects don't get miscompiled; for example, a placement new
5713 /// into the address of a local variable. In such a case, it's quite
5714 /// reasonable to just ignore the returned alignment when it isn't from an
5715 /// explicit source.
5716 Address
5717 EmitPointerWithAlignment(const Expr *Addr, LValueBaseInfo *BaseInfo = nullptr,
5718 TBAAAccessInfo *TBAAInfo = nullptr,
5719 KnownNonNull_t IsKnownNonNull = NotKnownNonNull);
5720
5721 /// If \p E references a parameter with pass_object_size info or a constant
5722 /// array size modifier, emit the object size divided by the size of \p EltTy.
5723 /// Otherwise return null.
5724 llvm::Value *LoadPassedObjectSize(const Expr *E, QualType EltTy);
5725
5726 void EmitSanitizerStatReport(llvm::SanitizerStatKind SSK);
5727
5729 llvm::Function *Function;
5731 std::optional<StringRef> Architecture;
5732
5733 FMVResolverOption(llvm::Function *F, ArrayRef<StringRef> Feats,
5734 std::optional<StringRef> Arch = std::nullopt)
5735 : Function(F), Features(Feats), Architecture(Arch) {}
5736 };
5737
5738 // Emits the body of a multiversion function's resolver. Assumes that the
5739 // options are already sorted in the proper order, with the 'default' option
5740 // last (if it exists).
5741 void EmitMultiVersionResolver(llvm::Function *Resolver,
5743 void EmitX86MultiVersionResolver(llvm::Function *Resolver,
5745 void EmitAArch64MultiVersionResolver(llvm::Function *Resolver,
5747 void EmitRISCVMultiVersionResolver(llvm::Function *Resolver,
5749 void EmitPPCAIXMultiVersionResolver(llvm::Function *Resolver,
5751
5752 Address EmitAddressOfPFPField(Address RecordPtr, const PFPField &Field);
5753 Address EmitAddressOfPFPField(Address RecordPtr, Address FieldPtr,
5754 const FieldDecl *Field);
5755
5756private:
5757 QualType getVarArgType(const Expr *Arg);
5758
5759 void EmitDeclMetadata();
5760
5761 BlockByrefHelpers *buildByrefHelpers(llvm::StructType &byrefType,
5762 const AutoVarEmission &emission);
5763
5764 void AddObjCARCExceptionMetadata(llvm::Instruction *Inst);
5765
5766 llvm::Value *GetValueForARMHint(unsigned BuiltinID);
5767 llvm::Value *EmitX86CpuIs(const CallExpr *E);
5768 llvm::Value *EmitX86CpuIs(StringRef CPUStr);
5769 llvm::Value *EmitX86CpuSupports(const CallExpr *E);
5770 llvm::Value *EmitX86CpuSupports(ArrayRef<StringRef> FeatureStrs);
5771 llvm::Value *EmitX86CpuSupports(std::array<uint32_t, 4> FeatureMask);
5772 llvm::Value *EmitX86CpuInit();
5773 llvm::Value *FormX86ResolverCondition(const FMVResolverOption &RO);
5774 llvm::Value *EmitAArch64CpuInit();
5775 llvm::Value *FormAArch64ResolverCondition(const FMVResolverOption &RO);
5776 llvm::Value *EmitAArch64CpuSupports(const CallExpr *E);
5777 llvm::Value *EmitAArch64CpuSupports(ArrayRef<StringRef> FeatureStrs);
5778};
5779
5780inline DominatingLLVMValue::saved_type
5782 if (!needsSaving(value))
5783 return saved_type(value);
5784
5785 // Otherwise, we need an alloca.
5786 auto align = CharUnits::fromQuantity(
5787 CGF.CGM.getDataLayout().getPrefTypeAlign(value->getType()))
5788 .getAsAlign();
5789 llvm::AllocaInst *AI =
5790 CGF.CreateTempAlloca(value->getType(), "cond-cleanup.save");
5791 AI->setAlignment(align);
5792 CGF.Builder.CreateAlignedStore(value, AI, align);
5793
5794 return saved_type(AI, value->getType());
5795}
5796
5798 saved_type value) {
5799 // If the value says it wasn't saved, trust that it's still dominating.
5800 if (!value.isSaved())
5801 return value.Value;
5802
5803 // Otherwise, it should be an alloca instruction, as set up in save().
5804 auto Alloca = cast<llvm::AllocaInst>(value.Value);
5805 return CGF.Builder.CreateAlignedLoad(value.Type, Alloca, Alloca->getAlign());
5806}
5807
5808} // end namespace CodeGen
5809
5810// Map the LangOption for floating point exception behavior into
5811// the corresponding enum in the IR.
5812llvm::fp::ExceptionBehavior
5814} // end namespace clang
5815
5816#endif
Enums/classes describing ABI related information about constructors, destructors and thunks.
#define V(N, I)
static bool CanThrow(Expr *E, ASTContext &Ctx)
Definition CFG.cpp:2854
static T * buildByrefHelpers(CodeGenModule &CGM, const BlockByrefInfo &byrefInfo, T &&generator)
Lazily build the copy and dispose helpers for a __block variable with the given information.
static bool isInAllocaArgument(CGCXXABI &ABI, QualType type)
Definition CGCall.cpp:4678
@ ForDeactivation
CodeGenFunction::ComplexPairTy ComplexPairTy
Defines the clang::Expr interface and subclasses for C++ expressions.
FormatToken * Previous
The previous token in the unwrapped line.
#define X(type, name)
Definition Value.h:97
llvm::MachO::Target Target
Definition MachO.h:51
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a kind
Defines some OpenMP-specific enums and functions.
llvm::json::Array Array
SanitizerHandler
This file defines OpenACC AST classes for statement-level contructs.
This file defines OpenMP AST classes for executable directives and clauses.
This file defines SYCL AST classes used to represent calls to SYCL kernels.
C Language Family Type Representation.
This represents 'pragma omp atomic' directive.
This represents 'pragma omp barrier' directive.
This represents 'pragma omp cancel' directive.
This represents 'pragma omp cancellation point' directive.
This represents 'pragma omp critical' directive.
This represents 'pragma omp depobj' directive.
This represents 'pragma omp distribute' directive.
This represents 'pragma omp distribute parallel for' composite directive.
This represents 'pragma omp distribute parallel for simd' composite directive.
This represents 'pragma omp distribute simd' composite directive.
This represents 'pragma omp error' directive.
Represents the 'pragma omp flatten' loop transformation directive.
This represents 'pragma omp flush' directive.
This represents 'pragma omp for' directive.
This represents 'pragma omp for simd' directive.
Represents the 'pragma omp fuse' loop transformation directive.
This represents 'pragma omp loop' directive.
Represents the 'pragma omp interchange' loop transformation directive.
This represents 'pragma omp interop' directive.
This is a common base class for loop directives ('omp simd', 'omp for', 'omp for simd' etc....
This represents 'pragma omp masked' directive.
This represents 'pragma omp masked taskloop' directive.
This represents 'pragma omp masked taskloop simd' directive.
This represents 'pragma omp master' directive.
This represents 'pragma omp master taskloop' directive.
This represents 'pragma omp master taskloop simd' directive.
This represents 'pragma omp metadirective' directive.
This represents block-associated 'pragma omp ordered' directive.
This represents standalone 'pragma omp ordered' directive.
This represents 'pragma omp parallel for' directive.
This represents 'pragma omp parallel for simd' directive.
This represents 'pragma omp parallel masked' directive.
This represents 'pragma omp parallel masked taskloop' directive.
This represents 'pragma omp parallel masked taskloop simd' directive.
This represents 'pragma omp parallel master' directive.
This represents 'pragma omp parallel master taskloop' directive.
This represents 'pragma omp parallel master taskloop simd' directive.
This represents 'pragma omp parallel sections' directive.
Represents the 'pragma omp reverse' loop transformation directive.
This represents 'pragma omp scan' directive.
This represents 'pragma omp scope' directive.
This represents 'pragma omp section' directive.
This represents 'pragma omp sections' directive.
This represents 'pragma omp simd' directive.
This represents 'pragma omp single' directive.
Represents the 'pragma omp split' loop transformation directive.
This represents the 'pragma omp stripe' loop transformation directive.
This represents 'pragma omp target data' directive.
This represents 'pragma omp target' directive.
This represents 'pragma omp target enter data' directive.
This represents 'pragma omp target exit data' directive.
This represents 'pragma omp target parallel' directive.
This represents 'pragma omp target parallel for' directive.
This represents 'pragma omp target parallel for simd' directive.
This represents 'pragma omp target parallel loop' directive.
This represents 'pragma omp target teams' directive.
This represents 'pragma omp target teams distribute' combined directive.
This represents 'pragma omp target teams distribute parallel for' combined directive.
This represents 'pragma omp target teams distribute parallel for simd' combined directive.
This represents 'pragma omp target teams distribute simd' combined directive.
This represents 'pragma omp target teams loop' directive.
This represents 'pragma omp target update' directive.
This represents 'pragma omp task' directive.
This represents 'pragma omp taskloop' directive.
This represents 'pragma omp taskloop simd' directive.
This represents 'pragma omp taskgroup' directive.
This represents 'pragma omp taskwait' directive.
This represents 'pragma omp taskyield' directive.
This represents 'pragma omp teams' directive.
This represents 'pragma omp teams distribute' directive.
This represents 'pragma omp teams distribute parallel for' composite directive.
This represents 'pragma omp teams distribute parallel for simd' composite directive.
This represents 'pragma omp teams distribute simd' combined directive.
This represents 'pragma omp teams loop' directive.
This represents the 'pragma omp tile' loop transformation directive.
This represents the 'pragma omp unroll' loop transformation directive.
This represents clause 'use_device_addr' in the 'pragma omp ...' directives.
This represents clause 'use_device_ptr' in the 'pragma omp ...' directives.
const Stmt * getAssociatedStmt() const
Stmt * getStructuredBlock()
This class represents a 'loop' construct. The 'loop' construct applies to a 'for' loop (or range-for ...
a trap message and trap category.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Definition APValue.h:158
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:245
AbstractConditionalOperator - An abstract base class for ConditionalOperator and BinaryConditionalOpe...
Definition Expr.h:4422
This class represents BOTH the OpenMP Array Section and OpenACC 'subarray', with a boolean differenti...
Definition Expr.h:7305
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition Expr.h:2790
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition TypeBase.h:3820
This structure holds the information gathered about the constraints for an inline assembly statement.
Definition CGStmt.cpp:2644
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
Definition Expr.h:7014
Attr - This represents one attribute.
Definition Attr.h:47
Represents an attribute applied to a statement.
Definition Stmt.h:2214
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
Definition Expr.h:4522
OpaqueValueExpr * getOpaqueValue() const
getOpaqueValue - Return the opaque value placeholder.
Definition Expr.h:4560
Expr * getCommon() const
getCommon - Return the common expression, written to the left of the condition.
Definition Expr.h:4557
A builtin binary operation expression such as "x + y" or "x <= y".
Definition Expr.h:4107
static bool isLogicalOp(Opcode Opc)
Definition Expr.h:4240
BinaryOperatorKind Opcode
Definition Expr.h:4112
A binding in a decomposition declaration.
Definition DeclCXX.h:4232
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition Expr.h:6758
Represents a call to a CUDA kernel function.
Definition ExprCXX.h:239
Represents binding an expression to a temporary.
Definition ExprCXX.h:1498
Represents a call to a C++ constructor.
Definition ExprCXX.h:1553
Represents a C++ constructor within a class.
Definition DeclCXX.h:2645
A default argument (C++ [dcl.fct.default]).
Definition ExprCXX.h:1275
A use of a default initializer in a constructor or in aggregate initialization.
Definition ExprCXX.h:1382
Represents a delete expression for memory deallocation and destructor calls, e.g.
Definition ExprCXX.h:2631
Represents a C++ destructor within a class.
Definition DeclCXX.h:2924
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
Definition ExprCXX.h:486
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
Definition StmtCXX.h:136
Represents a call to an inherited base class constructor from an inheriting constructor.
Definition ExprCXX.h:1756
Represents a call to a member function that may be written either with member call syntax (e....
Definition ExprCXX.h:184
Represents a static or instance method of a struct/union/class.
Definition DeclCXX.h:2153
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
Definition ExprCXX.h:2360
A call to an overloaded operator written using operator syntax.
Definition ExprCXX.h:86
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Definition ExprCXX.h:2750
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
Represents a C++ temporary.
Definition ExprCXX.h:1464
A C++ throw-expression (C++ [except.throw]).
Definition ExprCXX.h:1213
CXXTryStmt - A C++ try block, including all handlers.
Definition StmtCXX.h:70
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Definition ExprCXX.h:853
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition ExprCXX.h:1073
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition Expr.h:3012
This captures a statement into a function.
Definition Stmt.h:3950
const Capture * const_capture_iterator
Definition Stmt.h:4084
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of captures.
Definition Stmt.h:4101
const RecordDecl * getCapturedRecordDecl() const
Retrieve the record declaration for captured variables.
Definition Stmt.h:4071
capture_iterator capture_begin()
Retrieve an iterator pointing to the first capture.
Definition Stmt.h:4096
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition Expr.h:3745
const CXXBaseSpecifier *const * path_const_iterator
Definition Expr.h:3812
This is an opaque type for sizes expressed in character units.
Definition CharUnits.h:38
bool isZero() const
Test whether the quantity equals zero.
Definition CharUnits.h:101
llvm::Align getAsAlign() const
Returns Quantity as a valid llvm::Align, Beware llvm::Align assumes power of two 8-bit bytes.
Definition CharUnits.h:159
static CharUnits fromQuantity(QuantityType Quantity)
Construct a CharUnits quantity from a raw integer type.
Definition CharUnits.h:58
static CharUnits Zero()
Construct a CharUnits quantity of zero.
Definition CharUnits.h:52
Like RawAddress, an abstract representation of an aligned address, but the pointer contained in this ...
Definition Address.h:128
llvm::Value * getBasePointer() const
Definition Address.h:198
static Address invalid()
Definition Address.h:176
llvm::Value * emitRawPointer(CodeGenFunction &CGF) const
Return the pointer contained in this class after authenticating it and adding offset to it if necessa...
Definition Address.h:253
CharUnits getAlignment() const
Definition Address.h:194
llvm::Type * getElementType() const
Return the type of the values stored in this address.
Definition Address.h:209
void setAlignment(CharUnits Value)
Definition Address.h:196
llvm::Value * getOffset() const
Definition Address.h:246
void replaceBasePointer(llvm::Value *P)
This function is used in situations where the caller is doing some sort of opaque "laundering" of the...
Definition Address.h:186
llvm::PointerType * getType() const
Return the type of the pointer value.
Definition Address.h:204
An aggregate value slot.
Definition CGValue.h:551
static AggValueSlot ignored()
ignored - Returns an aggregate value slot indicating that the aggregate value is being ignored.
Definition CGValue.h:619
static AggValueSlot forAddr(Address addr, Qualifiers quals, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, IsAliased_t isAliased, Overlap_t mayOverlap, IsZeroed_t isZeroed=IsNotZeroed, IsSanitizerChecked_t isChecked=IsNotSanitizerChecked)
forAddr - Make a slot for an aggregate value.
Definition CGValue.h:634
A scoped helper to set the current source atom group for CGDebugInfo::addInstToCurrentSourceAtom.
A pair of helper functions for a __block variable.
Information about the layout of a __block variable.
Definition CGBlocks.h:136
CGBlockInfo - Information to generate a block literal.
Definition CGBlocks.h:157
llvm::StoreInst * CreateStore(llvm::Value *Val, Address Addr, bool IsVolatile=false)
Definition CGBuilder.h:156
llvm::StoreInst * CreateAlignedStore(llvm::Value *Val, llvm::Value *Addr, CharUnits Align, bool IsVolatile=false)
Definition CGBuilder.h:163
llvm::LoadInst * CreateAlignedLoad(llvm::Type *Ty, llvm::Value *Addr, CharUnits Align, const llvm::Twine &Name="")
Definition CGBuilder.h:148
Implements C++ ABI-specific code generation functions.
Definition CGCXXABI.h:43
All available information about a concrete callee.
Definition CGCall.h:66
This class gathers all debug information during compilation and is responsible for emitting to llvm g...
Definition CGDebugInfo.h:59
CGFunctionInfo - Class to encapsulate the information about a function definition.
CallArgList - Type for representing both the value and type of arguments in a call.
Definition CGCall.h:277
const ParmVarDecl * getParamDecl(unsigned I) const
ArrayInitLoopExprScope(CodeGenFunction &CGF, llvm::Value *Index)
Address getAllocatedAddress() const
Returns the raw, allocated address, which is not necessarily the address of the object itself.
RawAddress getOriginalAllocatedAddress() const
Returns the address for the original alloca instruction.
Address getObjectAddress(CodeGenFunction &CGF) const
Returns the address of the object within this declaration.
CGAtomicOptionsRAII(CodeGenModule &CGM_, AtomicOptions AO)
CGAtomicOptionsRAII(CodeGenModule &CGM_, const AtomicAttr *AA)
CGAtomicOptionsRAII(const CGAtomicOptionsRAII &)=delete
CGAtomicOptionsRAII & operator=(const CGAtomicOptionsRAII &)=delete
API for captured statement code generation.
static bool classof(const CGCapturedStmtInfo *)
llvm::SmallDenseMap< const VarDecl *, FieldDecl * > getCaptureFields()
Get the CaptureFields.
CGCapturedStmtInfo(CapturedRegionKind K=CR_Default)
virtual void EmitBody(CodeGenFunction &CGF, const Stmt *S)
Emit the captured statement body.
virtual StringRef getHelperName() const
Get the name of the capture helper.
CGCapturedStmtInfo(const CapturedStmt &S, CapturedRegionKind K=CR_Default)
virtual const FieldDecl * lookup(const VarDecl *VD) const
Lookup the captured field decl for a variable.
CGCapturedStmtRAII(CodeGenFunction &CGF, CGCapturedStmtInfo *NewCapturedStmtInfo)
CGFPOptionsRAII(CodeGenFunction &CGF, FPOptions FPFeatures)
CXXDefaultInitExprScope(CodeGenFunction &CGF, const CXXDefaultInitExpr *E)
void Emit(CodeGenFunction &CGF, Flags flags) override
An object to manage conditionally-evaluated expressions.
llvm::BasicBlock * getStartingBlock() const
Returns a block which will be executed prior to each evaluation of the conditional code.
static ConstantEmission forValue(llvm::Constant *C)
static ConstantEmission forReference(llvm::Constant *C)
LValue getReferenceLValue(CodeGenFunction &CGF, const Expr *RefExpr) const
void Emit(CodeGenFunction &CGF, Flags flags) override
FieldConstructionScope(CodeGenFunction &CGF, Address This)
A class controlling the emission of a finally block.
void enter(CodeGenFunction &CGF, const Stmt *Finally, llvm::FunctionCallee beginCatchFn, llvm::FunctionCallee endCatchFn, llvm::FunctionCallee rethrowFn)
Enters a finally block for an implementation using zero-cost exceptions.
void rescopeLabels()
Change the cleanup scope of the labels in this lexical scope to match the scope of the enclosing cont...
Definition CGStmt.cpp:760
~LexicalScope()
Exit this cleanup scope, emitting any accumulated cleanups.
void ForceCleanup()
Force the emission of cleanups now, instead of waiting until this object is destroyed.
InlinedRegionBodyRAII(CodeGenFunction &cgf, InsertPointTy &AllocaIP, llvm::BasicBlock &FiniBB)
OutlinedRegionBodyRAII(CodeGenFunction &cgf, InsertPointTy &AllocaIP, llvm::BasicBlock &RetBB)
OMPCancelStackRAII(CodeGenFunction &CGF, OpenMPDirectiveKind Kind, bool HasCancel)
The class used to assign some variables some temporarily addresses.
bool setVarAddr(CodeGenFunction &CGF, const ValueDecl *LocalVD, Address TempAddr)
Sets the address of the variable LocalVD to be TempAddr in function CGF.
bool apply(CodeGenFunction &CGF)
Applies new addresses to the list of the variables.
void restore(CodeGenFunction &CGF)
Restores original addresses of the variables.
The scope used to remap some variables as private in the OpenMP loop body (or other captured region e...
void restoreMap()
Restore all mapped variables w/o clean up.
bool Privatize()
Privatizes local variables previously registered as private.
bool isGlobalVarCaptured(const VarDecl *VD) const
Checks if the global variable is captured in current function.
OMPPrivateScope(CodeGenFunction &CGF)
Enter a new OpenMP private scope.
~OMPPrivateScope()
Exit scope - all the mapped variables are restored.
bool addPrivate(const ValueDecl *LocalVD, Address Addr)
Registers LocalVD variable as a private with Addr as the address of the corresponding private variabl...
A non-RAII class containing all the information about a bound opaque value.
static OpaqueValueMappingData bind(CodeGenFunction &CGF, const OpaqueValueExpr *ov, const LValue &lv)
static OpaqueValueMappingData bind(CodeGenFunction &CGF, const OpaqueValueExpr *ov, const RValue &rv)
static OpaqueValueMappingData bind(CodeGenFunction &CGF, const OpaqueValueExpr *ov, const Expr *e)
OpaqueValueMapping(CodeGenFunction &CGF, const OpaqueValueExpr *OV)
Build the opaque value mapping for an OpaqueValueExpr whose source expression is set to the expressio...
OpaqueValueMapping(CodeGenFunction &CGF, const AbstractConditionalOperator *op)
Build the opaque value mapping for the given conditional operator if it's the GNU ?
OpaqueValueMapping(CodeGenFunction &CGF, const OpaqueValueExpr *opaqueValue, RValue rvalue)
OpaqueValueMapping(CodeGenFunction &CGF, const OpaqueValueExpr *opaqueValue, LValue lvalue)
static ParamValue forIndirect(Address addr)
static ParamValue forDirect(llvm::Value *value)
ParentLoopDirectiveForScanRegion(CodeGenFunction &CGF, const OMPExecutableDirective &ParentLoopDirectiveForScan)
An object which temporarily prevents a value from being destroyed by aggressive peephole optimization...
RunCleanupsScope(CodeGenFunction &CGF)
Enter a new cleanup scope.
~RunCleanupsScope()
Exit this cleanup scope, emitting any accumulated cleanups.
void ForceCleanup(std::initializer_list< llvm::Value ** > ValuesToReload={})
Force the emission of cleanups now, instead of waiting until this object is destroyed.
bool requiresCleanups() const
Determine whether this scope requires any cleanups.
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
EHScopeStack::stable_iterator CurrentCleanupScopeDepth
llvm::CallInst * EmitIntrinsicCall(llvm::Intrinsic::ID ID, ArrayRef< llvm::Value * > Args, const Twine &Name="")
RValue EmitAMDGPUDevicePrintfCallExpr(const CallExpr *E)
LValue EmitMatrixSubscriptExpr(const MatrixSubscriptExpr *E)
Definition CGExpr.cpp:5430
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:2519
LValue EmitCoawaitLValue(const CoawaitExpr *E)
llvm::Value * GetVTablePtr(Address This, llvm::Type *VTableTy, const CXXRecordDecl *VTableClass, VTableAuthMode AuthMode=VTableAuthMode::Authenticate)
GetVTablePtr - Return the Value of the vtable pointer member pointed to by This.
Definition CGClass.cpp:2727
void EmitOMPParallelMaskedTaskLoopDirective(const OMPParallelMaskedTaskLoopDirective &S)
RValue EmitNVPTXDevicePrintfCallExpr(const CallExpr *E)
llvm::Value * EmitSVEPredicateCast(llvm::Value *Pred, llvm::ScalableVectorType *VTy)
Definition ARM.cpp:3427
StringRef AMDGPUAvailableVisibleMode
The mode string from the amdgpu_av attribute on the current statement, or empty if the attribute is n...
llvm::Value * EmitAVRBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition AVR.cpp:22
llvm::Value * EmitObjCConsumeObject(QualType T, llvm::Value *Ptr)
Produce the code for a CK_ARCConsumeObject.
Definition CGObjC.cpp:2171
llvm::Value * EmitFP8NeonFMLACall(unsigned IID, bool ExtendLaneArg, llvm::Type *RetTy, SmallVectorImpl< llvm::Value * > &Ops, const CallExpr *E, const char *name)
Definition ARM.cpp:480
void EmitCXXGuardedInit(const VarDecl &D, llvm::GlobalVariable *DeclPtr, bool PerformInit)
Emit code in this function to perform a guarded variable initialization.
void EmitBoundsCheckImpl(const Expr *ArrayExpr, QualType ArrayBaseType, llvm::Value *IndexVal, QualType IndexType, llvm::Value *BoundsVal, QualType BoundsType, bool Accessed)
Definition CGExpr.cpp:1303
void EmitRISCVMultiVersionResolver(llvm::Function *Resolver, ArrayRef< FMVResolverOption > Options)
void EmitOMPParallelMaskedDirective(const OMPParallelMaskedDirective &S)
void EmitOMPTaskyieldDirective(const OMPTaskyieldDirective &S)
LValue EmitLoadOfReferenceLValue(LValue RefLVal)
Definition CGExpr.cpp:3444
void EmitCXXTryStmt(const CXXTryStmt &S)
GlobalDecl CurGD
CurGD - The GlobalDecl for the current function being compiled.
void EmitBranchOnBoolExpr(const Expr *Cond, llvm::BasicBlock *TrueBlock, llvm::BasicBlock *FalseBlock, uint64_t TrueCount, Stmt::Likelihood LH=Stmt::LH_None, const Expr *ConditionalOp=nullptr, const VarDecl *ConditionalDecl=nullptr)
EmitBranchOnBoolExpr - Emit a branch on a boolean condition (e.g.
void setCurrentProfileCount(uint64_t Count)
Set the profiler's current count.
llvm::CallInst * EmitTrapCall(llvm::Intrinsic::ID IntrID, bool EnsureInsertPoint=true)
Emit a call to trap or debugtrap.
Definition CGExpr.cpp:4732
llvm::Constant * createAtExitStub(const VarDecl &VD, llvm::FunctionCallee Dtor, llvm::Constant *Addr)
Create a stub function, suitable for being passed to atexit, which passes the given address to the gi...
llvm::Value * EmitObjCAutorelease(llvm::Value *value, llvm::Type *returnType)
Autorelease the given object.
Definition CGObjC.cpp:2867
RValue EmitObjCMessageExpr(const ObjCMessageExpr *E, ReturnValueSlot Return=ReturnValueSlot())
Definition CGObjC.cpp:591
llvm::Value * emitBoolVecConversion(llvm::Value *SrcVec, unsigned NumElementsDst, const llvm::Twine &Name="")
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 ...
void EmitCXXConstructExpr(const CXXConstructExpr *E, AggValueSlot Dest)
CurrentSourceLocExprScope CurSourceLocExprScope
Source location information about the default argument or member initializer expression we're evaluat...
void EmitARCMoveWeak(Address dst, Address src)
void @objc_moveWeak(i8** dest, i8** src) Disregards the current value in dest.
Definition CGObjC.cpp:2711
llvm::BasicBlock * getFuncletEHDispatchBlock(EHScopeStack::stable_iterator scope)
void EmitAArch64MultiVersionResolver(llvm::Function *Resolver, ArrayRef< FMVResolverOption > Options)
void EmitDelegatingCXXConstructorCall(const CXXConstructorDecl *Ctor, const FunctionArgList &Args)
Definition CGClass.cpp:2525
void processInReduction(const OMPExecutableDirective &S, OMPTaskDataTy &Data, CodeGenFunction &CGF, const CapturedStmt *CS, OMPPrivateScope &Scope)
llvm::Value * EmitARCRetainAutoreleaseReturnValue(llvm::Value *value)
Do a fused retain/autorelease of the given object.
Definition CGObjC.cpp:2618
void emitDestroy(Address addr, QualType type, Destroyer *destroyer, bool useEHCleanupForArray)
emitDestroy - Immediately perform the destruction of the given object.
Definition CGDecl.cpp:2479
LValue EmitCXXConstructLValue(const CXXConstructExpr *E)
Definition CGExpr.cpp:7011
void EmitMustTailThunk(GlobalDecl GD, llvm::Value *AdjustedThisPtr, llvm::FunctionCallee Callee)
Emit a musttail call for a thunk with a potentially adjusted this pointer.
AggValueSlot::Overlap_t getOverlapForFieldInit(const FieldDecl *FD)
Determine whether a field initialization may overlap some other object.
RValue EmitCoroutineIntrinsic(const CallExpr *E, unsigned int IID)
bool isBinaryLogicalOp(const Expr *E) const
llvm::Value * BuildVector(ArrayRef< llvm::Value * > Ops)
Definition ARM.cpp:7406
void EmitDelegateCXXConstructorCall(const CXXConstructorDecl *Ctor, CXXCtorType CtorType, const FunctionArgList &Args, SourceLocation Loc)
Definition CGClass.cpp:2468
void ActivateCleanupBlock(EHScopeStack::stable_iterator Cleanup, llvm::Instruction *DominatingIP)
ActivateCleanupBlock - Activates an initially-inactive cleanup.
void emitByrefStructureInit(const AutoVarEmission &emission)
Initialize the structural components of a __block variable, i.e.
llvm::CallInst * EmitIntrinsicCall(llvm::Intrinsic::ID ID, ArrayRef< llvm::Value * > Args, llvm::Type *RetTy, const Twine &Name="")
llvm::Value * performAddrSpaceCast(llvm::Value *Src, llvm::Type *DestTy)
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...
LValue EmitConditionalOperatorLValue(const AbstractConditionalOperator *E)
Definition CGExpr.cpp:6300
llvm::Value * EmitARCReclaimReturnedObject(const Expr *e, bool allowUnsafeClaim)
Definition CGObjC.cpp:3107
std::pair< LValue, llvm::Value * > EmitARCStoreAutoreleasing(const BinaryOperator *e)
Definition CGObjC.cpp:3697
void EmitOMPTaskLoopBasedDirective(const OMPLoopDirective &S)
ComplexPairTy EmitComplexPrePostIncDec(const UnaryOperator *E, LValue LV, bool isInc, bool isPre)
Definition CGExpr.cpp:1422
void SetDivFPAccuracy(llvm::Value *Val)
Set the minimum required accuracy of the given sqrt operation based on CodeGenOpts.
Definition CGExpr.cpp:7422
llvm::Value * EmitARCUnsafeUnretainedScalarExpr(const Expr *expr)
EmitARCUnsafeUnretainedScalarExpr - Semantically equivalent to immediately releasing the resut of Emi...
Definition CGObjC.cpp:3636
llvm::Value * EmitObjCSelectorExpr(const ObjCSelectorExpr *E)
Emit a selector.
Definition CGObjC.cpp:275
llvm::Value * EmitScalarOrConstFoldImmArg(unsigned ICEArguments, unsigned Idx, const CallExpr *E)
void BuildBlockRelease(llvm::Value *DeclPtr, BlockFieldFlags flags, bool CanThrow)
llvm::Function * createTLSAtExitStub(const VarDecl &VD, llvm::FunctionCallee Dtor, llvm::Constant *Addr, llvm::FunctionCallee &AtExit)
Create a stub function, suitable for being passed to __pt_atexit_np, which passes the given address t...
SanitizerSet SanOpts
Sanitizers enabled for this function.
CodeGenUtils::EvaluationOrder EvaluationOrder
void emitOMPSimpleStore(LValue LVal, RValue RVal, QualType RValTy, SourceLocation Loc)
static void EmitOMPTargetParallelDeviceFunction(CodeGenModule &CGM, StringRef ParentName, const OMPTargetParallelDirective &S)
void EmitAsanPrologueOrEpilogue(bool Prologue)
Definition CGClass.cpp:718
CounterForIncrement
Used to specify which counter in a pair shall be incremented.
void callCStructMoveConstructor(LValue Dst, LValue Src)
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:2367
void pushStackRestore(CleanupKind kind, Address SPMem)
Definition CGDecl.cpp:2406
LValue EmitInitListLValue(const InitListExpr *E)
Definition CGExpr.cpp:6182
bool isUnderlyingBasePointerConstantNull(const Expr *E)
Check whether the underlying base pointer is a constant null.
Definition CGExpr.cpp:5754
llvm::DenseMap< const VarDecl *, llvm::Value * > NRVOFlags
A mapping from NRVO variables to the flags used to indicate when the NRVO has been applied to this va...
void EmitNullInitialization(Address DestPtr, QualType Ty)
EmitNullInitialization - Generate code to set a value of the given type to null, If the type contains...
bool IsOutlinedSEHHelper
True if the current function is an outlined SEH helper.
void EmitARCInitWeak(Address addr, llvm::Value *value)
i8* @objc_initWeak(i8** addr, i8* value) Returns value.
Definition CGObjC.cpp:2682
void EmitOMPCanonicalLoop(const OMPCanonicalLoop *S)
Emit an OMPCanonicalLoop using the OpenMPIRBuilder.
llvm::Value * getExceptionFromSlot()
Returns the contents of the function's exception object and selector slots.
void checkTargetFeatures(const CallExpr *E, const FunctionDecl *TargetDecl)
LValue EmitArraySubscriptExpr(const ArraySubscriptExpr *E, bool Accessed=false)
Definition CGExpr.cpp:5161
llvm::Value * EmitSVEStructLoad(const SVETypeFlags &TypeFlags, SmallVectorImpl< llvm::Value * > &Ops, unsigned IntID)
Definition ARM.cpp:3602
static bool ContainsLabel(const Stmt *S, bool IgnoreCaseStmts=false)
ContainsLabel - Return true if the statement contains a label in it.
llvm::Value * EmitSVEMaskedLoad(const CallExpr *, llvm::Type *ReturnTy, SmallVectorImpl< llvm::Value * > &Ops, unsigned BuiltinID, bool IsZExtReturn)
Definition ARM.cpp:3711
void EmitPPCAIXMultiVersionResolver(llvm::Function *Resolver, ArrayRef< FMVResolverOption > Options)
define internal ptr @foo.resolver() { entry: is_version_1 = __builtin_cpu_supports(version_1) br i1 %...
bool ShouldSkipSanitizerInstrumentation()
ShouldSkipSanitizerInstrumentation - Return true if the current function should not be instrumented w...
llvm::Value * EmitPPCBuiltinCpu(unsigned BuiltinID, llvm::Type *ReturnType, StringRef CPUStr)
Definition PPC.cpp:73
llvm::Value * EmitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E)
Definition CGObjC.cpp:269
void EmitCXXForRangeStmt(const CXXForRangeStmt &S, ArrayRef< const Attr * > Attrs={})
Definition CGStmt.cpp:1401
void EmitOMPGenericLoopDirective(const OMPGenericLoopDirective &S)
SmallVector< Address, 1 > SEHCodeSlotStack
A stack of exception code slots.
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...
llvm::Value * EmitFP8NeonCall(unsigned IID, ArrayRef< llvm::Type * > Tys, SmallVectorImpl< llvm::Value * > &O, const CallExpr *E, const char *name)
Definition ARM.cpp:455
LValue EmitObjCMessageExprLValue(const ObjCMessageExpr *E)
Definition CGExpr.cpp:7043
llvm::Value * GetCountedByFieldExprGEP(const Expr *Base, const FieldDecl *FD, const FieldDecl *CountDecl)
Definition CGExpr.cpp:1223
llvm::BlockAddress * GetAddrOfLabel(const LabelDecl *L)
void VolatilizeTryBlocks(llvm::BasicBlock *BB, llvm::SmallPtrSet< llvm::BasicBlock *, 10 > &V)
LValue MakeAddrLValue(llvm::Value *V, QualType T, CharUnits Alignment, AlignmentSource Source=AlignmentSource::Type)
llvm::Value * EmitRISCVCpuSupports(const CallExpr *E)
Definition RISCV.cpp:976
void EmitOMPScanDirective(const OMPScanDirective &S)
void EmitComplexExprIntoLValue(const Expr *E, LValue dest, bool isInit)
EmitComplexExprIntoLValue - Emit the given expression of complex type and place its result into the s...
llvm::BasicBlock * getInvokeDestImpl()
llvm::Value * EmitRISCVCpuInit()
Definition RISCV.cpp:966
const CastExpr * CurCast
If a cast expression is being visited, this holds the current cast's expression.
static bool hasScalarEvaluationKind(QualType T)
llvm::Type * ConvertType(QualType T)
bool isCleanupPadScope() const
Returns true while emitting a cleanuppad.
llvm::Value * EmitNeonSplat(llvm::Value *V, llvm::Constant *Idx)
void EmitOpenACCExitDataConstruct(const OpenACCExitDataConstruct &S)
void GenerateCode(GlobalDecl GD, llvm::Function *Fn, const CGFunctionInfo &FnInfo)
Address EmitCXXUuidofExpr(const CXXUuidofExpr *E)
Definition CGExpr.cpp:7024
AwaitSuspendWrapperInfo CurAwaitSuspendWrapper
void EmitFakeUse(Address Addr)
Definition CGDecl.cpp:1389
llvm::function_ref< std::pair< llvm::Value *, llvm::Value * >(CodeGenFunction &, const OMPExecutableDirective &S, Address LB, Address UB)> CodeGenDispatchBoundsTy
void EmitSanitizerStatReport(llvm::SanitizerStatKind SSK)
LValue InitCapturedStruct(const CapturedStmt &S)
Definition CGStmt.cpp:3435
void EmitOMPFlattenDirective(const OMPFlattenDirective &S)
void addInstToNewSourceAtom(llvm::Instruction *KeyInstruction, llvm::Value *Backup)
Add KeyInstruction and an optional Backup instruction to a new atom group (See ApplyAtomGroup for mor...
CGCapturedStmtInfo * CapturedStmtInfo
void EmitOMPDistributeDirective(const OMPDistributeDirective &S)
BuiltinCheckKind
Specifies which type of sanitizer check to apply when handling a particular builtin.
Address recoverAddrOfEscapedLocal(CodeGenFunction &ParentCGF, Address ParentVar, llvm::Value *ParentFP)
Recovers the address of a local in a parent function.
RValue EmitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *E)
llvm::Value * EmitSVEGatherPrefetch(const SVETypeFlags &TypeFlags, SmallVectorImpl< llvm::Value * > &Ops, unsigned IntID)
Definition ARM.cpp:3566
llvm::Value * EmitObjCProtocolExpr(const ObjCProtocolExpr *E)
Definition CGObjC.cpp:283
void EmitOMPParallelForDirective(const OMPParallelForDirective &S)
llvm::CallBase * EmitCallOrInvoke(llvm::FunctionCallee Callee, ArrayRef< llvm::Value * > Args, const Twine &Name="")
Emits a call or invoke instruction to the given function, depending on the current state of the EH st...
Definition CGCall.cpp:5557
llvm::Value * EmitSystemZBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition SystemZ.cpp:86
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:2352
void EmitNoreturnRuntimeCallOrInvoke(llvm::FunctionCallee callee, ArrayRef< llvm::Value * > args)
Emits a call or invoke to the given noreturn runtime function.
Definition CGCall.cpp:5520
llvm::CallInst * EmitRuntimeCall(llvm::FunctionCallee callee, ArrayRef< llvm::Value * > args, const Twine &name="", bool IsConvergent=false)
llvm::CallBase * EmitRuntimeCallOrInvoke(llvm::FunctionCallee callee, ArrayRef< llvm::Value * > args, const Twine &name="")
Emits a call or invoke instruction to the given runtime function.
Definition CGCall.cpp:5547
RValue EmitCXXMemberOrOperatorMemberCallExpr(const CallExpr *CE, const CXXMethodDecl *MD, ReturnValueSlot ReturnValue, bool HasQualifier, NestedNameSpecifier Qualifier, bool IsArrow, const Expr *Base, llvm::CallBase **CallOrInvoke)
PeepholeProtection protectFromPeepholes(RValue rvalue)
protectFromPeepholes - Protect a value that we're intending to store to the side, but which will prob...
ComplexPairTy EmitLoadOfComplex(LValue src, SourceLocation loc)
EmitLoadOfComplex - Load a complex number from the specified l-value.
void EmitOMPMasterDirective(const OMPMasterDirective &S)
llvm::Value * EmitSEHAbnormalTermination()
void EmitOMPParallelMasterTaskLoopSimdDirective(const OMPParallelMasterTaskLoopSimdDirective &S)
RValue emitStdcFirstBit(const CallExpr *E, llvm::Intrinsic::ID IntID, bool InvertArg)
llvm::Value * EmitARCAutoreleaseReturnValue(llvm::Value *value)
Autorelease the given object.
Definition CGObjC.cpp:2608
llvm::Value * EmitARCRetain(QualType type, llvm::Value *value)
Produce the code to do a retain.
Definition CGObjC.cpp:2347
llvm::Value * EmitPointerAuthQualify(PointerAuthQualifier Qualifier, llvm::Value *Pointer, QualType ValueType, Address StorageAddress, bool IsKnownNonNull)
void EmitVTablePtrCheckForCall(const CXXRecordDecl *RD, llvm::Value *VTable, CFITypeCheckKind TCK, SourceLocation Loc)
EmitVTablePtrCheckForCall - Virtual method MD is being called via VTable.
Definition CGClass.cpp:2854
void EmitLambdaStaticInvokeBody(const CXXMethodDecl *MD)
Definition CGClass.cpp:3104
CleanupKind getARCCleanupKind()
Retrieves the default cleanup kind for an ARC cleanup.
llvm::Value * EmitARCAutorelease(llvm::Value *value)
Autorelease the given object.
Definition CGObjC.cpp:2599
void EmitOMPSimdInit(const OMPLoopDirective &D)
Helpers for the OpenMP loop directives.
llvm::Value * EmitARCRetainAutoreleaseScalarExpr(const Expr *expr)
Definition CGObjC.cpp:3526
llvm::Value * EmitSMEReadWrite(const SVETypeFlags &TypeFlags, llvm::SmallVectorImpl< llvm::Value * > &Ops, unsigned IntID)
Definition ARM.cpp:3857
llvm::Type * SVEBuiltinMemEltTy(const SVETypeFlags &TypeFlags)
SVEBuiltinMemEltTy - Returns the memory element type for this memory access builtin.
Definition ARM.cpp:3293
const OMPExecutableDirective * OMPParentLoopDirectiveForScan
Parent loop-based directive for scan directive.
llvm::Value * EmitSVEScatterStore(const SVETypeFlags &TypeFlags, llvm::SmallVectorImpl< llvm::Value * > &Ops, unsigned IntID)
Definition ARM.cpp:3520
void EmitOpenACCInitConstruct(const OpenACCInitConstruct &S)
bool CurFuncIsThunk
In C++, whether we are code generating a thunk.
void EmitAtomicInit(Expr *E, LValue lvalue)
void EmitLambdaDelegatingInvokeBody(const CXXMethodDecl *MD, CallArgList &CallArgs)
Definition CGClass.cpp:3126
void EmitAggFinalDestCopy(QualType Type, AggValueSlot Dest, const LValue &Src, ExprValueKind SrcKind)
EmitAggFinalDestCopy - Emit copy of the specified aggregate into destination address.
void AddAMDGPUAvailableVisibleMMRA(llvm::Instruction *Inst)
Attach the AMDGPU availability/visibility MMRA to Inst when the amdgpu_av attribute is active on the ...
Definition AMDGPU.cpp:491
void EmitARCDestroyWeak(Address addr)
void @objc_destroyWeak(i8** addr) Essentially objc_storeWeak(addr, nil).
Definition CGObjC.cpp:2700
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:283
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 EmitOMPFlushDirective(const OMPFlushDirective &S)
void EmitStoreThroughExtVectorComponentLValue(RValue Src, LValue Dst)
Definition CGExpr.cpp:3141
llvm::Value * EmitVAStartEnd(llvm::Value *ArgValue, bool IsStart)
Emits a call to an LLVM variable-argument intrinsic, either llvm.va_start or llvm....
RValue EmitBlockCallExpr(const CallExpr *E, ReturnValueSlot ReturnValue, llvm::CallBase **CallOrInvoke)
static void EmitOMPTargetDeviceFunction(CodeGenModule &CGM, StringRef ParentName, const OMPTargetDirective &S)
Emit device code for the target directive.
llvm::Value * EmitSVEMaskedStore(const CallExpr *, SmallVectorImpl< llvm::Value * > &Ops, unsigned BuiltinID)
Definition ARM.cpp:3768
LValue EmitObjCEncodeExprLValue(const ObjCEncodeExpr *E)
Definition CGExpr.cpp:4009
bool EmitOMPFirstprivateClause(const OMPExecutableDirective &D, OMPPrivateScope &PrivateScope)
void EmitObjCRelease(llvm::Value *value, ARCPreciseLifetime_t precise)
Release the given object.
Definition CGObjC.cpp:2886
void EmitOMPTaskgroupDirective(const OMPTaskgroupDirective &S)
JumpDest getJumpDestForLabel(const LabelDecl *S)
getBasicBlockForLabel - Return the LLVM basicblock that the specified label maps to.
Definition CGStmt.cpp:712
void EmitCoreturnStmt(const CoreturnStmt &S)
void EmitOMPTargetTeamsDistributeParallelForSimdDirective(const OMPTargetTeamsDistributeParallelForSimdDirective &S)
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:2679
void EmitCXXThrowExpr(const CXXThrowExpr *E, bool KeepInsertionPoint=true)
SmallVector< llvm::ConvergenceControlInst *, 4 > ConvergenceTokenStack
Stack to track the controlled convergence tokens.
RValue emitStdcBitWidthMinus(const CallExpr *E, llvm::Intrinsic::ID IntID, bool IsPop)
static void EmitOMPTargetTeamsDeviceFunction(CodeGenModule &CGM, StringRef ParentName, const OMPTargetTeamsDirective &S)
Emit device code for the target teams directive.
llvm::Value * EmitAMDGPUBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition AMDGPU.cpp:573
LValue EmitCompoundLiteralLValue(const CompoundLiteralExpr *E)
Definition CGExpr.cpp:6150
bool isSEHTryScope() const
Returns true inside SEH __try blocks.
void registerGlobalDtorWithAtExit(const VarDecl &D, llvm::FunctionCallee fn, llvm::Constant *addr)
Call atexit() with a function that passes the given argument to the given function.
llvm::Value * EmitObjCAllocInit(llvm::Value *value, llvm::Type *resultType)
Definition CGObjC.cpp:2824
void unprotectFromPeepholes(PeepholeProtection protection)
void EmitOMPReductionClauseInit(const OMPExecutableDirective &D, OMPPrivateScope &PrivateScope, bool ForInscan=false)
Emit initial code for reduction variables.
void EmitObjCAtThrowStmt(const ObjCAtThrowStmt &S)
Definition CGObjC.cpp:2148
void EmitOMPDistributeSimdDirective(const OMPDistributeSimdDirective &S)
void EmitSynthesizedCXXCopyCtor(Address Dest, Address Src, const Expr *Exp)
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:7374
LValue EmitObjCIsaExpr(const ObjCIsaExpr *E)
void EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst, llvm::Value **Result=nullptr)
EmitStoreThroughBitfieldLValue - Store Src into Dst with same constraints as EmitStoreThroughLValue.
Definition CGExpr.cpp:3062
llvm::Value * EmitAArch64SMEBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition ARM.cpp:4410
void EmitAutoVarDecl(const VarDecl &D)
EmitAutoVarDecl - Emit an auto variable declaration.
Definition CGDecl.cpp:1360
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:4169
void EmitObjCAutoreleasePoolCleanup(llvm::Value *Ptr)
Definition CGObjC.cpp:2935
LValue EmitCXXUuidofLValue(const CXXUuidofExpr *E)
Definition CGExpr.cpp:7029
bool hasVolatileMember(QualType T)
hasVolatileMember - returns true if aggregate type has a volatile member.
void enterByrefCleanup(CleanupKind Kind, Address Addr, BlockFieldFlags Flags, bool LoadBlockVarAddr, bool CanThrow)
Enter a cleanup to destroy a __block variable.
void EmitAutoVarInit(const AutoVarEmission &emission)
Definition CGDecl.cpp:2012
llvm::Value * EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV, bool isInc, bool isPre)
void SetSqrtFPAccuracy(llvm::Value *Val)
Set the minimum required accuracy of the given sqrt operation based on CodeGenOpts.
Definition CGExpr.cpp:7400
static void EmitOMPTargetTeamsDistributeDeviceFunction(CodeGenModule &CGM, StringRef ParentName, const OMPTargetTeamsDistributeDirective &S)
Emit device code for the target teams distribute directive.
RValue EmitSimpleCallExpr(const CallExpr *E, ReturnValueSlot ReturnValue, llvm::CallBase **CallOrInvoke=nullptr)
Emit a CallExpr without considering whether it might be a subclass.
Definition CGExpr.cpp:6694
llvm::SmallVector< BypassingForwardJump, 4 > BypassingForwardJumps
llvm::SmallVector< DeferredDeactivateCleanup > DeferredDeactivationCleanupStack
RValue EmitVAArg(VAArgExpr *VE, Address &VAListAddr, AggValueSlot Slot=AggValueSlot::ignored())
Generate code to get an argument from the passed in pointer and update it accordingly.
Definition CGCall.cpp:6907
static bool isNullPointerAllowed(TypeCheckKind TCK)
Determine whether the pointer type check TCK permits null pointers.
Definition CGExpr.cpp:742
void EmitForwardingCallToLambda(const CXXMethodDecl *LambdaCallOperator, CallArgList &CallArgs, const CGFunctionInfo *CallOpFnInfo=nullptr, llvm::Constant *CallOpFn=nullptr)
Definition CGClass.cpp:3031
void EmitReturnValueCheck(llvm::Value *RV)
Emit a test that checks if the return value RV is nonnull.
Definition CGCall.cpp:4614
llvm::Value * getAsNaturalPointerTo(Address Addr, QualType PointeeType)
bool EmitSimpleStmt(const Stmt *S, ArrayRef< const Attr * > Attrs)
EmitSimpleStmt - Try to emit a "simple" statement which does not necessarily require an insertion poi...
Definition CGStmt.cpp:525
RValue emitBuiltinOSLogFormat(const CallExpr &E)
Emit IR for __builtin_os_log_format.
llvm::Function * GenerateOpenMPCapturedStmtFunctionAggregate(const CapturedStmt &S, const OMPExecutableDirective &D)
llvm::Value * emitPointerAuthResignCall(llvm::Value *Pointer, const CGPointerAuthInfo &CurInfo, const CGPointerAuthInfo &NewInfo)
void EmitOMPTaskwaitDirective(const OMPTaskwaitDirective &S)
RValue EmitPseudoObjectRValue(const PseudoObjectExpr *e, AggValueSlot slot=AggValueSlot::ignored())
Definition CGExpr.cpp:7533
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:4701
llvm::BasicBlock * createBasicBlock(const Twine &name="", llvm::Function *parent=nullptr, llvm::BasicBlock *before=nullptr)
createBasicBlock - Create an LLVM basic block.
void FinishObjCDirectPreconditionThunk()
Finish an Objective-C direct method thunk.
void EmitOMPTargetParallelForDirective(const OMPTargetParallelForDirective &S)
void maybeUpdateMCDCTestVectorBitmap(const Expr *E)
Increment the profiler's counter for the given expression by StepV.
void addInstToCurrentSourceAtom(llvm::Instruction *KeyInstruction, llvm::Value *Backup)
See CGDebugInfo::addInstToCurrentSourceAtom.
AggValueSlot::Overlap_t getOverlapForBaseInit(const CXXRecordDecl *RD, const CXXRecordDecl *BaseRD, bool IsVirtual)
Determine whether a base class initialization may overlap some other object.
void EmitCXXDeleteExpr(const CXXDeleteExpr *E)
llvm::Value * EmitObjCArrayLiteral(const ObjCArrayLiteral *E)
Definition CGObjC.cpp:265
llvm::Function * generateBuiltinOSLogHelperFunction(const analyze_os_log::OSLogBufferLayout &Layout, CharUnits BufferAlignment)
llvm::Value * EmitPromotedScalarExpr(const Expr *E, QualType PromotionType)
const LangOptions & getLangOpts() const
void addInstToSpecificSourceAtom(llvm::Instruction *KeyInstruction, llvm::Value *Backup, uint64_t Atom)
See CGDebugInfo::addInstToSpecificSourceAtom.
void EmitCfiCheckFail()
Emit a cross-DSO CFI failure handling function.
Definition CGExpr.cpp:4537
RValue EmitReferenceBindingToExpr(const Expr *E)
Emits a reference binding to the passed in expression.
Definition CGExpr.cpp:705
llvm::Value * EmitARCRetainAutorelease(QualType type, llvm::Value *value)
Do a fused retain/autorelease of the given object.
Definition CGObjC.cpp:2630
llvm::Value * EmitARCStoreStrong(LValue lvalue, llvm::Value *value, bool resultIgnored)
Store into a strong object.
Definition CGObjC.cpp:2564
llvm::Value * EmitARCRetainAutoreleasedReturnValue(llvm::Value *value)
Retain the given object which is the result of a function call.
Definition CGObjC.cpp:2482
bool isPointerKnownNonNull(const Expr *E)
void StartObjCMethod(const ObjCMethodDecl *MD, const ObjCContainerDecl *CD)
StartObjCMethod - Begin emission of an ObjCMethod.
Definition CGObjC.cpp:770
LValue MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T, KnownNonNull_t IsKnownNonNull=NotKnownNonNull)
AutoVarEmission EmitAutoVarAlloca(const VarDecl &var)
EmitAutoVarAlloca - Emit the alloca and debug information for a local variable.
Definition CGDecl.cpp:1491
LValue EmitPointerToDataMemberBinaryExpr(const BinaryOperator *E)
Definition CGExpr.cpp:7351
llvm::Value * EmitARCUnsafeClaimAutoreleasedReturnValue(llvm::Value *value)
Claim a possibly-autoreleased return value at +0.
Definition CGObjC.cpp:2494
llvm::Value * EmitObjCMRRAutoreleasePoolPush()
Produce the code to do an MRR version objc_autoreleasepool_push.
Definition CGObjC.cpp:2783
void EmitVarAnnotations(const VarDecl *D, llvm::Value *V)
Emit local annotations for the local variable V, declared by D.
llvm::BasicBlock * EHResumeBlock
EHResumeBlock - Unified block containing a call to llvm.eh.resume.
void EmitOpenACCShutdownConstruct(const OpenACCShutdownConstruct &S)
LValue EmitLValueForIvar(QualType ObjectTy, llvm::Value *Base, const ObjCIvarDecl *Ivar, unsigned CVRQualifiers)
Definition CGExpr.cpp:7077
void EmitAtomicUpdate(LValue LVal, llvm::AtomicOrdering AO, const llvm::function_ref< RValue(RValue)> &UpdateOp, bool IsVolatile)
bool InNoConvergentAttributedStmt
True if the current statement has noconvergent attribute.
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:670
void GenerateObjCCtorDtorMethod(ObjCImplementationDecl *IMP, ObjCMethodDecl *MD, bool ctor)
Definition CGObjC.cpp:1771
void EmitTypeCheck(TypeCheckKind TCK, SourceLocation Loc, Address Addr, QualType Type, CharUnits Alignment=CharUnits::Zero(), SanitizerSet SkippedChecks=SanitizerSet(), llvm::Value *ArraySize=nullptr)
Address GetAddressOfDerivedClass(Address Value, const CXXRecordDecl *Derived, CastExpr::path_const_iterator PathBegin, CastExpr::path_const_iterator PathEnd, bool NullCheckValue)
Definition CGClass.cpp:390
llvm::Value * EmitObjCAllocWithZone(llvm::Value *value, llvm::Type *returnType)
Allocate the given objc object.
Definition CGObjC.cpp:2817
void EmitIgnoredConditionalOperator(const AbstractConditionalOperator *E)
Definition CGExpr.cpp:6282
void GetAArch64SVEProcessedOperands(unsigned BuiltinID, const CallExpr *E, SmallVectorImpl< llvm::Value * > &Ops, SVETypeFlags TypeFlags)
Definition ARM.cpp:3996
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:2915
llvm::Value * EmitSVEGatherLoad(const SVETypeFlags &TypeFlags, llvm::SmallVectorImpl< llvm::Value * > &Ops, unsigned IntID)
Definition ARM.cpp:3478
llvm::Function * GenerateBlockFunction(GlobalDecl GD, const CGBlockInfo &Info, const DeclMapTy &ldm, bool IsLambdaConversionToBlock, bool BuildGlobalBlock)
void EmitCountedByBoundsChecking(const Expr *ArrayExpr, QualType ArrayType, Address ArrayInst, QualType IndexType, llvm::Value *IndexVal, bool Accessed, bool FlexibleArray)
EmitCountedByBoundsChecking - If the array being accessed has a "counted_by" attribute,...
Definition CGExpr.cpp:5087
Address EmitFieldAnnotations(const FieldDecl *D, Address V)
Emit field annotations for the given field & value.
bool IsInPreserveFieldInfo
True if CodeGen currently emits the argument of __builtin_preserve_field_info.
llvm::Function * LookupNeonLLVMIntrinsic(unsigned IntrinsicID, unsigned Modifier, llvm::Type *ArgTy, const CallExpr *E)
Definition ARM.cpp:1020
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:2362
void EmitScalarInit(const Expr *init, const ValueDecl *D, LValue lvalue, bool capturedByInit)
Definition CGDecl.cpp:799
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:772
void EmitConstructorBody(FunctionArgList &Args)
EmitConstructorBody - Emits the body of the current constructor.
Definition CGClass.cpp:781
const CodeGen::CGBlockInfo * BlockInfo
void EmitKCFIOperandBundle(const CGCallee &Callee, SmallVectorImpl< llvm::OperandBundleDef > &Bundles)
llvm::Value * EmitPointerAuthUnqualify(PointerAuthQualifier Qualifier, llvm::Value *Pointer, QualType PointerType, Address StorageAddress, bool IsKnownNonNull)
void EmitAggregateCopyCtor(LValue Dest, LValue Src, AggValueSlot::Overlap_t MayOverlap)
void EmitDeclRefExprDbgValue(const DeclRefExpr *E, const APValue &Init)
static void EmitOMPTargetSimdDeviceFunction(CodeGenModule &CGM, StringRef ParentName, const OMPLoopDirective &S)
Emit device code for the target simd and target loop directives.
Address makeNaturalAddressForPointer(llvm::Value *Ptr, QualType T, CharUnits Alignment=CharUnits::Zero(), bool ForPointeeType=false, LValueBaseInfo *BaseInfo=nullptr, TBAAAccessInfo *TBAAInfo=nullptr, KnownNonNull_t IsKnownNonNull=NotKnownNonNull)
Construct an address with the natural alignment of T.
void EmitOpenACCWaitConstruct(const OpenACCWaitConstruct &S)
llvm::AllocaInst * EHSelectorSlot
The selector slot.
Address EmitLoadOfPointer(Address Ptr, const PointerType *PtrTy, LValueBaseInfo *BaseInfo=nullptr, TBAAAccessInfo *TBAAInfo=nullptr)
Load a pointer with type PtrTy stored at address Ptr.
Definition CGExpr.cpp:3453
LValue MakeNaturalAlignPointeeRawAddrLValue(llvm::Value *V, QualType T)
Same as MakeNaturalAlignPointeeAddrLValue except that the pointer is known to be unsigned.
llvm::BasicBlock * EmitLandingPad()
Emits a landing pad for the current EH stack.
void EmitLambdaInAllocaImplFn(const CXXMethodDecl *CallOp, const CGFunctionInfo **ImplFnInfo, llvm::Function **ImplFn)
Definition CGClass.cpp:3180
llvm::Constant * GenerateCopyHelperFunction(const CGBlockInfo &blockInfo)
Generate the copy-helper function for a block closure object: static void block_copy_helper(block_t *...
void EmitCXXAggrConstructorCall(const CXXConstructorDecl *D, const ArrayType *ArrayTy, Address ArrayPtr, const CXXConstructExpr *E, bool NewPointerIsChecked, bool ZeroInitialization=false)
EmitCXXAggrConstructorCall - Emit a loop to call a particular constructor for each of several members...
Definition CGClass.cpp:2034
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.
CurrentSourceLocExprScope::SourceLocExprScopeGuard SourceLocExprScopeGuard
void EmitBlockAfterUses(llvm::BasicBlock *BB)
EmitBlockAfterUses - Emit the given block somewhere hopefully near its uses, and leave the insertion ...
Definition CGStmt.cpp:695
RValue EmitLoadOfGlobalRegLValue(LValue LV)
Load of global named registers are always calls to intrinsics.
Definition CGExpr.cpp:2777
VPtrsVector getVTablePointers(const CXXRecordDecl *VTableClass)
Definition CGClass.cpp:2647
void EmitVTablePtrCheckForCast(QualType T, Address Derived, bool MayBeNull, CFITypeCheckKind TCK, SourceLocation Loc)
Derived is the presumed address of an object of type T after a cast.
Definition CGClass.cpp:2868
TypeCheckKind
Situations in which we might emit a check for the suitability of a pointer or glvalue.
@ TCK_DowncastPointer
Checking the operand of a static_cast to a derived pointer type.
@ TCK_DowncastReference
Checking the operand of a static_cast to a derived reference type.
@ TCK_MemberAccess
Checking the object expression in a non-static data member access.
@ TCK_ConstructorCall
Checking the 'this' pointer for a constructor call.
@ TCK_Store
Checking the destination of a store. Must be suitably sized and aligned.
@ TCK_NonnullAssign
Checking the value assigned to a _Nonnull pointer. Must not be null.
@ TCK_UpcastToVirtualBase
Checking the operand of a cast to a virtual base object.
@ TCK_MemberCall
Checking the 'this' pointer for a call to a non-static member function.
@ TCK_DynamicOperation
Checking the operand of a dynamic_cast or a typeid expression.
@ TCK_ReferenceBinding
Checking the bound value in a reference binding.
@ TCK_Load
Checking the operand of a load. Must be suitably sized and aligned.
@ TCK_Upcast
Checking the operand of a cast to a base object.
llvm::Type * getEltType(const SVETypeFlags &TypeFlags)
Definition ARM.cpp:3309
void SimplifyForwardingBlocks(llvm::BasicBlock *BB)
SimplifyForwardingBlocks - If the given basic block is only a branch to another basic block,...
Definition CGStmt.cpp:636
static std::string getNonTrivialDestructorStr(QualType QT, CharUnits Alignment, bool IsVolatile, ASTContext &Ctx)
llvm::Value * EmitCXXNewExpr(const CXXNewExpr *E)
llvm::Value * EmitObjCThrowOperand(const Expr *expr)
Definition CGObjC.cpp:3560
void EmitOMPSplitDirective(const OMPSplitDirective &S)
DeclMapTy::iterator localDeclMapEnd()
void EmitCXXDestructorCall(const CXXDestructorDecl *D, CXXDtorType Type, bool ForVirtualBase, bool Delegating, Address This, QualType ThisTy)
Definition CGClass.cpp:2550
LValue MakeAddrLValue(Address Addr, QualType T, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
const BlockByrefInfo & getBlockByrefInfo(const VarDecl *var)
BuildByrefInfo - This routine changes a __block variable declared as T x into:
void EmitBranchThroughCleanup(JumpDest Dest)
EmitBranchThroughCleanup - Emit a branch from the current insert block through the normal cleanup han...
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 * EmitCommonNeonBuiltinExpr(unsigned BuiltinID, unsigned LLVMIntrinsic, unsigned AltLLVMIntrinsic, const char *NameHint, unsigned Modifier, const CallExpr *E, SmallVectorImpl< llvm::Value * > &Ops, Address PtrOp0, Address PtrOp1, llvm::Triple::ArchType Arch)
Definition ARM.cpp:1128
llvm::Value * EmitRISCVBuiltinExpr(unsigned BuiltinID, const CallExpr *E, ReturnValueSlot ReturnValue)
Definition RISCV.cpp:1079
LValue EmitBinaryOperatorLValue(const BinaryOperator *E)
Definition CGExpr.cpp:6854
bool InNoMergeAttributedStmt
True if the current statement has nomerge attribute.
void StartObjCDirectPreconditionThunk(const ObjCMethodDecl *OMD, llvm::Function *Fn, const CGFunctionInfo &FI)
Start an Objective-C direct method thunk.
llvm::Value * EmitNeonSplat(llvm::Value *V, llvm::Constant *Idx, const llvm::ElementCount &Count)
LValue EmitComplexCompoundAssignmentLValue(const CompoundAssignOperator *E)
void pushIrregularPartialArrayCleanup(llvm::Value *arrayBegin, Address arrayEndPointer, QualType elementType, CharUnits elementAlignment, Destroyer *destroyer)
pushIrregularPartialArrayCleanup - Push a NormalAndEHCleanup to destroy already-constructed elements ...
Definition CGDecl.cpp:2663
llvm::Value * EmitCheckedArgForBuiltin(const Expr *E, BuiltinCheckKind Kind)
Emits an argument for a call to a builtin.
void EmitOMPLoopBody(const OMPLoopDirective &D, JumpDest LoopExit)
Helper for the OpenMP loop directives.
Address EmitCheckedInBoundsGEP(Address Addr, ArrayRef< llvm::Value * > IdxList, llvm::Type *elementType, bool SignedIndices, bool IsSubtraction, SourceLocation Loc, CharUnits Align, const Twine &Name="")
void EmitOMPScopeDirective(const OMPScopeDirective &S)
const Decl * CurCodeDecl
CurCodeDecl - This is the inner-most code context, which includes blocks.
LValue MakeAddrLValueWithoutTBAA(Address Addr, QualType T, AlignmentSource Source=AlignmentSource::Type)
bool hasSkipCounter(const Stmt *S) const
llvm::BasicBlock * getUnreachableBlock()
Destroyer * getDestroyer(QualType::DestructionKind destructionKind)
Definition CGDecl.cpp:2335
llvm::AssertingVH< llvm::Instruction > AllocaInsertPt
AllocaInsertPoint - This is an instruction in the entry block before which we prefer to insert alloca...
void EmitAggregateAssign(LValue Dest, LValue Src, QualType EltTy)
Emit an aggregate assignment.
void EmitARCRelease(llvm::Value *value, ARCPreciseLifetime_t precise)
Release the given object.
Definition CGObjC.cpp:2500
void maybeAttachRangeForLoad(llvm::LoadInst *Load, QualType Ty, SourceLocation Loc)
Definition CGExpr.cpp:2119
void EmitCXXGlobalVarDeclInit(const VarDecl &D, llvm::GlobalVariable *GV, bool PerformInit)
EmitCXXGlobalVarDeclInit - Create the initializer for a C++ variable with global storage.
void EmitBitfieldConversionCheck(llvm::Value *Src, QualType SrcType, llvm::Value *Dst, QualType DstType, const CGBitFieldInfo &Info, SourceLocation Loc)
Emit a check that an [implicit] conversion of a bitfield.
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:2581
llvm::SmallVector< const JumpDest *, 2 > SEHTryEpilogueStack
void pushCallObjectDeleteCleanup(const FunctionDecl *OperatorDelete, llvm::Value *CompletePtr, QualType ElementType)
void EmitFunctionBody(const Stmt *Body)
JumpDest ReturnBlock
ReturnBlock - Unified return block.
void EmitOMPTargetTeamsDistributeSimdDirective(const OMPTargetTeamsDistributeSimdDirective &S)
RValue EmitCXXMemberOrOperatorCall(const CXXMethodDecl *Method, const CGCallee &Callee, ReturnValueSlot ReturnValue, llvm::Value *This, llvm::Value *ImplicitParam, QualType ImplicitParamTy, const CallExpr *E, CallArgList *RtlArgs, llvm::CallBase **CallOrInvoke)
Definition CGExprCXX.cpp:85
DominatingValue< T >::saved_type saveValueInCond(T value)
void EmitSEHExceptionCodeSave(CodeGenFunction &ParentCGF, llvm::Value *ParentFP, llvm::Value *EntryEBP)
const llvm::function_ref< void(CodeGenFunction &, llvm::Function *, const OMPTaskDataTy &)> TaskGenTy
std::pair< LValue, llvm::Value * > EmitARCStoreUnsafeUnretained(const BinaryOperator *e, bool ignored)
Definition CGObjC.cpp:3647
llvm::DebugLoc SourceLocToDebugLoc(SourceLocation Location)
Converts Location to a DebugLoc, if debug information is enabled.
static bool cxxDestructorCanThrow(QualType T)
Check if T is a C++ class that has a destructor that can throw.
llvm::Value * ExceptionSlot
The exception slot.
LValue EmitPseudoObjectLValue(const PseudoObjectExpr *e)
Definition CGExpr.cpp:7538
ComplexPairTy EmitPromotedComplexExpr(const Expr *E, QualType PromotionType)
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:4051
void CreateCoercedStore(llvm::Value *Src, QualType SrcFETy, Address Dst, llvm::TypeSize DstSize, bool DstIsVolatile)
Create a store to.
Definition CGCall.cpp:1786
void EmitCallAndReturnForThunk(llvm::FunctionCallee Callee, const ThunkInfo *Thunk, bool IsUnprototyped)
bool EmitOMPCopyinClause(const OMPExecutableDirective &D)
Emit code for copyin clause in D directive.
llvm::Value * EmitSVEDupX(llvm::Value *Scalar)
LValue EmitOpaqueValueLValue(const OpaqueValueExpr *e)
Definition CGExpr.cpp:6538
void EmitOMPLinearClause(const OMPLoopDirective &D, CodeGenFunction::OMPPrivateScope &PrivateScope)
Emit initial code for linear clauses.
llvm::Value * LoadPassedObjectSize(const Expr *E, QualType EltTy)
If E references a parameter with pass_object_size info or a constant array size modifier,...
Definition CGExpr.cpp:984
void EmitAnyExprToExn(const Expr *E, Address Addr)
LValue EmitScalarCompoundAssignWithComplex(const CompoundAssignOperator *E, llvm::Value *&Result)
llvm::BasicBlock * OMPBeforeScanBlock
void EmitOMPInterchangeDirective(const OMPInterchangeDirective &S)
void EmitOMPPrivateLoopCounters(const OMPLoopDirective &S, OMPPrivateScope &LoopScope)
Emit initial code for loop counters of loop-based directives.
llvm::ConvergenceControlInst * emitConvergenceLoopToken(llvm::BasicBlock *BB)
Definition CGStmt.cpp:3575
llvm::SmallPtrSet< const CXXRecordDecl *, 4 > VisitedVirtualBasesSetTy
void GenerateObjCGetter(ObjCImplementationDecl *IMP, const ObjCPropertyImplDecl *PID)
GenerateObjCGetter - Synthesize an Objective-C property getter function.
Definition CGObjC.cpp:1063
llvm::Value * EmitIvarOffsetAsPointerDiff(const ObjCInterfaceDecl *Interface, const ObjCIvarDecl *Ivar)
Definition CGExpr.cpp:7069
void initFullExprCleanupWithFlag(RawAddress ActiveFlag)
RValue EmitCUDAKernelCallExpr(const CUDAKernelCallExpr *E, ReturnValueSlot ReturnValue, llvm::CallBase **CallOrInvoke)
void pushCleanupAndDeferDeactivation(CleanupKind Kind, As... A)
llvm::DebugLoc EmitReturnBlock()
Emit the unified return block, trying to avoid its emission when possible.
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:4992
RValue EmitLoadOfAnyValue(LValue V, AggValueSlot Slot=AggValueSlot::ignored(), SourceLocation Loc={})
Like EmitLoadOfLValue but also handles complex and aggregate types.
Definition CGExpr.cpp:2531
llvm::BasicBlock * getEHResumeBlock(bool isCleanup)
void EmitAggregateCopy(LValue Dest, LValue Src, QualType EltTy, AggValueSlot::Overlap_t MayOverlap, bool isVolatile=false)
EmitAggregateCopy - Emit an aggregate copy.
llvm::DenseMap< const Decl *, Address > DeclMapTy
LValue EmitLValueForField(LValue Base, const FieldDecl *Field, bool IsInBounds=true)
Definition CGExpr.cpp:5966
RawAddress 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:187
const TargetInfo & getTarget() const
RValue emitRotate(const CallExpr *E, bool IsRotateRight)
void initFullExprCleanup()
Set up the last cleanup that was pushed as a conditional full-expression cleanup.
llvm::Value * EmitAArch64SVEBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition ARM.cpp:4039
llvm::Function * getSpecConstantFunction(const clang::QualType &SpecConstantType)
LValue EmitCompoundAssignmentLValue(const CompoundAssignOperator *E)
llvm::Value * EmitAnnotationCall(llvm::Function *AnnotationFn, llvm::Value *AnnotatedVal, StringRef AnnotationStr, SourceLocation Location, const AnnotateAttr *Attr)
Emit an annotation call (intrinsic).
void EmitStaticVarDecl(const VarDecl &D, llvm::GlobalValue::LinkageTypes Linkage)
Definition CGDecl.cpp:412
bool isInConditionalBranch() const
isInConditionalBranch - Return true if we're currently emitting one branch or the other of a conditio...
llvm::Value * EmitFP8NeonCvtCall(unsigned IID, llvm::Type *Ty0, llvm::Type *Ty1, bool Extract, SmallVectorImpl< llvm::Value * > &Ops, const CallExpr *E, const char *name)
Definition ARM.cpp:501
Address EmitCompoundStmtWithoutScope(const CompoundStmt &S, bool GetLast=false, AggValueSlot AVS=AggValueSlot::ignored())
Definition CGStmt.cpp:587
void pushKmpcAllocFree(CleanupKind Kind, std::pair< llvm::Value *, llvm::Value * > AddrSizePair)
Definition CGDecl.cpp:2411
void GenerateOpenMPCapturedVars(const CapturedStmt &S, SmallVectorImpl< llvm::Value * > &CapturedVars)
llvm::Value * EmitBlockCopyAndAutorelease(llvm::Value *Block, QualType Ty)
Definition CGObjC.cpp:3971
Address EmitCXXMemberDataPointerAddress(const Expr *E, Address base, llvm::Value *memberPtr, const MemberPointerType *memberPtrType, bool IsInBounds, LValueBaseInfo *BaseInfo=nullptr, TBAAAccessInfo *TBAAInfo=nullptr)
Emit the address of a field using a member data pointer.
Definition CGClass.cpp:152
void EmitGotoStmt(const GotoStmt &S)
Definition CGStmt.cpp:858
llvm::BasicBlock * getTerminateHandler()
getTerminateHandler - Return a handler (not a landing pad, just a catch handler) that just calls term...
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.
void EmitOMPDepobjDirective(const OMPDepobjDirective &S)
DeclMapTy::iterator findLocalDecl(const Decl *D)
Accessors for LocalDeclMap.
void maybeCreateMCDCCondBitmap()
Allocate a temp value on the stack that MCDC can use to track condition results.
void EmitOMPMetaDirective(const OMPMetaDirective &S)
llvm::Value * EmitARMBuiltinExpr(unsigned BuiltinID, const CallExpr *E, ReturnValueSlot ReturnValue, llvm::Triple::ArchType Arch)
Definition ARM.cpp:2189
static bool isVptrCheckRequired(TypeCheckKind TCK, QualType Ty)
Determine whether the pointer type check TCK requires a vptr check.
Definition CGExpr.cpp:747
CGCallee EmitCallee(const Expr *E)
Definition CGExpr.cpp:6762
void EmitWritebacks(const CallArgList &Args)
EmitWriteback - Emit callbacks for function.
Definition CGCall.cpp:5284
void EmitOMPCriticalDirective(const OMPCriticalDirective &S)
void EmitIgnoredExpr(const Expr *E)
EmitIgnoredExpr - Emit an expression in a context which ignores the result.
Definition CGExpr.cpp:263
void EnterSEHTryStmt(const SEHTryStmt &S)
llvm::Value * EmitRISCVCpuIs(const CallExpr *E)
Definition RISCV.cpp:1038
RValue EmitCallExpr(const CallExpr *E, ReturnValueSlot ReturnValue=ReturnValueSlot(), llvm::CallBase **CallOrInvoke=nullptr)
Definition CGExpr.cpp:6644
llvm::ScalableVectorType * getSVEType(const SVETypeFlags &TypeFlags)
Definition ARM.cpp:3382
void EmitOMPTaskLoopDirective(const OMPTaskLoopDirective &S)
RValue EmitLoadOfLValue(LValue V, SourceLocation Loc)
EmitLoadOfLValue - Given an expression that represents a value lvalue, this method emits the address ...
Definition CGExpr.cpp:2549
void EmitOMPCancelDirective(const OMPCancelDirective &S)
std::pair< DeclMapTy::iterator, bool > insertLocalDecl(const Decl *D, Address Addr)
void pushDestroyAndDeferDeactivation(QualType::DestructionKind dtorKind, Address addr, QualType type)
Definition CGDecl.cpp:2387
LValue EmitMatrixSingleSubscriptExpr(const MatrixSingleSubscriptExpr *E)
Definition CGExpr.cpp:5415
LValue EmitArraySectionExpr(const ArraySectionExpr *E, bool IsLowerBound=true)
Definition CGExpr.cpp:5492
const Expr * RetExpr
If a return statement is being visited, this holds the return statment's result expression.
Address GetAddrOfBlockDecl(const VarDecl *var)
void EmitOMPBarrierDirective(const OMPBarrierDirective &S)
llvm::Value * EmitComplexToScalarConversion(ComplexPairTy Src, QualType SrcTy, QualType DstTy, SourceLocation Loc)
Emit a conversion from the specified complex type to the specified destination type,...
static bool isInstrumentedCondition(const Expr *C)
isInstrumentedCondition - Determine whether the given condition is an instrumentable condition (i....
void EmitARCDestroyStrong(Address addr, ARCPreciseLifetime_t precise)
Destroy a __strong variable.
Definition CGObjC.cpp:2529
void pushCleanupAfterFullExpr(CleanupKind Kind, As... A)
Queue a cleanup to be pushed after finishing the current full-expression, potentially with an active ...
void DeactivateCleanupBlock(EHScopeStack::stable_iterator Cleanup, llvm::Instruction *DominatingIP)
DeactivateCleanupBlock - Deactivates the given cleanup block.
void EmitCfiCheckStub()
Emit a stub for the cross-DSO CFI check function.
Definition CGExpr.cpp:4499
void callCStructCopyAssignmentOperator(LValue Dst, LValue Src)
VlaSizePair getVLAElements1D(const VariableArrayType *vla)
Return the number of elements for a single dimension for the given array type.
llvm::Value * EmitBPFBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition ARM.cpp:7292
RawAddress CreateIRTempWithoutCast(QualType T, const Twine &Name="tmp")
CreateIRTempWithoutCast - Create a temporary IR object of the given type, with appropriate alignment.
Definition CGExpr.cpp:194
bool EmitOMPWorksharingLoop(const OMPLoopDirective &S, Expr *EUB, const CodeGenLoopBoundsTy &CodeGenLoopBounds, const CodeGenDispatchBoundsTy &CGDispatchBounds)
Emit code for the worksharing loop-based directive.
void EmitForStmt(const ForStmt &S, ArrayRef< const Attr * > Attrs={})
Definition CGStmt.cpp:1249
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:359
void pushFullExprCleanup(CleanupKind kind, As... A)
pushFullExprCleanup - Push a cleanup to be run at the end of the current full-expression.
bool AlwaysEmitXRayCustomEvents() const
AlwaysEmitXRayCustomEvents - Return true if we must unconditionally emit XRay custom event handling c...
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:1898
llvm::Value * EmitSMELdrStr(const SVETypeFlags &TypeFlags, llvm::SmallVectorImpl< llvm::Value * > &Ops, unsigned IntID)
Definition ARM.cpp:3879
LValue EmitOMPSharedLValue(const Expr *E)
Emits the lvalue for the expression with possibly captured variable.
QualType TypeOfSelfObject()
TypeOfSelfObject - Return type of object that this self represents.
Definition CGObjC.cpp:1815
llvm::CanonicalLoopInfo * EmitOMPCollapsedCanonicalLoopNest(const Stmt *S, int Depth)
Emit the Stmt S and return its topmost canonical loop, if any.
void EmitOMPSectionsDirective(const OMPSectionsDirective &S)
void EmitObjCAutoreleasePoolStmt(const ObjCAutoreleasePoolStmt &S)
Definition CGObjC.cpp:3706
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.
LValue EmitAggExprToLValue(const Expr *E)
EmitAggExprToLValue - Emit the computation of the specified expression of aggregate type into a tempo...
void EmitCXXExpansionStmtInstantiation(const CXXExpansionStmtInstantiation &S)
Definition CGStmt.cpp:1505
void EmitOMPInteropDirective(const OMPInteropDirective &S)
void SetFPAccuracy(llvm::Value *Val, float Accuracy)
SetFPAccuracy - Set the minimum required accuracy of the given floating point operation,...
Definition CGExpr.cpp:7389
Address mergeAddressesInConditionalExpr(Address LHS, Address RHS, llvm::BasicBlock *LHSBlock, llvm::BasicBlock *RHSBlock, llvm::BasicBlock *MergeBlock, QualType MergedType)
Address emitAddrOfImagComponent(Address complex, QualType complexType)
llvm::Value * EmitPointerAuthSign(const CGPointerAuthInfo &Info, llvm::Value *Pointer)
llvm::Value * EmitSVETupleCreate(const SVETypeFlags &TypeFlags, llvm::Type *ReturnType, ArrayRef< llvm::Value * > Ops)
Definition ARM.cpp:3984
void EmitOMPParallelSectionsDirective(const OMPParallelSectionsDirective &S)
void EmitCXXConstructorCall(const CXXConstructorDecl *D, CXXCtorType Type, bool ForVirtualBase, bool Delegating, AggValueSlot ThisAVS, const CXXConstructExpr *E)
Definition CGClass.cpp:2172
llvm::Value * EmitSVEPMull(const SVETypeFlags &TypeFlags, llvm::SmallVectorImpl< llvm::Value * > &Ops, unsigned BuiltinID)
Definition ARM.cpp:3665
llvm::Value * EmitObjCBoxedExpr(const ObjCBoxedExpr *E)
EmitObjCBoxedExpr - This routine generates code to call the appropriate expression boxing method.
Definition CGObjC.cpp:65
void EmitOMPTargetParallelDirective(const OMPTargetParallelDirective &S)
void EmitBoundsCheck(const Expr *ArrayExpr, const Expr *ArrayExprBase, 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:1287
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.
void markAsIgnoreThreadCheckingAtRuntime(llvm::Function *Fn)
Annotate the function with an attribute that disables TSan checking at runtime.
llvm::Value * EvaluateExprAsBool(const Expr *E)
EvaluateExprAsBool - Perform the usual unary conversions on the specified expression and compare the ...
Definition CGExpr.cpp:244
void EmitCallArg(CallArgList &args, const Expr *E, QualType ArgType)
EmitCallArg - Emit a single call argument.
Definition CGCall.cpp:5289
void maybeResetMCDCCondBitmap(const Expr *E)
Zero-init the MCDC temp value.
RValue EmitCoyieldExpr(const CoyieldExpr &E, AggValueSlot aggSlot=AggValueSlot::ignored(), bool ignoreResult=false)
void EmitWhileStmt(const WhileStmt &S, ArrayRef< const Attr * > Attrs={})
Definition CGStmt.cpp:1047
JumpDest getOMPCancelDestination(OpenMPDirectiveKind Kind)
void generateObjCSetterBody(const ObjCImplementationDecl *classImpl, const ObjCPropertyImplDecl *propImpl, llvm::Constant *AtomicHelperFn)
Definition CGObjC.cpp:1487
void GenerateCXXGlobalInitFunc(llvm::Function *Fn, ArrayRef< llvm::Function * > CXXThreadLocals, ConstantAddress Guard=ConstantAddress::invalid())
GenerateCXXGlobalInitFunc - Generates code for initializing global variables.
llvm::Value * EmitPPCBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition PPC.cpp:205
LValue EmitPredefinedLValue(const PredefinedExpr *E)
Definition CGExpr.cpp:4014
void EmitPointerAuthOperandBundle(const CGPointerAuthInfo &Info, SmallVectorImpl< llvm::OperandBundleDef > &Bundles)
void EmitOMPTargetParallelForSimdDirective(const OMPTargetParallelForSimdDirective &S)
void EmitOMPTargetParallelGenericLoopDirective(const OMPTargetParallelGenericLoopDirective &S)
Emit combined directive 'target parallel loop' as if its constituent constructs are 'target',...
void EmitOpenACCCombinedConstruct(const OpenACCCombinedConstruct &S)
void EmitOMPUseDeviceAddrClause(const OMPUseDeviceAddrClause &C, OMPPrivateScope &PrivateScope, const llvm::DenseMap< const ValueDecl *, llvm::Value * > CaptureDeviceAddrMap)
void EmitCheck(ArrayRef< std::pair< llvm::Value *, SanitizerKind::SanitizerOrdinal > > Checked, SanitizerHandler Check, ArrayRef< llvm::Constant * > StaticArgs, ArrayRef< llvm::Value * > DynamicArgs, const TrapReason *TR=nullptr)
Create a basic block that will either trap or call a handler function in the UBSan runtime with the p...
Definition CGExpr.cpp:4317
void GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn, const VarDecl *D, llvm::GlobalVariable *Addr, bool PerformInit)
Emit the code necessary to initialize the given global variable.
llvm::Value * EmitSVEDupX(llvm::Value *Scalar, llvm::Type *Ty)
void EmitExtendGCLifetime(llvm::Value *object)
EmitExtendGCLifetime - Given a pointer to an Objective-C object, make sure it survives garbage collec...
Definition CGObjC.cpp:3734
void ResolveBranchFixups(llvm::BasicBlock *Target)
LValue EmitDeclRefLValue(const DeclRefExpr *E)
Definition CGExpr.cpp:3691
void InsertHelper(llvm::Instruction *I, const llvm::Twine &Name, llvm::BasicBlock::iterator InsertPt) const
CGBuilder insert helper.
void EmitOMPTeamsDistributeParallelForSimdDirective(const OMPTeamsDistributeParallelForSimdDirective &S)
LValue EmitStringLiteralLValue(const StringLiteral *E)
Definition CGExpr.cpp:4004
llvm::Value * EmitARMMVEBuiltinExpr(unsigned BuiltinID, const CallExpr *E, ReturnValueSlot ReturnValue, llvm::Triple::ArchType Arch)
Definition ARM.cpp:3026
void EmitOMPMaskedDirective(const OMPMaskedDirective &S)
Address getAsNaturalAddressOf(Address Addr, QualType PointeeTy)
llvm::Value * EmitVTableTypeCheckedLoad(const CXXRecordDecl *RD, llvm::Value *VTable, llvm::Type *VTableTy, uint64_t VTableByteOffset, SourceLocation Loc)
Emit a type checked load from the given vtable.
Definition CGClass.cpp:2999
AggValueSlot CreateAggTemp(QualType T, const Twine &Name="tmp", RawAddress *Alloca=nullptr)
CreateAggTemp - Create a temporary memory object for the given aggregate type.
llvm::CallInst * EmitIntrinsicCall(llvm::Intrinsic::ID ID, const Twine &Name="")
bool checkIfLoopMustProgress(const Expr *, bool HasEmptyBody)
Returns true if a loop must make progress, which means the mustprogress attribute can be added.
Definition CGStmt.cpp:1039
RValue getOrCreateOpaqueRValueMapping(const OpaqueValueExpr *e)
Given an opaque value expression, return its RValue mapping if it exists, otherwise create one.
Definition CGExpr.cpp:6597
RValue EmitCall(const CGFunctionInfo &CallInfo, const CGCallee &Callee, ReturnValueSlot ReturnValue, const CallArgList &Args, llvm::CallBase **CallOrInvoke=nullptr, bool IsMustTail=false)
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...
void callCStructCopyConstructor(LValue Dst, LValue Src)
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...
Address getExceptionSlot()
Returns a pointer to the function's exception object and selector slot, which is assigned in every la...
void EmitCXXGuardedInitBranch(llvm::Value *NeedsInit, llvm::BasicBlock *InitBlock, llvm::BasicBlock *NoInitBlock, GuardKind Kind, const VarDecl *D)
Emit a branch to select whether or not to perform guarded initialization.
bool HaveInsertPoint() const
HaveInsertPoint - True if an insertion point is defined.
void EmitOMPTeamsDistributeSimdDirective(const OMPTeamsDistributeSimdDirective &S)
llvm::Function * GenerateVarArgsThunk(llvm::Function *Fn, const CGFunctionInfo &FnInfo, GlobalDecl GD, const ThunkInfo &Thunk)
RValue EmitAtomicLoad(LValue LV, SourceLocation SL, AggValueSlot Slot=AggValueSlot::ignored())
bool AlwaysEmitXRayTypedEvents() const
AlwaysEmitXRayTypedEvents - Return true if clang must unconditionally emit XRay typed event handling ...
void EmitOMPOrderedBlockAssocDirective(const OMPOrderedBlockAssocDirective &S)
void EmitVTableAssumptionLoads(const CXXRecordDecl *ClassDecl, Address This)
Emit assumption load for all bases.
Definition CGClass.cpp:2433
llvm::Value * EmitARCRetainBlock(llvm::Value *value, bool mandatory)
Retain the given block, with _Block_copy semantics.
Definition CGObjC.cpp:2368
llvm::Value * EmitObjCCollectionLiteral(const Expr *E, const ObjCMethodDecl *MethodWithObjects)
Definition CGObjC.cpp:132
llvm::BasicBlock * getTerminateFunclet()
getTerminateLandingPad - Return a cleanup funclet that just calls terminate.
void EmitInvariantStart(llvm::Constant *Addr, CharUnits Size)
llvm::Value * EmitNeonRShiftImm(llvm::Value *Vec, llvm::Value *Amt, llvm::Type *Ty, bool usgn, const char *name)
Definition ARM.cpp:517
llvm::BasicBlock * getTerminateLandingPad()
getTerminateLandingPad - Return a landing pad that just calls terminate.
void EmitOMPDistributeLoop(const OMPLoopDirective &S, const CodeGenLoopTy &CodeGenLoop, Expr *IncExpr)
Emit code for the distribute loop-based directive.
llvm::Function * GenerateSEHFinallyFunction(CodeGenFunction &ParentCGF, const SEHFinallyStmt &Finally)
llvm::Value * emitScalarConstant(const ConstantEmission &Constant, Expr *E)
Definition CGExpr.cpp:2061
void AddAMDGPUFenceAddressSpaceMMRA(llvm::Instruction *Inst, const CallExpr *E)
Definition AMDGPU.cpp:471
void EmitOMPMasterTaskLoopDirective(const OMPMasterTaskLoopDirective &S)
llvm::Value * EmitARCRetainScalarExpr(const Expr *expr)
EmitARCRetainScalarExpr - Semantically equivalent to EmitARCRetainObject(e->getType(),...
Definition CGObjC.cpp:3511
void EmitOMPReverseDirective(const OMPReverseDirective &S)
llvm::Value * getTypeSize(QualType Ty)
Returns calculated size of the specified type.
bool EmitLifetimeStart(llvm::Value *Addr)
Emit a lifetime.begin marker if some criteria are satisfied.
Definition CGDecl.cpp:1368
void EmitStartEHSpec(const Decl *D)
EmitStartEHSpec - Emit the start of the exception spec.
void popCatchScope()
popCatchScope - Pops the catch scope at the top of the EHScope stack, emitting any required code (oth...
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:1710
void EmitOMPCancellationPointDirective(const OMPCancellationPointDirective &S)
void EmitDestructorBody(FunctionArgList &Args)
EmitDestructorBody - Emits the body of the current destructor.
Definition CGClass.cpp:1419
void EmitOpenACCDataConstruct(const OpenACCDataConstruct &S)
LValue MakeRawAddrLValue(llvm::Value *V, QualType T, CharUnits Alignment, AlignmentSource Source=AlignmentSource::Type)
Same as MakeAddrLValue above except that the pointer is known to be unsigned.
llvm::MDNode * buildAllocToken(QualType AllocType)
Build metadata used by the AllocToken instrumentation.
Definition CGExpr.cpp:1368
RValue EmitCXXMemberCallExpr(const CXXMemberCallExpr *E, ReturnValueSlot ReturnValue, llvm::CallBase **CallOrInvoke=nullptr)
void EmitX86MultiVersionResolver(llvm::Function *Resolver, ArrayRef< FMVResolverOption > Options)
LValue EmitLValueForFieldInitialization(LValue Base, const FieldDecl *Field)
EmitLValueForFieldInitialization - Like EmitLValueForField, except that if the Field is a reference,...
Definition CGExpr.cpp:6125
llvm::Value * EmitBlockLiteral(const BlockExpr *)
Emit block literal.
Definition CGBlocks.cpp:764
void EmitOMPTargetTeamsDistributeParallelForDirective(const OMPTargetTeamsDistributeParallelForDirective &S)
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:2261
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:216
void EmitOMPMaskedTaskLoopDirective(const OMPMaskedTaskLoopDirective &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...
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:164
void EmitObjCAtTryStmt(const ObjCAtTryStmt &S)
Definition CGObjC.cpp:2144
SmallVector< llvm::Type *, 2 > getSVEOverloadTypes(const SVETypeFlags &TypeFlags, llvm::Type *ReturnType, ArrayRef< llvm::Value * > Ops)
Definition ARM.cpp:3946
bool ShouldInstrumentFunction()
ShouldInstrumentFunction - Return true if the current function should be instrumented with __cyg_prof...
void startOutlinedSEHHelper(CodeGenFunction &ParentCGF, bool IsFilter, const Stmt *OutlinedStmt)
Arrange a function prototype that can be called by Windows exception handling personalities.
void maybeUpdateMCDCCondBitmap(const Expr *E, llvm::Value *Val)
Update the MCDC temp value with the condition's evaluated result.
LValue getOrCreateOpaqueLValueMapping(const OpaqueValueExpr *e)
Given an opaque value expression, return its LValue mapping if it exists, otherwise create one.
Definition CGExpr.cpp:6583
llvm::function_ref< std::pair< LValue, LValue >(CodeGenFunction &, const OMPExecutableDirective &S)> CodeGenLoopBoundsTy
llvm::Function * generateAwaitSuspendWrapper(Twine const &CoroName, Twine const &SuspendPointName, CoroutineSuspendExpr const &S)
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:2133
ComplexPairTy EmitComplexExpr(const Expr *E, bool IgnoreReal=false, bool IgnoreImag=false)
EmitComplexExpr - Emit the computation of the specified expression of complex type,...
void emitAlignmentAssumptionCheck(llvm::Value *Ptr, QualType Ty, SourceLocation Loc, SourceLocation AssumptionLoc, llvm::Value *Alignment, llvm::Value *OffsetValue, llvm::Value *TheCheck, llvm::Instruction *Assumption)
RValue EmitCall(const CGFunctionInfo &CallInfo, const CGCallee &Callee, ReturnValueSlot ReturnValue, const CallArgList &Args, llvm::CallBase **CallOrInvoke, bool IsMustTail, SourceLocation Loc, bool IsVirtualFunctionPointerThunk=false)
EmitCall - Generate a call of the given function, expecting the given result type,...
Definition CGCall.cpp:5703
const TargetCodeGenInfo & getTargetHooks() const
void setBeforeOutermostConditional(llvm::Value *value, Address addr, CodeGenFunction &CGF)
CGPointerAuthInfo EmitPointerAuthInfo(const PointerAuthSchema &Schema, llvm::Value *StorageAddress, GlobalDecl SchemaDecl, QualType SchemaType)
Emit the concrete pointer authentication informaton for the given authentication schema.
void EmitOMPTargetExitDataDirective(const OMPTargetExitDataDirective &S)
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:1218
llvm::ConstantInt * getUBSanFunctionTypeHash(QualType T) const
Return a type hash constant for a function instrumented by -fsanitize=function.
RValue EmitBuiltinAlignTo(const CallExpr *E, bool AlignUp)
Emit IR for __builtin_align_up/__builtin_align_down.
LValue EmitHLSLArrayAssignLValue(const BinaryOperator *E)
Definition CGExpr.cpp:6969
void EmitSEHLeaveStmt(const SEHLeaveStmt &S)
void EmitLifetimeEnd(llvm::Value *Addr)
Definition CGDecl.cpp:1379
RawAddress CreateMemTempWithoutCast(QualType T, const Twine &Name="tmp")
CreateMemTemp - Create a temporary memory object of the given type, with appropriate alignmen without...
Definition CGExpr.cpp:236
void EmitBranchToCounterBlock(const Expr *Cond, BinaryOperator::Opcode LOp, llvm::BasicBlock *TrueBlock, llvm::BasicBlock *FalseBlock, uint64_t TrueCount=0, Stmt::Likelihood LH=Stmt::LH_None, const Expr *CntrIdx=nullptr)
EmitBranchToCounterBlock - Emit a conditional branch to a new block that increments a profile counter...
llvm::SmallDenseMap< const VarDecl *, Address, 4 > BypassedVarInits
void EmitPointerAuthCopy(PointerAuthQualifier Qualifier, QualType Type, Address DestField, Address SrcField)
void EmitOMPTargetEnterDataDirective(const OMPTargetEnterDataDirective &S)
LValue EmitVAArgExprLValue(const VAArgExpr *E)
Definition CGExpr.cpp:7006
bool InNoInlineAttributedStmt
True if the current statement has noinline attribute.
SmallVector< llvm::OperandBundleDef, 1 > getBundlesForFunclet(llvm::Value *Callee)
Definition CGCall.cpp:5436
void EmitOMPMaskedTaskLoopSimdDirective(const OMPMaskedTaskLoopSimdDirective &S)
llvm::Value * EmitWebAssemblyBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
llvm::Value * EmitNeonShiftVector(llvm::Value *V, llvm::Type *Ty, bool negateForRightShift)
Definition ARM.cpp:495
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:2799
void EmitVTableCheck(CFITypeCheckKind TCK, CanQualType T, llvm::Metadata *MD, llvm::Value *VTable, llvm::Value *TypeTest, SourceLocation Loc, bool UseCrossDsoSlowPath)
Emit a CFI check failure handler or trap for a vtable type test result.
Definition CGClass.cpp:2940
void EmitCapturedLocals(CodeGenFunction &ParentCGF, const Stmt *OutlinedStmt, bool IsFilter)
Scan the outlined statement for captures from the parent function.
llvm::Value * EmitObjCAlloc(llvm::Value *value, llvm::Type *returnType)
Allocate the given objc object.
Definition CGObjC.cpp:2808
llvm::Value * LoadObjCSelf()
LoadObjCSelf - Load the value of self.
Definition CGObjC.cpp:1807
void GenerateObjCMethod(const ObjCMethodDecl *OMD)
Generate an Objective-C method.
Definition CGObjC.cpp:834
void callCStructMoveAssignmentOperator(LValue Dst, LValue Src)
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.
bool IsInPreservedAIRegion
True if CodeGen currently emits code inside presereved access index region.
RValue EmitAnyExprToTemp(const Expr *E)
EmitAnyExprToTemp - Similarly to EmitAnyExpr(), however, the result will always be accessible even if...
Definition CGExpr.cpp:304
llvm::FenceInst * emitAtomicFence(llvm::AtomicOrdering Order, llvm::SyncScope::ID SSID=llvm::SyncScope::System)
Emit a fence instruction, applying relevant target-specific metadata when applicable.
void EmitCoroutineBody(const CoroutineBodyStmt &S)
void pushCleanupAfterFullExprWithActiveFlag(CleanupKind Kind, RawAddress ActiveFlag, As... A)
VlaSizePair getVLASize(const VariableArrayType *vla)
Returns an LLVM value that corresponds to the size, in non-variably-sized elements,...
LValue EmitStmtExprLValue(const StmtExpr *E)
Definition CGExpr.cpp:7109
void EmitOMPParallelDirective(const OMPParallelDirective &S)
void EmitOMPTaskDirective(const OMPTaskDirective &S)
llvm::Value * unregisterGlobalDtorWithUnAtExit(llvm::Constant *dtorStub)
Call unatexit() with function dtorStub.
void EmitOMPMasterTaskLoopSimdDirective(const OMPMasterTaskLoopSimdDirective &S)
void pushSEHCleanup(CleanupKind kind, llvm::Function *FinallyFunc)
llvm::Value * EmitARCLoadWeakRetained(Address addr)
i8* @objc_loadWeakRetained(i8** addr)
Definition CGObjC.cpp:2662
void EmitOMPDistributeParallelForDirective(const OMPDistributeParallelForDirective &S)
void EmitOMPAssumeDirective(const OMPAssumeDirective &S)
llvm::Value * emitPointerAuthResign(llvm::Value *Pointer, QualType PointerType, const CGPointerAuthInfo &CurAuthInfo, const CGPointerAuthInfo &NewAuthInfo, bool IsKnownNonNull)
int ExpectedOMPLoopDepth
Number of nested loop to be consumed by the last surrounding loop-associated directive.
void EmitOMPPrivateClause(const OMPExecutableDirective &D, OMPPrivateScope &PrivateScope)
llvm::CallInst * EmitNounwindRuntimeCall(llvm::FunctionCallee callee, const Twine &name="")
void EmitOMPTeamsDistributeDirective(const OMPTeamsDistributeDirective &S)
llvm::Value * EmitDirectXBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition DirectX.cpp:22
llvm::Value * EmitAArch64BuiltinExpr(unsigned BuiltinID, const CallExpr *E, llvm::Triple::ArchType Arch)
Definition ARM.cpp:4497
void EmitStopPoint(const Stmt *S)
EmitStopPoint - Emit a debug stoppoint if we are emitting debug info.
Definition CGStmt.cpp:49
RawAddress CreateTempAllocaWithoutCast(llvm::Type *Ty, CharUnits align, const Twine &Name="tmp", llvm::Value *ArraySize=nullptr)
CreateTempAlloca - This creates a alloca and inserts it into the entry block.
Definition CGExpr.cpp:113
void EmitOMPTargetUpdateDirective(const OMPTargetUpdateDirective &S)
llvm::Value * EmitWithOriginalRHSBitfieldAssignment(const BinaryOperator *E, llvm::Value **Previous, QualType *SrcType)
Retrieve the implicit cast expression of the rhs in a binary operator expression by passing pointers ...
llvm::Value * EmitMSVCBuiltinExpr(MSVCIntrin BuiltinID, const CallExpr *E)
llvm::Value * EmitLoadOfScalar(Address Addr, bool Volatile, QualType Ty, SourceLocation Loc, AlignmentSource Source=AlignmentSource::Type, bool isNontemporal=false)
EmitLoadOfScalar - Load a scalar value from an address, taking care to appropriately convert from the...
void EmitOMPTargetTeamsGenericLoopDirective(const OMPTargetTeamsGenericLoopDirective &S)
bool isMCDCBranchExpr(const Expr *E) const
llvm::Value * EmitFP8NeonFDOTCall(unsigned IID, bool ExtendLaneArg, llvm::Type *RetTy, SmallVectorImpl< llvm::Value * > &Ops, const CallExpr *E, const char *name)
Definition ARM.cpp:464
LValue EmitHLSLOutArgExpr(const HLSLOutArgExpr *E, CallArgList &Args, QualType Ty, bool IsImplicitObject=false)
Definition CGExpr.cpp:6566
void EmitMultiVersionResolver(llvm::Function *Resolver, ArrayRef< FMVResolverOption > Options)
void EmitIfStmt(const IfStmt &S)
Definition CGStmt.cpp:904
void emitAutoVarTypeCleanup(const AutoVarEmission &emission, QualType::DestructionKind dtorKind)
Enter a destroy cleanup for the given local variable.
Definition CGDecl.cpp:2214
void emitARCMoveAssignWeak(QualType Ty, Address DstAddr, Address SrcAddr)
Definition CGObjC.cpp:2733
llvm::Value * vectorWrapScalar16(llvm::Value *Op)
Definition ARM.cpp:3281
void Destroyer(CodeGenFunction &CGF, Address addr, QualType ty)
void EmitStoreOfComplex(ComplexPairTy V, LValue dest, bool isInit)
EmitStoreOfComplex - Store a complex number into the specified l-value.
const Decl * CurFuncDecl
CurFuncDecl - Holds the Decl for the current outermost non-closure context.
llvm::CallInst * EmitNounwindRuntimeCall(llvm::FunctionCallee callee, ArrayRef< llvm::Value * > args, const Twine &name="")
void EmitAutoVarCleanups(const AutoVarEmission &emission)
Definition CGDecl.cpp:2281
LValue EmitObjCIvarRefLValue(const ObjCIvarRefExpr *E)
Definition CGExpr.cpp:7085
llvm::Value * EmitARMCDEBuiltinExpr(unsigned BuiltinID, const CallExpr *E, ReturnValueSlot ReturnValue, llvm::Triple::ArchType Arch)
Definition ARM.cpp:3127
void EmitAndRegisterVariableArrayDimensions(CGDebugInfo *DI, const VarDecl &D, bool EmitDebugInfo)
Emits the alloca and debug information for the size expressions for each dimension of an array.
Definition CGDecl.cpp:1396
static const Expr * stripCond(const Expr *C)
Ignore parentheses and logical-NOT to track conditions consistently.
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:3503
void EmitDeferStmt(const DeferStmt &S)
Definition CGStmt.cpp:2049
void registerGlobalDtorWithLLVM(const VarDecl &D, llvm::FunctionCallee fn, llvm::Constant *addr)
Registers the dtor using 'llvm.global_dtors' for platforms that do not support an 'atexit()' function...
Address EmitAddressOfPFPField(Address RecordPtr, const PFPField &Field)
void emitBypassedVarInitsForSource(const Stmt *Source)
Re-emit trivial-auto-var-init stores for variables bypassed by the jump Source.
Definition CGDecl.cpp:1887
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:2801
SmallVector< llvm::CanonicalLoopInfo *, 4 > OMPLoopNestStack
List of recently emitted OMPCanonicalLoops.
Address EmitArrayToPointerDecay(const Expr *Array, LValueBaseInfo *BaseInfo=nullptr, TBAAAccessInfo *TBAAInfo=nullptr)
Definition CGExpr.cpp:4763
void SetFastMathFlags(FPOptions FPFeatures)
Set the codegen fast-math flags.
void pushLifetimeExtendedDestroy(CleanupKind kind, Address addr, QualType type, Destroyer *destroyer, bool useEHCleanupForArray)
Definition CGDecl.cpp:2416
llvm::Value * EmitAArch64CompareBuiltinExpr(llvm::Value *Op, llvm::Type *Ty, const llvm::CmpInst::Predicate Pred, const llvm::Twine &Name="")
Definition ARM.cpp:1849
llvm::SmallVector< char, 256 > LifetimeExtendedCleanupStack
llvm::Constant * GenerateObjCAtomicSetterCopyHelperFunction(const ObjCPropertyImplDecl *PID)
GenerateObjCAtomicSetterCopyHelperFunction - Given a c++ object type with non-trivial copy assignment...
Definition CGObjC.cpp:3751
llvm::Value * EmitSPIRVBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition SPIR.cpp:22
void EmitOpenACCAtomicConstruct(const OpenACCAtomicConstruct &S)
void EmitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt &S)
Definition CGObjC.cpp:2152
Address EmitCompoundStmt(const CompoundStmt &S, bool GetLast=false, AggValueSlot AVS=AggValueSlot::ignored())
EmitCompoundStmt - Emit a compound statement {..} node.
Definition CGStmt.cpp:575
llvm::Value * LoadCXXVTT()
LoadCXXVTT - Load the VTT parameter to base constructors/destructors have virtual bases.
RValue EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, const CallExpr *E, ReturnValueSlot ReturnValue)
void EmitOpenACCCacheConstruct(const OpenACCCacheConstruct &S)
Address EmitOMPBindingOriginalAddr(const BindingDecl *BD, SourceLocation Loc)
Emits the original address for a structured binding.
Address EmitVAListRef(const Expr *E)
void EmitOpenACCLoopConstruct(const OpenACCLoopConstruct &S)
void EmitOMPTeamsDistributeParallelForDirective(const OMPTeamsDistributeParallelForDirective &S)
RValue GetUndefRValue(QualType Ty)
GetUndefRValue - Get an appropriate 'undef' rvalue for the given type.
Definition CGExpr.cpp:1678
void EmitParmDecl(const VarDecl &D, ParamValue Arg, unsigned ArgNo)
EmitParmDecl - Emit a ParmVarDecl or an ImplicitParamDecl.
Definition CGDecl.cpp:2738
llvm::Instruction * getPostAllocaInsertPoint()
Return PostAllocaInsertPt.
RValue EmitBuiltinIsAligned(const CallExpr *E)
Emit IR for __builtin_is_aligned.
void EmitAllocToken(llvm::CallBase *CB, QualType AllocType)
Emit and set additional metadata used by the AllocToken instrumentation.
Definition CGExpr.cpp:1402
void EmitARCNoopIntrinsicUse(ArrayRef< llvm::Value * > values)
Emit a call to "clang.arc.noop.use", which consumes the result of a call that has operand bundle "cla...
Definition CGObjC.cpp:2198
llvm::AtomicRMWInst * emitAtomicRMWInst(llvm::AtomicRMWInst::BinOp Op, Address Addr, llvm::Value *Val, llvm::AtomicOrdering Order=llvm::AtomicOrdering::SequentiallyConsistent, llvm::SyncScope::ID SSID=llvm::SyncScope::System, const AtomicExpr *AE=nullptr)
Emit an atomicrmw instruction, and applying relevant metadata when applicable.
LValue EmitComplexAssignmentLValue(const BinaryOperator *E)
Emit an l-value for an assignment (simple or compound) of complex type.
LValue EmitCastLValue(const CastExpr *E)
EmitCastLValue - Casts are never lvalues unless that cast is to a reference type.
Definition CGExpr.cpp:6350
void EmitOMPFuseDirective(const OMPFuseDirective &S)
llvm::Value * EmitPointerArithmetic(const BinaryOperator *BO, Expr *pointerOperand, llvm::Value *pointer, Expr *indexOperand, llvm::Value *index, bool isSubtraction)
Emit pointer + index arithmetic.
void EmitInitializerForField(FieldDecl *Field, LValue LHS, Expr *Init)
Definition CGClass.cpp:632
LValue EmitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *E)
Definition CGExpr.cpp:529
LValue EmitLoadOfPointerLValue(Address Ptr, const PointerType *PtrTy)
Definition CGExpr.cpp:3463
void EmitAsmStmt(const AsmStmt &S)
Definition CGStmt.cpp:2745
void EmitDefaultStmt(const DefaultStmt &S, ArrayRef< const Attr * > Attrs)
Definition CGStmt.cpp:1950
void EmitOMPTargetTeamsDistributeDirective(const OMPTargetTeamsDistributeDirective &S)
void EmitLambdaInAllocaCallOpBody(const CXXMethodDecl *MD)
Definition CGClass.cpp:3161
void EmitSwitchStmt(const SwitchStmt &S)
Definition CGStmt.cpp:2341
Address ReturnValuePointer
ReturnValuePointer - The temporary alloca to hold a pointer to sret.
void EmitOMPUseDevicePtrClause(const OMPUseDevicePtrClause &C, OMPPrivateScope &PrivateScope, const llvm::DenseMap< const ValueDecl *, llvm::Value * > CaptureDeviceAddrMap)
llvm::Value * SEHInfo
Value returned by __exception_info intrinsic.
LValue EmitOMPCapturedBindingLValue(const BindingDecl *BD)
Emit an LValue for a structured binding captured in an OpenMP region.
Definition CGExpr.cpp:3631
static bool mightAddDeclToScope(const Stmt *S)
Determine if the given statement might introduce a declaration into the current scope,...
llvm::Value * EmitCheckValue(llvm::Value *V)
Convert a value into a format suitable for passing to a runtime sanitizer handler.
Definition CGExpr.cpp:4131
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:314
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:285
bool needsEHCleanup(QualType::DestructionKind kind)
Determines whether an EH cleanup is required to destroy a type with the given destruction kind.
LValue EmitExtVectorElementExpr(const ExtVectorElementExpr *E)
Definition CGExpr.cpp:5656
void EmitStmt(const Stmt *S, ArrayRef< const Attr * > Attrs={})
EmitStmt - Emit the code for the statement.
Definition CGStmt.cpp:59
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:361
llvm::DenseMap< const ValueDecl *, FieldDecl * > LambdaCaptureFields
RValue EmitBuiltinNewDeleteCall(const FunctionProtoType *Type, const CallExpr *TheCallExpr, bool IsDelete)
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:1704
void EmitOMPParallelForSimdDirective(const OMPParallelForSimdDirective &S)
bool AutoreleaseResult
In ARC, whether we should autorelease the return value.
CleanupKind getCleanupKind(QualType::DestructionKind kind)
llvm::CallInst * EmitRuntimeCall(llvm::FunctionCallee callee, const Twine &name="")
uint64_t getCurrentProfileCount()
Get the profiler's current count.
std::pair< LValue, LValue > EmitHLSLOutArgLValues(const HLSLOutArgExpr *E, QualType Ty)
Definition CGExpr.cpp:6544
LValue EmitObjCSelectorLValue(const ObjCSelectorExpr *E)
Definition CGExpr.cpp:7057
llvm::Value * EmitARCRetainNonBlock(llvm::Value *value)
Retain the given object, with normal retain semantics.
Definition CGObjC.cpp:2356
llvm::Type * ConvertTypeForMem(QualType T)
static std::string getNonTrivialCopyConstructorStr(QualType QT, CharUnits Alignment, bool IsVolatile, ASTContext &Ctx)
void generateObjCGetterBody(const ObjCImplementationDecl *classImpl, const ObjCPropertyImplDecl *propImpl, const ObjCMethodDecl *GetterMothodDecl, llvm::Constant *AtomicHelperFn)
Definition CGObjC.cpp:1149
LValue EmitCallExprLValue(const CallExpr *E, llvm::CallBase **CallOrInvoke=nullptr)
Definition CGExpr.cpp:6991
llvm::Value * EmitARCRetainAutoreleaseNonBlock(llvm::Value *value)
Do a fused retain/autorelease of the given object.
Definition CGObjC.cpp:2647
llvm::Value * EmitSVEMovl(const SVETypeFlags &TypeFlags, llvm::ArrayRef< llvm::Value * > Ops, unsigned BuiltinID)
Definition ARM.cpp:3683
void EmitOMPInnerLoop(const OMPExecutableDirective &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.
void EmitEndEHSpec(const Decl *D)
EmitEndEHSpec - Emit the end of the exception spec.
void EmitSynthesizedCXXCopyCtorCall(const CXXConstructorDecl *D, Address This, Address Src, const CXXConstructExpr *E)
Definition CGClass.cpp:2440
void GenerateCXXGlobalCleanUpFunc(llvm::Function *Fn, ArrayRef< std::tuple< llvm::FunctionType *, llvm::WeakTrackingVH, llvm::Constant * > > DtorsOrStermFinalizers)
GenerateCXXGlobalCleanUpFunc - Generates code for cleaning up global variables.
void EmitOMPTaskLoopSimdDirective(const OMPTaskLoopSimdDirective &S)
static void EmitOMPTargetTeamsDistributeParallelForDeviceFunction(CodeGenModule &CGM, StringRef ParentName, const OMPTargetTeamsDistributeParallelForDirective &S)
llvm::Value * EmitObjCAutoreleasePoolPush()
Produce the code to do a objc_autoreleasepool_push.
Definition CGObjC.cpp:2743
RValue EmitLoadOfBitfieldLValue(LValue LV, SourceLocation Loc)
Definition CGExpr.cpp:2663
void EmitSYCLKernelCallStmt(const SYCLKernelCallStmt &S)
RValue EmitAtomicExpr(AtomicExpr *E)
Definition CGAtomic.cpp:944
void GenerateObjCSetter(ObjCImplementationDecl *IMP, const ObjCPropertyImplDecl *PID)
GenerateObjCSetter - Synthesize an Objective-C property setter function for the given property.
Definition CGObjC.cpp:1691
llvm::Value * EmitARCLoadWeak(Address addr)
i8* @objc_loadWeak(i8** addr) Essentially objc_autorelease(objc_loadWeakRetained(addr)).
Definition CGObjC.cpp:2655
void EmitOMPTargetDirective(const OMPTargetDirective &S)
void ExitSEHTryStmt(const SEHTryStmt &S)
void EmitOpenACCEnterDataConstruct(const OpenACCEnterDataConstruct &S)
LValue EmitLValueForLambdaField(const FieldDecl *Field)
Definition CGExpr.cpp:5871
static void EmitOMPTargetParallelForSimdDeviceFunction(CodeGenModule &CGM, StringRef ParentName, const OMPTargetParallelForSimdDirective &S)
Emit device code for the target parallel for simd directive.
llvm::Value * EmitSVEPredicateTupleCast(llvm::Value *PredTuple, llvm::StructType *Ty)
Definition ARM.cpp:3462
void markStmtMaybeUsed(const Stmt *S)
void emitPFPPostCopyUpdates(Address DestPtr, Address SrcPtr, QualType Ty)
Copy all PFP fields from SrcPtr to DestPtr while updating signatures, assuming that DestPtr was alrea...
llvm::Value * EmitHexagonBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition Hexagon.cpp:77
Address EmitZOSVAListRef(const Expr *E)
Emit a "reference" to a __builtin_zos_va_list; this is always the address of the expression,...
CodeGenTypes & getTypes() const
RValue emitStdcCountIntrinsic(const CallExpr *E, llvm::Intrinsic::ID IntID, bool InvertArg, bool IsPop=false)
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:3461
llvm::Value * EmitX86BuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition X86.cpp:751
static TypeEvaluationKind getEvaluationKind(QualType T)
getEvaluationKind - Return the TypeEvaluationKind of QualType T.
void generateThunk(llvm::Function *Fn, const CGFunctionInfo &FnInfo, GlobalDecl GD, const ThunkInfo &Thunk, bool IsUnprototyped)
Generate a thunk for the given method.
void ExitCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock=false)
llvm::Value * EmitIvarOffset(const ObjCInterfaceDecl *Interface, const ObjCIvarDecl *Ivar)
Definition CGExpr.cpp:7063
CodeGenUtils::MSVCIntrin MSVCIntrin
llvm::Value * EmitSVEPrefetchLoad(const SVETypeFlags &TypeFlags, SmallVectorImpl< llvm::Value * > &Ops, unsigned BuiltinID)
Definition ARM.cpp:3690
bool IsSanitizerScope
True if CodeGen currently emits code implementing sanitizer checks.
void FlattenAccessAndTypeLValue(LValue LVal, SmallVectorImpl< LValue > &AccessList)
Definition CGExpr.cpp:7542
void EmitOMPTeamsDirective(const OMPTeamsDirective &S)
static bool containsBreak(const Stmt *S)
containsBreak - Return true if the statement contains a break out of it.
void emitImplicitAssignmentOperatorBody(FunctionArgList &Args)
Definition CGClass.cpp:1538
void EmitSimpleOMPExecutableDirective(const OMPExecutableDirective &D)
Emit simple code for OpenMP directives in Simd-only mode.
HLSLControlFlowHintAttr::Spelling HLSLControlFlowAttr
HLSL Branch attribute.
LValue EmitCoyieldLValue(const CoyieldExpr *E)
bool InAlwaysInlineAttributedStmt
True if the current statement has always_inline attribute.
void EmitCaseStmt(const CaseStmt &S, ArrayRef< const Attr * > Attrs)
Definition CGStmt.cpp:1839
RawAddress CreateTempAlloca(llvm::Type *Ty, CharUnits align, const Twine &Name="tmp", llvm::Value *ArraySize=nullptr, RawAddress *Alloca=nullptr)
CreateTempAlloca - This creates a alloca and inserts it into the entry block.
llvm::Constant * GenerateObjCAtomicGetterCopyHelperFunction(const ObjCPropertyImplDecl *PID)
Definition CGObjC.cpp:3851
void EmitOMPErrorDirective(const OMPErrorDirective &S)
void EmitOMPTargetTaskBasedDirective(const OMPExecutableDirective &S, const RegionCodeGenTy &BodyGen, OMPTargetDataInfo &InputInfo)
void EmitBreakStmt(const BreakStmt &S)
Definition CGStmt.cpp:1724
void EmitOMPParallelMaskedTaskLoopSimdDirective(const OMPParallelMaskedTaskLoopSimdDirective &S)
void EmitOMPTargetTeamsDirective(const OMPTargetTeamsDirective &S)
void EmitOpenACCComputeConstruct(const OpenACCComputeConstruct &S)
void EmitTypeCheck(TypeCheckKind TCK, SourceLocation Loc, LValue LV, QualType Type, SanitizerSet SkippedChecks=SanitizerSet(), llvm::Value *ArraySize=nullptr)
void EmitCfiSlowPathCheck(SanitizerKind::SanitizerOrdinal Ordinal, 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:4451
RValue EmitCoawaitExpr(const CoawaitExpr &E, AggValueSlot aggSlot=AggValueSlot::ignored(), bool ignoreResult=false)
llvm::SmallVector< const ParmVarDecl *, 4 > FnArgs
Save Parameter Decl for coroutine.
void EmitDoStmt(const DoStmt &S, ArrayRef< const Attr * > Attrs={})
Definition CGStmt.cpp:1164
void EmitOMPTargetDataDirective(const OMPTargetDataDirective &S)
llvm::Value * EmitSMEZero(const SVETypeFlags &TypeFlags, llvm::SmallVectorImpl< llvm::Value * > &Ops, unsigned IntID)
Definition ARM.cpp:3869
void EmitCXXTemporary(const CXXTemporary *Temporary, QualType TempType, Address Ptr)
Emits all the code to cause the given temporary to be cleaned up.
llvm::Value * authPointerToPointerCast(llvm::Value *ResultPtr, QualType SourceType, QualType DestType)
Address GenerateCapturedStmtArgument(const CapturedStmt &S)
Definition CGStmt.cpp:3476
LValue EmitUnaryOpLValue(const UnaryOperator *E)
Definition CGExpr.cpp:3937
bool EmitOMPLastprivateClauseInit(const OMPExecutableDirective &D, OMPPrivateScope &PrivateScope)
Emit initial code for lastprivate variables.
void StartThunk(llvm::Function *Fn, GlobalDecl GD, const CGFunctionInfo &FnInfo, bool IsUnprototyped)
void EmitFunctionEpilog(const CGFunctionInfo &FI, bool EmitRetDbgLoc, SourceLocation EndLoc, uint64_t RetKeyInstructionsSourceAtom)
EmitFunctionEpilog - Emit the target specific LLVM code to return the given temporary.
Definition CGCall.cpp:4400
Address EmitPointerWithAlignment(const Expr *Addr, LValueBaseInfo *BaseInfo=nullptr, TBAAAccessInfo *TBAAInfo=nullptr, KnownNonNull_t IsKnownNonNull=NotKnownNonNull)
EmitPointerWithAlignment - Given an expression with a pointer type, emit the value and compute our be...
Definition CGExpr.cpp:1661
static void EmitOMPTargetTeamsDistributeParallelForSimdDeviceFunction(CodeGenModule &CGM, StringRef ParentName, const OMPTargetTeamsDistributeParallelForSimdDirective &S)
Emit device code for the target teams distribute parallel for simd directive.
llvm::BasicBlock * getEHDispatchBlock(EHScopeStack::stable_iterator scope)
void EmitBranch(llvm::BasicBlock *Block)
EmitBranch - Emit a branch to the specified basic block from the current insert block,...
Definition CGStmt.cpp:678
bool LValueIsSuitableForInlineAtomic(LValue Src)
An LValue is a candidate for having its loads and stores be made atomic if we are operating under /vo...
llvm::Function * GenerateOpenMPCapturedStmtFunction(const CapturedStmt &S, const OMPExecutableDirective &D)
void EmitOMPSimdDirective(const OMPSimdDirective &S)
llvm::Value * EmitSVEStructStore(const SVETypeFlags &TypeFlags, SmallVectorImpl< llvm::Value * > &Ops, unsigned IntID)
Definition ARM.cpp:3617
LValue EmitCheckedLValue(const Expr *E, TypeCheckKind TCK)
Same as EmitLValue but additionally we generate checking code to guard against undefined behavior.
Definition CGExpr.cpp:1742
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:2318
RawAddress CreateMemTemp(QualType T, const Twine &Name="tmp", RawAddress *Alloca=nullptr)
CreateMemTemp - Create a temporary memory object of the given type, with appropriate alignmen and cas...
Definition CGExpr.cpp:200
Address EmitLoadOfReference(LValue RefLVal, LValueBaseInfo *PointeeBaseInfo=nullptr, TBAAAccessInfo *PointeeTBAAInfo=nullptr)
Definition CGExpr.cpp:3411
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:345
RValue EmitRValueForField(LValue LV, const FieldDecl *FD, SourceLocation Loc)
Definition CGExpr.cpp:6616
void EmitOMPParallelGenericLoopDirective(const OMPLoopDirective &S)
RawAddress NormalCleanupDest
i32s containing the indexes of the cleanup destinations.
llvm::Value * EmitObjCExtendObjectLifetime(QualType T, llvm::Value *Ptr)
Definition CGObjC.cpp:2179
SmallVector< llvm::Value *, 8 > ObjCEHValueStack
ObjCEHValueStack - Stack of Objective-C exception values, used for rethrows.
void WasmEmitFallthroughRethrow(llvm::BasicBlock *WasmCatchStartBlock)
void EmitOMPTeamsGenericLoopDirective(const OMPTeamsGenericLoopDirective &S)
void setBlockContextParameter(const ImplicitParamDecl *D, unsigned argNum, llvm::Value *ptr)
LValue EmitCXXBindTemporaryLValue(const CXXBindTemporaryExpr *E)
Definition CGExpr.cpp:7035
RValue EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E, ReturnValueSlot ReturnValue, llvm::CallBase **CallOrInvoke)
llvm::Type * convertTypeForLoadStore(QualType ASTTy, llvm::Type *LLVMTy=nullptr)
llvm::Value * EmitSMELd1St1(const SVETypeFlags &TypeFlags, llvm::SmallVectorImpl< llvm::Value * > &Ops, unsigned IntID)
Definition ARM.cpp:3822
void EmitOMPTargetSimdDirective(const OMPLoopDirective &S)
Also emits 'target loop'.
void EmitOMPOrderedStandaloneDirective(const OMPOrderedStandaloneDirective &S)
llvm::Value * EmitPointerAuthBlendDiscriminator(llvm::Value *StorageAddress, llvm::Value *Discriminator)
Create the discriminator from the storage address and the entity hash.
void EmitVarDecl(const VarDecl &D)
EmitVarDecl - Emit a local variable declaration.
Definition CGDecl.cpp:211
AggValueSlot::Overlap_t getOverlapForReturnValue()
Determine whether a return value slot may overlap some other object.
bool sanitizePerformTypeCheck() const
Whether any type-checking sanitizers are enabled.
Definition CGExpr.cpp:755
const BreakContinue * GetDestForLoopControlStmt(const LoopControlStmt &S)
Definition CGStmt.cpp:1710
Address EmitExtVectorElementLValue(LValue V)
Generates lvalue for partial ext_vector access.
Definition CGExpr.cpp:2759
bool EmitOMPLinearClauseInit(const OMPLoopDirective &D)
Emit initial code for linear variables.
void SpecialInitFn(CodeGenFunction &Init, const VarDecl &D, llvm::Value *Address)
llvm::Value * EmitCheckedInBoundsGEP(llvm::Type *ElemTy, 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...
void EmitInitializationToLValue(const Expr *E, LValue LV, AggValueSlot::IsZeroed_t IsZeroed=AggValueSlot::IsNotZeroed)
EmitInitializationToLValue - Emit an initializer to an LValue.
Definition CGExpr.cpp:344
void EmitAggExpr(const Expr *E, AggValueSlot AS)
EmitAggExpr - Emit the computation of the specified expression of aggregate type.
llvm::BasicBlock * GetIndirectGotoBlock()
static void EmitOMPTargetParallelGenericLoopDeviceFunction(CodeGenModule &CGM, StringRef ParentName, const OMPTargetParallelGenericLoopDirective &S)
Emit device code for the target parallel loop directive.
llvm::Value * EmitBuiltinAvailable(const VersionTuple &Version)
Definition CGObjC.cpp:4051
void EmitOpenACCHostDataConstruct(const OpenACCHostDataConstruct &S)
Address emitAddrOfRealComponent(Address complex, QualType complexType)
llvm::DILocation * SanitizerAnnotateDebugInfo(ArrayRef< SanitizerKind::SanitizerOrdinal > Ordinals, SanitizerHandler Handler)
Returns debug info, with additional annotation if CGM.getCodeGenOpts().SanitizeAnnotateDebugInfo[Ordi...
EHScopeStack::stable_iterator PrologueCleanupDepth
PrologueCleanupDepth - The cleanup depth enclosing all the cleanups associated with the parameters.
void EmitOpenACCUpdateConstruct(const OpenACCUpdateConstruct &S)
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:448
void EmitOMPUnrollDirective(const OMPUnrollDirective &S)
void EmitOMPStripeDirective(const OMPStripeDirective &S)
Address EmitMSVAListRef(const Expr *E)
Emit a "reference" to a __builtin_ms_va_list; this is always the value of the expression,...
llvm::Value * EmitScalarExpr(const Expr *E, bool IgnoreResultAssign=false)
EmitScalarExpr - Emit the computation of the specified expression of LLVM scalar type,...
const FunctionDecl * getCurrentFunctionDecl() const
RValue EmitLoadOfExtVectorElementLValue(LValue V)
Definition CGExpr.cpp:2701
static bool hasAggregateEvaluationKind(QualType T)
static bool IsWrappedCXXThis(const Expr *E)
Check if E is a C++ "this" pointer wrapped in value-preserving casts.
Definition CGExpr.cpp:1719
void EmitDeleteCall(const FunctionDecl *DeleteFD, llvm::Value *Ptr, QualType DeleteTy, llvm::Value *NumElements=nullptr, CharUnits CookieSize=CharUnits(), llvm::Constant *CalleeOverride=nullptr)
void EmitCallArgs(CallArgList &Args, PrototypeWrapper Prototype, 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.
Definition CGCall.cpp:5089
llvm::Value * EmitMatrixIndexExpr(const Expr *E)
Definition CGExpr.cpp:5407
void EmitCaseStmtRange(const CaseStmt &S, ArrayRef< const Attr * > Attrs)
EmitCaseStmtRange - If case statement range is not too big then add multiple cases to switch instruct...
Definition CGStmt.cpp:1753
ComplexPairTy EmitUnPromotedValue(ComplexPairTy result, QualType PromotionType)
LValue MakeAddrLValue(Address Addr, QualType T, AlignmentSource Source=AlignmentSource::Type)
void EmitOMPSingleDirective(const OMPSingleDirective &S)
void EmitTrapCheck(llvm::Value *Checked, SanitizerHandler CheckHandlerID, bool NoMerge=false, const TrapReason *TR=nullptr)
Create a basic block that will call the trap intrinsic, and emit a conditional branch to it,...
Definition CGExpr.cpp:4656
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:1585
void EmitTrapCallAndMakeUnreachable()
Emit a call to '@llvm.trap()' and clear the current insert point.
Definition CGExpr.cpp:4755
void EmitLambdaVLACapture(const VariableArrayType *VAT, LValue LV)
void FinishFunction(SourceLocation EndLoc=SourceLocation())
FinishFunction - Complete IR generation of the current function.
llvm::Value * LoadCXXThis()
LoadCXXThis - Load the value of 'this'.
llvm::function_ref< void(CodeGenFunction &, SourceLocation, const unsigned, const bool)> CodeGenOrderedTy
void EmitAtomicStore(RValue rvalue, LValue lvalue, bool isInit)
llvm::Value * EmitFromMemory(llvm::Value *Value, QualType Ty)
EmitFromMemory - Change a scalar value from its memory representation to its value representation.
Definition CGExpr.cpp:2295
llvm::Value * EmitCheckedArgForAssume(const Expr *E)
Emits an argument for a call to a __builtin_assume.
llvm::Value * EmitARCStoreStrongCall(Address addr, llvm::Value *value, bool resultIgnored)
Store into a strong object.
Definition CGObjC.cpp:2543
llvm::Function * GenerateCapturedStmtFunction(const CapturedStmt &S)
Creates the outlined function for a CapturedStmt.
Definition CGStmt.cpp:3483
static void EmitOMPTargetParallelForDeviceFunction(CodeGenModule &CGM, StringRef ParentName, const OMPTargetParallelForDirective &S)
Emit device code for the target parallel for directive.
void EnterCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock=false)
const CGFunctionInfo * CurFnInfo
uint64_t getProfileCount(const Stmt *S)
Get the profiler's count for the given statement.
llvm::Value * EmitLoadOfCountedByField(const Expr *Base, const FieldDecl *FD, const FieldDecl *CountDecl)
Build an expression accessing the "counted_by" field.
Definition CGExpr.cpp:1279
Address GetAddrOfLocalVar(const VarDecl *VD)
GetAddrOfLocalVar - Return the address of a local variable.
llvm::Value * EmitNVPTXBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition NVPTX.cpp:468
llvm::Value * getArrayInitIndex()
Get the index of the current ArrayInitLoopExpr, if any.
void EmitDeclStmt(const DeclStmt &S)
Definition CGStmt.cpp:1700
void InitializeVTablePointer(const VPtr &vptr)
Initialize the vtable pointer of the given subobject.
Definition CGClass.cpp:2593
void EmitLabelStmt(const LabelStmt &S)
Definition CGStmt.cpp:781
void EmitUnreachable(SourceLocation Loc)
Emit a reached-unreachable diagnostic if Loc is valid and runtime checking is enabled.
Definition CGExpr.cpp:4644
bool ConstantFoldsToSimpleInteger(const Expr *Cond, bool &Result, bool AllowLabels=false)
ConstantFoldsToSimpleInteger - If the specified expression does not fold to a constant,...
static void EmitOMPTargetTeamsGenericLoopDeviceFunction(CodeGenModule &CGM, StringRef ParentName, const OMPTargetTeamsGenericLoopDirective &S)
Emit device code for the target teams loop directive.
llvm::Value * EmitObjCStringLiteral(const ObjCStringLiteral *E)
Emits an instance of NSConstantString representing the object.
Definition CGObjC.cpp:52
void ErrorUnsupported(const Stmt *S, const char *Type)
ErrorUnsupported - Print out an error that codegen doesn't support the specified stmt yet.
llvm::Value * EmitSVEReinterpret(llvm::Value *Val, llvm::Type *Ty)
Definition ARM.cpp:3910
void EmitOMPTileDirective(const OMPTileDirective &S)
void EmitDecl(const Decl &D, bool EvaluateConditionDecl=false)
EmitDecl - Emit a declaration.
Definition CGDecl.cpp:52
LValue EmitCXXTypeidLValue(const CXXTypeidExpr *E)
Definition CGExpr.cpp:7020
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.
void EmitOMPAtomicDirective(const OMPAtomicDirective &S)
LValue EmitMemberExpr(const MemberExpr *E)
Definition CGExpr.cpp:5761
void EmitOpenACCSetConstruct(const OpenACCSetConstruct &S)
std::pair< llvm::Value *, llvm::Value * > ComplexPairTy
Address ReturnValue
ReturnValue - The temporary alloca to hold the return value.
ConstantEmission tryEmitAsConstant(const DeclRefExpr *RefExpr)
Try to emit a reference to the given value without producing it as an l-value.
Definition CGExpr.cpp:1957
void EmitObjCMRRAutoreleasePoolPop(llvm::Value *Ptr)
Produce the code to do a primitive release.
Definition CGObjC.cpp:2833
LValue EmitLValue(const Expr *E, KnownNonNull_t IsKnownNonNull=NotKnownNonNull)
EmitLValue - Emit code to compute a designator that specifies the location of the expression.
Definition CGExpr.cpp:1777
void EmitStoreThroughGlobalRegLValue(RValue Src, LValue Dst)
Store of global named registers are always calls to intrinsics.
Definition CGExpr.cpp:3251
void EmitAttributedStmt(const AttributedStmt &S)
Definition CGStmt.cpp:791
llvm::Value * EmitARCExtendBlockObject(const Expr *expr)
Definition CGObjC.cpp:3542
bool ShouldXRayInstrumentFunction() const
ShouldXRayInstrument - Return true if the current function should be instrumented with XRay nop sleds...
bool isOpaqueValueEmitted(const OpaqueValueExpr *E)
isOpaqueValueEmitted - Return true if the opaque value expression has already been emitted.
Definition CGExpr.cpp:6610
std::pair< llvm::Value *, CGPointerAuthInfo > EmitOrigPointerRValue(const Expr *E)
Retrieve a pointer rvalue and its ptrauth info.
void EmitOMPParallelMasterTaskLoopDirective(const OMPParallelMasterTaskLoopDirective &S)
void EmitOMPDistributeParallelForSimdDirective(const OMPDistributeParallelForSimdDirective &S)
void markStmtAsUsed(bool Skipped, const Stmt *S)
llvm::Instruction * CurrentFuncletPad
llvm::Value * EmitARCStoreWeak(Address addr, llvm::Value *value, bool ignored)
i8* @objc_storeWeak(i8** addr, i8* value) Returns value.
Definition CGObjC.cpp:2670
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:2982
void EmitOMPSectionDirective(const OMPSectionDirective &S)
llvm::Constant * GenerateDestroyHelperFunction(const CGBlockInfo &blockInfo)
Generate the destroy-helper function for a block closure object: static void block_destroy_helper(blo...
void EnsureInsertPoint()
EnsureInsertPoint - Ensure that an insertion point is defined so that emitted IR has a place to go.
void EmitOMPForSimdDirective(const OMPForSimdDirective &S)
llvm::LLVMContext & getLLVMContext()
bool SawAsmBlock
Whether we processed a Microsoft-style asm block during CodeGen.
void EmitNewArrayInitializer(const CXXNewExpr *E, QualType elementType, llvm::Type *ElementTy, Address NewPtr, llvm::Value *NumElements, llvm::Value *AllocSizeWithoutCookie)
RValue EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E, const CXXMethodDecl *MD, ReturnValueSlot ReturnValue, llvm::CallBase **CallOrInvoke)
ComplexPairTy EmitPromotedValue(ComplexPairTy result, QualType PromotionType)
bool checkIfFunctionMustProgress()
Returns true if a function must make progress, which means the mustprogress attribute can be added.
LValue EmitMatrixElementExpr(const MatrixElementExpr *E)
Definition CGExpr.cpp:2374
void incrementProfileCounter(const Stmt *S, llvm::Value *StepV=nullptr)
Increment the profiler's counter for the given statement by StepV.
void EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S)
Definition CGObjC.cpp:1823
llvm::SmallVector< VPtr, 4 > VPtrsVector
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:727
llvm::Value * EmitTargetBuiltinExpr(unsigned BuiltinID, const CallExpr *E, ReturnValueSlot ReturnValue)
EmitTargetBuiltinExpr - Emit the given builtin call.
void emitAlignmentAssumption(llvm::Value *PtrValue, QualType Ty, SourceLocation Loc, SourceLocation AssumptionLoc, llvm::Value *Alignment, llvm::Value *OffsetValue=nullptr)
static void EmitOMPTargetTeamsDistributeSimdDeviceFunction(CodeGenModule &CGM, StringRef ParentName, const OMPTargetTeamsDistributeSimdDirective &S)
Emit device code for the target teams distribute simd directive.
void EmitObjCAutoreleasePoolPop(llvm::Value *Ptr)
Produce the code to do a primitive release.
Definition CGObjC.cpp:2753
void InitializeVTablePointers(const CXXRecordDecl *ClassDecl)
Definition CGClass.cpp:2713
llvm::Value * EmitObjCRetainNonBlock(llvm::Value *value, llvm::Type *returnType)
Retain the given object, with normal retain semantics.
Definition CGObjC.cpp:2877
void EmitARCCopyWeak(Address dst, Address src)
void @objc_copyWeak(i8** dest, i8** src) Disregards the current value in dest.
Definition CGObjC.cpp:2720
bool isMCDCDecisionExpr(const Expr *E) const
llvm::function_ref< void(CodeGenFunction &, const OMPLoopDirective &, JumpDest)> CodeGenLoopTy
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...
LoadedLValueCapture * CurLoadedLValueCapture
void EmitIndirectGotoStmt(const IndirectGotoStmt &S)
Definition CGStmt.cpp:880
void EmitVariablyModifiedType(QualType Ty)
EmitVLASize - Capture all the sizes for the VLA expressions in the given variably-modified type and s...
static bool ShouldNullCheckClassCastValue(const CastExpr *Cast)
void EmitVTableAssumptionLoad(const VPtr &vptr, Address This)
Emit assumption that vptr load == global vtable.
Definition CGClass.cpp:2412
llvm::Value * EmitHLSLBuiltinExpr(unsigned BuiltinID, const CallExpr *E, ReturnValueSlot ReturnValue)
void MaybeEmitDeferredVarDeclInit(const VarDecl *var)
Definition CGDecl.cpp:2153
void ProcessOrderScopeAMDGCN(llvm::Value *Order, llvm::Value *Scope, llvm::AtomicOrdering &AO, llvm::SyncScope::ID &SSID)
Definition AMDGPU.cpp:447
bool isObviouslyBranchWithoutCleanups(JumpDest Dest) const
isObviouslyBranchWithoutCleanups - Return true if a branch to the specified destination obviously has...
void EmitSEHTryStmt(const SEHTryStmt &S)
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:1861
void EmitOMPParallelMasterDirective(const OMPParallelMasterDirective &S)
llvm::ScalableVectorType * getSVEPredType(const SVETypeFlags &TypeFlags)
Definition ARM.cpp:3347
void emitARCCopyAssignWeak(QualType Ty, Address DstAddr, Address SrcAddr)
Definition CGObjC.cpp:2726
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::CallInst * EmitNounwindRuntimeCall(llvm::FunctionCallee callee, ArrayRef< Address > args, const Twine &name="")
llvm::Value * EmitNonNullRValueCheck(RValue RV, QualType T)
Create a check that a scalar RValue is non-null.
Definition CGExpr.cpp:1671
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:2186
llvm::Value * EmitCMSEClearRecord(llvm::Value *V, llvm::IntegerType *ITy, QualType RTy)
Definition CGCall.cpp:4354
void EmitOMPTaskBasedDirective(const OMPExecutableDirective &S, const OpenMPDirectiveKind CapturedRegion, const RegionCodeGenTy &BodyGen, const TaskGenTy &TaskGen, OMPTaskDataTy &Data)
llvm::Value * EmitNeonCall(llvm::Function *F, SmallVectorImpl< llvm::Value * > &O, const char *name, unsigned shift=0, bool rightshift=false)
Definition ARM.cpp:435
void PopCleanupBlock(bool FallThroughIsBranchThrough=false, bool ForDeactivation=false)
PopCleanupBlock - Will pop the cleanup entry on the stack and process all branch fixups.
void EmitStoreOfScalar(llvm::Value *Value, Address Addr, bool Volatile, QualType Ty, AlignmentSource Source=AlignmentSource::Type, bool isInit=false, bool isNontemporal=false)
EmitStoreOfScalar - Store a scalar value to an address, taking care to appropriately convert from the...
void EmitOMPForDirective(const OMPForDirective &S)
bool hasLabelBeenSeenInCurrentScope() const
Return true if a label was seen in the current scope.
llvm::Function * GenerateSEHFilterFunction(CodeGenFunction &ParentCGF, const SEHExceptStmt &Except)
Create a stub filter function that will ultimately hold the code of the filter expression.
void EmitLabel(const LabelDecl *D)
EmitLabel - Emit the block for the given label.
Definition CGStmt.cpp:723
llvm::Value * EmitDynamicCast(Address V, const CXXDynamicCastExpr *DCE)
void EmitOMPLinearClauseFinal(const OMPLoopDirective &D, const llvm::function_ref< llvm::Value *(CodeGenFunction &)> CondGen)
Emit final code for linear clauses.
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
EmitBlock - Emit the given block.
Definition CGStmt.cpp:658
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:2171
LValue MakeNaturalAlignRawAddrLValue(llvm::Value *V, QualType T)
LValue EmitLoadOfReferenceLValue(Address RefAddr, QualType RefTy, AlignmentSource Source=AlignmentSource::Type)
llvm::Value * EmitSVETupleSetOrGet(const SVETypeFlags &TypeFlags, ArrayRef< llvm::Value * > Ops)
Definition ARM.cpp:3973
QualType BuildFunctionArgList(GlobalDecl GD, FunctionArgList &Args)
llvm::Value * EmitPointerAuthAuth(const CGPointerAuthInfo &Info, llvm::Value *Pointer)
void EmitContinueStmt(const ContinueStmt &S)
Definition CGStmt.cpp:1737
llvm::CallInst * EmitIntrinsicCall(llvm::Intrinsic::ID ID, ArrayRef< llvm::Type * > Types, ArrayRef< llvm::Value * > Args, const Twine &Name="")
llvm::Value * EmitCXXTypeidExpr(const CXXTypeidExpr *E)
void EmitOMPSimdFinal(const OMPLoopDirective &D, const llvm::function_ref< llvm::Value *(CodeGenFunction &)> CondGen)
llvm::Type * ConvertType(const TypeDecl *T)
This class organizes the cross-function state that is used while generating LLVM code.
const llvm::DataLayout & getDataLayout() const
Per-function PGO state.
Definition CodeGenPGO.h:29
This class organizes the cross-module state that is used while lowering AST types to LLVM types.
A specialization of Address that requires the address to be an LLVM Constant.
Definition Address.h:296
static ConstantAddress invalid()
Definition Address.h:304
DominatingValue< Address >::saved_type AggregateAddr
static saved_type save(CodeGenFunction &CGF, RValue value)
ConditionalCleanup stores the saved form of its parameters, then restores them and performs the clean...
A saved depth on the scope stack.
A stack of scopes which respond to exceptions, including cleanups and catch blocks.
static stable_iterator stable_end()
Create a stable reference to the bottom of the EH stack.
FunctionArgList - Type for representing both the decl and type of parameters to a function.
Definition CGCall.h:378
LValue - This represents an lvalue references.
Definition CGValue.h:183
CharUnits getAlignment() const
Definition CGValue.h:355
static LValue MakeAddr(Address Addr, QualType type, ASTContext &Context, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
Definition CGValue.h:454
QualType getType() const
Definition CGValue.h:303
llvm::Value * emitRawPointer(CodeGenFunction &CGF) const
A stack of loop information corresponding to loop nesting levels.
Definition CGLoopInfo.h:158
RValue - This trivial value class is used to represent the result of an expression that is evaluated.
Definition CGValue.h:42
static RValue get(llvm::Value *V)
Definition CGValue.h:99
An abstract representation of an aligned address.
Definition Address.h:42
static RawAddress invalid()
Definition Address.h:61
Class provides a way to call simple version of codegen for OpenMP region, or an advanced with possibl...
ReturnValueSlot - Contains the address where the return value of a function can be stored,...
Definition CGCall.h:384
TargetCodeGenInfo - This class organizes various target-specific codegeneration issues,...
Definition TargetInfo.h:80
The class detects jumps which bypass local variables declaration: goto L; int a; L:
CompoundAssignOperator - For compound assignments (e.g.
Definition Expr.h:4369
CompoundLiteralExpr - [C99 6.5.2.5].
Definition Expr.h:3674
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition Stmt.h:1751
Represents an expression that might suspend coroutine execution; either a co_await or co_yield expres...
Definition ExprCXX.h:5309
SourceLocExprScopeGuard(const Expr *DefaultExpr, CurrentSourceLocExprScope &Current)
Represents the current source location and context used to determine the value of the source location...
A reference to a declared variable, function, enum, etc.
Definition Expr.h:1315
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition DeclBase.h:996
This represents one expression.
Definition Expr.h:114
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
Definition Expr.cpp:3125
QualType getType() const
Definition Expr.h:146
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Definition Expr.h:6696
Represents a member of a struct/union/class.
Definition Decl.h:3341
Represents a function declaration or definition.
Definition Decl.h:2082
Represents a prototype with parameter type info, e.g.
Definition TypeBase.h:5548
GlobalDecl - represents a global declaration.
Definition GlobalDecl.h:60
const Decl * getDecl() const
Definition GlobalDecl.h:115
GotoStmt - This represents a direct goto.
Definition Stmt.h:2980
This class represents temporary values used to represent inout and out arguments in HLSL.
Definition Expr.h:7483
IfStmt - This represents an if/then/else.
Definition Stmt.h:2270
IndirectGotoStmt - This represents an indirect goto.
Definition Stmt.h:3019
Describes an C or C++ initializer list.
Definition Expr.h:5377
Represents the declaration of a label.
Definition Decl.h:526
LabelStmt - Represents a label, which has a substatement.
Definition Stmt.h:2157
FPExceptionModeKind
Possible floating point exception behavior.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Represents a point when we exit a loop.
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition ExprCXX.h:4974
MatrixSingleSubscriptExpr - Matrix single subscript expression for the MatrixType extension when you ...
Definition Expr.h:2864
MatrixSubscriptExpr - Matrix subscript expression for the MatrixType extension.
Definition Expr.h:2934
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition Expr.h:3433
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition TypeBase.h:3751
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp,...
Definition ExprObjC.h:219
Represents Objective-C's @synchronized statement.
Definition StmtObjC.h:303
Represents Objective-C's @throw statement.
Definition StmtObjC.h:358
Represents Objective-C's @try ... @catch ... @finally statement.
Definition StmtObjC.h:167
Represents Objective-C's @autoreleasepool Statement.
Definition StmtObjC.h:394
ObjCBoxedExpr - used for generalized expression boxing.
Definition ExprObjC.h:158
ObjCContainerDecl - Represents a container for method declarations.
Definition DeclObjC.h:954
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
Definition ExprObjC.h:341
ObjCEncodeExpr, used for @encode in Objective-C.
Definition ExprObjC.h:440
Represents Objective-C's collection statement.
Definition StmtObjC.h:23
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition DeclObjC.h:2603
Represents an ObjC class declaration.
Definition DeclObjC.h:1160
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
Definition ExprObjC.h:1530
ObjCIvarDecl - Represents an ObjC instance variable.
Definition DeclObjC.h:1958
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition ExprObjC.h:581
An expression that sends a message to the given Objective-C object or class.
Definition ExprObjC.h:972
ObjCMethodDecl - Represents an instance or class method declaration.
Definition DeclObjC.h:140
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Definition DeclObjC.h:2811
ObjCProtocolExpr used for protocol expression in Objective-C.
Definition ExprObjC.h:537
ObjCSelectorExpr used for @selector in Objective-C.
Definition ExprObjC.h:485
ObjCStringLiteral, used for Objective-C string literals i.e.
Definition ExprObjC.h:83
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
Definition Expr.h:1223
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Definition Expr.h:1273
Represents a parameter to a function.
Definition Decl.h:1832
Pointer-authentication qualifiers.
Definition TypeBase.h:153
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition TypeBase.h:3403
[C99 6.4.2.2] - A predefined identifier such as func.
Definition Expr.h:2074
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition Expr.h:6890
A (possibly-)qualified type.
Definition TypeBase.h:938
The collection of all-type qualifiers we support.
Definition TypeBase.h:332
specific_decl_iterator< FieldDecl > field_iterator
Definition Decl.h:4708
Flags to identify the types for overloaded SVE builtins.
Scope - A scope is a transient data structure that is used while parsing the program.
Definition Scope.h:41
Encodes a location in the source.
A trivial tuple used to represent a source range.
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Definition Expr.h:4664
Stmt - This represents one statement.
Definition Stmt.h:85
Likelihood
The likelihood of a branch being taken.
Definition Stmt.h:1447
@ LH_None
No attribute set or branches of the IfStmt have the same attribute.
Definition Stmt.h:1449
StringLiteral - This represents a string literal expression, e.g.
Definition Expr.h:1844
Exposes information about the current target.
Definition TargetInfo.h:228
Represents a declaration of a type.
Definition Decl.h:3696
bool isReferenceType() const
Definition TypeBase.h:8839
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition Expr.h:2313
Represents a call to the builtin function __builtin_va_arg.
Definition Expr.h:5026
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:714
QualType getType() const
Definition Decl.h:725
Represents a variable declaration or definition.
Definition Decl.h:934
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition Decl.cpp:2238
bool isLocalVarDeclOrParm() const
Similar to isLocalVarDecl but also includes parameters.
Definition Decl.h:1287
Represents a C array with a specified size that is not an integer-constant-expression.
Definition TypeBase.h:4064
Expr * getSizeExpr() const
Definition TypeBase.h:4078
WhileStmt - This represents a 'while' stmt.
Definition Stmt.h:2708
Defines the clang::TargetInfo interface.
EvaluationOrder
The order in which the arguments of a call must be evaluated.
Definition CallUtils.h:29
AlignmentSource
The source of the alignment of an l-value; an expression of confidence in the alignment actually matc...
Definition CGValue.h:142
@ Type
The l-value was considered opaque, so the alignment was determined from a type.
Definition CGValue.h:155
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
Definition CGValue.h:146
TypeEvaluationKind
The kind of evaluation to perform on values of a particular type.
@ NormalCleanup
Denotes a cleanup that should run when a scope is exited using normal control flow (falling off the e...
ARCPreciseLifetime_t
Does an ARC strong l-value have precise lifetime?
Definition CGValue.h:136
VE builtins.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const AstTypeMatcher< ArrayType > arrayType
const AstTypeMatcher< ComplexType > complexType
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
@ Address
A pointer to a ValueDecl.
Definition Primitives.h:28
Top level wrappers for InstallAPI frontend operations.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
CXXCtorType
C++ constructor types.
Definition ABI.h:24
bool isa(CodeGen::Address addr)
Definition Address.h:330
@ Success
Annotation was successful.
Definition Parser.h:65
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
CapturedRegionKind
The different kinds of captured statement.
@ CR_Default
OpenACCComputeConstruct(OpenACCDirectiveKind K, SourceLocation Start, SourceLocation DirectiveLoc, SourceLocation End, ArrayRef< const OpenACCClause * > Clauses, Stmt *StructuredBlock)
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
Definition Linkage.h:24
@ Result
The result type of a method or function.
Definition TypeBase.h:906
const FunctionProtoType * T
CXXDtorType
C++ destructor types.
Definition ABI.h:34
LangAS
Defines the address space values used by the address space qualifier of QualType.
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
Definition OpenMPKinds.h:25
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
Definition Specifiers.h:136
llvm::fp::ExceptionBehavior ToConstrainedExceptMD(LangOptions::FPExceptionModeKind Kind)
U cast(CodeGen::Address addr)
Definition Address.h:327
@ Interface
The "__interface" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:6151
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30
#define false
Definition stdbool.h:26
#define true
Definition stdbool.h:25
Structure with information about how a bitfield should be accessed.
llvm::SmallVector< llvm::AllocaInst * > Take()
llvm::AssertingVH< llvm::BasicBlock > Block
CXXDefaultArgExprScope(CodeGenFunction &CGF, const CXXDefaultArgExpr *E)
FMVResolverOption(llvm::Function *F, ArrayRef< StringRef > Feats, std::optional< StringRef > Arch=std::nullopt)
A jump destination is an abstract label, branching to which may require a jump out through normal cle...
void setScopeDepth(EHScopeStack::stable_iterator depth)
EHScopeStack::stable_iterator getScopeDepth() const
JumpDest(llvm::BasicBlock *Block, EHScopeStack::stable_iterator Depth, unsigned Index)
Header for data within LifetimeExtendedCleanupStack.
unsigned Size
The size of the following cleanup object.
unsigned IsConditional
Whether this is a conditional cleanup.
Records the l-value that ScalarExprEmitter loads from when it emits a specific expression.
const Expr * E
The expression whose l-value is recorded.
std::optional< LValue > LV
The recorded l-value, set if E was loaded by ScalarExprEmitter.
static Address getAddrOfThreadPrivate(CodeGenFunction &CGF, const VarDecl *VD, Address VDAddr, SourceLocation Loc)
Returns address of the threadprivate variable for the current thread.
llvm::OpenMPIRBuilder::InsertPointTy InsertPointTy
static void EmitOMPOutlinedRegionBody(CodeGenFunction &CGF, const Stmt *RegionBodyStmt, InsertPointTy AllocaIP, InsertPointTy CodeGenIP, Twine RegionName)
Emit the body of an OMP region that will be outlined in OpenMPIRBuilder::finalize().
static Address getAddressOfLocalVariable(CodeGenFunction &CGF, const VarDecl *VD)
Gets the OpenMP-specific address of the local variable /p VD.
static std::string getNameWithSeparators(ArrayRef< StringRef > Parts, StringRef FirstSeparator=".", StringRef Separator=".")
Get the platform-specific name separator.
static void FinalizeOMPRegion(CodeGenFunction &CGF, InsertPointTy IP)
Emit the Finalization for an OMP region.
static void EmitOMPInlinedRegionBody(CodeGenFunction &CGF, const Stmt *RegionBodyStmt, InsertPointTy AllocaIP, InsertPointTy CodeGenIP, Twine RegionName)
Emit the body of an OMP region.
static void EmitCaptureStmt(CodeGenFunction &CGF, llvm::BasicBlock *CodeGenIPBB, llvm::BasicBlock &FiniBB, llvm::Function *Fn, ArrayRef< llvm::Value * > Args)
OMPBuilderCBHelpers & operator=(const OMPBuilderCBHelpers &)=delete
OMPBuilderCBHelpers(const OMPBuilderCBHelpers &)=delete
OMPTargetDataInfo(Address BasePointersArray, Address PointersArray, Address SizesArray, Address MappersArray, unsigned NumberOfTargetItems)
llvm::PointerUnion< const FunctionProtoType *, const ObjCMethodDecl * > P
Struct with all information about dynamic [sub]class needed to set vptr.
This structure provides a set of types that are commonly used during IR emission.
saved_type(llvm::AllocaInst *Alloca, llvm::Type *Ty)
Helper class with most of the code for saving a value for a conditional expression cleanup.
static llvm::Value * restore(CodeGenFunction &CGF, saved_type value)
static saved_type save(CodeGenFunction &CGF, llvm::Value *value)
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)
static type restore(CodeGenFunction &CGF, saved_type value)
static saved_type save(CodeGenFunction &CGF, type value)
static saved_type save(CodeGenFunction &CGF, type value)
static type restore(CodeGenFunction &CGF, saved_type value)
A metaprogramming class for ensuring that a value will dominate an arbitrary position in a function.
static bool needsSaving(type value)
static saved_type save(CodeGenFunction &CGF, type value)
The this pointer adjustment as well as an optional return adjustment for a thunk.
Definition Thunk.h:157