29 #include "llvm/ADT/StringExtras.h"
30 #include "llvm/IR/Attributes.h"
31 #include "llvm/IR/CallSite.h"
32 #include "llvm/IR/DataLayout.h"
33 #include "llvm/IR/InlineAsm.h"
34 #include "llvm/IR/Intrinsics.h"
35 #include "llvm/IR/IntrinsicInst.h"
36 #include "llvm/Transforms/Utils/Local.h"
37 using namespace clang;
38 using namespace CodeGen;
50 case CC_AAPCS:
return llvm::CallingConv::ARM_AAPCS;
51 case CC_AAPCS_VFP:
return llvm::CallingConv::ARM_AAPCS_VFP;
104 prefix.append(FPT->param_type_begin(), FPT->param_type_end());
111 prefix.reserve(prefix.size() + FPT->getNumParams());
114 for (
unsigned I = 0,
E = FPT->getNumParams();
I !=
E; ++
I) {
115 prefix.push_back(FPT->getParamType(
I));
134 FTP->getExtInfo(), required);
152 if (D->
hasAttr<FastCallAttr>())
155 if (D->
hasAttr<ThisCallAttr>())
158 if (D->
hasAttr<VectorCallAttr>())
164 if (PcsAttr *PCS = D->
getAttr<PcsAttr>())
167 if (D->
hasAttr<IntelOclBiccAttr>())
198 *
this,
true, argTypes,
208 assert(!isa<CXXConstructorDecl>(MD) &&
"wrong method for constructors!");
209 assert(!isa<CXXDestructorDecl>(MD) &&
"wrong method for destructors!");
230 if (
auto *CD = dyn_cast<CXXConstructorDecl>(MD)) {
254 false, argTypes, extInfo,
263 unsigned ExtraArgs) {
266 for (
const auto &Arg : args)
280 false, ArgTypes, Info,
289 if (MD->isInstance())
294 assert(isa<FunctionType>(FTy));
298 if (isa<FunctionNoProtoType>(FTy)) {
301 noProto->getReturnType(),
false,
305 assert(isa<FunctionProtoType>(FTy));
331 for (
const auto *
I : MD->
params()) {
339 if (
getContext().getLangOpts().ObjCAutoRefCount &&
340 MD->
hasAttr<NSReturnsRetainedAttr>())
348 false, argTys, einfo, required);
372 assert(MD->
isVirtual() &&
"only virtual memptrs have thunks");
390 ArgTys.push_back(*FTP->param_type_begin());
392 ArgTys.push_back(Context.
IntTy);
407 unsigned numExtraRequiredArgs,
409 assert(args.size() >= numExtraRequiredArgs);
417 if (proto->isVariadic())
418 required =
RequiredArgs(proto->getNumParams() + numExtraRequiredArgs);
426 cast<FunctionNoProtoType>(fnType))) {
432 for (
const auto &arg : args)
448 chainCall ? 1 : 0, chainCall);
467 for (
const auto &Arg : args)
471 false, argTypes, info, required);
481 for (
const auto &Arg : args)
487 false, argTypes, info, required);
495 for (
auto Arg : args)
502 false, argTypes, info, required);
521 assert(std::all_of(argTypes.begin(), argTypes.end(),
527 llvm::FoldingSetNodeID
ID;
529 resultType, argTypes);
531 void *insertPos =
nullptr;
532 CGFunctionInfo *FI = FunctionInfos.FindNodeOrInsertPos(ID, insertPos);
538 resultType, argTypes, required);
539 FunctionInfos.InsertNode(FI, insertPos);
541 bool inserted = FunctionsBeingProcessed.insert(FI).second;
543 assert(inserted &&
"Recursively being processed?");
556 if (
I.info.canHaveCoerceToType() &&
I.info.getCoerceToType() ==
nullptr)
559 bool erased = FunctionsBeingProcessed.erase(FI); (void)erased;
560 assert(erased &&
"Not in set?");
573 sizeof(ArgInfo) * (argTypes.size() + 1));
575 FI->CallingConvention = llvmCC;
576 FI->EffectiveCallingConvention = llvmCC;
577 FI->ASTCallingConvention = info.
getCC();
578 FI->InstanceMethod = instanceMethod;
579 FI->ChainCall = chainCall;
582 FI->Required = required;
585 FI->ArgStruct =
nullptr;
586 FI->ArgStructAlign = 0;
587 FI->NumArgs = argTypes.size();
588 FI->getArgsBuffer()[0].type = resultType;
589 for (
unsigned i = 0, e = argTypes.size(); i != e; ++i)
590 FI->getArgsBuffer()[i + 1].type = argTypes[i];
600 struct TypeExpansion {
601 enum TypeExpansionKind {
613 const TypeExpansionKind
Kind;
615 TypeExpansion(TypeExpansionKind K) :
Kind(K) {}
616 virtual ~TypeExpansion() {}
619 struct ConstantArrayExpansion : TypeExpansion {
623 ConstantArrayExpansion(
QualType EltTy, uint64_t NumElts)
624 : TypeExpansion(TEK_ConstantArray), EltTy(EltTy), NumElts(NumElts) {}
625 static bool classof(
const TypeExpansion *TE) {
626 return TE->Kind == TEK_ConstantArray;
630 struct RecordExpansion : TypeExpansion {
637 : TypeExpansion(TEK_Record), Bases(Bases), Fields(Fields) {}
638 static bool classof(
const TypeExpansion *TE) {
639 return TE->Kind == TEK_Record;
643 struct ComplexExpansion : TypeExpansion {
647 static bool classof(
const TypeExpansion *TE) {
652 struct NoExpansion : TypeExpansion {
653 NoExpansion() : TypeExpansion(TEK_None) {}
654 static bool classof(
const TypeExpansion *TE) {
655 return TE->Kind == TEK_None;
660 static std::unique_ptr<TypeExpansion>
663 return llvm::make_unique<ConstantArrayExpansion>(
664 AT->getElementType(), AT->getSize().getZExtValue());
671 "Cannot expand structure with flexible array.");
678 for (
const auto *FD : RD->
fields()) {
680 if (FD->isBitField() && FD->getBitWidthValue(Context) == 0)
682 assert(!FD->isBitField() &&
683 "Cannot expand structure with bit-field members.");
685 if (UnionSize < FieldSize) {
686 UnionSize = FieldSize;
691 Fields.push_back(LargestFD);
693 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
694 assert(!CXXRD->isDynamicClass() &&
695 "cannot expand vtable pointers in dynamic classes");
697 Bases.push_back(&BS);
700 for (
const auto *FD : RD->
fields()) {
702 if (FD->isBitField() && FD->getBitWidthValue(Context) == 0)
704 assert(!FD->isBitField() &&
705 "Cannot expand structure with bit-field members.");
706 Fields.push_back(FD);
709 return llvm::make_unique<RecordExpansion>(std::move(Bases),
713 return llvm::make_unique<ComplexExpansion>(CT->getElementType());
715 return llvm::make_unique<NoExpansion>();
720 if (
auto CAExp = dyn_cast<ConstantArrayExpansion>(Exp.get())) {
723 if (
auto RExp = dyn_cast<RecordExpansion>(Exp.get())) {
725 for (
auto BS : RExp->Bases)
727 for (
auto FD : RExp->Fields)
731 if (isa<ComplexExpansion>(Exp.get()))
733 assert(isa<NoExpansion>(Exp.get()));
741 if (
auto CAExp = dyn_cast<ConstantArrayExpansion>(Exp.get())) {
742 for (
int i = 0, n = CAExp->NumElts; i < n; i++) {
745 }
else if (
auto RExp = dyn_cast<RecordExpansion>(Exp.get())) {
746 for (
auto BS : RExp->Bases)
748 for (
auto FD : RExp->Fields)
750 }
else if (
auto CExp = dyn_cast<ComplexExpansion>(Exp.get())) {
755 assert(isa<NoExpansion>(Exp.get()));
761 ConstantArrayExpansion *CAE,
763 llvm::function_ref<
void(
Address)> Fn) {
768 for (
int i = 0, n = CAE->NumElts; i < n; i++) {
771 Fn(
Address(EltAddr, EltAlign));
775 void CodeGenFunction::ExpandTypeFromArgs(
778 "Unexpected non-simple lvalue during struct expansion.");
781 if (
auto CAExp = dyn_cast<ConstantArrayExpansion>(Exp.get())) {
784 LValue LV = MakeAddrLValue(EltAddr, CAExp->EltTy);
785 ExpandTypeFromArgs(CAExp->EltTy, LV, AI);
787 }
else if (
auto RExp = dyn_cast<RecordExpansion>(Exp.get())) {
797 ExpandTypeFromArgs(BS->getType(), SubLV, AI);
799 for (
auto FD : RExp->Fields) {
801 LValue SubLV = EmitLValueForField(LV, FD);
802 ExpandTypeFromArgs(FD->getType(), SubLV, AI);
804 }
else if (isa<ComplexExpansion>(Exp.get())) {
805 auto realValue = *AI++;
806 auto imagValue = *AI++;
807 EmitStoreOfComplex(
ComplexPairTy(realValue, imagValue), LV,
true);
809 assert(isa<NoExpansion>(Exp.get()));
814 void CodeGenFunction::ExpandTypeToArgs(
818 if (
auto CAExp = dyn_cast<ConstantArrayExpansion>(Exp.get())) {
823 ExpandTypeToArgs(CAExp->EltTy, EltRV, IRFuncTy, IRCallArgs, IRCallArgPos);
825 }
else if (
auto RExp = dyn_cast<RecordExpansion>(Exp.get())) {
835 ExpandTypeToArgs(BS->getType(), BaseRV, IRFuncTy, IRCallArgs,
839 LValue LV = MakeAddrLValue(This, Ty);
840 for (
auto FD : RExp->Fields) {
842 ExpandTypeToArgs(FD->getType(), FldRV, IRFuncTy, IRCallArgs,
845 }
else if (isa<ComplexExpansion>(Exp.get())) {
847 IRCallArgs[IRCallArgPos++] = CV.first;
848 IRCallArgs[IRCallArgPos++] = CV.second;
850 assert(isa<NoExpansion>(Exp.get()));
852 "Unexpected non-scalar rvalue during struct expansion.");
856 if (IRCallArgPos < IRFuncTy->getNumParams() &&
857 V->getType() != IRFuncTy->getParamType(IRCallArgPos))
858 V =
Builder.CreateBitCast(V, IRFuncTy->getParamType(IRCallArgPos));
860 IRCallArgs[IRCallArgPos++] = V;
880 llvm::StructType *SrcSTy,
883 if (SrcSTy->getNumElements() == 0)
return SrcPtr;
885 llvm::Type *FirstElt = SrcSTy->getElementType(0);
891 uint64_t FirstEltSize =
893 if (FirstEltSize < DstSize &&
902 if (llvm::StructType *SrcSTy = dyn_cast<llvm::StructType>(SrcTy))
918 if (Val->getType() == Ty)
921 if (isa<llvm::PointerType>(Val->getType())) {
923 if (isa<llvm::PointerType>(Ty))
931 if (isa<llvm::PointerType>(DestIntTy))
934 if (Val->getType() != DestIntTy) {
936 if (DL.isBigEndian()) {
939 uint64_t SrcSize = DL.getTypeSizeInBits(Val->getType());
940 uint64_t DstSize = DL.getTypeSizeInBits(DestIntTy);
942 if (SrcSize > DstSize) {
943 Val = CGF.
Builder.CreateLShr(Val, SrcSize - DstSize,
"coerce.highbits");
944 Val = CGF.
Builder.CreateTrunc(Val, DestIntTy,
"coerce.val.ii");
946 Val = CGF.
Builder.CreateZExt(Val, DestIntTy,
"coerce.val.ii");
947 Val = CGF.
Builder.CreateShl(Val, DstSize - SrcSize,
"coerce.highbits");
951 Val = CGF.
Builder.CreateIntCast(Val, DestIntTy,
false,
"coerce.val.ii");
955 if (isa<llvm::PointerType>(Ty))
956 Val = CGF.
Builder.CreateIntToPtr(Val, Ty,
"coerce.val.ip");
979 if (llvm::StructType *SrcSTy = dyn_cast<llvm::StructType>(SrcTy)) {
981 SrcTy = Src.
getType()->getElementType();
988 if ((isa<llvm::IntegerType>(Ty) || isa<llvm::PointerType>(Ty)) &&
989 (isa<llvm::IntegerType>(SrcTy) || isa<llvm::PointerType>(SrcTy))) {
995 if (SrcSize >= DstSize) {
1011 llvm::ConstantInt::get(CGF.
IntPtrTy, SrcSize),
1021 Address Dest,
bool DestIsVolatile) {
1023 if (llvm::StructType *STy =
1024 dyn_cast<llvm::StructType>(Val->getType())) {
1025 const llvm::StructLayout *Layout =
1028 for (
unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
1051 if (SrcTy == DstTy) {
1058 if (llvm::StructType *DstSTy = dyn_cast<llvm::StructType>(DstTy)) {
1060 DstTy = Dst.
getType()->getElementType();
1065 if ((isa<llvm::IntegerType>(SrcTy) || isa<llvm::PointerType>(SrcTy)) &&
1066 (isa<llvm::IntegerType>(DstTy) || isa<llvm::PointerType>(DstTy))) {
1075 if (SrcSize <= DstSize) {
1093 llvm::ConstantInt::get(CGF.
IntPtrTy, DstSize),
1113 class ClangToLLVMArgMapping {
1114 static const unsigned InvalidIndex = ~0U;
1115 unsigned InallocaArgNo;
1117 unsigned TotalIRArgs;
1121 unsigned PaddingArgIndex;
1124 unsigned FirstArgIndex;
1125 unsigned NumberOfArgs;
1128 : PaddingArgIndex(InvalidIndex), FirstArgIndex(InvalidIndex),
1136 bool OnlyRequiredArgs =
false)
1137 : InallocaArgNo(InvalidIndex), SRetArgNo(InvalidIndex), TotalIRArgs(0),
1138 ArgInfo(OnlyRequiredArgs ? FI.getNumRequiredArgs() : FI.arg_size()) {
1139 construct(Context, FI, OnlyRequiredArgs);
1142 bool hasInallocaArg()
const {
return InallocaArgNo != InvalidIndex; }
1143 unsigned getInallocaArgNo()
const {
1144 assert(hasInallocaArg());
1145 return InallocaArgNo;
1148 bool hasSRetArg()
const {
return SRetArgNo != InvalidIndex; }
1149 unsigned getSRetArgNo()
const {
1150 assert(hasSRetArg());
1154 unsigned totalIRArgs()
const {
return TotalIRArgs; }
1156 bool hasPaddingArg(
unsigned ArgNo)
const {
1157 assert(ArgNo < ArgInfo.size());
1158 return ArgInfo[ArgNo].PaddingArgIndex != InvalidIndex;
1160 unsigned getPaddingArgNo(
unsigned ArgNo)
const {
1161 assert(hasPaddingArg(ArgNo));
1162 return ArgInfo[ArgNo].PaddingArgIndex;
1167 std::pair<unsigned, unsigned> getIRArgs(
unsigned ArgNo)
const {
1168 assert(ArgNo < ArgInfo.size());
1169 return std::make_pair(ArgInfo[ArgNo].FirstArgIndex,
1170 ArgInfo[ArgNo].NumberOfArgs);
1175 bool OnlyRequiredArgs);
1180 bool OnlyRequiredArgs) {
1181 unsigned IRArgNo = 0;
1182 bool SwapThisWithSRet =
false;
1187 SRetArgNo = SwapThisWithSRet ? 1 : IRArgNo++;
1198 auto &IRArgs = ArgInfo[ArgNo];
1201 IRArgs.PaddingArgIndex = IRArgNo++;
1207 llvm::StructType *STy = dyn_cast<llvm::StructType>(AI.
getCoerceToType());
1209 IRArgs.NumberOfArgs = STy->getNumElements();
1211 IRArgs.NumberOfArgs = 1;
1216 IRArgs.NumberOfArgs = 1;
1221 IRArgs.NumberOfArgs = 0;
1229 if (IRArgs.NumberOfArgs > 0) {
1230 IRArgs.FirstArgIndex = IRArgNo;
1231 IRArgNo += IRArgs.NumberOfArgs;
1236 if (IRArgNo == 1 && SwapThisWithSRet)
1239 assert(ArgNo == ArgInfo.size());
1242 InallocaArgNo = IRArgNo++;
1244 TotalIRArgs = IRArgNo;
1255 return ReturnTypeUsesSRet(FI) &&
1256 getTargetCodeGenInfo().doesReturnSlotInterfereWithArgs();
1261 switch (BT->getKind()) {
1264 case BuiltinType::Float:
1266 case BuiltinType::Double:
1268 case BuiltinType::LongDouble:
1279 if (BT->getKind() == BuiltinType::LongDouble)
1292 llvm::FunctionType *
1295 bool Inserted = FunctionsBeingProcessed.insert(&FI).second;
1297 assert(Inserted &&
"Recursively being processed?");
1303 llvm_unreachable(
"Invalid ABI kind for return argument");
1316 resultType = llvm::PointerType::get(ty, addressSpace);
1328 ClangToLLVMArgMapping IRFunctionArgs(
getContext(), FI,
true);
1332 if (IRFunctionArgs.hasSRetArg()) {
1336 ArgTypes[IRFunctionArgs.getSRetArgNo()] =
1337 llvm::PointerType::get(Ty, AddressSpace);
1341 if (IRFunctionArgs.hasInallocaArg()) {
1344 ArgTypes[IRFunctionArgs.getInallocaArgNo()] = ArgStruct->getPointerTo();
1351 for (; it != ie; ++it, ++ArgNo) {
1355 if (IRFunctionArgs.hasPaddingArg(ArgNo))
1356 ArgTypes[IRFunctionArgs.getPaddingArgNo(ArgNo)] =
1359 unsigned FirstIRArg, NumIRArgs;
1360 std::tie(FirstIRArg, NumIRArgs) = IRFunctionArgs.getIRArgs(ArgNo);
1365 assert(NumIRArgs == 0);
1369 assert(NumIRArgs == 1);
1372 ArgTypes[FirstIRArg] = LTy->getPointerTo();
1381 llvm::StructType *st = dyn_cast<llvm::StructType>(argType);
1383 assert(NumIRArgs == st->getNumElements());
1384 for (
unsigned i = 0, e = st->getNumElements(); i != e; ++i)
1385 ArgTypes[FirstIRArg + i] = st->getElementType(i);
1387 assert(NumIRArgs == 1);
1388 ArgTypes[FirstIRArg] = argType;
1394 auto ArgTypesIter = ArgTypes.begin() + FirstIRArg;
1396 assert(ArgTypesIter == ArgTypes.begin() + FirstIRArg + NumIRArgs);
1401 bool Erased = FunctionsBeingProcessed.erase(&FI); (void)Erased;
1402 assert(Erased &&
"Not in set?");
1404 return llvm::FunctionType::get(resultType, ArgTypes, FI.
isVariadic());
1415 if (isa<CXXDestructorDecl>(MD))
1424 llvm::AttrBuilder &FuncAttrs,
1431 FuncAttrs.addAttribute(llvm::Attribute::NoUnwind);
1437 llvm::AttrBuilder FuncAttrs;
1438 llvm::AttrBuilder RetAttrs;
1439 bool HasOptnone =
false;
1444 FuncAttrs.addAttribute(llvm::Attribute::NoReturn);
1455 if (TargetDecl->hasAttr<ReturnsTwiceAttr>())
1456 FuncAttrs.addAttribute(llvm::Attribute::ReturnsTwice);
1457 if (TargetDecl->hasAttr<NoThrowAttr>())
1458 FuncAttrs.addAttribute(llvm::Attribute::NoUnwind);
1459 if (TargetDecl->hasAttr<NoReturnAttr>())
1460 FuncAttrs.addAttribute(llvm::Attribute::NoReturn);
1461 if (TargetDecl->hasAttr<NoDuplicateAttr>())
1462 FuncAttrs.addAttribute(llvm::Attribute::NoDuplicate);
1464 if (
const FunctionDecl *Fn = dyn_cast<FunctionDecl>(TargetDecl)) {
1470 if (Fn->isNoReturn() && !(AttrOnCallSite && MD && MD->
isVirtual()))
1471 FuncAttrs.addAttribute(llvm::Attribute::NoReturn);
1475 if (TargetDecl->hasAttr<ConstAttr>()) {
1476 FuncAttrs.addAttribute(llvm::Attribute::ReadNone);
1477 FuncAttrs.addAttribute(llvm::Attribute::NoUnwind);
1478 }
else if (TargetDecl->hasAttr<PureAttr>()) {
1479 FuncAttrs.addAttribute(llvm::Attribute::ReadOnly);
1480 FuncAttrs.addAttribute(llvm::Attribute::NoUnwind);
1481 }
else if (TargetDecl->hasAttr<NoAliasAttr>()) {
1482 FuncAttrs.addAttribute(llvm::Attribute::ArgMemOnly);
1483 FuncAttrs.addAttribute(llvm::Attribute::NoUnwind);
1485 if (TargetDecl->hasAttr<RestrictAttr>())
1486 RetAttrs.addAttribute(llvm::Attribute::NoAlias);
1487 if (TargetDecl->hasAttr<ReturnsNonNullAttr>())
1488 RetAttrs.addAttribute(llvm::Attribute::NonNull);
1490 HasOptnone = TargetDecl->
hasAttr<OptimizeNoneAttr>();
1495 if (CodeGenOpts.OptimizeSize)
1496 FuncAttrs.addAttribute(llvm::Attribute::OptimizeForSize);
1497 if (CodeGenOpts.OptimizeSize == 2)
1498 FuncAttrs.addAttribute(llvm::Attribute::MinSize);
1501 if (CodeGenOpts.DisableRedZone)
1502 FuncAttrs.addAttribute(llvm::Attribute::NoRedZone);
1503 if (CodeGenOpts.NoImplicitFloat)
1504 FuncAttrs.addAttribute(llvm::Attribute::NoImplicitFloat);
1505 if (CodeGenOpts.EnableSegmentedStacks &&
1506 !(TargetDecl && TargetDecl->hasAttr<NoSplitStackAttr>()))
1507 FuncAttrs.addAttribute(
"split-stack");
1509 if (AttrOnCallSite) {
1511 if (!CodeGenOpts.SimplifyLibCalls ||
1512 CodeGenOpts.isNoBuiltinFunc(Name.data()))
1513 FuncAttrs.addAttribute(llvm::Attribute::NoBuiltin);
1514 if (!CodeGenOpts.TrapFuncName.empty())
1515 FuncAttrs.addAttribute(
"trap-func-name", CodeGenOpts.TrapFuncName);
1518 if (!CodeGenOpts.DisableFPElim) {
1519 FuncAttrs.addAttribute(
"no-frame-pointer-elim",
"false");
1520 }
else if (CodeGenOpts.OmitLeafFramePointer) {
1521 FuncAttrs.addAttribute(
"no-frame-pointer-elim",
"false");
1522 FuncAttrs.addAttribute(
"no-frame-pointer-elim-non-leaf");
1524 FuncAttrs.addAttribute(
"no-frame-pointer-elim",
"true");
1525 FuncAttrs.addAttribute(
"no-frame-pointer-elim-non-leaf");
1528 bool DisableTailCalls =
1529 CodeGenOpts.DisableTailCalls ||
1530 (TargetDecl && TargetDecl->hasAttr<DisableTailCallsAttr>());
1531 FuncAttrs.addAttribute(
"disable-tail-calls",
1532 llvm::toStringRef(DisableTailCalls));
1534 FuncAttrs.addAttribute(
"less-precise-fpmad",
1535 llvm::toStringRef(CodeGenOpts.LessPreciseFPMAD));
1536 FuncAttrs.addAttribute(
"no-infs-fp-math",
1537 llvm::toStringRef(CodeGenOpts.NoInfsFPMath));
1538 FuncAttrs.addAttribute(
"no-nans-fp-math",
1539 llvm::toStringRef(CodeGenOpts.NoNaNsFPMath));
1540 FuncAttrs.addAttribute(
"unsafe-fp-math",
1541 llvm::toStringRef(CodeGenOpts.UnsafeFPMath));
1542 FuncAttrs.addAttribute(
"use-soft-float",
1543 llvm::toStringRef(CodeGenOpts.SoftFloat));
1544 FuncAttrs.addAttribute(
"stack-protector-buffer-size",
1545 llvm::utostr(CodeGenOpts.SSPBufferSize));
1547 if (CodeGenOpts.StackRealignment)
1548 FuncAttrs.addAttribute(
"stackrealign");
1554 const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(TargetDecl);
1555 if (FD && FD->
hasAttr<TargetAttr>()) {
1556 llvm::StringMap<bool> FeatureMap;
1557 getFunctionFeatureMap(FeatureMap, FD);
1560 std::vector<std::string> Features;
1561 for (llvm::StringMap<bool>::const_iterator it = FeatureMap.begin(),
1562 ie = FeatureMap.end();
1564 Features.push_back((it->second ?
"+" :
"-") + it->first().str());
1570 const auto *TD = FD->
getAttr<TargetAttr>();
1571 TargetAttr::ParsedTargetAttr ParsedAttr = TD->parse();
1572 if (ParsedAttr.second !=
"")
1573 TargetCPU = ParsedAttr.second;
1574 if (TargetCPU !=
"")
1575 FuncAttrs.addAttribute(
"target-cpu", TargetCPU);
1576 if (!Features.empty()) {
1577 std::sort(Features.begin(), Features.end());
1578 FuncAttrs.addAttribute(
1580 llvm::join(Features.begin(), Features.end(),
","));
1586 if (TargetCPU !=
"")
1587 FuncAttrs.addAttribute(
"target-cpu", TargetCPU);
1588 if (!Features.empty()) {
1589 std::sort(Features.begin(), Features.end());
1590 FuncAttrs.addAttribute(
1592 llvm::join(Features.begin(), Features.end(),
","));
1597 ClangToLLVMArgMapping IRFunctionArgs(
getContext(), FI);
1604 RetAttrs.addAttribute(llvm::Attribute::SExt);
1606 RetAttrs.addAttribute(llvm::Attribute::ZExt);
1610 RetAttrs.addAttribute(llvm::Attribute::InReg);
1618 FuncAttrs.removeAttribute(llvm::Attribute::ReadOnly)
1619 .removeAttribute(llvm::Attribute::ReadNone);
1624 llvm_unreachable(
"Invalid ABI kind for return argument");
1630 RetAttrs.addDereferenceableAttr(
getContext().getTypeSizeInChars(PTy)
1632 else if (
getContext().getTargetAddressSpace(PTy) == 0)
1633 RetAttrs.addAttribute(llvm::Attribute::NonNull);
1637 if (RetAttrs.hasAttributes()) {
1638 PAL.push_back(llvm::AttributeSet::get(
1643 if (IRFunctionArgs.hasSRetArg()) {
1644 llvm::AttrBuilder SRETAttrs;
1645 SRETAttrs.addAttribute(llvm::Attribute::StructRet);
1647 SRETAttrs.addAttribute(llvm::Attribute::InReg);
1648 PAL.push_back(llvm::AttributeSet::get(
1649 getLLVMContext(), IRFunctionArgs.getSRetArgNo() + 1, SRETAttrs));
1653 if (IRFunctionArgs.hasInallocaArg()) {
1654 llvm::AttrBuilder Attrs;
1655 Attrs.addAttribute(llvm::Attribute::InAlloca);
1656 PAL.push_back(llvm::AttributeSet::get(
1657 getLLVMContext(), IRFunctionArgs.getInallocaArgNo() + 1, Attrs));
1663 I !=
E; ++
I, ++ArgNo) {
1666 llvm::AttrBuilder Attrs;
1669 if (IRFunctionArgs.hasPaddingArg(ArgNo)) {
1671 PAL.push_back(llvm::AttributeSet::get(
1673 llvm::Attribute::InReg));
1682 Attrs.addAttribute(llvm::Attribute::SExt);
1684 if (getTypes().getABIInfo().shouldSignExtUnsignedType(ParamType))
1685 Attrs.addAttribute(llvm::Attribute::SExt);
1687 Attrs.addAttribute(llvm::Attribute::ZExt);
1692 Attrs.addAttribute(llvm::Attribute::Nest);
1694 Attrs.addAttribute(llvm::Attribute::InReg);
1699 Attrs.addAttribute(llvm::Attribute::InReg);
1702 Attrs.addAttribute(llvm::Attribute::ByVal);
1724 FuncAttrs.removeAttribute(llvm::Attribute::ReadOnly)
1725 .removeAttribute(llvm::Attribute::ReadNone);
1734 FuncAttrs.removeAttribute(llvm::Attribute::ReadOnly)
1735 .removeAttribute(llvm::Attribute::ReadNone);
1742 Attrs.addDereferenceableAttr(
getContext().getTypeSizeInChars(PTy)
1744 else if (
getContext().getTargetAddressSpace(PTy) == 0)
1745 Attrs.addAttribute(llvm::Attribute::NonNull);
1748 if (Attrs.hasAttributes()) {
1749 unsigned FirstIRArg, NumIRArgs;
1750 std::tie(FirstIRArg, NumIRArgs) = IRFunctionArgs.getIRArgs(ArgNo);
1751 for (
unsigned i = 0; i < NumIRArgs; i++)
1753 FirstIRArg + i + 1, Attrs));
1758 if (FuncAttrs.hasAttributes())
1759 PAL.push_back(llvm::
1761 llvm::AttributeSet::FunctionIndex,
1774 if (value->getType() == varType)
return value;
1776 assert((varType->isIntegerTy() || varType->isFloatingPointTy())
1777 &&
"unexpected promotion type");
1779 if (isa<llvm::IntegerType>(varType))
1780 return CGF.
Builder.CreateTrunc(value, varType,
"arg.unpromote");
1782 return CGF.
Builder.CreateFPCast(value, varType,
"arg.unpromote");
1788 QualType ArgType,
unsigned ArgNo) {
1800 if (
auto ParmNNAttr = PVD->
getAttr<NonNullAttr>())
1807 if (NNAttr->isNonNull(ArgNo))
1816 if (CurCodeDecl && CurCodeDecl->hasAttr<NakedAttr>())
1824 if (
const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(CurCodeDecl)) {
1825 if (FD->hasImplicitReturnZero()) {
1826 QualType RetTy = FD->getReturnType().getUnqualifiedType();
1828 llvm::Constant* Zero = llvm::Constant::getNullValue(LLVMTy);
1829 Builder.CreateStore(Zero, ReturnValue);
1836 ClangToLLVMArgMapping IRFunctionArgs(CGM.
getContext(), FI);
1839 FnArgs.reserve(IRFunctionArgs.totalIRArgs());
1840 for (
auto &Arg : Fn->args()) {
1841 FnArgs.push_back(&Arg);
1843 assert(FnArgs.size() == IRFunctionArgs.totalIRArgs());
1848 const llvm::StructLayout *ArgStructLayout =
nullptr;
1849 if (IRFunctionArgs.hasInallocaArg()) {
1851 ArgStruct =
Address(FnArgs[IRFunctionArgs.getInallocaArgNo()],
1854 assert(ArgStruct.getType() == FI.
getArgStruct()->getPointerTo());
1858 if (IRFunctionArgs.hasSRetArg()) {
1859 auto AI = FnArgs[IRFunctionArgs.getSRetArgNo()];
1860 AI->setName(
"agg.result");
1861 AI->addAttr(llvm::AttributeSet::get(
getLLVMContext(), AI->getArgNo() + 1,
1862 llvm::Attribute::NoAlias));
1869 ArgVals.reserve(Args.size());
1875 assert(FI.
arg_size() == Args.size() &&
1876 "Mismatch between function signature & arguments.");
1879 for (FunctionArgList::const_iterator i = Args.begin(), e = Args.end();
1880 i != e; ++i, ++info_it, ++ArgNo) {
1886 isa<ParmVarDecl>(Arg) && cast<ParmVarDecl>(Arg)->isKNRPromoted();
1888 unsigned FirstIRArg, NumIRArgs;
1889 std::tie(FirstIRArg, NumIRArgs) = IRFunctionArgs.getIRArgs(ArgNo);
1893 assert(NumIRArgs == 0);
1897 Address V =
Builder.CreateStructGEP(ArgStruct, FieldIndex, FieldOffset,
1899 ArgVals.push_back(ParamValue::forIndirect(V));
1904 assert(NumIRArgs == 1);
1907 if (!hasScalarEvaluationKind(Ty)) {
1912 Address AlignedTemp = CreateMemTemp(Ty,
"coerce");
1920 auto SizeVal = llvm::ConstantInt::get(IntPtrTy, Size.
getQuantity());
1923 Builder.CreateMemCpy(Dst, Src, SizeVal,
false);
1926 ArgVals.push_back(ParamValue::forIndirect(V));
1930 EmitLoadOfScalar(ParamAddr,
false, Ty, Arg->
getLocStart());
1934 ArgVals.push_back(ParamValue::forDirect(V));
1946 assert(NumIRArgs == 1);
1947 auto AI = FnArgs[FirstIRArg];
1950 if (
const ParmVarDecl *PVD = dyn_cast<ParmVarDecl>(Arg)) {
1952 PVD->getFunctionScopeIndex()))
1955 llvm::Attribute::NonNull));
1957 QualType OTy = PVD->getOriginalType();
1958 if (
const auto *ArrTy =
1965 QualType ETy = ArrTy->getElementType();
1966 uint64_t ArrSize = ArrTy->getSize().getZExtValue();
1969 llvm::AttrBuilder Attrs;
1970 Attrs.addDereferenceableAttr(
1971 getContext().getTypeSizeInChars(ETy).getQuantity()*ArrSize);
1973 AI->getArgNo() + 1, Attrs));
1977 llvm::Attribute::NonNull));
1980 }
else if (
const auto *ArrTy =
1989 llvm::Attribute::NonNull));
1992 const auto *AVAttr = PVD->getAttr<AlignValueAttr>();
1994 if (
const auto *TOTy = dyn_cast<TypedefType>(OTy))
1995 AVAttr = TOTy->getDecl()->getAttr<AlignValueAttr>();
1998 EmitScalarExpr(AVAttr->getAlignment());
1999 llvm::ConstantInt *AlignmentCI =
2000 cast<llvm::ConstantInt>(AlignmentValue);
2001 unsigned Alignment =
2002 std::min((
unsigned) AlignmentCI->getZExtValue(),
2003 +llvm::Value::MaximumAlignment);
2005 llvm::AttrBuilder Attrs;
2006 Attrs.addAlignmentAttr(Alignment);
2008 AI->getArgNo() + 1, Attrs));
2015 llvm::Attribute::NoAlias));
2025 dyn_cast_or_null<CXXMethodDecl>(CurCodeDecl)) {
2026 if (MD->
isVirtual() && Arg == CXXABIThisDecl)
2028 adjustThisParameterInVirtualFunctionPrologue(*
this, CurGD, V);
2036 if (V->getType() != LTy)
2037 V =
Builder.CreateBitCast(V, LTy);
2039 ArgVals.push_back(ParamValue::forDirect(V));
2051 llvm::StructType *STy = dyn_cast<llvm::StructType>(ArgI.
getCoerceToType());
2053 STy->getNumElements() > 1) {
2055 uint64_t SrcSize = CGM.
getDataLayout().getTypeAllocSize(STy);
2057 uint64_t DstSize = CGM.
getDataLayout().getTypeAllocSize(DstTy);
2060 if (SrcSize <= DstSize) {
2062 Builder.CreateBitCast(Ptr, llvm::PointerType::getUnqual(STy));
2065 CreateTempAlloca(STy, Alloca.
getAlignment(),
"coerce");
2068 assert(STy->getNumElements() == NumIRArgs);
2069 for (
unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
2070 auto AI = FnArgs[FirstIRArg + i];
2071 AI->setName(Arg->
getName() +
".coerce" + Twine(i));
2075 Builder.CreateStore(AI, EltPtr);
2078 if (SrcSize > DstSize) {
2079 Builder.CreateMemCpy(Ptr, AddrToStoreInto, DstSize);
2084 assert(NumIRArgs == 1);
2085 auto AI = FnArgs[FirstIRArg];
2086 AI->setName(Arg->
getName() +
".coerce");
2093 EmitLoadOfScalar(Alloca,
false, Ty, Arg->
getLocStart());
2096 ArgVals.push_back(ParamValue::forDirect(V));
2098 ArgVals.push_back(ParamValue::forIndirect(Alloca));
2108 LValue LV = MakeAddrLValue(Alloca, Ty);
2109 ArgVals.push_back(ParamValue::forIndirect(Alloca));
2111 auto FnArgIter = FnArgs.begin() + FirstIRArg;
2112 ExpandTypeFromArgs(Ty, LV, FnArgIter);
2113 assert(FnArgIter == FnArgs.begin() + FirstIRArg + NumIRArgs);
2114 for (
unsigned i = 0, e = NumIRArgs; i != e; ++i) {
2115 auto AI = FnArgs[FirstIRArg + i];
2116 AI->setName(Arg->
getName() +
"." + Twine(i));
2122 assert(NumIRArgs == 0);
2124 if (!hasScalarEvaluationKind(Ty)) {
2125 ArgVals.push_back(ParamValue::forIndirect(CreateMemTemp(Ty)));
2128 ArgVals.push_back(ParamValue::forDirect(U));
2135 for (
int I = Args.size() - 1;
I >= 0; --
I)
2136 EmitParmDecl(*Args[
I], ArgVals[I], I + 1);
2138 for (
unsigned I = 0,
E = Args.size();
I !=
E; ++
I)
2139 EmitParmDecl(*Args[
I], ArgVals[I], I + 1);
2144 while (insn->use_empty()) {
2145 llvm::BitCastInst *bitcast = dyn_cast<llvm::BitCastInst>(insn);
2146 if (!bitcast)
return;
2149 insn = cast<llvm::Instruction>(bitcast->getOperand(0));
2150 bitcast->eraseFromParent();
2158 llvm::BasicBlock *BB = CGF.
Builder.GetInsertBlock();
2159 if (BB->empty())
return nullptr;
2160 if (&BB->back() != result)
return nullptr;
2165 llvm::Instruction *generator = cast<llvm::Instruction>(result);
2171 while (llvm::BitCastInst *bitcast = dyn_cast<llvm::BitCastInst>(generator)) {
2174 generator = cast<llvm::Instruction>(bitcast->getOperand(0));
2177 if (generator->getNextNode() != bitcast)
2180 insnsToKill.push_back(bitcast);
2187 llvm::CallInst *call = dyn_cast<llvm::CallInst>(generator);
2188 if (!call)
return nullptr;
2190 bool doRetainAutorelease;
2193 doRetainAutorelease =
true;
2196 doRetainAutorelease =
false;
2204 llvm::Instruction *prev = call->getPrevNode();
2206 if (isa<llvm::BitCastInst>(prev)) {
2207 prev = prev->getPrevNode();
2210 assert(isa<llvm::CallInst>(prev));
2211 assert(cast<llvm::CallInst>(prev)->getCalledValue() ==
2213 insnsToKill.push_back(prev);
2219 result = call->getArgOperand(0);
2220 insnsToKill.push_back(call);
2224 while (llvm::BitCastInst *bitcast = dyn_cast<llvm::BitCastInst>(result)) {
2225 if (!bitcast->hasOneUse())
break;
2226 insnsToKill.push_back(bitcast);
2227 result = bitcast->getOperand(0);
2232 i = insnsToKill.begin(), e = insnsToKill.end(); i != e; ++i)
2233 (*i)->eraseFromParent();
2236 if (doRetainAutorelease)
2248 dyn_cast_or_null<ObjCMethodDecl>(CGF.
CurCodeDecl);
2249 if (!method)
return nullptr;
2251 if (!self->getType().isConstQualified())
return nullptr;
2254 llvm::CallInst *retainCall =
2255 dyn_cast<llvm::CallInst>(result->stripPointerCasts());
2261 llvm::Value *retainedValue = retainCall->getArgOperand(0);
2262 llvm::LoadInst *load =
2263 dyn_cast<llvm::LoadInst>(retainedValue->stripPointerCasts());
2264 if (!load || load->isAtomic() || load->isVolatile() ||
2273 assert(retainCall->use_empty());
2274 retainCall->eraseFromParent();
2305 auto GetStoreIfValid = [&CGF](llvm::User *U) -> llvm::StoreInst * {
2306 auto *SI = dyn_cast<llvm::StoreInst>(U);
2311 assert(!SI->isAtomic() && !SI->isVolatile());
2319 llvm::BasicBlock *IP = CGF.
Builder.GetInsertBlock();
2320 if (IP->empty())
return nullptr;
2321 llvm::Instruction *
I = &IP->back();
2324 for (llvm::BasicBlock::reverse_iterator II = IP->rbegin(),
2327 if (llvm::IntrinsicInst *Intrinsic =
2328 dyn_cast<llvm::IntrinsicInst>(&*II)) {
2329 if (Intrinsic->getIntrinsicID() == llvm::Intrinsic::lifetime_end) {
2330 const llvm::Value *CastAddr = Intrinsic->getArgOperand(1);
2334 if (isa<llvm::BitCastInst>(&*II) && (CastAddr == &*II))
2342 return GetStoreIfValid(I);
2345 llvm::StoreInst *store =
2347 if (!store)
return nullptr;
2351 llvm::BasicBlock *StoreBB = store->getParent();
2352 llvm::BasicBlock *IP = CGF.
Builder.GetInsertBlock();
2353 while (IP != StoreBB) {
2354 if (!(IP = IP->getSinglePredecessor()))
2366 if (CurCodeDecl && CurCodeDecl->hasAttr<NakedAttr>()) {
2373 if (!ReturnValue.isValid()) {
2378 llvm::DebugLoc RetDbgLoc;
2387 assert(hasAggregateEvaluationKind(RetTy));
2389 llvm::Function::arg_iterator EI = CurFn->arg_end();
2394 RV =
Builder.CreateAlignedLoad(SRet, getPointerAlign(),
"sret");
2399 auto AI = CurFn->arg_begin();
2402 switch (getEvaluationKind(RetTy)) {
2405 EmitLoadOfComplex(MakeAddrLValue(ReturnValue, RetTy), EndLoc);
2406 EmitStoreOfComplex(RT, MakeNaturalAlignAddrLValue(&*AI, RetTy),
2414 EmitStoreOfScalar(
Builder.CreateLoad(ReturnValue),
2415 MakeNaturalAlignAddrLValue(&*AI, RetTy),
2431 if (llvm::StoreInst *SI =
2436 if (EmitRetDbgLoc && !AutoreleaseResult)
2437 RetDbgLoc = SI->getDebugLoc();
2439 RV = SI->getValueOperand();
2440 SI->eraseFromParent();
2443 auto returnValueInst = ReturnValue.getPointer();
2444 if (returnValueInst->use_empty()) {
2445 if (
auto alloca = dyn_cast<llvm::AllocaInst>(returnValueInst)) {
2446 alloca->eraseFromParent();
2453 RV =
Builder.CreateLoad(ReturnValue);
2464 if (AutoreleaseResult) {
2465 assert(getLangOpts().ObjCAutoRefCount &&
2477 llvm_unreachable(
"Invalid ABI kind for return argument");
2480 llvm::Instruction *Ret;
2482 if (CurCodeDecl && SanOpts.has(SanitizerKind::ReturnsNonnullAttribute)) {
2483 if (
auto RetNNAttr = CurCodeDecl->getAttr<ReturnsNonNullAttr>()) {
2486 RV, llvm::Constant::getNullValue(RV->getType()));
2487 llvm::Constant *StaticData[] = {
2488 EmitCheckSourceLocation(EndLoc),
2489 EmitCheckSourceLocation(RetNNAttr->getLocation()),
2491 EmitCheck(std::make_pair(Cond, SanitizerKind::ReturnsNonnullAttribute),
2492 "nonnull_return", StaticData,
None);
2497 Ret =
Builder.CreateRetVoid();
2501 Ret->setDebugLoc(std::move(RetDbgLoc));
2515 llvm::UndefValue::get(IRTy->getPointerTo()->getPointerTo());
2535 Address local = GetAddrOfLocalVar(param);
2544 if (!hasScalarEvaluationKind(ref->getPointeeType()))
2553 "cannot emit delegate call arguments for inalloca arguments!");
2555 args.
add(convertTempToRValue(local, type, loc), type);
2559 return isa<llvm::ConstantPointerNull>(addr);
2563 return isa<llvm::AllocaInst>(addr);
2572 "shouldn't have writeback for provably null argument");
2574 llvm::BasicBlock *contBB =
nullptr;
2579 if (!provablyNonNull) {
2585 CGF.
Builder.CreateCondBr(isNull, contBB, writebackBB);
2594 "icr.writeback-cast");
2603 if (writeback.
ToUse) {
2628 if (!provablyNonNull)
2644 for (
const auto &
I : llvm::reverse(Cleanups)) {
2646 I.IsActiveIP->eraseFromParent();
2653 return uop->getSubExpr();
2683 llvm::PointerType *destType =
2707 llvm::ConstantPointerNull::get(
2708 cast<llvm::PointerType>(destType->getElementType()));
2712 llvm::BasicBlock *contBB =
nullptr;
2713 llvm::BasicBlock *originBB =
nullptr;
2719 if (provablyNonNull) {
2725 finalArgument = CGF.
Builder.CreateSelect(isNull,
2726 llvm::ConstantPointerNull::get(destType),
2732 originBB = CGF.
Builder.GetInsertBlock();
2735 CGF.
Builder.CreateCondBr(isNull, contBB, copyBB);
2737 condEval.
begin(CGF);
2767 if (shouldCopy && !provablyNonNull) {
2768 llvm::BasicBlock *copyBB = CGF.
Builder.GetInsertBlock();
2773 llvm::PHINode *phiToUse = CGF.
Builder.CreatePHI(valueToUse->getType(), 2,
2775 phiToUse->addIncoming(valueToUse, copyBB);
2776 phiToUse->addIncoming(llvm::UndefValue::get(valueToUse->getType()),
2778 valueToUse = phiToUse;
2789 assert(!StackBase && !StackCleanup.isValid());
2793 StackBase = CGF.
Builder.CreateCall(F, {},
"inalloca.save");
2800 CGF.
Builder.CreateCall(F, StackBase);
2808 if (!SanOpts.has(SanitizerKind::NonnullAttribute) || !FD)
2811 unsigned ArgNo = PVD ? PVD->getFunctionScopeIndex() : ParmNum;
2819 Builder.CreateICmpNE(V, llvm::Constant::getNullValue(V->getType()));
2820 llvm::Constant *StaticData[] = {
2821 EmitCheckSourceLocation(ArgLoc),
2822 EmitCheckSourceLocation(NNAttr->getLocation()),
2823 llvm::ConstantInt::get(Int32Ty, ArgNo + 1),
2825 EmitCheck(std::make_pair(Cond, SanitizerKind::NonnullAttribute),
2826 "nonnull_arg", StaticData,
None);
2831 llvm::iterator_range<CallExpr::const_arg_iterator> ArgRange,
2832 const FunctionDecl *CalleeDecl,
unsigned ParamsToSkip) {
2833 assert((
int)ArgTypes.size() == (ArgRange.end() - ArgRange.begin()));
2835 auto MaybeEmitImplicitObjectSize = [&](
unsigned I,
const Expr *Arg) {
2836 if (CalleeDecl ==
nullptr || I >= CalleeDecl->
getNumParams())
2845 llvm::Value *V = evaluateOrEmitBuiltinObjectSize(Arg, PS->getType(), T);
2853 bool HasInAllocaArgs =
false;
2855 I !=
E && !HasInAllocaArgs; ++
I)
2857 if (HasInAllocaArgs) {
2858 assert(
getTarget().getTriple().getArch() == llvm::Triple::x86);
2863 size_t CallArgsStart = Args.size();
2864 for (
int I = ArgTypes.size() - 1; I >= 0; --
I) {
2866 EmitCallArg(Args, *Arg, ArgTypes[I]);
2867 EmitNonNullArgCheck(Args.back().RV, ArgTypes[
I], (*Arg)->getExprLoc(),
2868 CalleeDecl, ParamsToSkip +
I);
2869 MaybeEmitImplicitObjectSize(I, *Arg);
2874 std::reverse(Args.begin() + CallArgsStart, Args.end());
2878 for (
unsigned I = 0,
E = ArgTypes.size(); I !=
E; ++
I) {
2880 assert(Arg != ArgRange.end());
2881 EmitCallArg(Args, *Arg, ArgTypes[I]);
2882 EmitNonNullArgCheck(Args.back().RV, ArgTypes[
I], (*Arg)->getExprLoc(),
2883 CalleeDecl, ParamsToSkip +
I);
2884 MaybeEmitImplicitObjectSize(I, *Arg);
2892 : Addr(Addr), Ty(Ty) {}
2905 struct DisableDebugLocationUpdates {
2907 bool disabledDebugInfo;
2909 if ((disabledDebugInfo = isa<CXXDefaultArgExpr>(E) && CGF.
getDebugInfo()))
2912 ~DisableDebugLocationUpdates() {
2913 if (disabledDebugInfo)
2922 DisableDebugLocationUpdates Dis(*
this, E);
2924 = dyn_cast<ObjCIndirectCopyRestoreExpr>(E)) {
2925 assert(getLangOpts().ObjCAutoRefCount);
2931 "reference binding to unmaterialized r-value!");
2935 return args.
add(EmitReferenceBindingToExpr(E), type);
2938 bool HasAggregateEvalKind = hasAggregateEvaluationKind(type);
2943 if (HasAggregateEvalKind &&
2951 Slot = CreateAggTemp(type,
"agg.tmp");
2954 bool DestroyedInCallee =
2957 if (DestroyedInCallee)
2960 EmitAggExpr(E, Slot);
2964 if (DestroyedInCallee) {
2971 llvm::Instruction *IsActive =
Builder.CreateUnreachable();
2977 if (HasAggregateEvalKind && isa<ImplicitCastExpr>(E) &&
2979 LValue L = EmitLValue(cast<CastExpr>(E)->getSubExpr());
2986 Address tmp = CreateMemTemp(type);
2993 args.
add(EmitAnyExprToTemp(E), type);
2996 QualType CodeGenFunction::getVarArgType(
const Expr *Arg) {
3000 if (!
getTarget().getTriple().isOSWindows())
3017 CodeGenFunction::AddObjCARCExceptionMetadata(llvm::Instruction *Inst) {
3020 Inst->setMetadata(
"clang.arc.no_objc_arc_exceptions",
3027 const llvm::Twine &name) {
3028 return EmitNounwindRuntimeCall(callee, None, name);
3035 const llvm::Twine &name) {
3036 llvm::CallInst *call = EmitRuntimeCall(callee, args, name);
3037 call->setDoesNotThrow();
3045 const llvm::Twine &name) {
3046 return EmitRuntimeCall(callee, None, name);
3054 const llvm::Twine &name) {
3055 llvm::CallInst *call =
Builder.CreateCall(callee, args, name);
3056 call->setCallingConv(getRuntimeCC());
3064 llvm::Instruction *CurrentFuncletPad,
3067 if (!CurrentFuncletPad)
3071 auto *CalleeFn = dyn_cast<llvm::Function>(Callee->stripPointerCasts());
3072 if (CalleeFn && CalleeFn->isIntrinsic() && CalleeFn->doesNotThrow())
3075 BundleList.emplace_back(
"funclet", CurrentFuncletPad);
3084 if (getInvokeDest()) {
3085 llvm::InvokeInst *invoke =
3087 getUnreachableBlock(),
3091 invoke->setDoesNotReturn();
3092 invoke->setCallingConv(getRuntimeCC());
3094 llvm::CallInst *call =
Builder.CreateCall(callee, args, BundleList);
3095 call->setDoesNotReturn();
3096 call->setCallingConv(getRuntimeCC());
3105 const Twine &name) {
3106 return EmitRuntimeCallOrInvoke(callee,
None, name);
3113 const Twine &name) {
3114 llvm::CallSite callSite = EmitCallOrInvoke(callee, args, name);
3115 callSite.setCallingConv(getRuntimeCC());
3124 const Twine &
Name) {
3125 llvm::BasicBlock *InvokeDest = getInvokeDest();
3127 llvm::Instruction *Inst;
3129 Inst =
Builder.CreateCall(Callee, Args, Name);
3131 llvm::BasicBlock *ContBB = createBasicBlock(
"invoke.cont");
3132 Inst =
Builder.CreateInvoke(Callee, ContBB, InvokeDest, Args, Name);
3139 AddObjCARCExceptionMetadata(Inst);
3141 return llvm::CallSite(Inst);
3154 void CodeGenFunction::deferPlaceholderReplacement(llvm::Instruction *Old,
3156 DeferredReplacements.push_back(std::make_pair(Old, New));
3164 llvm::Instruction **callOrInvoke) {
3172 llvm::FunctionType *IRFuncTy =
3173 cast<llvm::FunctionType>(
3179 const llvm::StructLayout *ArgMemoryLayout =
nullptr;
3180 if (llvm::StructType *ArgStruct = CallInfo.
getArgStruct()) {
3181 ArgMemoryLayout = CGM.
getDataLayout().getStructLayout(ArgStruct);
3183 llvm::AllocaInst *AI;
3185 IP = IP->getNextNode();
3186 AI =
new llvm::AllocaInst(ArgStruct,
"argmem", IP);
3188 AI = CreateTempAlloca(ArgStruct,
"argmem");
3191 AI->setAlignment(Align.getQuantity());
3192 AI->setUsedWithInAlloca(
true);
3193 assert(AI->isUsedWithInAlloca() && !AI->isStaticAlloca());
3194 ArgMemory =
Address(AI, Align);
3198 auto createInAllocaStructGEP = [&](
unsigned FieldIndex) ->
Address {
3201 return Builder.CreateStructGEP(ArgMemory, FieldIndex, FieldOffset);
3204 ClangToLLVMArgMapping IRFunctionArgs(CGM.
getContext(), CallInfo);
3210 size_t UnusedReturnSize = 0;
3212 if (!ReturnValue.
isNull()) {
3215 SRetPtr = CreateMemTemp(RetTy);
3216 if (HaveInsertPoint() && ReturnValue.
isUnused()) {
3219 if (EmitLifetimeStart(size, SRetPtr.getPointer()))
3220 UnusedReturnSize = size;
3223 if (IRFunctionArgs.hasSRetArg()) {
3224 IRCallArgs[IRFunctionArgs.getSRetArgNo()] = SRetPtr.getPointer();
3227 Builder.CreateStore(SRetPtr.getPointer(), Addr);
3231 assert(CallInfo.
arg_size() == CallArgs.size() &&
3232 "Mismatch between function signature & arguments.");
3235 for (CallArgList::const_iterator
I = CallArgs.begin(), E = CallArgs.end();
3236 I !=
E; ++
I, ++info_it, ++ArgNo) {
3241 if (IRFunctionArgs.hasPaddingArg(ArgNo))
3242 IRCallArgs[IRFunctionArgs.getPaddingArgNo(ArgNo)] =
3245 unsigned FirstIRArg, NumIRArgs;
3246 std::tie(FirstIRArg, NumIRArgs) = IRFunctionArgs.getIRArgs(ArgNo);
3250 assert(NumIRArgs == 0);
3251 assert(
getTarget().getTriple().getArch() == llvm::Triple::x86);
3254 llvm::Instruction *Placeholder =
3256 CGBuilderTy::InsertPoint IP =
Builder.saveIP();
3257 Builder.SetInsertPoint(Placeholder);
3260 deferPlaceholderReplacement(Placeholder, Addr.
getPointer());
3264 unsigned AS = Addr.
getType()->getPointerAddressSpace();
3269 if (Addr.
getType() != MemType)
3270 Addr =
Builder.CreateBitCast(Addr, MemType);
3271 LValue argLV = MakeAddrLValue(Addr,
I->Ty);
3278 assert(NumIRArgs == 1);
3284 LValue argLV = MakeAddrLValue(Addr,
I->Ty);
3298 const unsigned RVAddrSpace = Addr.
getType()->getAddressSpace();
3299 const unsigned ArgAddrSpace =
3300 (FirstIRArg < IRFuncTy->getNumParams()
3301 ? IRFuncTy->getParamType(FirstIRArg)->getPointerAddressSpace()
3305 llvm::getOrEnforceKnownAlignment(Addr.
getPointer(),
3322 assert(NumIRArgs == 0);
3330 assert(NumIRArgs == 1);
3339 V->getType()->isIntegerTy())
3344 if (FirstIRArg < IRFuncTy->getNumParams() &&
3345 V->getType() != IRFuncTy->getParamType(FirstIRArg))
3346 V =
Builder.CreateBitCast(V, IRFuncTy->getParamType(FirstIRArg));
3347 IRCallArgs[FirstIRArg] = V;
3354 Src = CreateMemTemp(
I->Ty,
"coerce");
3355 LValue SrcLV = MakeAddrLValue(Src,
I->Ty);
3366 llvm::StructType *STy =
3370 uint64_t SrcSize = CGM.
getDataLayout().getTypeAllocSize(SrcTy);
3371 uint64_t DstSize = CGM.
getDataLayout().getTypeAllocSize(STy);
3377 if (SrcSize < DstSize) {
3381 Builder.CreateMemCpy(TempAlloca, Src, SrcSize);
3384 Src =
Builder.CreateBitCast(Src, llvm::PointerType::getUnqual(STy));
3388 assert(NumIRArgs == STy->getNumElements());
3389 for (
unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
3393 IRCallArgs[FirstIRArg + i] = LI;
3397 assert(NumIRArgs == 1);
3398 IRCallArgs[FirstIRArg] =
3406 unsigned IRArgPos = FirstIRArg;
3407 ExpandTypeToArgs(
I->Ty, RV, IRFuncTy, IRCallArgs, IRArgPos);
3408 assert(IRArgPos == FirstIRArg + NumIRArgs);
3413 if (ArgMemory.isValid()) {
3421 cast<llvm::PointerType>(Callee->getType())->getAddressSpace();
3422 Callee =
Builder.CreateBitCast(
3423 Callee, getTypes().
GetFunctionType(CallInfo)->getPointerTo(CalleeAS));
3426 IRFuncTy->getParamType(IRFuncTy->getNumParams() - 1);
3427 if (Arg->getType() != LastParamTy) {
3431 llvm::StructType *DeclaredTy = cast<llvm::StructType>(
3433 assert(DeclaredTy->getNumElements() == FullTy->getNumElements());
3434 for (llvm::StructType::element_iterator DI = DeclaredTy->element_begin(),
3435 DE = DeclaredTy->element_end(),
3436 FI = FullTy->element_begin();
3437 DI != DE; ++DI, ++FI)
3440 Arg =
Builder.CreateBitCast(Arg, LastParamTy);
3443 assert(IRFunctionArgs.hasInallocaArg());
3444 IRCallArgs[IRFunctionArgs.getInallocaArgNo()] = Arg;
3453 if (llvm::ConstantExpr *CE = dyn_cast<llvm::ConstantExpr>(Callee))
3454 if (llvm::Function *CalleeF = dyn_cast<llvm::Function>(CE->getOperand(0))) {
3455 llvm::PointerType *CurPT=cast<llvm::PointerType>(Callee->getType());
3456 llvm::FunctionType *CurFT =
3457 cast<llvm::FunctionType>(CurPT->getElementType());
3458 llvm::FunctionType *ActualFT = CalleeF->getFunctionType();
3460 if (CE->getOpcode() == llvm::Instruction::BitCast &&
3461 ActualFT->getReturnType() == CurFT->getReturnType() &&
3462 ActualFT->getNumParams() == CurFT->getNumParams() &&
3463 ActualFT->getNumParams() == IRCallArgs.size() &&
3464 (CurFT->isVarArg() || !ActualFT->isVarArg())) {
3465 bool ArgsMatch =
true;
3466 for (
unsigned i = 0, e = ActualFT->getNumParams(); i != e; ++i)
3467 if (ActualFT->getParamType(i) != CurFT->getParamType(i)) {
3480 assert(IRCallArgs.size() == IRFuncTy->getNumParams() || IRFuncTy->isVarArg());
3481 for (
unsigned i = 0; i < IRCallArgs.size(); ++i) {
3483 if (IRFunctionArgs.hasInallocaArg() &&
3484 i == IRFunctionArgs.getInallocaArgNo())
3486 if (i < IRFuncTy->getNumParams())
3487 assert(IRCallArgs[i]->getType() == IRFuncTy->getParamType(i));
3495 llvm::AttributeSet Attrs = llvm::AttributeSet::get(
getLLVMContext(),
3499 if (currentFunctionUsesSEHTry()) {
3501 CannotThrow =
false;
3502 }
else if (isCleanupPadScope() &&
3509 CannotThrow = Attrs.hasAttribute(llvm::AttributeSet::FunctionIndex,
3510 llvm::Attribute::NoUnwind);
3512 llvm::BasicBlock *InvokeDest = CannotThrow ?
nullptr : getInvokeDest();
3519 CS =
Builder.CreateCall(Callee, IRCallArgs, BundleList);
3521 llvm::BasicBlock *Cont = createBasicBlock(
"invoke.cont");
3522 CS =
Builder.CreateInvoke(Callee, Cont, InvokeDest, IRCallArgs,
3527 *callOrInvoke = CS.getInstruction();
3529 if (CurCodeDecl && CurCodeDecl->hasAttr<FlattenAttr>() &&
3530 !CS.hasFnAttr(llvm::Attribute::NoInline))
3532 Attrs.addAttribute(
getLLVMContext(), llvm::AttributeSet::FunctionIndex,
3533 llvm::Attribute::AlwaysInline);
3536 if (isSEHTryScope())
3538 Attrs.addAttribute(
getLLVMContext(), llvm::AttributeSet::FunctionIndex,
3539 llvm::Attribute::NoInline);
3541 CS.setAttributes(Attrs);
3542 CS.setCallingConv(static_cast<llvm::CallingConv::ID>(CallingConv));
3547 AddObjCARCExceptionMetadata(CS.getInstruction());
3552 if (CS.doesNotReturn()) {
3553 if (UnusedReturnSize)
3554 EmitLifetimeEnd(llvm::ConstantInt::get(Int64Ty, UnusedReturnSize),
3555 SRetPtr.getPointer());
3558 Builder.ClearInsertionPoint();
3563 EnsureInsertPoint();
3566 return GetUndefRValue(RetTy);
3569 llvm::Instruction *CI = CS.getInstruction();
3570 if (
Builder.isNamePreserving() && !CI->getType()->isVoidTy())
3571 CI->setName(
"call");
3582 if (llvm::CallInst *Call = dyn_cast<llvm::CallInst>(CI)) {
3583 const Decl *TargetDecl = CalleeInfo.getCalleeDecl();
3584 if (TargetDecl && TargetDecl->
hasAttr<NotTailCalledAttr>())
3585 Call->setTailCallKind(llvm::CallInst::TCK_NoTail);
3593 if (UnusedReturnSize)
3594 EmitLifetimeEnd(llvm::ConstantInt::get(Int64Ty, UnusedReturnSize),
3595 SRetPtr.getPointer());
3602 return GetUndefRValue(RetTy);
3608 switch (getEvaluationKind(RetTy)) {
3616 bool DestIsVolatile = ReturnValue.
isVolatile();
3619 DestPtr = CreateMemTemp(RetTy,
"agg.tmp");
3620 DestIsVolatile =
false;
3629 if (V->getType() != RetIRTy)
3630 V =
Builder.CreateBitCast(V, RetIRTy);
3634 llvm_unreachable(
"bad evaluation kind");
3638 bool DestIsVolatile = ReturnValue.
isVolatile();
3641 DestPtr = CreateMemTemp(RetTy,
"coerce");
3642 DestIsVolatile =
false;
3653 llvm_unreachable(
"Invalid ABI kind for return argument");
3656 llvm_unreachable(
"Unhandled ABIArgInfo::Kind");
3659 const Decl *TargetDecl = CalleeInfo.getCalleeDecl();
3661 if (Ret.
isScalar() && TargetDecl) {
3662 if (
const auto *AA = TargetDecl->
getAttr<AssumeAlignedAttr>()) {
3664 if (
const auto *
Offset = AA->getOffset())
3665 OffsetValue = EmitScalarExpr(
Offset);
3667 llvm::Value *Alignment = EmitScalarExpr(AA->getAlignment());
3668 llvm::ConstantInt *AlignmentCI = cast<llvm::ConstantInt>(Alignment);
3669 EmitAlignmentAssumption(Ret.
getScalarVal(), AlignmentCI->getZExtValue(),
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 ...
Ignore - Ignore the argument (treat as void).
ReturnValueSlot - Contains the address where the return value of a function can be stored...
bool useObjCFP2RetForComplexLongDouble() const
Check whether _Complex long double should use the "fp2ret" flavor of Objective-C message passing on t...
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
void getExpandedTypes(QualType Ty, SmallVectorImpl< llvm::Type * >::iterator &TI)
getExpandedTypes - Expand the type
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
CK_LValueToRValue - A conversion which causes the extraction of an r-value from the operand gl-value...
void end(CodeGenFunction &CGF)
void EmitCallArgs(CallArgList &Args, const T *CallArgTypeInfo, llvm::iterator_range< CallExpr::const_arg_iterator > ArgRange, const FunctionDecl *CalleeDecl=nullptr, unsigned ParamsToSkip=0)
EmitCallArgs - Emit call arguments for a function.
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
ObjCEntrypoints & getObjCEntrypoints() const
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
bool useObjCFPRetForRealType(RealType T) const
Check whether the given real type should use the "fpret" flavor of Objective-C message passing on thi...
bool isCanonicalAsParam() const
Determines if this canonical type is furthermore canonical as a parameter.
bool ReturnTypeUsesSRet(const CGFunctionInfo &FI)
Return true iff the given type uses 'sret' when used as a return type.
CodeGenTypes & getTypes()
llvm::Type * ConvertTypeForMem(QualType T)
CanQualType getReturnType() const
ExtInfo withCallingConv(CallingConv cc) const
static CanQual< FunctionProtoType > GetFormalType(const CXXMethodDecl *MD)
Returns the canonical formal type of the given C++ method.
CXXCtorType getCtorType() const
unsigned getInAllocaFieldIndex() const
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.
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...
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
FunctionType - C99 6.7.5.3 - Function Declarators.
const TargetInfo & getTarget() const
const CGFunctionInfo & arrangeFreeFunctionType(CanQual< FunctionProtoType > Ty, const FunctionDecl *FD)
Arrange the argument and result information for a value of the given freestanding function type...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
std::pair< llvm::Value *, llvm::Value * > getComplexVal() const
getComplexVal - Return the real/imag components of this complex value.
void EmitNonNullArgCheck(RValue RV, QualType ArgType, SourceLocation ArgLoc, const FunctionDecl *FD, unsigned ParmNum)
Create a check for a function parameter that may potentially be declared as non-null.
llvm::AllocaInst * CreateTempAlloca(llvm::Type *Ty, const Twine &Name="tmp")
CreateTempAlloca - This creates a alloca and inserts it into the entry block.
Extend - Valid only for integer argument types.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
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)
llvm::LoadInst * CreateDefaultAlignedLoad(llvm::Value *Addr, const llvm::Twine &Name="")
Decl - This represents one declaration (or definition), e.g.
Address getAddress() const
const CGFunctionInfo & arrangeCXXMethodType(const CXXRecordDecl *RD, const FunctionProtoType *FTP, const CXXMethodDecl *MD)
Arrange the argument and result information for a call to an unknown C++ non-static member function o...
const 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...
CGCXXABI & getCXXABI() const
bool hasNonTrivialDestructor() const
Determine whether this class has a non-trivial destructor (C++ [class.dtor]p3)
bool hasFlexibleArrayMember() const
ASTContext & getContext() const
const llvm::DataLayout & getDataLayout() const
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...
RValue asAggregateRValue() const
static const NonNullAttr * getNonNullAttr(const Decl *FD, const ParmVarDecl *PVD, QualType ArgType, unsigned ArgNo)
Returns the attribute (either parameter attribute, or function attribute), which declares argument Ar...
static CGFunctionInfo * create(unsigned llvmCC, bool instanceMethod, bool chainCall, const FunctionType::ExtInfo &extInfo, CanQualType resultType, ArrayRef< CanQualType > argTypes, RequiredArgs required)
static int getExpansionSize(QualType Ty, const ASTContext &Context)
bool isFuncTypeConvertible(const FunctionType *FT)
isFuncTypeConvertible - Utility to check whether a function type can be converted to an LLVM type (i...
bool isBlockPointerType() const
llvm::Value * EmitARCRetainNonBlock(llvm::Value *value)
Retain the given object, with normal retain semantics.
virtual void computeInfo(CodeGen::CGFunctionInfo &FI) const =0
const CGFunctionInfo & arrangeFreeFunctionDeclaration(QualType ResTy, const FunctionArgList &Args, const FunctionType::ExtInfo &Info, bool isVariadic)
llvm::IntegerType * Int8Ty
i8, i16, i32, and i64
Represents a C++ constructor within a class.
bool hasUnsignedIntegerRepresentation() const
Determine whether this type has an unsigned integer representation of some sort, e.g., it is an unsigned integer type or a vector.
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.
void freeArgumentMemory(CodeGenFunction &CGF) const
Default closure variant of a ctor.
Address GetAddrOfLocalVar(const VarDecl *VD)
GetAddrOfLocalVar - Return the address of a local variable.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
llvm::Type * getElementType() const
Return the type of the values stored in this address.
RAII object to set/unset CodeGenFunction::IsSanitizerScope.
bool areArgsDestroyedLeftToRightInCallee() const
Are arguments to a call destroyed left to right in the callee? This is a fundamental language change...
static llvm::Value * CreateCoercedLoad(Address Src, llvm::Type *Ty, CodeGenFunction &CGF)
CreateCoercedLoad - Create a load from.
void setCoerceToType(llvm::Type *T)
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
ObjCMethodDecl - Represents an instance or class method declaration.
static unsigned ClangCallConvToLLVMCallConv(CallingConv CC)
static void EmitInitStoreOfNonAggregate(CodeGenFunction &CGF, RValue Src, LValue Dst)
Store a non-aggregate value to an address to initialize it.
Address CreateConstInBoundsByteGEP(Address Addr, CharUnits Offset, const llvm::Twine &Name="")
Given a pointer to i8, adjust it by a given constant offset.
bool shouldUseFusedARCCalls()
const CGFunctionInfo & arrangeCXXStructorDeclaration(const CXXMethodDecl *MD, StructorType Type)
llvm::Type * ConvertTypeForMem(QualType T)
ConvertTypeForMem - Convert type T into a llvm::Type.
ParmVarDecl - Represents a parameter to a function.
bool isObjCRetainableType() const
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
const ArgInfo * const_arg_iterator
static bool isProvablyNonNull(llvm::Value *addr)
virtual bool hasMostDerivedReturn(GlobalDecl GD) const
RecordDecl - Represents a struct/union/class.
const_arg_iterator arg_end() const
An object to manage conditionally-evaluated expressions.
ExtInfo withProducesResult(bool producesResult) const
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.
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
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 ...
llvm::Constant * objc_retainAutoreleasedReturnValue
id objc_retainAutoreleasedReturnValue(id);
bool isReferenceType() const
llvm::Value * EmitARCRetainAutoreleaseReturnValue(llvm::Value *value)
Do a fused retain/autorelease of the given object.
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
bool isAnyPointerType() const
StructorType getFromDtorType(CXXDtorType T)
llvm::CallInst * EmitRuntimeCall(llvm::Value *callee, const Twine &name="")
bool getInAllocaSRet() const
Return true if this field of an inalloca struct should be returned to implement a struct return calli...
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.
const CGFunctionInfo & arrangeLLVMFunctionInfo(CanQualType returnType, bool instanceMethod, bool chainCall, ArrayRef< CanQualType > argTypes, FunctionType::ExtInfo info, RequiredArgs args)
"Arrange" the LLVM information for a call or type with the given signature.
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
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...
static const EHPersonality & get(CodeGenModule &CGM, const FunctionDecl *FD)
llvm::StructType * getArgStruct() const
Get the struct type used to represent all the arguments in memory.
llvm::Type * getCoerceToType() const
bool getCanBeFlattened() const
RValue EmitCall(const CGFunctionInfo &FnInfo, llvm::Value *Callee, ReturnValueSlot ReturnValue, const CallArgList &Args, CGCalleeInfo CalleeInfo=CGCalleeInfo(), llvm::Instruction **callOrInvoke=nullptr)
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.
unsigned getRegParm() const
i32 captured_struct **param SharedsTy A type which contains references the shared variables *param Shareds Context with the list of shared variables from the p *TaskFunction *param IfCond Not a nullptr if if clause was nullptr *otherwise *param PrivateVars List of references to private variables for the task *directive *param PrivateCopies List of private copies for each private variable in *p PrivateVars *param FirstprivateVars List of references to private variables for the *task directive *param FirstprivateCopies List of private copies for each private variable *in p FirstprivateVars *param FirstprivateInits List of references to auto generated variables *used for initialization of a single array element Used if firstprivate *variable is of array type *param Dependences List of dependences for the task construct
const Decl * getDecl() const
bool shouldCopy() const
shouldCopy - True if we should do the 'copy' part of the copy-restore.
void addArgCleanupDeactivation(EHScopeStack::stable_iterator Cleanup, llvm::Instruction *IsActiveIP)
unsigned getEffectiveCallingConvention() const
getEffectiveCallingConvention - Return the actual calling convention to use, which may depend on the ...
void EmitNoreturnRuntimeCallOrInvoke(llvm::Value *callee, ArrayRef< llvm::Value * > args)
Emits a call or invoke to the given noreturn runtime function.
CharUnits getArgStructAlignment() const
const FunctionProtoType * getCalleeFunctionProtoType()
static bool hasScalarEvaluationKind(QualType T)
CharUnits getAlignment() const
static llvm::Value * tryEmitFusedAutoreleaseOfResult(CodeGenFunction &CGF, llvm::Value *result)
Try to emit a fused autorelease of a return result.
const TargetInfo & getTargetInfo() 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.
Qualifiers::ObjCLifetime getObjCLifetime() const
CanProxy< U > getAs() const
Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed...
QualType getReturnType() const
virtual CodeGen::Address EmitMSVAArg(CodeGen::CodeGenFunction &CGF, CodeGen::Address VAListAddr, QualType Ty) const
Emit the target dependent code to load a value of.
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
field_range fields() const
const Expr * getSubExpr() const
QualType getIntPtrType() const
Return a type compatible with "intptr_t" (C99 7.18.1.4), as defined by the target.
virtual CodeGen::Address EmitVAArg(CodeGen::CodeGenFunction &CGF, CodeGen::Address VAListAddr, QualType Ty) const =0
EmitVAArg - Emit the target dependent code to load a value of.
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 ...
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 ...
bool isVariadic() const
Whether this function is variadic.
llvm::BasicBlock * createBasicBlock(const Twine &name="", llvm::Function *parent=nullptr, llvm::BasicBlock *before=nullptr)
createBasicBlock - Create an LLVM basic block.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
const CGFunctionInfo & arrangeCXXMethodDeclaration(const CXXMethodDecl *MD)
Arrange the argument and result information for a declaration or definition of the given C++ non-stat...
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
An ordinary object is located at an address in memory.
detail::InMemoryDirectory::const_iterator I
QualType getCanonicalTypeInternal() const
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.
Represents a K&R-style 'int foo()' function, which has no information available about its arguments...
unsigned getNumRequiredArgs() const
llvm::CallSite EmitRuntimeCallOrInvoke(llvm::Value *callee, ArrayRef< llvm::Value * > args, const Twine &name="")
Emits a call or invoke instruction to the given runtime function.
LValue MakeAddrLValue(Address Addr, QualType T, AlignmentSource AlignSource=AlignmentSource::Type)
ExtInfo getExtInfo() const
CanQualType getCanonicalTypeUnqualified() const
std::pair< llvm::Value *, llvm::Value * > ComplexPairTy
Represents a prototype with parameter type info, e.g.
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
llvm::CallInst * EmitNounwindRuntimeCall(llvm::Value *callee, const Twine &name="")
const TargetCodeGenInfo & getTargetCodeGenInfo()
writeback_const_range writebacks() const
const TargetInfo & getTarget() const
RValue - This trivial value class is used to represent the result of an expression that is evaluated...
ArrayRef< CallArgCleanup > getCleanupsToDeactivate() const
static void appendParameterTypes(const CodeGenTypes &CGT, SmallVectorImpl< CanQualType > &prefix, const CanQual< FunctionProtoType > &FPT, const FunctionDecl *FD)
Adds the formal paramaters in FPT to the given prefix.
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 ...
Represents a call to the builtin function __builtin_va_arg.
ID
Defines the set of possible language-specific address spaces.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
Address Temporary
The temporary alloca.
llvm::Value * ToUse
A value to "use" after the writeback, or null.
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
llvm::Value * getPointer() const
static AggValueSlot createPlaceholderSlot(CodeGenFunction &CGF, QualType Ty)
Expr - This represents one expression.
CXXDtorType getDtorType() const
CGCXXABI & getCXXABI() const
static bool isInAllocaArgument(CGCXXABI &ABI, QualType type)
static CanQualType GetReturnType(QualType RetTy)
Returns the "extra-canonicalized" return type, which discards qualifiers on the return type...
void EmitStoreOfScalar(llvm::Value *Value, Address Addr, bool Volatile, QualType Ty, AlignmentSource AlignSource=AlignmentSource::Type, llvm::MDNode *TBAAInfo=nullptr, bool isInit=false, QualType TBAABaseTy=QualType(), uint64_t TBAAOffset=0, bool isNontemporal=false)
EmitStoreOfScalar - Store a scalar value to an address, taking care to appropriately convert from the...
const CGFunctionInfo & arrangeNullaryFunction()
getNullaryFunctionInfo - Get the function info for a void() function with standard CC...
bool usesInAlloca() const
Return true if this function uses inalloca arguments.
Represents a C++ destructor within a class.
llvm::Constant * objc_retain
id objc_retain(id);
CharUnits getIndirectAlign() const
bool isMSVCXXPersonality() const
const ParmVarDecl * getParamDecl(unsigned i) const
ASTContext & getContext() const
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
ImplicitParamDecl * getSelfDecl() const
void add(RValue rvalue, QualType type, bool needscopy=false)
static void eraseUnusedBitCasts(llvm::Instruction *insn)
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...
static Address emitAddressAtOffset(CodeGenFunction &CGF, Address addr, const ABIArgInfo &info)
Address EmitPointerWithAlignment(const Expr *Addr, AlignmentSource *Source=nullptr)
EmitPointerWithAlignment - Given an expression with a pointer type, emit the value and compute our be...
static llvm::StoreInst * findDominatingStoreToReturnValue(CodeGenFunction &CGF)
Heuristically search for a dominating store to the return-value slot.
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...
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.
llvm::Function * getIntrinsic(unsigned IID, ArrayRef< llvm::Type * > Tys=None)
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
llvm::Type * getPaddingType() const
ARCPreciseLifetime_t isARCPreciseLifetime() const
static AggValueSlot forAddr(Address addr, Qualifiers quals, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, IsAliased_t isAliased, IsZeroed_t isZeroed=IsNotZeroed)
forAddr - Make a slot for an aggregate value.
bool isUnsignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is unsigned or an enumeration types whose underlying ...
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.
bool hasWritebacks() const
GlobalDecl - represents a global declaration.
static void BuildAggStore(CodeGenFunction &CGF, llvm::Value *Val, Address Dest, bool DestIsVolatile)
std::string CPU
If given, the name of the target CPU to generate code for.
The l-value was considered opaque, so the alignment was determined from a type.
bool isNothrow(const ASTContext &Ctx, bool ResultIfDependent=false) const
Determine whether this function type has a non-throwing exception specification.
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="")
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
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.
ConstExprIterator const_arg_iterator
static const Expr * maybeGetUnaryAddrOfOperand(const Expr *E)
ASTContext & getContext() const
Encodes a location in the source.
CharUnits getPointerAlign() const
void EmitARCIntrinsicUse(ArrayRef< llvm::Value * > values)
Given a number of pointers, inform the optimizer that they're being intrinsically used up until this ...
unsigned getNumParams() const
getNumParams - Return the number of parameters this function must have based on its FunctionType...
void EmitARCRelease(llvm::Value *value, ARCPreciseLifetime_t precise)
Release the given object.
llvm::Value * EmitLoadOfScalar(Address Addr, bool Volatile, QualType Ty, SourceLocation Loc, AlignmentSource AlignSource=AlignmentSource::Type, llvm::MDNode *TBAAInfo=nullptr, QualType TBAABaseTy=QualType(), uint64_t TBAAOffset=0, bool isNontemporal=false)
EmitLoadOfScalar - Load a scalar value from an address, taking care to appropriately convert from the...
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...
bool isConstantSizeType() const
Return true if this is not a variable sized type, according to the rules of C99 6.7.5p3.
void DeactivateCleanupBlock(EHScopeStack::stable_iterator Cleanup, llvm::Instruction *DominatingIP)
DeactivateCleanupBlock - Deactivates the given cleanup block.
const CGFunctionInfo & arrangeObjCMethodDeclaration(const ObjCMethodDecl *MD)
Arrange the argument and result information for the declaration or definition of an Objective-C metho...
bool getPaddingInReg() const
Represents a static or instance method of a struct/union/class.
bool isReturnsRetained() const
In ARC, whether this function retains its return value.
CanQualType getCanonicalParamType(QualType T) const
Return the canonical parameter type corresponding to the specific potentially non-canonical one...
void allocateArgumentMemory(CodeGenFunction &CGF)
const ConstantArrayType * getAsConstantArrayType(QualType T) const
std::vector< std::string > Features
The list of target specific features to enable or disable – this should be a list of strings starting...
static bool classof(const EHScope *Scope)
Specifies that a value-dependent expression should be considered to never be a null pointer constant...
CharUnits alignmentOfArrayElement(CharUnits elementSize) const
Given that this is the alignment of the first element of an array, return the minimum alignment of an...
llvm::InlineAsm * retainAutoreleasedReturnValueMarker
A void(void) inline asm to use to mark that the return value of a call will be immediately retain...
const CodeGenOptions & getCodeGenOpts() const
const LangOptions & getLangOpts() const
llvm::LLVMContext & getLLVMContext()
QualType getReturnType() const
const T * castAs() const
Member-template castAs<specific type>.
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)
llvm::StringRef getName() const
Return the IR name of the pointer value.
const CGFunctionInfo & arrangeCXXMethodCall(const CallArgList &args, const FunctionProtoType *type, RequiredArgs required)
Arrange a call to a C++ method, passing the given arguments.
CXXCtorType
C++ constructor types.
const CGFunctionInfo & arrangeBlockFunctionCall(const CallArgList &args, const FunctionType *type)
A block function call is essentially a free-function call with an extra implicit argument.
void setExternallyDestructed(bool destructed=true)
QualType getObjCSelType() const
Retrieve the type that corresponds to the predefined Objective-C 'SEL' type.
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...
bool isSRetAfterThis() const
FunctionArgList - Type for representing both the decl and type of parameters to a function...
CGFunctionInfo - Class to encapsulate the information about a function definition.
CharUnits getAlignment() const
Return the alignment of this pointer.
This class organizes the cross-function state that is used while generating LLVM code.
bool canHaveCoerceToType() const
static const Type * getElementType(const Expr *BaseExpr)
void EmitCXXDestructorCall(const CXXDestructorDecl *D, CXXDtorType Type, bool ForVirtualBase, bool Delegating, Address This)
llvm::Value * getAggregatePointer() const
static RValue getComplex(llvm::Value *V1, llvm::Value *V2)
bool isZero() const
isZero - Test whether the quantity equals zero.
unsigned getDirectOffset() const
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
llvm::Value * getScalarVal() const
getScalarVal() - Return the Value* of this scalar value.
CodeGenFunction::ComplexPairTy ComplexPairTy
Address CreateStructGEP(Address Addr, unsigned Index, CharUnits Offset, const llvm::Twine &Name="")
CXXDtorType toCXXDtorType(StructorType T)
virtual void 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...
LValue Source
The original argument.
const CGFunctionInfo & arrangeFunctionDeclaration(const FunctionDecl *FD)
Arrange the argument and result information for the declaration or definition of the given function...
bool getProducesResult() const
static void forConstantArrayExpansion(CodeGenFunction &CGF, ConstantArrayExpansion *CAE, Address BaseAddr, llvm::function_ref< void(Address)> Fn)
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...
llvm::LoadInst * CreateLoad(Address Addr, const llvm::Twine &Name="")
llvm::IntegerType * IntPtrTy
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
CallingConv getCC() const
SourceLocation getLocStart() const LLVM_READONLY
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
detail::InMemoryDirectory::const_iterator E
llvm::StoreInst * CreateStore(llvm::Value *Val, Address Addr, bool IsVolatile=false)
static void getBundlesForFunclet(llvm::Value *Callee, llvm::Instruction *CurrentFuncletPad, SmallVectorImpl< llvm::OperandBundleDef > &BundleList)
const VariableArrayType * getAsVariableArrayType(QualType T) const
static RequiredArgs forPrototypePlus(const FunctionProtoType *prototype, unsigned additional)
Compute the arguments required by the given formal prototype, given that there may be some additional...
llvm::PointerType * getType() const
Return the type of the pointer value.
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)
const T * getAs() const
Member-template getAs<specific type>'.
TargetOptions & getTargetOpts() const
Retrieve the target options.
Pass it using the normal C aggregate rules for the ABI, potentially introducing extra copies and pass...
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.
Implements C++ ABI-specific code generation functions.
This class organizes the cross-module state that is used while lowering AST types to LLVM types...
llvm::PointerType * Int8PtrTy
Expand - Only valid for aggregate argument types.
Address getAddress() const
const CGFunctionInfo & arrangeMSMemberPointerThunk(const CXXMethodDecl *MD)
Arrange a thunk that takes 'this' as the first parameter followed by varargs.
Base for LValueReferenceType and RValueReferenceType.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
static std::unique_ptr< TypeExpansion > getTypeExpansion(QualType Ty, const ASTContext &Context)
bool isRestrictQualified() const
Determine whether this type is restrict-qualified.
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
EmitBlock - Emit the given block.
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
ABIArgInfo & getReturnInfo()
Represents a base class of a C++ class.
llvm::MDNode * getNoObjCARCExceptionsMetadata()
Pass it on the stack using its defined layout.
uint64_t getPointerWidth(unsigned AddrSpace) const
Return the width of pointers on this target, for the specified address space.
const Decl * getCalleeDecl()
llvm::Type * GetFunctionTypeForVTable(GlobalDecl GD)
GetFunctionTypeForVTable - Get the LLVM function type for use in a vtable, given a CXXMethodDecl...
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
Represents a C++ struct/union/class.
BoundNodesTreeBuilder *const Builder
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
virtual const CXXRecordDecl * getThisArgumentTypeForMethod(const CXXMethodDecl *MD)
Get the type of the implicit "this" parameter used by a method.
bool isUsingInAlloca() const
Returns if we're using an inalloca struct to pass arguments in memory.
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
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...
CallingConv getDefaultCallingConvention(bool isVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current target.
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.
llvm::Instruction * getStackBase() const
This class is used for builtin types like 'int'.
Address getAggregateAddress() const
getAggregateAddr() - Return the Value* of the address of the aggregate.
const TargetInfo & getTarget() const
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
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.
const_arg_iterator arg_begin() const
bool getIndirectByVal() const
static CallingConv getCallingConventionForDecl(const Decl *D, bool IsWindows)
bool getHasRegParm() const
const CGFunctionInfo & arrangeMSCtorClosure(const CXXConstructorDecl *CD, CXXCtorType CT)
bool isMicrosoftABI() const
Returns whether this is really a Win64 ABI va_arg expression.
unsigned getTargetAddressSpace(QualType T) const
static void deactivateArgCleanupsBeforeCall(CodeGenFunction &CGF, const CallArgList &CallArgs)
const ABIInfo & getABIInfo() const
static RValue get(llvm::Value *V)
unsigned arg_size() const
bool isVolatileQualified() 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...
CXXCtorType toCXXCtorType(StructorType T)
bool getIndirectRealign() const
static RValue getAggregate(Address addr, bool isVolatile=false)
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
LValue - This represents an lvalue references.
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
Information for lazily generating a cleanup.
bool hasSignedIntegerRepresentation() const
Determine whether this type has an signed integer representation of some sort, e.g., it is an signed integer type or a vector.
void ConstructAttributeList(StringRef Name, const CGFunctionInfo &Info, CGCalleeInfo CalleeInfo, AttributeListType &PAL, unsigned &CallingConv, bool AttrOnCallSite)
Get the LLVM attributes and calling convention to use for a particular function type.
CallArgList - Type for representing both the value and type of arguments in a call.
Represents the canonical version of C arrays with a specified constant size.
CGCalleeInfo - Class to encapsulate the information about a callee to be used during the generation o...
A class which abstracts out some details necessary for making a call.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
AttributeList - Represents a syntactic attribute.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
const CGFunctionInfo & arrangeCXXConstructorCall(const CallArgList &Args, const CXXConstructorDecl *D, CXXCtorType CtorKind, unsigned ExtraArgs)
Arrange a call to a C++ method, passing the given arguments.
llvm::FunctionType * GetFunctionType(const CGFunctionInfo &Info)
GetFunctionType - Get the LLVM function type for.