#include "CodeGenFunction.h"
#include "CGBlocks.h"
#include "CGCUDARuntime.h"
#include "CGCXXABI.h"
#include "CGCleanup.h"
#include "CGDebugInfo.h"
#include "CGHLSLRuntime.h"
#include "CGOpenMPRuntime.h"
#include "CodeGenModule.h"
#include "CodeGenPGO.h"
#include "TargetInfo.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTLambda.h"
#include "clang/AST/Attr.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/Expr.h"
#include "clang/AST/StmtCXX.h"
#include "clang/AST/StmtObjC.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/CodeGenOptions.h"
#include "clang/Basic/TargetBuiltins.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/CodeGen/CGFunctionInfo.h"
#include "clang/Frontend/FrontendDiagnostic.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/FPEnv.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/Operator.h"
#include "llvm/Support/CRC.h"
#include "llvm/Support/xxhash.h"
#include "llvm/Transforms/Scalar/LowerExpectIntrinsic.h"
#include "llvm/Transforms/Utils/PromoteMemToReg.h"
#include <optional>
usingnamespaceclang;
usingnamespaceCodeGen;
namespace llvm {
extern cl::opt<bool> EnableSingleByteCoverage;
}
static bool shouldEmitLifetimeMarkers(const CodeGenOptions &CGOpts,
const LangOptions &LangOpts) { … }
CodeGenFunction::CodeGenFunction(CodeGenModule &cgm, bool suppressNewContext)
: … { … }
CodeGenFunction::~CodeGenFunction() { … }
llvm::fp::ExceptionBehavior
clang::ToConstrainedExceptMD(LangOptions::FPExceptionModeKind Kind) { … }
void CodeGenFunction::SetFastMathFlags(FPOptions FPFeatures) { … }
CodeGenFunction::CGFPOptionsRAII::CGFPOptionsRAII(CodeGenFunction &CGF,
const Expr *E)
: … { … }
CodeGenFunction::CGFPOptionsRAII::CGFPOptionsRAII(CodeGenFunction &CGF,
FPOptions FPFeatures)
: … { … }
void CodeGenFunction::CGFPOptionsRAII::ConstructorHelper(FPOptions FPFeatures) { … }
CodeGenFunction::CGFPOptionsRAII::~CGFPOptionsRAII() { … }
static LValue
makeNaturalAlignAddrLValue(llvm::Value *V, QualType T, bool ForPointeeType,
bool MightBeSigned, CodeGenFunction &CGF,
KnownNonNull_t IsKnownNonNull = NotKnownNonNull) { … }
LValue
CodeGenFunction::MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T,
KnownNonNull_t IsKnownNonNull) { … }
LValue
CodeGenFunction::MakeNaturalAlignPointeeAddrLValue(llvm::Value *V, QualType T) { … }
LValue CodeGenFunction::MakeNaturalAlignRawAddrLValue(llvm::Value *V,
QualType T) { … }
LValue CodeGenFunction::MakeNaturalAlignPointeeRawAddrLValue(llvm::Value *V,
QualType T) { … }
llvm::Type *CodeGenFunction::ConvertTypeForMem(QualType T) { … }
llvm::Type *CodeGenFunction::ConvertType(QualType T) { … }
llvm::Type *CodeGenFunction::convertTypeForLoadStore(QualType ASTTy,
llvm::Type *LLVMTy) { … }
TypeEvaluationKind CodeGenFunction::getEvaluationKind(QualType type) { … }
llvm::DebugLoc CodeGenFunction::EmitReturnBlock() { … }
static void EmitIfUsed(CodeGenFunction &CGF, llvm::BasicBlock *BB) { … }
void CodeGenFunction::FinishFunction(SourceLocation EndLoc) { … }
bool CodeGenFunction::ShouldInstrumentFunction() { … }
bool CodeGenFunction::ShouldSkipSanitizerInstrumentation() { … }
bool CodeGenFunction::ShouldXRayInstrumentFunction() const { … }
bool CodeGenFunction::AlwaysEmitXRayCustomEvents() const { … }
bool CodeGenFunction::AlwaysEmitXRayTypedEvents() const { … }
llvm::ConstantInt *
CodeGenFunction::getUBSanFunctionTypeHash(QualType Ty) const { … }
void CodeGenFunction::EmitKernelMetadata(const FunctionDecl *FD,
llvm::Function *Fn) { … }
static bool endsWithReturn(const Decl* F) { … }
void CodeGenFunction::markAsIgnoreThreadCheckingAtRuntime(llvm::Function *Fn) { … }
bool CodeGenFunction::requiresReturnValueCheck() const { … }
static bool matchesStlAllocatorFn(const Decl *D, const ASTContext &Ctx) { … }
bool CodeGenFunction::isInAllocaArgument(CGCXXABI &ABI, QualType Ty) { … }
bool CodeGenFunction::hasInAllocaArg(const CXXMethodDecl *MD) { … }
static llvm::Constant *getPrologueSignature(CodeGenModule &CGM,
const FunctionDecl *FD) { … }
void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
llvm::Function *Fn,
const CGFunctionInfo &FnInfo,
const FunctionArgList &Args,
SourceLocation Loc,
SourceLocation StartLoc) { … }
void CodeGenFunction::EmitFunctionBody(const Stmt *Body) { … }
void CodeGenFunction::EmitBlockWithFallThrough(llvm::BasicBlock *BB,
const Stmt *S) { … }
static void TryMarkNoThrow(llvm::Function *F) { … }
QualType CodeGenFunction::BuildFunctionArgList(GlobalDecl GD,
FunctionArgList &Args) { … }
void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn,
const CGFunctionInfo &FnInfo) { … }
bool CodeGenFunction::ContainsLabel(const Stmt *S, bool IgnoreCaseStmts) { … }
bool CodeGenFunction::containsBreak(const Stmt *S) { … }
bool CodeGenFunction::mightAddDeclToScope(const Stmt *S) { … }
bool CodeGenFunction::ConstantFoldsToSimpleInteger(const Expr *Cond,
bool &ResultBool,
bool AllowLabels) { … }
bool CodeGenFunction::ConstantFoldsToSimpleInteger(const Expr *Cond,
llvm::APSInt &ResultInt,
bool AllowLabels) { … }
const Expr *CodeGenFunction::stripCond(const Expr *C) { … }
bool CodeGenFunction::isInstrumentedCondition(const Expr *C) { … }
void CodeGenFunction::EmitBranchToCounterBlock(
const Expr *Cond, BinaryOperator::Opcode LOp, llvm::BasicBlock *TrueBlock,
llvm::BasicBlock *FalseBlock, uint64_t TrueCount ,
Stmt::Likelihood LH , const Expr *CntrIdx ) { … }
void CodeGenFunction::EmitBranchOnBoolExpr(
const Expr *Cond, llvm::BasicBlock *TrueBlock, llvm::BasicBlock *FalseBlock,
uint64_t TrueCount, Stmt::Likelihood LH, const Expr *ConditionalOp) { … }
void CodeGenFunction::ErrorUnsupported(const Stmt *S, const char *Type) { … }
static void emitNonZeroVLAInit(CodeGenFunction &CGF, QualType baseType,
Address dest, Address src,
llvm::Value *sizeInChars) { … }
void
CodeGenFunction::EmitNullInitialization(Address DestPtr, QualType Ty) { … }
llvm::BlockAddress *CodeGenFunction::GetAddrOfLabel(const LabelDecl *L) { … }
llvm::BasicBlock *CodeGenFunction::GetIndirectGotoBlock() { … }
llvm::Value *CodeGenFunction::emitArrayLength(const ArrayType *origArrayType,
QualType &baseType,
Address &addr) { … }
CodeGenFunction::VlaSizePair CodeGenFunction::getVLASize(QualType type) { … }
CodeGenFunction::VlaSizePair
CodeGenFunction::getVLASize(const VariableArrayType *type) { … }
CodeGenFunction::VlaSizePair
CodeGenFunction::getVLAElements1D(QualType type) { … }
CodeGenFunction::VlaSizePair
CodeGenFunction::getVLAElements1D(const VariableArrayType *Vla) { … }
void CodeGenFunction::EmitVariablyModifiedType(QualType type) { … }
Address CodeGenFunction::EmitVAListRef(const Expr* E) { … }
Address CodeGenFunction::EmitMSVAListRef(const Expr *E) { … }
void CodeGenFunction::EmitDeclRefExprDbgValue(const DeclRefExpr *E,
const APValue &Init) { … }
CodeGenFunction::PeepholeProtection
CodeGenFunction::protectFromPeepholes(RValue rvalue) { … }
void CodeGenFunction::unprotectFromPeepholes(PeepholeProtection protection) { … }
void CodeGenFunction::emitAlignmentAssumption(llvm::Value *PtrValue,
QualType Ty, SourceLocation Loc,
SourceLocation AssumptionLoc,
llvm::Value *Alignment,
llvm::Value *OffsetValue) { … }
void CodeGenFunction::emitAlignmentAssumption(llvm::Value *PtrValue,
const Expr *E,
SourceLocation AssumptionLoc,
llvm::Value *Alignment,
llvm::Value *OffsetValue) { … }
llvm::Value *CodeGenFunction::EmitAnnotationCall(llvm::Function *AnnotationFn,
llvm::Value *AnnotatedVal,
StringRef AnnotationStr,
SourceLocation Location,
const AnnotateAttr *Attr) { … }
void CodeGenFunction::EmitVarAnnotations(const VarDecl *D, llvm::Value *V) { … }
Address CodeGenFunction::EmitFieldAnnotations(const FieldDecl *D,
Address Addr) { … }
CodeGenFunction::CGCapturedStmtInfo::~CGCapturedStmtInfo() { … }
CodeGenFunction::SanitizerScope::SanitizerScope(CodeGenFunction *CGF)
: … { … }
CodeGenFunction::SanitizerScope::~SanitizerScope() { … }
void CodeGenFunction::InsertHelper(llvm::Instruction *I,
const llvm::Twine &Name,
llvm::BasicBlock::iterator InsertPt) const { … }
void CGBuilderInserter::InsertHelper(
llvm::Instruction *I, const llvm::Twine &Name,
llvm::BasicBlock::iterator InsertPt) const { … }
void CodeGenFunction::checkTargetFeatures(const CallExpr *E,
const FunctionDecl *TargetDecl) { … }
void CodeGenFunction::checkTargetFeatures(SourceLocation Loc,
const FunctionDecl *TargetDecl) { … }
void CodeGenFunction::EmitSanitizerStatReport(llvm::SanitizerStatKind SSK) { … }
void CodeGenFunction::EmitKCFIOperandBundle(
const CGCallee &Callee, SmallVectorImpl<llvm::OperandBundleDef> &Bundles) { … }
llvm::Value *CodeGenFunction::FormAArch64ResolverCondition(
const MultiVersionResolverOption &RO) { … }
llvm::Value *CodeGenFunction::FormX86ResolverCondition(
const MultiVersionResolverOption &RO) { … }
static void CreateMultiVersionResolverReturn(CodeGenModule &CGM,
llvm::Function *Resolver,
CGBuilderTy &Builder,
llvm::Function *FuncToReturn,
bool SupportsIFunc) { … }
void CodeGenFunction::EmitMultiVersionResolver(
llvm::Function *Resolver, ArrayRef<MultiVersionResolverOption> Options) { … }
static int getPriorityFromAttrString(StringRef AttrStr) { … }
void CodeGenFunction::EmitRISCVMultiVersionResolver(
llvm::Function *Resolver, ArrayRef<MultiVersionResolverOption> Options) { … }
void CodeGenFunction::EmitAArch64MultiVersionResolver(
llvm::Function *Resolver, ArrayRef<MultiVersionResolverOption> Options) { … }
void CodeGenFunction::EmitX86MultiVersionResolver(
llvm::Function *Resolver, ArrayRef<MultiVersionResolverOption> Options) { … }
void CodeGenFunction::emitAlignmentAssumptionCheck(
llvm::Value *Ptr, QualType Ty, SourceLocation Loc,
SourceLocation SecondaryLoc, llvm::Value *Alignment,
llvm::Value *OffsetValue, llvm::Value *TheCheck,
llvm::Instruction *Assumption) { … }
llvm::DebugLoc CodeGenFunction::SourceLocToDebugLoc(SourceLocation Location) { … }
llvm::Value *
CodeGenFunction::emitCondLikelihoodViaExpectIntrinsic(llvm::Value *Cond,
Stmt::Likelihood LH) { … }
llvm::Value *CodeGenFunction::emitBoolVecConversion(llvm::Value *SrcVec,
unsigned NumElementsDst,
const llvm::Twine &Name) { … }
void CodeGenFunction::EmitPointerAuthOperandBundle(
const CGPointerAuthInfo &PointerAuth,
SmallVectorImpl<llvm::OperandBundleDef> &Bundles) { … }
static llvm::Value *EmitPointerAuthCommon(CodeGenFunction &CGF,
const CGPointerAuthInfo &PointerAuth,
llvm::Value *Pointer,
unsigned IntrinsicID) { … }
llvm::Value *
CodeGenFunction::EmitPointerAuthSign(const CGPointerAuthInfo &PointerAuth,
llvm::Value *Pointer) { … }
static llvm::Value *EmitStrip(CodeGenFunction &CGF,
const CGPointerAuthInfo &PointerAuth,
llvm::Value *Pointer) { … }
llvm::Value *
CodeGenFunction::EmitPointerAuthAuth(const CGPointerAuthInfo &PointerAuth,
llvm::Value *Pointer) { … }