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