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