13#ifndef LLVM_CLANG_LIB_CODEGEN_CODEGENFUNCTION_H
14#define LLVM_CLANG_LIB_CODEGEN_CODEGENFUNCTION_H
38#include "llvm/ADT/ArrayRef.h"
39#include "llvm/ADT/DenseMap.h"
40#include "llvm/ADT/MapVector.h"
41#include "llvm/ADT/SmallVector.h"
42#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
43#include "llvm/IR/Instructions.h"
44#include "llvm/IR/ValueHandle.h"
45#include "llvm/Support/Debug.h"
46#include "llvm/Transforms/Utils/SanitizerStats.h"
56class CanonicalLoopInfo;
61class CXXDestructorDecl;
67class FunctionProtoType;
69class ObjCContainerDecl;
70class ObjCInterfaceDecl;
73class ObjCImplementationDecl;
74class ObjCPropertyImplDecl;
77class ObjCForCollectionStmt;
80class ObjCAtSynchronizedStmt;
81class ObjCAutoreleasePoolStmt;
82class OMPUseDevicePtrClause;
83class OMPUseDeviceAddrClause;
85class OMPExecutableDirective;
87namespace analyze_os_log {
88class OSLogBufferLayout;
97class BlockByrefHelpers;
100class RegionCodeGenTy;
101class TargetCodeGenInfo;
116#define LIST_SANITIZER_CHECKS \
117 SANITIZER_CHECK(AddOverflow, add_overflow, 0) \
118 SANITIZER_CHECK(BuiltinUnreachable, builtin_unreachable, 0) \
119 SANITIZER_CHECK(CFICheckFail, cfi_check_fail, 0) \
120 SANITIZER_CHECK(DivremOverflow, divrem_overflow, 0) \
121 SANITIZER_CHECK(DynamicTypeCacheMiss, dynamic_type_cache_miss, 0) \
122 SANITIZER_CHECK(FloatCastOverflow, float_cast_overflow, 0) \
123 SANITIZER_CHECK(FunctionTypeMismatch, function_type_mismatch, 0) \
124 SANITIZER_CHECK(ImplicitConversion, implicit_conversion, 0) \
125 SANITIZER_CHECK(InvalidBuiltin, invalid_builtin, 0) \
126 SANITIZER_CHECK(InvalidObjCCast, invalid_objc_cast, 0) \
127 SANITIZER_CHECK(LoadInvalidValue, load_invalid_value, 0) \
128 SANITIZER_CHECK(MissingReturn, missing_return, 0) \
129 SANITIZER_CHECK(MulOverflow, mul_overflow, 0) \
130 SANITIZER_CHECK(NegateOverflow, negate_overflow, 0) \
131 SANITIZER_CHECK(NullabilityArg, nullability_arg, 0) \
132 SANITIZER_CHECK(NullabilityReturn, nullability_return, 1) \
133 SANITIZER_CHECK(NonnullArg, nonnull_arg, 0) \
134 SANITIZER_CHECK(NonnullReturn, nonnull_return, 1) \
135 SANITIZER_CHECK(OutOfBounds, out_of_bounds, 0) \
136 SANITIZER_CHECK(PointerOverflow, pointer_overflow, 0) \
137 SANITIZER_CHECK(ShiftOutOfBounds, shift_out_of_bounds, 0) \
138 SANITIZER_CHECK(SubOverflow, sub_overflow, 0) \
139 SANITIZER_CHECK(TypeMismatch, type_mismatch, 1) \
140 SANITIZER_CHECK(AlignmentAssumption, alignment_assumption, 0) \
141 SANITIZER_CHECK(VLABoundNotPositive, vla_bound_not_positive, 0) \
142 SANITIZER_CHECK(BoundsSafety, bounds_safety, 0)
145#define SANITIZER_CHECK(Enum, Name, Version) Enum,
147#undef SANITIZER_CHECK
153 typedef llvm::PointerIntPair<llvm::Value*, 1, bool>
saved_type;
161 if (!isa<llvm::Instruction>(value))
return false;
164 llvm::BasicBlock *block = cast<llvm::Instruction>(value)->getParent();
165 return (block != &block->getParent()->getEntryBlock());
215 enum Kind { ScalarLiteral, ScalarAddress, AggregateLiteral,
216 AggregateAddress, ComplexAddress };
223 LLVM_PREFERRED_TYPE(Kind)
231 : Vals{Val1, Val2}, K(ComplexAddress) {}
234 : AggregateAddr(AggregateAddr), K(K) {}
245 return saved_type::needsSaving(value);
248 return saved_type::save(CGF, value);
251 return value.restore(CGF);
269 :
Block(
Block), ScopeDepth(Depth), Index(Index) {}
271 bool isValid()
const {
return Block !=
nullptr; }
272 llvm::BasicBlock *
getBlock()
const {
return Block; }
282 llvm::BasicBlock *Block;
330 const unsigned,
const bool)>
334 typedef llvm::function_ref<std::pair<LValue, LValue>(
339 typedef llvm::function_ref<std::pair<llvm::Value *, llvm::Value *>(
347 llvm::BasicBlock::iterator InsertPt)
const;
365 std::unique_ptr<CGCoroData>
Data;
396 Twine
const &SuspendPointName,
425 return !LabelMap.empty();
441 llvm::AssertingVH<llvm::Instruction> PostAllocaInsertPt =
nullptr;
447 if (!PostAllocaInsertPt) {
449 "Expected static alloca insertion point at function prologue");
451 "EBB should be entry block of the current code gen function");
453 PostAllocaInsertPt->setName(
"postallocapt");
457 return PostAllocaInsertPt;
464 : Kind(K), ThisValue(nullptr), CXXThisFieldDecl(nullptr) {}
467 : Kind(K), ThisValue(nullptr), CXXThisFieldDecl(nullptr) {
470 S.getCapturedRecordDecl()->field_begin();
473 I !=
E; ++I, ++Field) {
474 if (I->capturesThis())
475 CXXThisFieldDecl = *Field;
476 else if (I->capturesVariable())
477 CaptureFields[I->getCapturedVar()->getCanonicalDecl()] = *Field;
478 else if (I->capturesVariableByCopy())
479 CaptureFields[I->getCapturedVar()->getCanonicalDecl()] = *Field;
514 return CaptureFields;
522 llvm::SmallDenseMap<const VarDecl *, FieldDecl *> CaptureFields;
526 llvm::Value *ThisValue;
550 const Decl *CalleeDecl;
557 return isa_and_nonnull<FunctionDecl>(CalleeDecl);
561 if (
const auto *FD = dyn_cast<FunctionDecl>(CalleeDecl))
562 return FD->getNumParams();
563 return cast<ObjCMethodDecl>(CalleeDecl)->param_size();
566 if (
const auto *FD = dyn_cast<FunctionDecl>(CalleeDecl))
567 return FD->getParamDecl(I);
568 return *(cast<ObjCMethodDecl>(CalleeDecl)->param_begin() + I);
621 HLSLControlFlowHintAttr::SpellingNotCalculated;