31 #include "llvm/ADT/StringExtras.h" 32 #include "llvm/Transforms/Utils/Local.h" 33 #include "llvm/Analysis/ValueTracking.h" 34 #include "llvm/IR/Attributes.h" 35 #include "llvm/IR/CallSite.h" 36 #include "llvm/IR/CallingConv.h" 37 #include "llvm/IR/DataLayout.h" 38 #include "llvm/IR/InlineAsm.h" 39 #include "llvm/IR/IntrinsicInst.h" 40 #include "llvm/IR/Intrinsics.h" 41 using namespace clang;
42 using namespace CodeGen;
53 case CC_Win64:
return llvm::CallingConv::Win64;
55 case CC_AAPCS:
return llvm::CallingConv::ARM_AAPCS;
56 case CC_AAPCS_VFP:
return llvm::CallingConv::ARM_AAPCS_VFP;
66 case CC_Swift:
return llvm::CallingConv::Swift;
108 unsigned totalArgs) {
110 assert(paramInfos.size() <= prefixArgs);
111 assert(proto->
getNumParams() + prefixArgs <= totalArgs);
113 paramInfos.reserve(totalArgs);
116 paramInfos.resize(prefixArgs);
120 paramInfos.push_back(ParamInfo);
122 if (ParamInfo.hasPassObjectSize())
123 paramInfos.emplace_back();
126 assert(paramInfos.size() <= totalArgs &&
127 "Did we forget to insert pass_object_size args?");
129 paramInfos.resize(totalArgs);
139 if (!FPT->hasExtParameterInfos()) {
140 assert(paramInfos.empty() &&
141 "We have paramInfos, but the prototype doesn't?");
142 prefix.append(FPT->param_type_begin(), FPT->param_type_end());
146 unsigned PrefixSize = prefix.size();
150 prefix.reserve(prefix.size() + FPT->getNumParams());
152 auto ExtInfos = FPT->getExtParameterInfos();
153 assert(ExtInfos.size() == FPT->getNumParams());
154 for (
unsigned I = 0, E = FPT->getNumParams(); I != E; ++I) {
155 prefix.push_back(FPT->getParamType(I));
156 if (ExtInfos[I].hasPassObjectSize())
171 SmallVector<FunctionProtoType::ExtParameterInfo, 16> paramInfos;
180 FTP->getExtInfo(), paramInfos,
199 if (D->
hasAttr<FastCallAttr>())
205 if (D->
hasAttr<ThisCallAttr>())
208 if (D->
hasAttr<VectorCallAttr>())
214 if (PcsAttr *PCS = D->
getAttr<PcsAttr>())
217 if (D->
hasAttr<IntelOclBiccAttr>())
226 if (D->
hasAttr<PreserveMostAttr>())
229 if (D->
hasAttr<PreserveAllAttr>())
254 *
this,
true, argTypes,
261 if (FD->
hasAttr<CUDAGlobalAttr>()) {
274 assert(!isa<CXXConstructorDecl>(MD) &&
"wrong method for constructors!");
275 assert(!isa<CXXDestructorDecl>(MD) &&
"wrong method for destructors!");
307 bool PassParams =
true;
310 if (
auto *CD = dyn_cast<CXXConstructorDecl>(MD)) {
315 if (
auto Inherited = CD->getInheritedConstructor())
330 if (!paramInfos.empty()) {
333 paramInfos.insert(paramInfos.begin() + 1, AddedArgs.
Prefix,
336 paramInfos.append(AddedArgs.
Suffix,
351 false, argTypes, extInfo,
352 paramInfos, required);
357 SmallVector<CanQualType, 16> argTypes;
358 for (
auto &arg : args)
363 static SmallVector<CanQualType, 16>
365 SmallVector<CanQualType, 16> argTypes;
366 for (
auto &arg : args)
373 unsigned prefixArgs,
unsigned totalArgs) {
393 unsigned ExtraPrefixArgs,
394 unsigned ExtraSuffixArgs,
395 bool PassProtoArgs) {
398 for (
const auto &Arg : args)
402 unsigned TotalPrefixArgs = 1 + ExtraPrefixArgs;
418 if (PassProtoArgs && FPT->hasExtParameterInfos()) {
424 false, ArgTypes, Info,
425 ParamInfos, Required);
433 if (MD->isInstance())
438 assert(isa<FunctionType>(FTy));
445 noProto->getReturnType(),
false,
478 I->hasAttr<NoEscapeAttr>());
479 extParamInfos.push_back(extParamInfo);
486 if (
getContext().getLangOpts().ObjCAutoRefCount &&
487 MD->
hasAttr<NSReturnsRetainedAttr>())
495 false, argTys, einfo, extParamInfos, required);
530 assert(MD->
isVirtual() &&
"only methods have thunks");
548 ArgTys.push_back(*FTP->param_type_begin());
550 ArgTys.push_back(Context.
IntTy);
566 unsigned numExtraRequiredArgs,
568 assert(args.size() >= numExtraRequiredArgs);
578 if (proto->isVariadic())
579 required =
RequiredArgs(proto->getNumParams() + numExtraRequiredArgs);
581 if (proto->hasExtParameterInfos())
591 cast<FunctionNoProtoType>(fnType))) {
596 SmallVector<CanQualType, 16> argTypes;
597 for (
const auto &arg : args)
614 chainCall ? 1 : 0, chainCall);
634 false,
false, argTypes,
644 for (
const auto &Arg : args)
666 resultType,
false,
false,
678 unsigned numPrefixArgs) {
679 assert(numPrefixArgs + 1 <= args.size() &&
680 "Emitting a call with less args than the required prefix?");
692 false, argTypes, info, paramInfos, required);
704 assert(signature.
arg_size() <= args.size());
705 if (signature.
arg_size() == args.size())
710 if (!sigParamInfos.empty()) {
711 paramInfos.append(sigParamInfos.begin(), sigParamInfos.end());
712 paramInfos.resize(args.size());
744 assert(std::all_of(argTypes.begin(), argTypes.end(),
745 [](
CanQualType T) {
return T.isCanonicalAsParam(); }));
748 llvm::FoldingSetNodeID
ID;
750 required, resultType, argTypes);
752 void *insertPos =
nullptr;
753 CGFunctionInfo *FI = FunctionInfos.FindNodeOrInsertPos(ID, insertPos);
761 paramInfos, resultType, argTypes, required);
762 FunctionInfos.InsertNode(FI, insertPos);
764 bool inserted = FunctionsBeingProcessed.insert(FI).second;
766 assert(inserted &&
"Recursively being processed?");
769 if (CC == llvm::CallingConv::SPIR_KERNEL) {
786 for (
auto &I : FI->arguments())
787 if (I.info.canHaveCoerceToType() && I.info.getCoerceToType() ==
nullptr)
790 bool erased = FunctionsBeingProcessed.erase(FI); (void)erased;
791 assert(erased &&
"Not in set?");
804 assert(paramInfos.empty() || paramInfos.size() == argTypes.size());
807 operator new(totalSizeToAlloc<ArgInfo, ExtParameterInfo>(
808 argTypes.size() + 1, paramInfos.size()));
811 FI->CallingConvention = llvmCC;
812 FI->EffectiveCallingConvention = llvmCC;
813 FI->ASTCallingConvention = info.
getCC();
814 FI->InstanceMethod = instanceMethod;
815 FI->ChainCall = chainCall;
820 FI->Required = required;
823 FI->ArgStruct =
nullptr;
824 FI->ArgStructAlign = 0;
825 FI->NumArgs = argTypes.size();
826 FI->HasExtParameterInfos = !paramInfos.empty();
827 FI->getArgsBuffer()[0].
type = resultType;
828 for (
unsigned i = 0, e = argTypes.size(); i != e; ++i)
829 FI->getArgsBuffer()[i + 1].
type = argTypes[i];
830 for (
unsigned i = 0, e = paramInfos.size(); i != e; ++i)
831 FI->getExtParameterInfosBuffer()[i] = paramInfos[i];
841 struct TypeExpansion {
842 enum TypeExpansionKind {
854 const TypeExpansionKind
Kind;
856 TypeExpansion(TypeExpansionKind K) :
Kind(K) {}
857 virtual ~TypeExpansion() {}
860 struct ConstantArrayExpansion : TypeExpansion {
864 ConstantArrayExpansion(
QualType EltTy, uint64_t NumElts)
865 : TypeExpansion(TEK_ConstantArray), EltTy(EltTy), NumElts(NumElts) {}
866 static bool classof(
const TypeExpansion *TE) {
867 return TE->Kind == TEK_ConstantArray;
871 struct RecordExpansion : TypeExpansion {
878 : TypeExpansion(TEK_Record), Bases(std::move(Bases)),
879 Fields(std::move(Fields)) {}
880 static bool classof(
const TypeExpansion *TE) {
881 return TE->Kind == TEK_Record;
885 struct ComplexExpansion : TypeExpansion {
889 static bool classof(
const TypeExpansion *TE) {
894 struct NoExpansion : TypeExpansion {
895 NoExpansion() : TypeExpansion(TEK_None) {}
896 static bool classof(
const TypeExpansion *TE) {
897 return TE->Kind == TEK_None;
902 static std::unique_ptr<TypeExpansion>
905 return llvm::make_unique<ConstantArrayExpansion>(
906 AT->getElementType(), AT->getSize().getZExtValue());
909 SmallVector<const CXXBaseSpecifier *, 1> Bases;
910 SmallVector<const FieldDecl *, 1> Fields;
913 "Cannot expand structure with flexible array.");
920 for (
const auto *FD : RD->
fields()) {
921 if (FD->isZeroLengthBitField(Context))
923 assert(!FD->isBitField() &&
924 "Cannot expand structure with bit-field members.");
926 if (UnionSize < FieldSize) {
927 UnionSize = FieldSize;
932 Fields.push_back(LargestFD);
934 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
935 assert(!CXXRD->isDynamicClass() &&
936 "cannot expand vtable pointers in dynamic classes");
938 Bases.push_back(&BS);
941 for (
const auto *FD : RD->
fields()) {
942 if (FD->isZeroLengthBitField(Context))
944 assert(!FD->isBitField() &&
945 "Cannot expand structure with bit-field members.");
946 Fields.push_back(FD);
949 return llvm::make_unique<RecordExpansion>(std::move(Bases),
953 return llvm::make_unique<ComplexExpansion>(CT->getElementType());
955 return llvm::make_unique<NoExpansion>();
960 if (
auto CAExp = dyn_cast<ConstantArrayExpansion>(Exp.get())) {
963 if (
auto RExp = dyn_cast<RecordExpansion>(Exp.get())) {
965 for (
auto BS : RExp->Bases)
967 for (
auto FD : RExp->Fields)
971 if (isa<ComplexExpansion>(Exp.get()))
973 assert(isa<NoExpansion>(Exp.get()));
981 if (
auto CAExp = dyn_cast<ConstantArrayExpansion>(Exp.get())) {
982 for (
int i = 0, n = CAExp->NumElts; i < n; i++) {
985 }
else if (
auto RExp = dyn_cast<RecordExpansion>(Exp.get())) {
986 for (
auto BS : RExp->Bases)
988 for (
auto FD : RExp->Fields)
990 }
else if (
auto CExp = dyn_cast<ComplexExpansion>(Exp.get())) {
995 assert(isa<NoExpansion>(Exp.get()));
1001 ConstantArrayExpansion *CAE,
1003 llvm::function_ref<
void(
Address)> Fn) {
1008 for (
int i = 0, n = CAE->NumElts; i < n; i++) {
1011 Fn(
Address(EltAddr, EltAlign));
1015 void CodeGenFunction::ExpandTypeFromArgs(
1018 "Unexpected non-simple lvalue during struct expansion.");
1021 if (
auto CAExp = dyn_cast<ConstantArrayExpansion>(Exp.get())) {
1024 LValue LV = MakeAddrLValue(EltAddr, CAExp->EltTy);
1025 ExpandTypeFromArgs(CAExp->EltTy, LV, AI);
1027 }
else if (
auto RExp = dyn_cast<RecordExpansion>(Exp.get())) {
1037 ExpandTypeFromArgs(BS->getType(), SubLV, AI);
1039 for (
auto FD : RExp->Fields) {
1041 LValue SubLV = EmitLValueForFieldInitialization(LV, FD);
1042 ExpandTypeFromArgs(FD->getType(), SubLV, AI);
1044 }
else if (isa<ComplexExpansion>(Exp.get())) {
1045 auto realValue = *AI++;
1046 auto imagValue = *AI++;
1047 EmitStoreOfComplex(
ComplexPairTy(realValue, imagValue), LV,
true);
1049 assert(isa<NoExpansion>(Exp.get()));
1054 void CodeGenFunction::ExpandTypeToArgs(
1058 if (
auto CAExp = dyn_cast<ConstantArrayExpansion>(Exp.get())) {
1062 *
this, CAExp, Addr, [&](
Address EltAddr) {
1066 ExpandTypeToArgs(CAExp->EltTy, EltArg, IRFuncTy, IRCallArgs,
1069 }
else if (
auto RExp = dyn_cast<RecordExpansion>(Exp.get())) {
1080 ExpandTypeToArgs(BS->getType(), BaseArg, IRFuncTy, IRCallArgs,
1084 LValue LV = MakeAddrLValue(This, Ty);
1085 for (
auto FD : RExp->Fields) {
1088 ExpandTypeToArgs(FD->getType(), FldArg, IRFuncTy, IRCallArgs,
1091 }
else if (isa<ComplexExpansion>(Exp.get())) {
1093 IRCallArgs[IRCallArgPos++] = CV.first;
1094 IRCallArgs[IRCallArgPos++] = CV.second;
1096 assert(isa<NoExpansion>(Exp.get()));
1098 assert(RV.isScalar() &&
1099 "Unexpected non-scalar rvalue during struct expansion.");
1103 if (IRCallArgPos < IRFuncTy->getNumParams() &&
1104 V->getType() != IRFuncTy->getParamType(IRCallArgPos))
1105 V = Builder.CreateBitCast(V, IRFuncTy->getParamType(IRCallArgPos));
1107 IRCallArgs[IRCallArgPos++] = V;
1127 llvm::StructType *SrcSTy,
1130 if (SrcSTy->getNumElements() == 0)
return SrcPtr;
1132 llvm::Type *FirstElt = SrcSTy->getElementType(0);
1138 uint64_t FirstEltSize =
1140 if (FirstEltSize < DstSize &&
1149 if (llvm::StructType *SrcSTy = dyn_cast<llvm::StructType>(SrcTy))
1165 if (Val->getType() == Ty)
1168 if (isa<llvm::PointerType>(Val->getType())) {
1170 if (isa<llvm::PointerType>(Ty))
1178 if (isa<llvm::PointerType>(DestIntTy))
1181 if (Val->getType() != DestIntTy) {
1183 if (DL.isBigEndian()) {
1186 uint64_t SrcSize = DL.getTypeSizeInBits(Val->getType());
1187 uint64_t DstSize = DL.getTypeSizeInBits(DestIntTy);
1189 if (SrcSize > DstSize) {
1190 Val = CGF.
Builder.CreateLShr(Val, SrcSize - DstSize,
"coerce.highbits");
1191 Val = CGF.
Builder.CreateTrunc(Val, DestIntTy,
"coerce.val.ii");
1193 Val = CGF.
Builder.CreateZExt(Val, DestIntTy,
"coerce.val.ii");
1194 Val = CGF.
Builder.CreateShl(Val, DstSize - SrcSize,
"coerce.highbits");
1198 Val = CGF.
Builder.CreateIntCast(Val, DestIntTy,
false,
"coerce.val.ii");
1202 if (isa<llvm::PointerType>(Ty))
1203 Val = CGF.
Builder.CreateIntToPtr(Val, Ty,
"coerce.val.ip");
1226 if (llvm::StructType *SrcSTy = dyn_cast<llvm::StructType>(SrcTy)) {
1228 SrcTy = Src.
getType()->getElementType();
1235 if ((isa<llvm::IntegerType>(Ty) || isa<llvm::PointerType>(Ty)) &&
1236 (isa<llvm::IntegerType>(SrcTy) || isa<llvm::PointerType>(SrcTy))) {
1242 if (SrcSize >= DstSize) {
1259 llvm::ConstantInt::get(CGF.
IntPtrTy, SrcSize),
1269 Address Dest,
bool DestIsVolatile) {
1271 if (llvm::StructType *STy =
1272 dyn_cast<llvm::StructType>(Val->getType())) {
1273 const llvm::StructLayout *Layout =
1276 for (
unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
1299 if (SrcTy == DstTy) {
1306 if (llvm::StructType *DstSTy = dyn_cast<llvm::StructType>(DstTy)) {
1308 DstTy = Dst.
getType()->getElementType();
1313 if ((isa<llvm::IntegerType>(SrcTy) || isa<llvm::PointerType>(SrcTy)) &&
1314 (isa<llvm::IntegerType>(DstTy) || isa<llvm::PointerType>(DstTy))) {
1323 if (SrcSize <= DstSize) {
1341 llvm::ConstantInt::get(CGF.
IntPtrTy, DstSize),
1361 class ClangToLLVMArgMapping {
1362 static const unsigned InvalidIndex = ~0U;
1363 unsigned InallocaArgNo;
1365 unsigned TotalIRArgs;
1369 unsigned PaddingArgIndex;
1372 unsigned FirstArgIndex;
1373 unsigned NumberOfArgs;
1376 : PaddingArgIndex(InvalidIndex), FirstArgIndex(InvalidIndex),
1380 SmallVector<IRArgs, 8> ArgInfo;
1384 bool OnlyRequiredArgs =
false)
1385 : InallocaArgNo(InvalidIndex), SRetArgNo(InvalidIndex), TotalIRArgs(0),
1387 construct(Context, FI, OnlyRequiredArgs);
1390 bool hasInallocaArg()
const {
return InallocaArgNo != InvalidIndex; }
1391 unsigned getInallocaArgNo()
const {
1392 assert(hasInallocaArg());
1393 return InallocaArgNo;
1396 bool hasSRetArg()
const {
return SRetArgNo != InvalidIndex; }
1397 unsigned getSRetArgNo()
const {
1398 assert(hasSRetArg());
1402 unsigned totalIRArgs()
const {
return TotalIRArgs; }
1404 bool hasPaddingArg(
unsigned ArgNo)
const {
1405 assert(ArgNo < ArgInfo.size());
1406 return ArgInfo[ArgNo].PaddingArgIndex != InvalidIndex;
1408 unsigned getPaddingArgNo(
unsigned ArgNo)
const {
1409 assert(hasPaddingArg(ArgNo));
1410 return ArgInfo[ArgNo].PaddingArgIndex;
1415 std::pair<unsigned, unsigned> getIRArgs(
unsigned ArgNo)
const {
1416 assert(ArgNo < ArgInfo.size());
1417 return std::make_pair(ArgInfo[ArgNo].FirstArgIndex,
1418 ArgInfo[ArgNo].NumberOfArgs);
1423 bool OnlyRequiredArgs);
1426 void ClangToLLVMArgMapping::construct(
const ASTContext &Context,
1428 bool OnlyRequiredArgs) {
1429 unsigned IRArgNo = 0;
1430 bool SwapThisWithSRet =
false;
1435 SRetArgNo = SwapThisWithSRet ? 1 : IRArgNo++;
1446 auto &IRArgs = ArgInfo[ArgNo];
1449 IRArgs.PaddingArgIndex = IRArgNo++;
1455 llvm::StructType *STy = dyn_cast<llvm::StructType>(AI.
getCoerceToType());
1457 IRArgs.NumberOfArgs = STy->getNumElements();
1459 IRArgs.NumberOfArgs = 1;
1464 IRArgs.NumberOfArgs = 1;
1469 IRArgs.NumberOfArgs = 0;
1479 if (IRArgs.NumberOfArgs > 0) {
1480 IRArgs.FirstArgIndex = IRArgNo;
1481 IRArgNo += IRArgs.NumberOfArgs;
1486 if (IRArgNo == 1 && SwapThisWithSRet)
1489 assert(ArgNo == ArgInfo.size());
1492 InallocaArgNo = IRArgNo++;
1494 TotalIRArgs = IRArgNo;
1502 return RI.
isIndirect() || (RI.isInAlloca() && RI.getInAllocaSRet());
1506 return ReturnTypeUsesSRet(FI) &&
1507 getTargetCodeGenInfo().doesReturnSlotInterfereWithArgs();
1512 switch (BT->getKind()) {
1515 case BuiltinType::Float:
1517 case BuiltinType::Double:
1519 case BuiltinType::LongDouble:
1530 if (BT->getKind() == BuiltinType::LongDouble)
1543 llvm::FunctionType *
1546 bool Inserted = FunctionsBeingProcessed.insert(&FI).second;
1548 assert(Inserted &&
"Recursively being processed?");
1554 llvm_unreachable(
"Invalid ABI kind for return argument");
1567 resultType = llvm::PointerType::get(ty, addressSpace);
1583 ClangToLLVMArgMapping IRFunctionArgs(
getContext(), FI,
true);
1587 if (IRFunctionArgs.hasSRetArg()) {
1591 ArgTypes[IRFunctionArgs.getSRetArgNo()] =
1592 llvm::PointerType::get(Ty, AddressSpace);
1596 if (IRFunctionArgs.hasInallocaArg()) {
1599 ArgTypes[IRFunctionArgs.getInallocaArgNo()] = ArgStruct->getPointerTo();
1606 for (; it != ie; ++it, ++ArgNo) {
1610 if (IRFunctionArgs.hasPaddingArg(ArgNo))
1611 ArgTypes[IRFunctionArgs.getPaddingArgNo(ArgNo)] =
1614 unsigned FirstIRArg, NumIRArgs;
1615 std::tie(FirstIRArg, NumIRArgs) = IRFunctionArgs.getIRArgs(ArgNo);
1620 assert(NumIRArgs == 0);
1624 assert(NumIRArgs == 1);
1627 ArgTypes[FirstIRArg] = LTy->getPointerTo(
1628 CGM.getDataLayout().getAllocaAddrSpace());
1637 llvm::StructType *st = dyn_cast<llvm::StructType>(argType);
1639 assert(NumIRArgs == st->getNumElements());
1640 for (
unsigned i = 0, e = st->getNumElements(); i != e; ++i)
1641 ArgTypes[FirstIRArg + i] = st->getElementType(i);
1643 assert(NumIRArgs == 1);
1644 ArgTypes[FirstIRArg] = argType;
1650 auto ArgTypesIter = ArgTypes.begin() + FirstIRArg;
1652 *ArgTypesIter++ = EltTy;
1654 assert(ArgTypesIter == ArgTypes.begin() + FirstIRArg + NumIRArgs);
1659 auto ArgTypesIter = ArgTypes.begin() + FirstIRArg;
1661 assert(ArgTypesIter == ArgTypes.begin() + FirstIRArg + NumIRArgs);
1666 bool Erased = FunctionsBeingProcessed.erase(&FI); (void)Erased;
1667 assert(Erased &&
"Not in set?");
1669 return llvm::FunctionType::get(resultType, ArgTypes, FI.
isVariadic());
1680 if (isa<CXXDestructorDecl>(MD))
1689 llvm::AttrBuilder &FuncAttrs,
1696 FuncAttrs.addAttribute(llvm::Attribute::NoUnwind);
1699 void CodeGenModule::ConstructDefaultFnAttrList(StringRef Name,
bool HasOptnone,
1700 bool AttrOnCallSite,
1701 llvm::AttrBuilder &FuncAttrs) {
1704 if (CodeGenOpts.OptimizeSize)
1705 FuncAttrs.addAttribute(llvm::Attribute::OptimizeForSize);
1706 if (CodeGenOpts.OptimizeSize == 2)
1707 FuncAttrs.addAttribute(llvm::Attribute::MinSize);
1710 if (CodeGenOpts.DisableRedZone)
1711 FuncAttrs.addAttribute(llvm::Attribute::NoRedZone);
1712 if (CodeGenOpts.NoImplicitFloat)
1713 FuncAttrs.addAttribute(llvm::Attribute::NoImplicitFloat);
1715 if (AttrOnCallSite) {
1717 if (!CodeGenOpts.SimplifyLibCalls ||
1718 CodeGenOpts.isNoBuiltinFunc(Name.data()))
1719 FuncAttrs.addAttribute(llvm::Attribute::NoBuiltin);
1720 if (!CodeGenOpts.TrapFuncName.empty())
1721 FuncAttrs.addAttribute(
"trap-func-name", CodeGenOpts.TrapFuncName);
1724 if (!CodeGenOpts.DisableFPElim) {
1725 FuncAttrs.addAttribute(
"no-frame-pointer-elim",
"false");
1726 }
else if (CodeGenOpts.OmitLeafFramePointer) {
1727 FuncAttrs.addAttribute(
"no-frame-pointer-elim",
"false");
1728 FuncAttrs.addAttribute(
"no-frame-pointer-elim-non-leaf");
1730 FuncAttrs.addAttribute(
"no-frame-pointer-elim",
"true");
1731 FuncAttrs.addAttribute(
"no-frame-pointer-elim-non-leaf");
1734 FuncAttrs.addAttribute(
"less-precise-fpmad",
1735 llvm::toStringRef(CodeGenOpts.LessPreciseFPMAD));
1737 if (CodeGenOpts.NullPointerIsValid)
1738 FuncAttrs.addAttribute(
"null-pointer-is-valid",
"true");
1739 if (!CodeGenOpts.FPDenormalMode.empty())
1740 FuncAttrs.addAttribute(
"denormal-fp-math", CodeGenOpts.FPDenormalMode);
1742 FuncAttrs.addAttribute(
"no-trapping-math",
1743 llvm::toStringRef(CodeGenOpts.NoTrappingMath));
1747 if (!CodeGenOpts.StrictFloatCastOverflow)
1748 FuncAttrs.addAttribute(
"strict-float-cast-overflow",
"false");
1752 FuncAttrs.addAttribute(
"no-infs-fp-math",
1753 llvm::toStringRef(CodeGenOpts.NoInfsFPMath));
1754 FuncAttrs.addAttribute(
"no-nans-fp-math",
1755 llvm::toStringRef(CodeGenOpts.NoNaNsFPMath));
1756 FuncAttrs.addAttribute(
"unsafe-fp-math",
1757 llvm::toStringRef(CodeGenOpts.UnsafeFPMath));
1758 FuncAttrs.addAttribute(
"use-soft-float",
1759 llvm::toStringRef(CodeGenOpts.SoftFloat));
1760 FuncAttrs.addAttribute(
"stack-protector-buffer-size",
1761 llvm::utostr(CodeGenOpts.SSPBufferSize));
1762 FuncAttrs.addAttribute(
"no-signed-zeros-fp-math",
1763 llvm::toStringRef(CodeGenOpts.NoSignedZeros));
1764 FuncAttrs.addAttribute(
1765 "correctly-rounded-divide-sqrt-fp-math",
1766 llvm::toStringRef(CodeGenOpts.CorrectlyRoundedDivSqrt));
1768 if (getLangOpts().OpenCL)
1769 FuncAttrs.addAttribute(
"denorms-are-zero",
1770 llvm::toStringRef(CodeGenOpts.FlushDenorm));
1773 const std::vector<std::string> &Recips = CodeGenOpts.Reciprocals;
1774 if (!Recips.empty())
1775 FuncAttrs.addAttribute(
"reciprocal-estimates",
1776 llvm::join(Recips,
","));
1778 if (!CodeGenOpts.PreferVectorWidth.empty() &&
1779 CodeGenOpts.PreferVectorWidth !=
"none")
1780 FuncAttrs.addAttribute(
"prefer-vector-width",
1781 CodeGenOpts.PreferVectorWidth);
1783 if (CodeGenOpts.StackRealignment)
1784 FuncAttrs.addAttribute(
"stackrealign");
1785 if (CodeGenOpts.Backchain)
1786 FuncAttrs.addAttribute(
"backchain");
1789 if (getLangOpts().assumeFunctionsAreConvergent()) {
1795 FuncAttrs.addAttribute(llvm::Attribute::Convergent);
1798 if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) {
1800 FuncAttrs.addAttribute(llvm::Attribute::NoUnwind);
1803 if (CodeGenOpts.FlushDenorm)
1804 FuncAttrs.addAttribute(
"nvptx-f32ftz",
"true");
1809 llvm::AttrBuilder FuncAttrs;
1810 ConstructDefaultFnAttrList(F.getName(),
1811 F.hasFnAttribute(llvm::Attribute::OptimizeNone),
1813 F.addAttributes(llvm::AttributeList::FunctionIndex, FuncAttrs);
1818 llvm::AttributeList &AttrList,
unsigned &
CallingConv,
bool AttrOnCallSite) {
1819 llvm::AttrBuilder FuncAttrs;
1820 llvm::AttrBuilder RetAttrs;
1824 FuncAttrs.addAttribute(llvm::Attribute::NoReturn);
1833 bool HasOptnone =
false;
1836 if (TargetDecl->hasAttr<ReturnsTwiceAttr>())
1837 FuncAttrs.addAttribute(llvm::Attribute::ReturnsTwice);
1838 if (TargetDecl->hasAttr<NoThrowAttr>())
1839 FuncAttrs.addAttribute(llvm::Attribute::NoUnwind);
1840 if (TargetDecl->hasAttr<NoReturnAttr>())
1841 FuncAttrs.addAttribute(llvm::Attribute::NoReturn);
1842 if (TargetDecl->hasAttr<ColdAttr>())
1843 FuncAttrs.addAttribute(llvm::Attribute::Cold);
1844 if (TargetDecl->hasAttr<NoDuplicateAttr>())
1845 FuncAttrs.addAttribute(llvm::Attribute::NoDuplicate);
1846 if (TargetDecl->hasAttr<ConvergentAttr>())
1847 FuncAttrs.addAttribute(llvm::Attribute::Convergent);
1849 if (
const FunctionDecl *Fn = dyn_cast<FunctionDecl>(TargetDecl)) {
1855 if (Fn->isNoReturn() && !(AttrOnCallSite && MD && MD->
isVirtual()))
1856 FuncAttrs.addAttribute(llvm::Attribute::NoReturn);
1860 if (TargetDecl->hasAttr<ConstAttr>()) {
1861 FuncAttrs.addAttribute(llvm::Attribute::ReadNone);
1862 FuncAttrs.addAttribute(llvm::Attribute::NoUnwind);
1863 }
else if (TargetDecl->hasAttr<PureAttr>()) {
1864 FuncAttrs.addAttribute(llvm::Attribute::ReadOnly);
1865 FuncAttrs.addAttribute(llvm::Attribute::NoUnwind);
1866 }
else if (TargetDecl->hasAttr<NoAliasAttr>()) {
1867 FuncAttrs.addAttribute(llvm::Attribute::ArgMemOnly);
1868 FuncAttrs.addAttribute(llvm::Attribute::NoUnwind);
1870 if (TargetDecl->hasAttr<RestrictAttr>())
1871 RetAttrs.addAttribute(llvm::Attribute::NoAlias);
1872 if (TargetDecl->hasAttr<ReturnsNonNullAttr>() &&
1873 !CodeGenOpts.NullPointerIsValid)
1874 RetAttrs.addAttribute(llvm::Attribute::NonNull);
1875 if (TargetDecl->hasAttr<AnyX86NoCallerSavedRegistersAttr>())
1876 FuncAttrs.addAttribute(
"no_caller_saved_registers");
1877 if (TargetDecl->hasAttr<AnyX86NoCfCheckAttr>())
1878 FuncAttrs.addAttribute(llvm::Attribute::NoCfCheck);
1880 HasOptnone = TargetDecl->
hasAttr<OptimizeNoneAttr>();
1881 if (
auto *AllocSize = TargetDecl->getAttr<AllocSizeAttr>()) {
1883 if (AllocSize->getNumElemsParam().isValid())
1884 NumElemsParam = AllocSize->getNumElemsParam().getLLVMIndex();
1885 FuncAttrs.addAllocSizeAttr(AllocSize->getElemSizeParam().getLLVMIndex(),
1890 ConstructDefaultFnAttrList(Name, HasOptnone, AttrOnCallSite, FuncAttrs);
1892 if (CodeGenOpts.EnableSegmentedStacks &&
1893 !(TargetDecl && TargetDecl->hasAttr<NoSplitStackAttr>()))
1894 FuncAttrs.addAttribute(
"split-stack");
1898 if (TargetDecl && CodeGenOpts.NoPLT) {
1899 if (
auto *Fn = dyn_cast<FunctionDecl>(TargetDecl)) {
1900 if (!Fn->isDefined() && !AttrOnCallSite) {
1901 FuncAttrs.addAttribute(llvm::Attribute::NonLazyBind);
1906 if (TargetDecl && TargetDecl->hasAttr<OpenCLKernelAttr>()) {
1907 if (getLangOpts().OpenCLVersion <= 120) {
1909 FuncAttrs.addAttribute(
"uniform-work-group-size",
"true");
1916 FuncAttrs.addAttribute(
"uniform-work-group-size",
1917 llvm::toStringRef(CodeGenOpts.UniformWGSize));
1921 if (!AttrOnCallSite) {
1922 bool DisableTailCalls =
false;
1924 if (CodeGenOpts.DisableTailCalls)
1925 DisableTailCalls =
true;
1926 else if (TargetDecl) {
1927 if (TargetDecl->hasAttr<DisableTailCallsAttr>() ||
1928 TargetDecl->hasAttr<AnyX86InterruptAttr>())
1929 DisableTailCalls =
true;
1930 else if (CodeGenOpts.NoEscapingBlockTailCalls) {
1931 if (
const auto *BD = dyn_cast<BlockDecl>(TargetDecl))
1932 if (!BD->doesNotEscape())
1933 DisableTailCalls =
true;
1937 FuncAttrs.addAttribute(
"disable-tail-calls",
1938 llvm::toStringRef(DisableTailCalls));
1939 GetCPUAndFeaturesAttributes(TargetDecl, FuncAttrs);
1942 ClangToLLVMArgMapping IRFunctionArgs(
getContext(), FI);
1949 RetAttrs.addAttribute(llvm::Attribute::SExt);
1951 RetAttrs.addAttribute(llvm::Attribute::ZExt);
1955 RetAttrs.addAttribute(llvm::Attribute::InReg);
1963 FuncAttrs.removeAttribute(llvm::Attribute::ReadOnly)
1964 .removeAttribute(llvm::Attribute::ReadNone);
1972 llvm_unreachable(
"Invalid ABI kind for return argument");
1978 RetAttrs.addDereferenceableAttr(
getContext().getTypeSizeInChars(PTy)
1980 else if (
getContext().getTargetAddressSpace(PTy) == 0 &&
1981 !CodeGenOpts.NullPointerIsValid)
1982 RetAttrs.addAttribute(llvm::Attribute::NonNull);
1985 bool hasUsedSRet =
false;
1989 if (IRFunctionArgs.hasSRetArg()) {
1990 llvm::AttrBuilder SRETAttrs;
1992 SRETAttrs.addAttribute(llvm::Attribute::StructRet);
1995 SRETAttrs.addAttribute(llvm::Attribute::InReg);
1996 ArgAttrs[IRFunctionArgs.getSRetArgNo()] =
2001 if (IRFunctionArgs.hasInallocaArg()) {
2002 llvm::AttrBuilder Attrs;
2003 Attrs.addAttribute(llvm::Attribute::InAlloca);
2004 ArgAttrs[IRFunctionArgs.getInallocaArgNo()] =
2011 I != E; ++I, ++ArgNo) {
2014 llvm::AttrBuilder Attrs;
2017 if (IRFunctionArgs.hasPaddingArg(ArgNo)) {
2019 ArgAttrs[IRFunctionArgs.getPaddingArgNo(ArgNo)] =
2020 llvm::AttributeSet::get(
2022 llvm::AttrBuilder().addAttribute(llvm::Attribute::InReg));
2032 Attrs.addAttribute(llvm::Attribute::SExt);
2034 Attrs.addAttribute(llvm::Attribute::ZExt);
2038 Attrs.addAttribute(llvm::Attribute::Nest);
2040 Attrs.addAttribute(llvm::Attribute::InReg);
2045 Attrs.addAttribute(llvm::Attribute::InReg);
2048 Attrs.addAttribute(llvm::Attribute::ByVal);
2070 FuncAttrs.removeAttribute(llvm::Attribute::ReadOnly)
2071 .removeAttribute(llvm::Attribute::ReadNone);
2081 FuncAttrs.removeAttribute(llvm::Attribute::ReadOnly)
2082 .removeAttribute(llvm::Attribute::ReadNone);
2089 Attrs.addDereferenceableAttr(
getContext().getTypeSizeInChars(PTy)
2091 else if (
getContext().getTargetAddressSpace(PTy) == 0 &&
2092 !CodeGenOpts.NullPointerIsValid)
2093 Attrs.addAttribute(llvm::Attribute::NonNull);
2104 Attrs.addAttribute(llvm::Attribute::StructRet);
2109 Attrs.addAttribute(llvm::Attribute::NoAlias);
2113 if (!PTy->isIncompleteType() && PTy->isConstantSizeType()) {
2115 Attrs.addDereferenceableAttr(info.first.getQuantity());
2116 Attrs.addAttribute(llvm::Attribute::getWithAlignment(
getLLVMContext(),
2117 info.second.getQuantity()));
2123 Attrs.addAttribute(llvm::Attribute::SwiftError);
2127 Attrs.addAttribute(llvm::Attribute::SwiftSelf);
2132 Attrs.addAttribute(llvm::Attribute::NoCapture);
2134 if (Attrs.hasAttributes()) {
2135 unsigned FirstIRArg, NumIRArgs;
2136 std::tie(FirstIRArg, NumIRArgs) = IRFunctionArgs.getIRArgs(ArgNo);
2137 for (
unsigned i = 0; i < NumIRArgs; i++)
2138 ArgAttrs[FirstIRArg + i] =
2144 AttrList = llvm::AttributeList::get(
2158 if (value->getType() == varType)
return value;
2160 assert((varType->isIntegerTy() || varType->isFloatingPointTy())
2161 &&
"unexpected promotion type");
2163 if (isa<llvm::IntegerType>(varType))
2164 return CGF.
Builder.CreateTrunc(value, varType,
"arg.unpromote");
2166 return CGF.
Builder.CreateFPCast(value, varType,
"arg.unpromote");
2172 QualType ArgType,
unsigned ArgNo) {
2184 if (
auto ParmNNAttr = PVD->
getAttr<NonNullAttr>())
2191 if (NNAttr->isNonNull(ArgNo))
2201 CopyBackSwiftError(
Address temp,
Address arg) : Temp(temp), Arg(arg) {}
2212 if (CurCodeDecl && CurCodeDecl->hasAttr<NakedAttr>())
2220 if (
const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(CurCodeDecl)) {
2221 if (FD->hasImplicitReturnZero()) {
2222 QualType RetTy = FD->getReturnType().getUnqualifiedType();
2223 llvm::Type* LLVMTy = CGM.getTypes().ConvertType(RetTy);
2224 llvm::Constant* Zero = llvm::Constant::getNullValue(LLVMTy);
2225 Builder.CreateStore(Zero, ReturnValue);
2232 ClangToLLVMArgMapping IRFunctionArgs(CGM.getContext(), FI);
2235 FnArgs.reserve(IRFunctionArgs.totalIRArgs());
2236 for (
auto &Arg : Fn->args()) {
2237 FnArgs.push_back(&Arg);
2239 assert(FnArgs.size() == IRFunctionArgs.totalIRArgs());
2244 const llvm::StructLayout *ArgStructLayout =
nullptr;
2245 if (IRFunctionArgs.hasInallocaArg()) {
2246 ArgStructLayout = CGM.getDataLayout().getStructLayout(FI.
getArgStruct());
2247 ArgStruct =
Address(FnArgs[IRFunctionArgs.getInallocaArgNo()],
2250 assert(ArgStruct.getType() == FI.
getArgStruct()->getPointerTo());
2254 if (IRFunctionArgs.hasSRetArg()) {
2255 auto AI = cast<llvm::Argument>(FnArgs[IRFunctionArgs.getSRetArgNo()]);
2256 AI->setName(
"agg.result");
2257 AI->addAttr(llvm::Attribute::NoAlias);
2264 ArgVals.reserve(Args.size());
2270 assert(FI.
arg_size() == Args.size() &&
2271 "Mismatch between function signature & arguments.");
2274 for (FunctionArgList::const_iterator i = Args.begin(), e = Args.end();
2275 i != e; ++i, ++info_it, ++ArgNo) {
2280 isa<ParmVarDecl>(Arg) && cast<ParmVarDecl>(Arg)->isKNRPromoted();
2285 assert(hasScalarEvaluationKind(Ty) ==
2286 hasScalarEvaluationKind(Arg->
getType()));
2288 unsigned FirstIRArg, NumIRArgs;
2289 std::tie(FirstIRArg, NumIRArgs) = IRFunctionArgs.getIRArgs(ArgNo);
2293 assert(NumIRArgs == 0);
2297 Address V = Builder.CreateStructGEP(ArgStruct, FieldIndex, FieldOffset,
2299 ArgVals.push_back(ParamValue::forIndirect(V));
2304 assert(NumIRArgs == 1);
2307 if (!hasScalarEvaluationKind(Ty)) {
2312 Address AlignedTemp = CreateMemTemp(Ty,
"coerce");
2320 auto SizeVal = llvm::ConstantInt::get(IntPtrTy, Size.
getQuantity());
2321 Address Dst = Builder.CreateBitCast(AlignedTemp, Int8PtrTy);
2322 Address Src = Builder.CreateBitCast(ParamAddr, Int8PtrTy);
2323 Builder.CreateMemCpy(Dst, Src, SizeVal,
false);
2326 ArgVals.push_back(ParamValue::forIndirect(V));
2330 EmitLoadOfScalar(ParamAddr,
false, Ty, Arg->
getLocStart());
2334 ArgVals.push_back(ParamValue::forDirect(V));
2346 assert(NumIRArgs == 1);
2348 auto AI = cast<llvm::Argument>(V);
2350 if (
const ParmVarDecl *PVD = dyn_cast<ParmVarDecl>(Arg)) {
2352 PVD->getFunctionScopeIndex()) &&
2353 !CGM.getCodeGenOpts().NullPointerIsValid)
2354 AI->addAttr(llvm::Attribute::NonNull);
2356 QualType OTy = PVD->getOriginalType();
2357 if (
const auto *ArrTy =
2364 QualType ETy = ArrTy->getElementType();
2365 uint64_t ArrSize = ArrTy->getSize().getZExtValue();
2368 llvm::AttrBuilder Attrs;
2369 Attrs.addDereferenceableAttr(
2370 getContext().getTypeSizeInChars(ETy).getQuantity()*ArrSize);
2371 AI->addAttrs(Attrs);
2372 }
else if (
getContext().getTargetAddressSpace(ETy) == 0 &&
2373 !CGM.getCodeGenOpts().NullPointerIsValid) {
2374 AI->addAttr(llvm::Attribute::NonNull);
2377 }
else if (
const auto *ArrTy =
2384 !CGM.getCodeGenOpts().NullPointerIsValid)
2385 AI->addAttr(llvm::Attribute::NonNull);
2388 const auto *AVAttr = PVD->getAttr<AlignValueAttr>();
2390 if (
const auto *TOTy = dyn_cast<TypedefType>(OTy))
2391 AVAttr = TOTy->getDecl()->getAttr<AlignValueAttr>();
2394 EmitScalarExpr(AVAttr->getAlignment());
2395 llvm::ConstantInt *AlignmentCI =
2396 cast<llvm::ConstantInt>(AlignmentValue);
2397 unsigned Alignment =
std::min((
unsigned)AlignmentCI->getZExtValue(),
2398 +llvm::Value::MaximumAlignment);
2399 AI->addAttrs(llvm::AttrBuilder().addAlignmentAttr(Alignment));
2404 AI->addAttr(llvm::Attribute::NoAlias);
2413 CreateMemTemp(pointeeTy, getPointerAlign(),
"swifterror.temp");
2415 llvm::Value *incomingErrorValue = Builder.CreateLoad(arg);
2416 Builder.CreateStore(incomingErrorValue, temp);
2417 V = temp.getPointer();
2422 EHStack.pushCleanup<CopyBackSwiftError>(
NormalCleanup, temp, arg);
2437 if (V->getType() != LTy)
2438 V = Builder.CreateBitCast(V, LTy);
2440 ArgVals.push_back(ParamValue::forDirect(V));
2452 llvm::StructType *STy = dyn_cast<llvm::StructType>(ArgI.
getCoerceToType());
2454 STy->getNumElements() > 1) {
2455 auto SrcLayout = CGM.getDataLayout().getStructLayout(STy);
2456 uint64_t SrcSize = CGM.getDataLayout().getTypeAllocSize(STy);
2458 uint64_t DstSize = CGM.getDataLayout().getTypeAllocSize(DstTy);
2461 if (SrcSize <= DstSize) {
2462 AddrToStoreInto = Builder.CreateElementBitCast(Ptr, STy);
2465 CreateTempAlloca(STy, Alloca.
getAlignment(),
"coerce");
2468 assert(STy->getNumElements() == NumIRArgs);
2469 for (
unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
2470 auto AI = FnArgs[FirstIRArg + i];
2471 AI->setName(Arg->
getName() +
".coerce" + Twine(i));
2474 Builder.CreateStructGEP(AddrToStoreInto, i,
Offset);
2475 Builder.CreateStore(AI, EltPtr);
2478 if (SrcSize > DstSize) {
2479 Builder.CreateMemCpy(Ptr, AddrToStoreInto, DstSize);
2484 assert(NumIRArgs == 1);
2485 auto AI = FnArgs[FirstIRArg];
2486 AI->setName(Arg->
getName() +
".coerce");
2493 EmitLoadOfScalar(Alloca,
false, Ty, Arg->
getLocStart());
2496 ArgVals.push_back(ParamValue::forDirect(V));
2498 ArgVals.push_back(ParamValue::forIndirect(Alloca));
2506 ArgVals.push_back(ParamValue::forIndirect(alloca));
2509 alloca = Builder.CreateElementBitCast(alloca, coercionType);
2510 auto layout = CGM.getDataLayout().getStructLayout(coercionType);
2512 unsigned argIndex = FirstIRArg;
2513 for (
unsigned i = 0, e = coercionType->getNumElements(); i != e; ++i) {
2514 llvm::Type *eltType = coercionType->getElementType(i);
2518 auto eltAddr = Builder.CreateStructGEP(alloca, i, layout);
2519 auto elt = FnArgs[argIndex++];
2520 Builder.CreateStore(elt, eltAddr);
2522 assert(argIndex == FirstIRArg + NumIRArgs);
2531 LValue LV = MakeAddrLValue(Alloca, Ty);
2532 ArgVals.push_back(ParamValue::forIndirect(Alloca));
2534 auto FnArgIter = FnArgs.begin() + FirstIRArg;
2535 ExpandTypeFromArgs(Ty, LV, FnArgIter);
2536 assert(FnArgIter == FnArgs.begin() + FirstIRArg + NumIRArgs);
2537 for (
unsigned i = 0, e = NumIRArgs; i != e; ++i) {
2538 auto AI = FnArgs[FirstIRArg + i];
2539 AI->setName(Arg->
getName() +
"." + Twine(i));
2545 assert(NumIRArgs == 0);
2547 if (!hasScalarEvaluationKind(Ty)) {
2548 ArgVals.push_back(ParamValue::forIndirect(CreateMemTemp(Ty)));
2551 ArgVals.push_back(ParamValue::forDirect(U));
2558 for (
int I = Args.size() - 1; I >= 0; --I)
2559 EmitParmDecl(*Args[I], ArgVals[I], I + 1);
2561 for (
unsigned I = 0, E = Args.size(); I != E; ++I)
2562 EmitParmDecl(*Args[I], ArgVals[I], I + 1);
2567 while (insn->use_empty()) {
2568 llvm::BitCastInst *bitcast = dyn_cast<llvm::BitCastInst>(insn);
2569 if (!bitcast)
return;
2572 insn = cast<llvm::Instruction>(bitcast->getOperand(0));
2573 bitcast->eraseFromParent();
2581 llvm::BasicBlock *BB = CGF.
Builder.GetInsertBlock();
2582 if (BB->empty())
return nullptr;
2583 if (&BB->back() != result)
return nullptr;
2588 llvm::Instruction *generator = cast<llvm::Instruction>(result);
2590 SmallVector<llvm::Instruction *, 4> InstsToKill;
2594 while (llvm::BitCastInst *bitcast = dyn_cast<llvm::BitCastInst>(generator)) {
2597 generator = cast<llvm::Instruction>(bitcast->getOperand(0));
2600 if (generator->getNextNode() != bitcast)
2603 InstsToKill.push_back(bitcast);
2610 llvm::CallInst *call = dyn_cast<llvm::CallInst>(generator);
2611 if (!call)
return nullptr;
2613 bool doRetainAutorelease;
2616 doRetainAutorelease =
true;
2619 doRetainAutorelease =
false;
2627 llvm::Instruction *prev = call->getPrevNode();
2629 if (isa<llvm::BitCastInst>(prev)) {
2630 prev = prev->getPrevNode();
2633 assert(isa<llvm::CallInst>(prev));
2634 assert(cast<llvm::CallInst>(prev)->getCalledValue() ==
2636 InstsToKill.push_back(prev);
2642 result = call->getArgOperand(0);
2643 InstsToKill.push_back(call);
2647 while (llvm::BitCastInst *bitcast = dyn_cast<llvm::BitCastInst>(result)) {
2648 if (!bitcast->hasOneUse())
break;
2649 InstsToKill.push_back(bitcast);
2650 result = bitcast->getOperand(0);
2654 for (
auto *I : InstsToKill)
2655 I->eraseFromParent();
2658 if (doRetainAutorelease)
2670 dyn_cast_or_null<ObjCMethodDecl>(CGF.
CurCodeDecl);
2671 if (!method)
return nullptr;
2673 if (!self->getType().isConstQualified())
return nullptr;
2676 llvm::CallInst *retainCall =
2677 dyn_cast<llvm::CallInst>(result->stripPointerCasts());
2683 llvm::Value *retainedValue = retainCall->getArgOperand(0);
2684 llvm::LoadInst *load =
2685 dyn_cast<llvm::LoadInst>(retainedValue->stripPointerCasts());
2686 if (!load || load->isAtomic() || load->isVolatile() ||
2695 assert(retainCall->use_empty());
2696 retainCall->eraseFromParent();
2727 auto GetStoreIfValid = [&CGF](llvm::User *U) -> llvm::StoreInst * {
2728 auto *SI = dyn_cast<llvm::StoreInst>(U);
2733 assert(!SI->isAtomic() && !SI->isVolatile());
2741 llvm::BasicBlock *IP = CGF.
Builder.GetInsertBlock();
2742 if (IP->empty())
return nullptr;
2743 llvm::Instruction *I = &IP->back();
2746 for (llvm::BasicBlock::reverse_iterator II = IP->rbegin(),
2749 if (llvm::IntrinsicInst *Intrinsic =
2750 dyn_cast<llvm::IntrinsicInst>(&*II)) {
2751 if (Intrinsic->getIntrinsicID() == llvm::Intrinsic::lifetime_end) {
2752 const llvm::Value *CastAddr = Intrinsic->getArgOperand(1);
2756 if (isa<llvm::BitCastInst>(&*II) && (CastAddr == &*II))
2764 return GetStoreIfValid(I);
2767 llvm::StoreInst *store =
2769 if (!store)
return nullptr;
2773 llvm::BasicBlock *StoreBB = store->getParent();
2774 llvm::BasicBlock *IP = CGF.
Builder.GetInsertBlock();
2775 while (IP != StoreBB) {
2776 if (!(IP = IP->getSinglePredecessor()))
2790 EmitUnreachable(EndLoc);
2794 if (CurCodeDecl && CurCodeDecl->hasAttr<NakedAttr>()) {
2796 Builder.CreateUnreachable();
2801 if (!ReturnValue.isValid()) {
2802 Builder.CreateRetVoid();
2806 llvm::DebugLoc RetDbgLoc;
2815 assert(hasAggregateEvaluationKind(RetTy));
2817 llvm::Function::arg_iterator EI = CurFn->arg_end();
2822 RV = Builder.CreateAlignedLoad(SRet, getPointerAlign(),
"sret");
2827 auto AI = CurFn->arg_begin();
2830 switch (getEvaluationKind(RetTy)) {
2833 EmitLoadOfComplex(MakeAddrLValue(ReturnValue, RetTy), EndLoc);
2834 EmitStoreOfComplex(RT, MakeNaturalAlignAddrLValue(&*AI, RetTy),
2842 EmitStoreOfScalar(Builder.CreateLoad(ReturnValue),
2843 MakeNaturalAlignAddrLValue(&*AI, RetTy),
2859 if (llvm::StoreInst *SI =
2864 if (EmitRetDbgLoc && !AutoreleaseResult)
2865 RetDbgLoc = SI->getDebugLoc();
2867 RV = SI->getValueOperand();
2868 SI->eraseFromParent();
2871 auto returnValueInst = ReturnValue.getPointer();
2872 if (returnValueInst->use_empty()) {
2873 if (
auto alloca = dyn_cast<llvm::AllocaInst>(returnValueInst)) {
2874 alloca->eraseFromParent();
2881 RV = Builder.CreateLoad(ReturnValue);
2892 if (AutoreleaseResult) {
2900 if (
auto *FD = dyn_cast<FunctionDecl>(CurCodeDecl))
2901 RT = FD->getReturnType();
2902 else if (
auto *MD = dyn_cast<ObjCMethodDecl>(CurCodeDecl))
2903 RT = MD->getReturnType();
2904 else if (isa<BlockDecl>(CurCodeDecl))
2905 RT = BlockInfo->BlockExpression->getFunctionType()->getReturnType();
2907 llvm_unreachable(
"Unexpected function/method type");
2909 assert(getLangOpts().ObjCAutoRefCount &&
2923 auto layout = CGM.getDataLayout().getStructLayout(coercionType);
2927 Address addr = Builder.CreateElementBitCast(ReturnValue, coercionType);
2928 for (
unsigned i = 0, e = coercionType->getNumElements(); i != e; ++i) {
2929 auto coercedEltType = coercionType->getElementType(i);
2933 auto eltAddr = Builder.CreateStructGEP(addr, i, layout);
2934 auto elt = Builder.CreateLoad(eltAddr);
2935 results.push_back(elt);
2939 if (results.size() == 1) {
2947 RV = llvm::UndefValue::get(returnType);
2948 for (
unsigned i = 0, e = results.size(); i != e; ++i) {
2949 RV = Builder.CreateInsertValue(RV, results[i], i);
2956 llvm_unreachable(
"Invalid ABI kind for return argument");
2959 llvm::Instruction *Ret;
2961 EmitReturnValueCheck(RV);
2962 Ret = Builder.CreateRet(RV);
2964 Ret = Builder.CreateRetVoid();
2968 Ret->setDebugLoc(std::move(RetDbgLoc));
2976 ReturnsNonNullAttr *RetNNAttr =
nullptr;
2977 if (SanOpts.has(SanitizerKind::ReturnsNonnullAttribute))
2978 RetNNAttr = CurCodeDecl->getAttr<ReturnsNonNullAttr>();
2980 if (!RetNNAttr && !requiresReturnValueNullabilityCheck())
2988 assert(!requiresReturnValueNullabilityCheck() &&
2989 "Cannot check nullability and the nonnull attribute");
2990 AttrLoc = RetNNAttr->getLocation();
2991 CheckKind = SanitizerKind::ReturnsNonnullAttribute;
2992 Handler = SanitizerHandler::NonnullReturn;
2994 if (
auto *DD = dyn_cast<DeclaratorDecl>(CurCodeDecl))
2995 if (
auto *TSI = DD->getTypeSourceInfo())
2997 AttrLoc = FTL.getReturnLoc().findNullabilityLoc();
2998 CheckKind = SanitizerKind::NullabilityReturn;
2999 Handler = SanitizerHandler::NullabilityReturn;
3006 llvm::BasicBlock *Check = createBasicBlock(
"nullcheck");
3007 llvm::BasicBlock *NoCheck = createBasicBlock(
"no.nullcheck");
3008 llvm::Value *SLocPtr = Builder.CreateLoad(ReturnLocation,
"return.sloc.load");
3009 llvm::Value *CanNullCheck = Builder.CreateIsNotNull(SLocPtr);
3010 if (requiresReturnValueNullabilityCheck())
3012 Builder.CreateAnd(CanNullCheck, RetValNullabilityPrecondition);
3013 Builder.CreateCondBr(CanNullCheck, Check, NoCheck);
3018 llvm::Constant *StaticData[] = {EmitCheckSourceLocation(AttrLoc)};
3020 EmitCheck(std::make_pair(Cond, CheckKind), Handler, StaticData, DynamicData);
3041 llvm::Value *Placeholder = llvm::UndefValue::get(IRPtrTy->getPointerTo());
3062 Address local = GetAddrOfLocalVar(param);
3067 "cannot emit delegate call arguments for inalloca arguments!");
3079 }
else if (getLangOpts().ObjCAutoRefCount &&
3080 param->
hasAttr<NSConsumedAttr>() &&
3084 llvm::ConstantPointerNull::get(cast<llvm::PointerType>(ptr->getType()));
3085 Builder.CreateStore(null, local);
3091 args.
add(convertTempToRValue(local, type, loc), type);
3095 if (hasAggregateEvaluationKind(type) && !CurFuncIsThunk &&
3099 CalleeDestructedParamCleanups.lookup(cast<ParmVarDecl>(param));
3101 "cleanup for callee-destructed param not recorded");
3103 llvm::Instruction *isActive = Builder.CreateUnreachable();
3109 return isa<llvm::ConstantPointerNull>(addr);
3118 "shouldn't have writeback for provably null argument");
3120 llvm::BasicBlock *contBB =
nullptr;
3124 bool provablyNonNull = llvm::isKnownNonZero(srcAddr.
getPointer(),
3126 if (!provablyNonNull) {
3132 CGF.
Builder.CreateCondBr(isNull, contBB, writebackBB);
3141 "icr.writeback-cast");
3150 if (writeback.
ToUse) {
3175 if (!provablyNonNull)
3190 for (
const auto &I : llvm::reverse(Cleanups)) {
3192 I.IsActiveIP->eraseFromParent();
3198 if (uop->getOpcode() == UO_AddrOf)
3199 return uop->getSubExpr();
3229 llvm::PointerType *destType =
3253 llvm::ConstantPointerNull::get(
3254 cast<llvm::PointerType>(destType->getElementType()));
3258 llvm::BasicBlock *contBB =
nullptr;
3259 llvm::BasicBlock *originBB =
nullptr;
3264 bool provablyNonNull = llvm::isKnownNonZero(srcAddr.
getPointer(),
3266 if (provablyNonNull) {
3272 finalArgument = CGF.
Builder.CreateSelect(isNull,
3273 llvm::ConstantPointerNull::get(destType),
3279 originBB = CGF.
Builder.GetInsertBlock();
3282 CGF.
Builder.CreateCondBr(isNull, contBB, copyBB);
3284 condEval.
begin(CGF);
3314 if (shouldCopy && !provablyNonNull) {
3315 llvm::BasicBlock *copyBB = CGF.
Builder.GetInsertBlock();
3320 llvm::PHINode *phiToUse = CGF.
Builder.CreatePHI(valueToUse->getType(), 2,
3322 phiToUse->addIncoming(valueToUse, copyBB);
3323 phiToUse->addIncoming(llvm::UndefValue::get(valueToUse->getType()),
3325 valueToUse = phiToUse;
3340 StackBase = CGF.
Builder.CreateCall(F, {},
"inalloca.save");
3347 CGF.
Builder.CreateCall(F, StackBase);
3355 if (!AC.
getDecl() || !(SanOpts.has(SanitizerKind::NonnullAttribute) ||
3356 SanOpts.has(SanitizerKind::NullabilityArg)))
3364 const NonNullAttr *NNAttr =
nullptr;
3365 if (SanOpts.has(SanitizerKind::NonnullAttribute))
3368 bool CanCheckNullability =
false;
3369 if (SanOpts.has(SanitizerKind::NullabilityArg) && !NNAttr && PVD) {
3373 PVD->getTypeSourceInfo();
3376 if (!NNAttr && !CanCheckNullability)
3383 AttrLoc = NNAttr->getLocation();
3384 CheckKind = SanitizerKind::NonnullAttribute;
3385 Handler = SanitizerHandler::NonnullArg;
3387 AttrLoc = PVD->getTypeSourceInfo()->getTypeLoc().findNullabilityLoc();
3388 CheckKind = SanitizerKind::NullabilityArg;
3389 Handler = SanitizerHandler::NullabilityArg;
3396 Builder.CreateICmpNE(V, llvm::Constant::getNullValue(V->getType()));
3397 llvm::Constant *StaticData[] = {
3398 EmitCheckSourceLocation(ArgLoc), EmitCheckSourceLocation(AttrLoc),
3399 llvm::ConstantInt::get(Int32Ty, ArgNo + 1),
3401 EmitCheck(std::make_pair(Cond, CheckKind), Handler, StaticData, None);
3406 llvm::iterator_range<CallExpr::const_arg_iterator> ArgRange,
3408 assert((
int)ArgTypes.size() == (ArgRange.end() - ArgRange.begin()));
3416 CGM.getTarget().getCXXABI().areArgsDestroyedLeftToRightInCallee()
3417 ? Order == EvaluationOrder::ForceLeftToRight
3418 : Order != EvaluationOrder::ForceRightToLeft;
3420 auto MaybeEmitImplicitObjectSize = [&](
unsigned I,
const Expr *Arg,
3430 auto T = Builder.getIntNTy(Context.
getTypeSize(SizeTy));
3431 assert(EmittedArg.getScalarVal() &&
"We emitted nothing for the arg?");
3432 llvm::Value *V = evaluateOrEmitBuiltinObjectSize(Arg, PS->getType(), T,
3433 EmittedArg.getScalarVal());
3438 std::swap(Args.back(), *(&Args.back() - 1));
3442 bool HasInAllocaArgs =
false;
3443 if (CGM.getTarget().getCXXABI().isMicrosoft()) {
3445 I != E && !HasInAllocaArgs; ++I)
3447 if (HasInAllocaArgs) {
3448 assert(
getTarget().getTriple().getArch() == llvm::Triple::x86);
3454 size_t CallArgsStart = Args.size();
3455 for (
unsigned I = 0, E = ArgTypes.size(); I != E; ++I) {
3456 unsigned Idx = LeftToRight ? I : E - I - 1;
3458 unsigned InitialArgSize = Args.size();
3461 assert((!isa<ObjCIndirectCopyRestoreExpr>(*Arg) ||
3462 getContext().hasSameUnqualifiedType((*Arg)->getType(),
3464 (isa<ObjCMethodDecl>(AC.
getDecl()) &&
3465 isObjCMethodWithTypeParams(cast<ObjCMethodDecl>(AC.
getDecl())))) &&
3466 "Argument and parameter types don't match");
3467 EmitCallArg(Args, *Arg, ArgTypes[Idx]);
3470 assert(InitialArgSize + 1 == Args.size() &&
3471 "The code below depends on only adding one arg per EmitCallArg");
3472 (void)InitialArgSize;
3475 if (!Args.back().hasLValue()) {
3476 RValue RVArg = Args.back().getKnownRValue();
3477 EmitNonNullArgCheck(RVArg, ArgTypes[Idx], (*Arg)->getExprLoc(), AC,
3478 ParamsToSkip + Idx);
3482 MaybeEmitImplicitObjectSize(Idx, *Arg, RVArg);
3489 std::reverse(Args.begin() + CallArgsStart, Args.end());
3497 : Addr(Addr), Ty(Ty) {}
3515 struct DisableDebugLocationUpdates {
3517 bool disabledDebugInfo;
3519 if ((disabledDebugInfo = isa<CXXDefaultArgExpr>(E) && CGF.
getDebugInfo()))
3522 ~DisableDebugLocationUpdates() {
3523 if (disabledDebugInfo)
3542 if (!HasLV && RV.isScalar())
3544 else if (!HasLV && RV.isComplex())
3547 auto Addr = HasLV ? LV.
getAddress() : RV.getAggregateAddress();
3552 : RV.isVolatileQualified());
3559 DisableDebugLocationUpdates Dis(*
this, E);
3561 = dyn_cast<ObjCIndirectCopyRestoreExpr>(E)) {
3562 assert(getLangOpts().ObjCAutoRefCount);
3567 "reference binding to unmaterialized r-value!");
3571 return args.
add(EmitReferenceBindingToExpr(E), type);
3574 bool HasAggregateEvalKind = hasAggregateEvaluationKind(type);
3579 if (HasAggregateEvalKind &&
3587 Slot = CreateAggTemp(type,
"agg.tmp");
3589 bool DestroyedInCallee =
true, NeedsEHCleanup =
true;
3591 DestroyedInCallee = RD->hasNonTrivialDestructor();
3595 if (DestroyedInCallee)
3598 EmitAggExpr(E, Slot);
3602 if (DestroyedInCallee && NeedsEHCleanup) {
3609 llvm::Instruction *IsActive = Builder.CreateUnreachable();
3615 if (HasAggregateEvalKind && isa<ImplicitCastExpr>(E) &&
3616 cast<CastExpr>(E)->getCastKind() == CK_LValueToRValue) {
3617 LValue L = EmitLValue(cast<CastExpr>(E)->getSubExpr());
3623 args.
add(EmitAnyExprToTemp(E), type);
3626 QualType CodeGenFunction::getVarArgType(
const Expr *Arg) {
3630 if (!
getTarget().getTriple().isOSWindows())
3647 CodeGenFunction::AddObjCARCExceptionMetadata(llvm::Instruction *Inst) {
3648 if (CGM.getCodeGenOpts().OptimizationLevel != 0 &&
3649 !CGM.getCodeGenOpts().ObjCAutoRefCountExceptions)
3650 Inst->setMetadata(
"clang.arc.no_objc_arc_exceptions",
3651 CGM.getNoObjCARCExceptionsMetadata());
3657 const llvm::Twine &name) {
3658 return EmitNounwindRuntimeCall(callee, None, name);
3665 const llvm::Twine &name) {
3666 llvm::CallInst *call = EmitRuntimeCall(callee, args, name);
3667 call->setDoesNotThrow();
3675 const llvm::Twine &name) {
3676 return EmitRuntimeCall(callee, None, name);
3686 if (!CurrentFuncletPad)
3690 auto *CalleeFn = dyn_cast<llvm::Function>(Callee->stripPointerCasts());
3691 if (CalleeFn && CalleeFn->isIntrinsic() && CalleeFn->doesNotThrow())
3694 BundleList.emplace_back(
"funclet", CurrentFuncletPad);
3702 const llvm::Twine &name) {
3703 llvm::CallInst *call =
3704 Builder.CreateCall(callee, args, getBundlesForFunclet(callee), name);
3705 call->setCallingConv(getRuntimeCC());
3713 getBundlesForFunclet(callee);
3715 if (getInvokeDest()) {
3716 llvm::InvokeInst *invoke =
3717 Builder.CreateInvoke(callee,
3718 getUnreachableBlock(),
3722 invoke->setDoesNotReturn();
3723 invoke->setCallingConv(getRuntimeCC());
3725 llvm::CallInst *call = Builder.CreateCall(callee, args, BundleList);
3726 call->setDoesNotReturn();
3727 call->setCallingConv(getRuntimeCC());
3728 Builder.CreateUnreachable();
3735 const Twine &name) {
3736 return EmitRuntimeCallOrInvoke(callee, None, name);
3743 const Twine &name) {
3744 llvm::CallSite callSite = EmitCallOrInvoke(callee, args, name);
3745 callSite.setCallingConv(getRuntimeCC());
3754 const Twine &Name) {
3755 llvm::BasicBlock *InvokeDest = getInvokeDest();
3757 getBundlesForFunclet(Callee);
3759 llvm::Instruction *Inst;
3761 Inst = Builder.CreateCall(Callee, Args, BundleList, Name);
3763 llvm::BasicBlock *ContBB = createBasicBlock(
"invoke.cont");
3764 Inst = Builder.CreateInvoke(Callee, ContBB, InvokeDest, Args, BundleList,
3771 if (CGM.getLangOpts().ObjCAutoRefCount)
3772 AddObjCARCExceptionMetadata(Inst);
3774 return llvm::CallSite(Inst);
3777 void CodeGenFunction::deferPlaceholderReplacement(llvm::Instruction *Old,
3779 DeferredReplacements.push_back(std::make_pair(Old, New));
3786 llvm::Instruction **callOrInvoke,
3804 const llvm::StructLayout *ArgMemoryLayout =
nullptr;
3805 if (llvm::StructType *ArgStruct = CallInfo.
getArgStruct()) {
3806 const llvm::DataLayout &DL = CGM.getDataLayout();
3807 ArgMemoryLayout = DL.getStructLayout(ArgStruct);
3809 llvm::AllocaInst *AI;
3811 IP = IP->getNextNode();
3812 AI =
new llvm::AllocaInst(ArgStruct, DL.getAllocaAddrSpace(),
3815 AI = CreateTempAlloca(ArgStruct,
"argmem");
3818 AI->setAlignment(Align.getQuantity());
3819 AI->setUsedWithInAlloca(
true);
3820 assert(AI->isUsedWithInAlloca() && !AI->isStaticAlloca());
3821 ArgMemory =
Address(AI, Align);
3825 auto createInAllocaStructGEP = [&](
unsigned FieldIndex) ->
Address {
3828 return Builder.CreateStructGEP(ArgMemory, FieldIndex, FieldOffset);
3831 ClangToLLVMArgMapping IRFunctionArgs(CGM.getContext(), CallInfo);
3840 if (!ReturnValue.
isNull()) {
3843 SRetPtr = CreateMemTemp(RetTy,
"tmp", &SRetAlloca);
3844 if (HaveInsertPoint() && ReturnValue.
isUnused()) {
3847 UnusedReturnSizePtr = EmitLifetimeStart(size, SRetAlloca.
getPointer());
3850 if (IRFunctionArgs.hasSRetArg()) {
3851 IRCallArgs[IRFunctionArgs.getSRetArgNo()] = SRetPtr.getPointer();
3854 Builder.CreateStore(SRetPtr.getPointer(), Addr);
3862 assert(CallInfo.
arg_size() == CallArgs.size() &&
3863 "Mismatch between function signature & arguments.");
3866 for (CallArgList::const_iterator I = CallArgs.begin(), E = CallArgs.end();
3867 I != E; ++I, ++info_it, ++ArgNo) {
3871 if (IRFunctionArgs.hasPaddingArg(ArgNo))
3872 IRCallArgs[IRFunctionArgs.getPaddingArgNo(ArgNo)] =
3875 unsigned FirstIRArg, NumIRArgs;
3876 std::tie(FirstIRArg, NumIRArgs) = IRFunctionArgs.getIRArgs(ArgNo);
3880 assert(NumIRArgs == 0);
3881 assert(
getTarget().getTriple().getArch() == llvm::Triple::x86);
3882 if (I->isAggregate()) {
3885 ? I->getKnownLValue().getAddress()
3886 : I->getKnownRValue().getAggregateAddress();
3887 llvm::Instruction *Placeholder =
3889 CGBuilderTy::InsertPoint IP = Builder.saveIP();
3890 Builder.SetInsertPoint(Placeholder);
3892 Builder.restoreIP(IP);
3893 deferPlaceholderReplacement(Placeholder, Addr.
getPointer());
3897 unsigned AS = Addr.
getType()->getPointerAddressSpace();
3902 if (Addr.
getType() != MemType)
3903 Addr = Builder.CreateBitCast(Addr, MemType);
3904 I->copyInto(*
this, Addr);
3910 assert(NumIRArgs == 1);
3911 if (!I->isAggregate()) {
3913 Address Addr = CreateMemTempWithoutCast(
3917 I->copyInto(*
this, Addr);
3928 ? I->getKnownLValue().getAddress()
3929 : I->getKnownRValue().getAggregateAddress();
3932 const llvm::DataLayout *TD = &CGM.getDataLayout();
3934 assert((FirstIRArg >= IRFuncTy->getNumParams() ||
3935 IRFuncTy->getParamType(FirstIRArg)->getPointerAddressSpace() ==
3936 TD->getAllocaAddrSpace()) &&
3937 "indirect argument must be in alloca address space");
3939 bool NeedCopy =
false;
3942 llvm::getOrEnforceKnownAlignment(V, Align.
getQuantity(), *TD) <
3945 }
else if (I->hasLValue()) {
3946 auto LV = I->getKnownLValue();
3953 AS != CGM.getASTAllocaAddressSpace())))) {
3959 Address AI = CreateMemTempWithoutCast(
3962 I->copyInto(*
this, AI);
3965 auto *T = V->getType()->getPointerElementType()->getPointerTo(
3966 CGM.getDataLayout().getAllocaAddrSpace());
3967 IRCallArgs[FirstIRArg] = getTargetHooks().performAddrSpaceCast(
3976 assert(NumIRArgs == 0);
3984 assert(NumIRArgs == 1);
3986 if (!I->isAggregate())
3987 V = I->getKnownRValue().getScalarVal();
3989 V = Builder.CreateLoad(
3990 I->hasLValue() ? I->getKnownLValue().getAddress()
3991 : I->getKnownRValue().getAggregateAddress());
3997 assert(!swiftErrorTemp.
isValid() &&
"multiple swifterror args");
3999 QualType pointeeTy = I->Ty->getPointeeType();
4004 CreateMemTemp(pointeeTy, getPointerAlign(),
"swifterror.temp");
4006 cast<llvm::AllocaInst>(V)->setSwiftError(
true);
4008 llvm::Value *errorValue = Builder.CreateLoad(swiftErrorArg);
4009 Builder.CreateStore(errorValue, swiftErrorTemp);
4014 V->getType()->isIntegerTy())
4019 if (FirstIRArg < IRFuncTy->getNumParams() &&
4020 V->getType() != IRFuncTy->getParamType(FirstIRArg))
4021 V = Builder.CreateBitCast(V, IRFuncTy->getParamType(FirstIRArg));
4023 IRCallArgs[FirstIRArg] = V;
4029 if (!I->isAggregate()) {
4030 Src = CreateMemTemp(I->Ty,
"coerce");
4031 I->copyInto(*
this, Src);
4033 Src = I->hasLValue() ? I->getKnownLValue().getAddress()
4034 : I->getKnownRValue().getAggregateAddress();
4042 llvm::StructType *STy =
4046 uint64_t SrcSize = CGM.getDataLayout().getTypeAllocSize(SrcTy);
4047 uint64_t DstSize = CGM.getDataLayout().getTypeAllocSize(STy);
4053 if (SrcSize < DstSize) {
4057 Builder.CreateMemCpy(TempAlloca, Src, SrcSize);
4060 Src = Builder.CreateBitCast(Src,
4064 auto SrcLayout = CGM.getDataLayout().getStructLayout(STy);
4065 assert(NumIRArgs == STy->getNumElements());
4066 for (
unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
4070 IRCallArgs[FirstIRArg + i] = LI;
4074 assert(NumIRArgs == 1);
4075 IRCallArgs[FirstIRArg] =
4084 auto layout = CGM.getDataLayout().getStructLayout(coercionType);
4089 if (I->isAggregate()) {
4090 addr = I->hasLValue() ? I->getKnownLValue().getAddress()
4091 : I->getKnownRValue().getAggregateAddress();
4094 RValue RV = I->getKnownRValue();
4098 auto scalarSize = CGM.getDataLayout().getTypeAllocSize(scalarType);
4099 auto scalarAlign = CGM.getDataLayout().getPrefTypeAlignment(scalarType);
4104 layout->getAlignment(), scalarAlign)),
4106 nullptr, &AllocaAddr);
4107 tempSize = EmitLifetimeStart(scalarSize, AllocaAddr.
getPointer());
4112 addr = Builder.CreateElementBitCast(addr, coercionType);
4114 unsigned IRArgPos = FirstIRArg;
4115 for (
unsigned i = 0, e = coercionType->getNumElements(); i != e; ++i) {
4116 llvm::Type *eltType = coercionType->getElementType(i);
4118 Address eltAddr = Builder.CreateStructGEP(addr, i, layout);
4120 IRCallArgs[IRArgPos++] = elt;
4122 assert(IRArgPos == FirstIRArg + NumIRArgs);
4125 EmitLifetimeEnd(tempSize, AllocaAddr.
getPointer());
4132 unsigned IRArgPos = FirstIRArg;
4133 ExpandTypeToArgs(I->Ty, *I, IRFuncTy, IRCallArgs, IRArgPos);
4134 assert(IRArgPos == FirstIRArg + NumIRArgs);
4150 unsigned CalleeAS = CalleePtr->getType()->getPointerAddressSpace();
4151 auto FnTy = getTypes().GetFunctionType(CallInfo)->getPointerTo(CalleeAS);
4152 CalleePtr = Builder.CreateBitCast(CalleePtr, FnTy);
4155 IRFuncTy->getParamType(IRFuncTy->getNumParams() - 1);
4156 if (Arg->getType() != LastParamTy) {
4160 llvm::StructType *DeclaredTy = cast<llvm::StructType>(
4161 cast<llvm::PointerType>(LastParamTy)->getElementType());
4162 assert(DeclaredTy->getNumElements() == FullTy->getNumElements());
4163 for (llvm::StructType::element_iterator DI = DeclaredTy->element_begin(),
4164 DE = DeclaredTy->element_end(),
4165 FI = FullTy->element_begin();
4166 DI != DE; ++DI, ++FI)
4169 Arg = Builder.CreateBitCast(Arg, LastParamTy);
4172 assert(IRFunctionArgs.hasInallocaArg());
4173 IRCallArgs[IRFunctionArgs.getInallocaArgNo()] = Arg;
4185 llvm::FunctionType *CalleeFT =
4186 cast<llvm::FunctionType>(Ptr->getType()->getPointerElementType());
4187 if (!CalleeFT->isVarArg())
4190 llvm::ConstantExpr *CE = dyn_cast<llvm::ConstantExpr>(Ptr);
4191 if (!CE || CE->getOpcode() != llvm::Instruction::BitCast)
4194 llvm::Function *OrigFn = dyn_cast<llvm::Function>(CE->getOperand(0));
4198 llvm::FunctionType *OrigFT = OrigFn->getFunctionType();
4202 if (OrigFT->isVarArg() ||
4203 OrigFT->getNumParams() != CalleeFT->getNumParams() ||
4204 OrigFT->getReturnType() != CalleeFT->getReturnType())
4207 for (
unsigned i = 0, e = OrigFT->getNumParams(); i != e; ++i)
4208 if (OrigFT->getParamType(i) != CalleeFT->getParamType(i))
4213 CalleePtr = simplifyVariadicCallee(CalleePtr);
4227 assert(IRCallArgs.size() == IRFuncTy->getNumParams() || IRFuncTy->isVarArg());
4228 for (
unsigned i = 0; i < IRCallArgs.size(); ++i) {
4230 if (IRFunctionArgs.hasInallocaArg() &&
4231 i == IRFunctionArgs.getInallocaArgNo())
4233 if (i < IRFuncTy->getNumParams())
4234 assert(IRCallArgs[i]->getType() == IRFuncTy->getParamType(i));
4240 llvm::AttributeList Attrs;
4241 CGM.ConstructAttributeList(CalleePtr->getName(), CallInfo,
4250 if (CurCodeDecl && CurCodeDecl->hasAttr<FlattenAttr>() &&
4254 Attrs.addAttribute(
getLLVMContext(), llvm::AttributeList::FunctionIndex,
4255 llvm::Attribute::AlwaysInline);
4259 if (isSEHTryScope()) {
4261 Attrs.addAttribute(
getLLVMContext(), llvm::AttributeList::FunctionIndex,
4262 llvm::Attribute::NoInline);
4267 if (currentFunctionUsesSEHTry()) {
4269 CannotThrow =
false;
4270 }
else if (isCleanupPadScope() &&
4278 CannotThrow = Attrs.hasAttribute(llvm::AttributeList::FunctionIndex,
4279 llvm::Attribute::NoUnwind);
4286 if (UnusedReturnSizePtr)
4288 UnusedReturnSizePtr);
4290 llvm::BasicBlock *InvokeDest = CannotThrow ? nullptr : getInvokeDest();
4293 getBundlesForFunclet(CalleePtr);
4298 CS = Builder.CreateCall(CalleePtr, IRCallArgs, BundleList);
4300 llvm::BasicBlock *Cont = createBasicBlock(
"invoke.cont");
4301 CS = Builder.CreateInvoke(CalleePtr, Cont, InvokeDest, IRCallArgs,
4305 llvm::Instruction *CI = CS.getInstruction();
4310 CS.setAttributes(Attrs);
4311 CS.setCallingConv(static_cast<llvm::CallingConv::ID>(CallingConv));
4315 if (!CI->getType()->isVoidTy())
4316 CI->setName(
"call");
4321 if (!CS.getCalledFunction())
4322 PGO.valueProfile(Builder, llvm::IPVK_IndirectCallTarget,
4327 if (CGM.getLangOpts().ObjCAutoRefCount)
4328 AddObjCARCExceptionMetadata(CI);
4331 if (llvm::CallInst *Call = dyn_cast<llvm::CallInst>(CI)) {
4333 if (TargetDecl && TargetDecl->
hasAttr<NotTailCalledAttr>())
4334 Call->setTailCallKind(llvm::CallInst::TCK_NoTail);
4342 if (CS.doesNotReturn()) {
4343 if (UnusedReturnSizePtr)
4347 if (SanOpts.has(SanitizerKind::Unreachable)) {
4348 if (
auto *F = CS.getCalledFunction())
4349 F->removeFnAttr(llvm::Attribute::NoReturn);
4350 CS.removeAttribute(llvm::AttributeList::FunctionIndex,
4351 llvm::Attribute::NoReturn);
4354 EmitUnreachable(Loc);
4355 Builder.ClearInsertionPoint();
4360 EnsureInsertPoint();
4363 return GetUndefRValue(RetTy);
4367 if (swiftErrorTemp.
isValid()) {
4368 llvm::Value *errorResult = Builder.CreateLoad(swiftErrorTemp);
4369 Builder.CreateStore(errorResult, swiftErrorArg);
4386 auto layout = CGM.getDataLayout().getStructLayout(coercionType);
4389 addr = Builder.CreateElementBitCast(addr, coercionType);
4392 bool requiresExtract = isa<llvm::StructType>(CI->getType());
4394 unsigned unpaddedIndex = 0;
4395 for (
unsigned i = 0, e = coercionType->getNumElements(); i != e; ++i) {
4396 llvm::Type *eltType = coercionType->getElementType(i);
4398 Address eltAddr = Builder.CreateStructGEP(addr, i, layout);
4400 if (requiresExtract)
4401 elt = Builder.CreateExtractValue(elt, unpaddedIndex++);
4403 assert(unpaddedIndex == 0);
4404 Builder.CreateStore(elt, eltAddr);
4413 if (UnusedReturnSizePtr)
4421 return GetUndefRValue(RetTy);
4427 switch (getEvaluationKind(RetTy)) {
4429 llvm::Value *Real = Builder.CreateExtractValue(CI, 0);
4430 llvm::Value *Imag = Builder.CreateExtractValue(CI, 1);
4435 bool DestIsVolatile = ReturnValue.
isVolatile();
4438 DestPtr = CreateMemTemp(RetTy,
"agg.tmp");
4439 DestIsVolatile =
false;
4448 if (V->getType() != RetIRTy)
4449 V = Builder.CreateBitCast(V, RetIRTy);
4453 llvm_unreachable(
"bad evaluation kind");
4457 bool DestIsVolatile = ReturnValue.
isVolatile();
4460 DestPtr = CreateMemTemp(RetTy,
"coerce");
4461 DestIsVolatile =
false;
4472 llvm_unreachable(
"Invalid ABI kind for return argument");
4475 llvm_unreachable(
"Unhandled ABIArgInfo::Kind");
4480 if (Ret.
isScalar() && TargetDecl) {
4481 if (
const auto *AA = TargetDecl->
getAttr<AssumeAlignedAttr>()) {
4483 if (
const auto *
Offset = AA->getOffset())
4484 OffsetValue = EmitScalarExpr(
Offset);
4486 llvm::Value *Alignment = EmitScalarExpr(AA->getAlignment());
4487 llvm::ConstantInt *AlignmentCI = cast<llvm::ConstantInt>(Alignment);
4488 EmitAlignmentAssumption(Ret.
getScalarVal(), AlignmentCI->getZExtValue(),
4490 }
else if (
const auto *AA = TargetDecl->
getAttr<AllocAlignAttr>()) {
4492 CallArgs[AA->getParamIndex().getLLVMIndex()].getRValue(
4493 *
this).getScalarVal();
4503 const CallExpr *CE = getVirtualCallExpr();
4505 CGF, getVirtualMethodDecl(), getThisAddress(),
4520 return CGM.getTypes().getABIInfo().EmitMSVAArg(*
this, VAListAddr, Ty);
4521 return CGM.getTypes().getABIInfo().EmitVAArg(*
this, VAListAddr, Ty);
const CGFunctionInfo & arrangeBuiltinFunctionDeclaration(QualType resultType, const FunctionArgList &args)
A builtin function is a freestanding function using the default C conventions.
const llvm::DataLayout & getDataLayout() const
static CanQual< Type > CreateUnsafe(QualType Other)
Builds a canonical type from a QualType.
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
CGCXXABI & getCXXABI() const
Ignore - Ignore the argument (treat as void).
ReturnValueSlot - Contains the address where the return value of a function can be stored...
ParameterABI getABI() const
Return the ABI treatment of this parameter.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Represents a function declaration or definition.
Address getAddress() const
void end(CodeGenFunction &CGF)
const CGFunctionInfo & arrangeBlockFunctionDeclaration(const FunctionProtoType *type, const FunctionArgList &args)
Block invocation functions are C functions with an implicit parameter.
void EmitReturnValueCheck(llvm::Value *RV)
Emit a test that checks if the return value RV is nonnull.
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
bool isBlockPointerType() const
bool ReturnTypeUsesSRet(const CGFunctionInfo &FI)
Return true iff the given type uses 'sret' when used as a return type.
bool getNoCfCheck() const
llvm::Type * ConvertTypeForMem(QualType T)
const CodeGenOptions & getCodeGenOpts() const
bool isReturnsRetained() const
In ARC, whether this function retains its return value.
static void setCUDAKernelCallingConvention(CanQualType &FTy, CodeGenModule &CGM, const FunctionDecl *FD)
Set calling convention for CUDA/HIP kernel.
static CanQual< FunctionProtoType > GetFormalType(const CXXMethodDecl *MD)
Returns the canonical formal type of the given C++ method.
Address CreateMemTemp(QualType T, const Twine &Name="tmp", Address *Alloca=nullptr)
CreateMemTemp - Create a temporary memory object of the given type, with appropriate alignmen and cas...
static void emitWriteback(CodeGenFunction &CGF, const CallArgList::Writeback &writeback)
Emit the actual writing-back of a writeback.
static Address CreateTempAllocaForCoercion(CodeGenFunction &CGF, llvm::Type *Ty, CharUnits MinAlign)
Create a temporary allocation for the purposes of coercion.
CXXDtorType getDtorType() const
static llvm::Value * emitAutoreleaseOfResult(CodeGenFunction &CGF, llvm::Value *result)
Emit an ARC autorelease of the result of a function.
static const CGFunctionInfo & arrangeFreeFunctionLikeCall(CodeGenTypes &CGT, CodeGenModule &CGM, const CallArgList &args, const FunctionType *fnType, unsigned numExtraRequiredArgs, bool chainCall)
Arrange a call as unto a free function, except possibly with an additional number of formal parameter...
const ABIInfo & getABIInfo() const
FunctionType - C99 6.7.5.3 - Function Declarators.
const CGFunctionInfo & arrangeFreeFunctionType(CanQual< FunctionProtoType > Ty, const FunctionDecl *FD)
Arrange the argument and result information for a value of the given freestanding function type...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
const Decl * getCalleeDecl() const
bool hasExtParameterInfos() const
Is there any interesting extra information for any of the parameters of this function type...
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
Extend - Valid only for integer argument types.
Address EmitPointerWithAlignment(const Expr *Addr, LValueBaseInfo *BaseInfo=nullptr, TBAAAccessInfo *TBAAInfo=nullptr)
EmitPointerWithAlignment - Given an expression with a pointer type, emit the value and compute our be...
Address EmitVAArg(VAArgExpr *VE, Address &VAListAddr)
Generate code to get an argument from the passed in pointer and update it accordingly.
static bool isProvablyNull(llvm::Value *addr)
Decl - This represents one declaration (or definition), e.g.
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...
CGCallee prepareConcreteCallee(CodeGenFunction &CGF) const
If this is a delayed callee computation of some sort, prepare a concrete callee.
const Decl * CurCodeDecl
CurCodeDecl - This is the inner-most code context, which includes blocks.
Direct - Pass the argument directly using the normal converted LLVM type, or by coercing to another s...
const Expr * getSubExpr() const
void addUncopiedAggregate(LValue LV, QualType type)
The base class of the type hierarchy.
void EmitStoreThroughLValue(RValue Src, LValue Dst, bool isInit=false)
EmitStoreThroughLValue - Store the specified rvalue into the specified lvalue, where both are guarant...
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this 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...
bool isRestrictQualified() const
Determine whether this type is restrict-qualified.
bool isZero() const
isZero - Test whether the quantity equals zero.
static int getExpansionSize(QualType Ty, const ASTContext &Context)
const TargetInfo & getTargetInfo() const
const ParmVarDecl * getParamDecl(unsigned I) const
bool isFuncTypeConvertible(const FunctionType *FT)
isFuncTypeConvertible - Utility to check whether a function type can be converted to an LLVM type (i...
llvm::CallSite EmitCallOrInvoke(llvm::Value *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...
llvm::Value * EmitARCRetainNonBlock(llvm::Value *value)
Retain the given object, with normal retain semantics.
static llvm::SmallVector< FunctionProtoType::ExtParameterInfo, 16 > getExtParameterInfosForCall(const FunctionProtoType *proto, unsigned prefixArgs, unsigned totalArgs)
llvm::IntegerType * Int8Ty
i8, i16, i32, and i64
Represents a C++ constructor within a class.
virtual AddedStructorArgs buildStructorSignature(const CXXMethodDecl *MD, StructorType T, SmallVectorImpl< CanQualType > &ArgTys)=0
Build the signature of the given constructor or destructor variant by adding any required parameters...
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.
bool hasWritebacks() const
bool isCoerceAndExpand() const
Default closure variant of a ctor.
ExtParameterInfo withIsNoEscape(bool NoEscape) const
Address GetAddrOfLocalVar(const VarDecl *VD)
GetAddrOfLocalVar - Return the address of a local variable.
RValue EmitCall(const CGFunctionInfo &CallInfo, const CGCallee &Callee, ReturnValueSlot ReturnValue, const CallArgList &Args, llvm::Instruction **callOrInvoke, SourceLocation Loc)
EmitCall - Generate a call of the given function, expecting the given result type, and using the given argument list which specifies both the LLVM arguments and the types they were derived from.
CanQualType getCanonicalParamType(QualType T) const
Return the canonical parameter type corresponding to the specific potentially non-canonical one...
Represents a variable declaration or definition.
static void addExtParameterInfosForCall(llvm::SmallVectorImpl< FunctionProtoType::ExtParameterInfo > ¶mInfos, const FunctionProtoType *proto, unsigned prefixArgs, unsigned totalArgs)
llvm::Instruction * getStackBase() const
unsigned getNumParams() const
RAII object to set/unset CodeGenFunction::IsSanitizerScope.
llvm::Value * getFunctionPointer() const
static llvm::Value * CreateCoercedLoad(Address Src, llvm::Type *Ty, CodeGenFunction &CGF)
CreateCoercedLoad - Create a load from.
const T * getAs() const
Member-template getAs<specific type>'.
void setCoerceToType(llvm::Type *T)
ExtInfo withProducesResult(bool producesResult) const
ObjCMethodDecl - Represents an instance or class method declaration.
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.
Address CreateConstInBoundsByteGEP(Address Addr, CharUnits Offset, const llvm::Twine &Name="")
Given a pointer to i8, adjust it by a given constant offset.
llvm::Value * getPointer() const
bool shouldUseFusedARCCalls()
const CGFunctionInfo & arrangeCXXStructorDeclaration(const CXXMethodDecl *MD, StructorType Type)
llvm::Type * ConvertTypeForMem(QualType T)
ConvertTypeForMem - Convert type T into a llvm::Type.
Represents a parameter to a function.
bool hasFunctionDecl() const
unsigned getAddressSpace() const
Return the address space that this address resides in.
void add(RValue rvalue, QualType type)
unsigned ClangCallConvToLLVMCallConv(CallingConv CC)
Convert clang calling convention to LLVM callilng convention.
unsigned arg_size() const
virtual unsigned getOpenCLKernelCallingConv() const
Get LLVM calling convention for OpenCL kernel.
Represents a struct/union/class.
void freeArgumentMemory(CodeGenFunction &CGF) const
uint64_t getPointerWidth(unsigned AddrSpace) const
Return the width of pointers on this target, for the specified address space.
An object to manage conditionally-evaluated expressions.
Description of a constructor that was inherited from a base class.
bool usesInAlloca() const
Return true if this function uses inalloca arguments.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
static void emitWritebacks(CodeGenFunction &CGF, const CallArgList &args)
void EmitFunctionEpilog(const CGFunctionInfo &FI, bool EmitRetDbgLoc, SourceLocation EndLoc)
EmitFunctionEpilog - Emit the target specific LLVM code to return the given temporary.
bool isNothrow(bool ResultIfDependent=false) const
Determine whether this function type has a non-throwing exception specification.
Address getAddress() const
unsigned getRegParm() const
Indirect - Pass the argument indirectly via a hidden pointer with the specified alignment (0 indicate...
CGDebugInfo * getDebugInfo()
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
llvm::Type * ConvertType(QualType T)
ConvertType - Convert type T into a llvm::Type.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
ArrayRef< ExtParameterInfo > getExtParameterInfos() const
llvm::Constant * objc_retainAutoreleasedReturnValue
id objc_retainAutoreleasedReturnValue(id);
field_range fields() const
bool isVolatileQualified() const
llvm::Value * EmitARCRetainAutoreleaseReturnValue(llvm::Value *value)
Do a fused retain/autorelease of the given object.
Represents a member of a struct/union/class.
CharUnits getAlignment() const
RequiredArgs getRequiredArgs() const
bool isUsingInAlloca() const
Returns if we're using an inalloca struct to pass arguments in memory.
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
StructorType getFromDtorType(CXXDtorType T)
llvm::CallInst * EmitRuntimeCall(llvm::Value *callee, const Twine &name="")
Qualifiers::ObjCLifetime getObjCLifetime() const
CharUnits getArgStructAlignment() const
bool isReferenceType() const
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
Denotes a cleanup that should run when a scope is exited using exceptional control flow (a throw stat...
llvm::Value * EmitARCAutoreleaseReturnValue(llvm::Value *value)
Autorelease the given object.
static void emitWritebackArg(CodeGenFunction &CGF, CallArgList &args, const ObjCIndirectCopyRestoreExpr *CRE)
Emit an argument that's being passed call-by-writeback.
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.
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
static const EHPersonality & get(CodeGenModule &CGM, const FunctionDecl *FD)
unsigned getNumParams() const
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 addArgCleanupDeactivation(EHScopeStack::stable_iterator Cleanup, llvm::Instruction *IsActiveIP)
bool getSuppressSRet() const
bool getProducesResult() const
llvm::FunctionType * getFunctionType() const
ARCPreciseLifetime_t isARCPreciseLifetime() const
This parameter (which must have pointer type) uses the special Swift context-pointer ABI treatment...
static bool hasScalarEvaluationKind(QualType T)
static llvm::Value * tryEmitFusedAutoreleaseOfResult(CodeGenFunction &CGF, llvm::Value *result)
Try to emit a fused autorelease of a return result.
void copyInto(CodeGenFunction &CGF, Address A) const
Address CreateElementBitCast(Address Addr, llvm::Type *Ty, const llvm::Twine &Name="")
Cast the element type of the given address to a different type, preserving information like the align...
CharUnits - This is an opaque type for sizes expressed in character units.
llvm::StructType * getCoerceAndExpandType() const
bool hasConstructorVariants() const
Does this ABI have different entrypoints for complete-object and base-subobject constructors?
Wrapper for source info for functions.
CharUnits getAlignment() const
Return the alignment of this pointer.
virtual bool hasMostDerivedReturn(GlobalDecl GD) const
unsigned getInAllocaFieldIndex() const
const_arg_iterator arg_begin() const
CXXCtorType getCtorType() const
const CGFunctionInfo & arrangeCXXConstructorCall(const CallArgList &Args, const CXXConstructorDecl *D, CXXCtorType CtorKind, unsigned ExtraPrefixArgs, unsigned ExtraSuffixArgs, bool PassProtoArgs=true)
Arrange a call to a C++ method, passing the given arguments.
void ConstructAttributeList(StringRef Name, const CGFunctionInfo &Info, CGCalleeInfo CalleeInfo, llvm::AttributeList &Attrs, unsigned &CallingConv, bool AttrOnCallSite)
Get the LLVM attributes and calling convention to use for a particular function type.
llvm::CallInst * CreateMemCpy(Address Dest, Address Src, llvm::Value *Size, bool IsVolatile=false)
ABIArgInfo - Helper class to encapsulate information about how a specific C type should be passed to ...
static void appendParameterTypes(const CodeGenTypes &CGT, SmallVectorImpl< CanQualType > &prefix, SmallVectorImpl< FunctionProtoType::ExtParameterInfo > ¶mInfos, CanQual< FunctionProtoType > FPT)
Adds the formal parameters in FPT to the given prefix.
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 & arrangeCall(const CGFunctionInfo &declFI, const CallArgList &args)
Given a function info for a declaration, return the function info for a call with the given arguments...
Values of this type can never be null.
llvm::BasicBlock * createBasicBlock(const Twine &name="", llvm::Function *parent=nullptr, llvm::BasicBlock *before=nullptr)
createBasicBlock - Create an LLVM basic block.
Denotes a cleanup that should run when a scope is exited using normal control flow (falling off the e...
const CGFunctionInfo & arrangeCXXMethodDeclaration(const CXXMethodDecl *MD)
C++ methods have some special rules and also have implicit parameters.
CharUnits getPointerAlign() const
An ordinary object is located at an address in memory.
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
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...
FunctionType::ExtInfo getExtInfo() const
QualType getReturnType() const
const CGFunctionInfo & arrangeLLVMFunctionInfo(CanQualType returnType, bool instanceMethod, bool chainCall, ArrayRef< CanQualType > argTypes, FunctionType::ExtInfo info, ArrayRef< FunctionProtoType::ExtParameterInfo > paramInfos, RequiredArgs args)
"Arrange" the LLVM information for a call or type with the given signature.
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
Address getAggregateAddress() const
getAggregateAddr() - Return the Value* of the address of the aggregate.
const Decl * getDecl() const
bool getNoCallerSavedRegs() const
This parameter (which must have pointer-to-pointer type) uses the special Swift error-result ABI trea...
void EmitCallArg(CallArgList &args, const Expr *E, QualType ArgType)
EmitCallArg - Emit a single call argument.
void begin(CodeGenFunction &CGF)
const CGFunctionInfo & arrangeGlobalDeclaration(GlobalDecl GD)
static CanQualType GetThisType(ASTContext &Context, const CXXRecordDecl *RD)
Derives the 'this' type for codegen purposes, i.e.
virtual void setCUDAKernelCallingConvention(const FunctionType *&FT) const
ExtInfo withCallingConv(CallingConv cc) 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...
const CGFunctionInfo & arrangeUnprototypedObjCMessageSend(QualType returnType, const CallArgList &args)
Represents a K&R-style 'int foo()' function, which has no information available about its arguments...
CanQualType getReturnType() const
Const iterator for iterating over Stmt * arrays that contain only Expr *.
std::pair< llvm::Value *, llvm::Value * > ComplexPairTy
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
ASTContext & getContext() const
Represents a prototype with parameter type info, e.g.
llvm::CallInst * EmitNounwindRuntimeCall(llvm::Value *callee, const Twine &name="")
bool isMicrosoftABI() const
Returns whether this is really a Win64 ABI va_arg expression.
bool allowsOptionalArgs() const
const TargetCodeGenInfo & getTargetCodeGenInfo()
bool getPaddingInReg() const
RValue - This trivial value class is used to represent the result of an expression that is evaluated...
writeback_const_range writebacks() const
void addWriteback(LValue srcLV, Address temporary, llvm::Value *toUse)
void EmitDelegateCallArg(CallArgList &args, const VarDecl *param, SourceLocation loc)
EmitDelegateCallArg - We are performing a delegate call; that is, the current function is delegating ...
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Represents a call to the builtin function __builtin_va_arg.
Address Temporary
The temporary alloca.
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...
llvm::Value * ToUse
A value to "use" after the writeback, or null.
static AggValueSlot createPlaceholderSlot(CodeGenFunction &CGF, QualType Ty)
Expr - This represents one expression.
bool isVariadic() const
Whether this function is variadic.
llvm::Type * getUnpaddedCoerceAndExpandType() const
static bool isInAllocaArgument(CGCXXABI &ABI, QualType type)
bool useObjCFPRetForRealType(RealType T) const
Check whether the given real type should use the "fpret" flavor of Objective-C message passing on thi...
static CanQualType GetReturnType(QualType RetTy)
Returns the "extra-canonicalized" return type, which discards qualifiers on the return type...
std::pair< llvm::Value *, llvm::Value * > getComplexVal() const
getComplexVal - Return the real/imag components of this complex value.
void EmitCallArgs(CallArgList &Args, const T *CallArgTypeInfo, 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.
const CGFunctionInfo & arrangeNullaryFunction()
A nullary function is a freestanding function of type 'void ()'.
bool getHasRegParm() const
const T * castAs() const
Member-template castAs<specific type>.
bool isObjCRetainableType() const
Represents a C++ destructor within a class.
llvm::Constant * objc_retain
id objc_retain(id);
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
llvm::PointerType * getType() const
Return the type of the pointer value.
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
static bool isPaddingForCoerceAndExpand(llvm::Type *eltType)
static SmallVector< CanQualType, 16 > getArgTypesForCall(ASTContext &ctx, const CallArgList &args)
static void eraseUnusedBitCasts(llvm::Instruction *insn)
SmallVector< llvm::OperandBundleDef, 1 > getBundlesForFunclet(llvm::Value *Callee)
A class for recording the number of arguments that a function signature requires. ...
bool ReturnSlotInterferesWithArgs(const CGFunctionInfo &FI)
Return true iff the given type uses an argument slot when 'sret' is used as a return type...
const CGFunctionInfo & arrangeBuiltinFunctionCall(QualType resultType, const CallArgList &args)
static Address emitAddressAtOffset(CodeGenFunction &CGF, Address addr, const ABIArgInfo &info)
const CGFunctionInfo & arrangeUnprototypedMustTailThunk(const CXXMethodDecl *MD)
Arrange a thunk that takes 'this' as the first parameter followed by varargs.
static llvm::StoreInst * findDominatingStoreToReturnValue(CodeGenFunction &CGF)
Heuristically search for a dominating store to the return-value slot.
bool canHaveCoerceToType() const
CharUnits alignmentOfArrayElement(CharUnits elementSize) const
Given that this is the alignment of the first element of an array, return the minimum alignment of an...
bool getIndirectByVal() const
llvm::PointerType * AllocaInt8PtrTy
void Profile(llvm::FoldingSetNodeID &ID)
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
ASTContext & getContext() const
ImplicitParamDecl * getSelfDecl() const
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...
CallingConv
CallingConv - Specifies the calling convention that a function uses.
GlobalDecl - represents a global declaration.
static void BuildAggStore(CodeGenFunction &CGF, llvm::Value *Val, Address Dest, bool DestIsVolatile)
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
CanQualType getCanonicalTypeUnqualified() const
LValue getKnownLValue() const
The l-value was considered opaque, so the alignment was determined from a type.
RecordDecl * getDecl() const
unsigned getEffectiveCallingConvention() const
getEffectiveCallingConvention - Return the actual calling convention to use, which may depend on the ...
static void CreateCoercedStore(llvm::Value *Src, Address Dst, bool DstIsVolatile, CodeGenFunction &CGF)
CreateCoercedStore - Create a store to.
Enumerates target-specific builtins in their own namespaces within namespace clang.
Address CreateBitCast(Address Addr, llvm::Type *Ty, const llvm::Twine &Name="")
Assigning into this object requires the old value to be released and the new value to be retained...
bool ReturnTypeUsesFPRet(QualType ResultType)
Return true iff the given type uses 'fpret' when used as a return type.
CanProxy< U > castAs() const
static const Expr * maybeGetUnaryAddrOfOperand(const Expr *E)
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
Encodes a location in the source.
QualType getReturnType() const
void EmitARCRelease(llvm::Value *value, ARCPreciseLifetime_t precise)
Release the given object.
bool isSRetAfterThis() const
A saved depth on the scope stack.
bool inheritingCtorHasParams(const InheritedConstructor &Inherited, CXXCtorType Type)
Determine if a C++ inheriting constructor should have parameters matching those of its inherited cons...
llvm::CallSite EmitRuntimeCallOrInvoke(llvm::Value *callee, ArrayRef< llvm::Value *> args, const Twine &name="")
Emits a call or invoke instruction to the given runtime function.
void DeactivateCleanupBlock(EHScopeStack::stable_iterator Cleanup, llvm::Instruction *DominatingIP)
DeactivateCleanupBlock - Deactivates the given cleanup block.
CallingConv getCC() const
const Decl * getDecl() const
QualType getObjCSelType() const
Retrieve the type that corresponds to the predefined Objective-C 'SEL' type.
virtual void computeInfo(CodeGen::CGFunctionInfo &FI) const =0
const CGFunctionInfo & arrangeObjCMethodDeclaration(const ObjCMethodDecl *MD)
Objective-C methods are C functions with some implicit parameters.
Represents a static or instance method of a struct/union/class.
void computeABIInfo(CodeGenModule &CGM, CGFunctionInfo &FI)
Compute the ABI information of a swiftcall function.
const ConstantArrayType * getAsConstantArrayType(QualType T) const
const_arg_iterator arg_end() const
llvm::StructType * getArgStruct() const
Get the struct type used to represent all the arguments in memory.
ObjCEntrypoints & getObjCEntrypoints() const
bool isInstanceMethod() const
CoerceAndExpand - Only valid for aggregate argument types.
void allocateArgumentMemory(CodeGenFunction &CGF)
Specifies that a value-dependent expression should be considered to never be a null pointer constant...
llvm::InlineAsm * retainAutoreleasedReturnValueMarker
A void(void) inline asm to use to mark that the return value of a call will be immediately retain...
bool isAnyPointerType() const
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after...
bool useObjCFP2RetForComplexLongDouble() const
Check whether _Complex long double should use the "fp2ret" flavor of Objective-C message passing on t...
llvm::LLVMContext & getLLVMContext()
All available information about a concrete callee.
static SmallVector< CanQualType, 16 > getArgTypesForDeclaration(ASTContext &ctx, const FunctionArgList &args)
InAlloca - Pass the argument directly using the LLVM inalloca attribute.
bool ReturnTypeUsesFP2Ret(QualType ResultType)
Return true iff the given type uses 'fp2ret' when used as a return type.
static void AddAttributesFromFunctionProtoType(ASTContext &Ctx, llvm::AttrBuilder &FuncAttrs, const FunctionProtoType *FPT)
bool hasFlexibleArrayMember() const
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
CXXCtorType
C++ constructor types.
CanProxy< U > getAs() const
Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed...
const CGFunctionInfo & arrangeBlockFunctionCall(const CallArgList &args, const FunctionType *type)
A block function is essentially a free function with an extra implicit argument.
std::pair< CharUnits, CharUnits > getTypeInfoInChars(const Type *T) const
llvm::Type * getPaddingType() const
void setExternallyDestructed(bool destructed=true)
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...
FunctionArgList - Type for representing both the decl and type of parameters to a function...
bool getInAllocaSRet() const
Return true if this field of an inalloca struct should be returned to implement a struct return calli...
llvm::Value * getScalarVal() const
getScalarVal() - Return the Value* of this scalar value.
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current target.
const TargetInfo & getTarget() const
CGFunctionInfo - Class to encapsulate the information about a function definition.
This class organizes the cross-function state that is used while generating LLVM code.
Dataflow Directional Tag Classes.
void EmitCXXDestructorCall(const CXXDestructorDecl *D, CXXDtorType Type, bool ForVirtualBase, bool Delegating, Address This)
ExtInfo getExtInfo() const
static RValue getComplex(llvm::Value *V1, llvm::Value *V2)
CodeGenFunction::ComplexPairTy ComplexPairTy
Address CreateStructGEP(Address Addr, unsigned Index, CharUnits Offset, const llvm::Twine &Name="")
CXXDtorType toCXXDtorType(StructorType T)
LValue Source
The original argument.
const CGFunctionInfo & arrangeFunctionDeclaration(const FunctionDecl *FD)
Free functions are functions that are compatible with an ordinary C function pointer type...
void EmitNoreturnRuntimeCallOrInvoke(llvm::Value *callee, ArrayRef< llvm::Value *> args)
Emits a call or invoke to the given noreturn runtime function.
llvm::LoadInst * CreateAlignedLoad(llvm::Value *Addr, CharUnits Align, const llvm::Twine &Name="")
static void forConstantArrayExpansion(CodeGenFunction &CGF, ConstantArrayExpansion *CAE, Address BaseAddr, llvm::function_ref< void(Address)> Fn)
ArrayRef< ExtParameterInfo > getExtParameterInfos() const
static const CGFunctionInfo & arrangeLLVMFunctionInfo(CodeGenTypes &CGT, bool instanceMethod, SmallVectorImpl< CanQualType > &prefix, CanQual< FunctionProtoType > FTP, const FunctionDecl *FD)
Arrange the LLVM function layout for a value of the given function type, on top of any implicit param...
void EmitARCIntrinsicUse(ArrayRef< llvm::Value *> values)
Given a number of pointers, inform the optimizer that they're being intrinsically used up until this ...
void callCStructDestructor(LValue Dst)
llvm::LoadInst * CreateLoad(Address Addr, const llvm::Twine &Name="")
llvm::IntegerType * IntPtrTy
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
SourceLocation getLocStart() const LLVM_READONLY
SourceLocation getLocStart() const LLVM_READONLY
llvm::Function * getIntrinsic(unsigned IID, ArrayRef< llvm::Type *> Tys=None)
RValue getRValue(CodeGenFunction &CGF) const
static CGFunctionInfo * create(unsigned llvmCC, bool instanceMethod, bool chainCall, const FunctionType::ExtInfo &extInfo, ArrayRef< ExtParameterInfo > paramInfos, CanQualType resultType, ArrayRef< CanQualType > argTypes, RequiredArgs required)
llvm::StoreInst * CreateStore(llvm::Value *Val, Address Addr, bool IsVolatile=false)
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...
LValue MakeAddrLValue(Address Addr, QualType T, AlignmentSource Source=AlignmentSource::Type)
bool getCanBeFlattened() const
ArrayRef< llvm::Type * > getCoerceAndExpandTypeSequence() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Complex values, per C99 6.2.5p11.
StructorType getFromCtorType(CXXCtorType T)
static bool classof(const OMPClause *T)
bool isConstantSizeType() const
Return true if this is not a variable sized type, according to the rules of C99 6.7.5p3.
QualType getCanonicalTypeInternal() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
void EmitStoreOfComplex(ComplexPairTy V, LValue dest, bool isInit)
EmitStoreOfComplex - Store a complex number into the specified l-value.
static llvm::Value * tryRemoveRetainOfSelf(CodeGenFunction &CGF, llvm::Value *result)
If this is a +1 of the value of an immutable 'self', remove it.
CharUnits getIndirectAlign() const
Implements C++ ABI-specific code generation functions.
llvm::Type * getElementType() const
Return the type of the values stored in this address.
bool isMSVCXXPersonality() const
This class organizes the cross-module state that is used while lowering AST types to LLVM types...
llvm::StringRef getName() const
Return the IR name of the pointer value.
Expand - Only valid for aggregate argument types.
Base for LValueReferenceType and RValueReferenceType.
void getExpandedTypes(QualType Ty, SmallVectorImpl< llvm::Type *>::iterator &TI)
getExpandedTypes - Expand the type
static std::unique_ptr< TypeExpansion > getTypeExpansion(QualType Ty, const ASTContext &Context)
bool isParamDestroyedInCallee() const
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
EmitBlock - Emit the given block.
ABIArgInfo & getReturnInfo()
Represents a base class of a C++ class.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
ASTContext & getContext() const
Pass it on the stack using its defined layout.
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
llvm::Type * GetFunctionTypeForVTable(GlobalDecl GD)
GetFunctionTypeForVTable - Get the LLVM function type for use in a vtable, given a CXXMethodDecl...
LangAS getAddressSpace() const
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
RValue getKnownRValue() const
Represents a C++ struct/union/class.
virtual const CXXRecordDecl * getThisArgumentTypeForMethod(const CXXMethodDecl *MD)
Get the type of the implicit "this" parameter used by a method.
llvm::Type * ConvertType(QualType T)
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...
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
virtual RecordArgABI getRecordArgABI(const CXXRecordDecl *RD) const =0
Returns how an argument of the given record type should be passed.
LValue EmitLValue(const Expr *E)
EmitLValue - Emit code to compute a designator that specifies the location of the expression...
Address ReturnValue
ReturnValue - The temporary alloca to hold the return value.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
This class is used for builtin types like 'int'.
bool shouldCopy() const
shouldCopy - True if we should do the 'copy' part of the copy-restore.
RValue EmitLoadOfLValue(LValue V, SourceLocation Loc)
EmitLoadOfLValue - Given an expression that represents a value lvalue, this method emits the address ...
Copying closure variant of a ctor.
Defines the clang::TargetInfo interface.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
static CallingConv getCallingConventionForDecl(const Decl *D, bool IsWindows)
CGCXXABI & getCXXABI() const
const CGFunctionInfo & arrangeMSCtorClosure(const CXXConstructorDecl *CD, CXXCtorType CT)
__DEVICE__ int max(int __a, int __b)
bool constructsVirtualBase() const
Returns true if the constructed base class is a virtual base class subobject of this declaration's cl...
static void deactivateArgCleanupsBeforeCall(CodeGenFunction &CGF, const CallArgList &CallArgs)
void EmitAggregateCopy(LValue Dest, LValue Src, QualType EltTy, AggValueSlot::Overlap_t MayOverlap, bool isVolatile=false)
EmitAggregateCopy - Emit an aggregate copy.
const FunctionProtoType * getCalleeFunctionProtoType() const
QualType getIntPtrType() const
Return a type compatible with "intptr_t" (C99 7.18.1.4), as defined by the target.
static RValue get(llvm::Value *V)
static RequiredArgs forPrototypePlus(const FunctionProtoType *prototype, unsigned additional, const FunctionDecl *FD)
Compute the arguments required by the given formal prototype, given that there may be some additional...
bool isPointerType() const
__DEVICE__ int min(int __a, int __b)
unsigned getNumRequiredArgs() const
unsigned getDirectOffset() const
const CGFunctionInfo & arrangeFreeFunctionCall(const CallArgList &Args, const FunctionType *Ty, bool ChainCall)
Figure out the rules for calling a function with the given formal type using the given arguments...
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
CXXCtorType toCXXCtorType(StructorType T)
void computeSPIRKernelABIInfo(CodeGenModule &CGM, CGFunctionInfo &FI)
static RValue getAggregate(Address addr, bool isVolatile=false)
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
ExtParameterInfo getExtParameterInfo(unsigned argIndex) const
LValue - This represents an lvalue references.
An abstract representation of regular/ObjC call/message targets.
Information for lazily generating a cleanup.
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.
llvm::Type * getCoerceToType() const
CGCalleeInfo getAbstractInfo() const
Notes how many arguments were added to the beginning (Prefix) and ending (Suffix) of an arg list...
unsigned getTargetAddressSpace(QualType T) const
void AddDefaultFnAttrs(llvm::Function &F)
Adds attributes to F according to our CodeGenOptions and LangOptions, as though we had emitted it our...
CallArgList - Type for representing both the value and type of arguments in a call.
const CGFunctionInfo & arrangeCXXMethodCall(const CallArgList &args, const FunctionProtoType *type, RequiredArgs required, unsigned numPrefixArgs)
Arrange a call to a C++ method, passing the given arguments.
Represents the canonical version of C arrays with a specified constant size.
bool getIndirectRealign() const
Abstract information about a function or function prototype.
A class which abstracts out some details necessary for making a call.
This parameter (which must have pointer type) is a Swift indirect result parameter.
ConstructorUsingShadowDecl * getShadowDecl() const
ArrayRef< ParmVarDecl * > parameters() const
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
ArrayRef< CallArgCleanup > getCleanupsToDeactivate() const
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
static CharUnits getDeclAlign(Expr *E, CharUnits TypeAlign, ASTContext &Context)
A helper function to get the alignment of a Decl referred to by DeclRefExpr or MemberExpr.
llvm::FunctionType * GetFunctionType(const CGFunctionInfo &Info)
GetFunctionType - Get the LLVM function type for.