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