38#include "llvm/ABI/FunctionInfo.h"
39#include "llvm/ABI/IRTypeMapper.h"
40#include "llvm/ABI/TargetInfo.h"
41#include "llvm/ABI/Types.h"
42#include "llvm/ADT/STLExtras.h"
43#include "llvm/ADT/StringExtras.h"
44#include "llvm/Analysis/ValueTracking.h"
45#include "llvm/IR/Assumptions.h"
46#include "llvm/IR/AttributeMask.h"
47#include "llvm/IR/Attributes.h"
48#include "llvm/IR/CallingConv.h"
49#include "llvm/IR/DataLayout.h"
50#include "llvm/IR/DebugInfoMetadata.h"
51#include "llvm/IR/InlineAsm.h"
52#include "llvm/IR/IntrinsicInst.h"
53#include "llvm/IR/Intrinsics.h"
54#include "llvm/IR/Type.h"
55#include "llvm/Transforms/Utils/Local.h"
68 if (Target.getTriple().isSPIROrSPIRV())
69 return llvm::CallingConv::SPIR_FUNC;
70 return llvm::CallingConv::C;
72 return llvm::CallingConv::X86_StdCall;
74 return llvm::CallingConv::X86_FastCall;
76 return llvm::CallingConv::X86_RegCall;
78 return llvm::CallingConv::X86_ThisCall;
80 return llvm::CallingConv::Win64;
82 return llvm::CallingConv::X86_64_SysV;
84 return llvm::CallingConv::ARM_AAPCS;
86 return llvm::CallingConv::ARM_AAPCS_VFP;
88 return llvm::CallingConv::Intel_OCL_BI;
91 return llvm::CallingConv::C;
94 return llvm::CallingConv::X86_VectorCall;
96 return llvm::CallingConv::AArch64_VectorCall;
98 return llvm::CallingConv::AArch64_SVE_VectorCall;
100 return CGM.getTargetCodeGenInfo().getDeviceKernelCallingConv();
102 return llvm::CallingConv::PreserveMost;
104 return llvm::CallingConv::PreserveAll;
106 return llvm::CallingConv::Swift;
108 return llvm::CallingConv::SwiftTail;
110 return llvm::CallingConv::M68k_RTD;
112 return llvm::CallingConv::PreserveNone;
116#define CC_VLS_CASE(ABI_VLEN) \
117 case CC_RISCVVLSCall_##ABI_VLEN: \
118 return llvm::CallingConv::RISCV_VLSCall_##ABI_VLEN;
133 llvm_unreachable(
"unhandled calling convention");
144 RecTy = Context.getCanonicalTagType(RD);
146 RecTy = Context.VoidTy;
151 return Context.getPointerType(RecTy);
177 assert(paramInfos.size() <= prefixArgs);
178 assert(proto->
getNumParams() + prefixArgs <= totalArgs);
180 paramInfos.reserve(totalArgs);
183 paramInfos.resize(prefixArgs);
187 paramInfos.push_back(ParamInfo);
189 if (ParamInfo.hasPassObjectSize())
190 paramInfos.emplace_back();
193 assert(paramInfos.size() <= totalArgs &&
194 "Did we forget to insert pass_object_size args?");
196 paramInfos.resize(totalArgs);
206 if (!FPT->hasExtParameterInfos()) {
207 assert(paramInfos.empty() &&
208 "We have paramInfos, but the prototype doesn't?");
209 prefix.append(FPT->param_type_begin(), FPT->param_type_end());
213 unsigned PrefixSize = prefix.size();
217 prefix.reserve(prefix.size() + FPT->getNumParams());
219 auto ExtInfos = FPT->getExtParameterInfos();
220 assert(ExtInfos.size() == FPT->getNumParams());
221 for (
unsigned I = 0, E = FPT->getNumParams(); I != E; ++I) {
222 prefix.push_back(FPT->getParamType(I));
223 if (ExtInfos[I].hasPassObjectSize())
248 FTP->getExtInfo(), paramInfos,
Required,
259 return ::arrangeLLVMFunctionInfo(*
this,
false, argTypes,
264 bool IsTargetDefaultMSABI) {
269 if (D->
hasAttr<FastCallAttr>())
275 if (D->
hasAttr<ThisCallAttr>())
278 if (D->
hasAttr<VectorCallAttr>())
284 if (PcsAttr *PCS = D->
getAttr<PcsAttr>())
287 if (D->
hasAttr<AArch64VectorPcsAttr>())
290 if (D->
hasAttr<AArch64SVEPcsAttr>())
293 if (D->
hasAttr<DeviceKernelAttr>())
296 if (D->
hasAttr<IntelOclBiccAttr>())
305 if (D->
hasAttr<PreserveMostAttr>())
308 if (D->
hasAttr<PreserveAllAttr>())
314 if (D->
hasAttr<PreserveNoneAttr>())
317 if (D->
hasAttr<RISCVVectorCCAttr>())
320 if (RISCVVLSCCAttr *PCS = D->
getAttr<RISCVVLSCCAttr>()) {
321 switch (PCS->getVectorWidth()) {
323 llvm_unreachable(
"Invalid RISC-V VLS ABI VLEN");
324#define CC_VLS_CASE(ABI_VLEN) \
326 return CC_RISCVVLSCall_##ABI_VLEN;
364 CanonicalFTP.getTypePtr(), argTypes.size());
367 CanonicalFTP->getReturnType().getUnqualifiedType(),
369 paramInfos, required, MD);
375 if (FD->
hasAttr<CUDAGlobalAttr>()) {
407 argTypes, prototype->getExtInfo(), paramInfos,
417 !Target.getCXXABI().hasConstructorVariants();
430 bool PassParams =
true;
432 if (
auto *CD = dyn_cast<CXXConstructorDecl>(MD)) {
435 if (
auto Inherited = CD->getInheritedConstructor())
447 if (!paramInfos.empty()) {
450 paramInfos.insert(paramInfos.begin() + 1, AddedArgs.
Prefix,
453 paramInfos.append(AddedArgs.
Suffix,
458 (PassParams && MD->isVariadic() ?
RequiredArgs(argTypes.size())
464 ? CGM.getContext().VoidPtrTy
467 argTypes, extInfo, paramInfos, required, MD);
473 for (
auto &arg : args)
481 for (
auto &arg : args)
488 unsigned totalArgs) {
506 unsigned ExtraPrefixArgs,
unsigned ExtraSuffixArgs,
509 for (
const auto &Arg : args)
510 ArgTypes.push_back(Context.getCanonicalParamType(Arg.Ty));
513 unsigned TotalPrefixArgs = 1 + ExtraPrefixArgs;
518 FPT, TotalPrefixArgs + ExtraSuffixArgs)
524 ? CGM.getContext().VoidPtrTy
531 if (PassProtoArgs && FPT->hasExtParameterInfos()) {
538 ArgTypes, Info, ParamInfos,
Required,
548 if (MD->isImplicitObjectMemberFunction())
556 if (DeviceKernelAttr::isOpenCLSpelling(FD->
getAttr<DeviceKernelAttr>()) &&
559 CGM.getTargetCodeGenInfo().setOCLKernelStubCallingConvention(FT);
567 {}, noProto->getExtInfo(), {},
601 argTys.push_back(Context.getCanonicalParamType(receiverType));
603 argTys.push_back(Context.getCanonicalParamType(Context.getObjCSelType()));
605 argTys.push_back(Context.getCanonicalParamType(I->getType()));
607 I->hasAttr<NoEscapeAttr>());
608 extParamInfos.push_back(extParamInfo);
612 bool IsTargetDefaultMSABI =
618 if (
getContext().getLangOpts().ObjCAutoRefCount &&
619 MD->
hasAttr<NSReturnsRetainedAttr>())
657 assert(MD->
isVirtual() &&
"only methods have thunks");
674 ArgTys.push_back(*FTP->param_type_begin());
676 ArgTys.push_back(Context.IntTy);
677 CallingConv CC = Context.getDefaultCallingConvention(
689 unsigned numExtraRequiredArgs,
bool chainCall,
691 assert(args.size() >= numExtraRequiredArgs);
701 if (proto->isVariadic())
704 if (proto->hasExtParameterInfos())
718 for (
const auto &arg : args)
723 paramInfos, required, ABIInfoFD);
734 chainCall ? 1 : 0, chainCall, ABIInfoFD);
766 for (
const auto &Arg : args)
767 argTypes.push_back(Context.getCanonicalParamType(Arg.Ty));
809 assert(numPrefixArgs + 1 <= args.size() &&
810 "Emitting a call with less args than the required prefix?");
821 paramInfos, required, ABIInfoFD);
833 assert(signature.
arg_size() <= args.size());
834 unsigned X86ABIAVXLevel =
835 CGM.getABIInfo().getX86ABIAVXLevel(ABIInfoFD, signature.
getExtInfo());
836 if (signature.
arg_size() == args.size() &&
842 if (!sigParamInfos.empty()) {
843 paramInfos.append(sigParamInfos.begin(), sigParamInfos.end());
844 paramInfos.resize(args.size());
882 return "IndirectAliased";
888 return "CoerceAndExpand";
890 return "TargetSpecific";
894 llvm_unreachable(
"Unknown kind");
900 MappedArgTypes.reserve(FI.
arg_size());
902 MappedArgTypes.push_back(AbiMapper->convertType(Arg.type));
905 llvm::abi::RequiredArgs AbiRequired = llvm::abi::RequiredArgs::All;
907 AbiRequired = llvm::abi::RequiredArgs(
Required.getNumRequiredArgs());
909 auto AbiFI = llvm::abi::FunctionInfo::create(
911 MappedArgTypes, AbiRequired);
920 auto ConvertABIArgInfo = [&](
ABIArgInfo &Target,
923 auto Check = [&](
bool Cond, llvm::function_ref<void()> MessageFn) {
927 llvm::dbgs() <<
"For return value of type ";
929 llvm::dbgs() <<
"For argument " << ArgNo <<
" of type ";
930 llvm::dbgs() <<
Type <<
": ";
932 llvm::dbgs() <<
"\n";
935 auto CheckSimple = [&](
auto TargetVal,
auto ResVal, StringRef What) {
936 Check(TargetVal == ResVal, [&]() {
937 llvm::dbgs() << What <<
" mismatch (expected: " << TargetVal
938 <<
", given: " << ResVal <<
")";
943 Check(Target.getKind() == Res.
getKind(), [&]() {
944 llvm::dbgs() <<
"Kind mismatch (expected: "
945 << abiKindToString(Target.getKind())
946 <<
", given: " << abiKindToString(Res.getKind()) <<
")";
951 llvm::Type *TargetType = Target.getCoerceToType();
958 Check(TargetType == ResType, [&]() {
959 llvm::dbgs() <<
"CoerceToType mismatch (expected: " << *TargetType
960 <<
", given: " << *ResType <<
")";
966 CheckSimple(Target.isSignExt(), Res.
isSignExt(),
"SignExt");
967 CheckSimple(Target.isZeroExt(), Res.
isZeroExt(),
"ZeroExt");
972 CheckSimple(Target.getDirectAlign(), Res.
getDirectAlign(),
"DirectAlign");
986 "IndirectAddrSpace");
990 llvm::dbgs() <<
"IndirectAlign mismatch (expected: "
991 << Target.getIndirectAlign().getQuantity()
992 <<
", given: " << Res.getIndirectAlign().getQuantity()
997 Check(Target.getUnpaddedCoerceAndExpandType() ==
1000 llvm::dbgs() <<
"UnpaddedCoerceAndExpandType mismatch (expected: "
1001 << *Target.getUnpaddedCoerceAndExpandType()
1003 << *Res.getUnpaddedCoerceAndExpandType() <<
")";
1013 auto ConvertABIArgInfo =
1018 ConvertABIArgInfo(FI.
getReturnInfo(), AbiFI->getReturnInfo(),
1022 for (
auto [CGArg, AbiArg] :
1023 llvm::zip_equal(FI.
arguments(), AbiFI->arguments()))
1024 ConvertABIArgInfo(CGArg.info, AbiArg.Info, CGArg.type, ArgNo++);
1027ABIArgInfo CodeGenModule::convertABIArgInfo(
const llvm::abi::ArgInfo &AbiInfo,
1029 switch (AbiInfo.getKind()) {
1030 case llvm::abi::ArgInfo::Direct: {
1031 llvm::Type *CoercedType =
nullptr;
1032 if (AbiInfo.getCoerceToType())
1033 CoercedType = AbiReverseMapper->convertType(AbiInfo.getCoerceToType());
1035 CoercedType = getTypes().ConvertType(
Type);
1036 unsigned DirectAlign = 0;
1037 if (llvm::MaybeAlign Align = AbiInfo.getDirectAlign())
1038 DirectAlign = Align->value();
1043 AbiInfo.getCanBeFlattened(), DirectAlign);
1045 case llvm::abi::ArgInfo::Extend: {
1046 llvm::Type *CoercedType =
nullptr;
1047 if (AbiInfo.getCoerceToType())
1048 CoercedType = AbiReverseMapper->convertType(AbiInfo.getCoerceToType());
1050 CoercedType = getTypes().ConvertType(
Type);
1057 if (AbiInfo.isSignExt())
1059 else if (AbiInfo.isZeroExt())
1066 case llvm::abi::ArgInfo::Indirect: {
1070 AbiInfo.getIndirectByVal(),
1071 AbiInfo.getIndirectRealign());
1073 case llvm::abi::ArgInfo::IndirectAliased: {
1075 CharUnits Alignment =
1078 AbiInfo.getIndirectAddrSpace(),
1079 AbiInfo.getIndirectRealign());
1081 case llvm::abi::ArgInfo::Ignore:
1083 case llvm::abi::ArgInfo::CoerceAndExpand: {
1084 llvm::StructType *CoercedType = llvm::cast<llvm::StructType>(
1085 AbiReverseMapper->convertType(AbiInfo.getCoerceToType()));
1086 llvm::Type *UnpaddedType =
1087 AbiReverseMapper->convertType(AbiInfo.getUnpaddedCoerceAndExpandType());
1091 llvm_unreachable(
"Unexpected llvm::abi::ArgInfo kind");
1102 assert(llvm::all_of(argTypes,
1110 bool isDelegateCall =
1112 unsigned X86ABIAVXLevel = CGM.getABIInfo().getX86ABIAVXLevel(ABIInfoFD, info);
1116 paramInfos, required, resultType, argTypes);
1126 llvm::FoldingSetNodeID ID;
1128 X86ABIAVXLevel, info, paramInfos, required,
1129 resultType, argTypes);
1131 llvm::FoldingSetInsertToken InsertToken;
1136 unsigned CC = ClangCallConvToLLVMCallConv(info.getCC());
1140 X86ABIAVXLevel, info, paramInfos, resultType,
1141 argTypes, required);
1142 FunctionInfos.insert(FI, InsertToken);
1144 bool inserted = FunctionsBeingProcessed.insert(FI).second;
1146 assert(inserted &&
"Recursively being processed?");
1150 (CC == llvm::CallingConv::SPIR_KERNEL || CC == llvm::CallingConv::C)) {
1155 assert(CC != llvm::CallingConv::C || getContext().getLangOpts().
OpenCL);
1160 return CGM.getTriple().isSPIRV() &&
1161 Arg.type.getTypePtr()->isOpenCLSpecificType();
1163 if (CC == llvm::CallingConv::SPIR_KERNEL &&
1164 CGM.shouldUseLLVMABILowering(CC) &&
1165 llvm::none_of(FI->
arguments(), IsSPIRVOpenCLType))
1166 CGM.computeABIInfoUsingLib(*FI);
1171 }
else if (CGM.shouldUseLLVMABILowering(CC)) {
1172 CGM.computeABIInfoUsingLib(*FI);
1174 CGM.getABIInfo().computeInfo(*FI);
1185 if (I.info.canHaveCoerceToType() && I.info.getCoerceToType() ==
nullptr)
1186 I.info.setCoerceToType(ConvertType(I.type));
1188 bool erased = FunctionsBeingProcessed.erase(FI);
1190 assert(erased &&
"Not in set?");
1196 unsigned llvmCC,
bool instanceMethod,
bool chainCall,
bool delegateCall,
1200 assert(paramInfos.empty() || paramInfos.size() == argTypes.size());
1204 void *buffer =
operator new(totalSizeToAlloc<ArgInfo, ExtParameterInfo>(
1205 argTypes.size() + 1, paramInfos.size()));
1207 CGFunctionInfo *FI =
new (buffer) CGFunctionInfo();
1208 FI->CallingConvention = llvmCC;
1209 FI->EffectiveCallingConvention = llvmCC;
1210 FI->ASTCallingConvention = info.getCC();
1211 FI->InstanceMethod = instanceMethod;
1212 FI->ChainCall = chainCall;
1213 FI->DelegateCall = delegateCall;
1214 FI->CmseNSCall = info.getCmseNSCall();
1215 FI->NoReturn = info.getNoReturn();
1216 FI->ReturnsRetained = info.getProducesResult();
1217 FI->NoCallerSavedRegs = info.getNoCallerSavedRegs();
1218 FI->NoCfCheck = info.getNoCfCheck();
1219 FI->Required = required;
1220 FI->HasRegParm = info.getHasRegParm();
1221 FI->RegParm = info.getRegParm();
1222 FI->X86ABIAVXLevel = X86ABIAVXLevel;
1223 FI->ArgStruct =
nullptr;
1224 FI->ArgStructAlign = 0;
1225 FI->NumArgs = argTypes.size();
1226 FI->HasExtParameterInfos = !paramInfos.empty();
1227 FI->getArgsBuffer()[0].
type = resultType;
1228 FI->MaxVectorWidth = 0;
1229 for (
unsigned i = 0, e = argTypes.size(); i != e; ++i)
1230 FI->getArgsBuffer()[i + 1].
type = argTypes[i];
1231 for (
unsigned i = 0, e = paramInfos.size(); i != e; ++i)
1232 FI->getExtParameterInfosBuffer()[i] = paramInfos[i];
1242struct TypeExpansion {
1243 enum TypeExpansionKind {
1255 const TypeExpansionKind Kind;
1257 TypeExpansion(TypeExpansionKind K) : Kind(K) {}
1258 virtual ~TypeExpansion() {}
1261struct ConstantArrayExpansion : TypeExpansion {
1265 ConstantArrayExpansion(QualType EltTy,
uint64_t NumElts)
1266 : TypeExpansion(TEK_ConstantArray), EltTy(EltTy), NumElts(NumElts) {}
1267 static bool classof(
const TypeExpansion *TE) {
1268 return TE->Kind == TEK_ConstantArray;
1272struct RecordExpansion : TypeExpansion {
1273 SmallVector<const CXXBaseSpecifier *, 1> Bases;
1275 SmallVector<const FieldDecl *, 1> Fields;
1277 RecordExpansion(SmallVector<const CXXBaseSpecifier *, 1> &&Bases,
1278 SmallVector<const FieldDecl *, 1> &&Fields)
1279 : TypeExpansion(TEK_Record), Bases(std::move(Bases)),
1280 Fields(std::move(Fields)) {}
1281 static bool classof(
const TypeExpansion *TE) {
1282 return TE->Kind == TEK_Record;
1286struct ComplexExpansion : TypeExpansion {
1289 ComplexExpansion(QualType EltTy) : TypeExpansion(
TEK_Complex), EltTy(EltTy) {}
1290 static bool classof(
const TypeExpansion *TE) {
1295struct NoExpansion : TypeExpansion {
1296 NoExpansion() : TypeExpansion(TEK_None) {}
1297 static bool classof(
const TypeExpansion *TE) {
return TE->Kind == TEK_None; }
1301static std::unique_ptr<TypeExpansion>
1304 return std::make_unique<ConstantArrayExpansion>(AT->getElementType(),
1310 assert(!RD->hasFlexibleArrayMember() &&
1311 "Cannot expand structure with flexible array.");
1312 if (RD->isUnion()) {
1318 for (
const auto *FD : RD->fields()) {
1319 if (FD->isZeroLengthBitField())
1321 assert(!FD->isBitField() &&
1322 "Cannot expand structure with bit-field members.");
1323 CharUnits FieldSize = Context.getTypeSizeInChars(FD->getType());
1324 if (UnionSize < FieldSize) {
1325 UnionSize = FieldSize;
1330 Fields.push_back(LargestFD);
1332 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
1333 assert(!CXXRD->isDynamicClass() &&
1334 "cannot expand vtable pointers in dynamic classes");
1335 llvm::append_range(Bases, llvm::make_pointer_range(CXXRD->bases()));
1338 for (
const auto *FD : RD->fields()) {
1339 if (FD->isZeroLengthBitField())
1341 assert(!FD->isBitField() &&
1342 "Cannot expand structure with bit-field members.");
1343 Fields.push_back(FD);
1346 return std::make_unique<RecordExpansion>(std::move(Bases),
1350 return std::make_unique<ComplexExpansion>(CT->getElementType());
1352 return std::make_unique<NoExpansion>();
1357 if (
auto CAExp = dyn_cast<ConstantArrayExpansion>(Exp.get())) {
1360 if (
auto RExp = dyn_cast<RecordExpansion>(Exp.get())) {
1362 for (
auto BS : RExp->Bases)
1364 for (
auto FD : RExp->Fields)
1377 if (
auto CAExp = dyn_cast<ConstantArrayExpansion>(Exp.get())) {
1378 for (
int i = 0, n = CAExp->NumElts; i < n; i++) {
1381 }
else if (
auto RExp = dyn_cast<RecordExpansion>(Exp.get())) {
1382 for (
auto BS : RExp->Bases)
1384 for (
auto FD : RExp->Fields)
1386 }
else if (
auto CExp = dyn_cast<ComplexExpansion>(Exp.get())) {
1397 ConstantArrayExpansion *CAE,
1399 llvm::function_ref<
void(
Address)> Fn) {
1400 for (
int i = 0, n = CAE->NumElts; i < n; i++) {
1406void CodeGenFunction::ExpandTypeFromArgs(QualType Ty, LValue LV,
1407 llvm::Function::arg_iterator &AI) {
1408 assert(LV.isSimple() &&
1409 "Unexpected non-simple lvalue during struct expansion.");
1412 if (
auto CAExp = dyn_cast<ConstantArrayExpansion>(Exp.get())) {
1414 *
this, CAExp, LV.getAddress(), [&](Address EltAddr) {
1415 LValue LV = MakeAddrLValue(EltAddr, CAExp->EltTy);
1416 ExpandTypeFromArgs(CAExp->EltTy, LV, AI);
1418 }
else if (
auto RExp = dyn_cast<RecordExpansion>(Exp.get())) {
1420 for (
const CXXBaseSpecifier *BS : RExp->Bases) {
1424 false, SourceLocation());
1425 LValue SubLV = MakeAddrLValue(Base, BS->
getType());
1428 ExpandTypeFromArgs(BS->
getType(), SubLV, AI);
1430 for (
auto FD : RExp->Fields) {
1432 LValue SubLV = EmitLValueForFieldInitialization(LV, FD);
1433 ExpandTypeFromArgs(FD->getType(), SubLV, AI);
1436 auto realValue = &*AI++;
1437 auto imagValue = &*AI++;
1438 EmitStoreOfComplex(
ComplexPairTy(realValue, imagValue), LV,
true);
1443 llvm::Value *Arg = &*AI++;
1444 if (LV.isBitField()) {
1450 if (Arg->getType()->isPointerTy()) {
1452 Arg = Builder.CreateBitCast(Arg,
Addr.getElementType());
1454 EmitStoreOfScalar(Arg, LV);
1459void CodeGenFunction::ExpandTypeToArgs(
1460 QualType Ty, CallArg Arg, llvm::FunctionType *IRFuncTy,
1461 SmallVectorImpl<llvm::Value *> &IRCallArgs,
unsigned &IRCallArgPos) {
1463 if (
auto CAExp = dyn_cast<ConstantArrayExpansion>(Exp.get())) {
1468 CallArg(convertTempToRValue(EltAddr, CAExp->EltTy, SourceLocation()),
1470 ExpandTypeToArgs(CAExp->EltTy, EltArg, IRFuncTy, IRCallArgs,
1473 }
else if (
auto RExp = dyn_cast<RecordExpansion>(Exp.get())) {
1476 for (
const CXXBaseSpecifier *BS : RExp->Bases) {
1480 false, SourceLocation());
1484 ExpandTypeToArgs(BS->
getType(), BaseArg, IRFuncTy, IRCallArgs,
1488 LValue LV = MakeAddrLValue(This, Ty);
1489 for (
auto FD : RExp->Fields) {
1491 CallArg(EmitRValueForField(LV, FD, SourceLocation()), FD->getType());
1492 ExpandTypeToArgs(FD->getType(), FldArg, IRFuncTy, IRCallArgs,
1497 IRCallArgs[IRCallArgPos++] = CV.first;
1498 IRCallArgs[IRCallArgPos++] = CV.second;
1502 assert(RV.isScalar() &&
1503 "Unexpected non-scalar rvalue during struct expansion.");
1506 llvm::Value *
V = RV.getScalarVal();
1507 if (IRCallArgPos < IRFuncTy->getNumParams() &&
1508 V->getType() != IRFuncTy->getParamType(IRCallArgPos))
1509 V = Builder.CreateBitCast(
V, IRFuncTy->getParamType(IRCallArgPos));
1511 IRCallArgs[IRCallArgPos++] =
V;
1519 const Twine &Name =
"tmp") {
1532 llvm::StructType *SrcSTy,
1536 if (SrcSTy->getNumElements() == 0)
1546 if (FirstEltSize < DstSize &&
1555 if (llvm::StructType *SrcSTy = dyn_cast<llvm::StructType>(SrcTy))
1570 if (Val->getType() == Ty)
1576 return CGF.
Builder.CreateBitCast(Val, Ty,
"coerce.val");
1582 llvm::Type *DestIntTy = Ty;
1586 if (Val->getType() != DestIntTy) {
1588 if (DL.isBigEndian()) {
1591 uint64_t SrcSize = DL.getTypeSizeInBits(Val->getType());
1592 uint64_t DstSize = DL.getTypeSizeInBits(DestIntTy);
1594 if (SrcSize > DstSize) {
1595 Val = CGF.
Builder.CreateLShr(Val, SrcSize - DstSize,
"coerce.highbits");
1596 Val = CGF.
Builder.CreateTrunc(Val, DestIntTy,
"coerce.val.ii");
1598 Val = CGF.
Builder.CreateZExt(Val, DestIntTy,
"coerce.val.ii");
1599 Val = CGF.
Builder.CreateShl(Val, DstSize - SrcSize,
"coerce.highbits");
1603 Val = CGF.
Builder.CreateIntCast(Val, DestIntTy,
false,
"coerce.val.ii");
1608 Val = CGF.
Builder.CreateIntToPtr(Val, Ty,
"coerce.val.ip");
1615 if (PFPFields.empty())
1618 auto LoadCoercedField = [&](
CharUnits Offset,
1619 llvm::Type *FieldType) -> llvm::Value * {
1624 if (!PFPFields.empty() && PFPFields[0].Offset == Offset) {
1628 FieldVal = CGF.
Builder.CreatePtrToInt(FieldVal, FieldType);
1629 PFPFields.erase(PFPFields.begin());
1646 Val = CGF.
Builder.CreatePtrToInt(Val, Ty);
1650 auto *ET = AT->getElementType();
1654 llvm::Value *Val = llvm::PoisonValue::get(AT);
1655 for (
unsigned Idx = 0; Idx != AT->getNumElements(); ++Idx, Offset += WordSize)
1656 Val = CGF.
Builder.CreateInsertValue(Val, LoadCoercedField(Offset, ET), Idx);
1680 if (llvm::StructType *SrcSTy = dyn_cast<llvm::StructType>(SrcTy)) {
1682 DstSize.getFixedValue(), CGF);
1697 if (!SrcSize.isScalable() && !DstSize.isScalable() &&
1698 SrcSize.getFixedValue() >= DstSize.getFixedValue()) {
1712 if (
auto *ScalableDstTy = dyn_cast<llvm::ScalableVectorType>(Ty)) {
1713 if (
auto *FixedSrcTy = dyn_cast<llvm::FixedVectorType>(SrcTy)) {
1716 if (ScalableDstTy->getElementType()->isIntegerTy(1) &&
1717 FixedSrcTy->getElementType()->isIntegerTy(8)) {
1718 ScalableDstTy = llvm::ScalableVectorType::get(
1719 FixedSrcTy->getElementType(),
1721 ScalableDstTy->getElementCount().getKnownMinValue(), 8));
1723 if (ScalableDstTy->getElementType() == FixedSrcTy->getElementType()) {
1725 auto *PoisonVec = llvm::PoisonValue::get(ScalableDstTy);
1727 ScalableDstTy, PoisonVec, Load,
uint64_t(0),
"cast.scalable");
1729 llvm::VectorType::getWithSizeAndScalar(ScalableDstTy, Ty));
1730 if (
Result->getType() != ScalableDstTy)
1732 if (
Result->getType() != Ty)
1745 llvm::ConstantInt::get(CGF.
IntPtrTy, SrcSize.getKnownMinValue()));
1752 if (PFPFields.empty())
1755 llvm::Type *SrcTy = Src->getType();
1756 auto StoreCoercedField = [&](
CharUnits Offset, llvm::Value *FieldVal) {
1757 if (!PFPFields.empty() && PFPFields[0].Offset == Offset) {
1762 PFPFields.erase(PFPFields.begin());
1782 auto *ET = AT->getElementType();
1786 for (
unsigned i = 0; i != AT->getNumElements(); ++i, Offset += WordSize)
1787 StoreCoercedField(Offset, CGF.
Builder.CreateExtractValue(Src, i));
1793 Address Dst, llvm::TypeSize DstSize,
1794 bool DstIsVolatile) {
1798 llvm::Type *SrcTy = Src->getType();
1799 llvm::TypeSize SrcSize =
CGM.getDataLayout().getTypeAllocSize(SrcTy);
1805 if (llvm::StructType *DstSTy =
1807 assert(!SrcSize.isScalable());
1809 SrcSize.getFixedValue(), *
this);
1816 if (SrcSize.isScalable() || SrcSize <= DstSize) {
1817 if (SrcTy->isIntegerTy() && Dst.
getElementType()->isPointerTy() &&
1821 auto *I =
Builder.CreateStore(Src, Dst, DstIsVolatile);
1823 }
else if (llvm::StructType *STy =
1824 dyn_cast<llvm::StructType>(Src->getType())) {
1827 for (
unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
1829 llvm::Value *Elt =
Builder.CreateExtractValue(Src, i);
1830 auto *I =
Builder.CreateStore(Elt, EltPtr, DstIsVolatile);
1838 }
else if (SrcTy->isIntegerTy()) {
1840 llvm::Type *DstIntTy =
Builder.getIntNTy(DstSize.getFixedValue() * 8);
1857 Builder.CreateStore(Src, Tmp);
1858 auto *I =
Builder.CreateMemCpy(
1868 if (
unsigned offset = info.getDirectOffset()) {
1877static std::pair<llvm::Value *, bool>
1879 llvm::ScalableVectorType *FromTy, llvm::Value *
V,
1880 StringRef Name =
"") {
1883 if (FromTy->getElementType()->isIntegerTy(1) &&
1884 ToTy->getElementType() == CGF.
Builder.getInt8Ty()) {
1885 if (!FromTy->getElementCount().isKnownMultipleOf(8)) {
1886 FromTy = llvm::ScalableVectorType::get(
1887 FromTy->getElementType(),
1888 llvm::alignTo<8>(FromTy->getElementCount().getKnownMinValue()));
1889 llvm::Value *ZeroVec = llvm::Constant::getNullValue(FromTy);
1892 FromTy = llvm::ScalableVectorType::get(
1893 ToTy->getElementType(),
1894 FromTy->getElementCount().getKnownMinValue() / 8);
1895 V = CGF.
Builder.CreateBitCast(
V, FromTy);
1897 if (FromTy->getElementType() == ToTy->getElementType()) {
1898 V->setName(Name +
".coerce");
1909class ClangToLLVMArgMapping {
1910 static const unsigned InvalidIndex = ~0U;
1911 unsigned InallocaArgNo;
1913 unsigned TotalIRArgs;
1917 unsigned PaddingArgIndex;
1920 unsigned FirstArgIndex;
1921 unsigned NumberOfArgs;
1924 : PaddingArgIndex(InvalidIndex), FirstArgIndex(InvalidIndex),
1928 SmallVector<IRArgs, 8> ArgInfo;
1931 ClangToLLVMArgMapping(
const ASTContext &Context,
const CGFunctionInfo &FI,
1932 bool OnlyRequiredArgs =
false)
1933 : InallocaArgNo(InvalidIndex), SRetArgNo(InvalidIndex), TotalIRArgs(0),
1934 ArgInfo(OnlyRequiredArgs ? FI.getNumRequiredArgs() : FI.arg_size()) {
1935 construct(Context, FI, OnlyRequiredArgs);
1938 bool hasInallocaArg()
const {
return InallocaArgNo != InvalidIndex; }
1939 unsigned getInallocaArgNo()
const {
1940 assert(hasInallocaArg());
1941 return InallocaArgNo;
1944 bool hasSRetArg()
const {
return SRetArgNo != InvalidIndex; }
1945 unsigned getSRetArgNo()
const {
1946 assert(hasSRetArg());
1950 unsigned totalIRArgs()
const {
return TotalIRArgs; }
1952 bool hasPaddingArg(
unsigned ArgNo)
const {
1953 assert(ArgNo < ArgInfo.size());
1954 return ArgInfo[ArgNo].PaddingArgIndex != InvalidIndex;
1956 unsigned getPaddingArgNo(
unsigned ArgNo)
const {
1957 assert(hasPaddingArg(ArgNo));
1958 return ArgInfo[ArgNo].PaddingArgIndex;
1963 std::pair<unsigned, unsigned> getIRArgs(
unsigned ArgNo)
const {
1964 assert(ArgNo < ArgInfo.size());
1965 return std::make_pair(ArgInfo[ArgNo].FirstArgIndex,
1966 ArgInfo[ArgNo].NumberOfArgs);
1970 void construct(
const ASTContext &Context,
const CGFunctionInfo &FI,
1971 bool OnlyRequiredArgs);
1974void ClangToLLVMArgMapping::construct(
const ASTContext &Context,
1975 const CGFunctionInfo &FI,
1976 bool OnlyRequiredArgs) {
1977 unsigned IRArgNo = 0;
1978 bool SwapThisWithSRet =
false;
1983 SRetArgNo = SwapThisWithSRet ? 1 : IRArgNo++;
1991 QualType ArgType = I->type;
1992 const ABIArgInfo &AI = I->info;
1994 auto &IRArgs = ArgInfo[ArgNo];
1997 IRArgs.PaddingArgIndex = IRArgNo++;
2004 llvm::StructType *STy = dyn_cast<llvm::StructType>(AI.
getCoerceToType());
2006 IRArgs.NumberOfArgs = STy->getNumElements();
2008 IRArgs.NumberOfArgs = 1;
2014 IRArgs.NumberOfArgs = 1;
2019 IRArgs.NumberOfArgs = 0;
2029 if (IRArgs.NumberOfArgs > 0) {
2030 IRArgs.FirstArgIndex = IRArgNo;
2031 IRArgNo += IRArgs.NumberOfArgs;
2036 if (IRArgNo == 1 && SwapThisWithSRet)
2039 assert(ArgNo == ArgInfo.size());
2042 InallocaArgNo = IRArgNo++;
2044 TotalIRArgs = IRArgNo;
2052 return RI.
isIndirect() || (RI.isInAlloca() && RI.getInAllocaSRet());
2067 switch (BT->getKind()) {
2070 case BuiltinType::Float:
2072 case BuiltinType::Double:
2074 case BuiltinType::LongDouble:
2085 if (BT->getKind() == BuiltinType::LongDouble)
2086 return getTarget().useObjCFP2RetForComplexLongDouble();
2100 bool Inserted = FunctionsBeingProcessed.insert(&FI).second;
2102 assert(Inserted &&
"Recursively being processed?");
2104 llvm::Type *resultType =
nullptr;
2109 llvm_unreachable(
"Invalid ABI kind for return argument");
2121 unsigned addressSpace = CGM.getTypes().getTargetAddressSpace(ret);
2122 resultType = llvm::PointerType::get(
getLLVMContext(), addressSpace);
2138 ClangToLLVMArgMapping IRFunctionArgs(
getContext(), FI,
true);
2142 if (IRFunctionArgs.hasSRetArg()) {
2143 ArgTypes[IRFunctionArgs.getSRetArgNo()] = llvm::PointerType::get(
2148 if (IRFunctionArgs.hasInallocaArg())
2149 ArgTypes[IRFunctionArgs.getInallocaArgNo()] =
2156 for (; it != ie; ++it, ++ArgNo) {
2160 if (IRFunctionArgs.hasPaddingArg(ArgNo))
2161 ArgTypes[IRFunctionArgs.getPaddingArgNo(ArgNo)] =
2164 unsigned FirstIRArg, NumIRArgs;
2165 std::tie(FirstIRArg, NumIRArgs) = IRFunctionArgs.getIRArgs(ArgNo);
2170 assert(NumIRArgs == 0);
2174 assert(NumIRArgs == 1);
2176 ArgTypes[FirstIRArg] = llvm::PointerType::get(
2180 assert(NumIRArgs == 1);
2181 ArgTypes[FirstIRArg] = llvm::PointerType::get(
2190 llvm::StructType *st = dyn_cast<llvm::StructType>(argType);
2192 assert(NumIRArgs == st->getNumElements());
2193 for (
unsigned i = 0, e = st->getNumElements(); i != e; ++i)
2194 ArgTypes[FirstIRArg + i] = st->getElementType(i);
2196 assert(NumIRArgs == 1);
2197 ArgTypes[FirstIRArg] = argType;
2203 auto ArgTypesIter = ArgTypes.begin() + FirstIRArg;
2205 *ArgTypesIter++ = EltTy;
2207 assert(ArgTypesIter == ArgTypes.begin() + FirstIRArg + NumIRArgs);
2212 auto ArgTypesIter = ArgTypes.begin() + FirstIRArg;
2214 assert(ArgTypesIter == ArgTypes.begin() + FirstIRArg + NumIRArgs);
2219 bool Erased = FunctionsBeingProcessed.erase(&FI);
2221 assert(Erased &&
"Not in set?");
2223 return llvm::FunctionType::get(resultType, ArgTypes, FI.
isVariadic());
2237 llvm::AttrBuilder &FuncAttrs,
2244 FuncAttrs.addAttribute(llvm::Attribute::NoUnwind);
2248 FuncAttrs.addAttribute(
"aarch64_pstate_sm_enabled");
2250 FuncAttrs.addAttribute(
"aarch64_pstate_sm_compatible");
2252 FuncAttrs.addAttribute(
"aarch64_za_state_agnostic");
2256 FuncAttrs.addAttribute(
"aarch64_preserves_za");
2258 FuncAttrs.addAttribute(
"aarch64_in_za");
2260 FuncAttrs.addAttribute(
"aarch64_out_za");
2262 FuncAttrs.addAttribute(
"aarch64_inout_za");
2266 FuncAttrs.addAttribute(
"aarch64_preserves_zt0");
2268 FuncAttrs.addAttribute(
"aarch64_in_zt0");
2270 FuncAttrs.addAttribute(
"aarch64_out_zt0");
2272 FuncAttrs.addAttribute(
"aarch64_inout_zt0");
2276 const Decl *Callee) {
2282 for (
const OMPAssumeAttr *AA : Callee->specific_attrs<OMPAssumeAttr>())
2283 AA->getAssumption().split(Attrs,
",");
2286 FuncAttrs.addAttribute(llvm::AssumptionAttrKey,
2287 llvm::join(Attrs.begin(), Attrs.end(),
","));
2294 if (
const RecordType *RT =
2296 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
2297 return ClassDecl->hasTrivialDestructor();
2303 const Decl *TargetDecl) {
2309 if (
Module.getLangOpts().Sanitize.has(SanitizerKind::Memory))
2313 if (!
Module.getLangOpts().CPlusPlus)
2316 if (
const FunctionDecl *FDecl = dyn_cast<FunctionDecl>(TargetDecl)) {
2317 if (FDecl->isExternC())
2319 }
else if (
const VarDecl *VDecl = dyn_cast<VarDecl>(TargetDecl)) {
2321 if (VDecl->isExternC())
2329 return Module.getCodeGenOpts().StrictReturn ||
2330 !
Module.MayDropFunctionReturn(
Module.getContext(), RetTy) ||
2331 Module.getLangOpts().Sanitize.has(SanitizerKind::Return);
2338 llvm::DenormalMode FP32DenormalMode,
2339 llvm::AttrBuilder &FuncAttrs) {
2340 llvm::DenormalFPEnv FPEnv(FPDenormalMode, FP32DenormalMode);
2341 if (FPEnv != llvm::DenormalFPEnv::getDefault())
2342 FuncAttrs.addDenormalFPEnvAttr(FPEnv);
2350 llvm::AttrBuilder &FuncAttrs) {
2356 llvm::AttrBuilder &FuncAttrs) {
2357 switch (CodeGenOpts.getZeroCallUsedRegs()) {
2358 case llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind::Skip:
2360 case llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind::UsedGPRArg:
2361 FuncAttrs.addAttribute(
"zero-call-used-regs",
"used-gpr-arg");
2363 case llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind::UsedGPR:
2364 FuncAttrs.addAttribute(
"zero-call-used-regs",
"used-gpr");
2366 case llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind::UsedArg:
2367 FuncAttrs.addAttribute(
"zero-call-used-regs",
"used-arg");
2369 case llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind::Used:
2370 FuncAttrs.addAttribute(
"zero-call-used-regs",
"used");
2372 case llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind::AllGPRArg:
2373 FuncAttrs.addAttribute(
"zero-call-used-regs",
"all-gpr-arg");
2375 case llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind::AllGPR:
2376 FuncAttrs.addAttribute(
"zero-call-used-regs",
"all-gpr");
2378 case llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind::AllArg:
2379 FuncAttrs.addAttribute(
"zero-call-used-regs",
"all-arg");
2381 case llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind::All:
2382 FuncAttrs.addAttribute(
"zero-call-used-regs",
"all");
2388 StringRef Name,
bool HasOptnone,
const CodeGenOptions &CodeGenOpts,
2390 llvm::AttrBuilder &FuncAttrs) {
2393 if (CodeGenOpts.OptimizeSize)
2394 FuncAttrs.addAttribute(llvm::Attribute::OptimizeForSize);
2395 if (CodeGenOpts.OptimizeSize == 2)
2396 FuncAttrs.addAttribute(llvm::Attribute::MinSize);
2399 if (CodeGenOpts.DisableRedZone)
2400 FuncAttrs.addAttribute(llvm::Attribute::NoRedZone);
2401 if (CodeGenOpts.IndirectTlsSegRefs)
2402 FuncAttrs.addAttribute(
"indirect-tls-seg-refs");
2403 if (CodeGenOpts.NoImplicitFloat)
2404 FuncAttrs.addAttribute(llvm::Attribute::NoImplicitFloat);
2406 if (AttrOnCallSite) {
2411 FuncAttrs.addAttribute(llvm::Attribute::NoBuiltin);
2413 FuncAttrs.addAttribute(
"trap-func-name", CodeGenOpts.
TrapFuncName);
2415 switch (CodeGenOpts.getFramePointer()) {
2423 FuncAttrs.addAttribute(
"frame-pointer",
2425 CodeGenOpts.getFramePointer()));
2428 if (CodeGenOpts.NullPointerIsValid)
2429 FuncAttrs.addAttribute(llvm::Attribute::NullPointerIsValid);
2432 FuncAttrs.addAttribute(
"no-trapping-math",
"true");
2436 if (CodeGenOpts.SoftFloat)
2437 FuncAttrs.addAttribute(
"use-soft-float",
"true");
2438 FuncAttrs.addAttribute(
"stack-protector-buffer-size",
2439 llvm::utostr(CodeGenOpts.SSPBufferSize));
2440 if (LangOpts.NoSignedZero)
2441 FuncAttrs.addAttribute(
"no-signed-zeros-fp-math",
"true");
2444 const std::vector<std::string> &Recips = CodeGenOpts.
Reciprocals;
2445 if (!Recips.empty())
2446 FuncAttrs.addAttribute(
"reciprocal-estimates", llvm::join(Recips,
","));
2450 FuncAttrs.addAttribute(
"prefer-vector-width",
2453 if (CodeGenOpts.StackRealignment)
2454 FuncAttrs.addAttribute(
"stackrealign");
2455 if (CodeGenOpts.Backchain)
2456 FuncAttrs.addAttribute(
"backchain");
2457 if (CodeGenOpts.EnableSegmentedStacks)
2458 FuncAttrs.addAttribute(
"split-stack");
2460 if (CodeGenOpts.SpeculativeLoadHardening)
2461 FuncAttrs.addAttribute(llvm::Attribute::SpeculativeLoadHardening);
2470 FuncAttrs.addAttribute(llvm::Attribute::Convergent);
2475 if ((LangOpts.CUDA && LangOpts.CUDAIsDevice) || LangOpts.OpenCL ||
2476 LangOpts.SYCLIsDevice) {
2477 FuncAttrs.addAttribute(llvm::Attribute::NoUnwind);
2480 if (CodeGenOpts.SaveRegParams && !AttrOnCallSite)
2481 FuncAttrs.addAttribute(
"save-reg-params");
2484 StringRef Var,
Value;
2486 FuncAttrs.addAttribute(Var,
Value);
2489 if (!AttrOnCallSite) {
2502 const llvm::Function &F,
2504 auto FFeatures = F.getFnAttribute(
"target-features");
2506 llvm::StringSet<> MergedNames;
2508 MergedFeatures.reserve(TargetOpts.
Features.size());
2510 auto AddUnmergedFeatures = [&](
auto &&FeatureRange) {
2511 for (StringRef
Feature : FeatureRange) {
2515 StringRef Name =
Feature.drop_front(1);
2516 bool Merged = !MergedNames.insert(Name).second;
2518 MergedFeatures.push_back(
Feature);
2522 if (FFeatures.isValid())
2523 AddUnmergedFeatures(llvm::split(FFeatures.getValueAsString(),
','));
2524 AddUnmergedFeatures(TargetOpts.
Features);
2526 if (!MergedFeatures.empty()) {
2527 llvm::sort(MergedFeatures);
2528 FuncAttr.addAttribute(
"target-features", llvm::join(MergedFeatures,
","));
2535 bool WillInternalize) {
2537 llvm::AttrBuilder FuncAttrs(F.getContext());
2540 if (!TargetOpts.
CPU.empty())
2541 FuncAttrs.addAttribute(
"target-cpu", TargetOpts.
CPU);
2542 if (!TargetOpts.
TuneCPU.empty())
2543 FuncAttrs.addAttribute(
"tune-cpu", TargetOpts.
TuneCPU);
2546 CodeGenOpts, LangOpts,
2550 if (!WillInternalize && F.isInterposable()) {
2555 F.addFnAttrs(FuncAttrs);
2559 llvm::AttributeMask AttrsToRemove;
2563 llvm::DenormalFPEnv MergedFPEnv =
2564 OptsFPEnv.mergeCalleeMode(F.getDenormalFPEnv());
2566 if (MergedFPEnv == llvm::DenormalFPEnv::getDefault()) {
2567 AttrsToRemove.addAttribute(llvm::Attribute::DenormalFPEnv);
2570 FuncAttrs.addDenormalFPEnvAttr(MergedFPEnv);
2573 F.removeFnAttrs(AttrsToRemove);
2577 F.addFnAttrs(FuncAttrs);
2580void CodeGenModule::getTrivialDefaultFunctionAttributes(
2581 StringRef Name,
bool HasOptnone,
bool AttrOnCallSite,
2582 llvm::AttrBuilder &FuncAttrs) {
2584 getLangOpts(), AttrOnCallSite,
2588void CodeGenModule::getDefaultFunctionAttributes(StringRef Name,
2590 bool AttrOnCallSite,
2591 llvm::AttrBuilder &FuncAttrs) {
2595 if (!AttrOnCallSite)
2601 if (!AttrOnCallSite)
2606 llvm::AttrBuilder &attrs) {
2607 getDefaultFunctionAttributes(
"",
false,
2610 GetCPUAndFeaturesAttributes(
GlobalDecl(), attrs);
2615 const NoBuiltinAttr *NBA =
nullptr) {
2616 auto AddNoBuiltinAttr = [&FuncAttrs](StringRef BuiltinName) {
2618 AttributeName +=
"no-builtin-";
2619 AttributeName += BuiltinName;
2620 FuncAttrs.addAttribute(AttributeName);
2624 if (LangOpts.NoBuiltin) {
2626 FuncAttrs.addAttribute(
"no-builtins");
2640 if (llvm::is_contained(NBA->builtinNames(),
"*")) {
2641 FuncAttrs.addAttribute(
"no-builtins");
2646 llvm::for_each(NBA->builtinNames(), AddNoBuiltinAttr);
2650 const llvm::DataLayout &DL,
const ABIArgInfo &AI,
2651 bool CheckCoerce =
true) {
2658 if (!DL.typeSizeEqualsStoreSize(Ty))
2665 if (llvm::TypeSize::isKnownGT(DL.getTypeSizeInBits(CoerceTy),
2666 DL.getTypeSizeInBits(Ty)))
2690 if (
const MatrixType *Matrix = dyn_cast<MatrixType>(QTy))
2709 if (llvm::AttributeFuncs::isNoFPClassCompatibleType(IRTy))
2712 if (llvm::StructType *ST = dyn_cast<llvm::StructType>(IRTy)) {
2714 llvm::all_of(ST->elements(),
2715 llvm::AttributeFuncs::isNoFPClassCompatibleType);
2723 llvm::AttributeList &Attrs) {
2724 if (Attrs.getMemoryEffects().getModRef() == llvm::ModRefInfo::NoModRef) {
2725 Attrs = Attrs.removeFnAttribute(
getLLVMContext(), llvm::Attribute::Memory);
2726 llvm::Attribute MemoryAttr = llvm::Attribute::getWithMemoryEffects(
2752 llvm::AttributeList &AttrList,
2754 bool AttrOnCallSite,
bool IsThunk) {
2762 FuncAttrs.addAttribute(llvm::Attribute::NoReturn);
2764 FuncAttrs.addAttribute(
"cmse_nonsecure_call");
2775 bool HasOptnone =
false;
2777 const NoBuiltinAttr *NBA =
nullptr;
2781 std::optional<llvm::Attribute::AttrKind> MemAttrForPtrArgs;
2782 bool AddedPotentialArgAccess =
false;
2783 auto AddPotentialArgAccess = [&]() {
2784 AddedPotentialArgAccess =
true;
2785 llvm::Attribute A = FuncAttrs.getAttribute(llvm::Attribute::Memory);
2787 FuncAttrs.addMemoryAttr(A.getMemoryEffects() |
2788 llvm::MemoryEffects::argMemOnly());
2795 if (TargetDecl->
hasAttr<ReturnsTwiceAttr>())
2796 FuncAttrs.addAttribute(llvm::Attribute::ReturnsTwice);
2797 if (TargetDecl->
hasAttr<NoThrowAttr>())
2798 FuncAttrs.addAttribute(llvm::Attribute::NoUnwind);
2799 if (TargetDecl->
hasAttr<NoReturnAttr>())
2800 FuncAttrs.addAttribute(llvm::Attribute::NoReturn);
2801 if (TargetDecl->
hasAttr<ColdAttr>())
2802 FuncAttrs.addAttribute(llvm::Attribute::Cold);
2803 if (TargetDecl->
hasAttr<HotAttr>())
2804 FuncAttrs.addAttribute(llvm::Attribute::Hot);
2805 if (TargetDecl->
hasAttr<NoDuplicateAttr>())
2806 FuncAttrs.addAttribute(llvm::Attribute::NoDuplicate);
2807 if (TargetDecl->
hasAttr<ConvergentAttr>())
2808 FuncAttrs.addAttribute(llvm::Attribute::Convergent);
2810 if (
const FunctionDecl *Fn = dyn_cast<FunctionDecl>(TargetDecl)) {
2813 if (AttrOnCallSite && Fn->isReplaceableGlobalAllocationFunction()) {
2816 Fn->getDeclName().isAnyOperatorNew())
2817 RetAttrs.addAttribute(llvm::Attribute::NoAlias);
2820 const bool IsVirtualCall = MD && MD->
isVirtual();
2823 if (!(AttrOnCallSite && IsVirtualCall)) {
2824 if (Fn->isNoReturn())
2825 FuncAttrs.addAttribute(llvm::Attribute::NoReturn);
2826 NBA = Fn->getAttr<NoBuiltinAttr>();
2833 if (AttrOnCallSite && TargetDecl->
hasAttr<NoMergeAttr>())
2834 FuncAttrs.addAttribute(llvm::Attribute::NoMerge);
2838 if (TargetDecl->
hasAttr<ConstAttr>()) {
2839 FuncAttrs.addMemoryAttr(llvm::MemoryEffects::none());
2840 FuncAttrs.addAttribute(llvm::Attribute::NoUnwind);
2843 FuncAttrs.addAttribute(llvm::Attribute::WillReturn);
2844 MemAttrForPtrArgs = llvm::Attribute::ReadNone;
2845 }
else if (TargetDecl->
hasAttr<PureAttr>()) {
2846 FuncAttrs.addMemoryAttr(llvm::MemoryEffects::readOnly());
2847 FuncAttrs.addAttribute(llvm::Attribute::NoUnwind);
2849 FuncAttrs.addAttribute(llvm::Attribute::WillReturn);
2850 MemAttrForPtrArgs = llvm::Attribute::ReadOnly;
2851 }
else if (TargetDecl->
hasAttr<NoAliasAttr>()) {
2852 FuncAttrs.addMemoryAttr(llvm::MemoryEffects::inaccessibleOrArgMemOnly());
2853 FuncAttrs.addAttribute(llvm::Attribute::NoUnwind);
2855 if (
const auto *RA = TargetDecl->
getAttr<RestrictAttr>();
2856 RA && RA->getDeallocator() ==
nullptr)
2857 RetAttrs.addAttribute(llvm::Attribute::NoAlias);
2858 if (TargetDecl->
hasAttr<ReturnsNonNullAttr>() &&
2859 !CodeGenOpts.NullPointerIsValid)
2860 RetAttrs.addAttribute(llvm::Attribute::NonNull);
2861 if (TargetDecl->
hasAttr<AnyX86NoCallerSavedRegistersAttr>())
2862 FuncAttrs.addAttribute(
"no_caller_saved_registers");
2863 if (TargetDecl->
hasAttr<AnyX86NoCfCheckAttr>())
2864 FuncAttrs.addAttribute(llvm::Attribute::NoCfCheck);
2865 if (TargetDecl->
hasAttr<LeafAttr>())
2866 FuncAttrs.addAttribute(llvm::Attribute::NoCallback);
2867 if (TargetDecl->
hasAttr<BPFFastCallAttr>())
2868 FuncAttrs.addAttribute(
"bpf_fastcall");
2870 HasOptnone = TargetDecl->
hasAttr<OptimizeNoneAttr>();
2871 if (
auto *AllocSize = TargetDecl->
getAttr<AllocSizeAttr>()) {
2872 std::optional<unsigned> NumElemsParam;
2873 if (AllocSize->getNumElemsParam().isValid())
2874 NumElemsParam = AllocSize->getNumElemsParam().getLLVMIndex();
2875 FuncAttrs.addAllocSizeAttr(AllocSize->getElemSizeParam().getLLVMIndex(),
2885 FuncAttrs.addAttribute(
"uniform-work-group-size");
2887 if (TargetDecl->
hasAttr<ArmLocallyStreamingAttr>())
2888 FuncAttrs.addAttribute(
"aarch64_pstate_sm_body");
2890 if (
auto *ModularFormat = TargetDecl->
getAttr<ModularFormatAttr>()) {
2891 FormatAttr *Format = TargetDecl->
getAttr<FormatAttr>();
2892 StringRef
Type = Format->getType()->getName();
2893 std::string FormatIdx = std::to_string(Format->getFormatIdx());
2894 std::string FirstArg = std::to_string(Format->getFirstArg());
2896 Type, FormatIdx, FirstArg,
2897 ModularFormat->getModularImplFn()->getName(),
2898 ModularFormat->getImplName()};
2899 llvm::append_range(Args, ModularFormat->aspects());
2900 FuncAttrs.addAttribute(
"modular-format", llvm::join(Args,
","));
2913 getDefaultFunctionAttributes(Name, HasOptnone, AttrOnCallSite, FuncAttrs);
2916 const FunctionDecl *TargetFD = dyn_cast_or_null<FunctionDecl>(TargetDecl);
2917 bool IsMainFunction = TargetFD && TargetFD->
isMain();
2918 if (!AttrOnCallSite && !IsMainFunction)
2924 if (TargetDecl->
hasAttr<NoSpeculativeLoadHardeningAttr>())
2925 FuncAttrs.removeAttribute(llvm::Attribute::SpeculativeLoadHardening);
2926 if (TargetDecl->
hasAttr<SpeculativeLoadHardeningAttr>())
2927 FuncAttrs.addAttribute(llvm::Attribute::SpeculativeLoadHardening);
2928 if (TargetDecl->
hasAttr<NoSplitStackAttr>())
2929 FuncAttrs.removeAttribute(
"split-stack");
2930 if (!IsMainFunction && TargetDecl->
hasAttr<ZeroCallUsedRegsAttr>()) {
2933 TargetDecl->
getAttr<ZeroCallUsedRegsAttr>()->getZeroCallUsedRegs();
2934 FuncAttrs.removeAttribute(
"zero-call-used-regs");
2935 FuncAttrs.addAttribute(
2936 "zero-call-used-regs",
2937 ZeroCallUsedRegsAttr::ConvertZeroCallUsedRegsKindToStr(Kind));
2944 if (CodeGenOpts.NoPLT) {
2945 if (
auto *Fn = dyn_cast<FunctionDecl>(TargetDecl)) {
2946 if (!Fn->isDefined() && !AttrOnCallSite) {
2947 FuncAttrs.addAttribute(llvm::Attribute::NonLazyBind);
2952 if (TargetDecl->
hasAttr<NoConvergentAttr>())
2953 FuncAttrs.removeAttribute(llvm::Attribute::Convergent);
2958 if (TargetDecl && CodeGenOpts.UniqueInternalLinkageNames) {
2959 if (
const auto *FD = dyn_cast_or_null<FunctionDecl>(TargetDecl)) {
2960 if (!FD->isExternallyVisible())
2961 FuncAttrs.addAttribute(
"sample-profile-suffix-elision-policy",
2968 if (!AttrOnCallSite) {
2969 if (TargetDecl && TargetDecl->
hasAttr<CmseNSEntryAttr>())
2970 FuncAttrs.addAttribute(
"cmse_nonsecure_entry");
2973 auto shouldDisableTailCalls = [&] {
2975 if (CodeGenOpts.DisableTailCalls)
2981 if (TargetDecl->
hasAttr<DisableTailCallsAttr>() ||
2982 TargetDecl->
hasAttr<AnyX86InterruptAttr>())
2985 if (CodeGenOpts.NoEscapingBlockTailCalls) {
2986 if (
const auto *BD = dyn_cast<BlockDecl>(TargetDecl))
2987 if (!BD->doesNotEscape())
2993 if (shouldDisableTailCalls())
2994 FuncAttrs.addAttribute(
"disable-tail-calls",
"true");
2999 static const llvm::StringSet<> ReturnsTwiceFn{
3000 "_setjmpex",
"setjmp",
"_setjmp",
"vfork",
3001 "sigsetjmp",
"__sigsetjmp",
"savectx",
"getcontext"};
3002 if (ReturnsTwiceFn.contains(Name))
3003 FuncAttrs.addAttribute(llvm::Attribute::ReturnsTwice);
3007 GetCPUAndFeaturesAttributes(CalleeInfo.
getCalleeDecl(), FuncAttrs);
3010 if (!MSHotPatchFunctions.empty()) {
3011 bool IsHotPatched = llvm::binary_search(MSHotPatchFunctions, Name);
3013 FuncAttrs.addAttribute(
"marked_for_windows_hot_patching");
3018 if (CodeGenOpts.isLoaderReplaceableFunctionName(Name))
3019 FuncAttrs.addAttribute(
"loader-replaceable");
3022 ClangToLLVMArgMapping IRFunctionArgs(
getContext(), FI);
3029 if (CodeGenOpts.EnableNoundefAttrs &&
3033 RetAttrs.addAttribute(llvm::Attribute::NoUndef);
3038 assert(!RetAI.
isConservative() &&
"Conservative return not supported");
3040 RetAttrs.addAttribute(llvm::Attribute::SExt);
3042 RetAttrs.addAttribute(llvm::Attribute::ZExt);
3044 RetAttrs.addAttribute(llvm::Attribute::NoExt);
3049 RetAttrs.addAttribute(llvm::Attribute::InReg);
3052 RetAttrs.addNoFPClassAttr(
3062 AddPotentialArgAccess();
3071 llvm_unreachable(
"Invalid ABI kind for return argument");
3079 RetAttrs.addDereferenceableAttr(
3081 if (
getTypes().getTargetAddressSpace(PTy) == 0 &&
3082 !CodeGenOpts.NullPointerIsValid)
3083 RetAttrs.addAttribute(llvm::Attribute::NonNull);
3085 llvm::Align Alignment =
3087 RetAttrs.addAlignmentAttr(Alignment);
3092 bool hasUsedSRet =
false;
3094 for (
unsigned I = 0; I < IRFunctionArgs.totalIRArgs(); ++I)
3098 if (IRFunctionArgs.hasSRetArg()) {
3099 llvm::AttrBuilder &SRETAttrs = ArgAttrs[IRFunctionArgs.getSRetArgNo()];
3100 SRETAttrs.addStructRetAttr(
getTypes().ConvertTypeForMem(RetTy));
3101 SRETAttrs.addAttribute(llvm::Attribute::Writable);
3102 SRETAttrs.addAttribute(llvm::Attribute::DeadOnUnwind);
3105 SRETAttrs.addAttribute(llvm::Attribute::InReg);
3110 if (IRFunctionArgs.hasInallocaArg()) {
3111 ArgAttrs[IRFunctionArgs.getInallocaArgNo()].addInAllocaAttr(
3121 auto IRArgs = IRFunctionArgs.getIRArgs(0);
3123 assert(IRArgs.second == 1 &&
"Expected only a single `this` pointer.");
3125 llvm::AttrBuilder &Attrs = ArgAttrs[IRArgs.first];
3130 if (!CodeGenOpts.NullPointerIsValid &&
3132 Attrs.addAttribute(llvm::Attribute::NonNull);
3133 Attrs.addDereferenceableAttr(ThisSz);
3139 Attrs.addDereferenceableOrNullAttr(ThisSz);
3142 llvm::Align Alignment =
3146 Attrs.addAlignmentAttr(Alignment);
3148 const auto *DD = dyn_cast_if_present<CXXDestructorDecl>(
3162 CodeGenOpts.StrictLifetimes) {
3164 dyn_cast<CXXRecordDecl>(DD->getDeclContext());
3168 Attrs.addDeadOnReturnAttr(llvm::DeadOnReturnInfo(
3169 Context.getASTRecordLayout(ClassDecl).getDataSize().getQuantity()));
3173 if (
const auto *Fn = dyn_cast_if_present<FunctionDecl>(TargetDecl)) {
3174 if (Fn->isReplaceableGlobalAllocationFunction() &&
3175 Fn->getDeclName().isAnyOperatorDelete()) {
3176 auto IRArgs = IRFunctionArgs.getIRArgs(0);
3177 assert(IRArgs.second == 1 &&
"Expected only a single pointer to delete.");
3178 ArgAttrs[IRArgs.first].addAttribute(llvm::Attribute::AllocatedPointer);
3184 I != E; ++I, ++ArgNo) {
3190 if (IRFunctionArgs.hasPaddingArg(ArgNo)) {
3192 ArgAttrs[IRFunctionArgs.getPaddingArgNo(ArgNo)].addAttribute(
3193 llvm::Attribute::InReg);
3198 if (CodeGenOpts.EnableNoundefAttrs &&
3200 Attrs.addAttribute(llvm::Attribute::NoUndef);
3212 Attrs.addAttribute(llvm::Attribute::SExt);
3214 Attrs.addAttribute(llvm::Attribute::ZExt);
3216 Attrs.addAttribute(llvm::Attribute::NoExt);
3222 Attrs.addAttribute(llvm::Attribute::Nest);
3224 Attrs.addAttribute(llvm::Attribute::InReg);
3225 Attrs.addStackAlignmentAttr(llvm::MaybeAlign(AI.
getDirectAlign()));
3228 Attrs.addNoFPClassAttr(
3233 "Pass-by-value parameter has incomplete definition?");
3236 Attrs.addAttribute(llvm::Attribute::InReg);
3248 Attrs.addByValAttr(
getTypes().ConvertTypeForMem(ParamType));
3256 Attrs.addDeadOnReturnAttr(llvm::DeadOnReturnInfo());
3261 if (CodeGenOpts.PassByValueIsNoAlias &&
Decl &&
3262 Decl->getArgPassingRestrictions() ==
3266 Attrs.addAttribute(llvm::Attribute::NoAlias);
3296 Attrs.addAttribute(llvm::Attribute::NoFreeObj);
3297 Attrs.addDereferenceableAttr(
3298 Context.getTypeSizeInChars(ParamType).getQuantity());
3302 AddPotentialArgAccess();
3307 Attrs.addByRefAttr(
getTypes().ConvertTypeForMem(ParamType));
3318 AddPotentialArgAccess();
3326 if (
getTypes().getTargetAddressSpace(PTy) == 0 &&
3327 !CodeGenOpts.NullPointerIsValid)
3328 Attrs.addAttribute(llvm::Attribute::NonNull);
3330 llvm::Align Alignment =
3332 Attrs.addAlignmentAttr(Alignment);
3341 DeviceKernelAttr::isOpenCLSpelling(
3342 TargetDecl->
getAttr<DeviceKernelAttr>()) &&
3346 llvm::Align Alignment =
3348 Attrs.addAlignmentAttr(Alignment);
3355 Attrs.addAttribute(llvm::Attribute::NoAlias);
3364 Attrs.addStructRetAttr(
getTypes().ConvertTypeForMem(ParamType));
3369 Attrs.addAttribute(llvm::Attribute::NoAlias);
3373 if (!PTy->isIncompleteType() && PTy->isConstantSizeType()) {
3374 auto info =
getContext().getTypeInfoInChars(PTy);
3375 Attrs.addDereferenceableAttr(info.Width.getQuantity());
3376 Attrs.addAlignmentAttr(info.Align.getAsAlign());
3382 Attrs.addAttribute(llvm::Attribute::SwiftError);
3386 Attrs.addAttribute(llvm::Attribute::SwiftSelf);
3390 Attrs.addAttribute(llvm::Attribute::SwiftAsync);
3395 Attrs.addCapturesAttr(
3396 llvm::CaptureInfo(llvm::CaptureComponents::Address));
3398 if (Attrs.hasAttributes()) {
3399 unsigned FirstIRArg, NumIRArgs;
3400 std::tie(FirstIRArg, NumIRArgs) = IRFunctionArgs.getIRArgs(ArgNo);
3401 for (
unsigned i = 0; i < NumIRArgs; i++)
3402 ArgAttrs[FirstIRArg + i].merge(Attrs);
3410 AddPotentialArgAccess();
3413 if (AddedPotentialArgAccess && MemAttrForPtrArgs) {
3417 I != E; ++I, ++ArgNo) {
3418 if (I->info.isDirect() || I->info.isExpand() ||
3419 I->info.isCoerceAndExpand()) {
3420 unsigned FirstIRArg, NumIRArgs;
3421 std::tie(FirstIRArg, NumIRArgs) = IRFunctionArgs.getIRArgs(ArgNo);
3422 for (
unsigned i = FirstIRArg; i < FirstIRArg + NumIRArgs; ++i) {
3429 if (i < FunctionType->getNumParams() &&
3431 ArgAttrs[i].addAttribute(*MemAttrForPtrArgs);
3439 for (
const llvm::AttrBuilder &Attrs : ArgAttrs)
3440 ArgAttrSets.push_back(llvm::AttributeSet::get(
getLLVMContext(), Attrs));
3442 AttrList = llvm::AttributeList::get(
3444 llvm::AttributeSet::get(
getLLVMContext(), RetAttrs), ArgAttrSets);
3451 llvm::Value *value) {
3452 llvm::Type *varType = CGF.
ConvertType(var->getType());
3456 if (value->getType() == varType)
3459 assert((varType->isIntegerTy() || varType->isFloatingPointTy()) &&
3460 "unexpected promotion type");
3463 return CGF.
Builder.CreateTrunc(value, varType,
"arg.unpromote");
3465 return CGF.
Builder.CreateFPCast(value, varType,
"arg.unpromote");
3471 QualType ArgType,
unsigned ArgNo) {
3479 if (!ArgType->isAnyPointerType() && !ArgType->isBlockPointerType())
3483 if (
auto ParmNNAttr = PVD->
getAttr<NonNullAttr>())
3490 if (NNAttr->isNonNull(ArgNo))
3497struct CopyBackSwiftError final : EHScopeStack::Cleanup {
3500 CopyBackSwiftError(Address temp, Address arg) : Temp(temp), Arg(
arg) {}
3501 void Emit(CodeGenFunction &CGF, Flags flags)
override {
3520 if (FD->hasImplicitReturnZero()) {
3521 QualType RetTy = FD->getReturnType().getUnqualifiedType();
3522 llvm::Type *LLVMTy =
CGM.getTypes().ConvertType(RetTy);
3523 llvm::Constant *
Zero = llvm::Constant::getNullValue(LLVMTy);
3531 ClangToLLVMArgMapping IRFunctionArgs(
CGM.getContext(), FI);
3532 assert(Fn->arg_size() == IRFunctionArgs.totalIRArgs());
3537 if (IRFunctionArgs.hasInallocaArg())
3538 ArgStruct =
Address(Fn->getArg(IRFunctionArgs.getInallocaArgNo()),
3542 if (IRFunctionArgs.hasSRetArg()) {
3543 auto AI = Fn->getArg(IRFunctionArgs.getSRetArgNo());
3544 AI->setName(
"agg.result");
3545 AI->addAttr(llvm::Attribute::NoAlias);
3552 ArgVals.reserve(Args.size());
3558 assert(FI.
arg_size() == Args.size() &&
3559 "Mismatch between function signature & arguments.");
3562 for (FunctionArgList::const_iterator i = Args.begin(), e = Args.end(); i != e;
3563 ++i, ++info_it, ++ArgNo) {
3576 unsigned FirstIRArg, NumIRArgs;
3577 std::tie(FirstIRArg, NumIRArgs) = IRFunctionArgs.getIRArgs(ArgNo);
3581 assert(NumIRArgs == 0);
3594 assert(NumIRArgs == 1);
3617 llvm::ConstantInt::get(
IntPtrTy, Size.getQuantity()));
3618 ParamAddr = AlignedTemp;
3635 auto AI = Fn->getArg(FirstIRArg);
3643 assert(NumIRArgs == 1);
3645 if (
const ParmVarDecl *PVD = dyn_cast<ParmVarDecl>(Arg)) {
3648 PVD->getFunctionScopeIndex()) &&
3649 !
CGM.getCodeGenOpts().NullPointerIsValid)
3650 AI->addAttr(llvm::Attribute::NonNull);
3652 QualType OTy = PVD->getOriginalType();
3653 if (
const auto *ArrTy =
getContext().getAsConstantArrayType(OTy)) {
3659 QualType ETy = ArrTy->getElementType();
3660 llvm::Align Alignment =
3661 CGM.getNaturalTypeAlignment(ETy).getAsAlign();
3663 .addAlignmentAttr(Alignment));
3664 uint64_t ArrSize = ArrTy->getZExtSize();
3668 Attrs.addDereferenceableAttr(
3669 getContext().getTypeSizeInChars(ETy).getQuantity() *
3671 AI->addAttrs(Attrs);
3672 }
else if (
getContext().getTargetInfo().getNullPointerValue(
3674 !
CGM.getCodeGenOpts().NullPointerIsValid) {
3675 AI->addAttr(llvm::Attribute::NonNull);
3678 }
else if (
const auto *ArrTy =
3684 QualType ETy = ArrTy->getElementType();
3685 llvm::Align Alignment =
3686 CGM.getNaturalTypeAlignment(ETy).getAsAlign();
3688 .addAlignmentAttr(Alignment));
3689 if (!
getTypes().getTargetAddressSpace(ETy) &&
3690 !
CGM.getCodeGenOpts().NullPointerIsValid)
3691 AI->addAttr(llvm::Attribute::NonNull);
3696 const auto *AVAttr = PVD->getAttr<AlignValueAttr>();
3699 AVAttr = TOTy->getDecl()->getAttr<AlignValueAttr>();
3700 if (AVAttr && !
SanOpts.has(SanitizerKind::Alignment)) {
3704 llvm::ConstantInt *AlignmentCI =
3706 uint64_t AlignmentInt =
3707 AlignmentCI->getLimitedValue(llvm::Value::MaximumAlignment);
3708 if (AI->getParamAlign().valueOrOne() < AlignmentInt) {
3709 AI->removeAttr(llvm::Attribute::AttrKind::Alignment);
3711 .addAlignmentAttr(llvm::Align(AlignmentInt)));
3718 AI->addAttr(llvm::Attribute::NoAlias);
3726 assert(NumIRArgs == 1);
3730 llvm::Value *
V = AI;
3738 V, pointeeTy,
getContext().getTypeAlignInChars(pointeeTy));
3739 llvm::Value *incomingErrorValue =
Builder.CreateLoad(arg);
3740 Builder.CreateStore(incomingErrorValue, temp);
3761 if (
V->getType() != LTy)
3772 if (
auto *VecTyTo = dyn_cast<llvm::FixedVectorType>(
ConvertType(Ty))) {
3773 llvm::Value *ArgVal = Fn->getArg(FirstIRArg);
3774 if (
auto *VecTyFrom =
3775 dyn_cast<llvm::ScalableVectorType>(ArgVal->getType())) {
3777 *
this, VecTyTo, VecTyFrom, ArgVal, Arg->
getName());
3779 assert(NumIRArgs == 1);
3786 llvm::StructType *STy =
3797 STy->getNumElements() > 1) {
3798 llvm::TypeSize StructSize =
CGM.getDataLayout().getTypeAllocSize(STy);
3799 llvm::TypeSize PtrElementSize =
3800 CGM.getDataLayout().getTypeAllocSize(Ptr.getElementType());
3801 if (StructSize.isScalable()) {
3802 assert(STy->containsHomogeneousScalableVectorTypes() &&
3803 "ABI only supports structure with homogeneous scalable vector "
3805 assert(StructSize == PtrElementSize &&
3806 "Only allow non-fractional movement of structure with"
3807 "homogeneous scalable vector type");
3808 assert(STy->getNumElements() == NumIRArgs);
3810 llvm::Value *LoadedStructValue = llvm::PoisonValue::get(STy);
3811 for (
unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
3812 auto *AI = Fn->getArg(FirstIRArg + i);
3813 AI->setName(Arg->
getName() +
".coerce" + Twine(i));
3815 Builder.CreateInsertValue(LoadedStructValue, AI, i);
3818 Builder.CreateStore(LoadedStructValue, Ptr);
3820 uint64_t SrcSize = StructSize.getFixedValue();
3821 uint64_t DstSize = PtrElementSize.getFixedValue();
3824 if (SrcSize <= DstSize) {
3825 AddrToStoreInto = Ptr.withElementType(STy);
3831 assert(STy->getNumElements() == NumIRArgs);
3832 for (
unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
3833 auto AI = Fn->getArg(FirstIRArg + i);
3834 AI->setName(Arg->
getName() +
".coerce" + Twine(i));
3836 Builder.CreateStore(AI, EltPtr);
3839 if (SrcSize > DstSize) {
3840 Builder.CreateMemCpy(Ptr, AddrToStoreInto, DstSize);
3852 assert(NumIRArgs == 1);
3853 auto AI = Fn->getArg(FirstIRArg);
3854 AI->setName(Arg->
getName() +
".coerce");
3857 llvm::TypeSize::getFixed(
3858 getContext().getTypeSizeInChars(Ty).getQuantity() -
3884 auto *unpaddedStruct = dyn_cast<llvm::StructType>(unpaddedCoercionType);
3888 unsigned argIndex = FirstIRArg;
3889 unsigned unpaddedIndex = 0;
3890 for (
unsigned i = 0, e = coercionType->getNumElements(); i != e; ++i) {
3891 llvm::Type *eltType = coercionType->getElementType(i);
3895 auto eltAddr =
Builder.CreateStructGEP(alloca, i);
3896 llvm::Value *elt = Fn->getArg(argIndex++);
3898 auto paramType = unpaddedStruct
3899 ? unpaddedStruct->getElementType(unpaddedIndex++)
3900 : unpaddedCoercionType;
3902 if (
auto *VecTyTo = dyn_cast<llvm::FixedVectorType>(eltType)) {
3903 if (
auto *VecTyFrom = dyn_cast<llvm::ScalableVectorType>(paramType)) {
3906 *
this, VecTyTo, VecTyFrom, elt, elt->getName());
3907 assert(Extracted &&
"Unexpected scalable to fixed vector coercion");
3910 Builder.CreateStore(elt, eltAddr);
3912 assert(argIndex == FirstIRArg + NumIRArgs);
3925 auto FnArgIter = Fn->arg_begin() + FirstIRArg;
3926 ExpandTypeFromArgs(Ty, LV, FnArgIter);
3927 assert(FnArgIter == Fn->arg_begin() + FirstIRArg + NumIRArgs);
3928 for (
unsigned i = 0, e = NumIRArgs; i != e; ++i) {
3929 auto AI = Fn->getArg(FirstIRArg + i);
3930 AI->setName(Arg->
getName() +
"." + Twine(i));
3936 auto *AI = Fn->getArg(FirstIRArg);
3937 AI->setName(Arg->
getName() +
".target_coerce");
3941 CGM.getABIInfo().createCoercedStore(AI, Ptr, ArgI,
false, *
this);
3955 assert(NumIRArgs == 0);
3968 if (
getTarget().getCXXABI().areArgsDestroyedLeftToRightInCallee()) {
3969 for (
int I = Args.size() - 1; I >= 0; --I)
3972 for (
unsigned I = 0, E = Args.size(); I != E; ++I)
3978 while (insn->use_empty()) {
3979 llvm::BitCastInst *bitcast = dyn_cast<llvm::BitCastInst>(insn);
3985 bitcast->eraseFromParent();
3991 llvm::Value *result) {
3993 llvm::BasicBlock *BB = CGF.
Builder.GetInsertBlock();
3996 if (&BB->back() != result)
3999 llvm::Type *resultType = result->getType();
4008 while (llvm::BitCastInst *bitcast = dyn_cast<llvm::BitCastInst>(generator)) {
4014 if (generator->getNextNode() != bitcast)
4017 InstsToKill.push_back(bitcast);
4024 llvm::CallInst *call = dyn_cast<llvm::CallInst>(generator);
4028 bool doRetainAutorelease;
4031 doRetainAutorelease =
true;
4032 }
else if (call->getCalledOperand() ==
4034 doRetainAutorelease =
false;
4042 llvm::Instruction *prev = call->getPrevNode();
4045 prev = prev->getPrevNode();
4051 InstsToKill.push_back(prev);
4057 result = call->getArgOperand(0);
4058 InstsToKill.push_back(call);
4062 while (llvm::BitCastInst *bitcast = dyn_cast<llvm::BitCastInst>(result)) {
4063 if (!bitcast->hasOneUse())
4065 InstsToKill.push_back(bitcast);
4066 result = bitcast->getOperand(0);
4070 for (
auto *I : InstsToKill)
4071 I->eraseFromParent();
4074 if (doRetainAutorelease)
4078 return CGF.
Builder.CreateBitCast(result, resultType);
4083 llvm::Value *result) {
4086 dyn_cast_or_null<ObjCMethodDecl>(CGF.
CurCodeDecl);
4095 llvm::CallInst *retainCall = dyn_cast<llvm::CallInst>(result);
4096 if (!retainCall || retainCall->getCalledOperand() !=
4101 llvm::Value *retainedValue = retainCall->getArgOperand(0);
4102 llvm::LoadInst *load =
4103 dyn_cast<llvm::LoadInst>(retainedValue->stripPointerCasts());
4104 if (!load || load->isAtomic() || load->isVolatile() ||
4111 llvm::Type *resultType = result->getType();
4113 assert(retainCall->use_empty());
4114 retainCall->eraseFromParent();
4117 return CGF.
Builder.CreateBitCast(load, resultType);
4124 llvm::Value *result) {
4147 auto GetStoreIfValid = [&CGF,
4148 ReturnValuePtr](llvm::User *
U) -> llvm::StoreInst * {
4149 auto *SI = dyn_cast<llvm::StoreInst>(
U);
4150 if (!SI || SI->getPointerOperand() != ReturnValuePtr ||
4156 assert(!SI->isAtomic() &&
4164 if (!ReturnValuePtr->hasOneUse()) {
4165 llvm::BasicBlock *IP = CGF.
Builder.GetInsertBlock();
4171 const llvm::Instruction *LoadIntoFakeUse =
nullptr;
4172 for (llvm::Instruction &I : llvm::reverse(*IP)) {
4176 if (LoadIntoFakeUse == &I)
4180 if (
auto *II = dyn_cast<llvm::IntrinsicInst>(&I)) {
4181 if (II->getIntrinsicID() == llvm::Intrinsic::lifetime_end)
4184 if (II->getIntrinsicID() == llvm::Intrinsic::fake_use) {
4185 LoadIntoFakeUse = dyn_cast<llvm::Instruction>(II->getArgOperand(0));
4189 return GetStoreIfValid(&I);
4194 llvm::StoreInst *store = GetStoreIfValid(ReturnValuePtr->user_back());
4200 llvm::BasicBlock *StoreBB = store->getParent();
4201 llvm::BasicBlock *IP = CGF.
Builder.GetInsertBlock();
4203 while (IP != StoreBB) {
4204 if (!SeenBBs.insert(IP).second || !(IP = IP->getSinglePredecessor()))
4220 int BitWidth,
int CharWidth) {
4221 assert(CharWidth <= 64);
4222 assert(
static_cast<unsigned>(BitWidth) <= Bits.size() * CharWidth);
4225 if (BitOffset >= CharWidth) {
4226 Pos += BitOffset / CharWidth;
4227 BitOffset = BitOffset % CharWidth;
4231 if (BitOffset + BitWidth >= CharWidth) {
4232 Bits[Pos++] |= (
Used << BitOffset) &
Used;
4233 BitWidth -= CharWidth - BitOffset;
4237 while (BitWidth >= CharWidth) {
4239 BitWidth -= CharWidth;
4243 Bits[Pos++] |= (
Used >> (CharWidth - BitWidth)) << BitOffset;
4251 int StorageSize,
int BitOffset,
int BitWidth,
4252 int CharWidth,
bool BigEndian) {
4255 setBitRange(TmpBits, BitOffset, BitWidth, CharWidth);
4258 std::reverse(TmpBits.begin(), TmpBits.end());
4261 Bits[StorageOffset++] |=
V;
4264static void setUsedBits(CodeGenModule &, QualType,
int,
4265 SmallVectorImpl<uint64_t> &);
4307 QualType ETy = Context.getBaseElementType(ATy);
4308 int Size = Context.getTypeSizeInChars(ETy).getQuantity();
4312 for (
int I = 0, N = Context.getConstantArrayElementCount(ATy); I < N; ++I) {
4313 auto Src = TmpBits.begin();
4314 auto Dst = Bits.begin() + Offset + I * Size;
4315 for (
int J = 0; J < Size; ++J)
4328 if (
const auto *ATy = Context.getAsConstantArrayType(QTy))
4331 int Size = Context.getTypeSizeInChars(QTy).getQuantity();
4335 std::fill_n(Bits.begin() + Offset, Size,
4336 (
uint64_t(1) << Context.getCharWidth()) - 1);
4340 int Pos,
int Size,
int CharWidth,
4345 for (
auto P = Bits.begin() + Pos, E = Bits.begin() + Pos + Size; P != E;
4347 Mask = (Mask << CharWidth) | *P;
4349 auto P = Bits.begin() + Pos + Size, End = Bits.begin() + Pos;
4351 Mask = (Mask << CharWidth) | *--P;
4360 llvm::IntegerType *ITy,
4362 assert(Src->getType() == ITy);
4363 assert(ITy->getScalarSizeInBits() <= 64);
4365 const llvm::DataLayout &DataLayout =
CGM.getDataLayout();
4366 int Size = DataLayout.getTypeStoreSize(ITy);
4370 int CharWidth =
CGM.getContext().getCharWidth();
4374 return Builder.CreateAnd(Src, Mask,
"cmse.clear");
4380 llvm::ArrayType *ATy,
4382 const llvm::DataLayout &DataLayout =
CGM.getDataLayout();
4383 int Size = DataLayout.getTypeStoreSize(ATy);
4388 int CharWidth =
CGM.getContext().getCharWidth();
4390 ATy->getArrayElementType()->getScalarSizeInBits() / CharWidth;
4392 llvm::Value *R = llvm::PoisonValue::get(ATy);
4393 for (
int I = 0, N = ATy->getArrayNumElements(); I != N; ++I) {
4395 DataLayout.isBigEndian());
4396 MaskIndex += CharsPerElt;
4397 llvm::Value *T0 =
Builder.CreateExtractValue(Src, I);
4398 llvm::Value *T1 =
Builder.CreateAnd(T0, Mask,
"cmse.clear");
4399 R =
Builder.CreateInsertValue(R, T1, I);
4407 uint64_t RetKeyInstructionsSourceAtom) {
4422 auto *I =
Builder.CreateRetVoid();
4423 if (RetKeyInstructionsSourceAtom)
4430 llvm::DebugLoc RetDbgLoc;
4431 llvm::Value *RV =
nullptr;
4441 llvm::Function::arg_iterator EI =
CurFn->arg_end();
4443 llvm::Value *ArgStruct = &*EI;
4444 llvm::Value *SRet =
Builder.CreateStructGEP(
4453 auto AI =
CurFn->arg_begin();
4471 CGM.getNaturalTypeAlignment(RetTy, &BaseInfo, &TBAAInfo);
4498 RetDbgLoc = SI->getDebugLoc();
4500 RV = SI->getValueOperand();
4501 SI->eraseFromParent();
4524 if (
auto *FD = dyn_cast<FunctionDecl>(
CurCodeDecl))
4525 RT = FD->getReturnType();
4526 else if (
auto *MD = dyn_cast<ObjCMethodDecl>(
CurCodeDecl))
4527 RT = MD->getReturnType();
4529 RT =
BlockInfo->BlockExpression->getFunctionType()->getReturnType();
4531 llvm_unreachable(
"Unexpected function/method type");
4547 auto *unpaddedStruct = dyn_cast<llvm::StructType>(unpaddedCoercionType);
4552 unsigned unpaddedIndex = 0;
4553 for (
unsigned i = 0, e = coercionType->getNumElements(); i != e; ++i) {
4554 auto coercedEltType = coercionType->getElementType(i);
4558 auto eltAddr =
Builder.CreateStructGEP(addr, i);
4561 unpaddedStruct ? unpaddedStruct->getElementType(unpaddedIndex++)
4562 : unpaddedCoercionType,
4564 results.push_back(elt);
4568 if (results.size() == 1) {
4576 RV = llvm::PoisonValue::get(returnType);
4577 for (
unsigned i = 0, e = results.size(); i != e; ++i) {
4578 RV =
Builder.CreateInsertValue(RV, results[i], i);
4585 RV =
CGM.getABIInfo().createCoercedLoad(
V, RetAI, *
this);
4590 llvm_unreachable(
"Invalid ABI kind for return argument");
4593 llvm::Instruction *Ret;
4599 auto *ITy = dyn_cast<llvm::IntegerType>(RV->getType());
4606 Ret =
Builder.CreateRetVoid();
4610 Ret->setDebugLoc(std::move(RetDbgLoc));
4612 llvm::Value *Backup = RV ? Ret->getOperand(0) :
nullptr;
4613 if (RetKeyInstructionsSourceAtom)
4629 if (
SanOpts.has(SanitizerKind::Alignment)) {
4630 if (
const AllocAlignAttr *AA =
CurCodeDecl->getAttr<AllocAlignAttr>()) {
4632 unsigned PI = AA->getParamIndex().getLLVMIndex();
4633 llvm::Value *Alignment =
CurFn->getArg(PI);
4638 if (
const AssumeAlignedAttr *AA =
4641 llvm::ConstantInt *OffsetCI =
nullptr;
4642 if (
Expr *Offset = AA->getOffset()) {
4644 if (OffsetCI->isNullValue())
4648 Alignment, OffsetCI);
4652 ReturnsNonNullAttr *RetNNAttr =
nullptr;
4653 if (
SanOpts.has(SanitizerKind::ReturnsNonnullAttribute))
4654 RetNNAttr =
CurCodeDecl->getAttr<ReturnsNonNullAttr>();
4656 if (!RetNNAttr && !requiresReturnValueNullabilityCheck())
4664 assert(!requiresReturnValueNullabilityCheck() &&
4665 "Cannot check nullability and the nonnull attribute");
4666 AttrLoc = RetNNAttr->getLocation();
4667 CheckKind = SanitizerKind::SO_ReturnsNonnullAttribute;
4668 Handler = SanitizerHandler::NonnullReturn;
4670 if (
auto *DD = dyn_cast<DeclaratorDecl>(
CurCodeDecl))
4671 if (
auto *TSI = DD->getTypeSourceInfo())
4673 AttrLoc = FTL.getReturnLoc().findNullabilityLoc();
4674 CheckKind = SanitizerKind::SO_NullabilityReturn;
4675 Handler = SanitizerHandler::NullabilityReturn;
4684 llvm::Value *SLocPtr =
Builder.CreateLoad(ReturnLocation,
"return.sloc.load");
4685 llvm::Value *CanNullCheck =
Builder.CreateIsNotNull(SLocPtr);
4686 if (requiresReturnValueNullabilityCheck())
4688 Builder.CreateAnd(CanNullCheck, RetValNullabilityPrecondition);
4689 Builder.CreateCondBr(CanNullCheck, Check, NoCheck);
4693 llvm::Value *Cond =
Builder.CreateIsNotNull(RV);
4695 llvm::Value *DynamicData[] = {SLocPtr};
4696 EmitCheck(std::make_pair(Cond, CheckKind), Handler, StaticData, DynamicData);
4715 llvm::Type *IRPtrTy = llvm::PointerType::getUnqual(CGF.
getLLVMContext());
4716 llvm::Value *Placeholder = llvm::PoisonValue::get(IRPtrTy);
4741 if (
type->isReferenceType()) {
4750 param->
hasAttr<NSConsumedAttr>() &&
type->isObjCRetainableType()) {
4751 llvm::Value *ptr =
Builder.CreateLoad(local);
4754 Builder.CreateStore(null, local);
4765 type->castAsRecordDecl()->isParamDestroyedInCallee() &&
4769 assert(cleanup.isValid() &&
4770 "cleanup for callee-destructed param not recorded");
4772 llvm::Instruction *isActive =
4779 return llvm::isa_and_nonnull<llvm::ConstantPointerNull>(addr);
4789 const LValue &srcLV = writeback.
Source;
4790 Address srcAddr = srcLV.getAddress();
4792 "shouldn't have writeback for provably null argument");
4800 llvm::BasicBlock *contBB =
nullptr;
4806 if (!provablyNonNull) {
4811 CGF.
Builder.CreateCondBr(isNull, contBB, writebackBB);
4820 "icr.writeback-cast");
4829 if (writeback.
ToUse) {
4854 if (!provablyNonNull)
4863 for (
const auto &I : llvm::reverse(Cleanups)) {
4865 I.IsActiveIP->eraseFromParent();
4871 if (uop->getOpcode() == UO_AddrOf)
4872 return uop->getSubExpr();
4897 Address srcAddr = srcLV.getAddress();
4902 llvm::PointerType *destType =
4904 llvm::Type *destElemType =
4931 llvm::BasicBlock *contBB =
nullptr;
4932 llvm::BasicBlock *originBB =
nullptr;
4935 llvm::Value *finalArgument;
4939 if (provablyNonNull) {
4944 finalArgument = CGF.
Builder.CreateSelect(
4945 isNull, llvm::ConstantPointerNull::get(destType),
4951 originBB = CGF.
Builder.GetInsertBlock();
4954 CGF.
Builder.CreateCondBr(isNull, contBB, copyBB);
4956 condEval.
begin(CGF);
4960 llvm::Value *valueToUse =
nullptr;
4968 src = CGF.
Builder.CreateBitCast(src, destElemType,
"icr.cast");
4985 if (shouldCopy && !provablyNonNull) {
4986 llvm::BasicBlock *copyBB = CGF.
Builder.GetInsertBlock();
4991 llvm::PHINode *phiToUse =
4992 CGF.
Builder.CreatePHI(valueToUse->getType(), 2,
"icr.to-use");
4993 phiToUse->addIncoming(valueToUse, copyBB);
4994 phiToUse->addIncoming(llvm::PoisonValue::get(valueToUse->getType()),
4996 valueToUse = phiToUse;
5010 StackBase = CGF.
Builder.CreateStackSave(
"inalloca.save");
5016 CGF.
Builder.CreateStackRestore(StackBase);
5023 if (!AC.
getDecl() || !(
SanOpts.has(SanitizerKind::NonnullAttribute) ||
5024 SanOpts.has(SanitizerKind::NullabilityArg)))
5029 unsigned ArgNo = PVD ? PVD->getFunctionScopeIndex() : ParmNum;
5032 const NonNullAttr *NNAttr =
nullptr;
5033 if (
SanOpts.has(SanitizerKind::NonnullAttribute))
5036 bool CanCheckNullability =
false;
5037 if (
SanOpts.has(SanitizerKind::NullabilityArg) && !NNAttr && PVD &&
5038 !PVD->getType()->isRecordType()) {
5039 auto Nullability = PVD->getType()->getNullability();
5040 CanCheckNullability = Nullability &&
5042 PVD->getTypeSourceInfo();
5045 if (!NNAttr && !CanCheckNullability)
5052 AttrLoc = NNAttr->getLocation();
5053 CheckKind = SanitizerKind::SO_NonnullAttribute;
5054 Handler = SanitizerHandler::NonnullArg;
5056 AttrLoc = PVD->getTypeSourceInfo()->getTypeLoc().findNullabilityLoc();
5057 CheckKind = SanitizerKind::SO_NullabilityArg;
5058 Handler = SanitizerHandler::NullabilityArg;
5063 llvm::Constant *StaticData[] = {
5066 llvm::ConstantInt::get(
Int32Ty, ArgNo + 1),
5068 EmitCheck(std::make_pair(Cond, CheckKind), Handler, StaticData, {});
5074 if (!AC.
getDecl() || !(
SanOpts.has(SanitizerKind::NonnullAttribute) ||
5075 SanOpts.has(SanitizerKind::NullabilityArg)))
5094 return llvm::any_of(ArgTypes, [&](
QualType Ty) {
5105 return classDecl->getTypeParamListAsWritten();
5109 return catDecl->getTypeParamList();
5119 llvm::iterator_range<CallExpr::const_arg_iterator> ArgRange,
5123 assert((ParamsToSkip == 0 ||
Prototype.P) &&
5124 "Can't skip parameters if type info is not provided");
5134 bool IsVariadic =
false;
5136 const auto *MD = dyn_cast<const ObjCMethodDecl *>(
Prototype.P);
5138 IsVariadic = MD->isVariadic();
5140 MD,
CGM.getTarget().getTriple().isOSWindows());
5141 ArgTypes.assign(MD->param_type_begin() + ParamsToSkip,
5142 MD->param_type_end());
5145 IsVariadic = FPT->isVariadic();
5146 ExplicitCC = FPT->getExtInfo().getCC();
5147 ArgTypes.assign(FPT->param_type_begin() + ParamsToSkip,
5148 FPT->param_type_end());
5156 assert(Arg != ArgRange.end() &&
"Running over edge of argument list!");
5158 QualType ArgTy = (*Arg)->getType();
5159 if (
const auto *OBT = ParamTy->
getAs<OverflowBehaviorType>())
5160 ParamTy = OBT->getUnderlyingType();
5161 if (
const auto *OBT = ArgTy->
getAs<OverflowBehaviorType>())
5162 ArgTy = OBT->getUnderlyingType();
5165 getContext().getCanonicalType(ParamTy).getTypePtr() ==
5166 getContext().getCanonicalType(ArgTy).getTypePtr()) &&
5167 "type mismatch in call argument!");
5173 assert((Arg == ArgRange.end() || IsVariadic) &&
5174 "Extra arguments in non-variadic function!");
5179 for (
auto *A : llvm::drop_begin(ArgRange, ArgTypes.size()))
5180 ArgTypes.push_back(IsVariadic ? getVarArgType(A) : A->getType());
5181 assert((
int)ArgTypes.size() == (ArgRange.end() - ArgRange.begin()));
5189 Order,
CGM.getTarget().getCXXABI());
5191 auto MaybeEmitImplicitObjectSize = [&](
unsigned I,
const Expr *Arg,
5200 auto SizeTy = Context.getSizeType();
5202 assert(EmittedArg.getScalarVal() &&
"We emitted nothing for the arg?");
5203 llvm::Value *
V = evaluateOrEmitBuiltinObjectSize(
5204 Arg, PS->getType(),
T, EmittedArg.getScalarVal(), PS->isDynamic());
5209 std::swap(Args.back(), *(&Args.back() - 1));
5215 "inalloca only supported on x86");
5220 size_t CallArgsStart = Args.size();
5221 for (
unsigned I = 0, E = ArgTypes.size(); I != E; ++I) {
5222 unsigned Idx = LeftToRight ? I : E - I - 1;
5224 unsigned InitialArgSize = Args.size();
5228 getContext().hasSameUnqualifiedType((*Arg)->getType(),
5232 "Argument and parameter types don't match");
5236 assert(InitialArgSize + 1 == Args.size() &&
5237 "The code below depends on only adding one arg per EmitCallArg");
5238 (void)InitialArgSize;
5241 if (!Args.back().hasLValue()) {
5242 RValue RVArg = Args.back().getKnownRValue();
5244 ParamsToSkip + Idx);
5248 MaybeEmitImplicitObjectSize(Idx, *Arg, RVArg);
5255 std::reverse(Args.begin() + CallArgsStart, Args.end());
5264struct DestroyUnpassedArg final : EHScopeStack::Cleanup {
5274 assert(!Dtor->isTrivial());
5297 if (!HasLV &&
RV.isScalar())
5299 else if (!HasLV &&
RV.isComplex())
5302 auto Addr = HasLV ?
LV.getAddress() :
RV.getAggregateAddress();
5306 HasLV ?
LV.isVolatileQualified()
5307 :
RV.isVolatileQualified());
5319 std::optional<DisableDebugLocationUpdates> Dis;
5323 dyn_cast<ObjCIndirectCopyRestoreExpr>(E)) {
5337 "reference binding to unmaterialized r-value!");
5349 if (
type->isRecordType() &&
5350 type->castAsRecordDecl()->isParamDestroyedInCallee()) {
5357 bool DestroyedInCallee =
true, NeedsCleanup =
true;
5358 if (
const auto *RD =
type->getAsCXXRecordDecl())
5359 DestroyedInCallee = RD->hasNonTrivialDestructor();
5361 NeedsCleanup =
type.isDestructedType();
5363 if (DestroyedInCallee)
5370 if (DestroyedInCallee && NeedsCleanup) {
5377 llvm::Instruction *IsActive =
5384 if (HasAggregateEvalKind) {
5385 auto *ICE = dyn_cast<ImplicitCastExpr>(E);
5386 if (ICE && ICE->getCastKind() == CK_LValueToRValue &&
5387 ICE->getSubExpr()->getType().getAddressSpace() !=
5389 !
type->isArrayParameterType() && !
type.isNonTrivialToPrimitiveCopy()) {
5400QualType CodeGenFunction::getVarArgType(
const Expr *Arg) {
5404 if (!getTarget().
getTriple().isOSWindows())
5408 getContext().getTypeSize(Arg->
getType()) <
5412 return getContext().getIntPtrType();
5420void CodeGenFunction::AddObjCARCExceptionMetadata(llvm::Instruction *Inst) {
5421 if (CGM.getCodeGenOpts().OptimizationLevel != 0 &&
5422 !CGM.getCodeGenOpts().ObjCAutoRefCountExceptions)
5423 Inst->setMetadata(
"clang.arc.no_objc_arc_exceptions",
5424 CGM.getNoObjCARCExceptionsMetadata());
5430 const llvm::Twine &name) {
5431 return EmitNounwindRuntimeCall(callee, ArrayRef<llvm::Value *>(), name);
5437 ArrayRef<Address> args,
5438 const llvm::Twine &name) {
5439 SmallVector<llvm::Value *, 3> values;
5440 for (
auto arg : args)
5441 values.push_back(
arg.emitRawPointer(*
this));
5442 return EmitNounwindRuntimeCall(callee, values, name);
5447 ArrayRef<llvm::Value *> args,
5448 const llvm::Twine &name) {
5449 llvm::CallInst *call = EmitRuntimeCall(callee, args, name);
5450 call->setDoesNotThrow();
5457 const llvm::Twine &name) {
5458 return EmitRuntimeCall(callee, {},
name);
5463SmallVector<llvm::OperandBundleDef, 1>
5472 if (
auto *CalleeFn = dyn_cast<llvm::Function>(Callee->stripPointerCasts())) {
5473 if (CalleeFn->isIntrinsic() && CalleeFn->doesNotThrow()) {
5474 auto IID = CalleeFn->getIntrinsicID();
5475 if (!llvm::IntrinsicInst::mayLowerToFunctionCall(IID))
5486 assert(F->isIntrinsic() &&
"expected an intrinsic declaration");
5487 return F->isConvergent();
5492 ArrayRef<llvm::Value *> args,
5493 const llvm::Twine &name,
5494 bool IsConvergent) {
5495 SmallVector<llvm::OperandBundleDef> BundleList =
5496 getBundlesForFunclet(callee.getCallee());
5498 addConvergenceControlBundle(BundleList);
5500 llvm::CallInst *call = Builder.CreateCall(callee, args, BundleList, name);
5501 call->setCallingConv(getRuntimeCC());
5502 assert((IsConvergent == call->isConvergent() ||
5503 (!IsConvergent && !CGM.shouldEmitConvergenceTokens())) &&
5504 "runtime call convergence doesn't match its declaration");
5509 const llvm::Twine &Name) {
5510 return EmitIntrinsicCall(ID, {}, {}, Name);
5514 ArrayRef<llvm::Value *> Args,
5515 const llvm::Twine &Name) {
5516 return EmitIntrinsicCall(ID, {}, Args, Name);
5520 ArrayRef<llvm::Type *> Types,
5521 ArrayRef<llvm::Value *> Args,
5522 const llvm::Twine &Name) {
5524 llvm::Intrinsic::getOrInsertDeclaration(&CGM.getModule(), ID, Types);
5525 SmallVector<llvm::OperandBundleDef> BundleList = getBundlesForFunclet(F);
5527 addConvergenceControlBundle(BundleList);
5528 return Builder.CreateCall(F, Args, BundleList, Name);
5532 ArrayRef<llvm::Value *> Args,
5534 const llvm::Twine &Name) {
5535 SmallVector<llvm::Type *> ArgTys;
5536 ArgTys.reserve(Args.size());
5537 for (llvm::Value *Arg : Args)
5538 ArgTys.push_back(Arg->
getType());
5539 llvm::Function *F = llvm::Intrinsic::getOrInsertDeclaration(
5540 &CGM.getModule(), ID, RetTy, ArgTys);
5541 SmallVector<llvm::OperandBundleDef> BundleList = getBundlesForFunclet(F);
5543 addConvergenceControlBundle(BundleList);
5544 return Builder.CreateCall(F, Args, BundleList, Name);
5554 llvm::InvokeInst *invoke =
Builder.CreateInvoke(
5556 invoke->setDoesNotReturn();
5559 llvm::CallInst *call =
Builder.CreateCall(callee, args, BundleList);
5560 call->setDoesNotReturn();
5569 const Twine &name) {
5577 const Twine &name) {
5587 const Twine &Name) {
5592 llvm::CallBase *Inst;
5594 Inst =
Builder.CreateCall(Callee, Args, BundleList, Name);
5597 Inst =
Builder.CreateInvoke(Callee, ContBB, InvokeDest, Args, BundleList,
5604 if (
CGM.getLangOpts().ObjCAutoRefCount)
5605 AddObjCARCExceptionMetadata(Inst);
5610void CodeGenFunction::deferPlaceholderReplacement(llvm::Instruction *Old,
5612 DeferredReplacements.push_back(
5613 std::make_pair(llvm::WeakTrackingVH(Old),
New));
5620[[nodiscard]] llvm::AttributeList
5621maybeRaiseRetAlignmentAttribute(llvm::LLVMContext &Ctx,
5622 const llvm::AttributeList &Attrs,
5623 llvm::Align NewAlign) {
5624 llvm::Align CurAlign = Attrs.getRetAlignment().valueOrOne();
5625 if (CurAlign >= NewAlign)
5627 llvm::Attribute AlignAttr = llvm::Attribute::getWithAlignment(Ctx, NewAlign);
5628 return Attrs.removeRetAttribute(Ctx, llvm::Attribute::AttrKind::Alignment)
5629 .addRetAttribute(Ctx, AlignAttr);
5632template <
typename AlignedAttrTy>
class AbstractAssumeAlignedAttrEmitter {
5637 const AlignedAttrTy *AA =
nullptr;
5639 llvm::Value *Alignment =
nullptr;
5640 llvm::ConstantInt *OffsetCI =
nullptr;
5646 AA = FuncDecl->
getAttr<AlignedAttrTy>();
5651 [[nodiscard]] llvm::AttributeList
5652 TryEmitAsCallSiteAttribute(
const llvm::AttributeList &Attrs) {
5653 if (!AA || OffsetCI || CGF.
SanOpts.
has(SanitizerKind::Alignment))
5655 const auto *AlignmentCI = dyn_cast<llvm::ConstantInt>(Alignment);
5660 if (!AlignmentCI->getValue().isPowerOf2())
5662 llvm::AttributeList NewAttrs = maybeRaiseRetAlignmentAttribute(
5665 AlignmentCI->getLimitedValue(llvm::Value::MaximumAlignment)));
5673 void EmitAsAnAssumption(SourceLocation Loc, QualType RetTy, RValue &Ret) {
5677 AA->getLocation(), Alignment, OffsetCI);
5683class AssumeAlignedAttrEmitter final
5684 :
public AbstractAssumeAlignedAttrEmitter<AssumeAlignedAttr> {
5686 AssumeAlignedAttrEmitter(CodeGenFunction &CGF_,
const Decl *FuncDecl)
5687 : AbstractAssumeAlignedAttrEmitter(CGF_, FuncDecl) {
5692 if (Expr *Offset = AA->getOffset()) {
5694 if (OffsetCI->isNullValue())
5701class AllocAlignAttrEmitter final
5702 :
public AbstractAssumeAlignedAttrEmitter<AllocAlignAttr> {
5704 AllocAlignAttrEmitter(CodeGenFunction &CGF_,
const Decl *FuncDecl,
5705 const CallArgList &CallArgs)
5706 : AbstractAssumeAlignedAttrEmitter(CGF_, FuncDecl) {
5710 Alignment = CallArgs[AA->getParamIndex().getLLVMIndex()]
5715 [[nodiscard]] llvm::AttributeList
5716 TryEmitAsCallSiteAttribute(
const llvm::AttributeList &Attrs,
5717 const ClangToLLVMArgMapping &IRFunctionArgs) {
5718 llvm::AttributeList NewAttrs = Attrs;
5720 auto [FirstIRArg, NumIRArgs] =
5721 IRFunctionArgs.getIRArgs(AA->getParamIndex().getLLVMIndex());
5723 NewAttrs = NewAttrs.addParamAttribute(CGF.
getLLVMContext(), FirstIRArg,
5724 llvm::Attribute::AllocAlign);
5733 return AbstractAssumeAlignedAttrEmitter<
5734 AllocAlignAttr>::TryEmitAsCallSiteAttribute(NewAttrs);
5741 if (
auto *VT = dyn_cast<llvm::VectorType>(Ty))
5742 return VT->getPrimitiveSizeInBits().getKnownMinValue();
5743 if (
auto *AT = dyn_cast<llvm::ArrayType>(Ty))
5746 unsigned MaxVectorWidth = 0;
5747 if (
auto *ST = dyn_cast<llvm::StructType>(Ty))
5748 for (
auto *I : ST->elements())
5750 return MaxVectorWidth;
5757 llvm::CallBase **callOrInvoke,
bool IsMustTail,
5759 bool IsVirtualFunctionPointerThunk) {
5762 assert(Callee.isOrdinary() || Callee.isVirtual());
5769 llvm::FunctionType *IRFuncTy =
getTypes().GetFunctionType(CallInfo);
5771 const Decl *TargetDecl = Callee.getAbstractInfo().getCalleeDecl().getDecl();
5772 if (
const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(TargetDecl)) {
5779 if ((TargetDecl->
hasAttr<AlwaysInlineAttr>() &&
5780 (TargetDecl->
hasAttr<TargetAttr>() ||
5784 TargetDecl->
hasAttr<TargetAttr>())))
5791 const FunctionDecl *CalleeDecl = dyn_cast_or_null<FunctionDecl>(TargetDecl);
5792 CGM.getTargetCodeGenInfo().checkFunctionCallABI(
CGM, Loc, CallerDecl,
5793 CalleeDecl, CallArgs, RetTy);
5800 if (llvm::StructType *ArgStruct = CallInfo.
getArgStruct()) {
5801 const llvm::DataLayout &DL =
CGM.getDataLayout();
5803 llvm::AllocaInst *AI;
5805 IP = IP->getNextNode();
5806 AI =
new llvm::AllocaInst(ArgStruct, DL.getAllocaAddrSpace(),
"argmem",
5812 AI->setAlignment(Align.getAsAlign());
5813 AI->setUsedWithInAlloca(
true);
5814 assert(AI->isUsedWithInAlloca() && !AI->isStaticAlloca());
5815 ArgMemory =
RawAddress(AI, ArgStruct, Align);
5818 ClangToLLVMArgMapping IRFunctionArgs(
CGM.getContext(), CallInfo);
5826 bool NeedSRetLifetimeEnd =
false;
5832 if ((IsVirtualFunctionPointerThunk || IsMustTail) && RetAI.
isIndirect()) {
5834 IRFunctionArgs.getSRetArgNo(),
5842 if (NeedSRetLifetimeEnd)
5843 SRetAlloca = SRetPtr;
5846 if (IRFunctionArgs.hasSRetArg()) {
5859 IRCallArgs[IRFunctionArgs.getSRetArgNo()] =
5877 assert(CallInfo.
arg_size() == CallArgs.size() &&
5878 "Mismatch between function signature & arguments.");
5881 for (CallArgList::const_iterator I = CallArgs.begin(), E = CallArgs.end();
5882 I != E; ++I, ++info_it, ++ArgNo) {
5886 if (IRFunctionArgs.hasPaddingArg(ArgNo))
5887 IRCallArgs[IRFunctionArgs.getPaddingArgNo(ArgNo)] =
5890 unsigned FirstIRArg, NumIRArgs;
5891 std::tie(FirstIRArg, NumIRArgs) = IRFunctionArgs.getIRArgs(ArgNo);
5898 assert(NumIRArgs == 0);
5900 if (I->isAggregate()) {
5902 ? I->getKnownLValue().getAddress()
5903 : I->getKnownRValue().getAggregateAddress();
5904 llvm::Instruction *Placeholder =
5909 CGBuilderTy::InsertPoint IP =
Builder.saveIP();
5910 Builder.SetInsertPoint(Placeholder);
5924 deferPlaceholderReplacement(Placeholder,
Addr.getPointer());
5929 I->Ty,
getContext().getTypeAlignInChars(I->Ty),
5930 "indirect-arg-temp");
5931 I->copyInto(*
this,
Addr);
5940 I->copyInto(*
this,
Addr);
5947 assert(NumIRArgs == 1);
5948 if (I->isAggregate()) {
5958 ? I->getKnownLValue().getAddress()
5959 : I->getKnownRValue().getAggregateAddress();
5961 const llvm::DataLayout *TD = &
CGM.getDataLayout();
5963 assert((FirstIRArg >= IRFuncTy->getNumParams() ||
5964 IRFuncTy->getParamType(FirstIRArg)->getPointerAddressSpace() ==
5965 TD->getAllocaAddrSpace()) &&
5966 "indirect argument must be in alloca address space");
5968 bool NeedCopy =
false;
5969 if (
Addr.getAlignment() < Align &&
5970 llvm::getOrEnforceKnownAlignment(
Addr.emitRawPointer(*
this),
5974 }
else if (I->hasLValue()) {
5975 auto LV = I->getKnownLValue();
5980 if (!isByValOrRef ||
5981 (LV.getAlignment() <
getContext().getTypeAlignInChars(I->Ty))) {
5985 if (isByValOrRef &&
Addr.getType()->getAddressSpace() !=
5994 auto *
T = llvm::PointerType::get(
CGM.getLLVMContext(),
6002 if (ArgHasMaybeUndefAttr)
6003 Val =
Builder.CreateFreeze(Val);
6004 IRCallArgs[FirstIRArg] = Val;
6007 }
else if (I->getType()->isArrayParameterType()) {
6013 IRCallArgs[FirstIRArg] = I->getKnownRValue().getScalarVal();
6022 if (ArgHasMaybeUndefAttr)
6023 Val =
Builder.CreateFreeze(Val);
6024 IRCallArgs[FirstIRArg] = Val;
6029 CallLifetimeEndAfterCall.push_back(AI.
getPointer());
6032 I->copyInto(*
this, AI);
6037 assert(NumIRArgs == 0);
6045 assert(NumIRArgs == 1);
6047 if (!I->isAggregate())
6048 V = I->getKnownRValue().getScalarVal();
6051 I->hasLValue() ? I->getKnownLValue().getAddress()
6052 : I->getKnownRValue().getAggregateAddress());
6058 assert(!swiftErrorTemp.
isValid() &&
"multiple swifterror args");
6062 V, pointeeTy,
getContext().getTypeAlignInChars(pointeeTy));
6069 llvm::Value *errorValue =
Builder.CreateLoad(swiftErrorArg);
6070 Builder.CreateStore(errorValue, swiftErrorTemp);
6075 V->getType()->isIntegerTy())
6082 if (FirstIRArg < IRFuncTy->getNumParams() &&
6083 V->getType() != IRFuncTy->getParamType(FirstIRArg)) {
6084 assert(
V->getType()->isPointerTy() &&
"Only pointers can mismatch!");
6088 if (ArgHasMaybeUndefAttr)
6090 IRCallArgs[FirstIRArg] =
V;
6094 llvm::StructType *STy =
6099 if (!I->isAggregate()) {
6101 I->copyInto(*
this, Src);
6103 Src = I->hasLValue() ? I->getKnownLValue().getAddress()
6104 : I->getKnownRValue().getAggregateAddress();
6114 llvm::TypeSize SrcTypeSize =
6115 CGM.getDataLayout().getTypeAllocSize(SrcTy);
6116 llvm::TypeSize DstTypeSize =
CGM.getDataLayout().getTypeAllocSize(STy);
6117 if (SrcTypeSize.isScalable()) {
6118 assert(STy->containsHomogeneousScalableVectorTypes() &&
6119 "ABI only supports structure with homogeneous scalable vector "
6121 assert(SrcTypeSize == DstTypeSize &&
6122 "Only allow non-fractional movement of structure with "
6123 "homogeneous scalable vector type");
6124 assert(NumIRArgs == STy->getNumElements());
6126 llvm::Value *StoredStructValue =
6128 for (
unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
6129 llvm::Value *Extract =
Builder.CreateExtractValue(
6130 StoredStructValue, i, Src.
getName() +
".extract" + Twine(i));
6131 IRCallArgs[FirstIRArg + i] = Extract;
6134 uint64_t SrcSize = SrcTypeSize.getFixedValue();
6135 uint64_t DstSize = DstTypeSize.getFixedValue();
6136 bool HasPFPFields =
getContext().hasPFPFields(I->Ty);
6142 if (HasPFPFields || SrcSize < DstSize) {
6153 Builder.CreateMemCpy(TempAlloca, Src, SrcSize);
6159 assert(NumIRArgs == STy->getNumElements());
6160 for (
unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
6162 llvm::Value *LI =
Builder.CreateLoad(EltPtr);
6163 if (ArgHasMaybeUndefAttr)
6164 LI =
Builder.CreateFreeze(LI);
6165 IRCallArgs[FirstIRArg + i] = LI;
6170 assert(NumIRArgs == 1);
6178 auto *ATy = dyn_cast<llvm::ArrayType>(Load->getType());
6183 if (ArgHasMaybeUndefAttr)
6184 Load =
Builder.CreateFreeze(Load);
6185 IRCallArgs[FirstIRArg] = Load;
6193 auto layout =
CGM.getDataLayout().getStructLayout(coercionType);
6195 auto *unpaddedStruct = dyn_cast<llvm::StructType>(unpaddedCoercionType);
6199 bool NeedLifetimeEnd =
false;
6200 if (I->isAggregate()) {
6201 addr = I->hasLValue() ? I->getKnownLValue().getAddress()
6202 : I->getKnownRValue().getAggregateAddress();
6205 RValue RV = I->getKnownRValue();
6209 auto scalarAlign =
CGM.getDataLayout().getPrefTypeAlign(scalarType);
6214 layout->getAlignment(), scalarAlign)),
6216 nullptr, &AllocaAddr);
6224 unsigned IRArgPos = FirstIRArg;
6225 unsigned unpaddedIndex = 0;
6226 for (
unsigned i = 0, e = coercionType->getNumElements(); i != e; ++i) {
6227 llvm::Type *eltType = coercionType->getElementType(i);
6234 : unpaddedCoercionType,
6236 if (ArgHasMaybeUndefAttr)
6237 elt =
Builder.CreateFreeze(elt);
6238 IRCallArgs[IRArgPos++] = elt;
6240 assert(IRArgPos == FirstIRArg + NumIRArgs);
6242 if (NeedLifetimeEnd)
6248 unsigned IRArgPos = FirstIRArg;
6249 ExpandTypeToArgs(I->Ty, *I, IRFuncTy, IRCallArgs, IRArgPos);
6250 assert(IRArgPos == FirstIRArg + NumIRArgs);
6256 if (!I->isAggregate()) {
6258 I->copyInto(*
this, Src);
6260 Src = I->hasLValue() ? I->getKnownLValue().getAddress()
6261 : I->getKnownRValue().getAggregateAddress();
6267 CGM.getABIInfo().createCoercedLoad(Src, ArgInfo, *
this);
6268 IRCallArgs[FirstIRArg] = Load;
6274 const CGCallee &ConcreteCallee = Callee.prepareConcreteCallee(*
this);
6280 assert(IRFunctionArgs.hasInallocaArg());
6281 IRCallArgs[IRFunctionArgs.getInallocaArgNo()] = Arg;
6292 auto simplifyVariadicCallee = [](llvm::FunctionType *CalleeFT,
6293 llvm::Value *Ptr) -> llvm::Function * {
6294 if (!CalleeFT->isVarArg())
6298 if (llvm::ConstantExpr *CE = dyn_cast<llvm::ConstantExpr>(Ptr)) {
6299 if (CE->getOpcode() == llvm::Instruction::BitCast)
6300 Ptr = CE->getOperand(0);
6303 llvm::Function *OrigFn = dyn_cast<llvm::Function>(Ptr);
6307 llvm::FunctionType *OrigFT = OrigFn->getFunctionType();
6311 if (OrigFT->isVarArg() ||
6312 OrigFT->getNumParams() != CalleeFT->getNumParams() ||
6313 OrigFT->getReturnType() != CalleeFT->getReturnType())
6316 for (
unsigned i = 0, e = OrigFT->getNumParams(); i != e; ++i)
6317 if (OrigFT->getParamType(i) != CalleeFT->getParamType(i))
6323 if (llvm::Function *OrigFn = simplifyVariadicCallee(IRFuncTy, CalleePtr)) {
6325 IRFuncTy = OrigFn->getFunctionType();
6336 for (
unsigned i = 0; i < IRCallArgs.size(); ++i)
6337 LargestVectorWidth = std::max(LargestVectorWidth,
6342 llvm::AttributeList Attrs;
6343 CGM.ConstructAttributeList(CalleePtr->getName(), CallInfo,
6348 if (
CallingConv == llvm::CallingConv::X86_VectorCall &&
6350 CGM.Error(Loc,
"__vectorcall calling convention is not currently "
6355 if (FD->hasAttr<StrictFPAttr>())
6357 Attrs = Attrs.addFnAttribute(
getLLVMContext(), llvm::Attribute::StrictFP);
6362 if (FD->hasAttr<OptimizeNoneAttr>() &&
getLangOpts().FastMath)
6363 CGM.AdjustMemoryAttribute(CalleePtr->getName(), Callee.getAbstractInfo(),
6368 Attrs = Attrs.addFnAttribute(
getLLVMContext(), llvm::Attribute::NoMerge);
6372 Attrs = Attrs.addFnAttribute(
getLLVMContext(), llvm::Attribute::NoInline);
6377 !
CGM.getTargetCodeGenInfo().wouldInliningViolateFunctionCallABI(
6378 CallerDecl, CalleeDecl))
6380 Attrs.addFnAttribute(
getLLVMContext(), llvm::Attribute::AlwaysInline);
6389 !(TargetDecl && TargetDecl->
hasAttr<NoInlineAttr>()) &&
6390 !
CGM.getTargetCodeGenInfo().wouldInliningViolateFunctionCallABI(
6391 CallerDecl, CalleeDecl)) {
6393 Attrs.addFnAttribute(
getLLVMContext(), llvm::Attribute::AlwaysInline);
6398 Attrs = Attrs.addFnAttribute(
getLLVMContext(), llvm::Attribute::NoInline);
6405 CannotThrow =
false;
6414 CannotThrow = Attrs.hasFnAttr(llvm::Attribute::NoUnwind);
6416 if (
auto *FPtr = dyn_cast<llvm::Function>(CalleePtr))
6417 if (FPtr->hasFnAttribute(llvm::Attribute::NoUnwind))
6428 if (NeedSRetLifetimeEnd)
6436 if (
SanOpts.has(SanitizerKind::KCFI) &&
6437 !isa_and_nonnull<FunctionDecl>(TargetDecl))
6444 if (FD->hasAttr<StrictFPAttr>())
6446 Attrs = Attrs.addFnAttribute(
getLLVMContext(), llvm::Attribute::StrictFP);
6448 AssumeAlignedAttrEmitter AssumeAlignedAttrEmitter(*
this, TargetDecl);
6449 Attrs = AssumeAlignedAttrEmitter.TryEmitAsCallSiteAttribute(Attrs);
6451 AllocAlignAttrEmitter AllocAlignAttrEmitter(*
this, TargetDecl, CallArgs);
6453 AllocAlignAttrEmitter.TryEmitAsCallSiteAttribute(Attrs, IRFunctionArgs);
6455 if (Attrs.hasFnAttr(llvm::Attribute::Convergent)) {
6456 addConvergenceControlBundle(BundleList);
6466 auto *CalleeFn = dyn_cast<llvm::Function>(CalleePtr);
6468 (!
CGM.shouldEmitConvergenceTokens() ||
6469 (CalleeFn && CalleeFn->isConvergent()))) {
6471 llvm::Attribute::Convergent);
6478 CI =
Builder.CreateCall(IRFuncTy, CalleePtr, IRCallArgs, BundleList);
6481 CI =
Builder.CreateInvoke(IRFuncTy, CalleePtr, Cont, InvokeDest, IRCallArgs,
6485 if (CI->getCalledFunction() && CI->getCalledFunction()->hasName() &&
6486 CI->getCalledFunction()->getName().starts_with(
"_Z4sqrt")) {
6491 if (
CGM.getCodeGenOpts().CallGraphSection) {
6495 else if (
const auto *FPT =
6496 Callee.getAbstractInfo().getCalleeFunctionProtoType())
6498 else if (
const auto *FT =
6499 Callee.getAbstractInfo().getCalleeFunctionType())
6503 "Cannot find the callee type to generate callee_type metadata.");
6546 for (
const CallArg &Arg : CallArgs)
6547 ParamTypes.push_back(Arg.
getType());
6548 CST =
CGM.ReconstructCallGraphPrototype(FNPT, ParamTypes);
6551 llvm::Metadata *MD =
6552 CGM.CreateMetadataIdentifierForCallGraphType(CST);
6554 if (
auto *MDS = dyn_cast_or_null<llvm::MDString>(MD))
6555 TypeStr = MDS->getString();
6557 CGM.getDiags().Report(Loc, diag::warn_cgs_no_proto) << CST << TypeStr;
6559 CGM.createCalleeTypeMetadataForIcall(CST, *callOrInvoke);
6567 if (
const auto *FD = dyn_cast_or_null<FunctionDecl>(
CurFuncDecl)) {
6568 if (
const auto *A = FD->getAttr<CFGuardAttr>()) {
6569 if (A->getGuard() == CFGuardAttr::GuardArg::nocf &&
6570 !CI->getCalledFunction())
6576 CI->setAttributes(Attrs);
6577 CI->setCallingConv(
static_cast<llvm::CallingConv::ID
>(
CallingConv));
6581 if (!CI->getType()->isVoidTy())
6582 CI->setName(
"call");
6585 LargestVectorWidth =
6591 if (!CI->getCalledFunction())
6592 PGO->valueProfile(
Builder, llvm::IPVK_IndirectCallTarget, CI, CalleePtr);
6596 if (
CGM.getLangOpts().ObjCAutoRefCount)
6597 AddObjCARCExceptionMetadata(CI);
6600 bool IsPPC =
getTarget().getTriple().isPPC();
6601 bool IsMIPS =
getTarget().getTriple().isMIPS();
6602 bool HasMips16 =
false;
6605 HasMips16 = TargetOpts.
FeatureMap.lookup(
"mips16");
6607 HasMips16 = llvm::is_contained(TargetOpts.
Features,
"+mips16");
6609 if (llvm::CallInst *
Call = dyn_cast<llvm::CallInst>(CI)) {
6610 if (TargetDecl && TargetDecl->
hasAttr<NotTailCalledAttr>())
6611 Call->setTailCallKind(llvm::CallInst::TCK_NoTail);
6612 else if (IsMustTail) {
6615 CGM.getDiags().Report(Loc, diag::err_aix_musttail_unsupported);
6618 CGM.getDiags().Report(Loc, diag::err_ppc_impossible_musttail) << 0;
6619 else if (
Call->isIndirectCall())
6620 CGM.getDiags().Report(Loc, diag::err_ppc_impossible_musttail) << 1;
6621 else if (isa_and_nonnull<FunctionDecl>(TargetDecl)) {
6626 CGM.addUndefinedGlobalForTailCall(
6629 llvm::GlobalValue::LinkageTypes
Linkage =
CGM.getFunctionLinkage(
6631 if (llvm::GlobalValue::isWeakForLinker(
Linkage) ||
6632 llvm::GlobalValue::isDiscardableIfUnused(
Linkage))
6633 CGM.getDiags().Report(Loc, diag::err_ppc_impossible_musttail)
6641 CGM.getDiags().Report(Loc, diag::err_mips_impossible_musttail) << 0;
6642 else if (
const auto *FD = dyn_cast_or_null<FunctionDecl>(TargetDecl))
6643 CGM.addUndefinedGlobalForTailCall({FD, Loc});
6645 Call->setTailCallKind(llvm::CallInst::TCK_MustTail);
6659 bool NeedSrcLoc = TargetDecl->
hasAttr<ErrorAttr>();
6660 if (!NeedSrcLoc &&
CGM.getCodeGenOpts().ShowInliningChain) {
6661 if (
const auto *FD = dyn_cast<FunctionDecl>(TargetDecl))
6662 NeedSrcLoc = FD->isInlined() || FD->hasAttr<AlwaysInlineAttr>() ||
6664 FD->isInAnonymousNamespace();
6668 auto *MD = llvm::ConstantAsMetadata::get(
Line);
6669 CI->setMetadata(
"srcloc", llvm::MDNode::get(
getLLVMContext(), {MD}));
6678 if (CI->doesNotReturn()) {
6679 if (NeedSRetLifetimeEnd)
6683 if (
SanOpts.has(SanitizerKind::Unreachable)) {
6686 if (
auto *F = CI->getCalledFunction())
6687 F->removeFnAttr(llvm::Attribute::NoReturn);
6688 CI->removeFnAttr(llvm::Attribute::NoReturn);
6692 if (
SanOpts.hasOneOf(SanitizerKind::Address |
6693 SanitizerKind::KernelAddress)) {
6695 llvm::IRBuilder<>::InsertPointGuard IPGuard(
Builder);
6697 auto *FnType = llvm::FunctionType::get(
CGM.VoidTy,
false);
6698 llvm::FunctionCallee Fn =
6699 CGM.CreateRuntimeFunction(FnType,
"__asan_handle_no_return");
6705 Builder.ClearInsertionPoint();
6727 if (CI->doesNotThrow())
6730 diag::err_musttail_noexcept_mismatch);
6733 if (
auto *Cleanup = dyn_cast<EHCleanupScope>(&*it)) {
6736 if (Cleanup->isFakeUse()) {
6737 CGBuilderTy::InsertPointGuard IPG(
Builder);
6739 Cleanup->getCleanup()->Emit(*
this, EHScopeStack::Cleanup::Flags());
6742 if (Cleanup->isRedundantBeforeReturn())
6745 CGM.ErrorUnsupported(
MustTailCall,
"tail call skipping over cleanups");
6747 if (CI->getType()->isVoidTy())
6751 Builder.ClearInsertionPoint();
6757 if (swiftErrorTemp.
isValid()) {
6758 llvm::Value *errorResult =
Builder.CreateLoad(swiftErrorTemp);
6759 Builder.CreateStore(errorResult, swiftErrorArg);
6776 if (IsVirtualFunctionPointerThunk) {
6789 unsigned unpaddedIndex = 0;
6790 for (
unsigned i = 0, e = coercionType->getNumElements(); i != e; ++i) {
6791 llvm::Type *eltType = coercionType->getElementType(i);
6795 llvm::Value *elt = CI;
6796 if (requiresExtract)
6797 elt =
Builder.CreateExtractValue(elt, unpaddedIndex++);
6799 assert(unpaddedIndex == 0);
6800 Builder.CreateStore(elt, eltAddr);
6808 if (NeedSRetLifetimeEnd)
6825 llvm::Value *Real =
Builder.CreateExtractValue(CI, 0);
6826 llvm::Value *Imag =
Builder.CreateExtractValue(CI, 1);
6834 llvm::Value *
V = CI;
6835 if (
V->getType() != RetIRTy)
6845 if (
auto *FixedDstTy = dyn_cast<llvm::FixedVectorType>(RetIRTy)) {
6846 llvm::Value *
V = CI;
6847 if (
auto *ScalableSrcTy =
6848 dyn_cast<llvm::ScalableVectorType>(
V->getType())) {
6849 if (FixedDstTy->getElementType() ==
6850 ScalableSrcTy->getElementType()) {
6861 getContext().getTypeInfoDataSizeInChars(RetTy).Width.getQuantity();
6865 DestIsVolatile =
false;
6866 DestSize =
getContext().getTypeSizeInChars(RetTy).getQuantity();
6876 CI, RetTy, StorePtr,
6890 DestIsVolatile =
false;
6892 CGM.getABIInfo().createCoercedStore(CI, StorePtr, RetAI, DestIsVolatile,
6899 llvm_unreachable(
"Invalid ABI kind for return argument");
6902 llvm_unreachable(
"Unhandled ABIArgInfo::Kind");
6907 if (Ret.isScalar() && TargetDecl) {
6908 AssumeAlignedAttrEmitter.EmitAsAnAssumption(Loc, RetTy, Ret);
6913 for (llvm::Value *LifetimeEndAddr : CallLifetimeEndAfterCall)
6926 if (CalleeDecl && !CalleeDecl->
hasAttr<NoDebugAttr>() &&
6927 DI->getCallSiteRelatedAttrs() != llvm::DINode::FlagZero) {
6928 CodeGenFunction CalleeCGF(
CGM);
6930 Callee.getAbstractInfo().getCalleeDecl();
6931 CalleeCGF.
CurGD = CalleeGlobalDecl;
6934 DI->EmitFuncDeclForCallSite(
6935 CI, DI->getFunctionType(CalleeDecl, ResTy, Args), CalleeGlobalDecl);
6938 DI->addCallTargetIfVirtual(CalleeDecl, CI);
6959 VAListAddr =
VE->isMicrosoftABI()
6966 if (
VE->isMicrosoftABI())
6967 return CGM.getABIInfo().EmitMSVAArg(*
this, VAListAddr, Ty, Slot);
6969 return CGM.getABIInfo().EmitZOSVAArg(*
this, VAListAddr, Ty, Slot);
6970 return CGM.getABIInfo().EmitVAArg(*
this, VAListAddr, Ty, Slot);
6975 CGF.disableDebugInfo();
6979 CGF.enableDebugInfo();
static ExtParameterInfoList getExtParameterInfosForCall(const FunctionProtoType *proto, unsigned prefixArgs, unsigned totalArgs)
static bool isInAllocaArgument(CGCXXABI &ABI, QualType type)
static uint64_t buildMultiCharMask(const SmallVectorImpl< uint64_t > &Bits, int Pos, int Size, int CharWidth, bool BigEndian)
static llvm::Value * tryRemoveRetainOfSelf(CodeGenFunction &CGF, llvm::Value *result)
If this is a +1 of the value of an immutable 'self', remove it.
static CanQualType GetReturnType(QualType RetTy)
Returns the "extra-canonicalized" return type, which discards qualifiers on the return type.
static const NonNullAttr * getNonNullAttr(const Decl *FD, const ParmVarDecl *PVD, QualType ArgType, unsigned ArgNo)
Returns the attribute (either parameter attribute, or function attribute), which declares argument Ar...
static CanQualTypeList getArgTypesForCall(ASTContext &ctx, const CallArgList &args)
static Address emitAddressAtOffset(CodeGenFunction &CGF, Address addr, const ABIArgInfo &info)
static const char * abiKindToString(ABIArgInfo::Kind K)
static AggValueSlot createPlaceholderSlot(CodeGenFunction &CGF, QualType Ty)
static CallingConv getCallingConventionForDecl(const ObjCMethodDecl *D, bool IsTargetDefaultMSABI)
static void setBitRange(SmallVectorImpl< uint64_t > &Bits, int BitOffset, int BitWidth, int CharWidth)
static bool isProvablyNull(llvm::Value *addr)
static void AddAttributesFromFunctionProtoType(ASTContext &Ctx, llvm::AttrBuilder &FuncAttrs, const FunctionProtoType *FPT)
static void eraseUnusedBitCasts(llvm::Instruction *insn)
static bool isObjCMethodWithTypeParams(const ObjCMethodDecl *method)
static void emitWritebackArg(CodeGenFunction &CGF, CallArgList &args, const ObjCIndirectCopyRestoreExpr *CRE)
Emit an argument that's being passed call-by-writeback.
static void overrideFunctionFeaturesWithTargetFeatures(llvm::AttrBuilder &FuncAttr, const llvm::Function &F, const TargetOptions &TargetOpts)
Merges target-features from \TargetOpts and \F, and sets the result in \FuncAttr.
static llvm::Value * CreatePFPCoercedLoad(Address Src, QualType SrcFETy, llvm::Type *Ty, CodeGenFunction &CGF)
static int getExpansionSize(QualType Ty, const ASTContext &Context)
static bool DetermineNoUndef(QualType QTy, CodeGenTypes &Types, const llvm::DataLayout &DL, const ABIArgInfo &AI, bool CheckCoerce=true)
static const Expr * maybeGetUnaryAddrOfOperand(const Expr *E)
static void deactivateArgCleanupsBeforeCall(CodeGenFunction &CGF, const CallArgList &CallArgs)
static bool isProvablyNonNull(Address Addr, CodeGenFunction &CGF)
static llvm::Value * emitArgumentDemotion(CodeGenFunction &CGF, const VarDecl *var, llvm::Value *value)
An argument came in as a promoted argument; demote it back to its declared type.
SmallVector< CanQualType, 16 > CanQualTypeList
static bool isConvergentIntrinsic(const llvm::Function *F)
static std::pair< llvm::Value *, bool > CoerceScalableToFixed(CodeGenFunction &CGF, llvm::FixedVectorType *ToTy, llvm::ScalableVectorType *FromTy, llvm::Value *V, StringRef Name="")
static const CGFunctionInfo & arrangeLLVMFunctionInfo(CodeGenTypes &CGT, bool instanceMethod, SmallVectorImpl< CanQualType > &prefix, CanQual< FunctionProtoType > FTP)
Arrange the LLVM function layout for a value of the given function type, on top of any implicit param...
static llvm::Value * CreateCoercedLoad(Address Src, QualType SrcFETy, llvm::Type *Ty, CodeGenFunction &CGF)
CreateCoercedLoad - Create a load from.
static void addExtParameterInfosForCall(llvm::SmallVectorImpl< FunctionProtoType::ExtParameterInfo > ¶mInfos, const FunctionProtoType *proto, unsigned prefixArgs, unsigned totalArgs)
static bool canApplyNoFPClass(const ABIArgInfo &AI, QualType ParamType, bool IsReturn)
Test if it's legal to apply nofpclass for the given parameter type and it's lowered IR type.
static void getTrivialDefaultFunctionAttributes(StringRef Name, bool HasOptnone, const CodeGenOptions &CodeGenOpts, const LangOptions &LangOpts, bool AttrOnCallSite, llvm::AttrBuilder &FuncAttrs)
static void forConstantArrayExpansion(CodeGenFunction &CGF, ConstantArrayExpansion *CAE, Address BaseAddr, llvm::function_ref< void(Address)> Fn)
static bool hasInAllocaArgs(CodeGenModule &CGM, CallingConv ExplicitCC, ArrayRef< QualType > ArgTypes)
static std::unique_ptr< TypeExpansion > getTypeExpansion(QualType Ty, const ASTContext &Context)
SmallVector< FunctionProtoType::ExtParameterInfo, 16 > ExtParameterInfoList
static RawAddress CreateTempAllocaForCoercion(CodeGenFunction &CGF, llvm::Type *Ty, CharUnits MinAlign, const Twine &Name="tmp")
Create a temporary allocation for the purposes of coercion.
static void setUsedBits(CodeGenModule &, QualType, int, SmallVectorImpl< uint64_t > &)
static llvm::StoreInst * findDominatingStoreToReturnValue(CodeGenFunction &CGF)
Heuristically search for a dominating store to the return-value slot.
static void addZeroCallUsedRegsAttr(const CodeGenOptions &CodeGenOpts, llvm::AttrBuilder &FuncAttrs)
static llvm::Value * tryEmitFusedAutoreleaseOfResult(CodeGenFunction &CGF, llvm::Value *result)
Try to emit a fused autorelease of a return result.
static Address EnterStructPointerForCoercedAccess(Address SrcPtr, llvm::StructType *SrcSTy, uint64_t DstSize, CodeGenFunction &CGF)
EnterStructPointerForCoercedAccess - Given a struct pointer that we are accessing some number of byte...
static llvm::Value * emitAutoreleaseOfResult(CodeGenFunction &CGF, llvm::Value *result)
Emit an ARC autorelease of the result of a function.
static void emitWriteback(CodeGenFunction &CGF, const CallArgList::Writeback &writeback)
Emit the actual writing-back of a writeback.
static bool HasStrictReturn(const CodeGenModule &Module, QualType RetTy, const Decl *TargetDecl)
static CanQualTypeList getArgTypesForDeclaration(ASTContext &ctx, const FunctionArgList &args)
static void addMergableDefaultFunctionAttributes(const CodeGenOptions &CodeGenOpts, llvm::AttrBuilder &FuncAttrs)
Add default attributes to a function, which have merge semantics under -mlink-builtin-bitcode and sho...
static bool CreatePFPCoercedStore(llvm::Value *Src, QualType SrcFETy, Address Dst, CodeGenFunction &CGF)
static llvm::Value * CoerceIntOrPtrToIntOrPtr(llvm::Value *Val, llvm::Type *Ty, CodeGenFunction &CGF)
CoerceIntOrPtrToIntOrPtr - Convert a value Val to the specific Ty where both are either integers or p...
static void AddAttributesFromOMPAssumes(llvm::AttrBuilder &FuncAttrs, const Decl *Callee)
static unsigned getMaxVectorWidth(const llvm::Type *Ty)
CodeGenFunction::ComplexPairTy ComplexPairTy
static mlir::FailureOr< ArgClassification > convertABIArgInfo(const llvm::abi::ArgInfo &info, MLIRContext *ctx, mlir::Type origTy)
Convert an llvm::abi::ArgInfo into the ArgClassification consumed by CIRABIRewriteContext.
static void setCUDAKernelCallingConvention(CanQualType &funcTy, CIRGenModule &cgm, const FunctionDecl *fd)
Set calling convention for CUDA/HIP kernel.
static void addNoBuiltinAttributes(mlir::MLIRContext &ctx, mlir::NamedAttrList &attrs, const LangOptions &langOpts, const NoBuiltinAttr *nba=nullptr)
static void addDenormalModeAttrs(llvm::DenormalMode fpDenormalMode, llvm::DenormalMode fp32DenormalMode, mlir::NamedAttrList &attrs)
Add denormal-fp-math and denormal-fp-math-f32 as appropriate for the requested denormal behavior,...
static void appendParameterTypes(const CIRGenTypes &cgt, SmallVectorImpl< CanQualType > &prefix, CanQual< FunctionProtoType > fpt)
Adds the formal parameters in FPT to the given prefix.
static const CIRGenFunctionInfo & arrangeFreeFunctionLikeCall(CIRGenTypes &cgt, CIRGenModule &cgm, const CallArgList &args, const FunctionType *fnType)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Result
Implement __builtin_bit_cast and related operations.
#define CC_VLS_CASE(ABI_VLEN)
static bool hasFeature(StringRef Feature, const LangOptions &LangOpts, const TargetInfo &Target)
Determine whether a translation unit built using the current language options has the given feature.
static StringRef getTriple(const Command &Job)
Maps Clang QualType instances to corresponding LLVM ABI type representations.
static QualType getPointeeType(const MemRegion *R)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
CanQualType getCanonicalParamType(QualType T) const
Return the canonical parameter type corresponding to the specific potentially non-canonical one.
CanQualType getCanonicalSizeType() const
const TargetInfo & getTargetInfo() const
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
std::vector< PFPField > findPFPFields(QualType Ty) const
Returns a list of PFP fields for the given type, including subfields in bases or other fields,...
uint64_t getCharWidth() const
Return the size of the character type, in bits.
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
uint64_t getFieldOffset(unsigned FieldNo) const
getFieldOffset - Get the offset of the given field index, in bits.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Attr - This represents one attribute.
This class is used for builtin types like 'int'.
QualType getType() const
Retrieves the type of the base class.
Represents a C++ constructor within a class.
Represents a C++ destructor within a class.
Represents a static or instance method of a struct/union/class.
bool isImplicitObjectMemberFunction() const
[C++2b][dcl.fct]/p7 An implicit object member function is a non-static member function without an exp...
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
Qualifiers getMethodQualifiers() const
Represents a C++ struct/union/class.
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
SourceLocation getBeginLoc() const
ConstExprIterator const_arg_iterator
Represents a canonical, potentially-qualified type.
static CanQual< Type > CreateUnsafe(QualType Other)
CanProxy< U > castAs() const
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
CanProxy< U > getAs() const
Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed.
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
This is an opaque type for sizes expressed in character units.
bool isZero() const
Test whether the quantity equals zero.
llvm::Align getAsAlign() const
Returns Quantity as a valid llvm::Align, Beware llvm::Align assumes power of two 8-bit bytes.
QuantityType getQuantity() const
Get the raw integer representation of this quantity.
static CharUnits fromQuantity(QuantityType Quantity)
Construct a CharUnits quantity from a raw integer type.
static CharUnits Zero()
Construct a CharUnits quantity of zero.
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
llvm::DenormalMode FPDenormalMode
The floating-point denormal mode to use.
static StringRef getFramePointerKindName(FramePointerKind Kind)
std::vector< std::string > Reciprocals
llvm::DenormalMode FP32DenormalMode
The floating-point denormal mode to use, for float.
std::string TrapFuncName
If not an empty string, trap intrinsics are lowered to calls to this function instead of to trap inst...
std::vector< std::string > DefaultFunctionAttrs
std::string PreferVectorWidth
The preferred width for auto-vectorization transforms.
ABIArgInfo - Helper class to encapsulate information about how a specific C type should be passed to ...
static ABIArgInfo getZeroExtend(QualType Ty, llvm::Type *T=nullptr, llvm::Type *Padding=nullptr)
unsigned getInAllocaFieldIndex() const
static ABIArgInfo getSignExtend(QualType Ty, llvm::Type *T=nullptr, llvm::Type *Padding=nullptr)
void setConservative(bool Val)
static ABIArgInfo getNoExtend(llvm::IntegerType *T)
bool getIndirectByVal() const
bool isConservative() const
Whether the extension is conservative, i.e.
llvm::StructType * getCoerceAndExpandType() const
bool getIndirectRealign() const
static ABIArgInfo getIgnore()
void setCoerceToType(llvm::Type *T)
llvm::Type * getUnpaddedCoerceAndExpandType() const
bool getCanBeFlattened() const
unsigned getDirectOffset() const
static bool isPaddingForCoerceAndExpand(llvm::Type *eltType)
bool getInAllocaSRet() const
Return true if this field of an inalloca struct should be returned to implement a struct return calli...
llvm::Type * getPaddingType() const
bool getPaddingInReg() const
unsigned getDirectAlign() const
unsigned getIndirectAddrSpace() const
static ABIArgInfo getDirect(llvm::Type *T=nullptr, unsigned Offset=0, llvm::Type *Padding=nullptr, bool CanBeFlattened=true, unsigned Align=0)
@ Extend
Extend - Valid only for integer argument types.
@ Ignore
Ignore - Ignore the argument (treat as void).
@ IndirectAliased
IndirectAliased - Similar to Indirect, but the pointer may be to an object that is otherwise referenc...
@ Expand
Expand - Only valid for aggregate argument types.
@ TargetSpecific
TargetSpecific - Some argument types are passed as target specific types such as RISC-V's tuple type,...
@ InAlloca
InAlloca - Pass the argument directly using the LLVM inalloca attribute.
@ Indirect
Indirect - Pass the argument indirectly via a hidden pointer with the specified alignment (0 indicate...
@ CoerceAndExpand
CoerceAndExpand - Only valid for aggregate argument types.
@ Direct
Direct - Pass the argument directly using the normal converted LLVM type, or by coercing to another s...
static ABIArgInfo getIndirect(CharUnits Alignment, unsigned AddrSpace, bool ByVal=true, bool Realign=false, llvm::Type *Padding=nullptr)
ArrayRef< llvm::Type * > getCoerceAndExpandTypeSequence() const
static ABIArgInfo getIndirectAliased(CharUnits Alignment, unsigned AddrSpace, bool Realign=false, llvm::Type *Padding=nullptr)
Pass this in memory using the IR byref attribute.
bool isCoerceAndExpand() const
static ABIArgInfo getCoerceAndExpand(llvm::StructType *coerceToType, llvm::Type *unpaddedCoerceToType)
unsigned getInAllocaIndirect() const
llvm::Type * getCoerceToType() const
bool isIndirectAliased() const
bool isSRetAfterThis() const
bool canHaveCoerceToType() const
CharUnits getIndirectAlign() const
Like RawAddress, an abstract representation of an aligned address, but the pointer contained in this ...
llvm::Value * getBasePointer() const
llvm::Value * emitRawPointer(CodeGenFunction &CGF) const
Return the pointer contained in this class after authenticating it and adding offset to it if necessa...
CharUnits getAlignment() const
llvm::Type * getElementType() const
Return the type of the values stored in this address.
Address withPointer(llvm::Value *NewPointer, KnownNonNull_t IsKnownNonNull) const
Return address with different pointer, but same element type and alignment.
Address withElementType(llvm::Type *ElemTy) const
Return address with different element type, but same pointer and alignment.
unsigned getAddressSpace() const
Return the address space that this address resides in.
KnownNonNull_t isKnownNonNull() const
Whether the pointer is known not to be null.
llvm::StringRef getName() const
Return the IR name of the pointer value.
Address getAddress() const
void setExternallyDestructed(bool destructed=true)
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.
llvm::StoreInst * CreateStore(llvm::Value *Val, Address Addr, bool IsVolatile=false)
Address CreateConstInBoundsByteGEP(Address Addr, CharUnits Offset, const llvm::Twine &Name="")
Given a pointer to i8, adjust it by a given constant offset.
llvm::Value * CreateIsNull(Address Addr, const Twine &Name="")
Address CreateConstGEP2_32(Address Addr, unsigned Idx0, unsigned Idx1, const llvm::Twine &Name="")
Address CreateStructGEP(Address Addr, unsigned Index, const llvm::Twine &Name="")
llvm::LoadInst * CreateLoad(Address Addr, const llvm::Twine &Name="")
llvm::CallInst * CreateMemCpy(Address Dest, Address Src, llvm::Value *Size, bool IsVolatile=false)
llvm::LoadInst * CreateAlignedLoad(llvm::Type *Ty, llvm::Value *Addr, CharUnits Align, const llvm::Twine &Name="")
Implements C++ ABI-specific code generation functions.
virtual bool hasMostDerivedReturn(GlobalDecl GD) const
virtual bool HasThisReturn(GlobalDecl GD) const
Returns true if the given constructor or destructor is one of the kinds that the ABI says returns 'th...
@ RAA_DirectInMemory
Pass it on the stack using its defined layout.
virtual CGCallee getVirtualFunctionPointer(CodeGenFunction &CGF, GlobalDecl GD, Address This, llvm::Type *Ty, SourceLocation Loc)=0
Build a virtual function pointer in the ABI-specific way.
virtual RecordArgABI getRecordArgABI(const CXXRecordDecl *RD) const =0
Returns how an argument of the given record type should be passed.
virtual const CXXRecordDecl * getThisArgumentTypeForMethod(GlobalDecl GD)
Get the type of the implicit "this" parameter used by a method.
virtual AddedStructorArgCounts buildStructorSignature(GlobalDecl GD, SmallVectorImpl< CanQualType > &ArgTys)=0
Build the signature of the given constructor or destructor variant by adding any required parameters.
Abstract information about a function or function prototype.
const GlobalDecl getCalleeDecl() const
const FunctionProtoType * getCalleeFunctionProtoType() const
All available information about a concrete callee.
CGCallee prepareConcreteCallee(CodeGenFunction &CGF) const
If this is a delayed callee computation of some sort, prepare a concrete callee.
Address getThisAddress() const
const CallExpr * getVirtualCallExpr() const
llvm::Value * getFunctionPointer() const
llvm::FunctionType * getVirtualFunctionType() const
const CGPointerAuthInfo & getPointerAuthInfo() const
GlobalDecl getVirtualMethodDecl() const
This class gathers all debug information during compilation and is responsible for emitting to llvm g...
CGFunctionInfo - Class to encapsulate the information about a function definition.
bool usesInAlloca() const
Return true if this function uses inalloca arguments.
FunctionType::ExtInfo getExtInfo() const
bool isInstanceMethod() const
ABIArgInfo & getReturnInfo()
bool isReturnsRetained() const
In ARC, whether this function retains its return value.
unsigned getCallingConvention() const
getCallingConvention - Return the user specified calling convention, which has been translated into a...
void Profile(llvm::FoldingSetNodeID &ID)
const_arg_iterator arg_begin() const
ArrayRef< ExtParameterInfo > getExtParameterInfos() const
CanQualType getReturnType() const
static CGFunctionInfo * create(unsigned llvmCC, bool instanceMethod, bool chainCall, bool delegateCall, unsigned X86ABIAVXLevel, const FunctionType::ExtInfo &extInfo, ArrayRef< ExtParameterInfo > paramInfos, CanQualType resultType, ArrayRef< CanQualType > argTypes, RequiredArgs required)
const ArgInfo * const_arg_iterator
bool isCmseNSCall() const
bool isDelegateCall() const
MutableArrayRef< ArgInfo > arguments()
const_arg_iterator arg_end() const
unsigned getEffectiveCallingConvention() const
getEffectiveCallingConvention - Return the actual calling convention to use, which may depend on the ...
unsigned getX86ABIAVXLevel() const
ExtParameterInfo getExtParameterInfo(unsigned argIndex) const
CharUnits getArgStructAlignment() const
unsigned arg_size() const
RequiredArgs getRequiredArgs() const
unsigned getNumRequiredArgs() const
llvm::StructType * getArgStruct() const
Get the struct type used to represent all the arguments in memory.
CGRecordLayout - This class handles struct and union layout info while lowering AST types to LLVM typ...
const CGBitFieldInfo & getBitFieldInfo(const FieldDecl *FD) const
Return the BitFieldInfo that corresponds to the field FD.
CallArgList - Type for representing both the value and type of arguments in a call.
void addWriteback(LValue srcLV, Address temporary, llvm::Value *toUse, const Expr *writebackExpr=nullptr)
llvm::Instruction * getStackBase() const
void addUncopiedAggregate(LValue LV, QualType type)
void addArgCleanupDeactivation(EHScopeStack::stable_iterator Cleanup, llvm::Instruction *IsActiveIP)
ArrayRef< CallArgCleanup > getCleanupsToDeactivate() const
bool hasWritebacks() const
void add(RValue rvalue, QualType type)
bool isUsingInAlloca() const
Returns if we're using an inalloca struct to pass arguments in memory.
void allocateArgumentMemory(CodeGenFunction &CGF)
void freeArgumentMemory(CodeGenFunction &CGF) const
writeback_const_range writebacks() const
An abstract representation of regular/ObjC call/message targets.
const ParmVarDecl * getParamDecl(unsigned I) const
const Decl * getDecl() const
unsigned getNumParams() const
bool hasFunctionDecl() const
An object to manage conditionally-evaluated expressions.
void begin(CodeGenFunction &CGF)
void end(CodeGenFunction &CGF)
static ParamValue forIndirect(Address addr)
static ParamValue forDirect(llvm::Value *value)
RAII object to set/unset CodeGenFunction::IsSanitizerScope.
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
EHScopeStack::stable_iterator CurrentCleanupScopeDepth
GlobalDecl CurGD
CurGD - The GlobalDecl for the current function being compiled.
llvm::Value * EmitARCRetainAutoreleaseReturnValue(llvm::Value *value)
Do a fused retain/autorelease of the given object.
llvm::Value * performAddrSpaceCast(llvm::Value *Src, llvm::Type *DestTy)
SanitizerSet SanOpts
Sanitizers enabled for this function.
CodeGenUtils::EvaluationOrder EvaluationOrder
void checkTargetFeatures(const CallExpr *E, const FunctionDecl *TargetDecl)
static bool hasScalarEvaluationKind(QualType T)
llvm::Type * ConvertType(QualType T)
bool isCleanupPadScope() const
Returns true while emitting a cleanuppad.
void addInstToNewSourceAtom(llvm::Instruction *KeyInstruction, llvm::Value *Backup)
Add KeyInstruction and an optional Backup instruction to a new atom group (See ApplyAtomGroup for mor...
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...
void EmitNoreturnRuntimeCallOrInvoke(llvm::FunctionCallee callee, ArrayRef< llvm::Value * > args)
Emits a call or invoke to the given noreturn runtime function.
llvm::CallBase * EmitRuntimeCallOrInvoke(llvm::FunctionCallee callee, ArrayRef< llvm::Value * > args, const Twine &name="")
Emits a call or invoke instruction to the given runtime function.
void callCStructDestructor(LValue Dst)
ComplexPairTy EmitLoadOfComplex(LValue src, SourceLocation loc)
EmitLoadOfComplex - Load a complex number from the specified l-value.
llvm::Value * EmitARCAutoreleaseReturnValue(llvm::Value *value)
Autorelease the given object.
bool shouldUseFusedARCCalls()
bool CurFuncIsThunk
In C++, whether we are code generating a thunk.
bool isSEHTryScope() const
Returns true inside SEH __try blocks.
RValue convertTempToRValue(Address addr, QualType type, SourceLocation Loc)
Given the address of a temporary variable, produce an r-value of its type.
llvm::Constant * EmitCheckSourceLocation(SourceLocation Loc)
Emit a description of a source location in a format suitable for passing to a runtime sanitizer handl...
void SetSqrtFPAccuracy(llvm::Value *Val)
Set the minimum required accuracy of the given sqrt operation based on CodeGenOpts.
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.
void EmitReturnValueCheck(llvm::Value *RV)
Emit a test that checks if the return value RV is nonnull.
llvm::Value * getAsNaturalPointerTo(Address Addr, QualType PointeeType)
void EmitDelegateCallArg(CallArgList &args, const VarDecl *param, SourceLocation loc)
EmitDelegateCallArg - We are performing a delegate call; that is, the current function is delegating ...
llvm::BasicBlock * createBasicBlock(const Twine &name="", llvm::Function *parent=nullptr, llvm::BasicBlock *before=nullptr)
createBasicBlock - Create an LLVM basic block.
void addInstToCurrentSourceAtom(llvm::Instruction *KeyInstruction, llvm::Value *Backup)
See CGDebugInfo::addInstToCurrentSourceAtom.
const LangOptions & getLangOpts() const
void addInstToSpecificSourceAtom(llvm::Instruction *KeyInstruction, llvm::Value *Backup, uint64_t Atom)
See CGDebugInfo::addInstToSpecificSourceAtom.
RValue EmitReferenceBindingToExpr(const Expr *E)
Emits a reference binding to the passed in expression.
LValue MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T, KnownNonNull_t IsKnownNonNull=NotKnownNonNull)
bool InNoConvergentAttributedStmt
True if the current statement has noconvergent attribute.
void pushDestroy(QualType::DestructionKind dtorKind, Address addr, QualType type)
pushDestroy - Push the standard destructor for the given type as at least a normal cleanup.
const CodeGen::CGBlockInfo * BlockInfo
void EmitKCFIOperandBundle(const CGCallee &Callee, SmallVectorImpl< llvm::OperandBundleDef > &Bundles)
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 EmitCXXDestructorCall(const CXXDestructorDecl *D, CXXDtorType Type, bool ForVirtualBase, bool Delegating, Address This, QualType ThisTy)
bool InNoMergeAttributedStmt
True if the current statement has nomerge attribute.
const Decl * CurCodeDecl
CurCodeDecl - This is the inner-most code context, which includes blocks.
llvm::BasicBlock * getUnreachableBlock()
void EmitARCRelease(llvm::Value *value, ARCPreciseLifetime_t precise)
Release the given object.
bool currentFunctionUsesSEHTry() const
JumpDest ReturnBlock
ReturnBlock - Unified return block.
void CreateCoercedStore(llvm::Value *Src, QualType SrcFETy, Address Dst, llvm::TypeSize DstSize, bool DstIsVolatile)
Create a store to.
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.
void EmitAggregateCopy(LValue Dest, LValue Src, QualType EltTy, AggValueSlot::Overlap_t MayOverlap, bool isVolatile=false)
EmitAggregateCopy - Emit an aggregate copy.
const TargetInfo & getTarget() const
void emitReturnAlignmentAssumptionCheck(llvm::Value *Ptr, QualType Ty, SourceLocation AssumptionLoc, llvm::Value *Alignment, llvm::Value *OffsetValue=nullptr)
void EmitWritebacks(const CallArgList &Args)
EmitWriteback - Emit callbacks for function.
void EmitIgnoredExpr(const Expr *E)
EmitIgnoredExpr - Emit an expression in a context which ignores the result.
RValue EmitLoadOfLValue(LValue V, SourceLocation Loc)
EmitLoadOfLValue - Given an expression that represents a value lvalue, this method emits the address ...
void DeactivateCleanupBlock(EHScopeStack::stable_iterator Cleanup, llvm::Instruction *DominatingIP)
DeactivateCleanupBlock - Deactivates the given cleanup block.
void pushFullExprCleanup(CleanupKind kind, As... A)
pushFullExprCleanup - Push a cleanup to be run at the end of the current full-expression.
llvm::BasicBlock * getInvokeDest()
void EmitCallArg(CallArgList &args, const Expr *E, QualType ArgType)
EmitCallArg - Emit a single call argument.
void EmitPointerAuthOperandBundle(const CGPointerAuthInfo &Info, SmallVectorImpl< llvm::OperandBundleDef > &Bundles)
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...
AggValueSlot CreateAggTemp(QualType T, const Twine &Name="tmp", RawAddress *Alloca=nullptr)
CreateAggTemp - Create a temporary memory object for the given aggregate type.
llvm::CallInst * EmitIntrinsicCall(llvm::Intrinsic::ID ID, const Twine &Name="")
bool HaveInsertPoint() const
HaveInsertPoint - True if an insertion point is defined.
CGDebugInfo * getDebugInfo()
bool EmitLifetimeStart(llvm::Value *Addr)
Emit a lifetime.begin marker if some criteria are satisfied.
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...
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,...
void EmitLifetimeEnd(llvm::Value *Addr)
RawAddress CreateMemTempWithoutCast(QualType T, const Twine &Name="tmp")
CreateMemTemp - Create a temporary memory object of the given type, with appropriate alignmen without...
bool InNoInlineAttributedStmt
True if the current statement has noinline attribute.
SmallVector< llvm::OperandBundleDef, 1 > getBundlesForFunclet(llvm::Value *Callee)
RValue EmitAnyExprToTemp(const Expr *E)
EmitAnyExprToTemp - Similarly to EmitAnyExpr(), however, the result will always be accessible even if...
llvm::CallInst * EmitNounwindRuntimeCall(llvm::FunctionCallee callee, const Twine &name="")
ASTContext & getContext() const
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...
LValue EmitHLSLOutArgExpr(const HLSLOutArgExpr *E, CallArgList &Args, QualType Ty, bool IsImplicitObject=false)
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.
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.
Address EmitAddressOfPFPField(Address RecordPtr, const PFPField &Field)
void EmitStoreThroughLValue(RValue Src, LValue Dst, bool isInit=false)
EmitStoreThroughLValue - Store the specified rvalue into the specified lvalue, where both are guarant...
Address EmitVAListRef(const Expr *E)
RValue GetUndefRValue(QualType Ty)
GetUndefRValue - Get an appropriate 'undef' rvalue for the given type.
void EmitParmDecl(const VarDecl &D, ParamValue Arg, unsigned ArgNo)
EmitParmDecl - Emit a ParmVarDecl or an ImplicitParamDecl.
bool AutoreleaseResult
In ARC, whether we should autorelease the return value.
llvm::CallInst * EmitRuntimeCall(llvm::FunctionCallee callee, const Twine &name="")
llvm::Value * EmitARCRetainNonBlock(llvm::Value *value)
Retain the given object, with normal retain semantics.
llvm::Type * ConvertTypeForMem(QualType T)
Address EmitZOSVAListRef(const Expr *E)
Emit a "reference" to a __builtin_zos_va_list; this is always the address of the expression,...
CodeGenTypes & getTypes() const
static TypeEvaluationKind getEvaluationKind(QualType T)
getEvaluationKind - Return the TypeEvaluationKind of QualType T.
bool InAlwaysInlineAttributedStmt
True if the current statement has always_inline attribute.
void EmitFunctionEpilog(const CGFunctionInfo &FI, bool EmitRetDbgLoc, SourceLocation EndLoc, uint64_t RetKeyInstructionsSourceAtom)
EmitFunctionEpilog - Emit the target specific LLVM code to return the given temporary.
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...
void EmitAggExpr(const Expr *E, AggValueSlot AS)
EmitAggExpr - Emit the computation of the specified expression of aggregate type.
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,...
static bool hasAggregateEvaluationKind(QualType T)
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.
LValue MakeAddrLValue(Address Addr, QualType T, AlignmentSource Source=AlignmentSource::Type)
const CallExpr * MustTailCall
Address GetAddrOfLocalVar(const VarDecl *VD)
GetAddrOfLocalVar - Return the address of a local variable.
void EmitUnreachable(SourceLocation Loc)
Emit a reached-unreachable diagnostic if Loc is valid and runtime checking is enabled.
std::pair< llvm::Value *, llvm::Value * > ComplexPairTy
Address ReturnValue
ReturnValue - The temporary alloca to hold the return value.
LValue EmitLValue(const Expr *E, KnownNonNull_t IsKnownNonNull=NotKnownNonNull)
EmitLValue - Emit code to compute a designator that specifies the location of the expression.
llvm::Instruction * CurrentFuncletPad
void EnsureInsertPoint()
EnsureInsertPoint - Ensure that an insertion point is defined so that emitted IR has a place to go.
llvm::LLVMContext & getLLVMContext()
void emitAlignmentAssumption(llvm::Value *PtrValue, QualType Ty, SourceLocation Loc, SourceLocation AssumptionLoc, llvm::Value *Alignment, llvm::Value *OffsetValue=nullptr)
void EmitVariablyModifiedType(QualType Ty)
EmitVLASize - Capture all the sizes for the VLA expressions in the given variably-modified type and s...
llvm::Value * EmitNonNullRValueCheck(RValue RV, QualType T)
Create a check that a scalar RValue is non-null.
void EmitARCIntrinsicUse(ArrayRef< llvm::Value * > values)
Given a number of pointers, inform the optimizer that they're being intrinsically used up until this ...
llvm::Value * EmitCMSEClearRecord(llvm::Value *V, llvm::IntegerType *ITy, QualType RTy)
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 EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
EmitBlock - Emit the given block.
QualType BuildFunctionArgList(GlobalDecl GD, FunctionArgList &Args)
This class organizes the cross-function state that is used while generating LLVM code.
const ABIInfo & getABIInfo()
bool ReturnTypeUsesFPRet(QualType ResultType)
Return true iff the given type uses 'fpret' when used as a return type.
const LangOptions & getLangOpts() const
CharUnits getNaturalTypeAlignment(QualType T, LValueBaseInfo *BaseInfo=nullptr, TBAAAccessInfo *TBAAInfo=nullptr, bool forPointeeType=false)
CodeGenTypes & getTypes()
const TargetInfo & getTarget() const
void computeABIInfoUsingLib(CGFunctionInfo &FI)
Drive the experimental LLVMABI-based lowering path: map argument and return types into the LLVMABI li...
const llvm::DataLayout & getDataLayout() const
ObjCEntrypoints & getObjCEntrypoints() const
CGCXXABI & getCXXABI() const
bool ReturnTypeUsesFP2Ret(QualType ResultType)
Return true iff the given type uses 'fp2ret' when used as a return type.
bool ReturnSlotInterferesWithArgs(const CGFunctionInfo &FI)
Return true iff the given type uses an argument slot when 'sret' is used as a return type.
bool ReturnTypeHasInReg(const CGFunctionInfo &FI)
Return true iff the given type has inreg set.
void AdjustMemoryAttribute(StringRef Name, CGCalleeInfo CalleeInfo, llvm::AttributeList &Attrs)
Adjust Memory attribute to ensure that the BE gets the right attribute.
void ConstructAttributeList(StringRef Name, const CGFunctionInfo &Info, CGCalleeInfo CalleeInfo, llvm::AttributeList &Attrs, unsigned &CallingConv, bool AttrOnCallSite, bool IsThunk)
Get the LLVM attributes and calling convention to use for a particular function type.
const llvm::abi::TargetInfo & getLLVMABITargetInfo(llvm::abi::TypeBuilder &TB)
Lazily build and return the LLVMABI library's TargetInfo for the current target.
ASTContext & getContext() const
bool ReturnTypeUsesSRet(const CGFunctionInfo &FI)
Return true iff the given type uses 'sret' when used as a return type.
const TargetCodeGenInfo & getTargetCodeGenInfo()
const CodeGenOptions & getCodeGenOpts() const
void addDefaultFunctionDefinitionAttributes(llvm::AttrBuilder &attrs)
Like the overload taking a Function &, but intended specifically for frontends that want to build on ...
CharUnits getNaturalPointeeTypeAlignment(QualType T, LValueBaseInfo *BaseInfo=nullptr, TBAAAccessInfo *TBAAInfo=nullptr)
llvm::LLVMContext & getLLVMContext()
CharUnits getMinimumObjectSize(QualType Ty)
Returns the minimum object size for an object of the given type.
bool MayDropFunctionReturn(const ASTContext &Context, QualType ReturnType) const
Whether this function's return type has no side effects, and thus may be trivially discarded if it is...
This class organizes the cross-module state that is used while lowering AST types to LLVM types.
const CGFunctionInfo & arrangeLLVMFunctionInfo(CanQualType returnType, FnInfoOpts opts, ArrayRef< CanQualType > argTypes, FunctionType::ExtInfo info, ArrayRef< FunctionProtoType::ExtParameterInfo > paramInfos, RequiredArgs args, const FunctionDecl *ABIInfoFD)
"Arrange" the LLVM information for a call or type with the given signature.
const CGFunctionInfo & arrangeFreeFunctionCall(const CallArgList &Args, const FunctionType *Ty, bool ChainCall, const FunctionDecl *ABIInfoFD)
Figure out the rules for calling a function with the given formal type using the given arguments.
const CGFunctionInfo & arrangeCXXMethodType(const CXXRecordDecl *RD, const FunctionProtoType *FTP, const CXXMethodDecl *MD)
Arrange the argument and result information for a call to an unknown C++ non-static member function o...
const CGFunctionInfo & arrangeCXXConstructorCall(const CallArgList &Args, const CXXConstructorDecl *D, CXXCtorType CtorKind, unsigned ExtraPrefixArgs, unsigned ExtraSuffixArgs, const FunctionDecl *ABIInfoFD, bool PassProtoArgs=true)
Arrange a call to a C++ method, passing the given arguments.
llvm::Type * ConvertType(QualType T)
ConvertType - Convert type T into a llvm::Type.
CGCXXABI & getCXXABI() const
const CGFunctionInfo & arrangeCXXMethodCall(const CallArgList &args, const FunctionProtoType *type, RequiredArgs required, unsigned numPrefixArgs, const FunctionDecl *ABIInfoFD)
Arrange a call to a C++ method, passing the given arguments.
const CGFunctionInfo & arrangeCXXMethodDeclaration(const CXXMethodDecl *MD)
C++ methods have some special rules and also have implicit parameters.
ASTContext & getContext() const
const CGFunctionInfo & arrangeFreeFunctionType(CanQual< FunctionProtoType > Ty)
Arrange the argument and result information for a value of the given freestanding function type.
CanQualType DeriveThisType(const CXXRecordDecl *RD, const CXXMethodDecl *MD)
Derives the 'this' type for codegen purposes, i.e.
llvm::FunctionType * GetFunctionType(const CGFunctionInfo &Info)
GetFunctionType - Get the LLVM function type for.
bool inheritingCtorHasParams(const InheritedConstructor &Inherited, CXXCtorType Type)
Determine if a C++ inheriting constructor should have parameters matching those of its inherited cons...
bool isFuncTypeConvertible(const FunctionType *FT)
isFuncTypeConvertible - Utility to check whether a function type can be converted to an LLVM type (i....
const CGFunctionInfo & arrangeBlockFunctionCall(const CallArgList &args, const FunctionType *type)
A block function is essentially a free function with an extra implicit argument.
const CGFunctionInfo & arrangeBuiltinFunctionDeclaration(QualType resultType, const FunctionArgList &args)
A builtin function is a freestanding function using the default C conventions.
const CGFunctionInfo & arrangeUnprototypedObjCMessageSend(QualType returnType, const CallArgList &args)
const CGRecordLayout & getCGRecordLayout(const RecordDecl *)
getCGRecordLayout - Return record layout info for the given record decl.
void getExpandedTypes(QualType Ty, SmallVectorImpl< llvm::Type * >::iterator &TI)
getExpandedTypes - Expand the type
llvm::Type * ConvertTypeForMem(QualType T)
ConvertTypeForMem - Convert type T into a llvm::Type.
const CGFunctionInfo & arrangeObjCMethodDeclaration(const ObjCMethodDecl *MD)
Objective-C methods are C functions with some implicit parameters.
llvm::LLVMContext & getLLVMContext()
const CGFunctionInfo & arrangeDeviceKernelCallerDeclaration(QualType resultType, const FunctionArgList &args)
A device kernel caller function is an offload device entry point function with a target device depend...
const CGFunctionInfo & arrangeGlobalDeclaration(GlobalDecl GD)
const CGFunctionInfo & arrangeUnprototypedMustTailThunk(const CXXMethodDecl *MD)
Arrange a thunk that takes 'this' as the first parameter followed by varargs.
const CGFunctionInfo & arrangeBuiltinFunctionCall(QualType resultType, const CallArgList &args)
const CGFunctionInfo & arrangeBlockFunctionDeclaration(const FunctionProtoType *type, const FunctionArgList &args)
Block invocation functions are C functions with an implicit parameter.
unsigned ClangCallConvToLLVMCallConv(CallingConv CC)
Convert clang calling convention to LLVM callilng convention.
llvm::Type * GetFunctionTypeForVTable(GlobalDecl GD)
GetFunctionTypeForVTable - Get the LLVM function type for use in a vtable, given a CXXMethodDecl.
const CGFunctionInfo & arrangeCall(const CGFunctionInfo &declFI, const CallArgList &args, const FunctionDecl *ABIInfoFD)
Given a function info for a declaration, return the function info for a call with the given arguments...
const CGFunctionInfo & arrangeObjCMessageSendSignature(const ObjCMethodDecl *MD, QualType receiverType)
Arrange the argument and result information for the function type through which to perform a send to ...
const CGFunctionInfo & arrangeCXXStructorDeclaration(GlobalDecl GD)
const CGFunctionInfo & arrangeFunctionDeclaration(const GlobalDecl GD)
Free functions are functions that are compatible with an ordinary C function pointer type.
const CGFunctionInfo & arrangeMSCtorClosure(const CXXConstructorDecl *CD, CXXCtorType CT)
const CGFunctionInfo & arrangeNullaryFunction()
A nullary function is a freestanding function of type 'void ()'.
A saved depth on the scope stack.
FunctionArgList - Type for representing both the decl and type of parameters to a function.
LValue - This represents an lvalue references.
static LValue MakeAddr(Address Addr, QualType type, ASTContext &Context, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
Address getAddress() const
RValue - This trivial value class is used to represent the result of an expression that is evaluated.
static RValue get(llvm::Value *V)
static RValue getAggregate(Address addr, bool isVolatile=false)
Convert an Address to an RValue.
static RValue getComplex(llvm::Value *V1, llvm::Value *V2)
Address getAggregateAddress() const
getAggregateAddr() - Return the Value* of the address of the aggregate.
llvm::Value * getScalarVal() const
getScalarVal() - Return the Value* of this scalar value.
std::pair< llvm::Value *, llvm::Value * > getComplexVal() const
getComplexVal - Return the real/imag components of this complex value.
An abstract representation of an aligned address.
CharUnits getAlignment() const
Return the alignment of this pointer.
llvm::Value * getPointer() const
static RawAddress invalid()
A class for recording the number of arguments that a function signature requires.
bool allowsOptionalArgs() const
unsigned getNumRequiredArgs() const
static RequiredArgs forPrototypePlus(const FunctionProtoType *prototype, unsigned additional)
Compute the arguments required by the given formal prototype, given that there may be some additional...
ReturnValueSlot - Contains the address where the return value of a function can be stored,...
virtual void setCUDAKernelCallingConvention(const FunctionType *&FT) const
static void initPointerAuthFnAttributes(const PointerAuthOptions &Opts, llvm::AttrBuilder &FuncAttrs)
static void initBranchProtectionFnAttributes(const TargetInfo::BranchProtectionInfo &BPI, llvm::AttrBuilder &FuncAttrs)
virtual bool isNoProtoCallVariadic(const CodeGen::CallArgList &args, const FunctionNoProtoType *fnType) const
Determine whether a call to an unprototyped functions under the given calling convention should use t...
Complex values, per C99 6.2.5p11.
Represents the canonical version of C arrays with a specified constant size.
bool constructsVirtualBase() const
Returns true if the constructed base class is a virtual base class subobject of this declaration's cl...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Decl - This represents one declaration (or definition), e.g.
const FunctionType * getFunctionType(bool BlocksToo=true) const
Looks through the Decl's underlying type to extract a FunctionType when possible.
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
DeclContext * getDeclContext()
SourceLocation getBeginLoc() const LLVM_READONLY
This represents one expression.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
@ NPC_ValueDependentIsNotNull
Specifies that a value-dependent expression should be considered to never be a null pointer constant.
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant.
Represents a member of a struct/union/class.
bool isBitField() const
Determines whether this field is a bitfield.
bool isUnnamedBitField() const
Determines whether this is an unnamed bitfield.
bool isZeroLengthBitField() const
Is this a zero-length bit-field?
Represents a function declaration or definition.
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program.
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Represents a prototype with parameter type info, e.g.
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
unsigned getNumParams() const
unsigned getAArch64SMEAttributes() const
Return a bitmask describing the SME attributes on the function type, see AArch64SMETypeAttributes for...
bool isNothrow(bool ResultIfDependent=false) const
Determine whether this function type has a non-throwing exception specification.
ArrayRef< ExtParameterInfo > getExtParameterInfos() const
bool hasExtParameterInfos() const
Is there any interesting extra information for any of the parameters of this function type?
Wrapper for source info for functions.
A class which abstracts out some details necessary for making a call.
ExtInfo withCallingConv(CallingConv cc) const
ExtInfo withProducesResult(bool producesResult) const
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
ParameterABI getABI() const
Return the ABI treatment of this parameter.
ExtParameterInfo withIsNoEscape(bool NoEscape) const
FunctionType - C99 6.7.5.3 - Function Declarators.
ExtInfo getExtInfo() const
@ SME_PStateSMEnabledMask
@ SME_PStateSMCompatibleMask
@ SME_AgnosticZAStateMask
static ArmStateValue getArmZT0State(unsigned AttrBits)
static ArmStateValue getArmZAState(unsigned AttrBits)
QualType getReturnType() const
GlobalDecl - represents a global declaration.
CXXCtorType getCtorType() const
KernelReferenceKind getKernelReferenceKind() const
CXXDtorType getDtorType() const
const Decl * getDecl() const
This class represents temporary values used to represent inout and out arguments in HLSL.
Description of a constructor that was inherited from a base class.
ConstructorUsingShadowDecl * getShadowDecl() const
@ FPE_Ignore
Assume that floating-point exceptions are masked.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
std::vector< std::string > NoBuiltinFuncs
A list of all -fno-builtin-* function names (e.g., memset).
FPExceptionModeKind getDefaultExceptionMode() const
bool isNoBuiltinFunc(StringRef Name) const
Is this a libc/libm function that is no longer recognized as a builtin because a -fno-builtin-* optio...
bool assumeFunctionsAreConvergent() const
Represents a matrix type, as defined in the Matrix Types clang extensions.
Describes a module or submodule.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
ObjCCategoryDecl - Represents a category declaration.
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
bool shouldCopy() const
shouldCopy - True if we should do the 'copy' part of the copy-restore.
Represents an ObjC class declaration.
ObjCMethodDecl - Represents an instance or class method declaration.
ImplicitParamDecl * getSelfDecl() const
ArrayRef< ParmVarDecl * > parameters() const
bool isDirectMethod() const
True if the method is tagged as objc_direct.
QualType getReturnType() const
Represents a parameter to a function.
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
bool isRestrictQualified() const
Determine whether this type is restrict-qualified.
bool isTriviallyCopyableType(const ASTContext &Context) const
Return true if this is a trivially copyable type (C++0x [basic.types]p9)
bool isNull() const
Return true if this QualType doesn't point to a type yet.
LangAS getAddressSpace() const
Return the address space of this type.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
QualType getCanonicalType() const
bool isConstQualified() const
Determine whether this type is const-qualified.
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after.
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
LangAS getAddressSpace() const
Represents a struct/union/class.
field_iterator field_end() const
bool isParamDestroyedInCallee() const
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
field_iterator field_begin() const
Base for LValueReferenceType and RValueReferenceType.
Encodes a location in the source.
UIntTy getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
Options for controlling the target.
std::vector< std::string > Features
The list of target specific features to enable or disable – this should be a list of strings starting...
std::string TuneCPU
If given, the name of the target CPU to tune code for.
std::string CPU
If given, the name of the target CPU to generate code for.
llvm::StringMap< bool > FeatureMap
The map of which features have been enabled disabled based on the command line.
The base class of the type hierarchy.
bool isIncompleteArrayType() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
bool isConstantSizeType() const
Return true if this is not a variable sized type, according to the rules of C99 6....
bool isPointerType() const
CanQualType getCanonicalTypeUnqualified() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isScalarType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isBitIntType() const
RecordDecl * castAsRecordDecl() const
bool isMemberPointerType() const
bool isFunctionProtoType() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
bool isObjectType() const
Determine whether this type is an object type.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool hasFloatingRepresentation() const
Determine whether this type has a floating-point representation of some sort, e.g....
const T * getAsCanonical() const
If this type is canonically the specified type, return its canonical type cast to that specified type...
const T * castAsCanonical() const
Return this type's canonical type cast to the specified type.
const T * getAs() const
Member-template getAs<specific type>'.
bool isNullPtrType() const
bool isRecordType() const
bool isObjCRetainableType() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Represents a call to the builtin function __builtin_va_arg.
Represents a variable declaration or definition.
QualType::DestructionKind needsDestruction(const ASTContext &Ctx) const
Would the destruction of this variable have any effect, and if so, what kind?
Represents a GCC generic vector type.
Defines the clang::TargetInfo interface.
bool isArgumentMaybeUndef(const Decl *TargetDecl, unsigned NumRequiredArgs, unsigned ArgNo)
CanQual< FunctionProtoType > getFormalType(const CXXMethodDecl *MD)
Returns the canonical formal type of the given C++ method.
llvm::FPClassTest getNoFPClassTestMask(const LangOptions &LangOpts)
Returns the set of floating-point value kinds that the language options promise never reach a functio...
bool shouldEvaluateArgsLeftToRight(EvaluationOrder Order, const TargetCXXABI &ABI)
Returns true if call arguments should be emitted left-to-right, given the order the language requires...
void computeABIInfo(CodeGenModule &CGM, CGFunctionInfo &FI)
Compute the ABI information of a swiftcall function.
@ Type
The l-value was considered opaque, so the alignment was determined from a type.
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
void computeSPIRKernelABIInfo(CodeGenModule &CGM, CGFunctionInfo &FI)
const EHPersonality & getEHPersonality(CodeGenModule &CGM, const FunctionDecl *FD)
Selects the personality function to use for FD, or for the translation unit as a whole when FD is nul...
@ NormalCleanup
Denotes a cleanup that should run when a scope is exited using normal control flow (falling off the e...
void mergeDefaultFunctionDefinitionAttributes(llvm::Function &F, const CodeGenOptions &CodeGenOpts, const LangOptions &LangOpts, const TargetOptions &TargetOpts, bool WillInternalize)
Adds attributes to F according to our CodeGenOpts and LangOpts, as though we had emitted it ourselves...
QualType useFirstFieldIfTransparentUnion(QualType Ty)
Pass transparent unions as if they were the type of the first element.
bool isEmptyRecord(ASTContext &Context, QualType T, bool AllowArrays, bool AsIfNoUniqueAddr=false)
isEmptyRecord - Return true iff a structure contains only empty fields.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
PRESERVE_NONE bool Ret(InterpState &S)
bool This(InterpState &S, CodePtr OpPC)
@ Address
A pointer to a ValueDecl.
Top level wrappers for InstallAPI frontend operations.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
CXXCtorType
C++ constructor types.
@ Ctor_DefaultClosure
Default closure variant of a ctor.
@ Ctor_CopyingClosure
Copying closure variant of a ctor.
@ Ctor_Complete
Complete object ctor.
bool isa(CodeGen::Address addr)
static bool classof(const OMPClause *T)
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
bool isInstanceMethod(const Decl *D)
@ NonNull
Values of this type can never be null.
@ OK_Ordinary
An ordinary object is located at an address in memory.
@ Vector
'vector' clause, allowed on 'loop', Combined, and 'routine' directives.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
@ SwiftAsyncContext
This parameter (which must have pointer type) uses the special Swift asynchronous context-pointer ABI...
@ SwiftErrorResult
This parameter (which must have pointer-to-pointer type) uses the special Swift error-result ABI trea...
@ Ordinary
This parameter uses ordinary ABI rules for its type.
@ SwiftIndirectResult
This parameter (which must have pointer type) is a Swift indirect result parameter.
@ SwiftContext
This parameter (which must have pointer type) uses the special Swift context-pointer ABI treatment.
const FunctionProtoType * T
@ Dtor_VectorDeleting
Vector deleting dtor.
@ Dtor_Complete
Complete object dtor.
@ Dtor_Deleting
Deleting dtor.
@ CanPassInRegs
The argument of this type can be passed directly in registers.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
U cast(CodeGen::Address addr)
@ Struct
The "struct" keyword introduces the elaborated-type-specifier.
__DEVICE__ _Tp arg(const std::complex< _Tp > &__c)
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t uint64_t __builtin_riscv_ssha_i32 __builtin_riscv_sshl_u32 uint64_t
bool isMSVCXXPersonality() const
Structure with information about how a bitfield should be accessed.
CharUnits StorageOffset
The offset of the bitfield storage from the start of the struct.
unsigned Offset
The offset within a contiguous run of bitfields that are represented as a single "field" within the L...
unsigned Size
The total size of the bit-field, in bits, not including padding.
unsigned StorageSize
The storage size in bits which should be used when accessing this bitfield.
Similar to AddedStructorArgs, but only notes the number of additional arguments.
llvm::Value * ToUse
A value to "use" after the writeback, or null.
LValue Source
The original argument.
Address Temporary
The temporary alloca.
const Expr * WritebackExpr
An Expression (optional) that performs the writeback with any required casting.
LValue getKnownLValue() const
RValue getKnownRValue() const
void copyInto(CodeGenFunction &CGF, Address A) const
RValue getRValue(CodeGenFunction &CGF) const
llvm::PointerType * VoidPtrTy
llvm::IntegerType * Int64Ty
llvm::IntegerType * Int8Ty
i8, i16, i32, and i64
llvm::CallingConv::ID getRuntimeCC() const
llvm::IntegerType * SizeTy
llvm::IntegerType * Int32Ty
llvm::IntegerType * IntPtrTy
llvm::PointerType * Int8PtrTy
CharUnits getPointerAlign() const
~DisableDebugLocationUpdates()
DisableDebugLocationUpdates(CodeGenFunction &CGF)
llvm::Function * objc_retainAutoreleasedReturnValue
id objc_retainAutoreleasedReturnValue(id);
llvm::Function * objc_retain
id objc_retain(id);
llvm::InlineAsm * retainAutoreleasedReturnValueMarker
A void(void) inline asm to use to mark that the return value of a call will be immediately retain.
bool has(SanitizerMask K) const
Check if a certain (single) sanitizer is enabled.