24#include "llvm/Config/llvm-config.h"
53#include "llvm/IR/IntrinsicsAArch64.h"
54#include "llvm/IR/IntrinsicsARM.h"
86#include <system_error>
96 "Print the global id for each value when reading the module summary"));
101 "Expand constant expressions to instructions for testing purposes"));
106 SWITCH_INST_MAGIC = 0x4B5
112 return make_error<StringError>(
119 "file too small to contain bitcode header");
120 for (
unsigned C : {
'B',
'C'})
124 "file doesn't start with bitcode header");
126 return Res.takeError();
127 for (
unsigned C : {0x0, 0xC, 0xE, 0xD})
131 "file doesn't start with bitcode header");
133 return Res.takeError();
138 const unsigned char *BufPtr = (
const unsigned char *)Buffer.
getBufferStart();
139 const unsigned char *BufEnd = BufPtr + Buffer.
getBufferSize();
142 return error(
"Invalid bitcode signature");
148 return error(
"Invalid bitcode wrapper header");
152 return std::move(Err);
154 return std::move(Stream);
158template <
typename StrTy>
171 if (
F.isMaterializable())
174 I.setMetadata(LLVMContext::MD_tbaa,
nullptr);
182 return std::move(Err);
187 std::string ProducerIdentification;
194 switch (Entry.Kind) {
197 return error(
"Malformed block");
199 return ProducerIdentification;
210 switch (MaybeBitCode.
get()) {
212 return error(
"Invalid value");
220 Twine(
"Incompatible epoch: Bitcode '") +
Twine(epoch) +
239 switch (Entry.Kind) {
242 return error(
"Malformed block");
250 return std::move(Err);
262 return std::move(Err);
273 switch (Entry.Kind) {
276 return error(
"Malformed block");
288 switch (MaybeRecord.
get()) {
294 return error(
"Invalid section name record");
296 if (S.find(
"__DATA,__objc_catlist") != std::string::npos ||
297 S.find(
"__OBJC,__category") != std::string::npos)
315 switch (Entry.Kind) {
317 return error(
"Malformed block");
327 return std::move(Err);
340 return std::move(Err);
353 switch (Entry.Kind) {
356 return error(
"Malformed block");
368 switch (MaybeRecord.
get()) {
373 return error(
"Invalid triple record");
392 switch (Entry.Kind) {
394 return error(
"Malformed block");
404 return std::move(Err);
411 return Skipped.takeError();
418class BitcodeReaderBase {
421 : Stream(
std::
move(Stream)), Strtab(Strtab) {
431 bool UseStrtab =
false;
438 std::pair<StringRef, ArrayRef<uint64_t>>
441 Error readBlockInfo();
444 std::string ProducerIdentification;
451Error BitcodeReaderBase::error(
const Twine &Message) {
452 std::string FullMsg = Message.
str();
453 if (!ProducerIdentification.empty())
454 FullMsg +=
" (Producer: '" + ProducerIdentification +
"' Reader: 'LLVM " +
455 LLVM_VERSION_STRING
"')";
456 return ::error(FullMsg);
462 return error(
"Invalid version record");
463 unsigned ModuleVersion =
Record[0];
464 if (ModuleVersion > 2)
465 return error(
"Invalid value");
466 UseStrtab = ModuleVersion >= 2;
467 return ModuleVersion;
470std::pair<StringRef, ArrayRef<uint64_t>>
488class BitcodeConstant final :
public Value,
493 static constexpr uint8_t SubclassID = 255;
501 static constexpr uint8_t ConstantStructOpcode = 255;
502 static constexpr uint8_t ConstantArrayOpcode = 254;
503 static constexpr uint8_t ConstantVectorOpcode = 253;
504 static constexpr uint8_t NoCFIOpcode = 252;
505 static constexpr uint8_t DSOLocalEquivalentOpcode = 251;
506 static constexpr uint8_t BlockAddressOpcode = 250;
507 static constexpr uint8_t FirstSpecialOpcode = BlockAddressOpcode;
517 ExtraInfo(uint8_t Opcode, uint8_t Flags = 0,
unsigned Extra = 0,
518 Type *SrcElemTy =
nullptr)
519 : Opcode(Opcode),
Flags(
Flags), Extra(Extra), SrcElemTy(SrcElemTy) {}
524 unsigned NumOperands;
531 NumOperands(OpIDs.
size()), Extra(
Info.Extra),
532 SrcElemTy(
Info.SrcElemTy) {
533 std::uninitialized_copy(OpIDs.
begin(), OpIDs.
end(),
534 getTrailingObjects<unsigned>());
537 BitcodeConstant &
operator=(
const BitcodeConstant &) =
delete;
541 const ExtraInfo &Info,
543 void *Mem =
A.Allocate(totalSizeToAlloc<unsigned>(OpIDs.
size()),
544 alignof(BitcodeConstant));
545 return new (Mem) BitcodeConstant(Ty, Info, OpIDs);
548 static bool classof(
const Value *V) {
return V->getValueID() == SubclassID; }
551 return ArrayRef(getTrailingObjects<unsigned>(), NumOperands);
554 std::optional<unsigned> getInRangeIndex()
const {
555 assert(Opcode == Instruction::GetElementPtr);
556 if (Extra == (
unsigned)-1)
566class BitcodeReader :
public BitcodeReaderBase,
public GVMaterializer {
568 Module *TheModule =
nullptr;
573 bool SeenValueSymbolTable =
false;
576 std::vector<std::string> SectionTable;
577 std::vector<std::string> GCTable;
579 std::vector<Type *> TypeList;
597 std::optional<MetadataLoader> MDLoader;
598 std::vector<Comdat *> ComdatList;
602 std::vector<std::pair<GlobalVariable *, unsigned>> GlobalInits;
603 std::vector<std::pair<GlobalValue *, unsigned>> IndirectSymbolInits;
605 struct FunctionOperandInfo {
607 unsigned PersonalityFn;
611 std::vector<FunctionOperandInfo> FunctionOperands;
615 std::vector<AttributeList> MAttributes;
618 std::map<unsigned, AttributeList> MAttributeGroups;
622 std::vector<BasicBlock*> FunctionBBs;
626 std::vector<Function*> FunctionsWithBodies;
631 UpdatedIntrinsicMap UpgradedIntrinsics;
636 bool SeenFirstFunctionBody =
false;
645 std::vector<uint64_t> DeferredMetadataInfo;
651 std::deque<Function *> BasicBlockFwdRefQueue;
658 std::vector<Function *> BackwardRefFunctions;
666 bool UseRelativeIDs =
false;
670 bool WillMaterializeAllForwardRefs =
false;
675 std::vector<std::string> BundleTags;
678 std::optional<ValueTypeCallbackTy> ValueTypeCallback;
684 Error materializeForwardReferencedFunctions();
692 Error parseBitcodeInto(
Module *M,
bool ShouldLazyLoadMetadata,
703 std::vector<StructType *> IdentifiedStructTypes;
707 static constexpr unsigned InvalidTypeID = ~0
u;
709 Type *getTypeByID(
unsigned ID);
710 Type *getPtrElementTypeByID(
unsigned ID);
711 unsigned getContainedTypeID(
unsigned ID,
unsigned Idx = 0);
718 Value *getFnValueByID(
unsigned ID,
Type *Ty,
unsigned TyID,
726 return MDLoader->getMetadataFwdRefOrLoad(
ID);
730 if (
ID >= FunctionBBs.size())
return nullptr;
731 return FunctionBBs[
ID];
735 if (i-1 < MAttributes.size())
736 return MAttributes[i-1];
744 unsigned InstNum,
Value *&ResVal,
unsigned &
TypeID,
746 if (Slot ==
Record.size())
return true;
750 ValNo = InstNum - ValNo;
751 if (ValNo < InstNum) {
755 ResVal = getFnValueByID(ValNo,
nullptr,
TypeID, ConstExprInsertBB);
757 "Incorrect type ID stored for value");
758 return ResVal ==
nullptr;
760 if (Slot ==
Record.size())
764 ResVal = getFnValueByID(ValNo, getTypeByID(
TypeID),
TypeID,
766 return ResVal ==
nullptr;
773 unsigned InstNum,
Type *Ty,
unsigned TyID,
Value *&ResVal,
775 if (getValue(
Record, Slot, InstNum, Ty, TyID, ResVal, ConstExprInsertBB))
784 unsigned InstNum,
Type *Ty,
unsigned TyID,
Value *&ResVal,
786 ResVal = getValue(
Record, Slot, InstNum, Ty, TyID, ConstExprInsertBB);
787 return ResVal ==
nullptr;
793 unsigned InstNum,
Type *Ty,
unsigned TyID,
795 if (Slot ==
Record.size())
return nullptr;
799 ValNo = InstNum - ValNo;
800 return getFnValueByID(ValNo, Ty, TyID, ConstExprInsertBB);
805 unsigned InstNum,
Type *Ty,
unsigned TyID,
807 if (Slot ==
Record.size())
return nullptr;
811 ValNo = InstNum - ValNo;
812 return getFnValueByID(ValNo, Ty, TyID, ConstExprInsertBB);
817 if (
Record.size() - OpNum < 3)
818 return error(
"Too few records for range");
821 unsigned LowerActiveWords =
Record[OpNum];
822 unsigned UpperActiveWords =
Record[OpNum++] >> 32;
823 if (
Record.size() - OpNum < LowerActiveWords + UpperActiveWords)
824 return error(
"Too few records for range");
827 OpNum += LowerActiveWords;
830 OpNum += UpperActiveWords;
833 int64_t Start = BitcodeReader::decodeSignRotatedValue(
Record[OpNum++]);
834 int64_t
End = BitcodeReader::decodeSignRotatedValue(
Record[OpNum++]);
855 Error parseGlobalIndirectSymbolRecord(
unsigned BitCode,
858 Error parseAttributeBlock();
859 Error parseAttributeGroupBlock();
860 Error parseTypeTable();
861 Error parseTypeTableBody();
862 Error parseOperandBundleTags();
863 Error parseSyncScopeNames();
866 unsigned NameIndex,
Triple &TT);
867 void setDeferredFunctionInfo(
unsigned FuncBitcodeOffsetDelta,
Function *
F,
870 Error parseGlobalValueSymbolTable();
871 Error parseConstants();
872 Error rememberAndSkipFunctionBodies();
873 Error rememberAndSkipFunctionBody();
875 Error rememberAndSkipMetadata();
878 Error globalCleanup();
879 Error resolveGlobalAndIndirectSymbolInits();
880 Error parseUseLists();
881 Error findFunctionInStream(
890class ModuleSummaryIndexBitcodeReader :
public BitcodeReaderBase {
896 bool SeenGlobalValSummary =
false;
899 bool SeenValueSymbolTable =
false;
915 std::tuple<ValueInfo, GlobalValue::GUID, GlobalValue::GUID>>
916 ValueIdToValueInfoMap;
925 std::string SourceFileName;
937 std::vector<uint64_t> StackIds;
940 ModuleSummaryIndexBitcodeReader(
951 Error parseValueSymbolTable(
956 bool IsOldProfileFormat,
959 Error parseEntireSummary(
unsigned ID);
960 Error parseModuleStringTable();
964 std::vector<FunctionSummary::ParamAccess>
967 template <
bool AllowNullValueInfo = false>
968 std::tuple<ValueInfo, GlobalValue::GUID, GlobalValue::GUID>
969 getValueInfoFromValueId(
unsigned ValueId);
971 void addThisModule();
987 return std::error_code();
994 ValueList(this->Stream.SizeInBytes(),
996 return materializeValue(
ValID, InsertBB);
998 this->ProducerIdentification = std::string(ProducerIdentification);
1001Error BitcodeReader::materializeForwardReferencedFunctions() {
1002 if (WillMaterializeAllForwardRefs)
1006 WillMaterializeAllForwardRefs =
true;
1008 while (!BasicBlockFwdRefQueue.empty()) {
1009 Function *
F = BasicBlockFwdRefQueue.front();
1010 BasicBlockFwdRefQueue.pop_front();
1011 assert(
F &&
"Expected valid function");
1012 if (!BasicBlockFwdRefs.
count(
F))
1020 if (!
F->isMaterializable())
1021 return error(
"Never resolved function from blockaddress");
1024 if (
Error Err = materialize(
F))
1027 assert(BasicBlockFwdRefs.
empty() &&
"Function missing from queue");
1029 for (
Function *
F : BackwardRefFunctions)
1030 if (
Error Err = materialize(
F))
1032 BackwardRefFunctions.clear();
1035 WillMaterializeAllForwardRefs =
false;
1099 Flags.ReadNone = RawFlags & 0x1;
1100 Flags.ReadOnly = (RawFlags >> 1) & 0x1;
1101 Flags.NoRecurse = (RawFlags >> 2) & 0x1;
1102 Flags.ReturnDoesNotAlias = (RawFlags >> 3) & 0x1;
1103 Flags.NoInline = (RawFlags >> 4) & 0x1;
1104 Flags.AlwaysInline = (RawFlags >> 5) & 0x1;
1105 Flags.NoUnwind = (RawFlags >> 6) & 0x1;
1106 Flags.MayThrow = (RawFlags >> 7) & 0x1;
1107 Flags.HasUnknownCall = (RawFlags >> 8) & 0x1;
1108 Flags.MustBeUnreachable = (RawFlags >> 9) & 0x1;
1123 RawFlags = RawFlags >> 4;
1124 bool NotEligibleToImport = (RawFlags & 0x1) || Version < 3;
1128 bool Live = (RawFlags & 0x2) || Version < 3;
1129 bool Local = (RawFlags & 0x4);
1130 bool AutoHide = (RawFlags & 0x8);
1133 Live, Local, AutoHide);
1139 (RawFlags & 0x1) ?
true :
false, (RawFlags & 0x2) ?
true :
false,
1140 (RawFlags & 0x4) ?
true :
false,
1144static std::pair<CalleeInfo::HotnessType, bool>
1148 bool HasTailCall = (RawFlags & 0x8);
1149 return {Hotness, HasTailCall};
1153 bool &HasTailCall) {
1154 static constexpr uint64_t RelBlockFreqMask =
1156 RelBF = RawFlags & RelBlockFreqMask;
1182 case 0:
return false;
1183 case 1:
return true;
1206 case 0:
return GlobalVariable::NotThreadLocal;
1208 case 1:
return GlobalVariable::GeneralDynamicTLSModel;
1209 case 2:
return GlobalVariable::LocalDynamicTLSModel;
1210 case 3:
return GlobalVariable::InitialExecTLSModel;
1211 case 4:
return GlobalVariable::LocalExecTLSModel;
1218 case 0:
return GlobalVariable::UnnamedAddr::None;
1219 case 1:
return GlobalVariable::UnnamedAddr::Global;
1220 case 2:
return GlobalVariable::UnnamedAddr::Local;
1253 return IsFP ? Instruction::FNeg : -1;
1267 return IsFP ? Instruction::FAdd : Instruction::Add;
1269 return IsFP ? Instruction::FSub : Instruction::Sub;
1271 return IsFP ? Instruction::FMul : Instruction::Mul;
1273 return IsFP ? -1 : Instruction::UDiv;
1275 return IsFP ? Instruction::FDiv : Instruction::SDiv;
1277 return IsFP ? -1 : Instruction::URem;
1279 return IsFP ? Instruction::FRem : Instruction::SRem;
1281 return IsFP ? -1 : Instruction::Shl;
1283 return IsFP ? -1 : Instruction::LShr;
1285 return IsFP ? -1 : Instruction::AShr;
1287 return IsFP ? -1 : Instruction::And;
1289 return IsFP ? -1 : Instruction::Or;
1291 return IsFP ? -1 : Instruction::Xor;
1380Type *BitcodeReader::getTypeByID(
unsigned ID) {
1382 if (
ID >= TypeList.size())
1385 if (
Type *Ty = TypeList[
ID])
1390 return TypeList[
ID] = createIdentifiedStructType(Context);
1393unsigned BitcodeReader::getContainedTypeID(
unsigned ID,
unsigned Idx) {
1394 auto It = ContainedTypeIDs.
find(
ID);
1395 if (It == ContainedTypeIDs.
end())
1396 return InvalidTypeID;
1398 if (
Idx >= It->second.size())
1399 return InvalidTypeID;
1401 return It->second[
Idx];
1404Type *BitcodeReader::getPtrElementTypeByID(
unsigned ID) {
1405 if (
ID >= TypeList.size())
1412 return getTypeByID(getContainedTypeID(
ID, 0));
1415unsigned BitcodeReader::getVirtualTypeID(
Type *Ty,
1417 unsigned ChildTypeID = ChildTypeIDs.
empty() ? InvalidTypeID : ChildTypeIDs[0];
1418 auto CacheKey = std::make_pair(Ty, ChildTypeID);
1419 auto It = VirtualTypeIDs.
find(CacheKey);
1420 if (It != VirtualTypeIDs.
end()) {
1426 ContainedTypeIDs[It->second] == ChildTypeIDs) &&
1427 "Incorrect cached contained type IDs");
1431 unsigned TypeID = TypeList.size();
1432 TypeList.push_back(Ty);
1433 if (!ChildTypeIDs.
empty())
1440 uint8_t Opcode = BC->Opcode;
1443 if (Opcode >= BitcodeConstant::FirstSpecialOpcode)
1457 if (Opcode == Instruction::GetElementPtr)
1461 case Instruction::FNeg:
1462 case Instruction::Select:
1472 if (StartValID < ValueList.
size() && ValueList[StartValID] &&
1473 !isa<BitcodeConstant>(ValueList[StartValID]))
1474 return ValueList[StartValID];
1479 while (!Worklist.
empty()) {
1488 return error(
"Invalid value ID");
1491 auto *BC = dyn_cast<BitcodeConstant>(V);
1501 for (
unsigned OpID :
reverse(BC->getOperandIDs())) {
1502 auto It = MaterializedValues.
find(OpID);
1503 if (It != MaterializedValues.
end())
1511 if (Ops.
size() != BC->getOperandIDs().size())
1513 std::reverse(Ops.
begin(), Ops.
end());
1517 if (
auto *
C = dyn_cast<Constant>(
Op))
1530 switch (BC->Opcode) {
1531 case BitcodeConstant::NoCFIOpcode: {
1532 auto *GV = dyn_cast<GlobalValue>(ConstOps[0]);
1534 return error(
"no_cfi operand must be GlobalValue");
1538 case BitcodeConstant::DSOLocalEquivalentOpcode: {
1539 auto *GV = dyn_cast<GlobalValue>(ConstOps[0]);
1541 return error(
"dso_local operand must be GlobalValue");
1545 case BitcodeConstant::BlockAddressOpcode: {
1546 Function *Fn = dyn_cast<Function>(ConstOps[0]);
1548 return error(
"blockaddress operand must be a function");
1553 unsigned BBID = BC->Extra;
1556 return error(
"Invalid ID");
1559 for (
size_t I = 0,
E = BBID;
I !=
E; ++
I) {
1561 return error(
"Invalid ID");
1568 auto &FwdBBs = BasicBlockFwdRefs[Fn];
1570 BasicBlockFwdRefQueue.push_back(Fn);
1571 if (FwdBBs.size() < BBID + 1)
1572 FwdBBs.resize(BBID + 1);
1580 case BitcodeConstant::ConstantStructOpcode:
1583 case BitcodeConstant::ConstantArrayOpcode:
1586 case BitcodeConstant::ConstantVectorOpcode:
1589 case Instruction::ICmp:
1590 case Instruction::FCmp:
1593 case Instruction::GetElementPtr:
1596 BC->Flags, BC->getInRangeIndex());
1598 case Instruction::ExtractElement:
1601 case Instruction::InsertElement:
1605 case Instruction::ShuffleVector: {
1624 return error(
Twine(
"Value referenced by initializer is an unsupported "
1625 "constant expression of type ") +
1626 BC->getOpcodeName());
1632 BC->getType(),
"constexpr", InsertBB);
1635 "constexpr", InsertBB);
1638 Ops[1],
"constexpr", InsertBB);
1639 if (isa<OverflowingBinaryOperator>(
I)) {
1641 I->setHasNoSignedWrap();
1643 I->setHasNoUnsignedWrap();
1645 if (isa<PossiblyExactOperator>(
I) &&
1649 switch (BC->Opcode) {
1650 case BitcodeConstant::ConstantVectorOpcode: {
1654 Value *
Idx = ConstantInt::get(IdxTy, Pair.index());
1658 I = cast<Instruction>(V);
1661 case BitcodeConstant::ConstantStructOpcode:
1662 case BitcodeConstant::ConstantArrayOpcode: {
1666 "constexpr.ins", InsertBB);
1667 I = cast<Instruction>(V);
1670 case Instruction::ICmp:
1671 case Instruction::FCmp:
1674 "constexpr", InsertBB);
1676 case Instruction::GetElementPtr:
1678 ArrayRef(Ops).drop_front(),
"constexpr",
1681 cast<GetElementPtrInst>(
I)->setIsInBounds();
1683 case Instruction::Select:
1686 case Instruction::ExtractElement:
1689 case Instruction::InsertElement:
1693 case Instruction::ShuffleVector:
1706 return MaterializedValues[StartValID];
1715 return cast<Constant>(MaybeV.
get());
1721 IdentifiedStructTypes.push_back(Ret);
1727 IdentifiedStructTypes.push_back(Ret);
1743 case Attribute::ZExt:
return 1 << 0;
1744 case Attribute::SExt:
return 1 << 1;
1745 case Attribute::NoReturn:
return 1 << 2;
1746 case Attribute::InReg:
return 1 << 3;
1747 case Attribute::StructRet:
return 1 << 4;
1748 case Attribute::NoUnwind:
return 1 << 5;
1749 case Attribute::NoAlias:
return 1 << 6;
1750 case Attribute::ByVal:
return 1 << 7;
1751 case Attribute::Nest:
return 1 << 8;
1752 case Attribute::ReadNone:
return 1 << 9;
1753 case Attribute::ReadOnly:
return 1 << 10;
1754 case Attribute::NoInline:
return 1 << 11;
1755 case Attribute::AlwaysInline:
return 1 << 12;
1756 case Attribute::OptimizeForSize:
return 1 << 13;
1757 case Attribute::StackProtect:
return 1 << 14;
1758 case Attribute::StackProtectReq:
return 1 << 15;
1759 case Attribute::Alignment:
return 31 << 16;
1760 case Attribute::NoCapture:
return 1 << 21;
1761 case Attribute::NoRedZone:
return 1 << 22;
1762 case Attribute::NoImplicitFloat:
return 1 << 23;
1763 case Attribute::Naked:
return 1 << 24;
1764 case Attribute::InlineHint:
return 1 << 25;
1765 case Attribute::StackAlignment:
return 7 << 26;
1766 case Attribute::ReturnsTwice:
return 1 << 29;
1767 case Attribute::UWTable:
return 1 << 30;
1768 case Attribute::NonLazyBind:
return 1U << 31;
1769 case Attribute::SanitizeAddress:
return 1ULL << 32;
1770 case Attribute::MinSize:
return 1ULL << 33;
1771 case Attribute::NoDuplicate:
return 1ULL << 34;
1772 case Attribute::StackProtectStrong:
return 1ULL << 35;
1773 case Attribute::SanitizeThread:
return 1ULL << 36;
1774 case Attribute::SanitizeMemory:
return 1ULL << 37;
1775 case Attribute::NoBuiltin:
return 1ULL << 38;
1776 case Attribute::Returned:
return 1ULL << 39;
1777 case Attribute::Cold:
return 1ULL << 40;
1778 case Attribute::Builtin:
return 1ULL << 41;
1779 case Attribute::OptimizeNone:
return 1ULL << 42;
1780 case Attribute::InAlloca:
return 1ULL << 43;
1781 case Attribute::NonNull:
return 1ULL << 44;
1782 case Attribute::JumpTable:
return 1ULL << 45;
1783 case Attribute::Convergent:
return 1ULL << 46;
1784 case Attribute::SafeStack:
return 1ULL << 47;
1785 case Attribute::NoRecurse:
return 1ULL << 48;
1788 case Attribute::SwiftSelf:
return 1ULL << 51;
1789 case Attribute::SwiftError:
return 1ULL << 52;
1790 case Attribute::WriteOnly:
return 1ULL << 53;
1791 case Attribute::Speculatable:
return 1ULL << 54;
1792 case Attribute::StrictFP:
return 1ULL << 55;
1793 case Attribute::SanitizeHWAddress:
return 1ULL << 56;
1794 case Attribute::NoCfCheck:
return 1ULL << 57;
1795 case Attribute::OptForFuzzing:
return 1ULL << 58;
1796 case Attribute::ShadowCallStack:
return 1ULL << 59;
1797 case Attribute::SpeculativeLoadHardening:
1799 case Attribute::ImmArg:
1801 case Attribute::WillReturn:
1803 case Attribute::NoFree:
1819 if (
I == Attribute::Alignment)
1820 B.addAlignmentAttr(1ULL << ((
A >> 16) - 1));
1821 else if (
I == Attribute::StackAlignment)
1822 B.addStackAlignmentAttr(1ULL << ((
A >> 26)-1));
1824 B.addTypeAttr(
I,
nullptr);
1839 unsigned Alignment = (EncodedAttrs & (0xffffULL << 16)) >> 16;
1841 "Alignment must be a power of two.");
1844 B.addAlignmentAttr(Alignment);
1846 uint64_t Attrs = ((EncodedAttrs & (0xfffffULL << 32)) >> 11) |
1847 (EncodedAttrs & 0xffff);
1852 if (Attrs & (1ULL << 9)) {
1854 Attrs &= ~(1ULL << 9);
1857 if (Attrs & (1ULL << 10)) {
1859 Attrs &= ~(1ULL << 10);
1862 if (Attrs & (1ULL << 49)) {
1864 Attrs &= ~(1ULL << 49);
1867 if (Attrs & (1ULL << 50)) {
1869 Attrs &= ~(1ULL << 50);
1872 if (Attrs & (1ULL << 53)) {
1874 Attrs &= ~(1ULL << 53);
1878 B.addMemoryAttr(ME);
1884Error BitcodeReader::parseAttributeBlock() {
1888 if (!MAttributes.empty())
1889 return error(
"Invalid multiple blocks");
1902 switch (Entry.Kind) {
1905 return error(
"Malformed block");
1918 switch (MaybeRecord.
get()) {
1924 return error(
"Invalid parameter attribute record");
1926 for (
unsigned i = 0, e =
Record.size(); i != e; i += 2) {
1936 for (
unsigned i = 0, e =
Record.size(); i != e; ++i)
1952 return Attribute::Alignment;
1954 return Attribute::AlwaysInline;
1956 return Attribute::Builtin;
1958 return Attribute::ByVal;
1960 return Attribute::InAlloca;
1962 return Attribute::Cold;
1964 return Attribute::Convergent;
1966 return Attribute::DisableSanitizerInstrumentation;
1968 return Attribute::ElementType;
1970 return Attribute::FnRetThunkExtern;
1972 return Attribute::InlineHint;
1974 return Attribute::InReg;
1976 return Attribute::JumpTable;
1978 return Attribute::Memory;
1980 return Attribute::NoFPClass;
1982 return Attribute::MinSize;
1984 return Attribute::Naked;
1986 return Attribute::Nest;
1988 return Attribute::NoAlias;
1990 return Attribute::NoBuiltin;
1992 return Attribute::NoCallback;
1994 return Attribute::NoCapture;
1996 return Attribute::NoDuplicate;
1998 return Attribute::NoFree;
2000 return Attribute::NoImplicitFloat;
2002 return Attribute::NoInline;
2004 return Attribute::NoRecurse;
2006 return Attribute::NoMerge;
2008 return Attribute::NonLazyBind;
2010 return Attribute::NonNull;
2012 return Attribute::Dereferenceable;
2014 return Attribute::DereferenceableOrNull;
2016 return Attribute::AllocAlign;
2018 return Attribute::AllocKind;
2020 return Attribute::AllocSize;
2022 return Attribute::AllocatedPointer;
2024 return Attribute::NoRedZone;
2026 return Attribute::NoReturn;
2028 return Attribute::NoSync;
2030 return Attribute::NoCfCheck;
2032 return Attribute::NoProfile;
2034 return Attribute::SkipProfile;
2036 return Attribute::NoUnwind;
2038 return Attribute::NoSanitizeBounds;
2040 return Attribute::NoSanitizeCoverage;
2042 return Attribute::NullPointerIsValid;
2044 return Attribute::OptimizeForDebugging;
2046 return Attribute::OptForFuzzing;
2048 return Attribute::OptimizeForSize;
2050 return Attribute::OptimizeNone;
2052 return Attribute::ReadNone;
2054 return Attribute::ReadOnly;
2056 return Attribute::Returned;
2058 return Attribute::ReturnsTwice;
2060 return Attribute::SExt;
2062 return Attribute::Speculatable;
2064 return Attribute::StackAlignment;
2066 return Attribute::StackProtect;
2068 return Attribute::StackProtectReq;
2070 return Attribute::StackProtectStrong;
2072 return Attribute::SafeStack;
2074 return Attribute::ShadowCallStack;
2076 return Attribute::StrictFP;
2078 return Attribute::StructRet;
2080 return Attribute::SanitizeAddress;
2082 return Attribute::SanitizeHWAddress;
2084 return Attribute::SanitizeThread;
2086 return Attribute::SanitizeMemory;
2088 return Attribute::SpeculativeLoadHardening;
2090 return Attribute::SwiftError;
2092 return Attribute::SwiftSelf;
2094 return Attribute::SwiftAsync;
2096 return Attribute::UWTable;
2098 return Attribute::VScaleRange;
2100 return Attribute::WillReturn;
2102 return Attribute::WriteOnly;
2104 return Attribute::ZExt;
2106 return Attribute::ImmArg;
2108 return Attribute::SanitizeMemTag;
2110 return Attribute::Preallocated;
2112 return Attribute::NoUndef;
2114 return Attribute::ByRef;
2116 return Attribute::MustProgress;
2118 return Attribute::Hot;
2120 return Attribute::PresplitCoroutine;
2122 return Attribute::Writable;
2124 return Attribute::CoroDestroyOnlyWhenComplete;
2126 return Attribute::DeadOnUnwind;
2128 return Attribute::Range;
2137 return error(
"Invalid alignment value");
2145 return error(
"Unknown attribute kind (" +
Twine(Code) +
")");
2150 switch (EncodedKind) {
2174Error BitcodeReader::parseAttributeGroupBlock() {
2178 if (!MAttributeGroups.empty())
2179 return error(
"Invalid multiple blocks");
2190 switch (Entry.Kind) {
2193 return error(
"Malformed block");
2206 switch (MaybeRecord.
get()) {
2211 return error(
"Invalid grp record");
2218 for (
unsigned i = 2, e =
Record.size(); i != e; ++i) {
2226 if (
Error Err = parseAttrKind(EncodedKind, &Kind))
2232 if (Kind == Attribute::ByVal)
2233 B.addByValAttr(
nullptr);
2234 else if (Kind == Attribute::StructRet)
2235 B.addStructRetAttr(
nullptr);
2236 else if (Kind == Attribute::InAlloca)
2237 B.addInAllocaAttr(
nullptr);
2238 else if (Kind == Attribute::UWTable)
2239 B.addUWTableAttr(UWTableKind::Default);
2241 B.addAttribute(Kind);
2243 return error(
"Not an enum attribute");
2244 }
else if (
Record[i] == 1) {
2246 if (
Error Err = parseAttrKind(
Record[++i], &Kind))
2249 return error(
"Not an int attribute");
2250 if (Kind == Attribute::Alignment)
2251 B.addAlignmentAttr(
Record[++i]);
2252 else if (Kind == Attribute::StackAlignment)
2253 B.addStackAlignmentAttr(
Record[++i]);
2254 else if (Kind == Attribute::Dereferenceable)
2255 B.addDereferenceableAttr(
Record[++i]);
2256 else if (Kind == Attribute::DereferenceableOrNull)
2257 B.addDereferenceableOrNullAttr(
Record[++i]);
2258 else if (Kind == Attribute::AllocSize)
2259 B.addAllocSizeAttrFromRawRepr(
Record[++i]);
2260 else if (Kind == Attribute::VScaleRange)
2261 B.addVScaleRangeAttrFromRawRepr(
Record[++i]);
2262 else if (Kind == Attribute::UWTable)
2264 else if (Kind == Attribute::AllocKind)
2266 else if (Kind == Attribute::Memory)
2268 else if (Kind == Attribute::NoFPClass)
2276 while (
Record[i] != 0 && i != e)
2278 assert(
Record[i] == 0 &&
"Kind string not null terminated");
2283 while (
Record[i] != 0 && i != e)
2285 assert(
Record[i] == 0 &&
"Value string not null terminated");
2288 B.addAttribute(KindStr.
str(), ValStr.
str());
2290 bool HasType =
Record[i] == 6;
2292 if (
Error Err = parseAttrKind(
Record[++i], &Kind))
2295 return error(
"Not a type attribute");
2297 B.addTypeAttr(Kind, HasType ? getTypeByID(
Record[++i]) :
nullptr);
2298 }
else if (
Record[i] == 7) {
2302 if (
Error Err = parseAttrKind(
Record[i++], &Kind))
2305 return error(
"Not a ConstantRange attribute");
2312 B.addConstantRangeAttr(Kind, MaybeCR.
get());
2314 return error(
"Invalid attribute group entry");
2319 B.addMemoryAttr(ME);
2329Error BitcodeReader::parseTypeTable() {
2333 return parseTypeTableBody();
2336Error BitcodeReader::parseTypeTableBody() {
2337 if (!TypeList.empty())
2338 return error(
"Invalid multiple blocks");
2341 unsigned NumRecords = 0;
2352 switch (Entry.Kind) {
2355 return error(
"Malformed block");
2357 if (NumRecords != TypeList.size())
2358 return error(
"Malformed block");
2367 Type *ResultTy =
nullptr;
2372 switch (MaybeRecord.
get()) {
2374 return error(
"Invalid value");
2379 return error(
"Invalid numentry record");
2380 TypeList.resize(
Record[0]);
2423 return error(
"Invalid integer record");
2428 return error(
"Bitwidth for integer type out of range");
2435 return error(
"Invalid pointer record");
2439 ResultTy = getTypeByID(
Record[0]);
2441 !PointerType::isValidElementType(ResultTy))
2442 return error(
"Invalid type");
2449 return error(
"Invalid opaque pointer record");
2458 return error(
"Invalid function record");
2460 for (
unsigned i = 3, e =
Record.size(); i != e; ++i) {
2467 ResultTy = getTypeByID(
Record[2]);
2468 if (!ResultTy || ArgTys.
size() <
Record.size()-3)
2469 return error(
"Invalid type");
2472 ResultTy = FunctionType::get(ResultTy, ArgTys,
Record[0]);
2478 return error(
"Invalid function record");
2480 for (
unsigned i = 2, e =
Record.size(); i != e; ++i) {
2482 if (!FunctionType::isValidArgumentType(
T))
2483 return error(
"Invalid function argument type");
2490 ResultTy = getTypeByID(
Record[1]);
2491 if (!ResultTy || ArgTys.
size() <
Record.size()-2)
2492 return error(
"Invalid type");
2495 ResultTy = FunctionType::get(ResultTy, ArgTys,
Record[0]);
2500 return error(
"Invalid anon struct record");
2502 for (
unsigned i = 1, e =
Record.size(); i != e; ++i) {
2509 return error(
"Invalid type");
2516 return error(
"Invalid struct name record");
2521 return error(
"Invalid named struct record");
2523 if (NumRecords >= TypeList.size())
2524 return error(
"Invalid TYPE table");
2527 StructType *Res = cast_or_null<StructType>(TypeList[NumRecords]);
2530 TypeList[NumRecords] =
nullptr;
2532 Res = createIdentifiedStructType(Context, TypeName);
2536 for (
unsigned i = 1, e =
Record.size(); i != e; ++i) {
2543 return error(
"Invalid named struct record");
2551 return error(
"Invalid opaque type record");
2553 if (NumRecords >= TypeList.size())
2554 return error(
"Invalid TYPE table");
2557 StructType *Res = cast_or_null<StructType>(TypeList[NumRecords]);
2560 TypeList[NumRecords] =
nullptr;
2562 Res = createIdentifiedStructType(Context, TypeName);
2569 return error(
"Invalid target extension type record");
2571 if (NumRecords >= TypeList.size())
2572 return error(
"Invalid TYPE table");
2575 return error(
"Too many type parameters");
2577 unsigned NumTys =
Record[0];
2580 for (
unsigned i = 0; i < NumTys; i++) {
2584 return error(
"Invalid type");
2587 for (
unsigned i = NumTys + 1, e =
Record.size(); i < e; i++) {
2588 if (
Record[i] > UINT_MAX)
2589 return error(
"Integer parameter too large");
2598 return error(
"Invalid array type record");
2599 ResultTy = getTypeByID(
Record[1]);
2600 if (!ResultTy || !ArrayType::isValidElementType(ResultTy))
2601 return error(
"Invalid type");
2603 ResultTy = ArrayType::get(ResultTy,
Record[0]);
2608 return error(
"Invalid vector type record");
2610 return error(
"Invalid vector length");
2611 ResultTy = getTypeByID(
Record[1]);
2612 if (!ResultTy || !VectorType::isValidElementType(ResultTy))
2613 return error(
"Invalid type");
2616 ResultTy = VectorType::get(ResultTy,
Record[0], Scalable);
2620 if (NumRecords >= TypeList.size())
2621 return error(
"Invalid TYPE table");
2622 if (TypeList[NumRecords])
2624 "Invalid TYPE table: Only named structs can be forward referenced");
2625 assert(ResultTy &&
"Didn't read a type?");
2626 TypeList[NumRecords] = ResultTy;
2627 if (!ContainedIDs.
empty())
2628 ContainedTypeIDs[NumRecords] = std::move(ContainedIDs);
2633Error BitcodeReader::parseOperandBundleTags() {
2637 if (!BundleTags.empty())
2638 return error(
"Invalid multiple blocks");
2648 switch (Entry.Kind) {
2651 return error(
"Malformed block");
2665 return error(
"Invalid operand bundle record");
2668 BundleTags.emplace_back();
2670 return error(
"Invalid operand bundle record");
2675Error BitcodeReader::parseSyncScopeNames() {
2680 return error(
"Invalid multiple synchronization scope names blocks");
2689 switch (Entry.Kind) {
2692 return error(
"Malformed block");
2695 return error(
"Invalid empty synchronization scope names block");
2709 return error(
"Invalid sync scope record");
2713 return error(
"Invalid sync scope record");
2722 unsigned NameIndex,
Triple &TT) {
2725 return error(
"Invalid record");
2726 unsigned ValueID =
Record[0];
2727 if (ValueID >= ValueList.
size() || !ValueList[ValueID])
2728 return error(
"Invalid record");
2729 Value *
V = ValueList[ValueID];
2732 if (NameStr.contains(0))
2733 return error(
"Invalid value name");
2734 V->setName(NameStr);
2735 auto *GO = dyn_cast<GlobalObject>(V);
2736 if (GO && ImplicitComdatObjects.
contains(GO) &&
TT.supportsCOMDAT())
2749 return std::move(JumpFailed);
2755 return error(
"Expected value symbol table subblock");
2759void BitcodeReader::setDeferredFunctionInfo(
unsigned FuncBitcodeOffsetDelta,
2766 uint64_t FuncBitOffset = FuncWordOffset * 32;
2767 DeferredFunctionInfo[
F] = FuncBitOffset + FuncBitcodeOffsetDelta;
2771 if (FuncBitOffset > LastFunctionBlockBit)
2772 LastFunctionBlockBit = FuncBitOffset;
2776Error BitcodeReader::parseGlobalValueSymbolTable() {
2777 unsigned FuncBitcodeOffsetDelta =
2790 switch (Entry.Kind) {
2793 return error(
"Malformed block");
2804 switch (MaybeRecord.
get()) {
2806 unsigned ValueID =
Record[0];
2807 if (ValueID >= ValueList.
size() || !ValueList[ValueID])
2808 return error(
"Invalid value reference in symbol table");
2809 setDeferredFunctionInfo(FuncBitcodeOffsetDelta,
2810 cast<Function>(ValueList[ValueID]),
Record);
2826 if (!MaybeCurrentBit)
2828 CurrentBit = MaybeCurrentBit.
get();
2831 if (
Error Err = parseGlobalValueSymbolTable())
2833 if (
Error JumpFailed = Stream.JumpToBit(CurrentBit))
2852 unsigned FuncBitcodeOffsetDelta =
2871 switch (Entry.Kind) {
2874 return error(
"Malformed block");
2877 if (
Error JumpFailed = Stream.JumpToBit(CurrentBit))
2890 switch (MaybeRecord.
get()) {
2909 if (
auto *
F = dyn_cast<Function>(V))
2910 setDeferredFunctionInfo(FuncBitcodeOffsetDelta,
F,
Record);
2915 return error(
"Invalid bbentry record");
2918 return error(
"Invalid bbentry record");
2940Error BitcodeReader::resolveGlobalAndIndirectSymbolInits() {
2941 std::vector<std::pair<GlobalVariable *, unsigned>> GlobalInitWorklist;
2942 std::vector<std::pair<GlobalValue *, unsigned>> IndirectSymbolInitWorklist;
2943 std::vector<FunctionOperandInfo> FunctionOperandWorklist;
2945 GlobalInitWorklist.swap(GlobalInits);
2946 IndirectSymbolInitWorklist.swap(IndirectSymbolInits);
2947 FunctionOperandWorklist.swap(FunctionOperands);
2949 while (!GlobalInitWorklist.empty()) {
2950 unsigned ValID = GlobalInitWorklist.back().second;
2953 GlobalInits.push_back(GlobalInitWorklist.back());
2958 GlobalInitWorklist.back().first->setInitializer(MaybeC.
get());
2960 GlobalInitWorklist.pop_back();
2963 while (!IndirectSymbolInitWorklist.empty()) {
2964 unsigned ValID = IndirectSymbolInitWorklist.back().second;
2966 IndirectSymbolInits.push_back(IndirectSymbolInitWorklist.back());
2972 GlobalValue *GV = IndirectSymbolInitWorklist.back().first;
2973 if (
auto *GA = dyn_cast<GlobalAlias>(GV)) {
2975 return error(
"Alias and aliasee types don't match");
2977 }
else if (
auto *GI = dyn_cast<GlobalIFunc>(GV)) {
2980 return error(
"Expected an alias or an ifunc");
2983 IndirectSymbolInitWorklist.pop_back();
2986 while (!FunctionOperandWorklist.empty()) {
2987 FunctionOperandInfo &
Info = FunctionOperandWorklist.back();
2988 if (
Info.PersonalityFn) {
2989 unsigned ValID =
Info.PersonalityFn - 1;
2994 Info.F->setPersonalityFn(MaybeC.
get());
2995 Info.PersonalityFn = 0;
3004 Info.F->setPrefixData(MaybeC.
get());
3008 if (
Info.Prologue) {
3014 Info.F->setPrologueData(MaybeC.
get());
3018 if (
Info.PersonalityFn ||
Info.Prefix ||
Info.Prologue)
3019 FunctionOperands.push_back(Info);
3020 FunctionOperandWorklist.pop_back();
3029 BitcodeReader::decodeSignRotatedValue);
3031 return APInt(TypeBits, Words);
3034Error BitcodeReader::parseConstants() {
3042 unsigned Int32TyID = getVirtualTypeID(CurTy);
3043 unsigned CurTyID = Int32TyID;
3044 Type *CurElemTy =
nullptr;
3045 unsigned NextCstNo = ValueList.
size();
3053 switch (Entry.Kind) {
3056 return error(
"Malformed block");
3058 if (NextCstNo != ValueList.
size())
3059 return error(
"Invalid constant reference");
3073 switch (
unsigned BitCode = MaybeBitCode.
get()) {
3083 return error(
"Invalid settype record");
3084 if (
Record[0] >= TypeList.size() || !TypeList[
Record[0]])
3085 return error(
"Invalid settype record");
3086 if (TypeList[
Record[0]] == VoidType)
3087 return error(
"Invalid constant type");
3089 CurTy = TypeList[CurTyID];
3090 CurElemTy = getPtrElementTypeByID(CurTyID);
3094 return error(
"Invalid type for a constant null value");
3095 if (
auto *TETy = dyn_cast<TargetExtType>(CurTy))
3097 return error(
"Invalid type for a constant null value");
3102 return error(
"Invalid integer const record");
3107 return error(
"Invalid wide integer const record");
3111 V = ConstantInt::get(CurTy, VInt);
3116 return error(
"Invalid float const record");
3119 if (ScalarTy->isHalfTy())
3120 V = ConstantFP::get(CurTy,
APFloat(APFloat::IEEEhalf(),
3122 else if (ScalarTy->isBFloatTy())
3123 V = ConstantFP::get(
3125 else if (ScalarTy->isFloatTy())
3126 V = ConstantFP::get(CurTy,
APFloat(APFloat::IEEEsingle(),
3128 else if (ScalarTy->isDoubleTy())
3129 V = ConstantFP::get(
3131 else if (ScalarTy->isX86_FP80Ty()) {
3134 Rearrange[0] = (
Record[1] & 0xffffLL) | (
Record[0] << 16);
3135 Rearrange[1] =
Record[0] >> 48;
3136 V = ConstantFP::get(
3137 CurTy,
APFloat(APFloat::x87DoubleExtended(),
APInt(80, Rearrange)));
3138 }
else if (ScalarTy->isFP128Ty())
3139 V = ConstantFP::get(CurTy,
3141 else if (ScalarTy->isPPC_FP128Ty())
3142 V = ConstantFP::get(
3151 return error(
"Invalid aggregate record");
3155 for (
unsigned i = 0; i !=
Size; ++i)
3158 if (isa<StructType>(CurTy)) {
3159 V = BitcodeConstant::create(
3160 Alloc, CurTy, BitcodeConstant::ConstantStructOpcode, Elts);
3161 }
else if (isa<ArrayType>(CurTy)) {
3162 V = BitcodeConstant::create(Alloc, CurTy,
3163 BitcodeConstant::ConstantArrayOpcode, Elts);
3164 }
else if (isa<VectorType>(CurTy)) {
3165 V = BitcodeConstant::create(
3166 Alloc, CurTy, BitcodeConstant::ConstantVectorOpcode, Elts);
3175 return error(
"Invalid string record");
3184 return error(
"Invalid data record");
3187 if (
auto *Array = dyn_cast<ArrayType>(CurTy))
3188 EltTy =
Array->getElementType();
3190 EltTy = cast<VectorType>(CurTy)->getElementType();
3193 if (isa<VectorType>(CurTy))
3199 if (isa<VectorType>(CurTy))
3205 if (isa<VectorType>(CurTy))
3211 if (isa<VectorType>(CurTy))
3217 if (isa<VectorType>(CurTy))
3223 if (isa<VectorType>(CurTy))
3229 if (isa<VectorType>(CurTy))
3235 if (isa<VectorType>(CurTy))
3240 return error(
"Invalid type for value");
3246 return error(
"Invalid unary op constexpr record");
3251 V = BitcodeConstant::create(Alloc, CurTy, Opc, (
unsigned)
Record[1]);
3257 return error(
"Invalid binary op constexpr record");
3263 if (
Record.size() >= 4) {
3264 if (Opc == Instruction::Add ||
3265 Opc == Instruction::Sub ||
3266 Opc == Instruction::Mul ||
3267 Opc == Instruction::Shl) {
3272 }
else if (Opc == Instruction::SDiv ||
3273 Opc == Instruction::UDiv ||
3274 Opc == Instruction::LShr ||
3275 Opc == Instruction::AShr) {
3280 V = BitcodeConstant::create(Alloc, CurTy, {(uint8_t)Opc, Flags},
3287 return error(
"Invalid cast constexpr record");
3292 unsigned OpTyID =
Record[1];
3293 Type *OpTy = getTypeByID(OpTyID);
3295 return error(
"Invalid cast constexpr record");
3296 V = BitcodeConstant::create(Alloc, CurTy, Opc, (
unsigned)
Record[2]);
3305 return error(
"Constant GEP record must have at least two elements");
3307 Type *PointeeType =
nullptr;
3310 PointeeType = getTypeByID(
Record[OpNum++]);
3312 bool InBounds =
false;
3313 std::optional<unsigned> InRangeIndex;
3317 InRangeIndex =
Op >> 1;
3322 unsigned BaseTypeID =
Record[OpNum];
3323 while (OpNum !=
Record.size()) {
3324 unsigned ElTyID =
Record[OpNum++];
3325 Type *ElTy = getTypeByID(ElTyID);
3327 return error(
"Invalid getelementptr constexpr record");
3331 if (Elts.
size() < 1)
3332 return error(
"Invalid gep with no operands");
3336 BaseTypeID = getContainedTypeID(BaseTypeID, 0);
3337 BaseType = getTypeByID(BaseTypeID);
3342 return error(
"GEP base operand must be pointer or vector of pointer");
3345 PointeeType = getPtrElementTypeByID(BaseTypeID);
3347 return error(
"Missing element type for old-style constant GEP");
3350 V = BitcodeConstant::create(Alloc, CurTy,
3351 {Instruction::GetElementPtr, InBounds,
3352 InRangeIndex.value_or(-1), PointeeType},
3358 return error(
"Invalid select constexpr record");
3360 V = BitcodeConstant::create(
3361 Alloc, CurTy, Instruction::Select,
3368 return error(
"Invalid extractelement constexpr record");
3369 unsigned OpTyID =
Record[0];
3371 dyn_cast_or_null<VectorType>(getTypeByID(OpTyID));
3373 return error(
"Invalid extractelement constexpr record");
3375 if (
Record.size() == 4) {
3376 unsigned IdxTyID =
Record[2];
3377 Type *IdxTy = getTypeByID(IdxTyID);
3379 return error(
"Invalid extractelement constexpr record");
3385 V = BitcodeConstant::create(Alloc, CurTy, Instruction::ExtractElement,
3391 VectorType *OpTy = dyn_cast<VectorType>(CurTy);
3392 if (
Record.size() < 3 || !OpTy)
3393 return error(
"Invalid insertelement constexpr record");
3395 if (
Record.size() == 4) {
3396 unsigned IdxTyID =
Record[2];
3397 Type *IdxTy = getTypeByID(IdxTyID);
3399 return error(
"Invalid insertelement constexpr record");
3405 V = BitcodeConstant::create(
3406 Alloc, CurTy, Instruction::InsertElement,
3411 VectorType *OpTy = dyn_cast<VectorType>(CurTy);
3412 if (
Record.size() < 3 || !OpTy)
3413 return error(
"Invalid shufflevector constexpr record");
3414 V = BitcodeConstant::create(
3415 Alloc, CurTy, Instruction::ShuffleVector,
3420 VectorType *RTy = dyn_cast<VectorType>(CurTy);
3422 dyn_cast_or_null<VectorType>(getTypeByID(
Record[0]));
3423 if (
Record.size() < 4 || !RTy || !OpTy)
3424 return error(
"Invalid shufflevector constexpr record");
3425 V = BitcodeConstant::create(
3426 Alloc, CurTy, Instruction::ShuffleVector,
3432 return error(
"Invalid cmp constexpt record");
3433 unsigned OpTyID =
Record[0];
3434 Type *OpTy = getTypeByID(OpTyID);
3436 return error(
"Invalid cmp constexpr record");
3437 V = BitcodeConstant::create(
3440 : Instruction::ICmp),
3449 return error(
"Invalid inlineasm record");
3450 std::string AsmStr, ConstrStr;
3451 bool HasSideEffects =
Record[0] & 1;
3452 bool IsAlignStack =
Record[0] >> 1;
3453 unsigned AsmStrSize =
Record[1];
3454 if (2+AsmStrSize >=
Record.size())
3455 return error(
"Invalid inlineasm record");
3456 unsigned ConstStrSize =
Record[2+AsmStrSize];
3457 if (3+AsmStrSize+ConstStrSize >
Record.size())
3458 return error(
"Invalid inlineasm record");
3460 for (
unsigned i = 0; i != AsmStrSize; ++i)
3461 AsmStr += (
char)
Record[2+i];
3462 for (
unsigned i = 0; i != ConstStrSize; ++i)
3463 ConstrStr += (
char)
Record[3+AsmStrSize+i];
3466 return error(
"Missing element type for old-style inlineasm");
3468 HasSideEffects, IsAlignStack);
3475 return error(
"Invalid inlineasm record");
3476 std::string AsmStr, ConstrStr;
3477 bool HasSideEffects =
Record[0] & 1;
3478 bool IsAlignStack = (
Record[0] >> 1) & 1;
3479 unsigned AsmDialect =
Record[0] >> 2;
3480 unsigned AsmStrSize =
Record[1];
3481 if (2+AsmStrSize >=
Record.size())
3482 return error(
"Invalid inlineasm record");
3483 unsigned ConstStrSize =
Record[2+AsmStrSize];
3484 if (3+AsmStrSize+ConstStrSize >
Record.size())
3485 return error(
"Invalid inlineasm record");
3487 for (
unsigned i = 0; i != AsmStrSize; ++i)
3488 AsmStr += (
char)
Record[2+i];
3489 for (
unsigned i = 0; i != ConstStrSize; ++i)
3490 ConstrStr += (
char)
Record[3+AsmStrSize+i];
3493 return error(
"Missing element type for old-style inlineasm");
3495 HasSideEffects, IsAlignStack,
3502 return error(
"Invalid inlineasm record");
3504 std::string AsmStr, ConstrStr;
3505 bool HasSideEffects =
Record[OpNum] & 1;
3506 bool IsAlignStack = (
Record[OpNum] >> 1) & 1;
3507 unsigned AsmDialect = (
Record[OpNum] >> 2) & 1;
3508 bool CanThrow = (
Record[OpNum] >> 3) & 1;
3510 unsigned AsmStrSize =
Record[OpNum];
3512 if (OpNum + AsmStrSize >=
Record.size())
3513 return error(
"Invalid inlineasm record");
3514 unsigned ConstStrSize =
Record[OpNum + AsmStrSize];
3515 if (OpNum + 1 + AsmStrSize + ConstStrSize >
Record.size())
3516 return error(
"Invalid inlineasm record");
3518 for (
unsigned i = 0; i != AsmStrSize; ++i)
3519 AsmStr += (
char)
Record[OpNum + i];
3521 for (
unsigned i = 0; i != ConstStrSize; ++i)
3522 ConstrStr += (
char)
Record[OpNum + AsmStrSize + i];
3525 return error(
"Missing element type for old-style inlineasm");
3527 HasSideEffects, IsAlignStack,
3534 return error(
"Invalid inlineasm record");
3536 auto *FnTy = dyn_cast_or_null<FunctionType>(getTypeByID(
Record[OpNum]));
3539 return error(
"Invalid inlineasm record");
3540 std::string AsmStr, ConstrStr;
3541 bool HasSideEffects =
Record[OpNum] & 1;
3542 bool IsAlignStack = (
Record[OpNum] >> 1) & 1;
3543 unsigned AsmDialect = (
Record[OpNum] >> 2) & 1;
3544 bool CanThrow = (
Record[OpNum] >> 3) & 1;
3546 unsigned AsmStrSize =
Record[OpNum];
3548 if (OpNum + AsmStrSize >=
Record.size())
3549 return error(
"Invalid inlineasm record");
3550 unsigned ConstStrSize =
Record[OpNum + AsmStrSize];
3551 if (OpNum + 1 + AsmStrSize + ConstStrSize >
Record.size())
3552 return error(
"Invalid inlineasm record");
3554 for (
unsigned i = 0; i != AsmStrSize; ++i)
3555 AsmStr += (
char)
Record[OpNum + i];
3557 for (
unsigned i = 0; i != ConstStrSize; ++i)
3558 ConstrStr += (
char)
Record[OpNum + AsmStrSize + i];
3560 V =
InlineAsm::get(FnTy, AsmStr, ConstrStr, HasSideEffects, IsAlignStack,
3566 return error(
"Invalid blockaddress record");
3567 unsigned FnTyID =
Record[0];
3568 Type *FnTy = getTypeByID(FnTyID);
3570 return error(
"Invalid blockaddress record");
3571 V = BitcodeConstant::create(
3579 return error(
"Invalid dso_local record");
3580 unsigned GVTyID =
Record[0];
3581 Type *GVTy = getTypeByID(GVTyID);
3583 return error(
"Invalid dso_local record");
3584 V = BitcodeConstant::create(
3585 Alloc, CurTy, BitcodeConstant::DSOLocalEquivalentOpcode,
Record[1]);
3590 return error(
"Invalid no_cfi record");
3591 unsigned GVTyID =
Record[0];
3592 Type *GVTy = getTypeByID(GVTyID);
3594 return error(
"Invalid no_cfi record");
3595 V = BitcodeConstant::create(Alloc, CurTy, BitcodeConstant::NoCFIOpcode,
3601 assert(
V->getType() == getTypeByID(CurTyID) &&
"Incorrect result type ID");
3608Error BitcodeReader::parseUseLists() {
3621 switch (Entry.Kind) {
3624 return error(
"Malformed block");
3638 switch (MaybeRecord.
get()) {
3646 if (RecordLength < 3)
3648 return error(
"Invalid record");
3649 unsigned ID =
Record.pop_back_val();
3653 assert(
ID < FunctionBBs.size() &&
"Basic block not found");
3654 V = FunctionBBs[
ID];
3657 unsigned NumUses = 0;
3659 for (
const Use &U :
V->materialized_uses()) {
3660 if (++NumUses >
Record.size())
3662 Order[&
U] =
Record[NumUses - 1];
3669 V->sortUseList([&](
const Use &L,
const Use &R) {
3680Error BitcodeReader::rememberAndSkipMetadata() {
3682 uint64_t CurBit = Stream.GetCurrentBitNo();
3683 DeferredMetadataInfo.push_back(CurBit);
3686 if (
Error Err = Stream.SkipBlock())
3691Error BitcodeReader::materializeMetadata() {
3692 for (
uint64_t BitPos : DeferredMetadataInfo) {
3694 if (
Error JumpFailed = Stream.JumpToBit(BitPos))
3696 if (
Error Err = MDLoader->parseModuleMetadata())
3707 for (
const MDOperand &MDOptions : cast<MDNode>(Val)->operands())
3708 LinkerOpts->
addOperand(cast<MDNode>(MDOptions));
3712 DeferredMetadataInfo.clear();
3716void BitcodeReader::setStripDebugInfo() {
StripDebugInfo =
true; }
3720Error BitcodeReader::rememberAndSkipFunctionBody() {
3722 if (FunctionsWithBodies.empty())
3723 return error(
"Insufficient function protos");
3726 FunctionsWithBodies.pop_back();
3729 uint64_t CurBit = Stream.GetCurrentBitNo();
3731 (DeferredFunctionInfo[Fn] == 0 || DeferredFunctionInfo[Fn] == CurBit) &&
3732 "Mismatch between VST and scanned function offsets");
3733 DeferredFunctionInfo[Fn] = CurBit;
3736 if (
Error Err = Stream.SkipBlock())
3741Error BitcodeReader::globalCleanup() {
3743 if (
Error Err = resolveGlobalAndIndirectSymbolInits())
3745 if (!GlobalInits.empty() || !IndirectSymbolInits.empty())
3746 return error(
"Malformed global initializer set");
3751 MDLoader->upgradeDebugIntrinsics(
F);
3754 UpgradedIntrinsics[&
F] = NewFn;
3760 std::vector<std::pair<GlobalVariable *, GlobalVariable *>> UpgradedVariables;
3763 UpgradedVariables.emplace_back(&GV, Upgraded);
3764 for (
auto &Pair : UpgradedVariables) {
3765 Pair.first->eraseFromParent();
3766 TheModule->insertGlobalVariable(Pair.second);
3771 std::vector<std::pair<GlobalVariable *, unsigned>>().
swap(GlobalInits);
3772 std::vector<std::pair<GlobalValue *, unsigned>>().
swap(IndirectSymbolInits);
3780Error BitcodeReader::rememberAndSkipFunctionBodies() {
3781 if (
Error JumpFailed = Stream.JumpToBit(NextUnreadBit))
3784 if (Stream.AtEndOfStream())
3785 return error(
"Could not find function in stream");
3787 if (!SeenFirstFunctionBody)
3788 return error(
"Trying to materialize functions before seeing function blocks");
3792 assert(SeenValueSymbolTable);
3802 switch (Entry.Kind) {
3804 return error(
"Expect SubBlock");
3808 return error(
"Expect function block");
3810 if (
Error Err = rememberAndSkipFunctionBody())
3812 NextUnreadBit = Stream.GetCurrentBitNo();
3819Error BitcodeReaderBase::readBlockInfo() {
3821 Stream.ReadBlockInfoBlock();
3822 if (!MaybeNewBlockInfo)
3824 std::optional<BitstreamBlockInfo> NewBlockInfo =
3825 std::move(MaybeNewBlockInfo.
get());
3827 return error(
"Malformed block");
3828 BlockInfo = std::move(*NewBlockInfo);
3839 return error(
"Invalid record");
3841 std::string OldFormatName;
3844 return error(
"Invalid record");
3845 unsigned ComdatNameSize =
Record[1];
3846 if (ComdatNameSize >
Record.size() - 2)
3847 return error(
"Comdat name size too large");
3848 OldFormatName.reserve(ComdatNameSize);
3849 for (
unsigned i = 0; i != ComdatNameSize; ++i)
3850 OldFormatName += (
char)
Record[2 + i];
3851 Name = OldFormatName;
3854 C->setSelectionKind(SK);
3855 ComdatList.push_back(
C);
3869 Meta.NoAddress =
true;
3871 Meta.NoHWAddress =
true;
3875 Meta.IsDynInit =
true;
3890 return error(
"Invalid record");
3891 unsigned TyID =
Record[0];
3892 Type *Ty = getTypeByID(TyID);
3894 return error(
"Invalid record");
3896 bool explicitType =
Record[1] & 2;
3902 return error(
"Invalid type for value");
3903 AddressSpace = cast<PointerType>(Ty)->getAddressSpace();
3904 TyID = getContainedTypeID(TyID);
3905 Ty = getTypeByID(TyID);
3907 return error(
"Missing element type for old-style global");
3913 if (
Error Err = parseAlignmentValue(
Record[4], Alignment))
3917 if (
Record[5] - 1 >= SectionTable.size())
3918 return error(
"Invalid ID");
3935 bool ExternallyInitialized =
false;
3937 ExternallyInitialized =
Record[9];
3949 if (
Record.size() > 10) {
3961 if (
unsigned InitID =
Record[2])
3962 GlobalInits.push_back(std::make_pair(NewGV, InitID - 1));
3964 if (
Record.size() > 11) {
3965 if (
unsigned ComdatID =
Record[11]) {
3966 if (ComdatID > ComdatList.size())
3967 return error(
"Invalid global variable comdat ID");
3968 NewGV->
setComdat(ComdatList[ComdatID - 1]);
3971 ImplicitComdatObjects.
insert(NewGV);
3974 if (
Record.size() > 12) {
3979 if (
Record.size() > 13) {
3998 return error(
"Invalid global variable code model");
4004void BitcodeReader::callValueTypeCallback(
Value *
F,
unsigned TypeID) {
4005 if (ValueTypeCallback) {
4006 (*ValueTypeCallback)(
4007 F,
TypeID, [
this](
unsigned I) {
return getTypeByID(
I); },
4008 [
this](
unsigned I,
unsigned J) {
return getContainedTypeID(
I, J); });
4021 return error(
"Invalid record");
4022 unsigned FTyID =
Record[0];
4023 Type *FTy = getTypeByID(FTyID);
4025 return error(
"Invalid record");
4026 if (isa<PointerType>(FTy)) {
4027 FTyID = getContainedTypeID(FTyID, 0);
4028 FTy = getTypeByID(FTyID);
4030 return error(
"Missing element type for old-style function");
4033 if (!isa<FunctionType>(FTy))
4034 return error(
"Invalid type for value");
4037 return error(
"Invalid calling convention ID");
4039 unsigned AddrSpace = TheModule->getDataLayout().getProgramAddressSpace();
4045 AddrSpace,
Name, TheModule);
4048 "Incorrect fully specified type provided for function");
4049 FunctionTypeIDs[
Func] = FTyID;
4051 Func->setCallingConv(
CC);
4052 bool isProto =
Record[2];
4056 callValueTypeCallback(Func, FTyID);
4061 for (
unsigned i = 0; i !=
Func->arg_size(); ++i) {
4063 Attribute::InAlloca}) {
4064 if (!
Func->hasParamAttribute(i, Kind))
4067 if (
Func->getParamAttribute(i, Kind).getValueAsType())
4070 Func->removeParamAttr(i, Kind);
4072 unsigned ParamTypeID = getContainedTypeID(FTyID, i + 1);
4073 Type *PtrEltTy = getPtrElementTypeByID(ParamTypeID);
4075 return error(
"Missing param element type for attribute upgrade");
4079 case Attribute::ByVal:
4082 case Attribute::StructRet:
4085 case Attribute::InAlloca:
4092 Func->addParamAttr(i, NewAttr);
4097 !
Func->arg_empty() && !
Func->hasParamAttribute(0, Attribute::ByVal)) {
4098 unsigned ParamTypeID = getContainedTypeID(FTyID, 1);
4099 Type *ByValTy = getPtrElementTypeByID(ParamTypeID);
4101 return error(
"Missing param element type for x86_intrcc upgrade");
4103 Func->addParamAttr(0, NewAttr);
4107 if (
Error Err = parseAlignmentValue(
Record[5], Alignment))
4110 Func->setAlignment(*Alignment);
4112 if (
Record[6] - 1 >= SectionTable.size())
4113 return error(
"Invalid ID");
4114 Func->setSection(SectionTable[
Record[6] - 1]);
4118 if (!
Func->hasLocalLinkage())
4121 if (
Record[8] - 1 >= GCTable.size())
4122 return error(
"Invalid ID");
4128 Func->setUnnamedAddr(UnnamedAddr);
4130 FunctionOperandInfo OperandInfo = {
Func, 0, 0, 0};
4132 OperandInfo.Prologue =
Record[10];
4134 if (
Record.size() > 11) {
4136 if (!
Func->hasLocalLinkage()) {
4143 if (
Record.size() > 12) {
4144 if (
unsigned ComdatID =
Record[12]) {
4145 if (ComdatID > ComdatList.size())
4146 return error(
"Invalid function comdat ID");
4147 Func->setComdat(ComdatList[ComdatID - 1]);
4150 ImplicitComdatObjects.
insert(Func);
4154 OperandInfo.Prefix =
Record[13];
4157 OperandInfo.PersonalityFn =
Record[14];
4159 if (
Record.size() > 15) {
4168 if (
Record.size() > 18 && Strtab.data() &&
4173 ValueList.
push_back(Func, getVirtualTypeID(
Func->getType(), FTyID));
4175 if (OperandInfo.PersonalityFn || OperandInfo.Prefix || OperandInfo.Prologue)
4176 FunctionOperands.push_back(OperandInfo);
4181 Func->setIsMaterializable(
true);
4182 FunctionsWithBodies.push_back(Func);
4183 DeferredFunctionInfo[
Func] = 0;
4188Error BitcodeReader::parseGlobalIndirectSymbolRecord(
4202 if (
Record.size() < (3 + (
unsigned)NewRecord))
4203 return error(
"Invalid record");
4208 return error(
"Invalid record");
4212 auto *PTy = dyn_cast<PointerType>(Ty);
4214 return error(
"Invalid type for value");
4215 AddrSpace = PTy->getAddressSpace();
4217 Ty = getTypeByID(
TypeID);
4219 return error(
"Missing element type for old-style indirect symbol");
4221 AddrSpace =
Record[OpNum++];
4224 auto Val =
Record[OpNum++];
4233 nullptr, TheModule);
4237 if (OpNum !=
Record.size()) {
4238 auto VisInd = OpNum++;
4244 if (OpNum !=
Record.size()) {
4245 auto S =
Record[OpNum++];
4252 if (OpNum !=
Record.size())
4254 if (OpNum !=
Record.size())
4257 if (OpNum !=
Record.size())
4262 if (OpNum + 1 <
Record.size()) {
4265 return error(
"Malformed partition, too large.");
4272 IndirectSymbolInits.push_back(std::make_pair(NewGA, Val));
4277 bool ShouldLazyLoadMetadata,
4281 TheModule->IsNewDbgInfoFormat =
false;
4283 this->ValueTypeCallback = std::move(Callbacks.
ValueType);
4285 if (
Error JumpFailed = Stream.JumpToBit(ResumeBit))
4294 bool ResolvedDataLayout =
false;
4299 std::string TentativeDataLayoutStr = TheModule->getDataLayoutStr();
4301 auto ResolveDataLayout = [&]() ->
Error {
4302 if (ResolvedDataLayout)
4306 ResolvedDataLayout =
true;
4310 TentativeDataLayoutStr, TheModule->getTargetTriple());
4314 if (
auto LayoutOverride = (*Callbacks.
DataLayout)(
4315 TheModule->getTargetTriple(), TentativeDataLayoutStr))
4316 TentativeDataLayoutStr = *LayoutOverride;
4324 TheModule->setDataLayout(MaybeDL.
get());
4335 switch (Entry.Kind) {
4337 return error(
"Malformed block");
4339 if (
Error Err = ResolveDataLayout())
4341 return globalCleanup();
4346 if (
Error Err = Stream.SkipBlock())
4350 if (
Error Err = readBlockInfo())
4354 if (
Error Err = parseAttributeBlock())
4358 if (
Error Err = parseAttributeGroupBlock())
4362 if (
Error Err = parseTypeTable())
4366 if (!SeenValueSymbolTable) {
4372 assert(VSTOffset == 0 || FunctionsWithBodies.empty());
4373 if (
Error Err = parseValueSymbolTable())
4375 SeenValueSymbolTable =
true;
4380 if (
Error Err = Stream.SkipBlock())
4385 if (
Error Err = parseConstants())
4387 if (
Error Err = resolveGlobalAndIndirectSymbolInits())
4391 if (ShouldLazyLoadMetadata) {
4392 if (
Error Err = rememberAndSkipMetadata())
4396 assert(DeferredMetadataInfo.empty() &&
"Unexpected deferred metadata");
4397 if (
Error Err = MDLoader->parseModuleMetadata())
4401 if (
Error Err = MDLoader->parseMetadataKinds())
4405 if (
Error Err = ResolveDataLayout())
4410 if (!SeenFirstFunctionBody) {
4411 std::reverse(FunctionsWithBodies.begin(), FunctionsWithBodies.end());
4412 if (
Error Err = globalCleanup())
4414 SeenFirstFunctionBody =
true;
4417 if (VSTOffset > 0) {
4421 if (!SeenValueSymbolTable) {
4422 if (
Error Err = BitcodeReader::parseValueSymbolTable(VSTOffset))
4424 SeenValueSymbolTable =
true;
4436 if (
Error Err = Stream.SkipBlock())
4446 if (
Error Err = rememberAndSkipFunctionBody())
4453 if (SeenValueSymbolTable) {
4454 NextUnreadBit = Stream.GetCurrentBitNo();
4457 return globalCleanup();
4461 if (
Error Err = parseUseLists())
4465 if (
Error Err = parseOperandBundleTags())
4469 if (
Error Err = parseSyncScopeNames())
4484 switch (
unsigned BitCode = MaybeBitCode.
get()) {
4490 UseRelativeIDs = *VersionOrErr >= 1;
4494 if (ResolvedDataLayout)
4495 return error(
"target triple too late in module");
4498 return error(
"Invalid record");
4499 TheModule->setTargetTriple(S);
4503 if (ResolvedDataLayout)
4504 return error(
"datalayout too late in module");
4506 return error(
"Invalid record");
4512 return error(
"Invalid record");
4513 TheModule->setModuleInlineAsm(S);
4520 return error(
"Invalid record");
4527 return error(
"Invalid record");
4528 SectionTable.push_back(S);
4534 return error(
"Invalid record");
4535 GCTable.push_back(S);
4552 if (
Error Err = ResolveDataLayout())
4560 if (
Error Err = parseGlobalIndirectSymbolRecord(BitCode,
Record))
4566 return error(
"Invalid record");
4570 VSTOffset =
Record[0] - 1;
4576 return error(
"Invalid record");
4577 TheModule->setSourceFileName(
ValueName);
4582 this->ValueTypeCallback = std::nullopt;
4586Error BitcodeReader::parseBitcodeInto(
Module *M,
bool ShouldLazyLoadMetadata,
4591 MDCallbacks.
GetTypeByID = [&](
unsigned ID) {
return getTypeByID(
ID); };
4593 return getContainedTypeID(
I, J);
4596 MDLoader =
MetadataLoader(Stream, *M, ValueList, IsImporting, MDCallbacks);
4597 return parseModule(0, ShouldLazyLoadMetadata, Callbacks);
4600Error BitcodeReader::typeCheckLoadStoreInst(
Type *ValType,
Type *PtrType) {
4601 if (!isa<PointerType>(PtrType))
4602 return error(
"Load/Store operand is not a pointer type");
4603 if (!PointerType::isLoadableOrStorableType(ValType))
4604 return error(
"Cannot load/store from pointer");
4611 for (
unsigned i = 0; i != CB->
arg_size(); ++i) {
4613 Attribute::InAlloca}) {
4614 if (!
Attrs.hasParamAttr(i, Kind) ||
4615 Attrs.getParamAttr(i, Kind).getValueAsType())
4618 Type *PtrEltTy = getPtrElementTypeByID(ArgTyIDs[i]);
4620 return error(
"Missing element type for typed attribute upgrade");
4624 case Attribute::ByVal:
4627 case Attribute::StructRet:
4630 case Attribute::InAlloca:
4637 Attrs =
Attrs.addParamAttribute(Context, i, NewAttr);
4648 if (CI.isIndirect && !
Attrs.getParamElementType(ArgNo)) {
4649 Type *ElemTy = getPtrElementTypeByID(ArgTyIDs[ArgNo]);
4651 return error(
"Missing element type for inline asm upgrade");
4662 case Intrinsic::preserve_array_access_index:
4663 case Intrinsic::preserve_struct_access_index:
4664 case Intrinsic::aarch64_ldaxr:
4665 case Intrinsic::aarch64_ldxr:
4666 case Intrinsic::aarch64_stlxr:
4667 case Intrinsic::aarch64_stxr:
4668 case Intrinsic::arm_ldaex:
4669 case Intrinsic::arm_ldrex:
4670 case Intrinsic::arm_stlex:
4671 case Intrinsic::arm_strex: {
4674 case Intrinsic::aarch64_stlxr:
4675 case Intrinsic::aarch64_stxr:
4676 case Intrinsic::arm_stlex:
4677 case Intrinsic::arm_strex:
4684 if (!
Attrs.getParamElementType(ArgNo)) {
4685 Type *ElTy = getPtrElementTypeByID(ArgTyIDs[ArgNo]);
4687 return error(
"Missing element type for elementtype upgrade");
4689 Attrs =
Attrs.addParamAttribute(Context, ArgNo, NewAttr);
4707 if (MDLoader->hasFwdRefs())
4708 return error(
"Invalid function metadata: incoming forward references");
4710 InstructionList.
clear();
4711 unsigned ModuleValueListSize = ValueList.
size();
4712 unsigned ModuleMDLoaderSize = MDLoader->size();
4716 unsigned FTyID = FunctionTypeIDs[
F];
4718 unsigned ArgTyID = getContainedTypeID(FTyID, ArgNo + 1);
4719 assert(
I.getType() == getTypeByID(ArgTyID) &&
4720 "Incorrect fully specified type for Function Argument");
4724 unsigned NextValueNo = ValueList.
size();
4726 unsigned CurBBNo = 0;
4735 auto getLastInstruction = [&]() ->
Instruction * {
4736 if (CurBB && !CurBB->
empty())
4737 return &CurBB->
back();
4738 else if (CurBBNo && FunctionBBs[CurBBNo - 1] &&
4739 !FunctionBBs[CurBBNo - 1]->empty())
4740 return &FunctionBBs[CurBBNo - 1]->back();
4744 std::vector<OperandBundleDef> OperandBundles;
4755 switch (Entry.Kind) {
4757 return error(
"Malformed block");
4759 goto OutOfRecordLoop;
4764 if (
Error Err = Stream.SkipBlock())
4768 if (
Error Err = parseConstants())
4770 NextValueNo = ValueList.
size();
4773 if (
Error Err = parseValueSymbolTable())
4777 if (
Error Err = MDLoader->parseMetadataAttachment(*
F, InstructionList))
4781 assert(DeferredMetadataInfo.empty() &&
4782 "Must read all module-level metadata before function-level");
4783 if (
Error Err = MDLoader->parseFunctionMetadata())
4787 if (
Error Err = parseUseLists())
4801 unsigned ResTypeID = InvalidTypeID;
4805 switch (
unsigned BitCode = MaybeBitCode.
get()) {
4807 return error(
"Invalid value");
4810 return error(
"Invalid record");
4812 FunctionBBs.resize(
Record[0]);
4815 auto BBFRI = BasicBlockFwdRefs.
find(
F);
4816 if (BBFRI == BasicBlockFwdRefs.
end()) {
4820 auto &BBRefs = BBFRI->second;
4822 if (BBRefs.size() > FunctionBBs.size())
4823 return error(
"Invalid ID");
4824 assert(!BBRefs.empty() &&
"Unexpected empty array");
4825 assert(!BBRefs.front() &&
"Invalid reference to entry block");
4826 for (
unsigned I = 0,
E = FunctionBBs.size(), RE = BBRefs.size();
I !=
E;
4828 if (
I < RE && BBRefs[
I]) {
4829 BBRefs[
I]->insertInto(
F);
4830 FunctionBBs[
I] = BBRefs[
I];
4836 BasicBlockFwdRefs.
erase(BBFRI);
4839 CurBB = FunctionBBs[0];
4846 return error(
"Invalid record");
4861 if (
auto *
F = dyn_cast<Function>(ValueList[
ValID]))
4862 BackwardRefFunctions.push_back(
F);
4864 return error(
"Invalid record");
4871 I = getLastInstruction();
4874 return error(
"Invalid record");
4875 I->setDebugLoc(LastLoc);
4880 I = getLastInstruction();
4882 return error(
"Invalid record");
4890 Scope = dyn_cast_or_null<MDNode>(
4891 MDLoader->getMetadataFwdRefOrLoad(ScopeID - 1));
4893 return error(
"Invalid record");
4896 IA = dyn_cast_or_null<MDNode>(
4897 MDLoader->getMetadataFwdRefOrLoad(IAID - 1));
4899 return error(
"Invalid record");
4901 LastLoc = DILocation::get(
Scope->getContext(), Line, Col, Scope, IA,
4903 I->setDebugLoc(LastLoc);
4911 if (getValueTypePair(
Record, OpNum, NextValueNo, LHS,
TypeID, CurBB) ||
4913 return error(
"Invalid record");
4917 return error(
"Invalid record");
4921 if (OpNum <
Record.size()) {
4922 if (isa<FPMathOperator>(
I)) {
4925 I->setFastMathFlags(FMF);
4934 if (getValueTypePair(
Record, OpNum, NextValueNo, LHS,
TypeID, CurBB) ||
4938 return error(
"Invalid record");
4942 return error(
"Invalid record");
4946 if (OpNum <
Record.size()) {
4947 if (Opc == Instruction::Add ||
4948 Opc == Instruction::Sub ||
4949 Opc == Instruction::Mul ||
4950 Opc == Instruction::Shl) {
4952 cast<BinaryOperator>(
I)->setHasNoSignedWrap(
true);
4954 cast<BinaryOperator>(
I)->setHasNoUnsignedWrap(
true);
4955 }
else if (Opc == Instruction::SDiv ||
4956 Opc == Instruction::UDiv ||
4957 Opc == Instruction::LShr ||
4958 Opc == Instruction::AShr) {
4960 cast<BinaryOperator>(
I)->setIsExact(
true);
4961 }
else if (Opc == Instruction::Or) {
4963 cast<PossiblyDisjointInst>(
I)->setIsDisjoint(
true);
4964 }
else if (isa<FPMathOperator>(
I)) {
4967 I->setFastMathFlags(FMF);
4976 if (getValueTypePair(
Record, OpNum, NextValueNo,
Op, OpTypeID, CurBB) ||
4977 OpNum + 1 >
Record.size())
4978 return error(
"Invalid record");
4980 ResTypeID =
Record[OpNum++];
4981 Type *ResTy = getTypeByID(ResTypeID);
4984 if (Opc == -1 || !ResTy)
4985 return error(
"Invalid record");
4990 assert(CurBB &&
"No current BB?");
4996 return error(
"Invalid cast");
4999 if (OpNum <
Record.size() && isa<PossiblyNonNegInst>(
I) &&
5015 InBounds =
Record[OpNum++];
5017 Ty = getTypeByID(TyID);
5020 TyID = InvalidTypeID;
5025 unsigned BasePtrTypeID;
5026 if (getValueTypePair(
Record, OpNum, NextValueNo, BasePtr, BasePtrTypeID,
5028 return error(
"Invalid record");
5031 TyID = getContainedTypeID(BasePtrTypeID);
5032 if (
BasePtr->getType()->isVectorTy())
5033 TyID = getContainedTypeID(TyID);
5034 Ty = getTypeByID(TyID);
5038 while (OpNum !=
Record.size()) {
5041 if (getValueTypePair(
Record, OpNum, NextValueNo,
Op, OpTypeID, CurBB))
5042 return error(
"Invalid record");
5049 if (cast<GEPOperator>(
I)->getNumIndices() != 0) {
5052 unsigned SubType = 0;
5053 if (GTI.isStruct()) {
5055 Idx->getType()->isVectorTy()
5060 ResTypeID = getContainedTypeID(ResTypeID, SubType);
5067 ResTypeID = getVirtualTypeID(
I->getType()->getScalarType(), ResTypeID);
5068 if (
I->getType()->isVectorTy())
5069 ResTypeID = getVirtualTypeID(
I->getType(), ResTypeID);
5073 cast<GetElementPtrInst>(
I)->setIsInBounds(
true);
5082 if (getValueTypePair(
Record, OpNum, NextValueNo, Agg, AggTypeID, CurBB))
5083 return error(
"Invalid record");
5086 unsigned RecSize =
Record.size();
5087 if (OpNum == RecSize)
5088 return error(
"EXTRACTVAL: Invalid instruction with 0 indices");
5091 ResTypeID = AggTypeID;
5092 for (; OpNum != RecSize; ++OpNum) {
5097 if (!IsStruct && !IsArray)
5098 return error(
"EXTRACTVAL: Invalid type");
5100 return error(
"Invalid value");
5102 return error(
"EXTRACTVAL: Invalid struct index");
5104 return error(
"EXTRACTVAL: Invalid array index");
5109 ResTypeID = getContainedTypeID(ResTypeID,
Index);
5112 ResTypeID = getContainedTypeID(ResTypeID);
5126 if (getValueTypePair(
Record, OpNum, NextValueNo, Agg, AggTypeID, CurBB))
5127 return error(
"Invalid record");
5130 if (getValueTypePair(
Record, OpNum, NextValueNo, Val, ValTypeID, CurBB))
5131 return error(
"Invalid record");
5133 unsigned RecSize =
Record.size();
5134 if (OpNum == RecSize)
5135 return error(
"INSERTVAL: Invalid instruction with 0 indices");
5139 for (; OpNum != RecSize; ++OpNum) {
5144 if (!IsStruct && !IsArray)
5145 return error(
"INSERTVAL: Invalid type");
5147 return error(
"Invalid value");
5149 return error(
"INSERTVAL: Invalid struct index");
5151 return error(
"INSERTVAL: Invalid array index");
5161 return error(
"Inserted value type doesn't match aggregate type");
5164 ResTypeID = AggTypeID;
5176 if (getValueTypePair(
Record, OpNum, NextValueNo, TrueVal,
TypeID,
5180 popValue(
Record, OpNum, NextValueNo, CondType,
5181 getVirtualTypeID(CondType),
Cond, CurBB))
5182 return error(
"Invalid record");
5195 unsigned ValTypeID, CondTypeID;
5196 if (getValueTypePair(
Record, OpNum, NextValueNo, TrueVal, ValTypeID,
5198 popValue(
Record, OpNum, NextValueNo,
TrueVal->getType(), ValTypeID,
5200 getValueTypePair(
Record, OpNum, NextValueNo,
Cond, CondTypeID, CurBB))
5201 return error(
"Invalid record");
5205 dyn_cast<VectorType>(
Cond->getType())) {
5208 return error(
"Invalid type for value");
5212 return error(
"Invalid type for value");
5216 ResTypeID = ValTypeID;
5218 if (OpNum <
Record.size() && isa<FPMathOperator>(
I)) {
5221 I->setFastMathFlags(FMF);
5229 unsigned VecTypeID, IdxTypeID;
5230 if (getValueTypePair(
Record, OpNum, NextValueNo, Vec, VecTypeID, CurBB) ||
5231 getValueTypePair(
Record, OpNum, NextValueNo,
Idx, IdxTypeID, CurBB))
5232 return error(
"Invalid record");
5234 return error(
"Invalid type for value");
5236 ResTypeID = getContainedTypeID(VecTypeID);
5244 unsigned VecTypeID, IdxTypeID;
5245 if (getValueTypePair(
Record, OpNum, NextValueNo, Vec, VecTypeID, CurBB))
5246 return error(
"Invalid record");
5248 return error(
"Invalid type for value");
5249 if (popValue(
Record, OpNum, NextValueNo,
5250 cast<VectorType>(Vec->
getType())->getElementType(),
5251 getContainedTypeID(VecTypeID), Elt, CurBB) ||
5252 getValueTypePair(
Record, OpNum, NextValueNo,
Idx, IdxTypeID, CurBB))
5253 return error(
"Invalid record");
5255 ResTypeID = VecTypeID;
5263 unsigned Vec1TypeID;
5264 if (getValueTypePair(
Record, OpNum, NextValueNo, Vec1, Vec1TypeID,
5266 popValue(
Record, OpNum, NextValueNo, Vec1->
getType(), Vec1TypeID,
5268 return error(
"Invalid record");
5270 unsigned MaskTypeID;
5271 if (getValueTypePair(
Record, OpNum, NextValueNo, Mask, MaskTypeID, CurBB))
5272 return error(
"Invalid record");
5274 return error(
"Invalid type for value");
5278 getVirtualTypeID(
I->getType(), getContainedTypeID(Vec1TypeID));
5293 if (getValueTypePair(
Record, OpNum, NextValueNo, LHS, LHSTypeID, CurBB) ||
5296 return error(
"Invalid record");
5298 if (OpNum >=
Record.size())
5300 "Invalid record: operand number exceeded available operands");
5305 if (IsFP &&
Record.size() > OpNum+1)
5308 if (OpNum+1 !=
Record.size())
5309 return error(
"Invalid record");
5313 return error(
"Invalid fcmp predicate");
5317 return error(
"Invalid icmp predicate");
5321 ResTypeID = getVirtualTypeID(
I->getType()->getScalarType());
5323 ResTypeID = getVirtualTypeID(
I->getType(), ResTypeID);
5326 I->setFastMathFlags(FMF);
5343 if (getValueTypePair(
Record, OpNum, NextValueNo,
Op, OpTypeID, CurBB))
5344 return error(
"Invalid record");
5345 if (OpNum !=
Record.size())
5346 return error(
"Invalid record");
5354 return error(
"Invalid record");
5357 return error(
"Invalid record");
5359 if (
Record.size() == 1) {
5367 getVirtualTypeID(CondType), CurBB);
5368 if (!FalseDest || !
Cond)
5369 return error(
"Invalid record");
5377 return error(
"Invalid record");
5380 Value *CleanupPad = getValue(
Record,
Idx++, NextValueNo, TokenTy,
5381 getVirtualTypeID(TokenTy), CurBB);
5383 return error(
"Invalid record");
5385 if (
Record.size() == 2) {
5386 UnwindDest = getBasicBlock(
Record[
Idx++]);
5388 return error(
"Invalid record");
5397 return error(
"Invalid record");
5401 getVirtualTypeID(TokenTy), CurBB);
5403 return error(
"Invalid record");
5406 return error(
"Invalid record");
5415 return error(
"Invalid record");
5421 getVirtualTypeID(TokenTy), CurBB);
5423 return error(
"Invalid record");
5428 for (
unsigned Op = 0;
Op != NumHandlers; ++
Op) {
5431 return error(
"Invalid record");
5437 UnwindDest = getBasicBlock(
Record[
Idx++]);
5439 return error(
"Invalid record");
5443 return error(
"Invalid record");
5448 CatchSwitch->addHandler(Handler);
5450 ResTypeID = getVirtualTypeID(
I->getType());
5458 return error(
"Invalid record");
5464 getVirtualTypeID(TokenTy), CurBB);
5466 return error(
"Invald record");
5468 unsigned NumArgOperands =
Record[
Idx++];
5471 for (
unsigned Op = 0;
Op != NumArgOperands; ++
Op) {
5474 if (getValueTypePair(
Record,
Idx, NextValueNo, Val, ValTypeID,
nullptr))
5475 return error(
"Invalid record");
5476 Args.push_back(Val);
5480 return error(
"Invalid record");
5486 ResTypeID = getVirtualTypeID(
I->getType());
5492 if ((
Record[0] >> 16) == SWITCH_INST_MAGIC) {
5498 unsigned OpTyID =
Record[1];
5499 Type *OpTy = getTypeByID(OpTyID);
5500 unsigned ValueBitWidth = cast<IntegerType>(OpTy)->getBitWidth();
5505 return error(
"Invalid record");
5507 unsigned NumCases =
Record[4];
5512 unsigned CurIdx = 5;
5513 for (
unsigned i = 0; i != NumCases; ++i) {
5515 unsigned NumItems =
Record[CurIdx++];
5516 for (
unsigned ci = 0; ci != NumItems; ++ci) {
5517 bool isSingleNumber =
Record[CurIdx++];
5520 unsigned ActiveWords = 1;
5521 if (ValueBitWidth > 64)
5522 ActiveWords =
Record[CurIdx++];
5525 CurIdx += ActiveWords;
5527 if (!isSingleNumber) {
5529 if (ValueBitWidth > 64)
5530 ActiveWords =
Record[CurIdx++];
5533 CurIdx += ActiveWords;
5546 SI->addCase(Cst, DestBB);
5555 return error(
"Invalid record");
5556 unsigned OpTyID =
Record[0];
5557 Type *OpTy = getTypeByID(OpTyID);
5561 return error(
"Invalid record");
5562 unsigned NumCases = (
Record.size()-3)/2;
5565 for (
unsigned i = 0, e = NumCases; i !=
e; ++i) {
5566 ConstantInt *CaseVal = dyn_cast_or_null<ConstantInt>(
5567 getFnValueByID(
Record[3+i*2], OpTy, OpTyID,
nullptr));
5569 if (!CaseVal || !DestBB) {
5571 return error(
"Invalid record");
5573 SI->addCase(CaseVal, DestBB);
5580 return error(
"Invalid record");
5581 unsigned OpTyID =
Record[0];
5582 Type *OpTy = getTypeByID(OpTyID);
5584 if (!OpTy || !Address)
5585 return error(
"Invalid record");
5586 unsigned NumDests =
Record.size()-2;
5589 for (
unsigned i = 0, e = NumDests; i !=
e; ++i) {
5594 return error(
"Invalid record");
5604 return error(
"Invalid record");
5607 unsigned CCInfo =
Record[OpNum++];
5611 unsigned FTyID = InvalidTypeID;
5613 if ((CCInfo >> 13) & 1) {
5615 FTy = dyn_cast<FunctionType>(getTypeByID(FTyID));
5617 return error(
"Explicit invoke type is not a function type");
5621 unsigned CalleeTypeID;
5622 if (getValueTypePair(
Record, OpNum, NextValueNo, Callee, CalleeTypeID,
5624 return error(
"Invalid record");
5628 return error(
"Callee is not a pointer");
5630 FTyID = getContainedTypeID(CalleeTypeID);
5631 FTy = dyn_cast_or_null<FunctionType>(getTypeByID(FTyID));
5633 return error(
"Callee is not of pointer to function type");
5635 if (
Record.size() < FTy->getNumParams() + OpNum)
5636 return error(
"Insufficient operands to call");
5640 for (
unsigned i = 0, e = FTy->getNumParams(); i != e; ++i, ++OpNum) {
5641 unsigned ArgTyID = getContainedTypeID(FTyID, i + 1);
5642 Ops.
push_back(getValue(
Record, OpNum, NextValueNo, FTy->getParamType(i),
5646 return error(
"Invalid record");
5649 if (!FTy->isVarArg()) {
5650 if (
Record.size() != OpNum)
5651 return error(
"Invalid record");
5654 while (OpNum !=
Record.size()) {
5657 if (getValueTypePair(
Record, OpNum, NextValueNo,
Op, OpTypeID, CurBB))
5658 return error(
"Invalid record");
5665 if (!OperandBundles.empty())
5670 ResTypeID = getContainedTypeID(FTyID);
5671 OperandBundles.clear();
5673 cast<InvokeInst>(
I)->setCallingConv(
5675 cast<InvokeInst>(
I)->setAttributes(PAL);
5676 if (
Error Err = propagateAttributeTypes(cast<CallBase>(
I), ArgTyIDs)) {
5685 Value *Val =
nullptr;
5687 if (getValueTypePair(
Record,
Idx, NextValueNo, Val, ValTypeID, CurBB))
5688 return error(
"Invalid record");
5697 unsigned CCInfo =
Record[OpNum++];
5700 unsigned NumIndirectDests =
Record[OpNum++];
5702 for (
unsigned i = 0, e = NumIndirectDests; i !=
e; ++i)
5705 unsigned FTyID = InvalidTypeID;
5709 FTy = dyn_cast_or_null<FunctionType>(getTypeByID(FTyID));
5711 return error(
"Explicit call type is not a function type");
5715 unsigned CalleeTypeID;
5716 if (getValueTypePair(
Record, OpNum, NextValueNo, Callee, CalleeTypeID,
5718 return error(
"Invalid record");
5722 return error(
"Callee is not a pointer type");
5724 FTyID = getContainedTypeID(CalleeTypeID);
5725 FTy = dyn_cast_or_null<FunctionType>(getTypeByID(FTyID));
5727 return error(
"Callee is not of pointer to function type");
5729 if (
Record.size() < FTy->getNumParams() + OpNum)
5730 return error(
"Insufficient operands to call");
5735 for (
unsigned i = 0, e = FTy->getNumParams(); i != e; ++i, ++OpNum) {
5737 unsigned ArgTyID = getContainedTypeID(FTyID, i + 1);
5738 if (FTy->getParamType(i)->isLabelTy())
5739 Arg = getBasicBlock(
Record[OpNum]);
5741 Arg = getValue(
Record, OpNum, NextValueNo, FTy->getParamType(i),
5744 return error(
"Invalid record");
5745 Args.push_back(Arg);
5750 if (!FTy->isVarArg()) {
5751 if (OpNum !=
Record.size())
5752 return error(
"Invalid record");
5754 while (OpNum !=
Record.size()) {
5757 if (getValueTypePair(
Record, OpNum, NextValueNo,
Op, OpTypeID, CurBB))
5758 return error(
"Invalid record");
5765 if (!OperandBundles.empty())
5768 if (
auto *IA = dyn_cast<InlineAsm>(Callee)) {
5773 if (
none_of(ConstraintInfo, IsLabelConstraint)) {
5778 unsigned FirstBlockArg =
Args.size() - IndirectDests.
size();
5779 for (
unsigned ArgNo = FirstBlockArg; ArgNo <
Args.size(); ++ArgNo) {
5780 unsigned LabelNo = ArgNo - FirstBlockArg;
5781 auto *BA = dyn_cast<BlockAddress>(Args[ArgNo]);
5782 if (!BA || BA->getFunction() !=
F ||
5783 LabelNo > IndirectDests.
size() ||
5784 BA->getBasicBlock() != IndirectDests[LabelNo])
5785 return error(
"callbr argument does not match indirect dest");
5790 ArgTyIDs.
erase(ArgTyIDs.
begin() + FirstBlockArg, ArgTyIDs.
end());
5794 for (
Value *Arg : Args)
5797 FunctionType::get(FTy->getReturnType(), ArgTys, FTy->isVarArg());
5800 std::string Constraints =
IA->getConstraintString();
5803 for (
const auto &CI : ConstraintInfo) {
5805 if (ArgNo >= FirstBlockArg)
5806 Constraints.insert(Pos,
"!");
5811 Pos = Constraints.find(
',', Pos);
5812 if (Pos == std::string::npos)
5818 IA->hasSideEffects(),
IA->isAlignStack(),
5819 IA->getDialect(),
IA->canThrow());
5825 ResTypeID = getContainedTypeID(FTyID);
5826 OperandBundles.clear();
5828 cast<CallBrInst>(
I)->setCallingConv(
5830 cast<CallBrInst>(
I)->setAttributes(PAL);
5831 if (
Error Err = propagateAttributeTypes(cast<CallBase>(
I), ArgTyIDs)) {
5843 return error(
"Invalid phi record");
5845 unsigned TyID =
Record[0];
5846 Type *Ty = getTypeByID(TyID);
5848 return error(
"Invalid phi record");
5853 size_t NumArgs = (
Record.size() - 1) / 2;
5855 if ((
Record.size() - 1) % 2 == 1 && !isa<FPMathOperator>(PN)) {
5857 return error(
"Invalid phi record");
5862 for (
unsigned i = 0; i != NumArgs; i++) {
5866 return error(
"Invalid phi BB");
5873 auto It =
Args.find(BB);
5874 if (It !=
Args.end()) {
5885 if (!PhiConstExprBB)
5887 EdgeBB = PhiConstExprBB;
5895 V = getValueSigned(
Record, i * 2 + 1, NextValueNo, Ty, TyID, EdgeBB);
5897 V = getValue(
Record, i * 2 + 1, NextValueNo, Ty, TyID, EdgeBB);
5901 return error(
"Invalid phi record");
5904 if (EdgeBB == PhiConstExprBB && !EdgeBB->
empty()) {
5905 ConstExprEdgeBBs.
insert({{BB, CurBB}, EdgeBB});
5906 PhiConstExprBB =
nullptr;
5909 Args.insert({BB,
V});
5915 if (
Record.size() % 2 == 0) {
5916 assert(isa<FPMathOperator>(
I) &&
"Unexpected phi type");
5919 I->setFastMathFlags(FMF);
5931 return error(
"Invalid record");
5935 return error(
"Invalid record");
5938 Type *Ty = getTypeByID(ResTypeID);
5940 return error(
"Invalid record");
5942 Value *PersFn =
nullptr;
5943 unsigned PersFnTypeID;
5944 if (getValueTypePair(
Record,
Idx, NextValueNo, PersFn, PersFnTypeID,
5946 return error(
"Invalid record");
5948 if (!
F->hasPersonalityFn())
5949 F->setPersonalityFn(cast<Constant>(PersFn));
5950 else if (
F->getPersonalityFn() != cast<Constant>(PersFn))
5951 return error(
"Personality function mismatch");
5958 for (
unsigned J = 0; J != NumClauses; ++J) {
5964 if (getValueTypePair(
Record,
Idx, NextValueNo, Val, ValTypeID,
5967 return error(
"Invalid record");
5971 !isa<ArrayType>(Val->
getType())) &&
5972 "Catch clause has a invalid type!");
5974 isa<ArrayType>(Val->
getType())) &&
5975 "Filter clause has invalid type!");
5986 return error(
"Invalid record");
5989 const bool InAlloca = Bitfield::get<APV::UsedWithInAlloca>(Rec);
5990 const bool SwiftError = Bitfield::get<APV::SwiftError>(Rec);
5991 unsigned TyID =
Record[0];
5992 Type *Ty = getTypeByID(TyID);
5993 if (!Bitfield::get<APV::ExplicitType>(Rec)) {
5994 TyID = getContainedTypeID(TyID);
5995 Ty = getTypeByID(TyID);
5997 return error(
"Missing element type for old-style alloca");
5999 unsigned OpTyID =
Record[1];
6000 Type *OpTy = getTypeByID(OpTyID);
6004 Bitfield::get<APV::AlignLower>(Rec) |
6005 (Bitfield::get<APV::AlignUpper>(Rec) << APV::AlignLower::Bits);
6006 if (
Error Err = parseAlignmentValue(AlignExp,
Align)) {
6010 return error(
"Invalid record");
6013 unsigned AS =
Record.size() == 5 ?
Record[4] :
DL.getAllocaAddrSpace();
6017 return error(
"alloca of unsized type");
6019 Align =
DL.getPrefTypeAlign(Ty);
6021 if (!
Size->getType()->isIntegerTy())
6022 return error(
"alloca element count must have integer type");
6028 ResTypeID = getVirtualTypeID(AI->
getType(), TyID);
6036 if (getValueTypePair(
Record, OpNum, NextValueNo,
Op, OpTypeID, CurBB) ||
6037 (OpNum + 2 !=
Record.size() && OpNum + 3 !=
Record.size()))
6038 return error(
"Invalid record");
6040 if (!isa<PointerType>(
Op->getType()))
6041 return error(
"Load operand is not a pointer type");
6044 if (OpNum + 3 ==
Record.size()) {
6045 ResTypeID =
Record[OpNum++];
6046 Ty = getTypeByID(ResTypeID);
6048 ResTypeID = getContainedTypeID(OpTypeID);
6049 Ty = getTypeByID(ResTypeID);
6053 return error(
"Missing load type");
6055 if (
Error Err = typeCheckLoadStoreInst(Ty,
Op->getType()))
6063 return error(
"load of unsized type");
6065 Align = TheModule->getDataLayout().getABITypeAlign(Ty);
6075 if (getValueTypePair(
Record, OpNum, NextValueNo,
Op, OpTypeID, CurBB) ||
6076 (OpNum + 4 !=
Record.size() && OpNum + 5 !=
Record.size()))
6077 return error(
"Invalid record");
6079 if (!isa<PointerType>(
Op->getType()))
6080 return error(
"Load operand is not a pointer type");
6083 if (OpNum + 5 ==
Record.size()) {
6084 ResTypeID =
Record[OpNum++];
6085 Ty = getTypeByID(ResTypeID);
6087 ResTypeID = getContainedTypeID(OpTypeID);
6088 Ty = getTypeByID(ResTypeID);
6092 return error(
"Missing atomic load type");
6094 if (
Error Err = typeCheckLoadStoreInst(Ty,
Op->getType()))
6098 if (Ordering == AtomicOrdering::NotAtomic ||
6099 Ordering == AtomicOrdering::Release ||
6100 Ordering == AtomicOrdering::AcquireRelease)
6101 return error(
"Invalid record");
6102 if (Ordering != AtomicOrdering::NotAtomic &&
Record[OpNum] == 0)
6103 return error(
"Invalid record");
6110 return error(
"Alignment missing from atomic load");
6119 unsigned PtrTypeID, ValTypeID;
6120 if (getValueTypePair(
Record, OpNum, NextValueNo,
Ptr, PtrTypeID, CurBB))
6121 return error(
"Invalid record");
6124 if (getValueTypePair(
Record, OpNum, NextValueNo, Val, ValTypeID, CurBB))
6125 return error(
"Invalid record");
6127 ValTypeID = getContainedTypeID(PtrTypeID);
6128 if (popValue(
Record, OpNum, NextValueNo, getTypeByID(ValTypeID),
6129 ValTypeID, Val, CurBB))
6130 return error(
"Invalid record");
6133 if (OpNum + 2 !=
Record.size())
6134 return error(
"Invalid record");
6136 if (
Error Err = typeCheckLoadStoreInst(Val->
getType(),
Ptr->getType()))
6143 return error(
"store of unsized type");
6145 Align = TheModule->getDataLayout().getABITypeAlign(Val->
getType());
6155 unsigned PtrTypeID, ValTypeID;
6156 if (getValueTypePair(
Record, OpNum, NextValueNo,
Ptr, PtrTypeID, CurBB) ||
6157 !isa<PointerType>(
Ptr->getType()))
6158 return error(
"Invalid record");
6160 if (getValueTypePair(
Record, OpNum, NextValueNo, Val, ValTypeID, CurBB))
6161 return error(
"Invalid record");
6163 ValTypeID = getContainedTypeID(PtrTypeID);
6164 if (popValue(
Record, OpNum, NextValueNo, getTypeByID(ValTypeID),
6165 ValTypeID, Val, CurBB))
6166 return error(
"Invalid record");
6169 if (OpNum + 4 !=
Record.size())
6170 return error(
"Invalid record");
6172 if (
Error Err = typeCheckLoadStoreInst(Val->
getType(),
Ptr->getType()))
6175 if (Ordering == AtomicOrdering::NotAtomic ||
6176 Ordering == AtomicOrdering::Acquire ||
6177 Ordering == AtomicOrdering::AcquireRelease)
6178 return error(
"Invalid record");
6180 if (Ordering != AtomicOrdering::NotAtomic &&
Record[OpNum] == 0)
6181 return error(
"Invalid record");
6187 return error(
"Alignment missing from atomic store");
6195 const size_t NumRecords =
Record.size();
6199 if (getValueTypePair(
Record, OpNum, NextValueNo,
Ptr, PtrTypeID, CurBB))
6200 return error(
"Invalid record");
6202 if (!isa<PointerType>(
Ptr->getType()))
6203 return error(
"Cmpxchg operand is not a pointer type");
6206 unsigned CmpTypeID = getContainedTypeID(PtrTypeID);
6207 if (popValue(
Record, OpNum, NextValueNo, getTypeByID(CmpTypeID),
6208 CmpTypeID, Cmp, CurBB))
6209 return error(
"Invalid record");
6212 if (popValue(
Record, OpNum, NextValueNo,
Cmp->getType(), CmpTypeID,
6214 NumRecords < OpNum + 3 || NumRecords > OpNum + 5)
6215 return error(
"Invalid record");
6219 if (SuccessOrdering == AtomicOrdering::NotAtomic ||
6220 SuccessOrdering == AtomicOrdering::Unordered)
6221 return error(
"Invalid record");
6225 if (
Error Err = typeCheckLoadStoreInst(
Cmp->getType(),
Ptr->getType()))
6233 if (FailureOrdering == AtomicOrdering::NotAtomic ||
6234 FailureOrdering == AtomicOrdering::Unordered)
6235 return error(
"Invalid record");
6237 const Align Alignment(
6238 TheModule->getDataLayout().getTypeStoreSize(
Cmp->getType()));
6241 FailureOrdering, SSID);
6242 cast<AtomicCmpXchgInst>(
I)->setVolatile(
Record[OpNum]);
6244 if (NumRecords < 8) {
6248 I->insertInto(CurBB, CurBB->
end());
6250 ResTypeID = CmpTypeID;
6252 cast<AtomicCmpXchgInst>(
I)->setWeak(
Record[OpNum + 4]);
6254 ResTypeID = getVirtualTypeID(
I->getType(), {CmpTypeID, I1TypeID});
6263 const size_t NumRecords =
Record.size();
6267 if (getValueTypePair(
Record, OpNum, NextValueNo,
Ptr, PtrTypeID, CurBB))
6268 return error(
"Invalid record");
6270 if (!isa<PointerType>(
Ptr->getType()))
6271 return error(
"Cmpxchg operand is not a pointer type");
6275 if (getValueTypePair(
Record, OpNum, NextValueNo, Cmp, CmpTypeID, CurBB))
6276 return error(
"Invalid record");
6278 Value *Val =
nullptr;
6279 if (popValue(
Record, OpNum, NextValueNo,
Cmp->getType(), CmpTypeID, Val,
6281 return error(
"Invalid record");
6283 if (NumRecords < OpNum + 3 || NumRecords > OpNum + 6)
6284 return error(
"Invalid record");
6286 const bool IsVol =
Record[OpNum];
6291 return error(
"Invalid cmpxchg success ordering");
6295 if (
Error Err = typeCheckLoadStoreInst(
Cmp->getType(),
Ptr->getType()))
6301 return error(
"Invalid cmpxchg failure ordering");
6303 const bool IsWeak =
Record[OpNum + 4];
6307 if (NumRecords == (OpNum + 6)) {
6308 if (
Error Err = parseAlignmentValue(
Record[OpNum + 5], Alignment))
6313 Align(TheModule->getDataLayout().getTypeStoreSize(
Cmp->getType()));
6316 FailureOrdering, SSID);
6317 cast<AtomicCmpXchgInst>(
I)->setVolatile(IsVol);
6318 cast<AtomicCmpXchgInst>(
I)->setWeak(IsWeak);
6321 ResTypeID = getVirtualTypeID(
I->getType(), {CmpTypeID, I1TypeID});
6330 const size_t NumRecords =
Record.size();
6335 if (getValueTypePair(
Record, OpNum, NextValueNo,
Ptr, PtrTypeID, CurBB))
6336 return error(
"Invalid record");
6338 if (!isa<PointerType>(
Ptr->getType()))
6339 return error(
"Invalid record");
6341 Value *Val =
nullptr;
6342 unsigned ValTypeID = InvalidTypeID;
6344 ValTypeID = getContainedTypeID(PtrTypeID);
6345 if (popValue(
Record, OpNum, NextValueNo,
6346 getTypeByID(ValTypeID), ValTypeID, Val, CurBB))
6347 return error(
"Invalid record");
6349 if (getValueTypePair(
Record, OpNum, NextValueNo, Val, ValTypeID, CurBB))
6350 return error(
"Invalid record");
6353 if (!(NumRecords == (OpNum + 4) || NumRecords == (OpNum + 5)))
6354 return error(
"Invalid record");
6360 return error(
"Invalid record");
6362 const bool IsVol =
Record[OpNum + 1];
6365 if (Ordering == AtomicOrdering::NotAtomic ||
6366 Ordering == AtomicOrdering::Unordered)
6367 return error(
"Invalid record");
6373 if (NumRecords == (OpNum + 5)) {
6374 if (
Error Err = parseAlignmentValue(
Record[OpNum + 4], Alignment))
6380 Align(TheModule->getDataLayout().getTypeStoreSize(Val->
getType()));
6383 ResTypeID = ValTypeID;
6384 cast<AtomicRMWInst>(
I)->setVolatile(IsVol);
6391 return error(
"Invalid record");
6393 if (Ordering == AtomicOrdering::NotAtomic ||
6394 Ordering == AtomicOrdering::Unordered ||
6395 Ordering == AtomicOrdering::Monotonic)
6396 return error(
"Invalid record");
6406 return error(
"Invalid dbg record: missing instruction");
6420 return error(
"Invalid dbg record: missing instruction");
6436 cast<DILocalVariable>(getFnMetadataByID(
Record[Slot++]));
6438 cast<DIExpression>(getFnMetadataByID(
Record[Slot++]));
6450 unsigned SlotBefore =
Slot;
6451 if (getValueTypePair(
Record, Slot, NextValueNo, V, TyID, CurBB))
6452 return error(
"Invalid dbg record: invalid value");
6454 assert((SlotBefore == Slot - 1) &&
"unexpected fwd ref");
6457 RawLocation = getFnMetadataByID(
Record[Slot++]);
6464 DPV =
new DPValue(RawLocation, Var, Expr, DIL,
6465 DPValue::LocationType::Value);
6468 DPV =
new DPValue(RawLocation, Var, Expr, DIL,
6469 DPValue::LocationType::Declare);
6474 cast<DIExpression>(getFnMetadataByID(
Record[Slot++]));
6476 DPV =
new DPValue(RawLocation, Var, Expr,
ID,
Addr, AddrExpr, DIL);
6488 return error(
"Invalid record");
6492 unsigned CCInfo =
Record[OpNum++];
6498 return error(
"Fast math flags indicator set for call with no FMF");
6501 unsigned FTyID = InvalidTypeID;
6505 FTy = dyn_cast_or_null<FunctionType>(getTypeByID(FTyID));
6507 return error(
"Explicit call type is not a function type");
6511 unsigned CalleeTypeID;
6512 if (getValueTypePair(
Record, OpNum, NextValueNo, Callee, CalleeTypeID,
6514 return error(
"Invalid record");
6518 return error(
"Callee is not a pointer type");
6520 FTyID = getContainedTypeID(CalleeTypeID);
6521 FTy = dyn_cast_or_null<FunctionType>(getTypeByID(FTyID));
6523 return error(
"Callee is not of pointer to function type");
6525 if (
Record.size() < FTy->getNumParams() + OpNum)
6526 return error(
"Insufficient operands to call");
6531 for (
unsigned i = 0, e = FTy->getNumParams(); i != e; ++i, ++OpNum) {
6532 unsigned ArgTyID = getContainedTypeID(FTyID, i + 1);
6533 if (FTy->getParamType(i)->isLabelTy())
6534 Args.push_back(getBasicBlock(
Record[OpNum]));
6536 Args.push_back(getValue(
Record, OpNum, NextValueNo,
6537 FTy->getParamType(i), ArgTyID, CurBB));
6540 return error(
"Invalid record");
6544 if (!FTy->isVarArg()) {
6545 if (OpNum !=
Record.size())
6546 return error(
"Invalid record");
6548 while (OpNum !=
Record.size()) {
6551 if (getValueTypePair(
Record, OpNum, NextValueNo,
Op, OpTypeID, CurBB))
6552 return error(
"Invalid record");
6559 if (!OperandBundles.empty())
6563 ResTypeID = getContainedTypeID(FTyID);
6564 OperandBundles.clear();
6566 cast<CallInst>(
I)->setCallingConv(
6575 cast<CallInst>(
I)->setTailCallKind(TCK);
6576 cast<CallInst>(
I)->setAttributes(PAL);
6577 if (
Error Err = propagateAttributeTypes(cast<CallBase>(
I), ArgTyIDs)) {
6582 if (!isa<FPMathOperator>(
I))
6583 return error(
"Fast-math-flags specified for call without "
6584 "floating-point scalar or vector return type");
6585 I->setFastMathFlags(FMF);
6591 return error(
"Invalid record");
6592 unsigned OpTyID =
Record[0];
6593 Type *OpTy = getTypeByID(OpTyID);
6594 Value *
Op = getValue(
Record, 1, NextValueNo, OpTy, OpTyID, CurBB);
6596 Type *ResTy = getTypeByID(ResTypeID);
6597 if (!OpTy || !
Op || !ResTy)
6598 return error(
"Invalid record");
6610 return error(
"Invalid record");
6612 std::vector<Value *> Inputs;
6615 while (OpNum !=
Record.size()) {
6618 if (getValueTypePair(
Record, OpNum, NextValueNo,
Op, OpTypeID, CurBB))
6619 return error(
"Invalid record");
6620 Inputs.push_back(
Op);
6623 OperandBundles.emplace_back(BundleTags[
Record[0]], std::move(Inputs));
6631 if (getValueTypePair(
Record, OpNum, NextValueNo,
Op, OpTypeID, CurBB))
6632 return error(
"Invalid record");
6633 if (OpNum !=
Record.size())
6634 return error(
"Invalid record");
6637 ResTypeID = OpTypeID;
6647 return error(
"Invalid instruction with no BB");
6649 if (!OperandBundles.empty()) {
6651 return error(
"Operand bundles found with no consumer");
6653 I->insertInto(CurBB, CurBB->
end());
6656 if (
I->isTerminator()) {
6658 CurBB = CurBBNo < FunctionBBs.size() ? FunctionBBs[CurBBNo] :
nullptr;
6662 if (!
I->getType()->isVoidTy()) {
6663 assert(
I->getType() == getTypeByID(ResTypeID) &&
6664 "Incorrect result type ID");
6672 if (!OperandBundles.empty())
6673 return error(
"Operand bundles found with no consumer");
6677 if (!
A->getParent()) {
6679 for (
unsigned i = ModuleValueListSize, e = ValueList.
size(); i != e; ++i){
6680 if ((
A = dyn_cast_or_null<Argument>(ValueList[i])) && !
A->getParent()) {
6685 return error(
"Never resolved value found in function");
6690 if (MDLoader->hasFwdRefs())
6691 return error(
"Invalid function metadata: outgoing forward refs");
6696 for (
const auto &Pair : ConstExprEdgeBBs) {
6701 From->getTerminator()->replaceSuccessorWith(To, EdgeBB);
6707 ValueList.
shrinkTo(ModuleValueListSize);
6708 MDLoader->shrinkTo(ModuleMDLoaderSize);
6709 std::vector<BasicBlock*>().swap(FunctionBBs);
6714Error BitcodeReader::findFunctionInStream(
6717 while (DeferredFunctionInfoIterator->second == 0) {
6722 assert(VSTOffset == 0 || !
F->hasName());
6725 if (
Error Err = rememberAndSkipFunctionBodies())
6731SyncScope::ID BitcodeReader::getDecodedSyncScopeID(
unsigned Val) {
6734 if (Val >= SSIDs.
size())
6746 if (!
F || !
F->isMaterializable())
6750 assert(DFII != DeferredFunctionInfo.
end() &&
"Deferred function not found!");
6753 if (DFII->second == 0)
6754 if (
Error Err = findFunctionInStream(
F, DFII))
6758 if (
Error Err = materializeMetadata())
6762 if (
Error JumpFailed = Stream.JumpToBit(DFII->second))
6769 F->IsNewDbgInfoFormat =
true;
6771 if (
Error Err = parseFunctionBody(
F))
6773 F->setIsMaterializable(
false);
6777 F->convertFromNewDbgValues();
6783 for (
auto &
I : UpgradedIntrinsics) {
6785 if (
CallInst *CI = dyn_cast<CallInst>(U))
6790 if (
DISubprogram *SP = MDLoader->lookupSubprogramForFunction(
F))
6791 F->setSubprogram(SP);
6794 if (!MDLoader->isStrippingTBAA()) {
6796 MDNode *TBAA =
I.getMetadata(LLVMContext::MD_tbaa);
6799 MDLoader->setStripTBAA(
true);
6806 if (
auto *MD =
I.getMetadata(LLVMContext::MD_prof)) {
6807 if (MD->getOperand(0) !=
nullptr && isa<MDString>(MD->getOperand(0))) {
6808 MDString *MDS = cast<MDString>(MD->getOperand(0));
6811 if (!ProfName.
equals(
"branch_weights"))
6813 unsigned ExpectedNumOperands = 0;
6815 ExpectedNumOperands = BI->getNumSuccessors();
6816 else if (
SwitchInst *SI = dyn_cast<SwitchInst>(&
I))
6817 ExpectedNumOperands =
SI->getNumSuccessors();
6818 else if (isa<CallInst>(&
I))
6819 ExpectedNumOperands = 1;
6822 else if (isa<SelectInst>(&
I))
6823 ExpectedNumOperands = 2;
6828 if (MD->getNumOperands() != 1 + ExpectedNumOperands)
6829 I.setMetadata(LLVMContext::MD_prof,
nullptr);
6834 if (
auto *CI = dyn_cast<CallBase>(&
I)) {
6836 CI->getFunctionType()->getReturnType()));
6838 for (
unsigned ArgNo = 0; ArgNo < CI->arg_size(); ++ArgNo)
6840 CI->getArgOperand(ArgNo)->getType()));
6849 return materializeForwardReferencedFunctions();
6852Error BitcodeReader::materializeModule() {
6853 if (
Error Err = materializeMetadata())
6857 WillMaterializeAllForwardRefs =
true;
6862 if (
Error Err = materialize(&
F))
6868 if (LastFunctionBlockBit || NextUnreadBit)
6870 ? LastFunctionBlockBit
6876 if (!BasicBlockFwdRefs.
empty())
6877 return error(
"Never resolved function from blockaddress");
6883 for (
auto &
I : UpgradedIntrinsics) {
6884 for (
auto *U :
I.first->users()) {
6885 if (
CallInst *CI = dyn_cast<CallInst>(U))
6888 if (!
I.first->use_empty())
6889 I.first->replaceAllUsesWith(
I.second);
6890 I.first->eraseFromParent();
6892 UpgradedIntrinsics.clear();
6903std::vector<StructType *> BitcodeReader::getIdentifiedStructTypes()
const {
6904 return IdentifiedStructTypes;
6907ModuleSummaryIndexBitcodeReader::ModuleSummaryIndexBitcodeReader(
6910 : BitcodeReaderBase(
std::
move(Cursor), Strtab), TheIndex(TheIndex),
6911 ModulePath(ModulePath), IsPrevailing(IsPrevailing) {}
6913void ModuleSummaryIndexBitcodeReader::addThisModule() {
6918ModuleSummaryIndexBitcodeReader::getThisModule() {
6922template <
bool AllowNullValueInfo>
6923std::tuple<ValueInfo, GlobalValue::GUID, GlobalValue::GUID>
6924ModuleSummaryIndexBitcodeReader::getValueInfoFromValueId(
unsigned ValueId) {
6925 auto VGI = ValueIdToValueInfoMap[ValueId];
6930 assert(AllowNullValueInfo || std::get<0>(VGI));
6934void ModuleSummaryIndexBitcodeReader::setValueGUID(
6937 std::string GlobalId =
6940 auto OriginalNameID = ValueGUID;
6944 dbgs() <<
"GUID " << ValueGUID <<
"(" << OriginalNameID <<
") is "
6950 ValueIdToValueInfoMap[ValueID] = std::make_tuple(
6953 OriginalNameID, ValueGUID);
6959Error ModuleSummaryIndexBitcodeReader::parseValueSymbolTable(
6968 if (!MaybeCurrentBit)
6986 switch (Entry.Kind) {
6989 return error(
"Malformed block");
6992 if (
Error JumpFailed = Stream.JumpToBit(CurrentBit))
7005 switch (MaybeRecord.
get()) {
7010 return error(
"Invalid record");
7011 unsigned ValueID =
Record[0];
7013 auto VLI = ValueIdToLinkageMap.
find(ValueID);
7014 assert(VLI != ValueIdToLinkageMap.
end() &&
7015 "No linkage found for VST entry?");
7017 setValueGUID(ValueID,
ValueName, Linkage, SourceFileName);
7024 return error(
"Invalid record");
7025 unsigned ValueID =
Record[0];
7027 auto VLI = ValueIdToLinkageMap.
find(ValueID);
7028 assert(VLI != ValueIdToLinkageMap.
end() &&
7029 "No linkage found for VST entry?");
7031 setValueGUID(ValueID,
ValueName, Linkage, SourceFileName);
7037 unsigned ValueID =
Record[0];
7041 ValueIdToValueInfoMap[ValueID] = std::make_tuple(
7052Error ModuleSummaryIndexBitcodeReader::parseModule() {
7058 unsigned ValueId = 0;
7067 switch (Entry.Kind) {
7069 return error(
"Malformed block");
7076 if (
Error Err = Stream.SkipBlock())
7081 if (
Error Err = readBlockInfo())
7087 assert(((SeenValueSymbolTable && VSTOffset > 0) ||
7088 !SeenGlobalValSummary) &&
7089 "Expected early VST parse via VSTOffset record");
7090 if (
Error Err = Stream.SkipBlock())
7096 if (!SourceFileName.
empty())
7098 assert(!SeenValueSymbolTable &&
7099 "Already read VST when parsing summary block?");
7104 if (VSTOffset > 0) {
7105 if (
Error Err = parseValueSymbolTable(VSTOffset, ValueIdToLinkageMap))
7107 SeenValueSymbolTable =
true;
7109 SeenGlobalValSummary =
true;
7110 if (
Error Err = parseEntireSummary(Entry.ID))
7114 if (
Error Err = parseModuleStringTable())
7125 switch (MaybeBitCode.
get()) {
7129 if (
Error Err = parseVersionRecord(
Record).takeError())
7137 return error(
"Invalid record");
7145 auto &Hash = getThisModule()->second;
7147 for (
auto &Val :
Record) {
7148 assert(!(Val >> 32) &&
"Unexpected high bits set");
7156 return error(
"Invalid record");
7160 VSTOffset =
Record[0] - 1;
7171 std::tie(
Name, GVRecord) = readNameFromStrtab(
Record);
7172 if (GVRecord.
size() <= 3)
7173 return error(
"Invalid record");
7177 ValueIdToLinkageMap[ValueId++] =
Linkage;
7181 setValueGUID(ValueId++,
Name, Linkage, SourceFileName);
7191std::vector<ValueInfo>
7193 std::vector<ValueInfo>
Ret;
7196 Ret.push_back(std::get<0>(getValueInfoFromValueId(RefValueId)));
7200std::vector<FunctionSummary::EdgeTy>
7202 bool IsOldProfileFormat,
7203 bool HasProfile,
bool HasRelBF) {
7204 std::vector<FunctionSummary::EdgeTy>
Ret;
7206 for (
unsigned I = 0,
E =
Record.size();
I !=
E; ++
I) {
7208 bool HasTailCall =
false;
7211 if (IsOldProfileFormat) {
7215 }
else if (HasProfile)
7216 std::tie(Hotness, HasTailCall) =
7249 static_cast<size_t>(
Record[Slot + 1])};
7272 while (Slot <
Record.size())
7276std::vector<FunctionSummary::ParamAccess>
7278 auto ReadRange = [&]() {
7280 BitcodeReader::decodeSignRotatedValue(
Record.front()));
7283 BitcodeReader::decodeSignRotatedValue(
Record.front()));
7291 std::vector<FunctionSummary::ParamAccess> PendingParamAccesses;
7292 while (!
Record.empty()) {
7293 PendingParamAccesses.emplace_back();
7297 ParamAccess.
Use = ReadRange();
7300 for (
auto &Call : ParamAccess.
Calls) {
7303 Call.Callee = std::get<0>(getValueInfoFromValueId(
Record.front()));
7305 Call.Offsets = ReadRange();
7308 return PendingParamAccesses;
7311void ModuleSummaryIndexBitcodeReader::parseTypeIdCompatibleVtableInfo(
7319void ModuleSummaryIndexBitcodeReader::parseTypeIdCompatibleVtableSummaryRecord(
7325 static_cast<size_t>(
Record[Slot + 1])});
7328 while (Slot <
Record.size())
7329 parseTypeIdCompatibleVtableInfo(
Record, Slot, TypeId);
7335 assert(ROCnt + WOCnt <= Refs.size());
7336 unsigned FirstWORef = Refs.size() - WOCnt;
7337 unsigned RefNo = FirstWORef - ROCnt;
7338 for (; RefNo < FirstWORef; ++RefNo)
7339 Refs[RefNo].setReadOnly();
7340 for (; RefNo < Refs.size(); ++RefNo)
7341 Refs[RefNo].setWriteOnly();
7346Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(
unsigned ID) {
7347 if (
Error Err = Stream.EnterSubBlock(
ID))
7359 return error(
"Invalid Summary Block: record for version expected");
7364 return error(
"Invalid Summary Block: version expected");
7367 const bool IsOldProfileFormat =
Version == 1;
7369 return error(
"Invalid summary version " +
Twine(Version) +
7370 ". Version should be in the range [1-" +
7383 std::vector<GlobalValue::GUID> PendingTypeTests;
7384 std::vector<FunctionSummary::VFuncId> PendingTypeTestAssumeVCalls,
7385 PendingTypeCheckedLoadVCalls;
7386 std::vector<FunctionSummary::ConstVCall> PendingTypeTestAssumeConstVCalls,
7387 PendingTypeCheckedLoadConstVCalls;
7388 std::vector<FunctionSummary::ParamAccess> PendingParamAccesses;
7390 std::vector<CallsiteInfo> PendingCallsites;
7391 std::vector<AllocInfo> PendingAllocs;
7399 switch (Entry.Kind) {
7402 return error(
"Malformed block");
7421 switch (
unsigned BitCode = MaybeBitCode.
get()) {
7431 ValueIdToValueInfoMap[ValueID] = std::make_tuple(
7447 unsigned ValueID =
Record[0];
7449 unsigned InstCount =
Record[2];
7451 unsigned NumRefs =
Record[3];
7452 unsigned NumRORefs = 0, NumWORefs = 0;
7453 int RefListStartIndex = 4;
7457 RefListStartIndex = 5;
7460 RefListStartIndex = 6;
7463 RefListStartIndex = 7;
7474 int CallGraphEdgeStartIndex = RefListStartIndex + NumRefs;
7476 "Record size inconsistent with number of references");
7477 std::vector<ValueInfo> Refs = makeRefList(
7481 std::vector<FunctionSummary::EdgeTy> Calls = makeCallList(
7483 IsOldProfileFormat, HasProfile, HasRelBF);
7485 auto VIAndOriginalGUID = getValueInfoFromValueId(ValueID);
7492 !IsPrevailing(std::get<2>(VIAndOriginalGUID))) {
7493 PendingCallsites.clear();
7494 PendingAllocs.clear();
7496 auto FS = std::make_unique<FunctionSummary>(
7498 std::move(Refs), std::move(Calls), std::move(PendingTypeTests),
7499 std::move(PendingTypeTestAssumeVCalls),
7500 std::move(PendingTypeCheckedLoadVCalls),
7501 std::move(PendingTypeTestAssumeConstVCalls),
7502 std::move(PendingTypeCheckedLoadConstVCalls),
7503 std::move(PendingParamAccesses), std::move(PendingCallsites),
7504 std::move(PendingAllocs));
7505 FS->setModulePath(getThisModule()->first());
7506 FS->setOriginalName(std::get<1>(VIAndOriginalGUID));
7515 unsigned ValueID =
Record[0];
7517 unsigned AliaseeID =
Record[2];
7519 auto AS = std::make_unique<AliasSummary>(Flags);
7525 AS->setModulePath(getThisModule()->first());
7527 auto AliaseeVI = std::get<0>(getValueInfoFromValueId(AliaseeID));
7529 if (!AliaseeInModule)
7530 return error(
"Alias expects aliasee summary to be parsed");
7531 AS->setAliasee(AliaseeVI, AliaseeInModule);
7533 auto GUID = getValueInfoFromValueId(ValueID);
7534 AS->setOriginalName(std::get<1>(GUID));
7540 unsigned ValueID =
Record[0];
7542 unsigned RefArrayStart = 2;
7552 std::vector<ValueInfo> Refs =
7555 std::make_unique<GlobalVarSummary>(Flags, GVF, std::move(Refs));
7556 FS->setModulePath(getThisModule()->first());
7557 auto GUID = getValueInfoFromValueId(ValueID);
7558 FS->setOriginalName(std::get<1>(GUID));
7566 unsigned ValueID =
Record[0];
7569 unsigned NumRefs =
Record[3];
7570 unsigned RefListStartIndex = 4;
7571 unsigned VTableListStartIndex = RefListStartIndex + NumRefs;
7573 std::vector<ValueInfo> Refs = makeRefList(
7576 for (
unsigned I = VTableListStartIndex,
E =
Record.size();
I !=
E; ++
I) {
7582 std::make_unique<GlobalVarSummary>(Flags, GVF, std::move(Refs));
7583 VS->setModulePath(getThisModule()->first());
7584 VS->setVTableFuncs(VTableFuncs);
7585 auto GUID = getValueInfoFromValueId(ValueID);
7586 VS->setOriginalName(std::get<1>(GUID));
7598 unsigned ValueID =
Record[0];
7601 unsigned InstCount =
Record[3];
7604 unsigned NumRefs =
Record[4];
7605 unsigned NumRORefs = 0, NumWORefs = 0;
7606 int RefListStartIndex = 5;
7610 RefListStartIndex = 6;
7611 size_t NumRefsIndex = 5;
7613 unsigned NumRORefsOffset = 1;
7614 RefListStartIndex = 7;
7618 RefListStartIndex = 8;
7620 RefListStartIndex = 9;
7622 NumRORefsOffset = 2;
7625 NumRORefs =
Record[RefListStartIndex - NumRORefsOffset];
7627 NumRefs =
Record[NumRefsIndex];
7631 int CallGraphEdgeStartIndex = RefListStartIndex + NumRefs;
7633 "Record size inconsistent with number of references");
7634 std::vector<ValueInfo> Refs = makeRefList(
7637 std::vector<FunctionSummary::EdgeTy> Edges = makeCallList(
7639 IsOldProfileFormat, HasProfile,
false);
7640 ValueInfo VI = std::get<0>(getValueInfoFromValueId(ValueID));
7642 auto FS = std::make_unique<FunctionSummary>(
7644 std::move(Refs), std::move(Edges), std::move(PendingTypeTests),
7645 std::move(PendingTypeTestAssumeVCalls),
7646 std::move(PendingTypeCheckedLoadVCalls),
7647 std::move(PendingTypeTestAssumeConstVCalls),
7648 std::move(PendingTypeCheckedLoadConstVCalls),
7649 std::move(PendingParamAccesses), std::move(PendingCallsites),
7650 std::move(PendingAllocs));
7651 LastSeenSummary =
FS.get();
7652 LastSeenGUID =
VI.getGUID();
7653 FS->setModulePath(ModuleIdMap[ModuleId]);
7661 unsigned ValueID =
Record[0];
7664 unsigned AliaseeValueId =
Record[3];
7666 auto AS = std::make_unique<AliasSummary>(Flags);
7667 LastSeenSummary = AS.get();
7668 AS->setModulePath(ModuleIdMap[ModuleId]);
7670 auto AliaseeVI = std::get<0>(getValueInfoFromValueId(AliaseeValueId));
7672 AS->setAliasee(AliaseeVI, AliaseeInModule);
7674 ValueInfo VI = std::get<0>(getValueInfoFromValueId(ValueID));
7675 LastSeenGUID =
VI.getGUID();
7681 unsigned ValueID =
Record[0];
7684 unsigned RefArrayStart = 3;
7694 std::vector<ValueInfo> Refs =
7697 std::make_unique<GlobalVarSummary>(Flags, GVF, std::move(Refs));
7698 LastSeenSummary =
FS.get();
7699 FS->setModulePath(ModuleIdMap[ModuleId]);
7700 ValueInfo VI = std::get<0>(getValueInfoFromValueId(ValueID));
7701 LastSeenGUID =
VI.getGUID();
7708 if (!LastSeenSummary)
7709 return error(
"Name attachment that does not follow a combined record");
7713 LastSeenSummary =
nullptr;
7718 assert(PendingTypeTests.empty());
7723 assert(PendingTypeTestAssumeVCalls.empty());
7724 for (
unsigned I = 0;
I !=
Record.size();
I += 2)
7725 PendingTypeTestAssumeVCalls.push_back({Record[I], Record[I+1]});
7729 assert(PendingTypeCheckedLoadVCalls.empty());
7730 for (
unsigned I = 0;
I !=
Record.size();
I += 2)
7731 PendingTypeCheckedLoadVCalls.push_back({Record[I], Record[I+1]});
7735 PendingTypeTestAssumeConstVCalls.push_back(
7740 PendingTypeCheckedLoadConstVCalls.push_back(
7746 for (
unsigned I = 0;
I !=
Record.size();
I += 2)
7747 CfiFunctionDefs.insert(
7748 {Strtab.data() + Record[I], static_cast<size_t>(Record[I + 1])});
7754 for (
unsigned I = 0;
I !=
Record.size();
I += 2)
7755 CfiFunctionDecls.insert(
7756 {Strtab.data() + Record[I], static_cast<size_t>(Record[I + 1])});
7765 parseTypeIdCompatibleVtableSummaryRecord(
Record);
7773 PendingParamAccesses = parseParamAccesses(
Record);
7785 unsigned ValueID =
Record[0];
7787 for (
auto R =
Record.begin() + 1; R !=
Record.end(); R++) {
7788 assert(*R < StackIds.size());
7791 ValueInfo VI = std::get<0>(getValueInfoFromValueId(ValueID));
7792 PendingCallsites.push_back(
CallsiteInfo({
VI, std::move(StackIdList)}));
7797 auto RecordIter =
Record.begin();
7798 unsigned ValueID = *RecordIter++;
7799 unsigned NumStackIds = *RecordIter++;
7800 unsigned NumVersions = *RecordIter++;
7801 assert(
Record.size() == 3 + NumStackIds + NumVersions);
7803 for (
unsigned J = 0; J < NumStackIds; J++) {
7804 assert(*RecordIter < StackIds.size());
7809 for (
unsigned J = 0; J < NumVersions; J++)
7812 getValueInfoFromValueId</*AllowNullValueInfo*/ true>(ValueID));
7813 PendingCallsites.push_back(
7814 CallsiteInfo({
VI, std::move(Versions), std::move(StackIdList)}));
7820 std::vector<MIBInfo> MIBs;
7824 unsigned NumStackEntries =
Record[
I++];
7827 for (
unsigned J = 0; J < NumStackEntries; J++) {
7834 PendingAllocs.push_back(
AllocInfo(std::move(MIBs)));
7840 std::vector<MIBInfo> MIBs;
7841 unsigned NumMIBs =
Record[
I++];
7842 unsigned NumVersions =
Record[
I++];
7843 unsigned MIBsRead = 0;
7844 while (MIBsRead++ < NumMIBs) {
7847 unsigned NumStackEntries =
Record[
I++];
7850 for (
unsigned J = 0; J < NumStackEntries; J++) {
7859 for (
unsigned J = 0; J < NumVersions; J++)
7861 PendingAllocs.push_back(
7862 AllocInfo(std::move(Versions), std::move(MIBs)));
7872Error ModuleSummaryIndexBitcodeReader::parseModuleStringTable() {
7887 switch (Entry.Kind) {
7890 return error(
"Malformed block");
7902 switch (MaybeRecord.
get()) {
7910 return error(
"Invalid record");
7912 LastSeenModule = TheIndex.
addModule(ModulePath);
7913 ModuleIdMap[ModuleId] = LastSeenModule->
first();
7922 if (!LastSeenModule)
7923 return error(
"Invalid hash that does not follow a module path");
7925 for (
auto &Val :
Record) {
7926 assert(!(Val >> 32) &&
"Unexpected high bits set");
7927 LastSeenModule->
second[Pos++] = Val;
7930 LastSeenModule =
nullptr;
7943class BitcodeErrorCategoryType :
public std::error_category {
7944 const char *
name()
const noexcept
override {
7945 return "llvm.bitcode";
7948 std::string message(
int IE)
const override {
7951 case BitcodeError::CorruptedBitcode:
7952 return "Corrupted bitcode";
7961 static BitcodeErrorCategoryType ErrorCategory;
7962 return ErrorCategory;
7966 unsigned Block,
unsigned RecordID) {
7968 return std::move(Err);
7977 switch (Entry.Kind) {
7982 return error(
"Malformed block");
7986 return std::move(Err);
7996 if (MaybeRecord.
get() == RecordID)
8011 return FOrErr.takeError();
8012 return std::move(FOrErr->Mods);
8037 switch (Entry.Kind) {
8040 return error(
"Malformed block");
8043 uint64_t IdentificationBit = -1ull;
8047 return std::move(Err);
8053 Entry = MaybeEntry.
get();
8058 return error(
"Malformed block");
8064 return std::move(Err);
8083 if (!
I.Strtab.empty())
8090 if (!
F.Symtab.empty() &&
F.StrtabForSymtab.empty())
8091 F.StrtabForSymtab = *Strtab;
8107 if (
F.Symtab.empty())
8108 F.Symtab = *SymtabOrErr;
8113 return std::move(Err);
8118 return std::move(
E);
8133BitcodeModule::getModuleImpl(
LLVMContext &Context,
bool MaterializeAll,
8134 bool ShouldLazyLoadMetadata,
bool IsImporting,
8138 std::string ProducerIdentification;
8139 if (IdentificationBit != -1ull) {
8140 if (
Error JumpFailed = Stream.JumpToBit(IdentificationBit))
8141 return std::move(JumpFailed);
8144 return std::move(
E);
8147 if (
Error JumpFailed = Stream.JumpToBit(ModuleBit))
8148 return std::move(JumpFailed);
8149 auto *
R =
new BitcodeReader(std::move(Stream), Strtab, ProducerIdentification,
8152 std::unique_ptr<Module>
M =
8153 std::make_unique<Module>(ModuleIdentifier, Context);
8154 M->setMaterializer(R);
8157 if (
Error Err =
R->parseBitcodeInto(
M.get(), ShouldLazyLoadMetadata,
8158 IsImporting, Callbacks))
8159 return std::move(Err);
8161 if (MaterializeAll) {
8163 if (
Error Err =
M->materializeAll())
8164 return std::move(Err);
8167 if (
Error Err =
R->materializeForwardReferencedFunctions())
8168 return std::move(Err);
8171 return std::move(M);
8177 return getModuleImpl(
Context,
false, ShouldLazyLoadMetadata, IsImporting,
8192 ModuleSummaryIndexBitcodeReader R(std::move(Stream), Strtab, CombinedIndex,
8193 ModulePath, IsPrevailing);
8194 return R.parseModule();
8201 return std::move(JumpFailed);
8203 auto Index = std::make_unique<ModuleSummaryIndex>(
false);
8204 ModuleSummaryIndexBitcodeReader R(std::move(Stream), Strtab, *
Index,
8205 ModuleIdentifier, 0);
8207 if (
Error Err = R.parseModule())
8208 return std::move(Err);
8210 return std::move(
Index);
8218 return std::move(Err);
8223 std::pair<bool, bool> Result = {
false,
false};
8225 return std::move(
E);
8227 switch (Entry.Kind) {
8230 return error(
"Malformed block");
8245 switch (MaybeBitCode.
get()) {
8251 assert(Flags <= 0x2ff &&
"Unexpected bits in flag");
8253 bool EnableSplitLTOUnit = Flags & 0x8;
8254 bool UnifiedLTO = Flags & 0x200;
8255 Result = {EnableSplitLTOUnit, UnifiedLTO};
8268 return std::move(JumpFailed);
8271 return std::move(Err);
8276 return std::move(
E);
8278 switch (Entry.Kind) {
8280 return error(
"Malformed block");
8291 return Flags.takeError();
8303 return Flags.takeError();
8312 return std::move(Err);
8319 return StreamFailed.takeError();
8329 if (MsOrErr->size() != 1)
8330 return error(
"Expected a single module");
8332 return (*MsOrErr)[0];
8337 bool ShouldLazyLoadMetadata,
bool IsImporting,
8343 return BM->getLazyModule(
Context, ShouldLazyLoadMetadata, IsImporting,
8348 std::unique_ptr<MemoryBuffer> &&Buffer,
LLVMContext &Context,
8349 bool ShouldLazyLoadMetadata,
bool IsImporting,
ParserCallbacks Callbacks) {
8351 IsImporting, Callbacks);
8353 (*MOrErr)->setOwnedMemoryBuffer(std::move(Buffer));
8359 return getModuleImpl(
Context,
true,
false,
false, Callbacks);
8371 return BM->parseModule(
Context, Callbacks);
8404 return BM->readSummary(CombinedIndex, BM->getModuleIdentifier());
8413 return BM->getSummary();
8421 return BM->getLTOInfo();
8426 bool IgnoreEmptyThinLTOIndexFile) {
8431 if (IgnoreEmptyThinLTOIndexFile && !(*FileOrErr)->getBufferSize())
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static bool isConstant(const MachineInstr &MI)
This file declares a class to represent arbitrary precision floating point values and provide a varie...
This file implements a class to represent arbitrary precision integral constant values and operations...
Expand Atomic instructions
Atomic ordering constants.
This file contains the simple types necessary to represent the attributes associated with functions a...
static void getDecodedRelBFCallEdgeInfo(uint64_t RawFlags, uint64_t &RelBF, bool &HasTailCall)
static void upgradeDLLImportExportLinkage(GlobalValue *GV, unsigned Val)
static cl::opt< bool > PrintSummaryGUIDs("print-summary-global-ids", cl::init(false), cl::Hidden, cl::desc("Print the global id for each value when reading the module summary"))
static AtomicOrdering getDecodedOrdering(unsigned Val)
static std::pair< CalleeInfo::HotnessType, bool > getDecodedHotnessCallEdgeInfo(uint64_t RawFlags)
static FunctionSummary::FFlags getDecodedFFlags(uint64_t RawFlags)
static std::optional< CodeModel::Model > getDecodedCodeModel(unsigned Val)
static bool getDecodedDSOLocal(unsigned Val)
static bool convertToString(ArrayRef< uint64_t > Record, unsigned Idx, StrTy &Result)
Convert a string from a record into an std::string, return true on failure.
static GlobalVariable::UnnamedAddr getDecodedUnnamedAddrType(unsigned Val)
static void stripTBAA(Module *M)
static Expected< std::pair< bool, bool > > getEnableSplitLTOUnitAndUnifiedFlag(BitstreamCursor &Stream, unsigned ID, BitcodeLTOInfo <OInfo)
static int getDecodedUnaryOpcode(unsigned Val, Type *Ty)
static Expected< std::string > readTriple(BitstreamCursor &Stream)
static void parseWholeProgramDevirtResolutionByArg(ArrayRef< uint64_t > Record, size_t &Slot, WholeProgramDevirtResolution &Wpd)
static uint64_t getRawAttributeMask(Attribute::AttrKind Val)
static GlobalValueSummary::GVFlags getDecodedGVSummaryFlags(uint64_t RawFlags, uint64_t Version)
static void setSpecialRefs(std::vector< ValueInfo > &Refs, unsigned ROCnt, unsigned WOCnt)
static GlobalVarSummary::GVarFlags getDecodedGVarFlags(uint64_t RawFlags)
static Attribute::AttrKind getAttrFromCode(uint64_t Code)
static Expected< uint64_t > jumpToValueSymbolTable(uint64_t Offset, BitstreamCursor &Stream)
Helper to note and return the current location, and jump to the given offset.
static Expected< bool > hasObjCCategoryInModule(BitstreamCursor &Stream)
static GlobalValue::DLLStorageClassTypes getDecodedDLLStorageClass(unsigned Val)
static void decodeLLVMAttributesForBitcode(AttrBuilder &B, uint64_t EncodedAttrs, uint64_t AttrIdx)
This fills an AttrBuilder object with the LLVM attributes that have been decoded from the given integ...
static void parseTypeIdSummaryRecord(ArrayRef< uint64_t > Record, StringRef Strtab, ModuleSummaryIndex &TheIndex)
static void addRawAttributeValue(AttrBuilder &B, uint64_t Val)
static Comdat::SelectionKind getDecodedComdatSelectionKind(unsigned Val)
static bool hasImplicitComdat(size_t Val)
static GlobalValue::LinkageTypes getDecodedLinkage(unsigned Val)
static Error hasInvalidBitcodeHeader(BitstreamCursor &Stream)
static Expected< std::string > readIdentificationCode(BitstreamCursor &Stream)
static int getDecodedBinaryOpcode(unsigned Val, Type *Ty)
static AtomicRMWInst::BinOp getDecodedRMWOperation(unsigned Val)
static Expected< BitcodeModule > getSingleModule(MemoryBufferRef Buffer)
static Expected< bool > hasObjCCategory(BitstreamCursor &Stream)
static GlobalVariable::ThreadLocalMode getDecodedThreadLocalMode(unsigned Val)
static void parseWholeProgramDevirtResolution(ArrayRef< uint64_t > Record, StringRef Strtab, size_t &Slot, TypeIdSummary &TypeId)
static void inferDSOLocal(GlobalValue *GV)
static FastMathFlags getDecodedFastMathFlags(unsigned Val)
GlobalValue::SanitizerMetadata deserializeSanitizerMetadata(unsigned V)
static Expected< BitstreamCursor > initStream(MemoryBufferRef Buffer)
static cl::opt< bool > ExpandConstantExprs("expand-constant-exprs", cl::Hidden, cl::desc("Expand constant expressions to instructions for testing purposes"))
static bool upgradeOldMemoryAttribute(MemoryEffects &ME, uint64_t EncodedKind)
static Expected< StringRef > readBlobInRecord(BitstreamCursor &Stream, unsigned Block, unsigned RecordID)
static Expected< std::string > readIdentificationBlock(BitstreamCursor &Stream)
Read the "IDENTIFICATION_BLOCK_ID" block, do some basic enforcement on the "epoch" encoded in the bit...
static bool isConstExprSupported(const BitcodeConstant *BC)
static int getDecodedCastOpcode(unsigned Val)
static Expected< std::string > readModuleTriple(BitstreamCursor &Stream)
static GlobalValue::VisibilityTypes getDecodedVisibility(unsigned Val)
BlockVerifier::State From
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
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...
static StringRef getOpcodeName(uint8_t Opcode, uint8_t OpcodeBase)
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
Looks at all the uses of the given value Returns the Liveness deduced from the uses of this value Adds all uses that cause the result to be MaybeLive to MaybeLiveRetUses If the result is Live
This file defines the DenseMap class.
Provides ErrorOr<T> smart pointer.
This file contains the declaration of the GlobalIFunc class, which represents a single indirect funct...
ModuleSummaryIndex.h This file contains the declarations the classes that hold the module index and s...
Module.h This file contains the declarations for the Module class.
PowerPC Reduce CR logical Operation
const SmallVectorImpl< MachineOperand > & Cond
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static uint64_t decodeSignRotatedValue(uint64_t V)
Decode a signed value stored with the sign bit in the LSB for dense VBR encoding.
This file defines the SmallString class.
This file defines the SmallVector class.
Class for arbitrary precision integers.
an instruction to allocate memory on the stack
void setSwiftError(bool V)
Specify whether this alloca is used to represent a swifterror.
PointerType * getType() const
Overload to return most specific pointer type.
void setUsedWithInAlloca(bool V)
Specify whether this alloca is used to represent the arguments to a call.
This class represents an incoming formal argument to a Function.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
bool empty() const
empty - Check if the array is empty.
An instruction that atomically checks whether a specified value is in a memory location,...
static bool isValidFailureOrdering(AtomicOrdering Ordering)
static AtomicOrdering getStrongestFailureOrdering(AtomicOrdering SuccessOrdering)
Returns the strongest permitted ordering on failure, given the desired ordering on success.
static bool isValidSuccessOrdering(AtomicOrdering Ordering)
an instruction that atomically reads a memory location, combines it with another value,...
BinOp
This enumeration lists the possible modifications atomicrmw can make.
@ Min
*p = old <signed v ? old : v
@ UIncWrap
Increment one up to a maximum value.
@ Max
*p = old >signed v ? old : v
@ UMin
*p = old <unsigned v ? old : v
@ FMin
*p = minnum(old, v) minnum matches the behavior of llvm.minnum.
@ UMax
*p = old >unsigned v ? old : v
@ FMax
*p = maxnum(old, v) maxnum matches the behavior of llvm.maxnum.
@ UDecWrap
Decrement one until a minimum value or zero.
AttributeSet getFnAttrs() const
The function attributes are returned.
static AttributeList get(LLVMContext &C, ArrayRef< std::pair< unsigned, Attribute > > Attrs)
Create an AttributeList with the specified parameters in it.
static Attribute getWithStructRetType(LLVMContext &Context, Type *Ty)
static Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
static bool isTypeAttrKind(AttrKind Kind)
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
@ TombstoneKey
Use as Tombstone key for DenseMap of AttrKind.
@ None
No attributes have been set.
@ EmptyKey
Use as Empty key for DenseMap of AttrKind.
@ EndAttrKinds
Sentinel value useful for loops.
static bool isConstantRangeAttrKind(AttrKind Kind)
static Attribute getWithInAllocaType(LLVMContext &Context, Type *Ty)
static bool isIntAttrKind(AttrKind Kind)
static Attribute getWithByValType(LLVMContext &Context, Type *Ty)
static bool isEnumAttrKind(AttrKind Kind)
LLVM Basic Block Representation.
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
void replacePhiUsesWith(BasicBlock *Old, BasicBlock *New)
Update all phi nodes in this basic block to refer to basic block New instead of basic block Old.
SymbolTableList< BasicBlock >::iterator eraseFromParent()
Unlink 'this' from the containing function and delete it.
void insertDbgRecordBefore(DbgRecord *DPV, InstListType::iterator Here)
Insert a DbgRecord into a block at the position given by Here.
void moveBefore(BasicBlock *MovePos)
Unlink this basic block from its current function and insert it into the function that MovePos lives ...
const Instruction & back() const
static BinaryOperator * Create(BinaryOps Op, Value *S1, Value *S2, const Twine &Name, BasicBlock::iterator InsertBefore)
Construct a binary instruction, given the opcode and the two operands.
Represents a module in a bitcode file.
Expected< std::unique_ptr< ModuleSummaryIndex > > getSummary()
Parse the specified bitcode buffer, returning the module summary index.
Expected< BitcodeLTOInfo > getLTOInfo()
Returns information about the module to be used for LTO: whether to compile with ThinLTO,...
Error readSummary(ModuleSummaryIndex &CombinedIndex, StringRef ModulePath, std::function< bool(GlobalValue::GUID)> IsPrevailing=nullptr)
Parse the specified bitcode buffer and merge its module summary index into CombinedIndex.
Expected< std::unique_ptr< Module > > parseModule(LLVMContext &Context, ParserCallbacks Callbacks={})
Read the entire bitcode module and return it.
Expected< std::unique_ptr< Module > > getLazyModule(LLVMContext &Context, bool ShouldLazyLoadMetadata, bool IsImporting, ParserCallbacks Callbacks={})
Read the bitcode module and prepare for lazy deserialization of function bodies.
Value * getValueFwdRef(unsigned Idx, Type *Ty, unsigned TyID, BasicBlock *ConstExprInsertBB)
void push_back(Value *V, unsigned TypeID)
void replaceValueWithoutRAUW(unsigned ValNo, Value *NewV)
Error assignValue(unsigned Idx, Value *V, unsigned TypeID)
void shrinkTo(unsigned N)
unsigned getTypeID(unsigned ValNo) const
This class maintains the abbreviations read from a block info block.
This represents a position within a bitcode file, implemented on top of a SimpleBitstreamCursor.
Error JumpToBit(uint64_t BitNo)
Reset the stream to the specified bit number.
uint64_t GetCurrentBitNo() const
Return the bit # of the bit we are reading.
ArrayRef< uint8_t > getBitcodeBytes() const
Expected< word_t > Read(unsigned NumBits)
Expected< BitstreamEntry > advance(unsigned Flags=0)
Advance the current bitstream, returning the next entry in the stream.
Expected< BitstreamEntry > advanceSkippingSubblocks(unsigned Flags=0)
This is a convenience function for clients that don't expect any subblocks.
void setBlockInfo(BitstreamBlockInfo *BI)
Set the block info to be used by this BitstreamCursor to interpret abbreviated records.
Expected< unsigned > readRecord(unsigned AbbrevID, SmallVectorImpl< uint64_t > &Vals, StringRef *Blob=nullptr)
Error EnterSubBlock(unsigned BlockID, unsigned *NumWordsP=nullptr)
Having read the ENTER_SUBBLOCK abbrevid, and enter the block.
Error SkipBlock()
Having read the ENTER_SUBBLOCK abbrevid and a BlockID, skip over the body of this block.
Expected< unsigned > skipRecord(unsigned AbbrevID)
Read the current record and discard it, returning the code for the record.
uint64_t getCurrentByteNo() const
bool canSkipToPos(size_t pos) const
static BlockAddress * get(Function *F, BasicBlock *BB)
Return a BlockAddress for the specified function and basic block.
Conditional or Unconditional Branch instruction.
static BranchInst * Create(BasicBlock *IfTrue, BasicBlock::iterator InsertBefore)
Allocate memory in an ever growing pool, as if by bump-pointer.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
bool isInlineAsm() const
Check if this call is an inline asm statement.
Value * getCalledOperand() const
void setAttributes(AttributeList A)
Set the parameter attributes for this call.
Intrinsic::ID getIntrinsicID() const
Returns the intrinsic ID of the intrinsic called or Intrinsic::not_intrinsic if the called function i...
unsigned arg_size() const
AttributeList getAttributes() const
Return the parameter attributes for this call.
static CallBrInst * Create(FunctionType *Ty, Value *Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, const Twine &NameStr, BasicBlock::iterator InsertBefore)
This class represents a function call, abstracting a target machine's calling convention.
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr, BasicBlock::iterator InsertBefore)
static CastInst * Create(Instruction::CastOps, Value *S, Type *Ty, const Twine &Name, BasicBlock::iterator InsertBefore)
Provides a way to construct any of the CastInst subclasses using an opcode instead of the subclass's ...
static bool castIsValid(Instruction::CastOps op, Type *SrcTy, Type *DstTy)
This method can be used to determine if a cast from SrcTy to DstTy using Opcode op is valid or not.
static CatchPadInst * Create(Value *CatchSwitch, ArrayRef< Value * > Args, const Twine &NameStr, BasicBlock::iterator InsertBefore)
static CatchReturnInst * Create(Value *CatchPad, BasicBlock *BB, BasicBlock::iterator InsertBefore)
static CatchSwitchInst * Create(Value *ParentPad, BasicBlock *UnwindDest, unsigned NumHandlers, const Twine &NameStr, BasicBlock::iterator InsertBefore)
static CleanupPadInst * Create(Value *ParentPad, ArrayRef< Value * > Args, const Twine &NameStr, BasicBlock::iterator InsertBefore)
static CleanupReturnInst * Create(Value *CleanupPad, BasicBlock *UnwindBB, BasicBlock::iterator InsertBefore)
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
static CmpInst * Create(OtherOps Op, Predicate predicate, Value *S1, Value *S2, const Twine &Name, BasicBlock::iterator InsertBefore)
Construct a compare instruction, given the opcode, the predicate and the two operands.
bool isFPPredicate() const
bool isIntPredicate() const
@ Largest
The linker will choose the largest COMDAT.
@ SameSize
The data referenced by the COMDAT must be the same size.
@ Any
The linker may choose any COMDAT.
@ NoDeduplicate
No deduplication is performed.
@ ExactMatch
The data referenced by the COMDAT must be the same.
static Constant * get(ArrayType *T, ArrayRef< Constant * > V)
static Constant * getString(LLVMContext &Context, StringRef Initializer, bool AddNull=true)
This method constructs a CDS and initializes it with a text string.
static Constant * get(LLVMContext &Context, ArrayRef< ElementTy > Elts)
get() constructor - Return a constant with array type with an element count and element type matching...
static Constant * getFP(Type *ElementType, ArrayRef< uint16_t > Elts)
getFP() constructors - Return a constant of array type with a float element type taken from argument ...
static Constant * get(LLVMContext &Context, ArrayRef< uint8_t > Elts)
get() constructors - Return a constant with vector type with an element count and element type matchi...
static Constant * getFP(Type *ElementType, ArrayRef< uint16_t > Elts)
getFP() constructors - Return a constant of vector type with a float element type taken from argument...
static Constant * getExtractElement(Constant *Vec, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
static Constant * getCast(unsigned ops, Constant *C, Type *Ty, bool OnlyIfReduced=false)
Convenience function for getting a Cast operation.
static Constant * getInsertElement(Constant *Vec, Constant *Elt, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
static Constant * getShuffleVector(Constant *V1, Constant *V2, ArrayRef< int > Mask, Type *OnlyIfReducedTy=nullptr)
static bool isSupportedGetElementPtr(const Type *SrcElemTy)
Whether creating a constant expression for this getelementptr type is supported.
static Constant * getGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList, bool InBounds=false, std::optional< unsigned > InRangeIndex=std::nullopt, Type *OnlyIfReducedTy=nullptr)
Getelementptr form.
static Constant * get(unsigned Opcode, Constant *C1, Constant *C2, unsigned Flags=0, Type *OnlyIfReducedTy=nullptr)
get - Return a binary or shift operator constant expression, folding if possible.
static bool isSupportedBinOp(unsigned Opcode)
Whether creating a constant expression for this binary operator is supported.
static bool isSupportedCastOp(unsigned Opcode)
Whether creating a constant expression for this cast is supported.
static Constant * getCompare(unsigned short pred, Constant *C1, Constant *C2, bool OnlyIfReduced=false)
Return an ICmp or FCmp comparison operator constant expression.
This is the shared class of boolean and integer constants.
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
This class represents a range of values.
static Constant * get(StructType *T, ArrayRef< Constant * > V)
static Constant * get(ArrayRef< Constant * > V)
This is an important base class in LLVM.
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
Records a position in IR for a source label (DILabel).
Record of a variable value-assignment, aka a non instruction representation of the dbg....
static DSOLocalEquivalent * get(GlobalValue *GV)
Return a DSOLocalEquivalent for the specified global value.
This class represents an Operation in the Expression.
A parsed version of the target data layout string in and methods for querying it.
static Expected< DataLayout > parse(StringRef LayoutDescription)
Parse a data layout string and return the layout.
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
iterator find(const_arg_type_t< KeyT > Val)
bool erase(const KeyT &Val)
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Implements a dense probed hash-table based set.
Base class for error info classes.
virtual std::string message() const
Return the error message as a string.
virtual std::error_code convertToErrorCode() const =0
Convert this error to a std::error_code.
Represents either an error or a value T.
std::error_code getError() const
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
reference get()
Returns a reference to the stored T value.
This instruction compares its operands according to the predicate given to the constructor.
Convenience struct for specifying and reasoning about fast-math flags.
void setFast(bool B=true)
void setAllowContract(bool B=true)
void setAllowReciprocal(bool B=true)
void setNoSignedZeros(bool B=true)
void setNoNaNs(bool B=true)
void setAllowReassoc(bool B=true)
Flag setters.
void setApproxFunc(bool B=true)
void setNoInfs(bool B=true)
An instruction for ordering other memory operations.
This class represents a freeze function that returns random concrete value if an operand is either a ...
std::pair< ValueInfo, CalleeInfo > EdgeTy
<CalleeValueInfo, CalleeInfo> call edge pair.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
BasicBlockListType::iterator iterator
const BasicBlock & back() const
virtual void setStripDebugInfo()=0
virtual Error materializeModule()=0
Make sure the entire Module has been completely read.
virtual Error materializeMetadata()=0
virtual Error materialize(GlobalValue *GV)=0
Make sure the given GlobalValue is fully read.
virtual std::vector< StructType * > getIdentifiedStructTypes() const =0
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr, BasicBlock::iterator InsertBefore)
static GlobalAlias * create(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Aliasee, Module *Parent)
If a parent module is specified, the alias is automatically inserted into the end of the specified mo...
static GlobalIFunc * create(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Resolver, Module *Parent)
If a parent module is specified, the ifunc is automatically inserted into the end of the specified mo...
void setAlignment(Align Align)
Sets the alignment attribute of the GlobalObject.
void setComdat(Comdat *C)
void setSection(StringRef S)
Change the section for this global.
Function and variable summary information to aid decisions and implementation of importing.
void setOriginalName(GlobalValue::GUID Name)
Initialize the original name hash in this summary.
static bool isLocalLinkage(LinkageTypes Linkage)
void setUnnamedAddr(UnnamedAddr Val)
bool hasLocalLinkage() const
bool hasDefaultVisibility() const
void setDLLStorageClass(DLLStorageClassTypes C)
void setThreadLocalMode(ThreadLocalMode Val)
bool hasExternalWeakLinkage() const
DLLStorageClassTypes
Storage classes of global values for PE targets.
@ DLLExportStorageClass
Function to be accessible from DLL.
@ DLLImportStorageClass
Function to be imported from DLL.
GUID getGUID() const
Return a 64-bit global unique ID constructed from global value name (i.e.
void setDSOLocal(bool Local)
PointerType * getType() const
Global values are always pointers.
VisibilityTypes
An enumeration for the kinds of visibility of global values.
@ DefaultVisibility
The GV is visible.
@ HiddenVisibility
The GV is hidden.
@ ProtectedVisibility
The GV is protected.
void setVisibility(VisibilityTypes V)
void setSanitizerMetadata(SanitizerMetadata Meta)
std::string getGlobalIdentifier() const
Return the modified name for this global value suitable to be used as the key for a global lookup (e....
LinkageTypes
An enumeration for the kinds of linkage for global values.
@ PrivateLinkage
Like Internal, but omit from symbol table.
@ CommonLinkage
Tentative definitions.
@ InternalLinkage
Rename collisions when linking (static functions).
@ LinkOnceAnyLinkage
Keep one copy of function when linking (inline)
@ WeakODRLinkage
Same, but only replaced by something equivalent.
@ ExternalLinkage
Externally visible function.
@ WeakAnyLinkage
Keep one copy of named function when linking (weak)
@ AppendingLinkage
Special purpose, only applies to global arrays.
@ AvailableExternallyLinkage
Available for inspection, not emission.
@ ExternalWeakLinkage
ExternalWeak linkage description.
@ LinkOnceODRLinkage
Same, but only replaced by something equivalent.
void setPartition(StringRef Part)
void setAttributes(AttributeSet A)
Set attribute list for this global.
void setCodeModel(CodeModel::Model CM)
Change the code model for this global.
This instruction compares its operands according to the predicate given to the constructor.
Indirect Branch Instruction.
void addDestination(BasicBlock *Dest)
Add a destination.
static IndirectBrInst * Create(Value *Address, unsigned NumDests, BasicBlock::iterator InsertBefore)
unsigned getNumDestinations() const
return the number of possible destinations in this indirectbr instruction.
static InlineAsm * get(FunctionType *Ty, StringRef AsmString, StringRef Constraints, bool hasSideEffects, bool isAlignStack=false, AsmDialect asmDialect=AD_ATT, bool canThrow=false)
InlineAsm::get - Return the specified uniqued inline asm string.
std::vector< ConstraintInfo > ConstraintInfoVector
static InsertElementInst * Create(Value *Vec, Value *NewElt, Value *Idx, const Twine &NameStr, BasicBlock::iterator InsertBefore)
static InsertValueInst * Create(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &NameStr, BasicBlock::iterator InsertBefore)
const BasicBlock * getParent() const
const char * getOpcodeName() const
InstListType::iterator insertInto(BasicBlock *ParentBB, InstListType::iterator It)
Inserts an unlinked instruction into ParentBB at position It and returns the iterator of the inserted...
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
@ MIN_INT_BITS
Minimum number of bits that can be specified.
@ MAX_INT_BITS
Maximum number of bits that can be specified.
static InvokeInst * Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, const Twine &NameStr, BasicBlock::iterator InsertBefore)
This is an important class for using LLVM in a threaded context.
SyncScope::ID getOrInsertSyncScopeID(StringRef SSN)
getOrInsertSyncScopeID - Maps synchronization scope name to synchronization scope ID.
void emitError(uint64_t LocCookie, const Twine &ErrorStr)
emitError - Emit an error message to the currently installed error handler with optional location inf...
The landingpad instruction holds all of the information necessary to generate correct exception handl...
void addClause(Constant *ClauseVal)
Add a catch or filter clause to the landing pad.
void setCleanup(bool V)
Indicate that this landingpad instruction is a cleanup.
static LandingPadInst * Create(Type *RetTy, unsigned NumReservedClauses, const Twine &NameStr, BasicBlock::iterator InsertBefore)
Constructors - NumReservedClauses is a hint for the number of incoming clauses that this landingpad w...
An instruction for reading from memory.
Tracking metadata reference owned by Metadata.
StringRef getString() const
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
ValueT lookup(const KeyT &Key) const
size_t getBufferSize() const
StringRef getBufferIdentifier() const
const char * getBufferStart() const
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFileOrSTDIN(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, std::optional< Align > Alignment=std::nullopt)
Open the specified file as a MemoryBuffer, or open stdin if the Filename is "-".
static MemoryEffectsBase readOnly()
Create MemoryEffectsBase that can read any memory.
static MemoryEffectsBase argMemOnly(ModRefInfo MR=ModRefInfo::ModRef)
Create MemoryEffectsBase that can only access argument memory.
static MemoryEffectsBase inaccessibleMemOnly(ModRefInfo MR=ModRefInfo::ModRef)
Create MemoryEffectsBase that can only access inaccessible memory.
static MemoryEffectsBase createFromIntValue(uint32_t Data)
Create MemoryEffectsBase from an encoded integer value (used by memory attribute).
static MemoryEffectsBase writeOnly()
Create MemoryEffectsBase that can write any memory.
static MemoryEffectsBase inaccessibleOrArgMemOnly(ModRefInfo MR=ModRefInfo::ModRef)
Create MemoryEffectsBase that can only access inaccessible or argument memory.
static MemoryEffectsBase none()
Create MemoryEffectsBase that cannot read or write any memory.
static MemoryEffectsBase unknown()
Create MemoryEffectsBase that can read and write any memory.
Class to hold module path string table and global value map, and encapsulate methods for operating on...
std::set< std::string > & cfiFunctionDecls()
TypeIdSummary & getOrInsertTypeIdSummary(StringRef TypeId)
Return an existing or new TypeIdSummary entry for TypeId.
ValueInfo getOrInsertValueInfo(GlobalValue::GUID GUID)
Return a ValueInfo for GUID.
StringRef saveString(StringRef String)
void setFlags(uint64_t Flags)
void addBlockCount(uint64_t C)
ModuleInfo * addModule(StringRef ModPath, ModuleHash Hash=ModuleHash{{0}})
Add a new module with the given Hash, mapped to the given ModID, and return a reference to the module...
void addGlobalValueSummary(const GlobalValue &GV, std::unique_ptr< GlobalValueSummary > Summary)
Add a global value summary for a value.
static constexpr uint64_t BitcodeSummaryVersion
GlobalValueSummary * findSummaryInModule(ValueInfo VI, StringRef ModuleId) const
Find the summary for ValueInfo VI in module ModuleId, or nullptr if not found.
unsigned addOrGetStackIdIndex(uint64_t StackId)
std::set< std::string > & cfiFunctionDefs()
ModuleInfo * getModule(StringRef ModPath)
Return module entry for module with the given ModPath.
void addOriginalName(GlobalValue::GUID ValueGUID, GlobalValue::GUID OrigGUID)
Add an original name for the value of the given GUID.
TypeIdCompatibleVtableInfo & getOrInsertTypeIdCompatibleVtableSummary(StringRef TypeId)
Return an existing or new TypeIdCompatibleVtableMap entry for TypeId.
A Module instance is used to store all the information related to an LLVM module.
NamedMDNode * getNamedMetadata(const Twine &Name) const
Return the first NamedMDNode in the module with the specified name.
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
NamedMDNode * getOrInsertNamedMetadata(StringRef Name)
Return the named MDNode in the module with the specified name.
Comdat * getOrInsertComdat(StringRef Name)
Return the Comdat in the module with the specified name.
Metadata * getModuleFlag(StringRef Key) const
Return the corresponding value if Key appears in module flags, otherwise return null.
void addOperand(MDNode *M)
static NoCFIValue * get(GlobalValue *GV)
Return a NoCFIValue for the specified function.
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr, BasicBlock::iterator InsertBefore)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
static PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
static ResumeInst * Create(Value *Exn, BasicBlock::iterator InsertBefore)
static ReturnInst * Create(LLVMContext &C, Value *retVal, BasicBlock::iterator InsertBefore)
static SelectInst * Create(Value *C, Value *S1, Value *S2, const Twine &NameStr, BasicBlock::iterator InsertBefore, Instruction *MDFrom=nullptr)
This instruction constructs a fixed permutation of two input vectors.
ArrayRef< int > getShuffleMask() const
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
StringRef str() const
Explicit conversion to StringRef.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
iterator erase(const_iterator CI)
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - Check if the string is empty.
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
bool equals(StringRef RHS) const
equals - Check for string equality, this is more efficient than compare() when the relative ordering ...
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.
void setBody(ArrayRef< Type * > Elements, bool isPacked=false)
Specify a body for an opaque identified type.
static StructType * create(LLVMContext &Context, StringRef Name)
This creates an identified struct.
void setName(StringRef Name)
Change the name of this type to the specified name, or to a name with a suffix if there is a collisio...
static SwitchInst * Create(Value *Value, BasicBlock *Default, unsigned NumCases, BasicBlock::iterator InsertBefore)
Verify that the TBAA Metadatas are valid.
bool visitTBAAMetadata(Instruction &I, const MDNode *MD)
Visit an instruction and return true if it is valid, return false if an invalid TBAA is attached.
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.
@ HasZeroInit
zeroinitializer is valid for this target extension type.
See the file comment for details on the usage of the TrailingObjects type.
TrailingObjects()=default
Triple - Helper class for working with autoconf configuration names.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
std::string str() const
Return the twine contents as a std::string.
The instances of the Type class are immutable: once they are created, they are never changed.
static Type * getHalfTy(LLVMContext &C)
Type * getStructElementType(unsigned N) const
static Type * getDoubleTy(LLVMContext &C)
bool isVectorTy() const
True if this is an instance of VectorType.
bool isArrayTy() const
True if this is an instance of ArrayType.
static Type * getX86_FP80Ty(LLVMContext &C)
bool isLabelTy() const
Return true if this is 'label'.
static Type * getBFloatTy(LLVMContext &C)
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
bool isPointerTy() const
True if this is an instance of PointerType.
static IntegerType * getInt1Ty(LLVMContext &C)
Type * getArrayElementType() const
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)
unsigned getStructNumElements() const
uint64_t getArrayNumElements() const
TypeID
Definitions of all of the base types for the Type system.
static Type * getX86_MMXTy(LLVMContext &C)
static Type * getVoidTy(LLVMContext &C)
static Type * getLabelTy(LLVMContext &C)
bool isStructTy() const
True if this is an instance of StructType.
static Type * getFP128Ty(LLVMContext &C)
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
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 isFunctionTy() const
True if this is an instance of FunctionType.
static IntegerType * getInt32Ty(LLVMContext &C)
static Type * getFloatTy(LLVMContext &C)
bool isIntegerTy() const
True if this is an instance of IntegerType.
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'.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
bool isMetadataTy() const
Return true if this is 'metadata'.
static UnaryOperator * Create(UnaryOps Op, Value *S, const Twine &Name, BasicBlock::iterator InsertBefore)
Construct a unary instruction, given the opcode and an operand.
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
This function has undefined behavior.
A Use represents the edge between a Value definition and its users.
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
void setName(const Twine &Name)
Change the name of the value.
void deleteValue()
Delete a pointer to a generic Value.
static constexpr unsigned MaxAlignmentExponent
The maximum alignment for instructions.
Value & operator=(const Value &)=delete
std::pair< iterator, bool > insert(const ValueT &V)
bool contains(const_arg_type_t< ValueT > V) const
Check if the set contains the given element.
self_iterator getIterator()
This file contains the declaration of the Comdat class, which represents a single COMDAT in LLVM.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char TypeName[]
Key for Kernel::Arg::Metadata::mTypeName.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
AttributeMask typeIncompatible(Type *Ty, AttributeSafetyKind ASK=ASK_ALL)
Which attributes cannot be applied to a type.
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ MaxID
The highest possible ID. Must be some 2^k - 1.
@ X86_INTR
x86 hardware interrupt context.
@ C
The default llvm calling convention, compatible with C.
constexpr uint8_t RecordLength
Length of the parts of a physical GOFF record.
AttributeList getAttributes(LLVMContext &C, ID id)
Return the attributes for an intrinsic.
@ SingleThread
Synchronized with respect to signal handlers executing in the same thread.
@ System
Synchronized with respect to all concurrently executing threads.
@ TYPE_CODE_OPAQUE_POINTER
@ FS_COMBINED_GLOBALVAR_INIT_REFS
@ FS_TYPE_CHECKED_LOAD_VCALLS
@ FS_COMBINED_ORIGINAL_NAME
@ FS_PERMODULE_VTABLE_GLOBALVAR_INIT_REFS
@ FS_TYPE_TEST_ASSUME_CONST_VCALL
@ FS_PERMODULE_GLOBALVAR_INIT_REFS
@ FS_TYPE_TEST_ASSUME_VCALLS
@ FS_COMBINED_CALLSITE_INFO
@ FS_PERMODULE_CALLSITE_INFO
@ FS_PERMODULE_ALLOC_INFO
@ FS_TYPE_CHECKED_LOAD_CONST_VCALL
@ IDENTIFICATION_CODE_EPOCH
@ IDENTIFICATION_CODE_STRING
@ CST_CODE_CE_INBOUNDS_GEP
@ CST_CODE_INLINEASM_OLD3
@ CST_CODE_DSO_LOCAL_EQUIVALENT
@ CST_CODE_CE_GEP_WITH_INRANGE_INDEX
@ CST_CODE_INLINEASM_OLD2
@ VST_CODE_COMBINED_ENTRY
@ COMDAT_SELECTION_KIND_LARGEST
@ COMDAT_SELECTION_KIND_ANY
@ COMDAT_SELECTION_KIND_SAME_SIZE
@ COMDAT_SELECTION_KIND_EXACT_MATCH
@ COMDAT_SELECTION_KIND_NO_DUPLICATES
@ ATTR_KIND_STACK_PROTECT
@ ATTR_KIND_STACK_PROTECT_STRONG
@ ATTR_KIND_SANITIZE_MEMORY
@ ATTR_KIND_OPTIMIZE_FOR_SIZE
@ ATTR_KIND_INACCESSIBLEMEM_ONLY
@ ATTR_KIND_FNRETTHUNK_EXTERN
@ ATTR_KIND_SANITIZE_ADDRESS
@ ATTR_KIND_NO_IMPLICIT_FLOAT
@ ATTR_KIND_DEAD_ON_UNWIND
@ ATTR_KIND_STACK_ALIGNMENT
@ ATTR_KIND_INACCESSIBLEMEM_OR_ARGMEMONLY
@ ATTR_KIND_STACK_PROTECT_REQ
@ ATTR_KIND_NULL_POINTER_IS_VALID
@ ATTR_KIND_SANITIZE_HWADDRESS
@ ATTR_KIND_RETURNS_TWICE
@ ATTR_KIND_SHADOWCALLSTACK
@ ATTR_KIND_OPT_FOR_FUZZING
@ ATTR_KIND_ALLOCATED_POINTER
@ ATTR_KIND_DISABLE_SANITIZER_INSTRUMENTATION
@ ATTR_KIND_NON_LAZY_BIND
@ ATTR_KIND_DEREFERENCEABLE
@ ATTR_KIND_OPTIMIZE_NONE
@ ATTR_KIND_DEREFERENCEABLE_OR_NULL
@ ATTR_KIND_SPECULATIVE_LOAD_HARDENING
@ ATTR_KIND_ALWAYS_INLINE
@ ATTR_KIND_PRESPLIT_COROUTINE
@ ATTR_KIND_NO_SANITIZE_COVERAGE
@ ATTR_KIND_NO_SANITIZE_BOUNDS
@ ATTR_KIND_SANITIZE_MEMTAG
@ ATTR_KIND_CORO_ONLY_DESTROY_WHEN_COMPLETE
@ ATTR_KIND_SANITIZE_THREAD
@ ATTR_KIND_OPTIMIZE_FOR_DEBUGGING
@ SYNC_SCOPE_NAMES_BLOCK_ID
@ PARAMATTR_GROUP_BLOCK_ID
@ IDENTIFICATION_BLOCK_ID
@ GLOBALVAL_SUMMARY_BLOCK_ID
@ FULL_LTO_GLOBALVAL_SUMMARY_BLOCK_ID
@ OPERAND_BUNDLE_TAGS_BLOCK_ID
@ BLOCKINFO_BLOCK_ID
BLOCKINFO_BLOCK is used to define metadata about blocks, for example, standard abbrevs that should be...
@ MODULE_CODE_SOURCE_FILENAME
@ MODULE_CODE_SECTIONNAME
@ FUNC_CODE_INST_ATOMICRMW_OLD
@ FUNC_CODE_INST_CATCHRET
@ FUNC_CODE_INST_LANDINGPAD
@ FUNC_CODE_INST_EXTRACTVAL
@ FUNC_CODE_INST_CATCHPAD
@ FUNC_CODE_INST_CATCHSWITCH
@ FUNC_CODE_INST_INBOUNDS_GEP_OLD
@ FUNC_CODE_INST_STOREATOMIC_OLD
@ FUNC_CODE_INST_CLEANUPRET
@ FUNC_CODE_INST_LANDINGPAD_OLD
@ FUNC_CODE_DEBUG_RECORD_VALUE
@ FUNC_CODE_INST_LOADATOMIC
@ FUNC_CODE_DEBUG_RECORD_ASSIGN
@ FUNC_CODE_INST_STOREATOMIC
@ FUNC_CODE_INST_ATOMICRMW
@ FUNC_CODE_DEBUG_LOC_AGAIN
@ FUNC_CODE_INST_EXTRACTELT
@ FUNC_CODE_INST_INDIRECTBR
@ FUNC_CODE_DEBUG_RECORD_VALUE_SIMPLE
@ FUNC_CODE_INST_INSERTVAL
@ FUNC_CODE_DECLAREBLOCKS
@ FUNC_CODE_DEBUG_RECORD_LABEL
@ FUNC_CODE_INST_INSERTELT
@ FUNC_CODE_BLOCKADDR_USERS
@ FUNC_CODE_INST_CLEANUPPAD
@ FUNC_CODE_INST_SHUFFLEVEC
@ FUNC_CODE_INST_STORE_OLD
@ FUNC_CODE_INST_UNREACHABLE
@ FUNC_CODE_INST_CMPXCHG_OLD
@ FUNC_CODE_DEBUG_RECORD_DECLARE
@ FUNC_CODE_OPERAND_BUNDLE
@ PARAMATTR_CODE_ENTRY_OLD
@ PARAMATTR_GRP_CODE_ENTRY
initializer< Ty > init(const Ty &Val)
Linkage
Describes symbol linkage. This can be used to resolve definition clashes.
Scope
Defines the scope in which this symbol should be visible: Default – Visible in the public interface o...
NodeAddr< FuncNode * > Func
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
@ Low
Lower the current thread's priority such that it does not affect foreground tasks significantly.
void UpgradeIntrinsicCall(CallBase *CB, Function *NewFn)
This is the complement to the above, replacing a specific call to an intrinsic function with a call t...
const std::error_category & BitcodeErrorCategory()
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
Expected< std::unique_ptr< Module > > parseBitcodeFile(MemoryBufferRef Buffer, LLVMContext &Context, ParserCallbacks Callbacks={})
Read the specified bitcode file, returning the module.
void UpgradeInlineAsmString(std::string *AsmStr)
Upgrade comment in call to inline asm that represents an objc retain release marker.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are are tuples (A,...
std::error_code make_error_code(BitcodeError E)
bool stripDebugInfo(Function &F)
Expected< bool > isBitcodeContainingObjCCategory(MemoryBufferRef Buffer)
Return true if Buffer contains a bitcode file with ObjC code (category or class) in it.
void handleAllErrors(Error E, HandlerTs &&... Handlers)
Behaves the same as handleErrors, except that by contract all errors must be handled by the given han...
bool UpgradeIntrinsicFunction(Function *F, Function *&NewFn)
This is a more granular function that simply checks an intrinsic function for upgrading,...
void UpgradeAttributes(AttrBuilder &B)
Upgrade attributes that changed format or kind.
Expected< std::string > getBitcodeTargetTriple(MemoryBufferRef Buffer)
Read the header of the specified bitcode buffer and extract just the triple information.
std::unique_ptr< Module > parseModule(const uint8_t *Data, size_t Size, LLVMContext &Context)
Fuzzer friendly interface for the llvm bitcode parser.
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
Expected< BitcodeFileContents > getBitcodeFileContents(MemoryBufferRef Buffer)
Returns the contents of a bitcode file.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
bool UpgradeModuleFlags(Module &M)
This checks for module flags which should be upgraded.
Value * getSplatValue(const Value *V)
Get splat value if the input is a splat vector or return nullptr.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
void UpgradeOperandBundles(std::vector< OperandBundleDef > &OperandBundles)
Upgrade operand bundles (without knowing about their user instruction).
std::vector< VirtFuncOffset > VTableFuncList
List of functions referenced by a particular vtable definition.
Constant * UpgradeBitCastExpr(unsigned Opc, Constant *C, Type *DestTy)
This is an auto-upgrade for bitcast constant expression between pointers with different address space...
Expected< std::unique_ptr< ModuleSummaryIndex > > getModuleSummaryIndex(MemoryBufferRef Buffer)
Parse the specified bitcode buffer, returning the module summary index.
StringMapEntry< Value * > ValueName
OutputIt transform(R &&Range, OutputIt d_first, UnaryFunction F)
Wrapper function around std::transform to apply a function to a range and store the result elsewhere.
Expected< std::string > getBitcodeProducerString(MemoryBufferRef Buffer)
Read the header of the specified bitcode buffer and extract just the producer string information.
auto reverse(ContainerTy &&C)
Expected< std::unique_ptr< Module > > getLazyBitcodeModule(MemoryBufferRef Buffer, LLVMContext &Context, bool ShouldLazyLoadMetadata=false, bool IsImporting=false, ParserCallbacks Callbacks={})
Read the header of the specified bitcode buffer and prepare for lazy deserialization of function bodi...
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
detail::ValueMatchesPoly< M > HasValue(M Matcher)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
std::string UpgradeDataLayoutString(StringRef DL, StringRef Triple)
Upgrade the datalayout string by adding a section for address space pointers.
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly.
Expected< std::vector< BitcodeModule > > getBitcodeModuleList(MemoryBufferRef Buffer)
Returns a list of modules in the specified bitcode buffer.
Expected< BitcodeLTOInfo > getBitcodeLTOInfo(MemoryBufferRef Buffer)
Returns LTO information for the specified bitcode file.
GlobalVariable * UpgradeGlobalVariable(GlobalVariable *GV)
This checks for global variables which should be upgraded.
bool StripDebugInfo(Module &M)
Strip debug info in the module if it exists.
AtomicOrdering
Atomic ordering for LLVM's memory model.
Instruction * UpgradeBitCastInst(unsigned Opc, Value *V, Type *DestTy, Instruction *&Temp)
This is an auto-upgrade for bitcast between pointers with different address spaces: the instruction i...
MaybeAlign decodeMaybeAlign(unsigned Value)
Dual operation of the encode function above.
DWARFExpression::Operation Op
constexpr unsigned BitWidth
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
bool SkipBitcodeWrapperHeader(const unsigned char *&BufPtr, const unsigned char *&BufEnd, bool VerifyBufferSize)
SkipBitcodeWrapperHeader - Some systems wrap bc files with a special header for padding or other reas...
bool isBitcodeWrapper(const unsigned char *BufPtr, const unsigned char *BufEnd)
isBitcodeWrapper - Return true if the given bytes are the magic bytes for an LLVM IR bitcode wrapper.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
gep_type_iterator gep_type_begin(const User *GEP)
APInt readWideAPInt(ArrayRef< uint64_t > Vals, unsigned TypeBits)
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
bool UpgradeDebugInfo(Module &M)
Check the debug info version number, if it is out-dated, drop the debug info.
void UpgradeFunctionAttributes(Function &F)
Correct any IR that is relying on old function attribute behavior.
Error readModuleSummaryIndex(MemoryBufferRef Buffer, ModuleSummaryIndex &CombinedIndex)
Parse the specified bitcode buffer and merge the index into CombinedIndex.
std::vector< TypeIdOffsetVtableInfo > TypeIdCompatibleVtableInfo
List of vtable definitions decorated by a particular type identifier, and their corresponding offsets...
void UpgradeARCRuntime(Module &M)
Convert calls to ARC runtime functions to intrinsic calls and upgrade the old retain release marker t...
Expected< std::unique_ptr< ModuleSummaryIndex > > getModuleSummaryIndexForFile(StringRef Path, bool IgnoreEmptyThinLTOIndexFile=false)
Parse the module summary index out of an IR file and return the module summary index object if found,...
Expected< std::unique_ptr< Module > > getOwningLazyBitcodeModule(std::unique_ptr< MemoryBuffer > &&Buffer, LLVMContext &Context, bool ShouldLazyLoadMetadata=false, bool IsImporting=false, ParserCallbacks Callbacks={})
Like getLazyBitcodeModule, except that the module takes ownership of the memory buffer if successful.
std::error_code errorToErrorCodeAndEmitErrors(LLVMContext &Ctx, Error Err)
Implement std::hash so that hash_code can be used in STL containers.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Summary of memprof metadata on allocations.
Basic information extracted from a bitcode module to be used for LTO.
When advancing through a bitstream cursor, each advance can discover a few different kinds of entries...
Class to accumulate and hold information about a callee.
static constexpr unsigned RelBlockFreqBits
The value stored in RelBlockFreq has to be interpreted as the digits of a scaled number with a scale ...
Summary of memprof callsite metadata.
Flags specific to function summaries.
Describes the uses of a parameter by the function.
std::vector< Call > Calls
In the per-module summary, it summarizes the byte offset applied to each pointer parameter before pas...
ConstantRange Use
The range contains byte offsets from the parameter pointer which accessed by the function.
static constexpr uint32_t RangeWidth
Group flags (Linkage, NotEligibleToImport, etc.) as a bitfield.
Summary of a single MIB in a memprof metadata on allocations.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
std::optional< ValueTypeCallbackTy > ValueType
The ValueType callback is called for every function definition or declaration and allows accessing th...
std::optional< DataLayoutCallbackFuncTy > DataLayout
std::optional< MDTypeCallbackTy > MDType
The MDType callback is called for every value in metadata.
A MapVector that performs no allocations if smaller than a certain size.
std::map< uint64_t, WholeProgramDevirtResolution > WPDRes
Mapping from byte offset to whole-program devirt resolution for that (typeid, byte offset) pair.
Kind
Specifies which kind of type check we should emit for this byte array.
unsigned SizeM1BitWidth
Range of size-1 expressed as a bit width.
enum llvm::TypeTestResolution::Kind TheKind
ValID - Represents a reference of a definition of some sort with no type.
Struct that holds a reference to a particular GUID in a global value summary.
enum llvm::WholeProgramDevirtResolution::Kind TheKind
std::map< std::vector< uint64_t >, ByArg > ResByArg
Resolutions for calls with all constant integer arguments (excluding the first argument,...
std::string SingleImplName