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