34#include "llvm/IR/IntrinsicsAArch64.h"
35#include "llvm/IR/IntrinsicsAMDGPU.h"
36#include "llvm/IR/IntrinsicsARM.h"
37#include "llvm/IR/IntrinsicsBPF.h"
38#include "llvm/IR/IntrinsicsDirectX.h"
39#include "llvm/IR/IntrinsicsHexagon.h"
40#include "llvm/IR/IntrinsicsMips.h"
41#include "llvm/IR/IntrinsicsNVPTX.h"
42#include "llvm/IR/IntrinsicsPowerPC.h"
43#include "llvm/IR/IntrinsicsR600.h"
44#include "llvm/IR/IntrinsicsRISCV.h"
45#include "llvm/IR/IntrinsicsS390.h"
46#include "llvm/IR/IntrinsicsVE.h"
47#include "llvm/IR/IntrinsicsWebAssembly.h"
48#include "llvm/IR/IntrinsicsX86.h"
49#include "llvm/IR/IntrinsicsXCore.h"
81 cl::desc(
"Maximum size for the name of non-global values."));
88 :
Value(Ty,
Value::ArgumentVal), Parent(Par), ArgNo(ArgNo) {
92void Argument::setParent(
Function *parent) {
97 if (!
getType()->isPointerTy())
return false;
99 (AllowUndefOrPoison ||
104 getType()->getPointerAddressSpace()))
110 if (!
getType()->isPointerTy())
return false;
129 if (!
getType()->isPointerTy())
return false;
140 if (!
getType()->isPointerTy())
return false;
142 return Attrs.hasParamAttr(
getArgNo(), Attribute::ByVal) ||
143 Attrs.hasParamAttr(
getArgNo(), Attribute::InAlloca) ||
144 Attrs.hasParamAttr(
getArgNo(), Attribute::Preallocated);
151 return Attrs.hasParamAttr(
getArgNo(), Attribute::ByVal) ||
152 Attrs.hasParamAttr(
getArgNo(), Attribute::StructRet) ||
153 Attrs.hasParamAttr(
getArgNo(), Attribute::InAlloca) ||
154 Attrs.hasParamAttr(
getArgNo(), Attribute::Preallocated) ||
155 Attrs.hasParamAttr(
getArgNo(), Attribute::ByRef);
181 return DL.getTypeAllocSize(MemTy);
192 assert(
getType()->isPointerTy() &&
"Only pointers have alignments");
201 assert(
getType()->isPointerTy() &&
"Only pointers have byval types");
206 assert(
getType()->isPointerTy() &&
"Only pointers have sret types");
211 assert(
getType()->isPointerTy() &&
"Only pointers have byref types");
216 assert(
getType()->isPointerTy() &&
"Only pointers have inalloca types");
222 "Only pointers have dereferenceable bytes");
228 "Only pointers have dereferenceable bytes");
237 if (!
getType()->isPointerTy())
return false;
242 if (!
getType()->isPointerTy())
return false;
247 if (!
getType()->isPointerTy())
return false;
252 if (!
getType()->isPointerTy())
return false;
257 if (!
getType()->isPointerTy())
return false;
279 return Attrs.hasParamAttr(
getArgNo(), Attribute::ReadOnly) ||
280 Attrs.hasParamAttr(
getArgNo(), Attribute::ReadNone);
324 unsigned NumInstrs = 0;
326 NumInstrs += std::distance(BB.instructionsWithoutDebug().begin(),
327 BB.instructionsWithoutDebug().end());
333 return Create(Ty,
Linkage, M.getDataLayout().getProgramAddressSpace(),
N, &M);
338 unsigned AddrSpace,
const Twine &
N,
344 B.addUWTableAttr(UWTable);
345 switch (M->getFramePointer()) {
350 B.addAttribute(
"frame-pointer",
"non-leaf");
353 B.addAttribute(
"frame-pointer",
"all");
356 if (M->getModuleFlag(
"function_return_thunk_extern"))
357 B.addAttribute(Attribute::FnRetThunkExtern);
373#ifdef EXPENSIVE_CHECKS
375 auto FromFEnd = FromF->
end();
376 for (
auto It = FromBeginIt; It != FromEndIt; ++It)
377 assert(It != FromFEnd &&
"FromBeginIt not before FromEndIt!");
379 BasicBlocks.
splice(ToIt, FromF->BasicBlocks, FromBeginIt, FromEndIt);
384 return BasicBlocks.
erase(FromIt, ToIt);
394 if (AddrSpace ==
static_cast<unsigned>(-1))
395 return M ? M->getDataLayout().getProgramAddressSpace() : 0;
399Function::Function(
FunctionType *Ty, LinkageTypes Linkage,
unsigned AddrSpace,
404 NumArgs(Ty->getNumParams()) {
405 assert(FunctionType::isValidReturnType(getReturnType()) &&
406 "invalid return type");
407 setGlobalObjectSubClassData(0);
410 if (!getContext().shouldDiscardValueNames())
414 if (Ty->getNumParams())
415 setValueSubclassData(1);
439void Function::BuildLazyArguments()
const {
443 Arguments = std::allocator<Argument>().allocate(NumArgs);
444 for (
unsigned i = 0, e = NumArgs; i != e; ++i) {
445 Type *ArgTy = FT->getParamType(i);
446 assert(!ArgTy->
isVoidTy() &&
"Cannot have void typed arguments!");
454 const_cast<Function*
>(
this)->setValueSubclassData(SDC);
464#define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC) \
465 case Intrinsic::INTRINSIC:
466#include "llvm/IR/ConstrainedOps.def"
474void Function::clearArguments() {
479 std::allocator<Argument>().deallocate(Arguments, NumArgs);
489 [](
const Argument &
A) {
return A.use_empty(); }) &&
490 "Expected arguments to be unused in declaration");
496 if (Src.hasLazyArguments())
501 Arguments = Src.Arguments;
502 Src.Arguments =
nullptr;
517 Src.setValueSubclassData(Src.getSubclassDataFromValue() | (1 << 0));
536 while (!BasicBlocks.empty())
537 BasicBlocks.begin()->eraseFromParent();
682 if (
A.isStringAttribute()) {
684 if (Str.getAsInteger(0, Result))
737 setValueSubclassDataBit(14, !Str.empty());
745 setValueSubclassDataBit(14,
false);
764 if (Src->hasPersonalityFn())
766 if (Src->hasPrefixData())
768 if (Src->hasPrologueData())
834#define GET_INTRINSIC_NAME_TABLE
835#include "llvm/IR/IntrinsicImpl.inc"
836#undef GET_INTRINSIC_NAME_TABLE
840#define GET_INTRINSIC_TARGET_DATA
841#include "llvm/IR/IntrinsicImpl.inc"
842#undef GET_INTRINSIC_TARGET_DATA
845 return IID > TargetInfos[0].Count;
864 Targets, [=](
const IntrinsicTargetInfo &TI) {
return TI.Name <
Target; });
886 const auto MatchSize = strlen(NameTable[
Idx]);
887 assert(
Name.size() >= MatchSize &&
"Expected either exact or prefix match");
888 bool IsExactMatch =
Name.size() == MatchSize;
895 if (!
Name.startswith(
"llvm.")) {
918 if (
PointerType *PTyp = dyn_cast<PointerType>(Ty)) {
919 Result +=
"p" + utostr(PTyp->getAddressSpace());
922 if (!PTyp->isOpaque())
925 }
else if (
ArrayType *ATyp = dyn_cast<ArrayType>(Ty)) {
926 Result +=
"a" + utostr(ATyp->getNumElements()) +
928 }
else if (
StructType *STyp = dyn_cast<StructType>(Ty)) {
929 if (!STyp->isLiteral()) {
932 Result += STyp->getName();
934 HasUnnamedType =
true;
937 for (
auto *Elem : STyp->elements())
942 }
else if (
FunctionType *FT = dyn_cast<FunctionType>(Ty)) {
944 for (
size_t i = 0; i < FT->getNumParams(); i++)
950 }
else if (
VectorType *VTy = dyn_cast<VectorType>(Ty)) {
954 Result +=
"v" + utostr(EC.getKnownMinValue()) +
956 }
else if (
TargetExtType *TETy = dyn_cast<TargetExtType>(Ty)) {
958 Result += TETy->getName();
959 for (
Type *ParamTy : TETy->type_params())
961 for (
unsigned IntParam : TETy->int_params())
962 Result +=
"_" + utostr(IntParam);
980 Result +=
"i" + utostr(cast<IntegerType>(Ty)->
getBitWidth());
988 assert(
id < num_intrinsics &&
"Invalid intrinsic ID!");
993 assert(
id < num_intrinsics &&
"Invalid intrinsic ID!");
995 "This version of getName does not support overloading");
1001 bool EarlyModuleCheck) {
1003 assert(Id < Intrinsic::num_intrinsics &&
"Invalid intrinsic ID!");
1005 "This version of getName is for overloaded intrinsics only");
1006 (void)EarlyModuleCheck;
1007 assert((!EarlyModuleCheck || M ||
1008 !
any_of(Tys, [](
Type *
T) {
return isa<PointerType>(
T); })) &&
1009 "Intrinsic overloading on pointer types need to provide a Module");
1010 bool HasUnnamedType =
false;
1012 for (
Type *Ty : Tys)
1014 if (HasUnnamedType) {
1015 assert(M &&
"unnamed types need a module");
1020 "Provided FunctionType must match arguments");
1021 return M->getUniqueIntrinsicName(Result, Id, FT);
1028 assert(M &&
"We need to have a Module");
1041#define GET_INTRINSIC_IITINFO
1042#include "llvm/IR/IntrinsicImpl.inc"
1043#undef GET_INTRINSIC_IITINFO
1049 using namespace Intrinsic;
1051 bool IsScalableVector = (LastInfo == IIT_SCALABLE_VEC);
1054 unsigned StructElts = 2;
1058 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Void, 0));
1061 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::VarArg, 0));
1064 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::MMX, 0));
1067 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::AMX, 0));
1070 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Token, 0));
1073 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Metadata, 0));
1076 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Half, 0));
1079 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::BFloat, 0));
1082 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Float, 0));
1085 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Double, 0));
1088 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Quad, 0));
1091 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::PPCQuad, 0));
1094 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 1));
1097 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 2));
1100 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 4));
1102 case IIT_AARCH64_SVCOUNT:
1103 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::AArch64Svcount, 0));
1106 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 8));
1109 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer,16));
1112 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 32));
1115 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 64));
1118 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 128));
1121 OutputTable.
push_back(IITDescriptor::getVector(1, IsScalableVector));
1125 OutputTable.
push_back(IITDescriptor::getVector(2, IsScalableVector));
1129 OutputTable.
push_back(IITDescriptor::getVector(3, IsScalableVector));
1133 OutputTable.
push_back(IITDescriptor::getVector(4, IsScalableVector));
1137 OutputTable.
push_back(IITDescriptor::getVector(8, IsScalableVector));
1141 OutputTable.
push_back(IITDescriptor::getVector(16, IsScalableVector));
1145 OutputTable.
push_back(IITDescriptor::getVector(32, IsScalableVector));
1149 OutputTable.
push_back(IITDescriptor::getVector(64, IsScalableVector));
1153 OutputTable.
push_back(IITDescriptor::getVector(128, IsScalableVector));
1157 OutputTable.
push_back(IITDescriptor::getVector(256, IsScalableVector));
1161 OutputTable.
push_back(IITDescriptor::getVector(512, IsScalableVector));
1165 OutputTable.
push_back(IITDescriptor::getVector(1024, IsScalableVector));
1169 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Pointer, 10));
1170 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Struct, 0));
1173 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Pointer, 20));
1174 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 8));
1177 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Pointer, 0));
1181 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Pointer,
1187 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
1188 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Argument,
ArgInfo));
1191 case IIT_EXTEND_ARG: {
1192 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
1193 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::ExtendArgument,
1197 case IIT_TRUNC_ARG: {
1198 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
1199 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::TruncArgument,
1203 case IIT_HALF_VEC_ARG: {
1204 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
1205 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::HalfVecArgument,
1209 case IIT_SAME_VEC_WIDTH_ARG: {
1210 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
1211 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::SameVecWidthArgument,
1215 case IIT_PTR_TO_ARG: {
1216 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
1217 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::PtrToArgument,
1221 case IIT_PTR_TO_ELT: {
1222 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
1223 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::PtrToElt,
ArgInfo));
1226 case IIT_ANYPTR_TO_ELT: {
1227 unsigned short ArgNo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
1228 unsigned short RefNo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
1230 IITDescriptor::get(IITDescriptor::AnyPtrToElt, ArgNo, RefNo));
1233 case IIT_VEC_OF_ANYPTRS_TO_ELT: {
1234 unsigned short ArgNo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
1235 unsigned short RefNo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
1237 IITDescriptor::get(IITDescriptor::VecOfAnyPtrsToElt, ArgNo, RefNo));
1240 case IIT_EMPTYSTRUCT:
1241 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Struct, 0));
1243 case IIT_STRUCT9: ++StructElts; [[fallthrough]];
1244 case IIT_STRUCT8: ++StructElts; [[fallthrough]];
1245 case IIT_STRUCT7: ++StructElts; [[fallthrough]];
1246 case IIT_STRUCT6: ++StructElts; [[fallthrough]];
1247 case IIT_STRUCT5: ++StructElts; [[fallthrough]];
1248 case IIT_STRUCT4: ++StructElts; [[fallthrough]];
1249 case IIT_STRUCT3: ++StructElts; [[fallthrough]];
1251 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Struct,StructElts));
1253 for (
unsigned i = 0; i != StructElts; ++i)
1257 case IIT_SUBDIVIDE2_ARG: {
1258 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
1259 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Subdivide2Argument,
1263 case IIT_SUBDIVIDE4_ARG: {
1264 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
1265 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Subdivide4Argument,
1269 case IIT_VEC_ELEMENT: {
1270 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
1271 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::VecElementArgument,
1275 case IIT_SCALABLE_VEC: {
1279 case IIT_VEC_OF_BITCASTS_TO_INT: {
1280 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
1281 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::VecOfBitcastsToInt,
1289#define GET_INTRINSIC_GENERATOR_GLOBAL
1290#include "llvm/IR/IntrinsicImpl.inc"
1291#undef GET_INTRINSIC_GENERATOR_GLOBAL
1296 unsigned TableVal = IIT_Table[
id-1];
1301 unsigned NextElt = 0;
1302 if ((TableVal >> 31) != 0) {
1304 IITEntries = IIT_LongEncodingTable;
1307 NextElt = (TableVal << 1) >> 1;
1316 IITEntries = IITValues;
1322 while (NextElt != IITEntries.
size() && IITEntries[NextElt] != 0)
1328 using namespace Intrinsic;
1330 IITDescriptor
D = Infos.
front();
1331 Infos = Infos.
slice(1);
1346 case IITDescriptor::AArch64Svcount:
1349 case IITDescriptor::Integer:
1351 case IITDescriptor::Vector:
1354 case IITDescriptor::Pointer:
1356 D.Pointer_AddressSpace);
1357 case IITDescriptor::Struct: {
1359 for (
unsigned i = 0, e =
D.Struct_NumElements; i != e; ++i)
1363 case IITDescriptor::Argument:
1364 return Tys[
D.getArgumentNumber()];
1365 case IITDescriptor::ExtendArgument: {
1366 Type *Ty = Tys[
D.getArgumentNumber()];
1367 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
1372 case IITDescriptor::TruncArgument: {
1373 Type *Ty = Tys[
D.getArgumentNumber()];
1374 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
1381 case IITDescriptor::Subdivide2Argument:
1382 case IITDescriptor::Subdivide4Argument: {
1383 Type *Ty = Tys[
D.getArgumentNumber()];
1385 assert(VTy &&
"Expected an argument of Vector Type");
1386 int SubDivs =
D.Kind == IITDescriptor::Subdivide2Argument ? 1 : 2;
1389 case IITDescriptor::HalfVecArgument:
1391 Tys[
D.getArgumentNumber()]));
1392 case IITDescriptor::SameVecWidthArgument: {
1394 Type *Ty = Tys[
D.getArgumentNumber()];
1395 if (
auto *VTy = dyn_cast<VectorType>(Ty))
1399 case IITDescriptor::PtrToArgument: {
1400 Type *Ty = Tys[
D.getArgumentNumber()];
1403 case IITDescriptor::PtrToElt: {
1404 Type *Ty = Tys[
D.getArgumentNumber()];
1408 Type *EltTy = VTy->getElementType();
1411 case IITDescriptor::VecElementArgument: {
1412 Type *Ty = Tys[
D.getArgumentNumber()];
1413 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
1414 return VTy->getElementType();
1417 case IITDescriptor::VecOfBitcastsToInt: {
1418 Type *Ty = Tys[
D.getArgumentNumber()];
1420 assert(VTy &&
"Expected an argument of Vector Type");
1423 case IITDescriptor::VecOfAnyPtrsToElt:
1425 return Tys[
D.getOverloadArgNumber()];
1426 case IITDescriptor::AnyPtrToElt:
1428 return Tys[
D.getOverloadArgNumber()];
1447 if (!ArgTys.
empty() && ArgTys.
back()->isVoidTy()) {
1455#define GET_INTRINSIC_OVERLOAD_TABLE
1456#include "llvm/IR/IntrinsicImpl.inc"
1457#undef GET_INTRINSIC_OVERLOAD_TABLE
1461#define GET_INTRINSIC_ATTRIBUTES
1462#include "llvm/IR/IntrinsicImpl.inc"
1463#undef GET_INTRINSIC_ATTRIBUTES
1468 auto *FT =
getType(M->getContext(),
id, Tys);
1469 return cast<Function>(
1470 M->getOrInsertFunction(
1476#define GET_LLVM_INTRINSIC_FOR_CLANG_BUILTIN
1477#include "llvm/IR/IntrinsicImpl.inc"
1478#undef GET_LLVM_INTRINSIC_FOR_CLANG_BUILTIN
1481#define GET_LLVM_INTRINSIC_FOR_MS_BUILTIN
1482#include "llvm/IR/IntrinsicImpl.inc"
1483#undef GET_LLVM_INTRINSIC_FOR_MS_BUILTIN
1486 std::pair<Type *, ArrayRef<Intrinsic::IITDescriptor>>;
1492 bool IsDeferredCheck) {
1493 using namespace Intrinsic;
1496 if (Infos.
empty())
return true;
1499 auto InfosRef = Infos;
1500 auto DeferCheck = [&DeferredChecks, &InfosRef](
Type *
T) {
1505 IITDescriptor
D = Infos.
front();
1506 Infos = Infos.
slice(1);
1509 case IITDescriptor::Void:
return !Ty->
isVoidTy();
1510 case IITDescriptor::VarArg:
return true;
1511 case IITDescriptor::MMX:
return !Ty->
isX86_MMXTy();
1512 case IITDescriptor::AMX:
return !Ty->
isX86_AMXTy();
1513 case IITDescriptor::Token:
return !Ty->
isTokenTy();
1514 case IITDescriptor::Metadata:
return !Ty->
isMetadataTy();
1515 case IITDescriptor::Half:
return !Ty->
isHalfTy();
1516 case IITDescriptor::BFloat:
return !Ty->
isBFloatTy();
1517 case IITDescriptor::Float:
return !Ty->
isFloatTy();
1518 case IITDescriptor::Double:
return !Ty->
isDoubleTy();
1519 case IITDescriptor::Quad:
return !Ty->
isFP128Ty();
1521 case IITDescriptor::Integer:
return !Ty->
isIntegerTy(
D.Integer_Width);
1522 case IITDescriptor::AArch64Svcount:
1523 return !isa<TargetExtType>(Ty) ||
1524 cast<TargetExtType>(Ty)->getName() !=
"aarch64.svcount";
1525 case IITDescriptor::Vector: {
1527 return !VT || VT->getElementCount() !=
D.Vector_Width ||
1529 DeferredChecks, IsDeferredCheck);
1531 case IITDescriptor::Pointer: {
1533 if (!PT || PT->getAddressSpace() !=
D.Pointer_AddressSpace)
1535 if (!PT->isOpaque()) {
1540 if (Infos.
front().Kind == IITDescriptor::Struct &&
1541 Infos.
front().Struct_NumElements == 0) {
1542 Infos = Infos.
slice(1);
1546 ArgTys, DeferredChecks, IsDeferredCheck);
1552 while (Infos.
front().Kind == IITDescriptor::Pointer ||
1553 Infos.
front().Kind == IITDescriptor::Vector)
1554 Infos = Infos.
slice(1);
1555 assert((Infos.
front().Kind != IITDescriptor::Argument ||
1556 Infos.
front().getArgumentKind() == IITDescriptor::AK_MatchType) &&
1557 "Unsupported polymorphic pointer type with opaque pointer");
1558 Infos = Infos.
slice(1);
1562 case IITDescriptor::Struct: {
1564 if (!ST || !ST->isLiteral() || ST->isPacked() ||
1565 ST->getNumElements() !=
D.Struct_NumElements)
1568 for (
unsigned i = 0, e =
D.Struct_NumElements; i != e; ++i)
1570 DeferredChecks, IsDeferredCheck))
1575 case IITDescriptor::Argument:
1578 if (
D.getArgumentNumber() < ArgTys.
size())
1579 return Ty != ArgTys[
D.getArgumentNumber()];
1581 if (
D.getArgumentNumber() > ArgTys.
size() ||
1582 D.getArgumentKind() == IITDescriptor::AK_MatchType)
1583 return IsDeferredCheck || DeferCheck(Ty);
1585 assert(
D.getArgumentNumber() == ArgTys.
size() && !IsDeferredCheck &&
1586 "Table consistency error");
1589 switch (
D.getArgumentKind()) {
1590 case IITDescriptor::AK_Any:
return false;
1593 case IITDescriptor::AK_AnyVector:
return !isa<VectorType>(Ty);
1594 case IITDescriptor::AK_AnyPointer:
return !isa<PointerType>(Ty);
1599 case IITDescriptor::ExtendArgument: {
1601 if (
D.getArgumentNumber() >= ArgTys.
size())
1602 return IsDeferredCheck || DeferCheck(Ty);
1604 Type *NewTy = ArgTys[
D.getArgumentNumber()];
1605 if (
VectorType *VTy = dyn_cast<VectorType>(NewTy))
1607 else if (
IntegerType *ITy = dyn_cast<IntegerType>(NewTy))
1614 case IITDescriptor::TruncArgument: {
1616 if (
D.getArgumentNumber() >= ArgTys.
size())
1617 return IsDeferredCheck || DeferCheck(Ty);
1619 Type *NewTy = ArgTys[
D.getArgumentNumber()];
1620 if (
VectorType *VTy = dyn_cast<VectorType>(NewTy))
1622 else if (
IntegerType *ITy = dyn_cast<IntegerType>(NewTy))
1629 case IITDescriptor::HalfVecArgument:
1631 if (
D.getArgumentNumber() >= ArgTys.
size())
1632 return IsDeferredCheck || DeferCheck(Ty);
1633 return !isa<VectorType>(ArgTys[
D.getArgumentNumber()]) ||
1635 cast<VectorType>(ArgTys[
D.getArgumentNumber()])) != Ty;
1636 case IITDescriptor::SameVecWidthArgument: {
1637 if (
D.getArgumentNumber() >= ArgTys.
size()) {
1639 Infos = Infos.
slice(1);
1640 return IsDeferredCheck || DeferCheck(Ty);
1642 auto *
ReferenceType = dyn_cast<VectorType>(ArgTys[
D.getArgumentNumber()]);
1643 auto *ThisArgType = dyn_cast<VectorType>(Ty);
1650 ThisArgType->getElementCount())
1652 EltTy = ThisArgType->getElementType();
1657 case IITDescriptor::PtrToArgument: {
1658 if (
D.getArgumentNumber() >= ArgTys.
size())
1659 return IsDeferredCheck || DeferCheck(Ty);
1661 PointerType *ThisArgType = dyn_cast<PointerType>(Ty);
1662 return (!ThisArgType ||
1665 case IITDescriptor::PtrToElt: {
1666 if (
D.getArgumentNumber() >= ArgTys.
size())
1667 return IsDeferredCheck || DeferCheck(Ty);
1669 dyn_cast<VectorType> (ArgTys[
D.getArgumentNumber()]);
1670 PointerType *ThisArgType = dyn_cast<PointerType>(Ty);
1674 return !ThisArgType->isOpaqueOrPointeeTypeMatches(
1677 case IITDescriptor::AnyPtrToElt: {
1678 unsigned RefArgNumber =
D.getRefArgNumber();
1679 if (RefArgNumber >= ArgTys.
size()) {
1680 if (IsDeferredCheck)
1685 return DeferCheck(Ty);
1688 if (!IsDeferredCheck) {
1689 assert(
D.getOverloadArgNumber() == ArgTys.
size() &&
1690 "Table consistency error");
1694 auto *
ReferenceType = dyn_cast<VectorType>(ArgTys[RefArgNumber]);
1695 auto *ThisArgType = dyn_cast<PointerType>(Ty);
1698 return !ThisArgType->isOpaqueOrPointeeTypeMatches(
1701 case IITDescriptor::VecOfAnyPtrsToElt: {
1702 unsigned RefArgNumber =
D.getRefArgNumber();
1703 if (RefArgNumber >= ArgTys.
size()) {
1704 if (IsDeferredCheck)
1709 return DeferCheck(Ty);
1712 if (!IsDeferredCheck){
1713 assert(
D.getOverloadArgNumber() == ArgTys.
size() &&
1714 "Table consistency error");
1721 auto *
ReferenceType = dyn_cast<VectorType>(ArgTys[RefArgNumber]);
1722 auto *ThisArgVecTy = dyn_cast<VectorType>(Ty);
1724 (
ReferenceType->getElementCount() != ThisArgVecTy->getElementCount()))
1727 dyn_cast<PointerType>(ThisArgVecTy->getElementType());
1730 return !ThisArgEltTy->isOpaqueOrPointeeTypeMatches(
1733 case IITDescriptor::VecElementArgument: {
1734 if (
D.getArgumentNumber() >= ArgTys.
size())
1735 return IsDeferredCheck ?
true : DeferCheck(Ty);
1736 auto *
ReferenceType = dyn_cast<VectorType>(ArgTys[
D.getArgumentNumber()]);
1739 case IITDescriptor::Subdivide2Argument:
1740 case IITDescriptor::Subdivide4Argument: {
1742 if (
D.getArgumentNumber() >= ArgTys.
size())
1743 return IsDeferredCheck || DeferCheck(Ty);
1745 Type *NewTy = ArgTys[
D.getArgumentNumber()];
1746 if (
auto *VTy = dyn_cast<VectorType>(NewTy)) {
1747 int SubDivs =
D.Kind == IITDescriptor::Subdivide2Argument ? 1 : 2;
1753 case IITDescriptor::VecOfBitcastsToInt: {
1754 if (
D.getArgumentNumber() >= ArgTys.
size())
1755 return IsDeferredCheck || DeferCheck(Ty);
1756 auto *
ReferenceType = dyn_cast<VectorType>(ArgTys[
D.getArgumentNumber()]);
1757 auto *ThisArgVecTy = dyn_cast<VectorType>(Ty);
1775 unsigned NumDeferredReturnChecks = DeferredChecks.
size();
1777 for (
auto *Ty : FTy->
params())
1781 for (
unsigned I = 0,
E = DeferredChecks.
size();
I !=
E; ++
I) {
1800 if (Infos.
size() != 1)
1805 Infos = Infos.
slice(1);
1806 if (
D.Kind == IITDescriptor::VarArg)
1836 return std::nullopt;
1840 std::string WantedName =
1842 if (
Name == WantedName)
1843 return std::nullopt;
1846 if (
auto *ExistingGV =
F->getParent()->getNamedValue(WantedName)) {
1847 if (
auto *ExistingF = dyn_cast<Function>(ExistingGV))
1848 if (ExistingF->getFunctionType() ==
F->getFunctionType())
1855 ExistingGV->
setName(WantedName +
".renamed");
1862 "Shouldn't change the signature");
1871 bool IgnoreCallbackUses,
1872 bool IgnoreAssumeLikeCalls,
bool IgnoreLLVMUsed,
1873 bool IgnoreARCAttachedCall)
const {
1875 const User *FU = U.getUser();
1876 if (isa<BlockAddress>(FU))
1879 if (IgnoreCallbackUses) {
1885 const auto *Call = dyn_cast<CallBase>(FU);
1887 if (IgnoreAssumeLikeCalls &&
1888 isa<BitCastOperator, AddrSpaceCastOperator>(FU) &&
1890 if (const auto *I = dyn_cast<IntrinsicInst>(U))
1891 return I->isAssumeLikeIntrinsic();
1898 const User *FUU = FU;
1899 if (isa<BitCastOperator, AddrSpaceCastOperator>(FU) &&
1903 if (const auto *GV = dyn_cast<GlobalVariable>(U))
1904 return GV->hasName() &&
1905 (GV->getName().equals(
"llvm.compiler.used") ||
1906 GV->getName().equals(
"llvm.used"));
1916 if (IgnoreAssumeLikeCalls) {
1917 if (
const auto *
I = dyn_cast<IntrinsicInst>(Call))
1918 if (
I->isAssumeLikeIntrinsic())
1922 if (!Call->isCallee(&U) || Call->getFunctionType() !=
getFunctionType()) {
1923 if (IgnoreARCAttachedCall &&
1944 if (!isa<BlockAddress>(U))
1954 if (
const auto *Call = dyn_cast<CallBase>(&
I))
1955 if (Call->hasFnAttr(Attribute::ReturnsTwice))
1963 return cast<Constant>(Op<0>());
1967 setHungoffOperand<0>(Fn);
1968 setValueSubclassDataBit(3, Fn !=
nullptr);
1973 return cast<Constant>(Op<1>());
1977 setHungoffOperand<1>(PrefixData);
1978 setValueSubclassDataBit(1, PrefixData !=
nullptr);
1983 return cast<Constant>(Op<2>());
1987 setHungoffOperand<2>(PrologueData);
1988 setValueSubclassDataBit(2, PrologueData !=
nullptr);
1991void Function::allocHungoffUselist() {
2007void Function::setHungoffOperand(
Constant *
C) {
2009 allocHungoffUselist();
2017void Function::setValueSubclassDataBit(
unsigned Bit,
bool On) {
2018 assert(Bit < 16 &&
"SubclassData contains only 16 bits");
2029 assert(!PrevCount || PrevCount->getType() == Count.
getType());
2033 if (S ==
nullptr && ImportGUIDs.
size())
2038 LLVMContext::MD_prof,
2051 if (MDS->getString().equals(
"function_entry_count")) {
2057 return std::nullopt;
2059 }
else if (AllowSynthetic &&
2060 MDS->getString().equals(
"synthetic_function_entry_count")) {
2066 return std::nullopt;
2072 if (
MDString *MDS = dyn_cast<MDString>(MD->getOperand(0)))
2073 if (MDS->getString().equals(
"function_entry_count"))
2074 for (
unsigned i = 2; i < MD->getNumOperands(); i++)
2075 R.insert(mdconst::extract<ConstantInt>(MD->getOperand(i))
2089 assert(cast<MDString>(MD->getOperand(0))
2091 .equals(
"function_section_prefix") &&
2092 "Metadata not match");
2093 return cast<MDString>(MD->getOperand(1))->getString();
2095 return std::nullopt;
2103 if (
F &&
F->nullPointerIsDefined())
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file contains the simple types necessary to represent the attributes associated with functions a...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Analysis containing CSE Info
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
This file defines the DenseSet and SmallDenseSet classes.
static Type * getMemoryParamAllocType(AttributeSet ParamAttrs)
For a byval, sret, inalloca, or preallocated parameter, get the in-memory parameter type.
static cl::opt< unsigned > NonGlobalValueMaxNameSize("non-global-value-max-name-size", cl::Hidden, cl::init(1024), cl::desc("Maximum size for the name of non-global values."))
static bool matchIntrinsicType(Type *Ty, ArrayRef< Intrinsic::IITDescriptor > &Infos, SmallVectorImpl< Type * > &ArgTys, SmallVectorImpl< DeferredIntrinsicMatchPair > &DeferredChecks, bool IsDeferredCheck)
static std::string getIntrinsicNameImpl(Intrinsic::ID Id, ArrayRef< Type * > Tys, Module *M, FunctionType *FT, bool EarlyModuleCheck)
static MutableArrayRef< Argument > makeArgArray(Argument *Args, size_t Count)
std::pair< Type *, ArrayRef< Intrinsic::IITDescriptor > > DeferredIntrinsicMatchPair
static ArrayRef< const char * > findTargetSubtable(StringRef Name)
Find the segment of IntrinsicNameTable for intrinsics with the same target as Name,...
static void DecodeIITType(unsigned &NextElt, ArrayRef< unsigned char > Infos, IIT_Info LastInfo, SmallVectorImpl< Intrinsic::IITDescriptor > &OutputTable)
IIT_Info
IIT_Info - These are enumerators that describe the entries returned by the getIntrinsicInfoTableEntri...
static Type * DecodeFixedType(ArrayRef< Intrinsic::IITDescriptor > &Infos, ArrayRef< Type * > Tys, LLVMContext &Context)
static const char *const IntrinsicNameTable[]
Table of string intrinsic names indexed by enum value.
static std::string getMangledTypeStr(Type *Ty, bool &HasUnnamedType)
Returns a stable mangling for the type specified for use in the name mangling scheme used by 'any' ty...
static unsigned computeAddrSpace(unsigned AddrSpace, Module *M)
Module.h This file contains the declarations for the Module class.
print must be executed print the must be executed context for all instructions
static StringRef getName(Value *V)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallString class.
This file defines the SmallVector class.
static SymbolRef::Type getType(const Symbol *Sym)
This defines the Use class.
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type.
uint64_t getZExtValue() const
Get zero extended value.
bool isCallbackCall() const
Return true if this ACS represents a callback call.
This class represents an incoming formal argument to a Function.
Type * getParamByRefType() const
If this is a byref argument, return its type.
Attribute getAttribute(Attribute::AttrKind Kind) const
bool hasNoAliasAttr() const
Return true if this argument has the noalias attribute.
bool hasNonNullAttr(bool AllowUndefOrPoison=true) const
Return true if this argument has the nonnull attribute.
bool hasByRefAttr() const
Return true if this argument has the byref attribute.
uint64_t getDereferenceableOrNullBytes() const
If this argument has the dereferenceable_or_null attribute, return the number of bytes known to be de...
void addAttr(Attribute::AttrKind Kind)
Argument(Type *Ty, const Twine &Name="", Function *F=nullptr, unsigned ArgNo=0)
Argument constructor.
bool onlyReadsMemory() const
Return true if this argument has the readonly or readnone attribute.
bool hasPointeeInMemoryValueAttr() const
Return true if this argument has the byval, sret, inalloca, preallocated, or byref attribute.
bool hasAttribute(Attribute::AttrKind Kind) const
Check if an argument has a given attribute.
bool hasReturnedAttr() const
Return true if this argument has the returned attribute.
Type * getParamStructRetType() const
If this is an sret argument, return its type.
bool hasInRegAttr() const
Return true if this argument has the inreg attribute.
bool hasByValAttr() const
Return true if this argument has the byval attribute.
bool hasPreallocatedAttr() const
Return true if this argument has the preallocated attribute.
bool hasSExtAttr() const
Return true if this argument has the sext attribute.
void removeAttr(Attribute::AttrKind Kind)
Remove attributes from an argument.
uint64_t getPassPointeeByValueCopySize(const DataLayout &DL) const
If this argument satisfies has hasPassPointeeByValueAttr, return the in-memory ABI size copied to the...
void removeAttrs(const AttributeMask &AM)
const Function * getParent() const
Type * getPointeeInMemoryValueType() const
If hasPointeeInMemoryValueAttr returns true, the in-memory ABI type is returned.
bool hasInAllocaAttr() const
Return true if this argument has the inalloca attribute.
bool hasSwiftErrorAttr() const
Return true if this argument has the swifterror attribute.
FPClassTest getNoFPClass() const
If this argument has nofpclass attribute, return the mask representing disallowed floating-point valu...
void addAttrs(AttrBuilder &B)
Add attributes to an argument.
bool hasNoFreeAttr() const
Return true if this argument has the nofree attribute.
bool hasSwiftSelfAttr() const
Return true if this argument has the swiftself attribute.
Type * getParamInAllocaType() const
If this is an inalloca argument, return its type.
bool hasZExtAttr() const
Return true if this argument has the zext attribute.
unsigned getArgNo() const
Return the index of this formal argument in its containing function.
Type * getParamByValType() const
If this is a byval argument, return its type.
bool hasNestAttr() const
Return true if this argument has the nest attribute.
MaybeAlign getParamAlign() const
If this is a byval or inalloca argument, return its alignment.
bool hasStructRetAttr() const
Return true if this argument has the sret attribute.
bool hasPassPointeeByValueCopyAttr() const
Return true if this argument has the byval, inalloca, or preallocated attribute.
MaybeAlign getParamStackAlign() const
bool hasNoCaptureAttr() const
Return true if this argument has the nocapture attribute.
uint64_t getDereferenceableBytes() const
If this argument has the dereferenceable attribute, return the number of bytes known to be dereferenc...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
const T & front() const
front - Get the first element.
size_t size() const
size - Get the array size.
bool empty() const
empty - Check if the array is empty.
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
AttributeList addDereferenceableParamAttr(LLVMContext &C, unsigned ArgNo, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given arg index.
AttributeList removeAttributeAtIndex(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Remove the specified attribute at the specified index from this attribute list.
AttributeList removeParamAttributes(LLVMContext &C, unsigned ArgNo, const AttributeMask &AttrsToRemove) const
Remove the specified attribute at the specified arg index from this attribute list.
AttributeList addRetAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add a return value attribute to the list.
AttributeList addRetAttributes(LLVMContext &C, const AttrBuilder &B) const
Add a return value attribute to the list.
AttributeList removeRetAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const
Remove the specified attribute at the return value index from this attribute list.
Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Return the attribute object that exists at the arg index.
AttributeList addFnAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add a function attribute to the list.
AttributeList addFnAttributes(LLVMContext &C, const AttrBuilder &B) const
Add function attribute to the list.
bool hasFnAttr(Attribute::AttrKind Kind) const
Return true if the attribute exists for the function.
Attribute getFnAttr(Attribute::AttrKind Kind) const
Return the attribute object that exists for the function.
Attribute getAttributeAtIndex(unsigned Index, Attribute::AttrKind Kind) const
Return the attribute object that exists at the given index.
AttributeList removeParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Remove the specified attribute at the specified arg index from this attribute list.
bool hasParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Return true if the attribute exists for the given argument.
AttributeList removeFnAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Remove the specified attribute at the function index from this attribute list.
AttributeList addDereferenceableOrNullParamAttr(LLVMContext &C, unsigned ArgNo, uint64_t Bytes) const
Add the dereferenceable_or_null attribute to the attribute set at the given arg index.
AttributeList removeFnAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const
Remove the specified attribute at the function index from this attribute list.
AttributeList addAttributeAtIndex(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Add an attribute to the attribute set at the given index.
AttributeSet getParamAttrs(unsigned ArgNo) const
The attributes for the argument or parameter at the given index are returned.
AttributeList addParamAttributes(LLVMContext &C, unsigned ArgNo, const AttrBuilder &B) const
Add an argument attribute to the list.
AttributeList removeRetAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Remove the specified attribute at the return value index from this attribute list.
AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Add an argument attribute to the list.
MemoryEffects getMemoryEffects() const
Returns memory effects of the function.
bool hasRetAttr(Attribute::AttrKind Kind) const
Return true if the attribute exists for the return value.
Type * getInAllocaType() const
Type * getByValType() const
Type * getStructRetType() const
Type * getPreallocatedType() const
Type * getByRefType() const
StringRef getValueAsString() const
Return the attribute's value as a string.
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
static Attribute getWithMemoryEffects(LLVMContext &Context, MemoryEffects ME)
bool isValid() const
Return true if the attribute is any kind of attribute.
LLVM Basic Block Representation.
void dropAllReferences()
Cause all subinstructions to "let go" of all the references that said subinstructions are maintaining...
This is the shared class of boolean and integer constants.
const APInt & getValue() const
Return the constant as an APInt value reference.
static ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
This is an important base class in LLVM.
A parsed version of the target data layout string in and methods for querying it.
Implements a dense probed hash-table based set.
Class to represent function types.
ArrayRef< Type * > params() const
Type * getReturnType() const
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
Class to represent profile counts.
uint64_t getCount() const
ProfileCountType getType() const
void addFnAttr(Attribute::AttrKind Kind)
Add function attributes to this function.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
void addParamAttrs(unsigned ArgNo, const AttrBuilder &Attrs)
adds the attributes to the list of attributes for the given arg.
void removeRetAttr(Attribute::AttrKind Kind)
removes the attribute from the return value list of attributes.
void addRetAttrs(const AttrBuilder &Attrs)
Add return value attributes to this function.
std::optional< StringRef > getSectionPrefix() const
Get the section prefix for this function.
bool isDefTriviallyDead() const
isDefTriviallyDead - Return true if it is trivially safe to remove this function definition from the ...
bool onlyAccessesInaccessibleMemOrArgMem() const
Determine if the function may only access memory that is either inaccessible from the IR or pointed t...
void splice(Function::iterator ToIt, Function *FromF)
Transfer all blocks from FromF to this function at ToIt.
BasicBlockListType::iterator iterator
void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
removes the attribute from the list of attributes.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
bool nullPointerIsDefined() const
Check if null pointer dereferencing is considered undefined behavior for the function.
void dropAllReferences()
dropAllReferences() - This method causes all the subinstructions to "let go" of all references that t...
Attribute getParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const
gets the specified attribute from the list of attributes.
void setPrefixData(Constant *PrefixData)
bool hasStackProtectorFnAttr() const
Returns true if the function has ssp, sspstrong, or sspreq fn attrs.
void removeFromParent()
removeFromParent - This method unlinks 'this' from the containing module, but does not delete it.
void addFnAttrs(const AttrBuilder &Attrs)
Add function attributes to this function.
void setDoesNotAccessMemory()
static Intrinsic::ID lookupIntrinsicID(StringRef Name)
This does the actual lookup of an intrinsic ID which matches the given function name.
void setGC(std::string Str)
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
uint64_t getFnAttributeAsParsedInteger(StringRef Kind, uint64_t Default=0) const
For a string attribute Kind, parse attribute as an integer.
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
bool isConstrainedFPIntrinsic() const
Returns true if the function is one of the "Constrained Floating-Point Intrinsics".
void setOnlyAccessesArgMemory()
MemoryEffects getMemoryEffects() const
void setOnlyAccessesInaccessibleMemory()
void removeParamAttrs(unsigned ArgNo, const AttributeMask &Attrs)
removes the attribute from the list of attributes.
void setIsMaterializable(bool V)
uint64_t getParamDereferenceableBytes(unsigned ArgNo) const
Extract the number of dereferenceable bytes for a parameter.
bool hasParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const
check if an attributes is in the list of attributes.
void recalculateIntrinsicID()
Recalculate the ID for this function if it is an Intrinsic defined in llvm/Intrinsics....
static Function * createWithDefaultAttr(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
Creates a function with some attributes recorded in llvm.module.flags applied.
bool hasGC() const
hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm to use during code generatio...
void setSectionPrefix(StringRef Prefix)
Set the section prefix for this function.
void setOnlyReadsMemory()
bool isTargetIntrinsic() const
isTargetIntrinsic - Returns true if this function is an intrinsic and the intrinsic is specific to a ...
Type * getParamByValType(unsigned ArgNo) const
Extract the byval type for a parameter.
FPClassTest getParamNoFPClass(unsigned ArgNo) const
Extract the nofpclass attribute for a parameter.
void removeFnAttrs(const AttributeMask &Attrs)
DenormalMode getDenormalModeRaw() const
Return the representational value of "denormal-fp-math".
bool hasPrefixData() const
Check whether this function has prefix data.
bool hasPersonalityFn() const
Check whether this function has a personality function.
void addRetAttr(Attribute::AttrKind Kind)
Add return value attributes to this function.
DenormalMode getDenormalModeF32Raw() const
Return the representational value of "denormal-fp-math-f32".
Constant * getPrologueData() const
Get the prologue data associated with this function.
Constant * getPersonalityFn() const
Get the personality function associated with this function.
void setOnlyWritesMemory()
void setPersonalityFn(Constant *Fn)
AttributeList getAttributes() const
Return the attribute list for this Function.
DenseSet< GlobalValue::GUID > getImportGUIDs() const
Returns the set of GUIDs that needs to be imported to the function for sample PGO,...
Type * getParamByRefType(unsigned ArgNo) const
Extract the byref type for a parameter.
void removeAttributeAtIndex(unsigned i, Attribute::AttrKind Kind)
removes the attribute from the list of attributes.
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const
Extract the number of dereferenceable_or_null bytes for a parameter.
void removeFnAttr(Attribute::AttrKind Kind)
Remove function attributes from this function.
void addDereferenceableOrNullParamAttr(unsigned ArgNo, uint64_t Bytes)
adds the dereferenceable_or_null attribute to the list of attributes for the given arg.
MaybeAlign getParamAlign(unsigned ArgNo) const
void stealArgumentListFrom(Function &Src)
Steal arguments from another function.
void setAttributes(AttributeList Attrs)
Set the attribute list for this Function.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
const std::string & getGC() const
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
adds the attribute to the list of attributes for the given arg.
bool doesNotAccessMemory() const
Determine if the function does not access memory.
DenormalMode getDenormalMode(const fltSemantics &FPType) const
Returns the denormal handling type for the default rounding mode of the function.
Type * getParamInAllocaType(unsigned ArgNo) const
Extract the inalloca type for a parameter.
bool callsFunctionThatReturnsTwice() const
callsFunctionThatReturnsTwice - Return true if the function has a call to setjmp or other function th...
bool hasRetAttribute(Attribute::AttrKind Kind) const
check if an attribute is in the list of attributes for the return value.
bool onlyWritesMemory() const
Determine if the function does not access or only writes memory.
std::optional< ProfileCount > getEntryCount(bool AllowSynthetic=false) const
Get the entry count for this function.
bool onlyAccessesInaccessibleMemory() const
Determine if the function may only access memory that is inaccessible from the IR.
MaybeAlign getParamStackAlign(unsigned ArgNo) const
void setPrologueData(Constant *PrologueData)
bool hasAddressTaken(const User **=nullptr, bool IgnoreCallbackUses=false, bool IgnoreAssumeLikeCalls=true, bool IngoreLLVMUsed=false, bool IgnoreARCAttachedCall=false) const
hasAddressTaken - returns true if there are any uses of this function other than direct calls or invo...
void removeRetAttrs(const AttributeMask &Attrs)
removes the attributes from the return value list of attributes.
bool hasLazyArguments() const
hasLazyArguments/CheckLazyArguments - The argument list of a function is built on demand,...
bool onlyAccessesArgMemory() const
Determine if the call can access memmory only using pointers based on its arguments.
Function::iterator erase(Function::iterator FromIt, Function::iterator ToIt)
Erases a range of BasicBlocks from FromIt to (not including) ToIt.
void setMemoryEffects(MemoryEffects ME)
Constant * getPrefixData() const
Get the prefix data associated with this function.
Attribute getAttributeAtIndex(unsigned i, Attribute::AttrKind Kind) const
gets the attribute from the list of attributes.
void setCallingConv(CallingConv::ID CC)
void setOnlyAccessesInaccessibleMemOrArgMem()
bool hasPrologueData() const
Check whether this function has prologue data.
Type * getParamStructRetType(unsigned ArgNo) const
Extract the sret type for a parameter.
void setEntryCount(ProfileCount Count, const DenseSet< GlobalValue::GUID > *Imports=nullptr)
Set the entry count for this function.
void addDereferenceableParamAttr(unsigned ArgNo, uint64_t Bytes)
adds the dereferenceable attribute to the list of attributes for the given arg.
unsigned getInstructionCount() const
Returns the number of non-debug IR instructions in this function.
bool onlyReadsMemory() const
Determine if the function does not access or only reads memory.
void addAttributeAtIndex(unsigned i, Attribute Attr)
adds the attribute to the list of attributes.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
void copyAttributesFrom(const Function *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a Function) from the ...
void setMetadata(unsigned KindID, MDNode *Node)
Set a particular kind of metadata attachment.
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
void copyAttributesFrom(const GlobalObject *Src)
void clearMetadata()
Erase all metadata attached to this Value.
bool hasLinkOnceLinkage() const
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
bool hasLocalLinkage() const
Intrinsic::ID IntID
The intrinsic ID for this subclass (which must be a Function).
unsigned HasLLVMReservedName
True if the function's name starts with "llvm.".
Module * getParent()
Get the module that this global value is contained inside of...
PointerType * getType() const
Global values are always pointers.
bool hasAvailableExternallyLinkage() const
LinkageTypes
An enumeration for the kinds of linkage for global values.
Class to represent integer types.
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
This is an important class for using LLVM in a threaded context.
void deleteGC(const Function &Fn)
Remove the GC for a function.
const std::string & getGC(const Function &Fn)
Return the GC for a function.
@ OB_clang_arc_attachedcall
void setGC(const Function &Fn, std::string GCName)
Define the GC for a function.
void emitError(uint64_t LocCookie, const Twine &ErrorStr)
emitError - Emit an error message to the currently installed error handler with optional location inf...
MDNode * createFunctionEntryCount(uint64_t Count, bool Synthetic, const DenseSet< GlobalValue::GUID > *Imports)
Return metadata containing the entry Count for a function, a boolean \Synthetic indicating whether th...
MDNode * createFunctionSectionPrefix(StringRef Prefix)
Return metadata containing the section prefix for a function.
const MDOperand & getOperand(unsigned I) const
Summary of how a function affects memory in the program.
bool onlyAccessesArgPointees() const
Whether this function only (at most) accesses argument memory.
static MemoryEffects writeOnly()
Create MemoryEffects that can write any memory.
static MemoryEffects readOnly()
Create MemoryEffects that can read any memory.
static MemoryEffects inaccessibleMemOnly(ModRefInfo MR=ModRefInfo::ModRef)
Create MemoryEffects that can only access inaccessible memory.
bool onlyReadsMemory() const
Whether this function only (at most) reads memory.
bool onlyWritesMemory() const
Whether this function only (at most) writes memory.
static MemoryEffects inaccessibleOrArgMemOnly(ModRefInfo MR=ModRefInfo::ModRef)
Create MemoryEffects that can only access inaccessible or argument memory.
bool onlyAccessesInaccessibleMem() const
Whether this function only (at most) accesses inaccessible memory.
bool doesNotAccessMemory() const
Whether this function accesses no memory.
bool onlyAccessesInaccessibleOrArgMem() const
Whether this function only (at most) accesses argument and inaccessible memory.
static MemoryEffects none()
Create MemoryEffects that cannot read or write any memory.
static MemoryEffects argMemOnly(ModRefInfo MR=ModRefInfo::ModRef)
Create MemoryEffects that can only access argument memory.
A Module instance is used to store all the information related to an LLVM module.
const FunctionListType & getFunctionList() const
Get the Module's list of functions (constant).
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
reference emplace_back(ArgTypes &&... Args)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
bool startswith(StringRef Prefix) const
Class to represent struct types.
static StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
Class to represent target extensions types, which are generally unintrospectable from target-independ...
static TargetExtType * get(LLVMContext &Context, StringRef Name, ArrayRef< Type * > Types=std::nullopt, ArrayRef< unsigned > Ints=std::nullopt)
Return a target extension type having the specified name and optional type and integer parameters.
Target - Wrapper for Target specific information.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
static Type * getHalfTy(LLVMContext &C)
static Type * getDoubleTy(LLVMContext &C)
static PointerType * getInt1PtrTy(LLVMContext &C, unsigned AS=0)
static Type * getBFloatTy(LLVMContext &C)
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
static Type * getX86_AMXTy(LLVMContext &C)
bool isBFloatTy() const
Return true if this is 'bfloat', a 16-bit bfloat type.
static Type * getMetadataTy(LLVMContext &C)
@ X86_MMXTyID
MMX vectors (64 bits, X86 specific)
@ X86_AMXTyID
AMX vectors (8192 bits, X86 specific)
@ HalfTyID
16-bit floating point type
@ VoidTyID
type with no size
@ FloatTyID
32-bit floating point type
@ IntegerTyID
Arbitrary bit width integers.
@ BFloatTyID
16-bit floating point type (7-bit significand)
@ DoubleTyID
64-bit floating point type
@ X86_FP80TyID
80-bit floating point type (X87)
@ PPC_FP128TyID
128-bit floating point type (two 64-bits, PowerPC)
@ FP128TyID
128-bit floating point type (112-bit significand)
bool isX86_MMXTy() const
Return true if this is X86 MMX.
bool isPPC_FP128Ty() const
Return true if this is powerpc long double.
static Type * getX86_MMXTy(LLVMContext &C)
bool isFP128Ty() const
Return true if this is 'fp128'.
static Type * getVoidTy(LLVMContext &C)
static Type * getFP128Ty(LLVMContext &C)
bool isHalfTy() const
Return true if this is 'half', a 16-bit IEEE fp type.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
static Type * getTokenTy(LLVMContext &C)
bool isX86_AMXTy() const
Return true if this is X86 AMX.
static Type * getFloatTy(LLVMContext &C)
bool isIntegerTy() const
True if this is an instance of IntegerType.
TypeID getTypeID() const
Return the type id for the type.
bool isTokenTy() const
Return true if this is 'token'.
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
static Type * getPPC_FP128Ty(LLVMContext &C)
bool isVoidTy() const
Return true if this is 'void'.
bool isMetadataTy() const
Return true if this is 'metadata'.
A Use represents the edge between a Value definition and its users.
void allocHungoffUses(unsigned N, bool IsPhi=false)
Allocate the array of Uses, followed by a pointer (with bottom bit set) to the User.
void dropAllReferences()
Drop all references to operands.
void setNumHungOffUseOperands(unsigned NumOps)
Subclasses with hung off uses need to manage the operand count themselves.
unsigned getNumOperands() const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
unsigned short getSubclassDataFromValue() const
user_iterator user_begin()
void setName(const Twine &Name)
Change the name of the value.
bool hasOneUse() const
Return true if there is exactly one use of this value.
iterator_range< user_iterator > users()
iterator_range< use_iterator > uses()
StringRef getName() const
Return a constant reference to the value's name.
static VectorType * getHalfElementsVectorType(VectorType *VTy)
This static method returns a VectorType with half as many elements as the input type and the same ele...
static VectorType * getExtendedElementVectorType(VectorType *VTy)
This static method is like getInteger except that the element types are twice as wide as the elements...
static VectorType * getSubdividedVectorType(VectorType *VTy, int NumSubdivs)
static VectorType * getInteger(VectorType *VTy)
This static method gets a VectorType with the same number of elements as the input type,...
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
static VectorType * getTruncatedElementVectorType(VectorType *VTy)
self_iterator getIterator()
void splice(iterator where, iplist_impl &L2)
void push_back(pointer val)
iterator erase(iterator where)
pointer remove(iterator &IT)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type * > Tys=std::nullopt)
Return the function type for an intrinsic.
MatchIntrinsicTypesResult matchIntrinsicSignature(FunctionType *FTy, ArrayRef< IITDescriptor > &Infos, SmallVectorImpl< Type * > &ArgTys)
Match the specified function type with the type constraints specified by the .td file.
void getIntrinsicInfoTableEntries(ID id, SmallVectorImpl< IITDescriptor > &T)
Return the IIT table descriptor for the specified intrinsic into an array of IITDescriptors.
MatchIntrinsicTypesResult
@ MatchIntrinsicTypes_Match
@ MatchIntrinsicTypes_NoMatchRet
@ MatchIntrinsicTypes_NoMatchArg
int lookupLLVMIntrinsicByName(ArrayRef< const char * > NameTable, StringRef Name)
Looks up Name in NameTable via binary search.
std::string getNameNoUnnamedTypes(ID Id, ArrayRef< Type * > Tys)
Return the LLVM name for an intrinsic.
std::optional< Function * > remangleIntrinsicFunction(Function *F)
StringRef getName(ID id)
Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
bool getIntrinsicSignature(Function *F, SmallVectorImpl< Type * > &ArgTys)
Gets the type arguments of an intrinsic call by matching type contraints specified by the ....
AttributeList getAttributes(LLVMContext &C, ID id)
Return the attributes for an intrinsic.
StringRef getBaseName(ID id)
Return the LLVM name for an intrinsic, without encoded types for overloading, such as "llvm....
bool isOverloaded(ID id)
Returns true if the intrinsic can be overloaded.
Function * getDeclaration(Module *M, ID id, ArrayRef< Type * > Tys=std::nullopt)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
bool matchIntrinsicVarArg(bool isVarArg, ArrayRef< IITDescriptor > &Infos)
Verify if the intrinsic has variable arguments.
initializer< Ty > init(const Ty &Val)
Linkage
Describes symbol linkage. This can be used to resolve definition clashes.
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
auto partition_point(R &&Range, Predicate P)
Binary search for the first iterator in a range where a predicate is false.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
@ None
No unwind table requested.
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
bool NullPointerIsDefined(const Function *F, unsigned AS=0)
Check whether null pointer dereferencing is considered undefined behavior for a given function or an ...
DenormalMode parseDenormalFPAttribute(StringRef Str)
Returns the denormal mode to use for inputs and outputs.
@ Default
The result values are uniform if and only if all operands are uniform.
static const fltSemantics & IEEEsingle() LLVM_READNONE
Helper struct shared between Function Specialization and SCCP Solver.
Represent subnormal handling kind for floating point instruction inputs and outputs.
static constexpr DenormalMode getInvalid()
This is a type descriptor which explains the type requirements of an intrinsic.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Compile-time customization of User operands.