64        "Allow incomplete IR on a best effort basis (references to unknown " 
   65        "metadata will be dropped)"));
 
   80  if (Context.shouldDiscardValueNames())
 
   83        "Can't read textual IR with a Context that discards named Values");
 
   86    if (parseTargetDefinitions(DataLayoutCallback))
 
   90  return parseTopLevelEntities() || validateEndOfModule(UpgradeDebugInfo) ||
 
 
   96  restoreParsingState(Slots);
 
  100  if (parseType(Ty) || parseConstantValue(Ty, 
C))
 
  103    return error(Lex.getLoc(), 
"expected end of string");
 
 
  109  restoreParsingState(Slots);
 
  113  SMLoc Start = Lex.getLoc();
 
  117  SMLoc End = Lex.getLoc();
 
 
  125  restoreParsingState(Slots);
 
  129  SMLoc Start = Lex.getLoc();
 
  131  bool Status = parseDIExpressionBody(Result, 
false);
 
  132  SMLoc End = Lex.getLoc();
 
 
  138void LLParser::restoreParsingState(
const SlotMapping *Slots) {
 
  145        std::make_pair(
I.getKey(), std::make_pair(
I.second, 
LocTy())));
 
  146  for (
const auto &
I : Slots->
Types)
 
  147    NumberedTypes.insert(
 
  148        std::make_pair(
I.first, std::make_pair(
I.second, 
LocTy())));
 
  154      II->getIntrinsicID() != Intrinsic::experimental_noalias_scope_decl)
 
  161        if (MD->isTemporary())
 
  165    assert(
II->use_empty() && 
"Cannot have uses");
 
  166    II->eraseFromParent();
 
 
  175void LLParser::dropUnknownMetadataReferences() {
 
  176  auto Pred = [](
unsigned MDKind, MDNode *
Node) { 
return Node->isTemporary(); };
 
  177  for (Function &
F : *M) {
 
  178    F.eraseMetadataIf(Pred);
 
  180      I.eraseMetadataIf(Pred);
 
  187  for (GlobalVariable &GV : M->globals())
 
  188    GV.eraseMetadataIf(Pred);
 
  193    if (
Info.first->getNumTemporaryUses() == 1) {
 
  194      NumberedMetadata.erase(
ID);
 
  195      ForwardRefMDNodes.erase(
ID);
 
  208  assert(!(SeenNewDbgInfoFormat && SeenOldDbgInfoFormat) &&
 
  209         "Mixed debug intrinsics/records seen without a parsing error?");
 
  212  for (
const auto &RAG : ForwardRefAttrGroups) {
 
  214    const std::vector<unsigned> &
Attrs = RAG.second;
 
  215    AttrBuilder 
B(Context);
 
  217    for (
const auto &Attr : Attrs) {
 
  218      auto R = NumberedAttrBuilders.find(Attr);
 
  219      if (R != NumberedAttrBuilders.end())
 
  224      AttributeList AS = Fn->getAttributes();
 
  225      AttrBuilder FnAttrs(M->getContext(), AS.getFnAttrs());
 
  226      AS = AS.removeFnAttributes(Context);
 
  232      if (MaybeAlign 
A = FnAttrs.getAlignment()) {
 
  233        Fn->setAlignment(*
A);
 
  234        FnAttrs.removeAttribute(Attribute::Alignment);
 
  237      AS = AS.addFnAttributes(Context, FnAttrs);
 
  238      Fn->setAttributes(AS);
 
  240      AttributeList AS = CI->getAttributes();
 
  241      AttrBuilder FnAttrs(M->getContext(), AS.getFnAttrs());
 
  242      AS = AS.removeFnAttributes(Context);
 
  244      AS = AS.addFnAttributes(Context, FnAttrs);
 
  245      CI->setAttributes(AS);
 
  247      AttributeList AS = 
II->getAttributes();
 
  248      AttrBuilder FnAttrs(M->getContext(), AS.getFnAttrs());
 
  249      AS = AS.removeFnAttributes(Context);
 
  251      AS = AS.addFnAttributes(Context, FnAttrs);
 
  252      II->setAttributes(AS);
 
  254      AttributeList AS = CBI->getAttributes();
 
  255      AttrBuilder FnAttrs(M->getContext(), AS.getFnAttrs());
 
  256      AS = AS.removeFnAttributes(Context);
 
  258      AS = AS.addFnAttributes(Context, FnAttrs);
 
  259      CBI->setAttributes(AS);
 
  261      AttrBuilder 
Attrs(M->getContext(), GV->getAttributes());
 
  271  if (!ForwardRefBlockAddresses.empty())
 
  272    return error(ForwardRefBlockAddresses.begin()->first.Loc,
 
  273                 "expected function name in blockaddress");
 
  275  auto ResolveForwardRefDSOLocalEquivalents = [&](
const ValID &GVRef,
 
  276                                                  GlobalValue *FwdRef) {
 
  277    GlobalValue *GV = 
nullptr;
 
  279      GV = M->getNamedValue(GVRef.
StrVal);
 
  281      GV = NumberedVals.get(GVRef.
UIntVal);
 
  286                                  "' referenced by dso_local_equivalent");
 
  290                   "expected a function, alias to function, or ifunc " 
  291                   "in dso_local_equivalent");
 
  294    FwdRef->replaceAllUsesWith(Equiv);
 
  295    FwdRef->eraseFromParent();
 
  302  for (
auto &Iter : ForwardRefDSOLocalEquivalentIDs) {
 
  303    if (ResolveForwardRefDSOLocalEquivalents(Iter.first, Iter.second))
 
  306  for (
auto &Iter : ForwardRefDSOLocalEquivalentNames) {
 
  307    if (ResolveForwardRefDSOLocalEquivalents(Iter.first, Iter.second))
 
  310  ForwardRefDSOLocalEquivalentIDs.clear();
 
  311  ForwardRefDSOLocalEquivalentNames.clear();
 
  313  for (
const auto &NT : NumberedTypes)
 
  314    if (
NT.second.second.isValid())
 
  316                   "use of undefined type '%" + Twine(
NT.first) + 
"'");
 
  318  for (StringMap<std::pair<Type*, LocTy> >::iterator 
I =
 
  319       NamedTypes.begin(), 
E = NamedTypes.end(); 
I != 
E; ++
I)
 
  320    if (
I->second.second.isValid())
 
  321      return error(
I->second.second,
 
  322                   "use of undefined type named '" + 
I->getKey() + 
"'");
 
  324  if (!ForwardRefComdats.empty())
 
  325    return error(ForwardRefComdats.begin()->second,
 
  326                 "use of undefined comdat '$" +
 
  327                     ForwardRefComdats.begin()->first + 
"'");
 
  341        if (!CB || !CB->isCallee(&U))
 
  342          return error(
Info.second, 
"intrinsic can only be used as callee");
 
  356              return error(
Info.second, 
"unknown intrinsic '" + Name + 
"'");
 
  357            return error(
Info.second, 
"invalid intrinsic signature");
 
  367      Info.first->eraseFromParent();
 
  368      ForwardRefVals.erase(Name);
 
  377    auto GetCommonFunctionType = [](
Value *
V) -> FunctionType * {
 
  378      FunctionType *FTy = 
nullptr;
 
  379      for (Use &U : 
V->uses()) {
 
  381        if (!CB || !CB->isCallee(&U) || (FTy && FTy != CB->getFunctionType()))
 
  383        FTy = CB->getFunctionType();
 
  391    Type *Ty = GetCommonFunctionType(
Info.first);
 
  399      GV = 
new GlobalVariable(*M, Ty,  
false,
 
  402    Info.first->replaceAllUsesWith(GV);
 
  403    Info.first->eraseFromParent();
 
  404    ForwardRefVals.erase(Name);
 
  407  if (!ForwardRefVals.empty())
 
  408    return error(ForwardRefVals.begin()->second.second,
 
  409                 "use of undefined value '@" + ForwardRefVals.begin()->first +
 
  412  if (!ForwardRefValIDs.empty())
 
  413    return error(ForwardRefValIDs.begin()->second.second,
 
  414                 "use of undefined value '@" +
 
  415                     Twine(ForwardRefValIDs.begin()->first) + 
"'");
 
  418    dropUnknownMetadataReferences();
 
  420  if (!ForwardRefMDNodes.empty())
 
  421    return error(ForwardRefMDNodes.begin()->second.second,
 
  422                 "use of undefined metadata '!" +
 
  423                     Twine(ForwardRefMDNodes.begin()->first) + 
"'");
 
  426  for (
auto &
N : NumberedMetadata) {
 
  427    if (
N.second && !
N.second->isResolved())
 
  428      N.second->resolveCycles();
 
  431  for (
auto *Inst : InstsWithTBAATag) {
 
  432    MDNode *MD = Inst->getMetadata(LLVMContext::MD_tbaa);
 
  435      assert(MD && 
"UpgradeInstWithTBAATag should have a TBAA tag");
 
  438      if (MD != UpgradedMD)
 
  439        Inst->setMetadata(LLVMContext::MD_tbaa, UpgradedMD);
 
  448  if (UpgradeDebugInfo)
 
  461  Slots->GlobalValues = std::move(NumberedVals);
 
  462  Slots->MetadataNodes = std::move(NumberedMetadata);
 
  463  for (
const auto &
I : NamedTypes)
 
  464    Slots->NamedTypes.insert(std::make_pair(
I.getKey(), 
I.second.first));
 
  465  for (
const auto &
I : NumberedTypes)
 
  466    Slots->Types.insert(std::make_pair(
I.first, 
I.second.first));
 
  472bool LLParser::validateEndOfIndex() {
 
  476  if (!ForwardRefValueInfos.empty())
 
  477    return error(ForwardRefValueInfos.begin()->second.front().second,
 
  478                 "use of undefined summary '^" +
 
  479                     Twine(ForwardRefValueInfos.begin()->first) + 
"'");
 
  481  if (!ForwardRefAliasees.empty())
 
  482    return error(ForwardRefAliasees.begin()->second.front().second,
 
  483                 "use of undefined summary '^" +
 
  484                     Twine(ForwardRefAliasees.begin()->first) + 
"'");
 
  486  if (!ForwardRefTypeIds.empty())
 
  487    return error(ForwardRefTypeIds.begin()->second.front().second,
 
  488                 "use of undefined type id summary '^" +
 
  489                     Twine(ForwardRefTypeIds.begin()->first) + 
"'");
 
  503  std::string TentativeDLStr = M->getDataLayoutStr();
 
  508    switch (Lex.getKind()) {
 
  510      if (parseTargetDefinition(TentativeDLStr, DLStrLoc))
 
  514      if (parseSourceFileName())
 
  523  if (
auto LayoutOverride =
 
  524          DataLayoutCallback(M->getTargetTriple().str(), TentativeDLStr)) {
 
  525    TentativeDLStr = *LayoutOverride;
 
  531  M->setDataLayout(MaybeDL.
get());
 
  535bool LLParser::parseTopLevelEntities() {
 
  539      switch (Lex.getKind()) {
 
  543        if (parseSummaryEntry())
 
  547        if (parseSourceFileName())
 
  557    switch (Lex.getKind()) {
 
  559      return tokError(
"expected top-level entity");
 
  570      if (parseModuleAsm())
 
  574      if (parseUnnamedType())
 
  578      if (parseNamedType())
 
  582      if (parseUnnamedGlobal())
 
  586      if (parseNamedGlobal())
 
  591      if (parseStandaloneMetadata())
 
  595      if (parseSummaryEntry())
 
  599      if (parseNamedMetadata())
 
  603      if (parseUnnamedAttrGrp())
 
  607      if (parseUseListOrder())
 
  611      if (parseUseListOrderBB())
 
  620bool LLParser::parseModuleAsm() {
 
  626      parseStringConstant(AsmStr))
 
  629  M->appendModuleInlineAsm(AsmStr);
 
  636bool LLParser::parseTargetDefinition(std::string &TentativeDLStr,
 
  642    return tokError(
"unknown target property");
 
  645    if (parseToken(
lltok::equal, 
"expected '=' after target triple") ||
 
  646        parseStringConstant(Str))
 
  648    M->setTargetTriple(Triple(std::move(Str)));
 
  652    if (parseToken(
lltok::equal, 
"expected '=' after target datalayout"))
 
  654    DLStrLoc = Lex.getLoc();
 
  655    if (parseStringConstant(TentativeDLStr))
 
  663bool LLParser::parseSourceFileName() {
 
  666  if (parseToken(
lltok::equal, 
"expected '=' after source_filename") ||
 
  667      parseStringConstant(SourceFileName))
 
  670    M->setSourceFileName(SourceFileName);
 
  676bool LLParser::parseUnnamedType() {
 
  677  LocTy TypeLoc = Lex.getLoc();
 
  678  unsigned TypeID = Lex.getUIntVal();
 
  681  if (parseToken(
lltok::equal, 
"expected '=' after name") ||
 
  686  if (parseStructDefinition(TypeLoc, 
"", NumberedTypes[
TypeID], Result))
 
  690    std::pair<Type*, LocTy> &
Entry = NumberedTypes[
TypeID];
 
  692      return error(TypeLoc, 
"non-struct types may not be recursive");
 
  694    Entry.second = SMLoc();
 
  702bool LLParser::parseNamedType() {
 
  703  std::string 
Name = Lex.getStrVal();
 
  704  LocTy NameLoc = Lex.getLoc();
 
  707  if (parseToken(
lltok::equal, 
"expected '=' after name") ||
 
  712  if (parseStructDefinition(NameLoc, Name, NamedTypes[Name], Result))
 
  716    std::pair<Type*, LocTy> &
Entry = NamedTypes[
Name];
 
  718      return error(NameLoc, 
"non-struct types may not be recursive");
 
  720    Entry.second = SMLoc();
 
  728bool LLParser::parseDeclare() {
 
  732  std::vector<std::pair<unsigned, MDNode *>> MDs;
 
  736    if (parseMetadataAttachment(MDK, 
N))
 
  738    MDs.push_back({MDK, 
N});
 
  742  unsigned FunctionNumber = -1;
 
  743  SmallVector<unsigned> UnnamedArgNums;
 
  744  if (parseFunctionHeader(
F, 
false, FunctionNumber, UnnamedArgNums))
 
  747    F->addMetadata(MD.first, *MD.second);
 
  753bool LLParser::parseDefine() {
 
  755  FileLoc FunctionStart(Lex.getTokLineColumnPos());
 
  759  unsigned FunctionNumber = -1;
 
  760  SmallVector<unsigned> UnnamedArgNums;
 
  762      parseFunctionHeader(
F, 
true, FunctionNumber, UnnamedArgNums) ||
 
  763      parseOptionalFunctionMetadata(*
F) ||
 
  764      parseFunctionBody(*
F, FunctionNumber, UnnamedArgNums);
 
  766    ParserContext->addFunctionLocation(
 
  767        F, FileLocRange(FunctionStart, Lex.getPrevTokEndLineColumnPos()));
 
  775bool LLParser::parseGlobalType(
bool &IsConstant) {
 
  782    return tokError(
"expected 'global' or 'constant'");
 
  788bool LLParser::parseOptionalUnnamedAddr(
 
  809bool LLParser::parseUnnamedGlobal() {
 
  812  LocTy NameLoc = Lex.getLoc();
 
  816    VarID = Lex.getUIntVal();
 
  817    if (checkValueID(NameLoc, 
"global", 
"@", NumberedVals.getNext(), 
VarID))
 
  821    if (parseToken(
lltok::equal, 
"expected '=' after name"))
 
  824    VarID = NumberedVals.getNext();
 
  828  unsigned Linkage, Visibility, DLLStorageClass;
 
  832  if (parseOptionalLinkage(
Linkage, HasLinkage, Visibility, DLLStorageClass,
 
  834      parseOptionalThreadLocal(TLM) || parseOptionalUnnamedAddr(UnnamedAddr))
 
  837  switch (Lex.getKind()) {
 
  839    return parseGlobal(Name, 
VarID, NameLoc, 
Linkage, HasLinkage, Visibility,
 
  840                       DLLStorageClass, DSOLocal, TLM, UnnamedAddr);
 
  843    return parseAliasOrIFunc(Name, 
VarID, NameLoc, 
Linkage, Visibility,
 
  844                             DLLStorageClass, DSOLocal, TLM, UnnamedAddr);
 
  853bool LLParser::parseNamedGlobal() {
 
  855  LocTy NameLoc = Lex.getLoc();
 
  856  std::string 
Name = Lex.getStrVal();
 
  860  unsigned Linkage, Visibility, DLLStorageClass;
 
  864  if (parseToken(
lltok::equal, 
"expected '=' in global variable") ||
 
  865      parseOptionalLinkage(
Linkage, HasLinkage, Visibility, DLLStorageClass,
 
  867      parseOptionalThreadLocal(TLM) || parseOptionalUnnamedAddr(UnnamedAddr))
 
  870  switch (Lex.getKind()) {
 
  872    return parseGlobal(Name, -1, NameLoc, 
Linkage, HasLinkage, Visibility,
 
  873                       DLLStorageClass, DSOLocal, TLM, UnnamedAddr);
 
  876    return parseAliasOrIFunc(Name, -1, NameLoc, 
Linkage, Visibility,
 
  877                             DLLStorageClass, DSOLocal, TLM, UnnamedAddr);
 
  881bool LLParser::parseComdat() {
 
  883  std::string 
Name = Lex.getStrVal();
 
  884  LocTy NameLoc = Lex.getLoc();
 
  891    return tokError(
"expected comdat type");
 
  894  switch (Lex.getKind()) {
 
  896    return tokError(
"unknown selection kind");
 
  918  if (
I != ComdatSymTab.
end() && !ForwardRefComdats.erase(Name))
 
  919    return error(NameLoc, 
"redefinition of comdat '$" + Name + 
"'");
 
  922  if (
I != ComdatSymTab.
end())
 
  925    C = M->getOrInsertComdat(Name);
 
  926  C->setSelectionKind(SK);
 
  933bool LLParser::parseMDString(
MDString *&Result) {
 
  935  if (parseStringConstant(Str))
 
  943bool LLParser::parseMDNodeID(
MDNode *&Result) {
 
  945  LocTy IDLoc = Lex.getLoc();
 
  947  if (parseUInt32(MID))
 
  951  auto [It, 
Inserted] = NumberedMetadata.try_emplace(MID);
 
  958  auto &FwdRef = ForwardRefMDNodes[MID];
 
  961  Result = FwdRef.first.get();
 
  962  It->second.reset(Result);
 
  968bool LLParser::parseNamedMetadata() {
 
  970  std::string 
Name = Lex.getStrVal();
 
  978  NamedMDNode *NMD = M->getOrInsertNamedMetadata(Name);
 
  986          Lex.getStrVal() == 
"DIExpression") {
 
  987        if (parseDIExpression(
N, 
false))
 
  992                 Lex.getStrVal() == 
"DIArgList") {
 
  993        return tokError(
"found DIArgList outside of function");
 
 1001  return parseToken(
lltok::rbrace, 
"expected end of metadata node");
 
 1006bool LLParser::parseStandaloneMetadata() {
 
 1009  unsigned MetadataID = 0;
 
 1012  if (parseUInt32(MetadataID) || parseToken(
lltok::equal, 
"expected '=' here"))
 
 1017    return tokError(
"unexpected type in metadata definition");
 
 1021    if (parseSpecializedMDNode(Init, IsDistinct))
 
 1024             parseMDTuple(Init, IsDistinct))
 
 1028  auto FI = ForwardRefMDNodes.find(MetadataID);
 
 1029  if (FI != ForwardRefMDNodes.end()) {
 
 1030    auto *ToReplace = FI->second.first.get();
 
 1034      for (
auto *Inst : TempDIAssignIDAttachments[ToReplace]) {
 
 1035        assert(!Inst->getMetadata(LLVMContext::MD_DIAssignID) &&
 
 1036               "Inst unexpectedly already has DIAssignID attachment");
 
 1037        Inst->setMetadata(LLVMContext::MD_DIAssignID, Init);
 
 1041    ToReplace->replaceAllUsesWith(Init);
 
 1042    ForwardRefMDNodes.erase(FI);
 
 1044    assert(NumberedMetadata[MetadataID] == Init && 
"Tracking VH didn't work");
 
 1046    auto [It, 
Inserted] = NumberedMetadata.try_emplace(MetadataID);
 
 1048      return tokError(
"Metadata id is already used");
 
 1049    It->second.reset(Init);
 
 1056bool LLParser::skipModuleSummaryEntry() {
 
 1066        "Expected 'gv', 'module', 'typeid', 'flags' or 'blockcount' at the " 
 1067        "start of summary entry");
 
 1069    return parseSummaryIndexFlags();
 
 1071    return parseBlockCount();
 
 1073  if (parseToken(
lltok::colon, 
"expected ':' at start of summary entry") ||
 
 1074      parseToken(
lltok::lparen, 
"expected '(' at start of summary entry"))
 
 1078  unsigned NumOpenParen = 1;
 
 1080    switch (Lex.getKind()) {
 
 1088      return tokError(
"found end of file while parsing summary entry");
 
 1094  } 
while (NumOpenParen > 0);
 
 1100bool LLParser::parseSummaryEntry() {
 
 1106  Lex.setIgnoreColonInIdentifiers(
true);
 
 1114    return skipModuleSummaryEntry();
 
 1116  bool result = 
false;
 
 1117  switch (Lex.getKind()) {
 
 1119    result = parseGVEntry(SummaryID);
 
 1122    result = parseModuleEntry(SummaryID);
 
 1125    result = parseTypeIdEntry(SummaryID);
 
 1128    result = parseTypeIdCompatibleVtableEntry(SummaryID);
 
 1131    result = parseSummaryIndexFlags();
 
 1134    result = parseBlockCount();
 
 1137    result = 
error(Lex.getLoc(), 
"unexpected summary kind");
 
 1140  Lex.setIgnoreColonInIdentifiers(
false);
 
 1174bool LLParser::parseAliasOrIFunc(
const std::string &Name, 
unsigned NameID,
 
 1175                                 LocTy NameLoc, 
unsigned L, 
unsigned Visibility,
 
 1176                                 unsigned DLLStorageClass, 
bool DSOLocal,
 
 1191    return error(NameLoc, 
"invalid linkage type for alias");
 
 1194    return error(NameLoc,
 
 1195                 "symbol with local linkage must have default visibility");
 
 1198    return error(NameLoc,
 
 1199                 "symbol with local linkage cannot have a DLL storage class");
 
 1202  LocTy ExplicitTypeLoc = Lex.getLoc();
 
 1203  if (parseType(Ty) ||
 
 1204      parseToken(
lltok::comma, 
"expected comma after alias or ifunc's type"))
 
 1208  LocTy AliaseeLoc = Lex.getLoc();
 
 1213    if (parseGlobalTypeAndValue(Aliasee))
 
 1218    if (parseValID(
ID, 
nullptr))
 
 1221      return error(AliaseeLoc, 
"invalid aliasee");
 
 1222    Aliasee = 
ID.ConstantVal;
 
 1228    return error(AliaseeLoc, 
"An alias or ifunc must have pointer type");
 
 1229  unsigned AddrSpace = PTy->getAddressSpace();
 
 1231  GlobalValue *GVal = 
nullptr;
 
 1235  if (!
Name.empty()) {
 
 1236    auto I = ForwardRefVals.find(Name);
 
 1237    if (
I != ForwardRefVals.end()) {
 
 1238      GVal = 
I->second.first;
 
 1239      ForwardRefVals.erase(Name);
 
 1240    } 
else if (M->getNamedValue(Name)) {
 
 1241      return error(NameLoc, 
"redefinition of global '@" + Name + 
"'");
 
 1244    auto I = ForwardRefValIDs.find(NameID);
 
 1245    if (
I != ForwardRefValIDs.end()) {
 
 1246      GVal = 
I->second.first;
 
 1247      ForwardRefValIDs.erase(
I);
 
 1252  std::unique_ptr<GlobalAlias> GA;
 
 1253  std::unique_ptr<GlobalIFunc> GI;
 
 1281      if (parseGlobalObjectMetadataAttachment(*GI))
 
 1284      return tokError(
"unknown alias or ifunc property!");
 
 1289    NumberedVals.add(NameID, GV);
 
 1296          "forward reference and definition of alias have different types");
 
 1306    M->insertAlias(GA.release());
 
 1308    M->insertIFunc(GI.release());
 
 1309  assert(GV->
getName() == Name && 
"Should not be a name conflict!");
 
 1318  case lltok::kw_sanitize_memtag:
 
 
 1332  switch (Lex.getKind()) {
 
 1334    Meta.NoAddress = 
true;
 
 1337    Meta.NoHWAddress = 
true;
 
 1339  case lltok::kw_sanitize_memtag:
 
 1343    Meta.IsDynInit = 
true;
 
 1346    return tokError(
"non-sanitizer token passed to LLParser::parseSanitizer()");
 
 1366bool LLParser::parseGlobal(
const std::string &Name, 
unsigned NameID,
 
 1367                           LocTy NameLoc, 
unsigned Linkage, 
bool HasLinkage,
 
 1368                           unsigned Visibility, 
unsigned DLLStorageClass,
 
 1372    return error(NameLoc,
 
 1373                 "symbol with local linkage must have default visibility");
 
 1376    return error(NameLoc,
 
 1377                 "symbol with local linkage cannot have a DLL storage class");
 
 1381  LocTy IsExternallyInitializedLoc;
 
 1385  if (parseOptionalAddrSpace(AddrSpace) ||
 
 1387                         IsExternallyInitialized,
 
 1388                         &IsExternallyInitializedLoc) ||
 
 1389      parseGlobalType(IsConstant) || parseType(Ty, TyLoc))
 
 1398    if (parseGlobalValue(Ty, Init))
 
 1403    return error(TyLoc, 
"invalid type for global variable");
 
 1405  GlobalValue *GVal = 
nullptr;
 
 1408  if (!
Name.empty()) {
 
 1409    auto I = ForwardRefVals.find(Name);
 
 1410    if (
I != ForwardRefVals.end()) {
 
 1411      GVal = 
I->second.first;
 
 1412      ForwardRefVals.erase(
I);
 
 1413    } 
else if (M->getNamedValue(Name)) {
 
 1414      return error(NameLoc, 
"redefinition of global '@" + Name + 
"'");
 
 1419    if (NameID == (
unsigned)-1)
 
 1420      NameID = NumberedVals.getNext();
 
 1422    auto I = ForwardRefValIDs.find(NameID);
 
 1423    if (
I != ForwardRefValIDs.end()) {
 
 1424      GVal = 
I->second.first;
 
 1425      ForwardRefValIDs.erase(
I);
 
 1429  GlobalVariable *GV = 
new GlobalVariable(
 
 1434    NumberedVals.add(NameID, GV);
 
 1452          "forward reference and definition of global have different types");
 
 1472    } 
else if (Lex.getKind() == lltok::kw_align) {
 
 1473      MaybeAlign Alignment;
 
 1474      if (parseOptionalAlignment(Alignment))
 
 1480      if (parseOptionalCodeModel(CodeModel))
 
 1484      if (parseGlobalObjectMetadataAttachment(*GV))
 
 1487      if (parseSanitizer(GV))
 
 1491      if (parseOptionalComdat(Name, 
C))
 
 1496        return tokError(
"unknown global variable property!");
 
 1500  AttrBuilder 
Attrs(M->getContext());
 
 1502  std::vector<unsigned> FwdRefAttrGrps;
 
 1503  if (parseFnAttributeValuePairs(Attrs, FwdRefAttrGrps, 
false, BuiltinLoc))
 
 1505  if (
Attrs.hasAttributes() || !FwdRefAttrGrps.empty()) {
 
 1507    ForwardRefAttrGroups[GV] = FwdRefAttrGrps;
 
 1515bool LLParser::parseUnnamedAttrGrp() {
 
 1517  LocTy AttrGrpLoc = Lex.getLoc();
 
 1521    return tokError(
"expected attribute group id");
 
 1523  unsigned VarID = Lex.getUIntVal();
 
 1524  std::vector<unsigned> unused;
 
 1532  auto R = NumberedAttrBuilders.find(
VarID);
 
 1533  if (R == NumberedAttrBuilders.end())
 
 1534    R = NumberedAttrBuilders.emplace(
VarID, AttrBuilder(M->getContext())).first;
 
 1536  if (parseFnAttributeValuePairs(
R->second, unused, 
true, BuiltinLoc) ||
 
 1537      parseToken(
lltok::rbrace, 
"expected end of attribute group"))
 
 1540  if (!
R->second.hasAttributes())
 
 1541    return error(AttrGrpLoc, 
"attribute group has no attributes");
 
 1548#define GET_ATTR_NAMES 
 1549#define ATTRIBUTE_ENUM(ENUM_NAME, DISPLAY_NAME) \ 
 1550  case lltok::kw_##DISPLAY_NAME: \ 
 1551    return Attribute::ENUM_NAME; 
 1552#include "llvm/IR/Attributes.inc" 
 
 1561    return parseRequiredTypeAttr(
B, Lex.getKind(), Attr);
 
 1564  case Attribute::Alignment: {
 
 1565    MaybeAlign Alignment;
 
 1573      if (parseOptionalAlignment(Alignment, 
true))
 
 1576    B.addAlignmentAttr(Alignment);
 
 1579  case Attribute::StackAlignment: {
 
 1584          parseUInt32(Alignment))
 
 1587      if (parseOptionalStackAlignment(Alignment))
 
 1590    B.addStackAlignmentAttr(Alignment);
 
 1593  case Attribute::AllocSize: {
 
 1594    unsigned ElemSizeArg;
 
 1595    std::optional<unsigned> NumElemsArg;
 
 1596    if (parseAllocSizeArguments(ElemSizeArg, NumElemsArg))
 
 1598    B.addAllocSizeAttr(ElemSizeArg, NumElemsArg);
 
 1601  case Attribute::VScaleRange: {
 
 1602    unsigned MinValue, MaxValue;
 
 1603    if (parseVScaleRangeArguments(MinValue, MaxValue))
 
 1605    B.addVScaleRangeAttr(MinValue,
 
 1606                         MaxValue > 0 ? MaxValue : std::optional<unsigned>());
 
 1609  case Attribute::Dereferenceable: {
 
 1611    if (parseOptionalDerefAttrBytes(lltok::kw_dereferenceable, Bytes))
 
 1613    B.addDereferenceableAttr(Bytes);
 
 1616  case Attribute::DereferenceableOrNull: {
 
 1618    if (parseOptionalDerefAttrBytes(lltok::kw_dereferenceable_or_null, Bytes))
 
 1620    B.addDereferenceableOrNullAttr(Bytes);
 
 1623  case Attribute::UWTable: {
 
 1625    if (parseOptionalUWTableKind(Kind))
 
 1627    B.addUWTableAttr(Kind);
 
 1630  case Attribute::AllocKind: {
 
 1632    if (parseAllocKind(Kind))
 
 1634    B.addAllocKindAttr(Kind);
 
 1637  case Attribute::Memory: {
 
 1638    std::optional<MemoryEffects> ME = parseMemoryAttr();
 
 1641    B.addMemoryAttr(*ME);
 
 1644  case Attribute::NoFPClass: {
 
 1647      B.addNoFPClassAttr(NoFPClass);
 
 1653  case Attribute::Range:
 
 1654    return parseRangeAttr(
B);
 
 1655  case Attribute::Initializes:
 
 1656    return parseInitializesAttr(
B);
 
 1657  case Attribute::Captures:
 
 1658    return parseCapturesAttr(
B);
 
 1660    B.addAttribute(Attr);
 
 1668  case lltok::kw_readnone:
 
 1671  case lltok::kw_readonly:
 
 1674  case lltok::kw_writeonly:
 
 
 1693bool LLParser::parseFnAttributeValuePairs(AttrBuilder &
B,
 
 1694                                          std::vector<unsigned> &FwdRefAttrGrps,
 
 1695                                          bool InAttrGrp, LocTy &BuiltinLoc) {
 
 1696  bool HaveError = 
false;
 
 1707      if (parseStringAttribute(
B))
 
 1719            "cannot have an attribute group reference in an attribute group");
 
 1722        FwdRefAttrGrps.push_back(Lex.getUIntVal());
 
 1728    SMLoc Loc = Lex.getLoc();
 
 1729    if (Token == lltok::kw_builtin)
 
 1741      return error(Lex.getLoc(), 
"unterminated attribute group");
 
 1744    if (parseEnumAttribute(Attr, 
B, InAttrGrp))
 
 1751      HaveError |= 
error(Loc, 
"this attribute does not apply to functions");
 
 1755    B.addMemoryAttr(ME);
 
 1769                            PTy->getAddressSpace());
 
 
 1778    error(Loc, 
"'" + Name + 
"' is not a basic block");
 
 1780    error(Loc, 
"'" + Name + 
"' defined with type '" +
 
 1793    error(Loc, 
"global variable reference must have pointer type");
 
 1804    auto I = ForwardRefVals.find(Name);
 
 1805    if (
I != ForwardRefVals.end())
 
 1806      Val = 
I->second.first;
 
 1812        checkValidVariableType(Loc, 
"@" + Name, Ty, Val));
 
 1816  ForwardRefVals[
Name] = std::make_pair(FwdVal, Loc);
 
 1823    error(Loc, 
"global variable reference must have pointer type");
 
 1827  GlobalValue *Val = NumberedVals.get(
ID);
 
 1832    auto I = ForwardRefValIDs.find(
ID);
 
 1833    if (
I != ForwardRefValIDs.end())
 
 1834      Val = 
I->second.first;
 
 1840        checkValidVariableType(Loc, 
"@" + Twine(
ID), Ty, Val));
 
 1844  ForwardRefValIDs[
ID] = std::make_pair(FwdVal, Loc);
 
 1852Comdat *LLParser::getComdat(
const std::string &Name, LocTy 
Loc) {
 
 1856  if (
I != ComdatSymTab.
end())
 
 1860  Comdat *
C = M->getOrInsertComdat(Name);
 
 1861  ForwardRefComdats[
Name] = Loc;
 
 1871bool LLParser::parseToken(
lltok::Kind T, 
const char *ErrMsg) {
 
 1872  if (Lex.getKind() != 
T)
 
 1873    return tokError(ErrMsg);
 
 1880bool LLParser::parseStringConstant(std::string &Result) {
 
 1882    return tokError(
"expected string constant");
 
 1883  Result = Lex.getStrVal();
 
 1890bool LLParser::parseUInt32(uint32_t &Val) {
 
 1891  if (Lex.getKind() != 
lltok::APSInt || Lex.getAPSIntVal().isSigned())
 
 1892    return tokError(
"expected integer");
 
 1893  uint64_t Val64 = Lex.getAPSIntVal().getLimitedValue(0xFFFFFFFFULL+1);
 
 1894  if (Val64 != 
unsigned(Val64))
 
 1895    return tokError(
"expected 32-bit integer (too large)");
 
 1903bool LLParser::parseUInt64(uint64_t &Val) {
 
 1904  if (Lex.getKind() != 
lltok::APSInt || Lex.getAPSIntVal().isSigned())
 
 1905    return tokError(
"expected integer");
 
 1906  Val = Lex.getAPSIntVal().getLimitedValue();
 
 1916  switch (Lex.getKind()) {
 
 1918      return tokError(
"expected localdynamic, initialexec or localexec");
 
 1946    return parseTLSModel(TLM) ||
 
 1947           parseToken(
lltok::rparen, 
"expected ')' after thread local model");
 
 1955bool LLParser::parseOptionalAddrSpace(
unsigned &AddrSpace, 
unsigned DefaultAS) {
 
 1956  AddrSpace = DefaultAS;
 
 1960  auto ParseAddrspaceValue = [&](
unsigned &AddrSpace) -> 
bool {
 
 1962      auto AddrSpaceStr = Lex.getStrVal();
 
 1963      if (AddrSpaceStr == 
"A") {
 
 1964        AddrSpace = M->getDataLayout().getAllocaAddrSpace();
 
 1965      } 
else if (AddrSpaceStr == 
"G") {
 
 1966        AddrSpace = M->getDataLayout().getDefaultGlobalsAddressSpace();
 
 1967      } 
else if (AddrSpaceStr == 
"P") {
 
 1968        AddrSpace = M->getDataLayout().getProgramAddressSpace();
 
 1970        return tokError(
"invalid symbolic addrspace '" + AddrSpaceStr + 
"'");
 
 1976      return tokError(
"expected integer or string constant");
 
 1977    SMLoc Loc = Lex.getLoc();
 
 1978    if (parseUInt32(AddrSpace))
 
 1981      return error(Loc, 
"invalid address space, must be a 24-bit integer");
 
 1985  return parseToken(
lltok::lparen, 
"expected '(' in address space") ||
 
 1986         ParseAddrspaceValue(AddrSpace) ||
 
 1993bool LLParser::parseStringAttribute(AttrBuilder &
B) {
 
 1994  std::string Attr = Lex.getStrVal();
 
 1997  if (EatIfPresent(
lltok::equal) && parseStringConstant(Val))
 
 1999  B.addAttribute(Attr, Val);
 
 2004bool LLParser::parseOptionalParamOrReturnAttrs(AttrBuilder &
B, 
bool IsParam) {
 
 2005  bool HaveError = 
false;
 
 2012      if (parseStringAttribute(
B))
 
 2023    SMLoc Loc = Lex.getLoc();
 
 2028    if (parseEnumAttribute(Attr, 
B,  
false))
 
 2032      HaveError |= 
error(Loc, 
"this attribute does not apply to parameters");
 
 2034      HaveError |= 
error(Loc, 
"this attribute does not apply to return values");
 
 2082bool LLParser::parseOptionalLinkage(
unsigned &Res, 
bool &HasLinkage,
 
 2083                                    unsigned &Visibility,
 
 2084                                    unsigned &DLLStorageClass, 
bool &DSOLocal) {
 
 2088  parseOptionalDSOLocal(DSOLocal);
 
 2089  parseOptionalVisibility(Visibility);
 
 2090  parseOptionalDLLStorageClass(DLLStorageClass);
 
 2093    return error(Lex.getLoc(), 
"dso_location and DLL-StorageClass mismatch");
 
 2099void LLParser::parseOptionalDSOLocal(
bool &DSOLocal) {
 
 2100  switch (Lex.getKind()) {
 
 2121void LLParser::parseOptionalVisibility(
unsigned &Res) {
 
 2122  switch (Lex.getKind()) {
 
 2139bool LLParser::parseOptionalImportType(
lltok::Kind Kind,
 
 2143    return tokError(
"unknown import kind. Expect definition or declaration.");
 
 2158void LLParser::parseOptionalDLLStorageClass(
unsigned &Res) {
 
 2159  switch (Lex.getKind()) {
 
 2229bool LLParser::parseOptionalCallingConv(
unsigned &CC) {
 
 2230  switch (Lex.getKind()) {
 
 2317      return tokError(
"unknown RISC-V ABI VLEN");
 
 2318#define CC_VLS_CASE(ABIVlen)                                                   \ 
 2320    CC = CallingConv::RISCV_VLSCall_##ABIVlen;                                 \ 
 2348      return parseUInt32(CC);
 
 2358bool LLParser::parseMetadataAttachment(
unsigned &Kind, 
MDNode *&MD) {
 
 2361  std::string 
Name = Lex.getStrVal();
 
 2362  Kind = M->getMDKindID(Name);
 
 2365  return parseMDNode(MD);
 
 2370bool LLParser::parseInstructionMetadata(
Instruction &Inst) {
 
 2373      return tokError(
"expected metadata after comma");
 
 2377    if (parseMetadataAttachment(MDK, 
N))
 
 2380    if (MDK == LLVMContext::MD_DIAssignID)
 
 2381      TempDIAssignIDAttachments[
N].push_back(&Inst);
 
 2385    if (MDK == LLVMContext::MD_tbaa)
 
 2386      InstsWithTBAATag.push_back(&Inst);
 
 2395bool LLParser::parseGlobalObjectMetadataAttachment(
GlobalObject &GO) {
 
 2398  if (parseMetadataAttachment(MDK, 
N))
 
 2407bool LLParser::parseOptionalFunctionMetadata(
Function &
F) {
 
 2409    if (parseGlobalObjectMetadataAttachment(
F))
 
 2417bool LLParser::parseOptionalAlignment(
MaybeAlign &Alignment, 
bool AllowParens) {
 
 2418  Alignment = std::nullopt;
 
 2419  if (!EatIfPresent(lltok::kw_align))
 
 2421  LocTy AlignLoc = Lex.getLoc();
 
 2424  LocTy ParenLoc = Lex.getLoc();
 
 2425  bool HaveParens = 
false;
 
 2431  if (parseUInt64(
Value))
 
 2435    return error(ParenLoc, 
"expected ')'");
 
 2438    return error(AlignLoc, 
"alignment is not a power of two");
 
 2440    return error(AlignLoc, 
"huge alignments are not supported yet");
 
 2450  auto StrVal = Lex.getStrVal();
 
 2451  auto ErrMsg = 
"expected global code model string";
 
 2452  if (StrVal == 
"tiny")
 
 2454  else if (StrVal == 
"small")
 
 2456  else if (StrVal == 
"kernel")
 
 2458  else if (StrVal == 
"medium")
 
 2460  else if (StrVal == 
"large")
 
 2463    return tokError(ErrMsg);
 
 2474bool LLParser::parseOptionalDerefAttrBytes(
lltok::Kind AttrKind,
 
 2476  assert((AttrKind == lltok::kw_dereferenceable ||
 
 2477          AttrKind == lltok::kw_dereferenceable_or_null) &&
 
 2481  if (!EatIfPresent(AttrKind))
 
 2483  LocTy ParenLoc = Lex.getLoc();
 
 2485    return error(ParenLoc, 
"expected '('");
 
 2486  LocTy DerefLoc = Lex.getLoc();
 
 2487  if (parseUInt64(Bytes))
 
 2489  ParenLoc = Lex.getLoc();
 
 2491    return error(ParenLoc, 
"expected ')'");
 
 2493    return error(DerefLoc, 
"dereferenceable bytes must be non-zero");
 
 2497bool LLParser::parseOptionalUWTableKind(
UWTableKind &Kind) {
 
 2502  LocTy KindLoc = Lex.getLoc();
 
 2508    return error(KindLoc, 
"expected unwind table kind");
 
 2515  LocTy ParenLoc = Lex.getLoc();
 
 2517    return error(ParenLoc, 
"expected '('");
 
 2518  LocTy KindLoc = Lex.getLoc();
 
 2520  if (parseStringConstant(Arg))
 
 2521    return error(KindLoc, 
"expected allockind value");
 
 2525    } 
else if (
A == 
"realloc") {
 
 2527    } 
else if (
A == 
"free") {
 
 2529    } 
else if (
A == 
"uninitialized") {
 
 2531    } 
else if (
A == 
"zeroed") {
 
 2533    } 
else if (
A == 
"aligned") {
 
 2536      return error(KindLoc, Twine(
"unknown allockind ") + 
A);
 
 2539  ParenLoc = Lex.getLoc();
 
 2541    return error(ParenLoc, 
"expected ')'");
 
 2543    return error(KindLoc, 
"expected allockind value");
 
 2556    return std::nullopt;
 
 
 2571    return std::nullopt;
 
 
 2575std::optional<MemoryEffects> LLParser::parseMemoryAttr() {
 
 2580  Lex.setIgnoreColonInIdentifiers(
true);
 
 2585    tokError(
"expected '('");
 
 2586    return std::nullopt;
 
 2589  bool SeenLoc = 
false;
 
 2591    std::optional<IRMemLocation> Loc = 
keywordToLoc(Lex.getKind());
 
 2595        tokError(
"expected ':' after location");
 
 2596        return std::nullopt;
 
 2603        tokError(
"expected memory location (argmem, inaccessiblemem, errnomem) " 
 2604                 "or access kind (none, read, write, readwrite)");
 
 2606        tokError(
"expected access kind (none, read, write, readwrite)");
 
 2607      return std::nullopt;
 
 2616        tokError(
"default access kind must be specified first");
 
 2617        return std::nullopt;
 
 2626  tokError(
"unterminated memory attribute");
 
 2627  return std::nullopt;
 
 2669unsigned LLParser::parseNoFPClassAttr() {
 
 2674    tokError(
"expected '('");
 
 2681    if (TestMask != 0) {
 
 2685               !parseUInt64(
Value)) {
 
 2687        error(Lex.getLoc(), 
"invalid mask value for 'nofpclass'");
 
 2692        error(Lex.getLoc(), 
"expected ')'");
 
 2698      error(Lex.getLoc(), 
"expected nofpclass test mask");
 
 2716bool LLParser::parseOptionalCommaAlign(
MaybeAlign &Alignment,
 
 2717                                       bool &AteExtraComma) {
 
 2718  AteExtraComma = 
false;
 
 2722      AteExtraComma = 
true;
 
 2726    if (Lex.getKind() != lltok::kw_align)
 
 2727      return error(Lex.getLoc(), 
"expected metadata or 'align'");
 
 2729    if (parseOptionalAlignment(Alignment))
 
 2742bool LLParser::parseOptionalCommaAddrSpace(
unsigned &AddrSpace, LocTy &
Loc,
 
 2743                                           bool &AteExtraComma) {
 
 2744  AteExtraComma = 
false;
 
 2748      AteExtraComma = 
true;
 
 2754      return error(Lex.getLoc(), 
"expected metadata or 'addrspace'");
 
 2756    if (parseOptionalAddrSpace(AddrSpace))
 
 2763bool LLParser::parseAllocSizeArguments(
unsigned &BaseSizeArg,
 
 2764                                       std::optional<unsigned> &HowManyArg) {
 
 2767  auto StartParen = Lex.getLoc();
 
 2769    return error(StartParen, 
"expected '('");
 
 2771  if (parseUInt32(BaseSizeArg))
 
 2775    auto HowManyAt = Lex.getLoc();
 
 2777    if (parseUInt32(HowMany))
 
 2779    if (HowMany == BaseSizeArg)
 
 2780      return error(HowManyAt,
 
 2781                   "'allocsize' indices can't refer to the same parameter");
 
 2782    HowManyArg = HowMany;
 
 2784    HowManyArg = std::nullopt;
 
 2786  auto EndParen = Lex.getLoc();
 
 2788    return error(EndParen, 
"expected ')'");
 
 2792bool LLParser::parseVScaleRangeArguments(
unsigned &MinValue,
 
 2793                                         unsigned &MaxValue) {
 
 2796  auto StartParen = Lex.getLoc();
 
 2798    return error(StartParen, 
"expected '('");
 
 2800  if (parseUInt32(MinValue))
 
 2804    if (parseUInt32(MaxValue))
 
 2807    MaxValue = MinValue;
 
 2809  auto EndParen = Lex.getLoc();
 
 2811    return error(EndParen, 
"expected ')'");
 
 2820bool LLParser::parseScopeAndOrdering(
bool IsAtomic, 
SyncScope::ID &SSID,
 
 2825  return parseScope(SSID) || parseOrdering(Ordering);
 
 2835    auto StartParenAt = Lex.getLoc();
 
 2837      return error(StartParenAt, 
"Expected '(' in syncscope");
 
 2840    auto SSNAt = Lex.getLoc();
 
 2841    if (parseStringConstant(SSN))
 
 2842      return error(SSNAt, 
"Expected synchronization scope name");
 
 2844    auto EndParenAt = Lex.getLoc();
 
 2846      return error(EndParenAt, 
"Expected ')' in syncscope");
 
 2848    SSID = Context.getOrInsertSyncScopeID(SSN);
 
 2859  switch (Lex.getKind()) {
 
 2861    return tokError(
"Expected ordering on atomic instruction");
 
 2880bool LLParser::parseOptionalStackAlignment(
unsigned &Alignment) {
 
 2882  if (!EatIfPresent(lltok::kw_alignstack))
 
 2884  LocTy ParenLoc = Lex.getLoc();
 
 2886    return error(ParenLoc, 
"expected '('");
 
 2887  LocTy AlignLoc = Lex.getLoc();
 
 2888  if (parseUInt32(Alignment))
 
 2890  ParenLoc = Lex.getLoc();
 
 2892    return error(ParenLoc, 
"expected ')'");
 
 2894    return error(AlignLoc, 
"stack alignment is not a power of two");
 
 2908                              bool &AteExtraComma) {
 
 2909  AteExtraComma = 
false;
 
 2912    return tokError(
"expected ',' as start of index list");
 
 2916      if (Indices.
empty())
 
 2917        return tokError(
"expected index");
 
 2918      AteExtraComma = 
true;
 
 2922    if (parseUInt32(Idx))
 
 2935bool LLParser::parseType(
Type *&Result, 
const Twine &Msg, 
bool AllowVoid) {
 
 2936  SMLoc TypeLoc = Lex.getLoc();
 
 2937  switch (Lex.getKind()) {
 
 2939    return tokError(Msg);
 
 2948    if (
Result->isPointerTy()) {
 
 2950      if (parseOptionalAddrSpace(AddrSpace))
 
 2956        return tokError(
"ptr* is invalid - use ptr instead");
 
 2967    if (parseTargetExtType(Result))
 
 2973    if (parseAnonStructType(Result, 
false))
 
 2979    if (parseArrayVectorType(Result, 
false))
 
 2986      if (parseAnonStructType(Result, 
true) ||
 
 2987          parseToken(
lltok::greater, 
"expected '>' at end of packed struct"))
 
 2989    } 
else if (parseArrayVectorType(Result, 
true))
 
 2994    std::pair<Type*, LocTy> &
Entry = NamedTypes[Lex.getStrVal()];
 
 3000      Entry.second = Lex.getLoc();
 
 3009    std::pair<Type*, LocTy> &
Entry = NumberedTypes[Lex.getUIntVal()];
 
 3015      Entry.second = Lex.getLoc();
 
 3025    switch (Lex.getKind()) {
 
 3028      if (!AllowVoid && 
Result->isVoidTy())
 
 3029        return error(TypeLoc, 
"void type only allowed for function results");
 
 3035        return tokError(
"basic block pointers are invalid");
 
 3037        return tokError(
"pointers to void are invalid - use i8* instead");
 
 3039        return tokError(
"pointer to this type is invalid");
 
 3047        return tokError(
"basic block pointers are invalid");
 
 3049        return tokError(
"pointers to void are invalid; use i8* instead");
 
 3051        return tokError(
"pointer to this type is invalid");
 
 3053      if (parseOptionalAddrSpace(AddrSpace) ||
 
 3054          parseToken(
lltok::star, 
"expected '*' in address space"))
 
 3063      if (parseFunctionType(Result))
 
 3076                                  PerFunctionState &PFS, 
bool IsMustTailCall,
 
 3077                                  bool InVarArgsFunc) {
 
 3083    if (!ArgList.
empty() &&
 
 3084        parseToken(
lltok::comma, 
"expected ',' in argument list"))
 
 3089      const char *Msg = 
"unexpected ellipsis in argument list for ";
 
 3090      if (!IsMustTailCall)
 
 3091        return tokError(Twine(Msg) + 
"non-musttail call");
 
 3093        return tokError(Twine(Msg) + 
"musttail call in non-varargs function");
 
 3095      return parseToken(
lltok::rparen, 
"expected ')' at end of argument list");
 
 3100    Type *ArgTy = 
nullptr;
 
 3102    if (parseType(ArgTy, ArgLoc))
 
 3105      return error(ArgLoc, 
"invalid type for function argument");
 
 3107    AttrBuilder ArgAttrs(M->getContext());
 
 3110      if (parseMetadataAsValue(V, PFS))
 
 3114      if (parseOptionalParamAttrs(ArgAttrs) || parseValue(ArgTy, V, PFS))
 
 3121  if (IsMustTailCall && InVarArgsFunc)
 
 3122    return tokError(
"expected '...' at end of argument list for musttail call " 
 3123                    "in varargs function");
 
 3131bool LLParser::parseRequiredTypeAttr(AttrBuilder &
B, 
lltok::Kind AttrToken,
 
 3134  if (!EatIfPresent(AttrToken))
 
 3137    return error(Lex.getLoc(), 
"expected '('");
 
 3141    return error(Lex.getLoc(), 
"expected ')'");
 
 3143  B.addTypeAttr(AttrKind, Ty);
 
 3149bool LLParser::parseRangeAttr(AttrBuilder &
B) {
 
 3157  auto ParseAPSInt = [&](
unsigned BitWidth, APInt &Val) {
 
 3159      return tokError(
"expected integer");
 
 3160    if (Lex.getAPSIntVal().getBitWidth() > 
BitWidth)
 
 3162          "integer is too large for the bit width of specified type");
 
 3163    Val = Lex.getAPSIntVal().extend(
BitWidth);
 
 3168  if (parseToken(
lltok::lparen, 
"expected '('") || parseType(Ty, TyLoc))
 
 3171    return error(TyLoc, 
"the range must have integer type!");
 
 3179    return tokError(
"the range represent the empty set but limits aren't 0!");
 
 3190bool LLParser::parseInitializesAttr(AttrBuilder &
B) {
 
 3193  auto ParseAPSInt = [&](APInt &Val) {
 
 3195      return tokError(
"expected integer");
 
 3196    Val = Lex.getAPSIntVal().extend(64);
 
 3216      return tokError(
"the range should not represent the full or empty set!");
 
 3228  if (!CRLOrNull.has_value())
 
 3229    return tokError(
"Invalid (unordered or overlapping) range list");
 
 3230  B.addInitializesAttr(*CRLOrNull);
 
 3234bool LLParser::parseCapturesAttr(AttrBuilder &
B) {
 
 3236  std::optional<CaptureComponents> 
Ret;
 
 3240  Lex.setIgnoreColonInIdentifiers(
true);
 
 3248  bool SeenComponent = 
false;
 
 3254        return tokError(
"duplicate 'ret' location");
 
 3257      SeenComponent = 
false;
 
 3262        return tokError(
"cannot use 'none' with other component");
 
 3266        return tokError(
"cannot use 'none' with other component");
 
 3277        return tokError(
"expected one of 'none', 'address', 'address_is_null', " 
 3278                        "'provenance' or 'read_provenance'");
 
 3281    SeenComponent = 
true;
 
 3302bool LLParser::parseOptionalOperandBundles(
 
 3304  LocTy BeginLoc = Lex.getLoc();
 
 3310    if (!BundleList.
empty() &&
 
 3311        parseToken(
lltok::comma, 
"expected ',' in input list"))
 
 3315    if (parseStringConstant(
Tag))
 
 3318    if (parseToken(
lltok::lparen, 
"expected '(' in operand bundle"))
 
 3321    std::vector<Value *> Inputs;
 
 3324      if (!Inputs.empty() &&
 
 3325          parseToken(
lltok::comma, 
"expected ',' in input list"))
 
 3329      Value *Input = 
nullptr;
 
 3333        if (parseMetadataAsValue(Input, PFS))
 
 3335      } 
else if (parseValue(Ty, Input, PFS)) {
 
 3338      Inputs.push_back(Input);
 
 3346  if (BundleList.
empty())
 
 3347    return error(BeginLoc, 
"operand bundle set must not be empty");
 
 3354                            unsigned NextID, 
unsigned ID) {
 
 3356    return error(Loc, Kind + 
" expected to be numbered '" + Prefix +
 
 3357                          Twine(NextID) + 
"' or greater");
 
 3374  unsigned CurValID = 0;
 
 3388      LocTy TypeLoc = Lex.getLoc();
 
 3389      Type *ArgTy = 
nullptr;
 
 3390      AttrBuilder 
Attrs(M->getContext());
 
 3391      if (parseType(ArgTy) || parseOptionalParamAttrs(Attrs))
 
 3395        return error(TypeLoc, 
"argument can not have void type");
 
 3399        Name = Lex.getStrVal();
 
 3404          ArgID = Lex.getUIntVal();
 
 3405          if (checkValueID(TypeLoc, 
"argument", 
"%", CurValID, ArgID))
 
 3412        CurValID = ArgID + 1;
 
 3416        return error(TypeLoc, 
"invalid type for function argument");
 
 3424  return parseToken(
lltok::rparen, 
"expected ')' at end of argument list");
 
 3429bool LLParser::parseFunctionType(
Type *&Result) {
 
 3433    return tokError(
"invalid function return type");
 
 3437  SmallVector<unsigned> UnnamedArgNums;
 
 3438  if (parseArgumentList(ArgList, UnnamedArgNums, IsVarArg))
 
 3442  for (
const ArgInfo &Arg : ArgList) {
 
 3443    if (!Arg.Name.empty())
 
 3444      return error(Arg.Loc, 
"argument name invalid in function type");
 
 3445    if (Arg.Attrs.hasAttributes())
 
 3446      return error(Arg.Loc, 
"argument attributes invalid in function type");
 
 3450  for (
const ArgInfo &Arg : ArgList)
 
 3459bool LLParser::parseAnonStructType(
Type *&Result, 
bool Packed) {
 
 3461  if (parseStructBody(Elts))
 
 3469bool LLParser::parseStructDefinition(
SMLoc TypeLoc, 
StringRef Name,
 
 3470                                     std::pair<Type *, LocTy> &Entry,
 
 3474    return error(TypeLoc, 
"redefinition of type");
 
 3480    Entry.second = SMLoc();
 
 3485    ResultTy = 
Entry.first;
 
 3497      return error(TypeLoc, 
"forward references to non-struct type");
 
 3501      return parseArrayVectorType(ResultTy, 
true);
 
 3502    return parseType(ResultTy);
 
 3506  Entry.second = SMLoc();
 
 3515  if (parseStructBody(Body) ||
 
 3516      (isPacked && parseToken(
lltok::greater, 
"expected '>' in packed struct")))
 
 3520    return tokError(
toString(std::move(
E)));
 
 3540  LocTy EltTyLoc = Lex.getLoc();
 
 3547    return error(EltTyLoc, 
"invalid element type for struct");
 
 3550    EltTyLoc = Lex.getLoc();
 
 3555      return error(EltTyLoc, 
"invalid element type for struct");
 
 3560  return parseToken(
lltok::rbrace, 
"expected '}' at end of struct");
 
 3569bool LLParser::parseArrayVectorType(
Type *&Result, 
bool IsVector) {
 
 3570  bool Scalable = 
false;
 
 3574    if (parseToken(
lltok::kw_x, 
"expected 'x' after vscale"))
 
 3580  if (Lex.getKind() != 
lltok::APSInt || Lex.getAPSIntVal().isSigned() ||
 
 3581      Lex.getAPSIntVal().getBitWidth() > 64)
 
 3582    return tokError(
"expected number in address space");
 
 3584  LocTy SizeLoc = Lex.getLoc();
 
 3585  uint64_t 
Size = Lex.getAPSIntVal().getZExtValue();
 
 3588  if (parseToken(
lltok::kw_x, 
"expected 'x' after element count"))
 
 3591  LocTy TypeLoc = Lex.getLoc();
 
 3592  Type *EltTy = 
nullptr;
 
 3593  if (parseType(EltTy))
 
 3597                 "expected end of sequential type"))
 
 3602      return error(SizeLoc, 
"zero element vector is illegal");
 
 3604      return error(SizeLoc, 
"size too large for vector");
 
 3606      return error(TypeLoc, 
"invalid vector element type");
 
 3610      return error(TypeLoc, 
"invalid array element type");
 
 3627bool LLParser::parseTargetExtType(
Type *&Result) {
 
 3632  if (parseToken(
lltok::lparen, 
"expected '(' in target extension type") ||
 
 3633      parseStringConstant(TypeName))
 
 3640  SmallVector<unsigned> IntParams;
 
 3641  bool SeenInt = 
false;
 
 3648      if (parseUInt32(IntVal))
 
 3651    } 
else if (SeenInt) {
 
 3654      return tokError(
"expected uint32 param");
 
 3657      if (parseType(TypeParam, 
true))
 
 3663  if (parseToken(
lltok::rparen, 
"expected ')' in target extension type"))
 
 3668  if (
auto E = TTy.takeError())
 
 3669    return tokError(
toString(std::move(
E)));
 
 3682  : 
P(
p), 
F(
f), FunctionNumber(functionNumber) {
 
 3685  auto It = UnnamedArgNums.
begin();
 
 3688      unsigned ArgNum = *It++;
 
 3689      NumberedVals.add(ArgNum, &A);
 
 3694LLParser::PerFunctionState::~PerFunctionState() {
 
 3697  for (
const auto &P : ForwardRefVals) {
 
 3700    P.second.first->replaceAllUsesWith(
 
 3702    P.second.first->deleteValue();
 
 3705  for (
const auto &P : ForwardRefValIDs) {
 
 3708    P.second.first->replaceAllUsesWith(
 
 3710    P.second.first->deleteValue();
 
 3714bool LLParser::PerFunctionState::finishFunction() {
 
 3715  if (!ForwardRefVals.empty())
 
 3716    return P.error(ForwardRefVals.begin()->second.second,
 
 3717                   "use of undefined value '%" + ForwardRefVals.begin()->first +
 
 3719  if (!ForwardRefValIDs.empty())
 
 3720    return P.error(ForwardRefValIDs.begin()->second.second,
 
 3721                   "use of undefined value '%" +
 
 3722                       Twine(ForwardRefValIDs.begin()->first) + 
"'");
 
 3729Value *LLParser::PerFunctionState::getVal(
const std::string &Name, 
Type *Ty,
 
 3732  Value *Val = 
F.getValueSymbolTable()->lookup(Name);
 
 3737    auto I = ForwardRefVals.find(Name);
 
 3738    if (
I != ForwardRefVals.end())
 
 3739      Val = 
I->second.first;
 
 3744    return P.checkValidVariableType(Loc, 
"%" + Name, Ty, Val);
 
 3748    P.error(Loc, 
"invalid use of a non-first-class type");
 
 3759  if (FwdVal->
getName() != Name) {
 
 3760    P.error(Loc, 
"name is too long which can result in name collisions, " 
 3761                 "consider making the name shorter or " 
 3762                 "increasing -non-global-value-max-name-size");
 
 3766  ForwardRefVals[
Name] = std::make_pair(FwdVal, Loc);
 
 3770Value *LLParser::PerFunctionState::getVal(
unsigned ID, 
Type *Ty, 
LocTy Loc) {
 
 3772  Value *Val = NumberedVals.get(
ID);
 
 3777    auto I = ForwardRefValIDs.find(
ID);
 
 3778    if (
I != ForwardRefValIDs.end())
 
 3779      Val = 
I->second.first;
 
 3784    return P.checkValidVariableType(Loc, 
"%" + Twine(
ID), Ty, Val);
 
 3787    P.error(Loc, 
"invalid use of a non-first-class type");
 
 3799  ForwardRefValIDs[
ID] = std::make_pair(FwdVal, Loc);
 
 3805bool LLParser::PerFunctionState::setInstName(
int NameID,
 
 3806                                             const std::string &NameStr,
 
 3807                                             LocTy NameLoc, Instruction *Inst) {
 
 3810    if (NameID != -1 || !NameStr.empty())
 
 3811      return P.error(NameLoc, 
"instructions returning void cannot have a name");
 
 3817  if (NameStr.empty()) {
 
 3820      NameID = NumberedVals.getNext();
 
 3822    if (
P.checkValueID(NameLoc, 
"instruction", 
"%", NumberedVals.getNext(),
 
 3826    auto FI = ForwardRefValIDs.find(NameID);
 
 3827    if (FI != ForwardRefValIDs.end()) {
 
 3830        return P.error(NameLoc, 
"instruction forward referenced with type '" +
 
 3834      Sentinel->replaceAllUsesWith(Inst);
 
 3836      ForwardRefValIDs.erase(FI);
 
 3839    NumberedVals.add(NameID, Inst);
 
 3844  auto FI = ForwardRefVals.find(NameStr);
 
 3845  if (FI != ForwardRefVals.end()) {
 
 3848      return P.error(NameLoc, 
"instruction forward referenced with type '" +
 
 3852    Sentinel->replaceAllUsesWith(Inst);
 
 3854    ForwardRefVals.erase(FI);
 
 3860  if (Inst->
getName() != NameStr)
 
 3861    return P.error(NameLoc, 
"multiple definition of local value named '" +
 
 3868BasicBlock *LLParser::PerFunctionState::getBB(
const std::string &Name,
 
 3882BasicBlock *LLParser::PerFunctionState::defineBB(
const std::string &Name,
 
 3883                                                 int NameID, 
LocTy Loc) {
 
 3887      if (
P.checkValueID(Loc, 
"label", 
"", NumberedVals.getNext(), NameID))
 
 3890      NameID = NumberedVals.getNext();
 
 3892    BB = getBB(NameID, Loc);
 
 3894      P.error(Loc, 
"unable to create block numbered '" + Twine(NameID) + 
"'");
 
 3898    BB = getBB(Name, Loc);
 
 3900      P.error(Loc, 
"unable to create block named '" + Name + 
"'");
 
 3911    ForwardRefValIDs.erase(NameID);
 
 3912    NumberedVals.add(NameID, BB);
 
 3915    ForwardRefVals.erase(Name);
 
 3932bool LLParser::parseValID(ValID &
ID, PerFunctionState *PFS, 
Type *ExpectedTy) {
 
 3933  ID.Loc = Lex.getLoc();
 
 3934  switch (Lex.getKind()) {
 
 3936    return tokError(
"expected value token");
 
 3938    ID.UIntVal = Lex.getUIntVal();
 
 3942    ID.StrVal = Lex.getStrVal();
 
 3946    ID.UIntVal = Lex.getUIntVal();
 
 3950    ID.StrVal = Lex.getStrVal();
 
 3954    ID.APSIntVal = Lex.getAPSIntVal();
 
 3958    ID.APFloatVal = Lex.getAPFloatVal();
 
 3979    if (parseGlobalValueVector(Elts) ||
 
 3980        parseToken(
lltok::rbrace, 
"expected end of struct constant"))
 
 3983    ID.ConstantStructElts = std::make_unique<Constant *[]>(Elts.
size());
 
 3984    ID.UIntVal = Elts.
size();
 
 3985    memcpy(
ID.ConstantStructElts.get(), Elts.
data(),
 
 3986           Elts.
size() * 
sizeof(Elts[0]));
 
 3997    LocTy FirstEltLoc = Lex.getLoc();
 
 3998    if (parseGlobalValueVector(Elts) ||
 
 4000         parseToken(
lltok::rbrace, 
"expected end of packed struct")) ||
 
 4004    if (isPackedStruct) {
 
 4005      ID.ConstantStructElts = std::make_unique<Constant *[]>(Elts.
size());
 
 4006      memcpy(
ID.ConstantStructElts.get(), Elts.
data(),
 
 4007             Elts.
size() * 
sizeof(Elts[0]));
 
 4008      ID.UIntVal = Elts.
size();
 
 4014      return error(
ID.Loc, 
"constant vector must not be empty");
 
 4016    if (!Elts[0]->
getType()->isIntegerTy() &&
 
 4017        !Elts[0]->
getType()->isFloatingPointTy() &&
 
 4021          "vector elements must have integer, pointer or floating point type");
 
 4024    for (
unsigned i = 1, e = Elts.
size(); i != e; ++i)
 
 4026        return error(FirstEltLoc, 
"vector element #" + Twine(i) +
 
 4027                                      " is not of type '" +
 
 4037    LocTy FirstEltLoc = Lex.getLoc();
 
 4038    if (parseGlobalValueVector(Elts) ||
 
 4050    if (!Elts[0]->
getType()->isFirstClassType())
 
 4051      return error(FirstEltLoc, 
"invalid array element type: " +
 
 4057    for (
unsigned i = 0, e = Elts.
size(); i != e; ++i) {
 
 4059        return error(FirstEltLoc, 
"array element #" + Twine(i) +
 
 4060                                      " is not of type '" +
 
 4080    bool HasSideEffect, AlignStack, AsmDialect, CanThrow;
 
 4083        parseOptionalToken(lltok::kw_alignstack, AlignStack) ||
 
 4086        parseStringConstant(
ID.StrVal) ||
 
 4087        parseToken(
lltok::comma, 
"expected comma in inline asm expression") ||
 
 4090    ID.StrVal2 = Lex.getStrVal();
 
 4091    ID.UIntVal = unsigned(HasSideEffect) | (unsigned(AlignStack) << 1) |
 
 4092                 (
unsigned(AsmDialect) << 2) | (unsigned(CanThrow) << 3);
 
 4103    if (parseToken(
lltok::lparen, 
"expected '(' in block address expression") ||
 
 4104        parseValID(Fn, PFS) ||
 
 4106                   "expected comma in block address expression") ||
 
 4107        parseValID(Label, PFS) ||
 
 4108        parseToken(
lltok::rparen, 
"expected ')' in block address expression"))
 
 4112      return error(Fn.
Loc, 
"expected function name in blockaddress");
 
 4114      return error(
Label.Loc, 
"expected basic block name in blockaddress");
 
 4117    GlobalValue *GV = 
nullptr;
 
 4119      GV = NumberedVals.get(Fn.
UIntVal);
 
 4120    } 
else if (!ForwardRefVals.count(Fn.
StrVal)) {
 
 4121      GV = M->getNamedValue(Fn.
StrVal);
 
 4127        return error(Fn.
Loc, 
"expected function name in blockaddress");
 
 4129      if (
F->isDeclaration())
 
 4130        return error(Fn.
Loc, 
"cannot take blockaddress inside a declaration");
 
 4135      GlobalValue *&FwdRef =
 
 4136          ForwardRefBlockAddresses[std::move(Fn)][std::move(Label)];
 
 4144                         "type of blockaddress must be a pointer and not '" +
 
 4149          FwdDeclAS = PFS->getFunction().getAddressSpace();
 
 4153        FwdRef = 
new GlobalVariable(
 
 4158      ID.ConstantVal = FwdRef;
 
 4166    if (BlockAddressPFS && 
F == &BlockAddressPFS->getFunction()) {
 
 4168        BB = BlockAddressPFS->getBB(
Label.UIntVal, 
Label.Loc);
 
 4170        BB = BlockAddressPFS->getBB(
Label.StrVal, 
Label.Loc);
 
 4172        return error(
Label.Loc, 
"referenced value is not a basic block");
 
 4175        return error(
Label.Loc, 
"cannot take address of numeric label after " 
 4176                                "the function is defined");
 
 4178          F->getValueSymbolTable()->lookup(
Label.StrVal));
 
 4180        return error(
Label.Loc, 
"referenced value is not a basic block");
 
 4194    if (parseValID(Fn, PFS))
 
 4199                   "expected global value name in dso_local_equivalent");
 
 4202    GlobalValue *GV = 
nullptr;
 
 4204      GV = NumberedVals.get(Fn.
UIntVal);
 
 4205    } 
else if (!ForwardRefVals.count(Fn.
StrVal)) {
 
 4206      GV = M->getNamedValue(Fn.
StrVal);
 
 4212                            ? ForwardRefDSOLocalEquivalentIDs
 
 4213                            : ForwardRefDSOLocalEquivalentNames;
 
 4214      GlobalValue *&FwdRef = FwdRefMap[Fn];
 
 4221      ID.ConstantVal = FwdRef;
 
 4227      return error(Fn.
Loc, 
"expected a function, alias to function, or ifunc " 
 4228                           "in dso_local_equivalent");
 
 4239    if (parseValID(
ID, PFS))
 
 4243      return error(
ID.Loc, 
"expected global value name in no_cfi");
 
 4254    Constant *Disc = 
nullptr, *AddrDisc = 
nullptr;
 
 4257                   "expected '(' in constant ptrauth expression") ||
 
 4258        parseGlobalTypeAndValue(
Ptr) ||
 
 4260                   "expected comma in constant ptrauth expression") ||
 
 4261        parseGlobalTypeAndValue(
Key))
 
 4265      if (parseGlobalTypeAndValue(Disc) ||
 
 4266          (EatIfPresent(
lltok::comma) && parseGlobalTypeAndValue(AddrDisc)))
 
 4269                   "expected ')' in constant ptrauth expression"))
 
 4272    if (!
Ptr->getType()->isPointerTy())
 
 4273      return error(
ID.Loc, 
"constant ptrauth base pointer must be a pointer");
 
 4276    if (!KeyC || KeyC->getBitWidth() != 32)
 
 4277      return error(
ID.Loc, 
"constant ptrauth key must be i32 constant");
 
 4279    ConstantInt *DiscC = 
nullptr;
 
 4285            "constant ptrauth integer discriminator must be i64 constant");
 
 4291      if (!AddrDisc->getType()->isPointerTy())
 
 4293            ID.Loc, 
"constant ptrauth address discriminator must be a pointer");
 
 4309    unsigned Opc = Lex.getUIntVal();
 
 4310    Type *DestTy = 
nullptr;
 
 4313    if (parseToken(
lltok::lparen, 
"expected '(' after constantexpr cast") ||
 
 4314        parseGlobalTypeAndValue(SrcVal) ||
 
 4315        parseToken(
lltok::kw_to, 
"expected 'to' in constantexpr cast") ||
 
 4316        parseType(DestTy) ||
 
 4317        parseToken(
lltok::rparen, 
"expected ')' at end of constantexpr cast"))
 
 4320      return error(
ID.Loc, 
"invalid cast opcode for cast from '" +
 
 4329    return error(
ID.Loc, 
"extractvalue constexprs are no longer supported");
 
 4331    return error(
ID.Loc, 
"insertvalue constexprs are no longer supported");
 
 4333    return error(
ID.Loc, 
"udiv constexprs are no longer supported");
 
 4335    return error(
ID.Loc, 
"sdiv constexprs are no longer supported");
 
 4337    return error(
ID.Loc, 
"urem constexprs are no longer supported");
 
 4339    return error(
ID.Loc, 
"srem constexprs are no longer supported");
 
 4341    return error(
ID.Loc, 
"fadd constexprs are no longer supported");
 
 4343    return error(
ID.Loc, 
"fsub constexprs are no longer supported");
 
 4345    return error(
ID.Loc, 
"fmul constexprs are no longer supported");
 
 4347    return error(
ID.Loc, 
"fdiv constexprs are no longer supported");
 
 4349    return error(
ID.Loc, 
"frem constexprs are no longer supported");
 
 4351    return error(
ID.Loc, 
"and constexprs are no longer supported");
 
 4353    return error(
ID.Loc, 
"or constexprs are no longer supported");
 
 4355    return error(
ID.Loc, 
"lshr constexprs are no longer supported");
 
 4357    return error(
ID.Loc, 
"ashr constexprs are no longer supported");
 
 4359    return error(
ID.Loc, 
"shl constexprs are no longer supported");
 
 4361    return error(
ID.Loc, 
"mul constexprs are no longer supported");
 
 4363    return error(
ID.Loc, 
"fneg constexprs are no longer supported");
 
 4365    return error(
ID.Loc, 
"select constexprs are no longer supported");
 
 4367    return error(
ID.Loc, 
"zext constexprs are no longer supported");
 
 4369    return error(
ID.Loc, 
"sext constexprs are no longer supported");
 
 4371    return error(
ID.Loc, 
"fptrunc constexprs are no longer supported");
 
 4373    return error(
ID.Loc, 
"fpext constexprs are no longer supported");
 
 4375    return error(
ID.Loc, 
"uitofp constexprs are no longer supported");
 
 4377    return error(
ID.Loc, 
"sitofp constexprs are no longer supported");
 
 4379    return error(
ID.Loc, 
"fptoui constexprs are no longer supported");
 
 4381    return error(
ID.Loc, 
"fptosi constexprs are no longer supported");
 
 4383    return error(
ID.Loc, 
"icmp constexprs are no longer supported");
 
 4385    return error(
ID.Loc, 
"fcmp constexprs are no longer supported");
 
 4393    unsigned Opc = Lex.getUIntVal();
 
 4396    if (
Opc == Instruction::Add || 
Opc == Instruction::Sub ||
 
 4397        Opc == Instruction::Mul) {
 
 4406    if (parseToken(
lltok::lparen, 
"expected '(' in binary constantexpr") ||
 
 4407        parseGlobalTypeAndValue(Val0) ||
 
 4408        parseToken(
lltok::comma, 
"expected comma in binary constantexpr") ||
 
 4409        parseGlobalTypeAndValue(Val1) ||
 
 4410        parseToken(
lltok::rparen, 
"expected ')' in binary constantexpr"))
 
 4413      return error(
ID.Loc, 
"operands of constexpr must have same type");
 
 4417                   "constexpr requires integer or integer vector operands");
 
 4428    if (parseToken(
lltok::lparen, 
"expected '(' after vector splat"))
 
 4431    if (parseGlobalTypeAndValue(
C))
 
 4433    if (parseToken(
lltok::rparen, 
"expected ')' at end of vector splat"))
 
 4445    unsigned Opc = Lex.getUIntVal();
 
 4448    bool HasInRange = 
false;
 
 4454    if (
Opc == Instruction::GetElementPtr) {
 
 4470          return tokError(
"expected integer");
 
 4471        InRangeStart = Lex.getAPSIntVal();
 
 4476          return tokError(
"expected integer");
 
 4477        InRangeEnd = Lex.getAPSIntVal();
 
 4485    if (parseToken(
lltok::lparen, 
"expected '(' in constantexpr"))
 
 4488    if (
Opc == Instruction::GetElementPtr) {
 
 4489      if (parseType(Ty) ||
 
 4490          parseToken(
lltok::comma, 
"expected comma after getelementptr's type"))
 
 4494    if (parseGlobalValueVector(Elts) ||
 
 4498    if (
Opc == Instruction::GetElementPtr) {
 
 4499      if (Elts.
size() == 0 ||
 
 4500          !Elts[0]->getType()->isPtrOrPtrVectorTy())
 
 4501        return error(
ID.Loc, 
"base of getelementptr must be a pointer");
 
 4504      std::optional<ConstantRange> 
InRange;
 
 4506        unsigned IndexWidth =
 
 4507            M->getDataLayout().getIndexTypeSizeInBits(
BaseType);
 
 4508        InRangeStart = InRangeStart.
extOrTrunc(IndexWidth);
 
 4509        InRangeEnd = InRangeEnd.
extOrTrunc(IndexWidth);
 
 4510        if (InRangeStart.
sge(InRangeEnd))
 
 4511          return error(
ID.Loc, 
"expected end to be larger than start");
 
 4521      for (Constant *Val : Indices) {
 
 4524          return error(
ID.Loc, 
"getelementptr index must be an integer");
 
 4527          if (GEPWidth && (ValNumEl != GEPWidth))
 
 4530                "getelementptr vector index has a wrong number of elements");
 
 4533          GEPWidth = ValNumEl;
 
 4537      SmallPtrSet<Type*, 4> Visited;
 
 4538      if (!Indices.empty() && !Ty->
isSized(&Visited))
 
 4539        return error(
ID.Loc, 
"base element of getelementptr must be sized");
 
 4542        return error(
ID.Loc, 
"invalid base element for constant getelementptr");
 
 4545        return error(
ID.Loc, 
"invalid getelementptr indices");
 
 4549    } 
else if (
Opc == Instruction::ShuffleVector) {
 
 4550      if (Elts.
size() != 3)
 
 4551        return error(
ID.Loc, 
"expected three operands to shufflevector");
 
 4553        return error(
ID.Loc, 
"invalid operands to shufflevector");
 
 4554      SmallVector<int, 16> 
Mask;
 
 4557    } 
else if (
Opc == Instruction::ExtractElement) {
 
 4558      if (Elts.
size() != 2)
 
 4559        return error(
ID.Loc, 
"expected two operands to extractelement");
 
 4561        return error(
ID.Loc, 
"invalid extractelement operands");
 
 4564      assert(
Opc == Instruction::InsertElement && 
"Unknown opcode");
 
 4565      if (Elts.
size() != 3)
 
 4566        return error(
ID.Loc, 
"expected three operands to insertelement");
 
 4568        return error(
ID.Loc, 
"invalid insertelement operands");
 
 4583bool LLParser::parseGlobalValue(
Type *Ty, Constant *&
C) {
 
 4587  bool Parsed = parseValID(
ID, 
nullptr, Ty) ||
 
 4588                convertValIDToValue(Ty, 
ID, V, 
nullptr);
 
 4590    return error(
ID.Loc, 
"global values must be constants");
 
 4594bool LLParser::parseGlobalTypeAndValue(Constant *&V) {
 
 4596  return parseType(Ty) || parseGlobalValue(Ty, V);
 
 4599bool LLParser::parseOptionalComdat(StringRef GlobalName, Comdat *&
C) {
 
 4602  LocTy KwLoc = Lex.getLoc();
 
 4608      return tokError(
"expected comdat variable");
 
 4609    C = getComdat(Lex.getStrVal(), Lex.getLoc());
 
 4611    if (parseToken(
lltok::rparen, 
"expected ')' after comdat var"))
 
 4614    if (GlobalName.
empty())
 
 4615      return tokError(
"comdat cannot be unnamed");
 
 4616    C = getComdat(std::string(GlobalName), KwLoc);
 
 4625bool LLParser::parseGlobalValueVector(SmallVectorImpl<Constant *> &Elts) {
 
 4639    if (parseGlobalTypeAndValue(
C))
 
 4647bool LLParser::parseMDTuple(MDNode *&MD, 
bool IsDistinct) {
 
 4649  if (parseMDNodeVector(Elts))
 
 4660bool LLParser::parseMDNode(MDNode *&
N) {
 
 4662    return parseSpecializedMDNode(
N);
 
 4664  return parseToken(
lltok::exclaim, 
"expected '!' here") || parseMDNodeTail(
N);
 
 4667bool LLParser::parseMDNodeTail(MDNode *&
N) {
 
 4670    return parseMDTuple(
N);
 
 4673  return parseMDNodeID(
N);
 
 4679template <
class FieldTy> 
struct MDFieldImpl {
 
 4680  typedef MDFieldImpl ImplTy;
 
 4684  void assign(FieldTy Val) {
 
 4686    this->Val = std::move(Val);
 
 4689  explicit MDFieldImpl(FieldTy 
Default)
 
 4697template <
class FieldTypeA, 
class FieldTypeB> 
struct MDEitherFieldImpl {
 
 4698  typedef MDEitherFieldImpl<FieldTypeA, FieldTypeB> ImplTy;
 
 4709  void assign(FieldTypeA 
A) {
 
 4711    this->
A = std::move(
A);
 
 4715  void assign(FieldTypeB 
B) {
 
 4717    this->
B = std::move(
B);
 
 4721  explicit MDEitherFieldImpl(FieldTypeA DefaultA, FieldTypeB DefaultB)
 
 4723        WhatIs(IsInvalid) {}
 
 4726struct MDUnsignedField : 
public MDFieldImpl<uint64_t> {
 
 4733struct LineField : 
public MDUnsignedField {
 
 4734  LineField() : MDUnsignedField(0, UINT32_MAX) {}
 
 4737struct ColumnField : 
public MDUnsignedField {
 
 4738  ColumnField() : MDUnsignedField(0, UINT16_MAX) {}
 
 4741struct DwarfTagField : 
public MDUnsignedField {
 
 4747struct DwarfMacinfoTypeField : 
public MDUnsignedField {
 
 4753struct DwarfAttEncodingField : 
public MDUnsignedField {
 
 4754  DwarfAttEncodingField() : MDUnsignedField(0, dwarf::
DW_ATE_hi_user) {}
 
 4757struct DwarfVirtualityField : 
public MDUnsignedField {
 
 4761struct DwarfLangField : 
public MDUnsignedField {
 
 4765struct DwarfSourceLangNameField : 
public MDUnsignedField {
 
 4766  DwarfSourceLangNameField() : MDUnsignedField(0, UINT32_MAX) {}
 
 4769struct DwarfCCField : 
public MDUnsignedField {
 
 4770  DwarfCCField() : MDUnsignedField(0, dwarf::
DW_CC_hi_user) {}
 
 4773struct DwarfEnumKindField : 
public MDUnsignedField {
 
 4774  DwarfEnumKindField()
 
 4779struct EmissionKindField : 
public MDUnsignedField {
 
 4780  EmissionKindField() : MDUnsignedField(0, DICompileUnit::LastEmissionKind) {}
 
 4783struct FixedPointKindField : 
public MDUnsignedField {
 
 4784  FixedPointKindField()
 
 4785      : MDUnsignedField(0, DIFixedPointType::LastFixedPointKind) {}
 
 4788struct NameTableKindField : 
public MDUnsignedField {
 
 4789  NameTableKindField()
 
 4792                   DICompileUnit::DebugNameTableKind::LastDebugNameTableKind) {}
 
 4795struct DIFlagField : 
public MDFieldImpl<DINode::DIFlags> {
 
 4796  DIFlagField() : MDFieldImpl(DINode::FlagZero) {}
 
 4799struct DISPFlagField : 
public MDFieldImpl<DISubprogram::DISPFlags> {
 
 4800  DISPFlagField() : MDFieldImpl(DISubprogram::SPFlagZero) {}
 
 4803struct MDAPSIntField : 
public MDFieldImpl<APSInt> {
 
 4804  MDAPSIntField() : ImplTy(
APSInt()) {}
 
 4807struct MDSignedField : 
public MDFieldImpl<int64_t> {
 
 4811  MDSignedField(int64_t 
Default = 0)
 
 4813  MDSignedField(int64_t 
Default, int64_t Min, int64_t Max)
 
 4817struct MDBoolField : 
public MDFieldImpl<bool> {
 
 4821struct MDField : 
public MDFieldImpl<Metadata *> {
 
 4824  MDField(
bool AllowNull = 
true) : ImplTy(nullptr), AllowNull(AllowNull) {}
 
 4827struct MDStringField : 
public MDFieldImpl<MDString *> {
 
 4828  enum class EmptyIs {
 
 4833  MDStringField(
enum EmptyIs EmptyIs = EmptyIs::Null)
 
 4834      : ImplTy(nullptr), EmptyIs(EmptyIs) {}
 
 4837struct MDFieldList : 
public MDFieldImpl<SmallVector<Metadata *, 4>> {
 
 4841struct ChecksumKindField : 
public MDFieldImpl<DIFile::ChecksumKind> {
 
 4845struct MDSignedOrMDField : MDEitherFieldImpl<MDSignedField, MDField> {
 
 4846  MDSignedOrMDField(int64_t 
Default = 0, 
bool AllowNull = 
true)
 
 4847      : ImplTy(MDSignedField(
Default), MDField(AllowNull)) {}
 
 4849  MDSignedOrMDField(int64_t 
Default, int64_t Min, int64_t Max,
 
 4850                    bool AllowNull = 
true)
 
 4851      : ImplTy(MDSignedField(
Default, Min, 
Max), MDField(AllowNull)) {}
 
 4853  bool isMDSignedField()
 const { 
return WhatIs == IsTypeA; }
 
 4854  bool isMDField()
 const { 
return WhatIs == IsTypeB; }
 
 4855  int64_t getMDSignedValue()
 const {
 
 4856    assert(isMDSignedField() && 
"Wrong field type");
 
 4859  Metadata *getMDFieldValue()
 const {
 
 4860    assert(isMDField() && 
"Wrong field type");
 
 4865struct MDUnsignedOrMDField : MDEitherFieldImpl<MDUnsignedField, MDField> {
 
 4866  MDUnsignedOrMDField(uint64_t 
Default = 0, 
bool AllowNull = 
true)
 
 4867      : ImplTy(MDUnsignedField(
Default), MDField(AllowNull)) {}
 
 4869  MDUnsignedOrMDField(uint64_t 
Default, uint64_t Max, 
bool AllowNull = 
true)
 
 4870      : ImplTy(MDUnsignedField(
Default, 
Max), MDField(AllowNull)) {}
 
 4872  bool isMDUnsignedField()
 const { 
return WhatIs == IsTypeA; }
 
 4873  bool isMDField()
 const { 
return WhatIs == IsTypeB; }
 
 4874  uint64_t getMDUnsignedValue()
 const {
 
 4875    assert(isMDUnsignedField() && 
"Wrong field type");
 
 4878  Metadata *getMDFieldValue()
 const {
 
 4879    assert(isMDField() && 
"Wrong field type");
 
 4884    if (isMDUnsignedField())
 
 4886          ConstantInt::get(Type::getInt64Ty(
Context), getMDUnsignedValue()));
 
 4888      return getMDFieldValue();
 
 4900    return tokError(
"expected integer");
 
 4902  Result.assign(Lex.getAPSIntVal());
 
 
 4909                            MDUnsignedField &Result) {
 
 4910  if (Lex.getKind() != 
lltok::APSInt || Lex.getAPSIntVal().isSigned())
 
 4911    return tokError(
"expected unsigned integer");
 
 4913  auto &U = Lex.getAPSIntVal();
 
 4914  if (U.ugt(Result.Max))
 
 4915    return tokError(
"value for '" + Name + 
"' too large, limit is " +
 
 4917  Result.assign(U.getZExtValue());
 
 4918  assert(Result.Val <= Result.Max && 
"Expected value in range");
 
 
 4925  return parseMDField(
Loc, Name, 
static_cast<MDUnsignedField &
>(Result));
 
 
 4929  return parseMDField(
Loc, Name, 
static_cast<MDUnsignedField &
>(Result));
 
 
 4935    return parseMDField(
Loc, Name, 
static_cast<MDUnsignedField &
>(Result));
 
 4938    return tokError(
"expected DWARF tag");
 
 4942    return tokError(
"invalid DWARF tag" + 
Twine(
" '") + Lex.getStrVal() + 
"'");
 
 4943  assert(
Tag <= Result.Max && 
"Expected valid DWARF tag");
 
 
 4952                            DwarfMacinfoTypeField &Result) {
 
 4954    return parseMDField(
Loc, Name, 
static_cast<MDUnsignedField &
>(Result));
 
 4957    return tokError(
"expected DWARF macinfo type");
 
 4961    return tokError(
"invalid DWARF macinfo type" + 
Twine(
" '") +
 
 4962                    Lex.getStrVal() + 
"'");
 
 4963  assert(Macinfo <= Result.Max && 
"Expected valid DWARF macinfo type");
 
 4965  Result.assign(Macinfo);
 
 
 4972                            DwarfVirtualityField &Result) {
 
 4974    return parseMDField(
Loc, Name, 
static_cast<MDUnsignedField &
>(Result));
 
 4977    return tokError(
"expected DWARF virtuality code");
 
 4981    return tokError(
"invalid DWARF virtuality code" + 
Twine(
" '") +
 
 4982                    Lex.getStrVal() + 
"'");
 
 4983  assert(Virtuality <= Result.Max && 
"Expected valid DWARF virtuality code");
 
 4984  Result.assign(Virtuality);
 
 
 4991                            DwarfEnumKindField &Result) {
 
 4993    return parseMDField(
Loc, Name, 
static_cast<MDUnsignedField &
>(Result));
 
 4996    return tokError(
"expected DWARF enum kind code");
 
 5000    return tokError(
"invalid DWARF enum kind code" + 
Twine(
" '") +
 
 5001                    Lex.getStrVal() + 
"'");
 
 5002  assert(EnumKind <= Result.Max && 
"Expected valid DWARF enum kind code");
 
 5003  Result.assign(EnumKind);
 
 
 5011    return parseMDField(
Loc, Name, 
static_cast<MDUnsignedField &
>(Result));
 
 5014    return tokError(
"expected DWARF language");
 
 5018    return tokError(
"invalid DWARF language" + 
Twine(
" '") + Lex.getStrVal() +
 
 5020  assert(Lang <= Result.Max && 
"Expected valid DWARF language");
 
 5021  Result.assign(Lang);
 
 
 5028                            DwarfSourceLangNameField &Result) {
 
 5030    return parseMDField(
Loc, Name, 
static_cast<MDUnsignedField &
>(Result));
 
 5033    return tokError(
"expected DWARF source language name");
 
 5037    return tokError(
"invalid DWARF source language name" + 
Twine(
" '") +
 
 5038                    Lex.getStrVal() + 
"'");
 
 5039  assert(Lang <= Result.Max && 
"Expected valid DWARF source language name");
 
 5040  Result.assign(Lang);
 
 
 5048    return parseMDField(
Loc, Name, 
static_cast<MDUnsignedField &
>(Result));
 
 5051    return tokError(
"expected DWARF calling convention");
 
 5055    return tokError(
"invalid DWARF calling convention" + 
Twine(
" '") +
 
 5056                    Lex.getStrVal() + 
"'");
 
 5057  assert(CC <= Result.Max && 
"Expected valid DWARF calling convention");
 
 
 5065                            EmissionKindField &Result) {
 
 5067    return parseMDField(
Loc, Name, 
static_cast<MDUnsignedField &
>(Result));
 
 5070    return tokError(
"expected emission kind");
 
 5074    return tokError(
"invalid emission kind" + 
Twine(
" '") + Lex.getStrVal() +
 
 5076  assert(*Kind <= Result.Max && 
"Expected valid emission kind");
 
 5077  Result.assign(*Kind);
 
 
 5084                            FixedPointKindField &Result) {
 
 5086    return parseMDField(
Loc, Name, 
static_cast<MDUnsignedField &
>(Result));
 
 5089    return tokError(
"expected fixed-point kind");
 
 5093    return tokError(
"invalid fixed-point kind" + 
Twine(
" '") + Lex.getStrVal() +
 
 5095  assert(*Kind <= Result.Max && 
"Expected valid fixed-point kind");
 
 5096  Result.assign(*Kind);
 
 
 5103                            NameTableKindField &Result) {
 
 5105    return parseMDField(
Loc, Name, 
static_cast<MDUnsignedField &
>(Result));
 
 5108    return tokError(
"expected nameTable kind");
 
 5112    return tokError(
"invalid nameTable kind" + 
Twine(
" '") + Lex.getStrVal() +
 
 5114  assert(((
unsigned)*Kind) <= Result.Max && 
"Expected valid nameTable kind");
 
 5115  Result.assign((
unsigned)*Kind);
 
 
 5122                            DwarfAttEncodingField &Result) {
 
 5124    return parseMDField(
Loc, Name, 
static_cast<MDUnsignedField &
>(Result));
 
 5127    return tokError(
"expected DWARF type attribute encoding");
 
 5131    return tokError(
"invalid DWARF type attribute encoding" + 
Twine(
" '") +
 
 5132                    Lex.getStrVal() + 
"'");
 
 5133  assert(Encoding <= Result.Max && 
"Expected valid DWARF language");
 
 5134  Result.assign(Encoding);
 
 
 5148    if (Lex.getKind() == 
lltok::APSInt && !Lex.getAPSIntVal().isSigned()) {
 
 5150      bool Res = parseUInt32(TempVal);
 
 5156      return tokError(
"expected debug info flag");
 
 5160      return tokError(
Twine(
"invalid debug info flag '") + Lex.getStrVal() +
 
 5175  Result.assign(Combined);
 
 
 5188    if (Lex.getKind() == 
lltok::APSInt && !Lex.getAPSIntVal().isSigned()) {
 
 5190      bool Res = parseUInt32(TempVal);
 
 5196      return tokError(
"expected debug info flag");
 
 5200      return tokError(
Twine(
"invalid subprogram debug info flag '") +
 
 5201                      Lex.getStrVal() + 
"'");
 
 5215  Result.assign(Combined);
 
 
 5222    return tokError(
"expected signed integer");
 
 5224  auto &S = Lex.getAPSIntVal();
 
 5226    return tokError(
"value for '" + Name + 
"' too small, limit is " +
 
 5229    return tokError(
"value for '" + Name + 
"' too large, limit is " +
 
 5231  Result.assign(S.getExtValue());
 
 5232  assert(Result.Val >= Result.Min && 
"Expected value in range");
 
 5233  assert(Result.Val <= Result.Max && 
"Expected value in range");
 
 
 5240  switch (Lex.getKind()) {
 
 5242    return tokError(
"expected 'true' or 'false'");
 
 5244    Result.assign(
true);
 
 5247    Result.assign(
false);
 
 
 5257    if (!Result.AllowNull)
 
 5258      return tokError(
"'" + Name + 
"' cannot be null");
 
 5260    Result.assign(
nullptr);
 
 5265  if (parseMetadata(MD, 
nullptr))
 
 
 5274                            MDSignedOrMDField &Result) {
 
 5277    MDSignedField Res = Result.A;
 
 5278    if (!parseMDField(
Loc, Name, Res)) {
 
 5286  MDField Res = Result.B;
 
 5287  if (!parseMDField(
Loc, Name, Res)) {
 
 
 5297                            MDUnsignedOrMDField &Result) {
 
 5300    MDUnsignedField Res = Result.A;
 
 5301    if (!parseMDField(
Loc, Name, Res)) {
 
 5309  MDField Res = Result.B;
 
 5310  if (!parseMDField(
Loc, Name, Res)) {
 
 
 5320  LocTy ValueLoc = Lex.getLoc();
 
 5322  if (parseStringConstant(S))
 
 5326    switch (Result.EmptyIs) {
 
 5327    case MDStringField::EmptyIs::Null:
 
 5328      Result.assign(
nullptr);
 
 5330    case MDStringField::EmptyIs::Empty:
 
 5332    case MDStringField::EmptyIs::Error:
 
 5333      return error(ValueLoc, 
"'" + Name + 
"' cannot be empty");
 
 
 5344  if (parseMDNodeVector(MDs))
 
 5347  Result.assign(std::move(MDs));
 
 
 5353                            ChecksumKindField &Result) {
 
 5354  std::optional<DIFile::ChecksumKind> CSKind =
 
 5358    return tokError(
"invalid checksum kind" + 
Twine(
" '") + Lex.getStrVal() +
 
 5361  Result.assign(*CSKind);
 
 
 5368template <
class ParserTy>
 
 5369bool LLParser::parseMDFieldsImplBody(ParserTy ParseField) {
 
 5372      return tokError(
"expected field label here");
 
 5381template <
class ParserTy>
 
 5382bool LLParser::parseMDFieldsImpl(ParserTy ParseField, LocTy &ClosingLoc) {
 
 5389    if (parseMDFieldsImplBody(ParseField))
 
 5392  ClosingLoc = Lex.getLoc();
 
 5396template <
class FieldTy>
 
 5397bool LLParser::parseMDField(
StringRef Name, FieldTy &Result) {
 
 5399    return tokError(
"field '" + Name + 
"' cannot be specified more than once");
 
 5401  LocTy Loc = Lex.getLoc();
 
 5403  return parseMDField(Loc, Name, Result);
 
 5406bool LLParser::parseSpecializedMDNode(
MDNode *&
N, 
bool IsDistinct) {
 
 5409#define HANDLE_SPECIALIZED_MDNODE_LEAF(CLASS)                                  \ 
 5410  if (Lex.getStrVal() == #CLASS)                                               \ 
 5411    return parse##CLASS(N, IsDistinct); 
 5412#include "llvm/IR/Metadata.def" 
 5414  return tokError(
"expected metadata type");
 
 5417#define DECLARE_FIELD(NAME, TYPE, INIT) TYPE NAME INIT 
 5418#define NOP_FIELD(NAME, TYPE, INIT) 
 5419#define REQUIRE_FIELD(NAME, TYPE, INIT)                                        \ 
 5421    return error(ClosingLoc, "missing required field '" #NAME "'"); 
 
 5422#define PARSE_MD_FIELD(NAME, TYPE, DEFAULT)                                    \ 
 5423  if (Lex.getStrVal() == #NAME)                                                \ 
 5424    return parseMDField(#NAME, NAME); 
 
 5425#define PARSE_MD_FIELDS()                                                      \ 
 5426  VISIT_MD_FIELDS(DECLARE_FIELD, DECLARE_FIELD)                                \ 
 5429    if (parseMDFieldsImpl(                                                     \ 
 5431              VISIT_MD_FIELDS(PARSE_MD_FIELD, PARSE_MD_FIELD)                  \ 
 5432              return tokError(Twine("invalid field '") + Lex.getStrVal() +     \ 
 5437    VISIT_MD_FIELDS(NOP_FIELD, REQUIRE_FIELD)                                  \ 
 
 5439#define GET_OR_DISTINCT(CLASS, ARGS)                                           \ 
 5440  (IsDistinct ? CLASS::getDistinct ARGS : CLASS::get ARGS) 
 
 5445bool LLParser::parseDILocation(
MDNode *&Result, 
bool IsDistinct) {
 
 5446#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \ 
 5447  OPTIONAL(line, LineField, );                                                 \ 
 5448  OPTIONAL(column, ColumnField, );                                             \ 
 5449  REQUIRED(scope, MDField, ( false));                           \ 
 5450  OPTIONAL(inlinedAt, MDField, );                                              \ 
 5451  OPTIONAL(isImplicitCode, MDBoolField, (false));                              \ 
 5452  OPTIONAL(atomGroup, MDUnsignedField, (0, UINT64_MAX));                       \ 
 5453  OPTIONAL(atomRank, MDUnsignedField, (0, UINT8_MAX)); 
 5455#undef VISIT_MD_FIELDS 
 5458      DILocation, (Context, line.Val, column.Val, scope.Val, inlinedAt.Val,
 
 5459                   isImplicitCode.Val, atomGroup.Val, atomRank.Val));
 
 5465bool LLParser::parseDIAssignID(
MDNode *&Result, 
bool IsDistinct) {
 
 5467    return tokError(
"missing 'distinct', required for !DIAssignID()");
 
 5483bool LLParser::parseGenericDINode(
MDNode *&Result, 
bool IsDistinct) {
 
 5484#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \ 
 5485  REQUIRED(tag, DwarfTagField, );                                              \ 
 5486  OPTIONAL(header, MDStringField, );                                           \ 
 5487  OPTIONAL(operands, MDFieldList, ); 
 5489#undef VISIT_MD_FIELDS 
 5492                           (Context, tag.Val, header.Val, operands.Val));
 
 5501bool LLParser::parseDISubrangeType(
MDNode *&Result, 
bool IsDistinct) {
 
 5502#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \ 
 5503  OPTIONAL(name, MDStringField, );                                             \ 
 5504  OPTIONAL(file, MDField, );                                                   \ 
 5505  OPTIONAL(line, LineField, );                                                 \ 
 5506  OPTIONAL(scope, MDField, );                                                  \ 
 5507  OPTIONAL(baseType, MDField, );                                               \ 
 5508  OPTIONAL(size, MDUnsignedOrMDField, (0, UINT64_MAX));                        \ 
 5509  OPTIONAL(align, MDUnsignedField, (0, UINT32_MAX));                           \ 
 5510  OPTIONAL(flags, DIFlagField, );                                              \ 
 5511  OPTIONAL(lowerBound, MDSignedOrMDField, );                                   \ 
 5512  OPTIONAL(upperBound, MDSignedOrMDField, );                                   \ 
 5513  OPTIONAL(stride, MDSignedOrMDField, );                                       \ 
 5514  OPTIONAL(bias, MDSignedOrMDField, ); 
 5516#undef VISIT_MD_FIELDS 
 5518  auto convToMetadata = [&](MDSignedOrMDField Bound) -> 
Metadata * {
 
 5519    if (Bound.isMDSignedField())
 
 5522    if (Bound.isMDField())
 
 5523      return Bound.getMDFieldValue();
 
 5527  Metadata *LowerBound = convToMetadata(lowerBound);
 
 5529  Metadata *Stride = convToMetadata(stride);
 
 5530  Metadata *Bias = convToMetadata(bias);
 
 5533      DISubrangeType, (Context, 
name.Val, 
file.Val, line.Val, scope.Val,
 
 5534                       size.getValueAsMetadata(Context), align.Val, flags.Val,
 
 5535                       baseType.Val, LowerBound, UpperBound, Stride, Bias));
 
 5544bool LLParser::parseDISubrange(
MDNode *&Result, 
bool IsDistinct) {
 
 5545#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \ 
 5546  OPTIONAL(count, MDSignedOrMDField, (-1, -1, INT64_MAX, false));              \ 
 5547  OPTIONAL(lowerBound, MDSignedOrMDField, );                                   \ 
 5548  OPTIONAL(upperBound, MDSignedOrMDField, );                                   \ 
 5549  OPTIONAL(stride, MDSignedOrMDField, ); 
 5551#undef VISIT_MD_FIELDS 
 5558  auto convToMetadata = [&](
const MDSignedOrMDField &Bound) -> 
Metadata * {
 
 5559    if (Bound.isMDSignedField())
 
 5562    if (Bound.isMDField())
 
 5563      return Bound.getMDFieldValue();
 
 5568  LowerBound = convToMetadata(lowerBound);
 
 5570  Stride = convToMetadata(stride);
 
 5573                           (Context, 
Count, LowerBound, UpperBound, Stride));
 
 5581bool LLParser::parseDIGenericSubrange(
MDNode *&Result, 
bool IsDistinct) {
 
 5582#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \ 
 5583  OPTIONAL(count, MDSignedOrMDField, );                                        \ 
 5584  OPTIONAL(lowerBound, MDSignedOrMDField, );                                   \ 
 5585  OPTIONAL(upperBound, MDSignedOrMDField, );                                   \ 
 5586  OPTIONAL(stride, MDSignedOrMDField, ); 
 5588#undef VISIT_MD_FIELDS 
 5590  auto ConvToMetadata = [&](
const MDSignedOrMDField &Bound) -> 
Metadata * {
 
 5591    if (Bound.isMDSignedField())
 
 5593          Context, {dwarf::DW_OP_consts,
 
 5594                    static_cast<uint64_t
>(Bound.getMDSignedValue())});
 
 5595    if (Bound.isMDField())
 
 5596      return Bound.getMDFieldValue();
 
 5601  Metadata *LowerBound = ConvToMetadata(lowerBound);
 
 5603  Metadata *Stride = ConvToMetadata(stride);
 
 5606                           (Context, 
Count, LowerBound, UpperBound, Stride));
 
 5613bool LLParser::parseDIEnumerator(
MDNode *&Result, 
bool IsDistinct) {
 
 5614#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \ 
 5615  REQUIRED(name, MDStringField, );                                             \ 
 5616  REQUIRED(value, MDAPSIntField, );                                            \ 
 5617  OPTIONAL(isUnsigned, MDBoolField, (false)); 
 5619#undef VISIT_MD_FIELDS 
 5621  if (isUnsigned.Val && value.Val.isNegative())
 
 5622    return tokError(
"unsigned enumerator with negative value");
 
 5627  if (!isUnsigned.Val && value.Val.isUnsigned() && value.Val.isSignBitSet())
 
 5639bool LLParser::parseDIBasicType(
MDNode *&Result, 
bool IsDistinct) {
 
 5640#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \ 
 5641  OPTIONAL(tag, DwarfTagField, (dwarf::DW_TAG_base_type));                     \ 
 5642  OPTIONAL(name, MDStringField, );                                             \ 
 5643  OPTIONAL(size, MDUnsignedOrMDField, (0, UINT64_MAX));                        \ 
 5644  OPTIONAL(align, MDUnsignedField, (0, UINT32_MAX));                           \ 
 5645  OPTIONAL(dataSize, MDUnsignedField, (0, UINT32_MAX));                        \ 
 5646  OPTIONAL(encoding, DwarfAttEncodingField, );                                 \ 
 5647  OPTIONAL(num_extra_inhabitants, MDUnsignedField, (0, UINT32_MAX));           \ 
 5648  OPTIONAL(flags, DIFlagField, ); 
 5650#undef VISIT_MD_FIELDS 
 5654      (Context, tag.Val, 
name.Val, 
size.getValueAsMetadata(Context), align.Val,
 
 5655       encoding.Val, num_extra_inhabitants.Val, dataSize.Val, flags.Val));
 
 5664bool LLParser::parseDIFixedPointType(
MDNode *&Result, 
bool IsDistinct) {
 
 5665#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \ 
 5666  OPTIONAL(tag, DwarfTagField, (dwarf::DW_TAG_base_type));                     \ 
 5667  OPTIONAL(name, MDStringField, );                                             \ 
 5668  OPTIONAL(size, MDUnsignedOrMDField, (0, UINT64_MAX));                        \ 
 5669  OPTIONAL(align, MDUnsignedField, (0, UINT32_MAX));                           \ 
 5670  OPTIONAL(encoding, DwarfAttEncodingField, );                                 \ 
 5671  OPTIONAL(flags, DIFlagField, );                                              \ 
 5672  OPTIONAL(kind, FixedPointKindField, );                                       \ 
 5673  OPTIONAL(factor, MDSignedField, );                                           \ 
 5674  OPTIONAL(numerator, MDAPSIntField, );                                        \ 
 5675  OPTIONAL(denominator, MDAPSIntField, ); 
 5677#undef VISIT_MD_FIELDS 
 5680                           (Context, tag.Val, 
name.Val,
 
 5681                            size.getValueAsMetadata(Context), align.Val,
 
 5682                            encoding.Val, flags.Val, kind.Val, factor.Val,
 
 5683                            numerator.Val, denominator.Val));
 
 5689bool LLParser::parseDIStringType(
MDNode *&Result, 
bool IsDistinct) {
 
 5690#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \ 
 5691  OPTIONAL(tag, DwarfTagField, (dwarf::DW_TAG_string_type));                   \ 
 5692  OPTIONAL(name, MDStringField, );                                             \ 
 5693  OPTIONAL(stringLength, MDField, );                                           \ 
 5694  OPTIONAL(stringLengthExpression, MDField, );                                 \ 
 5695  OPTIONAL(stringLocationExpression, MDField, );                               \ 
 5696  OPTIONAL(size, MDUnsignedOrMDField, (0, UINT64_MAX));                        \ 
 5697  OPTIONAL(align, MDUnsignedField, (0, UINT32_MAX));                           \ 
 5698  OPTIONAL(encoding, DwarfAttEncodingField, ); 
 5700#undef VISIT_MD_FIELDS 
 5704      (Context, tag.Val, 
name.Val, stringLength.Val, stringLengthExpression.Val,
 
 5705       stringLocationExpression.Val, 
size.getValueAsMetadata(Context),
 
 5706       align.Val, encoding.Val));
 
 5719bool LLParser::parseDIDerivedType(
MDNode *&Result, 
bool IsDistinct) {
 
 5720#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \ 
 5721  REQUIRED(tag, DwarfTagField, );                                              \ 
 5722  OPTIONAL(name, MDStringField, );                                             \ 
 5723  OPTIONAL(file, MDField, );                                                   \ 
 5724  OPTIONAL(line, LineField, );                                                 \ 
 5725  OPTIONAL(scope, MDField, );                                                  \ 
 5726  REQUIRED(baseType, MDField, );                                               \ 
 5727  OPTIONAL(size, MDUnsignedOrMDField, (0, UINT64_MAX));                        \ 
 5728  OPTIONAL(align, MDUnsignedField, (0, UINT32_MAX));                           \ 
 5729  OPTIONAL(offset, MDUnsignedOrMDField, (0, UINT64_MAX));                      \ 
 5730  OPTIONAL(flags, DIFlagField, );                                              \ 
 5731  OPTIONAL(extraData, MDField, );                                              \ 
 5732  OPTIONAL(dwarfAddressSpace, MDUnsignedField, (UINT32_MAX, UINT32_MAX));      \ 
 5733  OPTIONAL(annotations, MDField, );                                            \ 
 5734  OPTIONAL(ptrAuthKey, MDUnsignedField, (0, 7));                               \ 
 5735  OPTIONAL(ptrAuthIsAddressDiscriminated, MDBoolField, );                      \ 
 5736  OPTIONAL(ptrAuthExtraDiscriminator, MDUnsignedField, (0, 0xffff));           \ 
 5737  OPTIONAL(ptrAuthIsaPointer, MDBoolField, );                                  \ 
 5738  OPTIONAL(ptrAuthAuthenticatesNullValues, MDBoolField, ); 
 5740#undef VISIT_MD_FIELDS 
 5742  std::optional<unsigned> DWARFAddressSpace;
 
 5743  if (dwarfAddressSpace.Val != UINT32_MAX)
 
 5744    DWARFAddressSpace = dwarfAddressSpace.Val;
 
 5745  std::optional<DIDerivedType::PtrAuthData> PtrAuthData;
 
 5747    PtrAuthData.emplace(
 
 5748        (
unsigned)ptrAuthKey.Val, ptrAuthIsAddressDiscriminated.Val,
 
 5749        (
unsigned)ptrAuthExtraDiscriminator.Val, ptrAuthIsaPointer.Val,
 
 5750        ptrAuthAuthenticatesNullValues.Val);
 
 5753      DIDerivedType, (Context, tag.Val, 
name.Val, 
file.Val, line.Val, scope.Val,
 
 5754                      baseType.Val, 
size.getValueAsMetadata(Context), align.Val,
 
 5755                      offset.getValueAsMetadata(Context), DWARFAddressSpace,
 
 5756                      PtrAuthData, flags.Val, extraData.Val, annotations.Val));
 
 5760bool LLParser::parseDICompositeType(
MDNode *&Result, 
bool IsDistinct) {
 
 5761#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \ 
 5762  REQUIRED(tag, DwarfTagField, );                                              \ 
 5763  OPTIONAL(name, MDStringField, );                                             \ 
 5764  OPTIONAL(file, MDField, );                                                   \ 
 5765  OPTIONAL(line, LineField, );                                                 \ 
 5766  OPTIONAL(scope, MDField, );                                                  \ 
 5767  OPTIONAL(baseType, MDField, );                                               \ 
 5768  OPTIONAL(size, MDUnsignedOrMDField, (0, UINT64_MAX));                        \ 
 5769  OPTIONAL(align, MDUnsignedField, (0, UINT32_MAX));                           \ 
 5770  OPTIONAL(offset, MDUnsignedOrMDField, (0, UINT64_MAX));                      \ 
 5771  OPTIONAL(flags, DIFlagField, );                                              \ 
 5772  OPTIONAL(elements, MDField, );                                               \ 
 5773  OPTIONAL(runtimeLang, DwarfLangField, );                                     \ 
 5774  OPTIONAL(enumKind, DwarfEnumKindField, );                                    \ 
 5775  OPTIONAL(vtableHolder, MDField, );                                           \ 
 5776  OPTIONAL(templateParams, MDField, );                                         \ 
 5777  OPTIONAL(identifier, MDStringField, );                                       \ 
 5778  OPTIONAL(discriminator, MDField, );                                          \ 
 5779  OPTIONAL(dataLocation, MDField, );                                           \ 
 5780  OPTIONAL(associated, MDField, );                                             \ 
 5781  OPTIONAL(allocated, MDField, );                                              \ 
 5782  OPTIONAL(rank, MDSignedOrMDField, );                                         \ 
 5783  OPTIONAL(annotations, MDField, );                                            \ 
 5784  OPTIONAL(num_extra_inhabitants, MDUnsignedField, (0, UINT32_MAX));           \ 
 5785  OPTIONAL(specification, MDField, );                                          \ 
 5786  OPTIONAL(bitStride, MDField, ); 
 5788#undef VISIT_MD_FIELDS 
 5791  if (rank.isMDSignedField())
 
 5794  else if (rank.isMDField())
 
 5795    Rank = rank.getMDFieldValue();
 
 5797  std::optional<unsigned> EnumKind;
 
 5799    EnumKind = enumKind.Val;
 
 5804            Context, *identifier.Val, tag.Val, 
name.Val, 
file.Val, line.Val,
 
 5805            scope.Val, baseType.Val, 
size.getValueAsMetadata(Context),
 
 5806            align.Val, offset.getValueAsMetadata(Context), specification.Val,
 
 5807            num_extra_inhabitants.Val, flags.Val, elements.Val, runtimeLang.Val,
 
 5808            EnumKind, vtableHolder.Val, templateParams.Val, discriminator.Val,
 
 5809            dataLocation.Val, associated.Val, allocated.Val, Rank,
 
 5810            annotations.Val, bitStride.Val)) {
 
 5819      (Context, tag.Val, 
name.Val, 
file.Val, line.Val, scope.Val, baseType.Val,
 
 5820       size.getValueAsMetadata(Context), align.Val,
 
 5821       offset.getValueAsMetadata(Context), flags.Val, elements.Val,
 
 5822       runtimeLang.Val, EnumKind, vtableHolder.Val, templateParams.Val,
 
 5823       identifier.Val, discriminator.Val, dataLocation.Val, associated.Val,
 
 5824       allocated.Val, Rank, annotations.Val, specification.Val,
 
 5825       num_extra_inhabitants.Val, bitStride.Val));
 
 5829bool LLParser::parseDISubroutineType(
MDNode *&Result, 
bool IsDistinct) {
 
 5830#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \ 
 5831  OPTIONAL(flags, DIFlagField, );                                              \ 
 5832  OPTIONAL(cc, DwarfCCField, );                                                \ 
 5833  REQUIRED(types, MDField, ); 
 5835#undef VISIT_MD_FIELDS 
 5838                           (Context, flags.Val, cc.Val, types.Val));
 
 5847bool LLParser::parseDIFile(
MDNode *&Result, 
bool IsDistinct) {
 
 5851#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \ 
 5852  REQUIRED(filename, MDStringField, );                                         \ 
 5853  REQUIRED(directory, MDStringField, );                                        \ 
 5854  OPTIONAL(checksumkind, ChecksumKindField, (DIFile::CSK_MD5));                \ 
 5855  OPTIONAL(checksum, MDStringField, );                                         \ 
 5856  OPTIONAL(source, MDStringField, (MDStringField::EmptyIs::Empty)); 
 5858#undef VISIT_MD_FIELDS 
 5860  std::optional<DIFile::ChecksumInfo<MDString *>> OptChecksum;
 
 5861  if (checksumkind.Seen && checksum.Seen)
 
 5862    OptChecksum.emplace(checksumkind.Val, checksum.Val);
 
 5863  else if (checksumkind.Seen || checksum.Seen)
 
 5864    return tokError(
"'checksumkind' and 'checksum' must be provided together");
 
 5866  MDString *
Source = 
nullptr;
 
 5870      DIFile, (Context, 
filename.Val, directory.Val, OptChecksum, Source));
 
 5881bool LLParser::parseDICompileUnit(
MDNode *&Result, 
bool IsDistinct) {
 
 5883    return tokError(
"missing 'distinct', required for !DICompileUnit");
 
 5885  LocTy Loc = Lex.getLoc();
 
 5887#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \ 
 5888  REQUIRED(file, MDField, ( false));                            \ 
 5889  OPTIONAL(language, DwarfLangField, );                                        \ 
 5890  OPTIONAL(sourceLanguageName, DwarfSourceLangNameField, );                    \ 
 5891  OPTIONAL(sourceLanguageVersion, MDUnsignedField, (0, UINT32_MAX));           \ 
 5892  OPTIONAL(producer, MDStringField, );                                         \ 
 5893  OPTIONAL(isOptimized, MDBoolField, );                                        \ 
 5894  OPTIONAL(flags, MDStringField, );                                            \ 
 5895  OPTIONAL(runtimeVersion, MDUnsignedField, (0, UINT32_MAX));                  \ 
 5896  OPTIONAL(splitDebugFilename, MDStringField, );                               \ 
 5897  OPTIONAL(emissionKind, EmissionKindField, );                                 \ 
 5898  OPTIONAL(enums, MDField, );                                                  \ 
 5899  OPTIONAL(retainedTypes, MDField, );                                          \ 
 5900  OPTIONAL(globals, MDField, );                                                \ 
 5901  OPTIONAL(imports, MDField, );                                                \ 
 5902  OPTIONAL(macros, MDField, );                                                 \ 
 5903  OPTIONAL(dwoId, MDUnsignedField, );                                          \ 
 5904  OPTIONAL(splitDebugInlining, MDBoolField, = true);                           \ 
 5905  OPTIONAL(debugInfoForProfiling, MDBoolField, = false);                       \ 
 5906  OPTIONAL(nameTableKind, NameTableKindField, );                               \ 
 5907  OPTIONAL(rangesBaseAddress, MDBoolField, = false);                           \ 
 5908  OPTIONAL(sysroot, MDStringField, );                                          \ 
 5909  OPTIONAL(sdk, MDStringField, ); 
 5911#undef VISIT_MD_FIELDS 
 5913  if (!language.Seen && !sourceLanguageName.Seen)
 
 5914    return error(Loc, 
"missing one of 'language' or 'sourceLanguageName', " 
 5915                      "required for !DICompileUnit");
 
 5917  if (language.Seen && sourceLanguageName.Seen)
 
 5918    return error(Loc, 
"can only specify one of 'language' and " 
 5919                      "'sourceLanguageName' on !DICompileUnit");
 
 5921  if (sourceLanguageVersion.Seen && !sourceLanguageName.Seen)
 
 5922    return error(Loc, 
"'sourceLanguageVersion' requires an associated " 
 5923                      "'sourceLanguageName' on !DICompileUnit");
 
 5927      language.Seen ? DISourceLanguageName(language.Val)
 
 5928                    : DISourceLanguageName(sourceLanguageName.Val,
 
 5929                                           sourceLanguageVersion.Val),
 
 5930      file.Val, producer.Val, isOptimized.Val, flags.Val, runtimeVersion.Val,
 
 5931      splitDebugFilename.Val, emissionKind.Val, enums.Val, retainedTypes.Val,
 
 5932      globals.Val, imports.Val, macros.Val, dwoId.Val, splitDebugInlining.Val,
 
 5933      debugInfoForProfiling.Val, nameTableKind.Val, rangesBaseAddress.Val,
 
 5934      sysroot.Val, sdk.Val);
 
 5947bool LLParser::parseDISubprogram(
MDNode *&Result, 
bool IsDistinct) {
 
 5948  auto Loc = Lex.getLoc();
 
 5949#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \ 
 5950  OPTIONAL(scope, MDField, );                                                  \ 
 5951  OPTIONAL(name, MDStringField, );                                             \ 
 5952  OPTIONAL(linkageName, MDStringField, );                                      \ 
 5953  OPTIONAL(file, MDField, );                                                   \ 
 5954  OPTIONAL(line, LineField, );                                                 \ 
 5955  OPTIONAL(type, MDField, );                                                   \ 
 5956  OPTIONAL(isLocal, MDBoolField, );                                            \ 
 5957  OPTIONAL(isDefinition, MDBoolField, (true));                                 \ 
 5958  OPTIONAL(scopeLine, LineField, );                                            \ 
 5959  OPTIONAL(containingType, MDField, );                                         \ 
 5960  OPTIONAL(virtuality, DwarfVirtualityField, );                                \ 
 5961  OPTIONAL(virtualIndex, MDUnsignedField, (0, UINT32_MAX));                    \ 
 5962  OPTIONAL(thisAdjustment, MDSignedField, (0, INT32_MIN, INT32_MAX));          \ 
 5963  OPTIONAL(flags, DIFlagField, );                                              \ 
 5964  OPTIONAL(spFlags, DISPFlagField, );                                          \ 
 5965  OPTIONAL(isOptimized, MDBoolField, );                                        \ 
 5966  OPTIONAL(unit, MDField, );                                                   \ 
 5967  OPTIONAL(templateParams, MDField, );                                         \ 
 5968  OPTIONAL(declaration, MDField, );                                            \ 
 5969  OPTIONAL(retainedNodes, MDField, );                                          \ 
 5970  OPTIONAL(thrownTypes, MDField, );                                            \ 
 5971  OPTIONAL(annotations, MDField, );                                            \ 
 5972  OPTIONAL(targetFuncName, MDStringField, );                                   \ 
 5973  OPTIONAL(keyInstructions, MDBoolField, ); 
 5975#undef VISIT_MD_FIELDS 
 5980      spFlags.Seen ? spFlags.Val
 
 5982                                             isOptimized.Val, virtuality.Val);
 
 5983  if ((SPFlags & DISubprogram::SPFlagDefinition) && !IsDistinct)
 
 5986        "missing 'distinct', required for !DISubprogram that is a Definition");
 
 5989      (Context, scope.Val, 
name.Val, linkageName.Val, 
file.Val, line.Val,
 
 5990       type.Val, scopeLine.Val, containingType.Val, virtualIndex.Val,
 
 5991       thisAdjustment.Val, flags.Val, SPFlags, unit.Val, templateParams.Val,
 
 5992       declaration.Val, retainedNodes.Val, thrownTypes.Val, annotations.Val,
 
 5993       targetFuncName.Val, keyInstructions.Val));
 
 5999bool LLParser::parseDILexicalBlock(
MDNode *&Result, 
bool IsDistinct) {
 
 6000#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \ 
 6001  REQUIRED(scope, MDField, ( false));                           \ 
 6002  OPTIONAL(file, MDField, );                                                   \ 
 6003  OPTIONAL(line, LineField, );                                                 \ 
 6004  OPTIONAL(column, ColumnField, ); 
 6006#undef VISIT_MD_FIELDS 
 6009      DILexicalBlock, (Context, scope.Val, 
file.Val, line.Val, column.Val));
 
 6015bool LLParser::parseDILexicalBlockFile(
MDNode *&Result, 
bool IsDistinct) {
 
 6016#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \ 
 6017  REQUIRED(scope, MDField, ( false));                           \ 
 6018  OPTIONAL(file, MDField, );                                                   \ 
 6019  REQUIRED(discriminator, MDUnsignedField, (0, UINT32_MAX)); 
 6021#undef VISIT_MD_FIELDS 
 6024                           (Context, scope.Val, 
file.Val, discriminator.Val));
 
 6030bool LLParser::parseDICommonBlock(
MDNode *&Result, 
bool IsDistinct) {
 
 6031#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \ 
 6032  REQUIRED(scope, MDField, );                                                  \ 
 6033  OPTIONAL(declaration, MDField, );                                            \ 
 6034  OPTIONAL(name, MDStringField, );                                             \ 
 6035  OPTIONAL(file, MDField, );                                                   \ 
 6036  OPTIONAL(line, LineField, ); 
 6038#undef VISIT_MD_FIELDS 
 6041                           (Context, scope.Val, declaration.Val, 
name.Val,
 
 6042                            file.Val, line.Val));
 
 6048bool LLParser::parseDINamespace(
MDNode *&Result, 
bool IsDistinct) {
 
 6049#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \ 
 6050  REQUIRED(scope, MDField, );                                                  \ 
 6051  OPTIONAL(name, MDStringField, );                                             \ 
 6052  OPTIONAL(exportSymbols, MDBoolField, ); 
 6054#undef VISIT_MD_FIELDS 
 6057                           (Context, scope.Val, 
name.Val, exportSymbols.Val));
 
 6064bool LLParser::parseDIMacro(
MDNode *&Result, 
bool IsDistinct) {
 
 6065#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \ 
 6066  REQUIRED(type, DwarfMacinfoTypeField, );                                     \ 
 6067  OPTIONAL(line, LineField, );                                                 \ 
 6068  REQUIRED(name, MDStringField, );                                             \ 
 6069  OPTIONAL(value, MDStringField, ); 
 6071#undef VISIT_MD_FIELDS 
 6074                           (Context, type.Val, line.Val, 
name.Val, value.Val));
 
 6080bool LLParser::parseDIMacroFile(
MDNode *&Result, 
bool IsDistinct) {
 
 6081#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \ 
 6082  OPTIONAL(type, DwarfMacinfoTypeField, (dwarf::DW_MACINFO_start_file));       \ 
 6083  OPTIONAL(line, LineField, );                                                 \ 
 6084  REQUIRED(file, MDField, );                                                   \ 
 6085  OPTIONAL(nodes, MDField, ); 
 6087#undef VISIT_MD_FIELDS 
 6090                           (Context, type.Val, line.Val, 
file.Val, 
nodes.Val));
 
 6098bool LLParser::parseDIModule(
MDNode *&Result, 
bool IsDistinct) {
 
 6099#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \ 
 6100  REQUIRED(scope, MDField, );                                                  \ 
 6101  REQUIRED(name, MDStringField, );                                             \ 
 6102  OPTIONAL(configMacros, MDStringField, );                                     \ 
 6103  OPTIONAL(includePath, MDStringField, );                                      \ 
 6104  OPTIONAL(apinotes, MDStringField, );                                         \ 
 6105  OPTIONAL(file, MDField, );                                                   \ 
 6106  OPTIONAL(line, LineField, );                                                 \ 
 6107  OPTIONAL(isDecl, MDBoolField, ); 
 6109#undef VISIT_MD_FIELDS 
 6112                                      configMacros.Val, includePath.Val,
 
 6113                                      apinotes.Val, line.Val, isDecl.Val));
 
 6119bool LLParser::parseDITemplateTypeParameter(
MDNode *&Result, 
bool IsDistinct) {
 
 6120#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \ 
 6121  OPTIONAL(name, MDStringField, );                                             \ 
 6122  REQUIRED(type, MDField, );                                                   \ 
 6123  OPTIONAL(defaulted, MDBoolField, ); 
 6125#undef VISIT_MD_FIELDS 
 6128                           (Context, 
name.Val, type.Val, defaulted.Val));
 
 6136bool LLParser::parseDITemplateValueParameter(
MDNode *&Result, 
bool IsDistinct) {
 
 6137#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \ 
 6138  OPTIONAL(tag, DwarfTagField, (dwarf::DW_TAG_template_value_parameter));      \ 
 6139  OPTIONAL(name, MDStringField, );                                             \ 
 6140  OPTIONAL(type, MDField, );                                                   \ 
 6141  OPTIONAL(defaulted, MDBoolField, );                                          \ 
 6142  REQUIRED(value, MDField, ); 
 6145#undef VISIT_MD_FIELDS 
 6148      DITemplateValueParameter,
 
 6149      (Context, tag.Val, 
name.Val, type.Val, defaulted.Val, value.Val));
 
 6158bool LLParser::parseDIGlobalVariable(
MDNode *&Result, 
bool IsDistinct) {
 
 6159#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \ 
 6160  OPTIONAL(name, MDStringField, (MDStringField::EmptyIs::Error));              \ 
 6161  OPTIONAL(scope, MDField, );                                                  \ 
 6162  OPTIONAL(linkageName, MDStringField, );                                      \ 
 6163  OPTIONAL(file, MDField, );                                                   \ 
 6164  OPTIONAL(line, LineField, );                                                 \ 
 6165  OPTIONAL(type, MDField, );                                                   \ 
 6166  OPTIONAL(isLocal, MDBoolField, );                                            \ 
 6167  OPTIONAL(isDefinition, MDBoolField, (true));                                 \ 
 6168  OPTIONAL(templateParams, MDField, );                                         \ 
 6169  OPTIONAL(declaration, MDField, );                                            \ 
 6170  OPTIONAL(align, MDUnsignedField, (0, UINT32_MAX));                           \ 
 6171  OPTIONAL(annotations, MDField, ); 
 6173#undef VISIT_MD_FIELDS 
 6177                      (Context, scope.Val, 
name.Val, linkageName.Val, 
file.Val,
 
 6178                       line.Val, type.Val, isLocal.Val, isDefinition.Val,
 
 6179                       declaration.Val, templateParams.Val, align.Val,
 
 6191bool LLParser::parseDILocalVariable(
MDNode *&Result, 
bool IsDistinct) {
 
 6192#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \ 
 6193  REQUIRED(scope, MDField, ( false));                           \ 
 6194  OPTIONAL(name, MDStringField, );                                             \ 
 6195  OPTIONAL(arg, MDUnsignedField, (0, UINT16_MAX));                             \ 
 6196  OPTIONAL(file, MDField, );                                                   \ 
 6197  OPTIONAL(line, LineField, );                                                 \ 
 6198  OPTIONAL(type, MDField, );                                                   \ 
 6199  OPTIONAL(flags, DIFlagField, );                                              \ 
 6200  OPTIONAL(align, MDUnsignedField, (0, UINT32_MAX));                           \ 
 6201  OPTIONAL(annotations, MDField, ); 
 6203#undef VISIT_MD_FIELDS 
 6206                           (Context, scope.Val, 
name.Val, 
file.Val, line.Val,
 
 6207                            type.Val, arg.Val, flags.Val, align.Val,
 
 6214bool LLParser::parseDILabel(
MDNode *&Result, 
bool IsDistinct) {
 
 6215#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \ 
 6216  REQUIRED(scope, MDField, ( false));                           \ 
 6217  REQUIRED(name, MDStringField, );                                             \ 
 6218  REQUIRED(file, MDField, );                                                   \ 
 6219  REQUIRED(line, LineField, );                                                 \ 
 6220  OPTIONAL(column, ColumnField, );                                             \ 
 6221  OPTIONAL(isArtificial, MDBoolField, );                                       \ 
 6222  OPTIONAL(coroSuspendIdx, MDUnsignedField, ); 
 6224#undef VISIT_MD_FIELDS 
 6226  std::optional<unsigned> CoroSuspendIdx =
 
 6227      coroSuspendIdx.Seen ? std::optional<unsigned>(coroSuspendIdx.Val)
 
 6231                           (Context, scope.Val, 
name.Val, 
file.Val, line.Val,
 
 6232                            column.Val, isArtificial.Val, CoroSuspendIdx));
 
 6238bool LLParser::parseDIExpressionBody(
MDNode *&Result, 
bool IsDistinct) {
 
 6251        return tokError(Twine(
"invalid DWARF op '") + Lex.getStrVal() + 
"'");
 
 6260        return tokError(Twine(
"invalid DWARF attribute encoding '") +
 
 6261                        Lex.getStrVal() + 
"'");
 
 6264      if (Lex.getKind() != 
lltok::APSInt || Lex.getAPSIntVal().isSigned())
 
 6265        return tokError(
"expected unsigned integer");
 
 6267      auto &
U = Lex.getAPSIntVal();
 
 6269        return tokError(
"element too large, limit is " + Twine(
UINT64_MAX));
 
 6283bool LLParser::parseDIExpression(
MDNode *&Result, 
bool IsDistinct) {
 
 6285  assert(Lex.getStrVal() == 
"DIExpression" && 
"Expected '!DIExpression'");
 
 6288  return parseDIExpressionBody(Result, IsDistinct);
 
 6293bool LLParser::parseDIArgList(
Metadata *&MD, PerFunctionState *PFS) {
 
 6294  assert(PFS && 
"Expected valid function state");
 
 6305      if (parseValueAsMetadata(MD, 
"expected value-as-metadata operand", PFS))
 
 6319bool LLParser::parseDIGlobalVariableExpression(
MDNode *&Result,
 
 6321#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \ 
 6322  REQUIRED(var, MDField, );                                                    \ 
 6323  REQUIRED(expr, MDField, ); 
 6325#undef VISIT_MD_FIELDS 
 6328      GET_OR_DISTINCT(DIGlobalVariableExpression, (Context, var.Val, expr.Val));
 
 6335bool LLParser::parseDIObjCProperty(
MDNode *&Result, 
bool IsDistinct) {
 
 6336#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \ 
 6337  OPTIONAL(name, MDStringField, );                                             \ 
 6338  OPTIONAL(file, MDField, );                                                   \ 
 6339  OPTIONAL(line, LineField, );                                                 \ 
 6340  OPTIONAL(setter, MDStringField, );                                           \ 
 6341  OPTIONAL(getter, MDStringField, );                                           \ 
 6342  OPTIONAL(attributes, MDUnsignedField, (0, UINT32_MAX));                      \ 
 6343  OPTIONAL(type, MDField, ); 
 6345#undef VISIT_MD_FIELDS 
 6348                           (Context, 
name.Val, 
file.Val, line.Val, getter.Val,
 
 6349                            setter.Val, attributes.Val, type.Val));
 
 6356bool LLParser::parseDIImportedEntity(
MDNode *&Result, 
bool IsDistinct) {
 
 6357#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \ 
 6358  REQUIRED(tag, DwarfTagField, );                                              \ 
 6359  REQUIRED(scope, MDField, );                                                  \ 
 6360  OPTIONAL(entity, MDField, );                                                 \ 
 6361  OPTIONAL(file, MDField, );                                                   \ 
 6362  OPTIONAL(line, LineField, );                                                 \ 
 6363  OPTIONAL(name, MDStringField, );                                             \ 
 6364  OPTIONAL(elements, MDField, ); 
 6366#undef VISIT_MD_FIELDS 
 6369                           (Context, tag.Val, scope.Val, entity.Val, 
file.Val,
 
 6370                            line.Val, 
name.Val, elements.Val));
 
 6374#undef PARSE_MD_FIELD 
 6386bool LLParser::parseMetadataAsValue(
Value *&V, PerFunctionState &PFS) {
 
 6389  if (parseMetadata(MD, &PFS))
 
 6400bool LLParser::parseValueAsMetadata(
Metadata *&MD, 
const Twine &TypeMsg,
 
 6401                                    PerFunctionState *PFS) {
 
 6404  if (parseType(Ty, TypeMsg, Loc))
 
 6407    return error(Loc, 
"invalid metadata-value-metadata roundtrip");
 
 6410  if (parseValue(Ty, V, PFS))
 
 6425bool LLParser::parseMetadata(
Metadata *&MD, PerFunctionState *PFS) {
 
 6429    if (Lex.getStrVal() == 
"DIArgList") {
 
 6431      if (parseDIArgList(AL, PFS))
 
 6437    if (parseSpecializedMDNode(
N)) {
 
 6447    return parseValueAsMetadata(MD, 
"expected metadata operand", PFS);
 
 6457    if (parseMDString(S))
 
 6467  if (parseMDNodeTail(
N))
 
 6478                                   PerFunctionState *PFS) {
 
 6480    return error(
ID.Loc, 
"functions are not values, refer to them as pointers");
 
 6485      return error(
ID.Loc, 
"invalid use of function-local name");
 
 6486    V = PFS->getVal(
ID.UIntVal, Ty, 
ID.Loc);
 
 6487    return V == 
nullptr;
 
 6490      return error(
ID.Loc, 
"invalid use of function-local name");
 
 6491    V = PFS->getVal(
ID.StrVal, Ty, 
ID.Loc);
 
 6492    return V == 
nullptr;
 
 6495      return error(
ID.Loc, 
"invalid type for inline asm constraint string");
 
 6499        ID.FTy, 
ID.StrVal, 
ID.StrVal2, 
ID.UIntVal & 1, (
ID.UIntVal >> 1) & 1,
 
 6504    V = getGlobalVal(
ID.StrVal, Ty, 
ID.Loc);
 
 6507    return V == 
nullptr;
 
 6509    V = getGlobalVal(
ID.UIntVal, Ty, 
ID.Loc);
 
 6512    return V == 
nullptr;
 
 6515      return error(
ID.Loc, 
"integer constant must have integer type");
 
 6517    V = ConstantInt::get(Context, 
ID.APSIntVal);
 
 6522      return error(
ID.Loc, 
"floating point constant invalid for type");
 
 6528      bool IsSNAN = 
ID.APFloatVal.isSignaling();
 
 6543        APInt Payload = 
ID.APFloatVal.bitcastToAPInt();
 
 6545                                         ID.APFloatVal.isNegative(), &Payload);
 
 6548    V = ConstantFP::get(Context, 
ID.APFloatVal);
 
 6550    if (
V->getType() != Ty)
 
 6551      return error(
ID.Loc, 
"floating point constant does not have type '" +
 
 6557      return error(
ID.Loc, 
"null must be a pointer type");
 
 6563      return error(
ID.Loc, 
"invalid type for undef constant");
 
 6568      return error(
ID.Loc, 
"invalid empty array initializer");
 
 6574      return error(
ID.Loc, 
"invalid type for null constant");
 
 6577        return error(
ID.Loc, 
"invalid type for null constant");
 
 6582      return error(
ID.Loc, 
"invalid type for none constant");
 
 6588      return error(
ID.Loc, 
"invalid type for poison constant");
 
 6592    if (
ID.ConstantVal->getType() != Ty)
 
 6593      return error(
ID.Loc, 
"constant expression type mismatch: got type '" +
 
 6600      return error(
ID.Loc, 
"vector constant must have vector type");
 
 6602      return error(
ID.Loc, 
"constant expression type mismatch: got type '" +
 
 6604                               "' but expected '" +
 
 6612      if (
ST->getNumElements() != 
ID.UIntVal)
 
 6614                     "initializer with struct type has wrong # elements");
 
 6616        return error(
ID.Loc, 
"packed'ness of initializer and type don't match");
 
 6619      for (
unsigned i = 0, e = 
ID.UIntVal; i != e; ++i)
 
 6620        if (
ID.ConstantStructElts[i]->getType() != 
ST->getElementType(i))
 
 6623              "element " + Twine(i) +
 
 6624                  " of struct initializer doesn't match struct element type");
 
 6627          ST, 
ArrayRef(
ID.ConstantStructElts.get(), 
ID.UIntVal));
 
 6629      return error(
ID.Loc, 
"constant expression type mismatch");
 
 6638  auto Loc = Lex.getLoc();
 
 6639  if (parseValID(
ID, 
nullptr))
 
 6652    if (convertValIDToValue(Ty, 
ID, V, 
nullptr))
 
 6662    return error(Loc, 
"expected a constant value");
 
 6666bool LLParser::parseValue(
Type *Ty, 
Value *&V, PerFunctionState *PFS) {
 
 6669  return parseValID(
ID, PFS, Ty) ||
 
 6670         convertValIDToValue(Ty, 
ID, V, PFS);
 
 6673bool LLParser::parseTypeAndValue(
Value *&V, PerFunctionState *PFS) {
 
 6675  return parseType(Ty) || parseValue(Ty, V, PFS);
 
 6678bool LLParser::parseTypeAndBasicBlock(
BasicBlock *&BB, LocTy &
Loc,
 
 6679                                      PerFunctionState &PFS) {
 
 6682  if (parseTypeAndValue(V, PFS))
 
 6685    return error(Loc, 
"expected a basic block");
 
 6694  if (!Name.starts_with(
"llvm.dbg."))
 
 6697  return FnID == Intrinsic::dbg_declare || FnID == Intrinsic::dbg_value ||
 
 6698         FnID == Intrinsic::dbg_assign;
 
 
 6706bool LLParser::parseFunctionHeader(
Function *&Fn, 
bool IsDefine,
 
 6707                                   unsigned &FunctionNumber,
 
 6710  LocTy LinkageLoc = Lex.getLoc();
 
 6712  unsigned Visibility;
 
 6713  unsigned DLLStorageClass;
 
 6715  AttrBuilder RetAttrs(M->getContext());
 
 6718  Type *RetType = 
nullptr;
 
 6719  LocTy RetTypeLoc = Lex.getLoc();
 
 6720  if (parseOptionalLinkage(
Linkage, HasLinkage, Visibility, DLLStorageClass,
 
 6722      parseOptionalCallingConv(CC) || parseOptionalReturnAttrs(RetAttrs) ||
 
 6723      parseType(RetType, RetTypeLoc, 
true ))
 
 6732      return error(LinkageLoc, 
"invalid linkage for function definition");
 
 6742      return error(LinkageLoc, 
"invalid linkage for function declaration");
 
 6746    return error(LinkageLoc, 
"invalid function linkage type");
 
 6750    return error(LinkageLoc,
 
 6751                 "symbol with local linkage must have default visibility");
 
 6754    return error(LinkageLoc,
 
 6755                 "symbol with local linkage cannot have a DLL storage class");
 
 6758    return error(RetTypeLoc, 
"invalid function return type");
 
 6760  LocTy NameLoc = Lex.getLoc();
 
 6762  std::string FunctionName;
 
 6764    FunctionName = Lex.getStrVal();
 
 6766    FunctionNumber = Lex.getUIntVal();
 
 6767    if (checkValueID(NameLoc, 
"function", 
"@", NumberedVals.getNext(),
 
 6771    return tokError(
"expected function name");
 
 6777    return tokError(
"expected '(' in function argument list");
 
 6781  AttrBuilder FuncAttrs(M->getContext());
 
 6782  std::vector<unsigned> FwdRefAttrGrps;
 
 6785  std::string Partition;
 
 6786  MaybeAlign Alignment;
 
 6789  unsigned AddrSpace = 0;
 
 6795  if (parseArgumentList(ArgList, UnnamedArgNums, IsVarArg) ||
 
 6796      parseOptionalUnnamedAddr(UnnamedAddr) ||
 
 6797      parseOptionalProgramAddrSpace(AddrSpace) ||
 
 6798      parseFnAttributeValuePairs(FuncAttrs, FwdRefAttrGrps, 
false,
 
 6802      parseOptionalComdat(FunctionName, 
C) ||
 
 6803      parseOptionalAlignment(Alignment) ||
 
 6804      (EatIfPresent(
lltok::kw_gc) && parseStringConstant(GC)) ||
 
 6808       parseGlobalTypeAndValue(PersonalityFn)))
 
 6811  if (FuncAttrs.contains(Attribute::Builtin))
 
 6812    return error(BuiltinLoc, 
"'builtin' attribute not valid on function");
 
 6815  if (MaybeAlign 
A = FuncAttrs.getAlignment()) {
 
 6817    FuncAttrs.removeAttribute(Attribute::Alignment);
 
 6822  std::vector<Type*> ParamTypeList;
 
 6825  for (
const ArgInfo &Arg : ArgList) {
 
 6826    ParamTypeList.push_back(Arg.Ty);
 
 6827    Attrs.push_back(Arg.Attrs);
 
 6834  if (PAL.hasParamAttr(0, Attribute::StructRet) && !RetType->
isVoidTy())
 
 6835    return error(RetTypeLoc, 
"functions with 'sret' argument must return void");
 
 6841  GlobalValue *FwdFn = 
nullptr;
 
 6842  if (!FunctionName.empty()) {
 
 6845    auto FRVI = ForwardRefVals.find(FunctionName);
 
 6846    if (FRVI != ForwardRefVals.end()) {
 
 6847      FwdFn = FRVI->second.first;
 
 6849        return error(FRVI->second.second,
 
 6850                     "invalid forward reference to " 
 6853                         "' with wrong type: " 
 6857      ForwardRefVals.erase(FRVI);
 
 6858    } 
else if ((Fn = M->getFunction(FunctionName))) {
 
 6860      return error(NameLoc,
 
 6861                   "invalid redefinition of function '" + FunctionName + 
"'");
 
 6862    } 
else if (M->getNamedValue(FunctionName)) {
 
 6863      return error(NameLoc, 
"redefinition of function '@" + FunctionName + 
"'");
 
 6869    if (FunctionNumber == (
unsigned)-1)
 
 6870      FunctionNumber = NumberedVals.getNext();
 
 6874    auto I = ForwardRefValIDs.find(FunctionNumber);
 
 6875    if (
I != ForwardRefValIDs.end()) {
 
 6876      FwdFn = 
I->second.first;
 
 6878        return error(NameLoc, 
"type of definition and forward reference of '@" +
 
 6879                                  Twine(FunctionNumber) +
 
 6884      ForwardRefValIDs.erase(
I);
 
 6893  if (FunctionName.empty())
 
 6894    NumberedVals.add(FunctionNumber, Fn);
 
 6909  if (!
GC.empty()) Fn->
setGC(GC);
 
 6912  ForwardRefAttrGroups[Fn] = FwdRefAttrGrps;
 
 6916  for (
unsigned i = 0, e = ArgList.size(); i != e; ++i, ++ArgIt) {
 
 6918    if (ArgList[i].
Name.empty()) 
continue;
 
 6921    ArgIt->
setName(ArgList[i].Name);
 
 6923    if (ArgIt->
getName() != ArgList[i].Name)
 
 6924      return error(ArgList[i].Loc,
 
 6925                   "redefinition of argument '%" + ArgList[i].Name + 
"'");
 
 6938  if (FunctionName.empty()) {
 
 6940    ID.UIntVal = FunctionNumber;
 
 6943    ID.StrVal = FunctionName;
 
 6945  auto Blocks = ForwardRefBlockAddresses.find(
ID);
 
 6946  if (Blocks != ForwardRefBlockAddresses.end())
 
 6947    return error(Blocks->first.Loc,
 
 6948                 "cannot take blockaddress inside a declaration");
 
 6952bool LLParser::PerFunctionState::resolveForwardRefBlockAddresses() {
 
 6954  if (FunctionNumber == -1) {
 
 6956    ID.StrVal = std::string(F.getName());
 
 6959    ID.UIntVal = FunctionNumber;
 
 6962  auto Blocks = P.ForwardRefBlockAddresses.find(
ID);
 
 6963  if (Blocks == P.ForwardRefBlockAddresses.end())
 
 6966  for (
const auto &
I : Blocks->second) {
 
 6967    const ValID &BBID = 
I.first;
 
 6968    GlobalValue *GV = 
I.second;
 
 6971           "Expected local id or name");
 
 6978      return P.error(BBID.
Loc, 
"referenced value is not a basic block");
 
 6981    ResolvedVal = P.checkValidVariableType(BBID.
Loc, BBID.
StrVal, GV->
getType(),
 
 6989  P.ForwardRefBlockAddresses.erase(Blocks);
 
 6995bool LLParser::parseFunctionBody(Function &Fn, 
unsigned FunctionNumber,
 
 6996                                 ArrayRef<unsigned> UnnamedArgNums) {
 
 6998    return tokError(
"expected '{' in function body");
 
 7001  PerFunctionState PFS(*
this, Fn, FunctionNumber, UnnamedArgNums);
 
 7005  if (PFS.resolveForwardRefBlockAddresses())
 
 7011    return tokError(
"function body requires at least one basic block");
 
 7015    if (parseBasicBlock(PFS))
 
 7019    if (parseUseListOrder(&PFS))
 
 7026  return PFS.finishFunction();
 
 7031bool LLParser::parseBasicBlock(PerFunctionState &PFS) {
 
 7032  FileLoc BBStart(Lex.getTokLineColumnPos());
 
 7037  LocTy NameLoc = Lex.getLoc();
 
 7039    Name = Lex.getStrVal();
 
 7042    NameID = Lex.getUIntVal();
 
 7046  BasicBlock *BB = PFS.defineBB(Name, NameID, NameLoc);
 
 7050  std::string NameStr;
 
 7055  auto DeleteDbgRecord = [](DbgRecord *DR) { DR->deleteRecord(); };
 
 7056  using DbgRecordPtr = std::unique_ptr<DbgRecord, 
decltype(DeleteDbgRecord)>;
 
 7063      if (SeenOldDbgInfoFormat)
 
 7064        return error(Lex.getLoc(), 
"debug record should not appear in a module " 
 7065                                   "containing debug info intrinsics");
 
 7066      SeenNewDbgInfoFormat = 
true;
 
 7070      if (parseDebugRecord(DR, PFS))
 
 7072      TrailingDbgRecord.emplace_back(DR, DeleteDbgRecord);
 
 7075    FileLoc InstStart(Lex.getTokLineColumnPos());
 
 7078    LocTy NameLoc = Lex.getLoc();
 
 7083      NameID = Lex.getUIntVal();
 
 7085      if (parseToken(
lltok::equal, 
"expected '=' after instruction id"))
 
 7088      NameStr = Lex.getStrVal();
 
 7090      if (parseToken(
lltok::equal, 
"expected '=' after instruction name"))
 
 7094    switch (parseInstruction(Inst, BB, PFS)) {
 
 7097    case InstError: 
return true;
 
 7104        if (parseInstructionMetadata(*Inst))
 
 7107    case InstExtraComma:
 
 7112      if (parseInstructionMetadata(*Inst))
 
 7118    if (PFS.setInstName(NameID, NameStr, NameLoc, Inst))
 
 7122    for (DbgRecordPtr &DR : TrailingDbgRecord)
 
 7124    TrailingDbgRecord.clear();
 
 7125    if (ParserContext) {
 
 7126      ParserContext->addInstructionLocation(
 
 7127          Inst, FileLocRange(InstStart, Lex.getPrevTokEndLineColumnPos()));
 
 7132    ParserContext->addBlockLocation(
 
 7133        BB, FileLocRange(BBStart, Lex.getPrevTokEndLineColumnPos()));
 
 7135  assert(TrailingDbgRecord.empty() &&
 
 7136         "All debug values should have been attached to an instruction.");
 
 7145bool LLParser::parseDebugRecord(DbgRecord *&DR, PerFunctionState &PFS) {
 
 7148  LocTy DVRLoc = Lex.getLoc();
 
 7150    return error(DVRLoc, 
"expected debug record type here");
 
 7151  RecordKind 
RecordType = StringSwitch<RecordKind>(Lex.getStrVal())
 
 7152                              .Case(
"declare", RecordKind::ValueKind)
 
 7153                              .Case(
"value", RecordKind::ValueKind)
 
 7154                              .Case(
"assign", RecordKind::ValueKind)
 
 7155                              .Case(
"label", RecordKind::LabelKind);
 
 7164    if (parseMDNode(Label))
 
 7169    if (parseMDNode(DbgLoc))
 
 7177  LocType 
ValueType = StringSwitch<LocType>(Lex.getStrVal())
 
 7178                          .Case(
"declare", LocType::Declare)
 
 7179                          .Case(
"value", LocType::Value)
 
 7180                          .Case(
"assign", LocType::Assign);
 
 7188  if (parseMetadata(ValLocMD, &PFS))
 
 7195  if (parseMDNode(Variable))
 
 7202  if (parseMDNode(Expression))
 
 7208  MDNode *AssignID = 
nullptr;
 
 7209  Metadata *AddressLocation = 
nullptr;
 
 7210  MDNode *AddressExpression = 
nullptr;
 
 7213    if (parseMDNode(AssignID))
 
 7219    if (parseMetadata(AddressLocation, &PFS))
 
 7225    if (parseMDNode(AddressExpression))
 
 7239      ValueType, ValLocMD, Variable, Expression, AssignID, AddressLocation,
 
 7249int LLParser::parseInstruction(Instruction *&Inst, BasicBlock *BB,
 
 7250                               PerFunctionState &PFS) {
 
 7253    return tokError(
"found end of file when expecting more instructions");
 
 7254  LocTy Loc = Lex.getLoc();
 
 7255  unsigned KeywordVal = Lex.getUIntVal();
 
 7260    return error(Loc, 
"expected instruction opcode");
 
 7264    return parseRet(Inst, BB, PFS);
 
 7266    return parseBr(Inst, PFS);
 
 7268    return parseSwitch(Inst, PFS);
 
 7270    return parseIndirectBr(Inst, PFS);
 
 7272    return parseInvoke(Inst, PFS);
 
 7274    return parseResume(Inst, PFS);
 
 7276    return parseCleanupRet(Inst, PFS);
 
 7278    return parseCatchRet(Inst, PFS);
 
 7280    return parseCatchSwitch(Inst, PFS);
 
 7282    return parseCatchPad(Inst, PFS);
 
 7284    return parseCleanupPad(Inst, PFS);
 
 7286    return parseCallBr(Inst, PFS);
 
 7289    FastMathFlags FMF = EatFastMathFlagsIfPresent();
 
 7290    int Res = parseUnaryOp(Inst, PFS, KeywordVal,  
true);
 
 7306    if (parseArithmetic(Inst, PFS, KeywordVal,  
false))
 
 7318    FastMathFlags FMF = EatFastMathFlagsIfPresent();
 
 7319    int Res = parseArithmetic(Inst, PFS, KeywordVal,  
true);
 
 7333    if (parseArithmetic(Inst, PFS, KeywordVal,  
false))
 
 7341    return parseArithmetic(Inst, PFS, KeywordVal,
 
 7345    if (parseLogical(Inst, PFS, KeywordVal))
 
 7353    return parseLogical(Inst, PFS, KeywordVal);
 
 7356    if (parseCompare(Inst, PFS, KeywordVal))
 
 7363    FastMathFlags FMF = EatFastMathFlagsIfPresent();
 
 7364    int Res = parseCompare(Inst, PFS, KeywordVal);
 
 7376    bool Res = parseCast(Inst, PFS, KeywordVal);
 
 7388    if (parseCast(Inst, PFS, KeywordVal))
 
 7405    return parseCast(Inst, PFS, KeywordVal);
 
 7408    FastMathFlags FMF = EatFastMathFlagsIfPresent();
 
 7409    if (parseCast(Inst, PFS, KeywordVal))
 
 7418    FastMathFlags FMF = EatFastMathFlagsIfPresent();
 
 7419    int Res = parseSelect(Inst, PFS);
 
 7424        return error(Loc, 
"fast-math-flags specified for select without " 
 7425                          "floating-point scalar or vector return type");
 
 7431    return parseVAArg(Inst, PFS);
 
 7433    return parseExtractElement(Inst, PFS);
 
 7435    return parseInsertElement(Inst, PFS);
 
 7437    return parseShuffleVector(Inst, PFS);
 
 7439    FastMathFlags FMF = EatFastMathFlagsIfPresent();
 
 7440    int Res = parsePHI(Inst, PFS);
 
 7445        return error(Loc, 
"fast-math-flags specified for phi without " 
 7446                          "floating-point scalar or vector return type");
 
 7452    return parseLandingPad(Inst, PFS);
 
 7454    return parseFreeze(Inst, PFS);
 
 7466    return parseAlloc(Inst, PFS);
 
 7468    return parseLoad(Inst, PFS);
 
 7470    return parseStore(Inst, PFS);
 
 7472    return parseCmpXchg(Inst, PFS);
 
 7474    return parseAtomicRMW(Inst, PFS);
 
 7476    return parseFence(Inst, PFS);
 
 7478    return parseGetElementPtr(Inst, PFS);
 
 7480    return parseExtractValue(Inst, PFS);
 
 7482    return parseInsertValue(Inst, PFS);
 
 7487bool LLParser::parseCmpPredicate(
unsigned &
P, 
unsigned Opc) {
 
 7488  if (
Opc == Instruction::FCmp) {
 
 7489    switch (Lex.getKind()) {
 
 7491      return tokError(
"expected fcmp predicate (e.g. 'oeq')");
 
 7510    switch (Lex.getKind()) {
 
 7512      return tokError(
"expected icmp predicate (e.g. 'eq')");
 
 7536bool LLParser::parseRet(Instruction *&Inst, BasicBlock *BB,
 
 7537                        PerFunctionState &PFS) {
 
 7538  SMLoc TypeLoc = Lex.getLoc();
 
 7540  if (parseType(Ty, 
true ))
 
 7543  Type *ResType = PFS.getFunction().getReturnType();
 
 7547      return error(TypeLoc, 
"value doesn't match function result type '" +
 
 7555  if (parseValue(Ty, RV, PFS))
 
 7559    return error(TypeLoc, 
"value doesn't match function result type '" +
 
 7569bool LLParser::parseBr(Instruction *&Inst, PerFunctionState &PFS) {
 
 7573  if (parseTypeAndValue(Op0, Loc, PFS))
 
 7582    return error(Loc, 
"branch condition must have 'i1' type");
 
 7584  if (parseToken(
lltok::comma, 
"expected ',' after branch condition") ||
 
 7585      parseTypeAndBasicBlock(Op1, Loc, PFS) ||
 
 7586      parseToken(
lltok::comma, 
"expected ',' after true destination") ||
 
 7587      parseTypeAndBasicBlock(Op2, Loc2, PFS))
 
 7599bool LLParser::parseSwitch(Instruction *&Inst, PerFunctionState &PFS) {
 
 7600  LocTy CondLoc, BBLoc;
 
 7603  if (parseTypeAndValue(
Cond, CondLoc, PFS) ||
 
 7604      parseToken(
lltok::comma, 
"expected ',' after switch condition") ||
 
 7605      parseTypeAndBasicBlock(DefaultBB, BBLoc, PFS) ||
 
 7609  if (!
Cond->getType()->isIntegerTy())
 
 7610    return error(CondLoc, 
"switch condition must have integer type");
 
 7613  SmallPtrSet<Value*, 32> SeenCases;
 
 7619    if (parseTypeAndValue(Constant, CondLoc, PFS) ||
 
 7620        parseToken(
lltok::comma, 
"expected ',' after case value") ||
 
 7621        parseTypeAndBasicBlock(DestBB, PFS))
 
 7624    if (!SeenCases.
insert(Constant).second)
 
 7625      return error(CondLoc, 
"duplicate case value in switch");
 
 7627      return error(CondLoc, 
"case value is not a constant integer");
 
 7635  for (
const auto &[OnVal, Dest] : Table)
 
 7636    SI->addCase(OnVal, Dest);
 
 7644bool LLParser::parseIndirectBr(Instruction *&Inst, PerFunctionState &PFS) {
 
 7647  if (parseTypeAndValue(
Address, AddrLoc, PFS) ||
 
 7648      parseToken(
lltok::comma, 
"expected ',' after indirectbr address") ||
 
 7652  if (!
Address->getType()->isPointerTy())
 
 7653    return error(AddrLoc, 
"indirectbr address must have pointer type");
 
 7656  SmallVector<BasicBlock*, 16> DestList;
 
 7660    if (parseTypeAndBasicBlock(DestBB, PFS))
 
 7665      if (parseTypeAndBasicBlock(DestBB, PFS))
 
 7671  if (parseToken(
lltok::rsquare, 
"expected ']' at end of block list"))
 
 7675  for (BasicBlock *Dest : DestList)
 
 7685                                   FunctionType *&FuncTy) {
 
 7691    for (
const ParamInfo &Arg : ArgList)
 
 7705bool LLParser::parseInvoke(Instruction *&Inst, PerFunctionState &PFS) {
 
 7706  LocTy CallLoc = Lex.getLoc();
 
 7707  AttrBuilder RetAttrs(M->getContext()), FnAttrs(M->getContext());
 
 7708  std::vector<unsigned> FwdRefAttrGrps;
 
 7711  unsigned InvokeAddrSpace;
 
 7712  Type *RetType = 
nullptr;
 
 7719  if (parseOptionalCallingConv(CC) || parseOptionalReturnAttrs(RetAttrs) ||
 
 7720      parseOptionalProgramAddrSpace(InvokeAddrSpace) ||
 
 7721      parseType(RetType, RetTypeLoc, 
true ) ||
 
 7722      parseValID(CalleeID, &PFS) || parseParameterList(ArgList, PFS) ||
 
 7723      parseFnAttributeValuePairs(FnAttrs, FwdRefAttrGrps, 
false,
 
 7725      parseOptionalOperandBundles(BundleList, PFS) ||
 
 7727      parseTypeAndBasicBlock(NormalBB, PFS) ||
 
 7729      parseTypeAndBasicBlock(UnwindBB, PFS))
 
 7736  if (resolveFunctionType(RetType, ArgList, Ty))
 
 7737    return error(RetTypeLoc, 
"Invalid result type for LLVM function");
 
 7743  if (convertValIDToValue(
PointerType::get(Context, InvokeAddrSpace), CalleeID,
 
 7748  SmallVector<Value *, 8> 
Args;
 
 7755  for (
const ParamInfo &Arg : ArgList) {
 
 7756    Type *ExpectedTy = 
nullptr;
 
 7759    } 
else if (!Ty->isVarArg()) {
 
 7760      return error(Arg.Loc, 
"too many arguments specified");
 
 7763    if (ExpectedTy && ExpectedTy != Arg.V->getType())
 
 7764      return error(Arg.Loc, 
"argument is not of expected type '" +
 
 7766    Args.push_back(Arg.V);
 
 7771    return error(CallLoc, 
"not enough parameters specified for call");
 
 7780  II->setCallingConv(CC);
 
 7781  II->setAttributes(PAL);
 
 7782  ForwardRefAttrGroups[
II] = FwdRefAttrGrps;
 
 7789bool LLParser::parseResume(Instruction *&Inst, PerFunctionState &PFS) {
 
 7791  if (parseTypeAndValue(Exn, ExnLoc, PFS))
 
 7799bool LLParser::parseExceptionArgs(SmallVectorImpl<Value *> &Args,
 
 7800                                  PerFunctionState &PFS) {
 
 7801  if (parseToken(
lltok::lsquare, 
"expected '[' in catchpad/cleanuppad"))
 
 7806    if (!
Args.empty() &&
 
 7807        parseToken(
lltok::comma, 
"expected ',' in argument list"))
 
 7812    Type *ArgTy = 
nullptr;
 
 7813    if (parseType(ArgTy, ArgLoc))
 
 7818      if (parseMetadataAsValue(V, PFS))
 
 7821      if (parseValue(ArgTy, V, PFS))
 
 7833bool LLParser::parseCleanupRet(Instruction *&Inst, PerFunctionState &PFS) {
 
 7834  Value *CleanupPad = 
nullptr;
 
 7836  if (parseToken(
lltok::kw_from, 
"expected 'from' after cleanupret"))
 
 7851    if (parseTypeAndBasicBlock(UnwindBB, PFS)) {
 
 7862bool LLParser::parseCatchRet(Instruction *&Inst, PerFunctionState &PFS) {
 
 7863  Value *CatchPad = 
nullptr;
 
 7865  if (parseToken(
lltok::kw_from, 
"expected 'from' after catchret"))
 
 7872  if (parseToken(
lltok::kw_to, 
"expected 'to' in catchret") ||
 
 7873      parseTypeAndBasicBlock(BB, PFS))
 
 7882bool LLParser::parseCatchSwitch(Instruction *&Inst, PerFunctionState &PFS) {
 
 7890    return tokError(
"expected scope value for catchswitch");
 
 7895  if (parseToken(
lltok::lsquare, 
"expected '[' with catchswitch labels"))
 
 7901    if (parseTypeAndBasicBlock(DestBB, PFS))
 
 7906  if (parseToken(
lltok::rsquare, 
"expected ']' after catchswitch labels"))
 
 7909  if (parseToken(
lltok::kw_unwind, 
"expected 'unwind' after catchswitch scope"))
 
 7917    if (parseTypeAndBasicBlock(UnwindBB, PFS))
 
 7923  for (BasicBlock *DestBB : Table)
 
 7924    CatchSwitch->addHandler(DestBB);
 
 7931bool LLParser::parseCatchPad(Instruction *&Inst, PerFunctionState &PFS) {
 
 7932  Value *CatchSwitch = 
nullptr;
 
 7938    return tokError(
"expected scope value for catchpad");
 
 7943  SmallVector<Value *, 8> 
Args;
 
 7944  if (parseExceptionArgs(Args, PFS))
 
 7953bool LLParser::parseCleanupPad(Instruction *&Inst, PerFunctionState &PFS) {
 
 7954  Value *ParentPad = 
nullptr;
 
 7961    return tokError(
"expected scope value for cleanuppad");
 
 7966  SmallVector<Value *, 8> 
Args;
 
 7967  if (parseExceptionArgs(Args, PFS))
 
 7983bool LLParser::parseUnaryOp(Instruction *&Inst, PerFunctionState &PFS,
 
 7984                            unsigned Opc, 
bool IsFP) {
 
 7986  if (parseTypeAndValue(
LHS, Loc, PFS))
 
 7993    return error(Loc, 
"invalid operand type for instruction");
 
 8003bool LLParser::parseCallBr(Instruction *&Inst, PerFunctionState &PFS) {
 
 8004  LocTy CallLoc = Lex.getLoc();
 
 8005  AttrBuilder RetAttrs(M->getContext()), FnAttrs(M->getContext());
 
 8006  std::vector<unsigned> FwdRefAttrGrps;
 
 8009  Type *RetType = 
nullptr;
 
 8016  if (parseOptionalCallingConv(CC) || parseOptionalReturnAttrs(RetAttrs) ||
 
 8017      parseType(RetType, RetTypeLoc, 
true ) ||
 
 8018      parseValID(CalleeID, &PFS) || parseParameterList(ArgList, PFS) ||
 
 8019      parseFnAttributeValuePairs(FnAttrs, FwdRefAttrGrps, 
false,
 
 8021      parseOptionalOperandBundles(BundleList, PFS) ||
 
 8023      parseTypeAndBasicBlock(DefaultDest, PFS) ||
 
 8028  SmallVector<BasicBlock *, 16> IndirectDests;
 
 8032    if (parseTypeAndBasicBlock(DestBB, PFS))
 
 8037      if (parseTypeAndBasicBlock(DestBB, PFS))
 
 8043  if (parseToken(
lltok::rsquare, 
"expected ']' at end of block list"))
 
 8050  if (resolveFunctionType(RetType, ArgList, Ty))
 
 8051    return error(RetTypeLoc, 
"Invalid result type for LLVM function");
 
 8062  SmallVector<Value *, 8> 
Args;
 
 8069  for (
const ParamInfo &Arg : ArgList) {
 
 8070    Type *ExpectedTy = 
nullptr;
 
 8073    } 
else if (!Ty->isVarArg()) {
 
 8074      return error(Arg.Loc, 
"too many arguments specified");
 
 8077    if (ExpectedTy && ExpectedTy != Arg.V->getType())
 
 8078      return error(Arg.Loc, 
"argument is not of expected type '" +
 
 8080    Args.push_back(Arg.V);
 
 8085    return error(CallLoc, 
"not enough parameters specified for call");
 
 8097  ForwardRefAttrGroups[CBI] = FwdRefAttrGrps;
 
 8111bool LLParser::parseArithmetic(Instruction *&Inst, PerFunctionState &PFS,
 
 8112                               unsigned Opc, 
bool IsFP) {
 
 8114  if (parseTypeAndValue(
LHS, Loc, PFS) ||
 
 8115      parseToken(
lltok::comma, 
"expected ',' in arithmetic operation") ||
 
 8123    return error(Loc, 
"invalid operand type for instruction");
 
 8131bool LLParser::parseLogical(Instruction *&Inst, PerFunctionState &PFS,
 
 8134  if (parseTypeAndValue(
LHS, Loc, PFS) ||
 
 8135      parseToken(
lltok::comma, 
"expected ',' in logical operation") ||
 
 8141                 "instruction requires integer or integer vector operands");
 
 8150bool LLParser::parseCompare(Instruction *&Inst, PerFunctionState &PFS,
 
 8156  if (parseCmpPredicate(Pred, 
Opc) || parseTypeAndValue(
LHS, Loc, PFS) ||
 
 8157      parseToken(
lltok::comma, 
"expected ',' after compare value") ||
 
 8161  if (
Opc == Instruction::FCmp) {
 
 8163      return error(Loc, 
"fcmp requires floating point operands");
 
 8166    assert(
Opc == Instruction::ICmp && 
"Unknown opcode for CmpInst!");
 
 8169      return error(Loc, 
"icmp requires integer operands");
 
 8181bool LLParser::parseCast(Instruction *&Inst, PerFunctionState &PFS,
 
 8185  Type *DestTy = 
nullptr;
 
 8186  if (parseTypeAndValue(
Op, Loc, PFS) ||
 
 8187      parseToken(
lltok::kw_to, 
"expected 'to' after cast value") ||
 
 8192    return error(Loc, 
"invalid cast opcode for cast from '" +
 
 8201bool LLParser::parseSelect(Instruction *&Inst, PerFunctionState &PFS) {
 
 8203  Value *Op0, *Op1, *Op2;
 
 8204  if (parseTypeAndValue(Op0, Loc, PFS) ||
 
 8205      parseToken(
lltok::comma, 
"expected ',' after select condition") ||
 
 8206      parseTypeAndValue(Op1, PFS) ||
 
 8207      parseToken(
lltok::comma, 
"expected ',' after select value") ||
 
 8208      parseTypeAndValue(Op2, PFS))
 
 8212    return error(Loc, Reason);
 
 8220bool LLParser::parseVAArg(Instruction *&Inst, PerFunctionState &PFS) {
 
 8222  Type *EltTy = 
nullptr;
 
 8224  if (parseTypeAndValue(
Op, PFS) ||
 
 8225      parseToken(
lltok::comma, 
"expected ',' after vaarg operand") ||
 
 8226      parseType(EltTy, TypeLoc))
 
 8230    return error(TypeLoc, 
"va_arg requires operand with first class type");
 
 8232  Inst = 
new VAArgInst(
Op, EltTy);
 
 8238bool LLParser::parseExtractElement(Instruction *&Inst, PerFunctionState &PFS) {
 
 8241  if (parseTypeAndValue(Op0, Loc, PFS) ||
 
 8242      parseToken(
lltok::comma, 
"expected ',' after extract value") ||
 
 8243      parseTypeAndValue(Op1, PFS))
 
 8247    return error(Loc, 
"invalid extractelement operands");
 
 8255bool LLParser::parseInsertElement(Instruction *&Inst, PerFunctionState &PFS) {
 
 8257  Value *Op0, *Op1, *Op2;
 
 8258  if (parseTypeAndValue(Op0, Loc, PFS) ||
 
 8259      parseToken(
lltok::comma, 
"expected ',' after insertelement value") ||
 
 8260      parseTypeAndValue(Op1, PFS) ||
 
 8261      parseToken(
lltok::comma, 
"expected ',' after insertelement value") ||
 
 8262      parseTypeAndValue(Op2, PFS))
 
 8266    return error(Loc, 
"invalid insertelement operands");
 
 8274bool LLParser::parseShuffleVector(Instruction *&Inst, PerFunctionState &PFS) {
 
 8276  Value *Op0, *Op1, *Op2;
 
 8277  if (parseTypeAndValue(Op0, Loc, PFS) ||
 
 8278      parseToken(
lltok::comma, 
"expected ',' after shuffle mask") ||
 
 8279      parseTypeAndValue(Op1, PFS) ||
 
 8280      parseToken(
lltok::comma, 
"expected ',' after shuffle value") ||
 
 8281      parseTypeAndValue(Op2, PFS))
 
 8285    return error(Loc, 
"invalid shufflevector operands");
 
 8287  Inst = 
new ShuffleVectorInst(Op0, Op1, Op2);
 
 8293int LLParser::parsePHI(Instruction *&Inst, PerFunctionState &PFS) {
 
 8297  if (parseType(Ty, TypeLoc))
 
 8301    return error(TypeLoc, 
"phi node must have first class type");
 
 8304  bool AteExtraComma = 
false;
 
 8316      AteExtraComma = 
true;
 
 8320    if (parseToken(
lltok::lsquare, 
"expected '[' in phi value list") ||
 
 8321        parseValue(Ty, Op0, PFS) ||
 
 8322        parseToken(
lltok::comma, 
"expected ',' after insertelement value") ||
 
 8331  for (
const auto &[Val, BB] : PHIVals)
 
 8334  return AteExtraComma ? InstExtraComma : InstNormal;
 
 8343bool LLParser::parseLandingPad(Instruction *&Inst, PerFunctionState &PFS) {
 
 8346  if (parseType(Ty, TyLoc))
 
 8359      return tokError(
"expected 'catch' or 'filter' clause type");
 
 8363    if (parseTypeAndValue(V, VLoc, PFS))
 
 8370        return error(VLoc, 
"'catch' clause has an invalid type");
 
 8373        return error(VLoc, 
"'filter' clause has an invalid type");
 
 8378      return error(VLoc, 
"clause argument must be a constant");
 
 8382  Inst = LP.release();
 
 8388bool LLParser::parseFreeze(Instruction *&Inst, PerFunctionState &PFS) {
 
 8391  if (parseTypeAndValue(
Op, Loc, PFS))
 
 8394  Inst = 
new FreezeInst(
Op);
 
 8407bool LLParser::parseCall(Instruction *&Inst, PerFunctionState &PFS,
 
 8409  AttrBuilder RetAttrs(M->getContext()), FnAttrs(M->getContext());
 
 8410  std::vector<unsigned> FwdRefAttrGrps;
 
 8412  unsigned CallAddrSpace;
 
 8414  Type *RetType = 
nullptr;
 
 8419  LocTy CallLoc = Lex.getLoc();
 
 8423                 "expected 'tail call', 'musttail call', or 'notail call'"))
 
 8426  FastMathFlags FMF = EatFastMathFlagsIfPresent();
 
 8428  if (parseOptionalCallingConv(CC) || parseOptionalReturnAttrs(RetAttrs) ||
 
 8429      parseOptionalProgramAddrSpace(CallAddrSpace) ||
 
 8430      parseType(RetType, RetTypeLoc, 
true ) ||
 
 8431      parseValID(CalleeID, &PFS) ||
 
 8433                         PFS.getFunction().isVarArg()) ||
 
 8434      parseFnAttributeValuePairs(FnAttrs, FwdRefAttrGrps, 
false, BuiltinLoc) ||
 
 8435      parseOptionalOperandBundles(BundleList, PFS))
 
 8442  if (resolveFunctionType(RetType, ArgList, Ty))
 
 8443    return error(RetTypeLoc, 
"Invalid result type for LLVM function");
 
 8449  if (convertValIDToValue(
PointerType::get(Context, CallAddrSpace), CalleeID,
 
 8456  SmallVector<Value*, 8> 
Args;
 
 8462  for (
const ParamInfo &Arg : ArgList) {
 
 8463    Type *ExpectedTy = 
nullptr;
 
 8466    } 
else if (!Ty->isVarArg()) {
 
 8467      return error(Arg.Loc, 
"too many arguments specified");
 
 8470    if (ExpectedTy && ExpectedTy != Arg.V->getType())
 
 8471      return error(Arg.Loc, 
"argument is not of expected type '" +
 
 8473    Args.push_back(Arg.V);
 
 8474    Attrs.push_back(Arg.Attrs);
 
 8478    return error(CallLoc, 
"not enough parameters specified for call");
 
 8491      return error(CallLoc, 
"fast-math-flags specified for call without " 
 8492                            "floating-point scalar or vector return type");
 
 8499    if (SeenNewDbgInfoFormat) {
 
 8501      return error(CallLoc, 
"llvm.dbg intrinsic should not appear in a module " 
 8502                            "using non-intrinsic debug info");
 
 8504    SeenOldDbgInfoFormat = 
true;
 
 8507  ForwardRefAttrGroups[CI] = FwdRefAttrGrps;
 
 8519int LLParser::parseAlloc(Instruction *&Inst, PerFunctionState &PFS) {
 
 8521  LocTy SizeLoc, TyLoc, ASLoc;
 
 8522  MaybeAlign Alignment;
 
 8523  unsigned AddrSpace = 0;
 
 8526  bool IsInAlloca = EatIfPresent(lltok::kw_inalloca);
 
 8527  bool IsSwiftError = EatIfPresent(lltok::kw_swifterror);
 
 8529  if (parseType(Ty, TyLoc))
 
 8533    return error(TyLoc, 
"invalid type for alloca");
 
 8535  bool AteExtraComma = 
false;
 
 8537    if (Lex.getKind() == lltok::kw_align) {
 
 8538      if (parseOptionalAlignment(Alignment))
 
 8540      if (parseOptionalCommaAddrSpace(AddrSpace, ASLoc, AteExtraComma))
 
 8543      ASLoc = Lex.getLoc();
 
 8544      if (parseOptionalAddrSpace(AddrSpace))
 
 8547      AteExtraComma = 
true;
 
 8549      if (parseTypeAndValue(
Size, SizeLoc, PFS))
 
 8552        if (Lex.getKind() == lltok::kw_align) {
 
 8553          if (parseOptionalAlignment(Alignment))
 
 8555          if (parseOptionalCommaAddrSpace(AddrSpace, ASLoc, AteExtraComma))
 
 8558          ASLoc = Lex.getLoc();
 
 8559          if (parseOptionalAddrSpace(AddrSpace))
 
 8562          AteExtraComma = 
true;
 
 8568  if (
Size && !
Size->getType()->isIntegerTy())
 
 8569    return error(SizeLoc, 
"element count must have integer type");
 
 8571  SmallPtrSet<Type *, 4> Visited;
 
 8572  if (!Alignment && !Ty->
isSized(&Visited))
 
 8573    return error(TyLoc, 
"Cannot allocate unsized type");
 
 8575    Alignment = M->getDataLayout().getPrefTypeAlign(Ty);
 
 8576  AllocaInst *AI = 
new AllocaInst(Ty, AddrSpace, 
Size, *Alignment);
 
 8580  return AteExtraComma ? InstExtraComma : InstNormal;
 
 8587int LLParser::parseLoad(Instruction *&Inst, PerFunctionState &PFS) {
 
 8589  MaybeAlign Alignment;
 
 8590  bool AteExtraComma = 
false;
 
 8591  bool isAtomic = 
false;
 
 8600  bool isVolatile = 
false;
 
 8607  LocTy ExplicitTypeLoc = Lex.getLoc();
 
 8608  if (parseType(Ty) ||
 
 8609      parseToken(
lltok::comma, 
"expected comma after load's type") ||
 
 8610      parseTypeAndValue(Val, Loc, PFS) ||
 
 8611      parseScopeAndOrdering(isAtomic, SSID, Ordering) ||
 
 8612      parseOptionalCommaAlign(Alignment, AteExtraComma))
 
 8616    return error(Loc, 
"load operand must be a pointer to a first class type");
 
 8617  if (isAtomic && !Alignment)
 
 8618    return error(Loc, 
"atomic load must have explicit non-zero alignment");
 
 8621    return error(Loc, 
"atomic load cannot use Release ordering");
 
 8623  SmallPtrSet<Type *, 4> Visited;
 
 8624  if (!Alignment && !Ty->
isSized(&Visited))
 
 8625    return error(ExplicitTypeLoc, 
"loading unsized types is not allowed");
 
 8627    Alignment = M->getDataLayout().getABITypeAlign(Ty);
 
 8628  Inst = 
new LoadInst(Ty, Val, 
"", isVolatile, *Alignment, Ordering, SSID);
 
 8629  return AteExtraComma ? InstExtraComma : InstNormal;
 
 8637int LLParser::parseStore(Instruction *&Inst, PerFunctionState &PFS) {
 
 8639  MaybeAlign Alignment;
 
 8640  bool AteExtraComma = 
false;
 
 8641  bool isAtomic = 
false;
 
 8650  bool isVolatile = 
false;
 
 8656  if (parseTypeAndValue(Val, Loc, PFS) ||
 
 8657      parseToken(
lltok::comma, 
"expected ',' after store operand") ||
 
 8658      parseTypeAndValue(
Ptr, PtrLoc, PFS) ||
 
 8659      parseScopeAndOrdering(isAtomic, SSID, Ordering) ||
 
 8660      parseOptionalCommaAlign(Alignment, AteExtraComma))
 
 8663  if (!
Ptr->getType()->isPointerTy())
 
 8664    return error(PtrLoc, 
"store operand must be a pointer");
 
 8666    return error(Loc, 
"store operand must be a first class value");
 
 8667  if (isAtomic && !Alignment)
 
 8668    return error(Loc, 
"atomic store must have explicit non-zero alignment");
 
 8671    return error(Loc, 
"atomic store cannot use Acquire ordering");
 
 8672  SmallPtrSet<Type *, 4> Visited;
 
 8674    return error(Loc, 
"storing unsized types is not allowed");
 
 8676    Alignment = M->getDataLayout().getABITypeAlign(Val->
getType());
 
 8678  Inst = 
new StoreInst(Val, 
Ptr, isVolatile, *Alignment, Ordering, SSID);
 
 8679  return AteExtraComma ? InstExtraComma : InstNormal;
 
 8686int LLParser::parseCmpXchg(Instruction *&Inst, PerFunctionState &PFS) {
 
 8688  bool AteExtraComma = 
false;
 
 8692  bool isVolatile = 
false;
 
 8693  bool isWeak = 
false;
 
 8694  MaybeAlign Alignment;
 
 8702  if (parseTypeAndValue(
Ptr, PtrLoc, PFS) ||
 
 8703      parseToken(
lltok::comma, 
"expected ',' after cmpxchg address") ||
 
 8704      parseTypeAndValue(Cmp, CmpLoc, PFS) ||
 
 8705      parseToken(
lltok::comma, 
"expected ',' after cmpxchg cmp operand") ||
 
 8706      parseTypeAndValue(New, NewLoc, PFS) ||
 
 8707      parseScopeAndOrdering(
true , SSID, SuccessOrdering) ||
 
 8708      parseOrdering(FailureOrdering) ||
 
 8709      parseOptionalCommaAlign(Alignment, AteExtraComma))
 
 8713    return tokError(
"invalid cmpxchg success ordering");
 
 8715    return tokError(
"invalid cmpxchg failure ordering");
 
 8716  if (!
Ptr->getType()->isPointerTy())
 
 8717    return error(PtrLoc, 
"cmpxchg operand must be a pointer");
 
 8718  if (
Cmp->getType() != 
New->getType())
 
 8719    return error(NewLoc, 
"compare value and new value type do not match");
 
 8720  if (!
New->getType()->isFirstClassType())
 
 8721    return error(NewLoc, 
"cmpxchg operand must be a first class value");
 
 8723  const Align DefaultAlignment(
 
 8724      PFS.getFunction().getDataLayout().getTypeStoreSize(
 
 8727  AtomicCmpXchgInst *CXI =
 
 8728      new AtomicCmpXchgInst(
Ptr, Cmp, New, Alignment.value_or(DefaultAlignment),
 
 8729                            SuccessOrdering, FailureOrdering, SSID);
 
 8734  return AteExtraComma ? InstExtraComma : InstNormal;
 
 8740int LLParser::parseAtomicRMW(Instruction *&Inst, PerFunctionState &PFS) {
 
 8742  bool AteExtraComma = 
false;
 
 8745  bool isVolatile = 
false;
 
 8748  MaybeAlign Alignment;
 
 8753  switch (Lex.getKind()) {
 
 8755    return tokError(
"expected binary operation in atomicrmw");
 
 8806  if (parseTypeAndValue(
Ptr, PtrLoc, PFS) ||
 
 8807      parseToken(
lltok::comma, 
"expected ',' after atomicrmw address") ||
 
 8808      parseTypeAndValue(Val, ValLoc, PFS) ||
 
 8809      parseScopeAndOrdering(
true , SSID, Ordering) ||
 
 8810      parseOptionalCommaAlign(Alignment, AteExtraComma))
 
 8814    return tokError(
"atomicrmw cannot be unordered");
 
 8815  if (!
Ptr->getType()->isPointerTy())
 
 8816    return error(PtrLoc, 
"atomicrmw operand must be a pointer");
 
 8818    return error(ValLoc, 
"atomicrmw operand may not be scalable");
 
 8827              " operand must be an integer, floating point, or pointer type");
 
 8831      return error(ValLoc, 
"atomicrmw " +
 
 8833                               " operand must be a floating point type");
 
 8837      return error(ValLoc, 
"atomicrmw " +
 
 8839                               " operand must be an integer");
 
 8844      PFS.getFunction().getDataLayout().getTypeStoreSizeInBits(
 
 8847    return error(ValLoc, 
"atomicrmw operand must be power-of-two byte-sized" 
 8849  const Align DefaultAlignment(
 
 8850      PFS.getFunction().getDataLayout().getTypeStoreSize(
 
 8852  AtomicRMWInst *RMWI =
 
 8854                        Alignment.value_or(DefaultAlignment), Ordering, SSID);
 
 8857  return AteExtraComma ? InstExtraComma : InstNormal;
 
 8862int LLParser::parseFence(Instruction *&Inst, PerFunctionState &PFS) {
 
 8865  if (parseScopeAndOrdering(
true , SSID, Ordering))
 
 8869    return tokError(
"fence cannot be unordered");
 
 8871    return tokError(
"fence cannot be monotonic");
 
 8873  Inst = 
new FenceInst(Context, Ordering, SSID);
 
 8879int LLParser::parseGetElementPtr(Instruction *&Inst, PerFunctionState &PFS) {
 
 8881  Value *Val = 
nullptr;
 
 8897  if (parseType(Ty) ||
 
 8898      parseToken(
lltok::comma, 
"expected comma after getelementptr's type") ||
 
 8899      parseTypeAndValue(
Ptr, Loc, PFS))
 
 8904  if (!BasePointerType)
 
 8905    return error(Loc, 
"base of getelementptr must be a pointer");
 
 8907  SmallVector<Value*, 16> Indices;
 
 8908  bool AteExtraComma = 
false;
 
 8911  ElementCount GEPWidth = 
BaseType->isVectorTy()
 
 8917      AteExtraComma = 
true;
 
 8920    if (parseTypeAndValue(Val, EltLoc, PFS))
 
 8923      return error(EltLoc, 
"getelementptr index must be an integer");
 
 8926      ElementCount ValNumEl = ValVTy->getElementCount();
 
 8930            "getelementptr vector index has a wrong number of elements");
 
 8931      GEPWidth = ValNumEl;
 
 8936  SmallPtrSet<Type*, 4> Visited;
 
 8938    return error(Loc, 
"base element of getelementptr must be sized");
 
 8942    return error(Loc, 
"getelementptr cannot target structure that contains " 
 8943                      "scalable vector type");
 
 8946    return error(Loc, 
"invalid getelementptr indices");
 
 8949  GEP->setNoWrapFlags(NW);
 
 8950  return AteExtraComma ? InstExtraComma : InstNormal;
 
 8955int LLParser::parseExtractValue(Instruction *&Inst, PerFunctionState &PFS) {
 
 8957  SmallVector<unsigned, 4> Indices;
 
 8959  if (parseTypeAndValue(Val, Loc, PFS) ||
 
 8960      parseIndexList(Indices, AteExtraComma))
 
 8964    return error(Loc, 
"extractvalue operand must be aggregate type");
 
 8967    return error(Loc, 
"invalid indices for extractvalue");
 
 8969  return AteExtraComma ? InstExtraComma : InstNormal;
 
 8974int LLParser::parseInsertValue(Instruction *&Inst, PerFunctionState &PFS) {
 
 8976  SmallVector<unsigned, 4> Indices;
 
 8978  if (parseTypeAndValue(Val0, Loc0, PFS) ||
 
 8979      parseToken(
lltok::comma, 
"expected comma after insertvalue operand") ||
 
 8980      parseTypeAndValue(Val1, Loc1, PFS) ||
 
 8981      parseIndexList(Indices, AteExtraComma))
 
 8985    return error(Loc0, 
"insertvalue operand must be aggregate type");
 
 8989    return error(Loc0, 
"invalid indices for insertvalue");
 
 8990  if (IndexedType != Val1->
getType())
 
 8991    return error(Loc1, 
"insertvalue operand and field disagree in type: '" +
 
 8995  return AteExtraComma ? InstExtraComma : InstNormal;
 
 9006bool LLParser::parseMDNodeVector(SmallVectorImpl<Metadata *> &Elts) {
 
 9021    if (parseMetadata(MD, 
nullptr))
 
 9026  return parseToken(
lltok::rbrace, 
"expected end of metadata node");
 
 9032bool LLParser::sortUseListOrder(
Value *V, ArrayRef<unsigned> Indexes,
 
 9034  if (!
V->hasUseList())
 
 9037    return error(Loc, 
"value has no uses");
 
 9039  unsigned NumUses = 0;
 
 9040  SmallDenseMap<const Use *, unsigned, 16> Order;
 
 9041  for (
const Use &U : 
V->uses()) {
 
 9042    if (++NumUses > Indexes.
size())
 
 9044    Order[&
U] = Indexes[NumUses - 1];
 
 9047    return error(Loc, 
"value only has one use");
 
 9048  if (Order.
size() != Indexes.
size() || NumUses > Indexes.
size())
 
 9050                 "wrong number of indexes, expected " + Twine(
V->getNumUses()));
 
 9052  V->sortUseList([&](
const Use &L, 
const Use &R) {
 
 9060bool LLParser::parseUseListOrderIndexes(SmallVectorImpl<unsigned> &Indexes) {
 
 9061  SMLoc Loc = Lex.getLoc();
 
 9065    return tokError(
"expected non-empty list of uselistorder indexes");
 
 9072  bool IsOrdered = 
true;
 
 9073  assert(Indexes.
empty() && 
"Expected empty order vector");
 
 9076    if (parseUInt32(Index))
 
 9081    Max = std::max(Max, Index);
 
 9082    IsOrdered &= Index == Indexes.
size();
 
 9090  if (Indexes.
size() < 2)
 
 9091    return error(Loc, 
"expected >= 2 uselistorder indexes");
 
 9094                 "expected distinct uselistorder indexes in range [0, size)");
 
 9096    return error(Loc, 
"expected uselistorder indexes to change the order");
 
 9103bool LLParser::parseUseListOrder(PerFunctionState *PFS) {
 
 9104  SMLoc Loc = Lex.getLoc();
 
 9109  SmallVector<unsigned, 16> Indexes;
 
 9110  if (parseTypeAndValue(V, PFS) ||
 
 9111      parseToken(
lltok::comma, 
"expected comma in uselistorder directive") ||
 
 9112      parseUseListOrderIndexes(Indexes))
 
 9115  return sortUseListOrder(V, Indexes, Loc);
 
 9120bool LLParser::parseUseListOrderBB() {
 
 9122  SMLoc Loc = Lex.getLoc();
 
 9126  SmallVector<unsigned, 16> Indexes;
 
 9127  if (parseValID(Fn, 
nullptr) ||
 
 9128      parseToken(
lltok::comma, 
"expected comma in uselistorder_bb directive") ||
 
 9129      parseValID(Label, 
nullptr) ||
 
 9130      parseToken(
lltok::comma, 
"expected comma in uselistorder_bb directive") ||
 
 9131      parseUseListOrderIndexes(Indexes))
 
 9137    GV = M->getNamedValue(Fn.
StrVal);
 
 9139    GV = NumberedVals.get(Fn.
UIntVal);
 
 9141    return error(Fn.
Loc, 
"expected function name in uselistorder_bb");
 
 9144                 "invalid function forward reference in uselistorder_bb");
 
 9147    return error(Fn.
Loc, 
"expected function name in uselistorder_bb");
 
 9148  if (
F->isDeclaration())
 
 9149    return error(Fn.
Loc, 
"invalid declaration in uselistorder_bb");
 
 9153    return error(
Label.Loc, 
"invalid numeric label in uselistorder_bb");
 
 9155    return error(
Label.Loc, 
"expected basic block name in uselistorder_bb");
 
 9156  Value *
V = 
F->getValueSymbolTable()->lookup(
Label.StrVal);
 
 9158    return error(
Label.Loc, 
"invalid basic block in uselistorder_bb");
 
 9160    return error(
Label.Loc, 
"expected basic block in uselistorder_bb");
 
 9162  return sortUseListOrder(V, Indexes, Loc);
 
 9168bool LLParser::parseModuleEntry(
unsigned ID) {
 
 9177      parseStringConstant(Path) ||
 
 9185  if (parseUInt32(Hash[0]) || parseToken(
lltok::comma, 
"expected ',' here") ||
 
 9186      parseUInt32(Hash[1]) || parseToken(
lltok::comma, 
"expected ',' here") ||
 
 9187      parseUInt32(Hash[2]) || parseToken(
lltok::comma, 
"expected ',' here") ||
 
 9188      parseUInt32(Hash[3]) || parseToken(
lltok::comma, 
"expected ',' here") ||
 
 9189      parseUInt32(Hash[4]))
 
 9196  auto ModuleEntry = Index->addModule(Path, Hash);
 
 9197  ModuleIdMap[
ID] = ModuleEntry->first();
 
 9204bool LLParser::parseTypeIdEntry(
unsigned ID) {
 
 9213      parseStringConstant(Name))
 
 9216  TypeIdSummary &TIS = Index->getOrInsertTypeIdSummary(Name);
 
 9218      parseTypeIdSummary(TIS) || parseToken(
lltok::rparen, 
"expected ')' here"))
 
 9223  auto FwdRefTIDs = ForwardRefTypeIds.find(
ID);
 
 9224  if (FwdRefTIDs != ForwardRefTypeIds.end()) {
 
 9225    for (
auto TIDRef : FwdRefTIDs->second) {
 
 9227             "Forward referenced type id GUID expected to be 0");
 
 9230    ForwardRefTypeIds.erase(FwdRefTIDs);
 
 9238bool LLParser::parseTypeIdSummary(TypeIdSummary &TIS) {
 
 9242      parseTypeTestResolution(TIS.
TTRes))
 
 9247    if (parseOptionalWpdResolutions(TIS.
WPDRes))
 
 9258    ValueInfo(
false, (GlobalValueSummaryMapTy::value_type *)-8);
 
 9264bool LLParser::parseTypeIdCompatibleVtableEntry(
unsigned ID) {
 
 9273      parseStringConstant(Name))
 
 9277      Index->getOrInsertTypeIdCompatibleVtableSummary(Name);
 
 9284  IdToIndexMapType IdToIndexMap;
 
 9297    if (parseGVReference(VI, GVId))
 
 9304      IdToIndexMap[GVId].push_back(std::make_pair(TI.size(), 
Loc));
 
 9305    TI.push_back({
Offset, VI});
 
 9313  for (
auto I : IdToIndexMap) {
 
 9314    auto &Infos = ForwardRefValueInfos[
I.first];
 
 9315    for (
auto P : 
I.second) {
 
 9317             "Forward referenced ValueInfo expected to be empty");
 
 9318      Infos.emplace_back(&TI[
P.first].VTableVI, 
P.second);
 
 9328  auto FwdRefTIDs = ForwardRefTypeIds.find(
ID);
 
 9329  if (FwdRefTIDs != ForwardRefTypeIds.end()) {
 
 9330    for (
auto TIDRef : FwdRefTIDs->second) {
 
 9332             "Forward referenced type id GUID expected to be 0");
 
 9335    ForwardRefTypeIds.erase(FwdRefTIDs);
 
 9347bool LLParser::parseTypeTestResolution(TypeTestResolution &TTRes) {
 
 9355  switch (Lex.getKind()) {
 
 9375    return error(Lex.getLoc(), 
"unexpected TypeTestResolution kind");
 
 9387    switch (Lex.getKind()) {
 
 9402      if (parseToken(
lltok::colon, 
"expected ':'") || parseUInt32(Val))
 
 9415      return error(Lex.getLoc(), 
"expected optional TypeTestResolution field");
 
 9428bool LLParser::parseOptionalWpdResolutions(
 
 9429    std::map<uint64_t, WholeProgramDevirtResolution> &WPDResMap) {
 
 9437    WholeProgramDevirtResolution WPDRes;
 
 9441        parseToken(
lltok::comma, 
"expected ',' here") || parseWpdRes(WPDRes) ||
 
 9444    WPDResMap[
Offset] = WPDRes;
 
 9461bool LLParser::parseWpdRes(WholeProgramDevirtResolution &WPDRes) {
 
 9469  switch (Lex.getKind()) {
 
 9480    return error(Lex.getLoc(), 
"unexpected WholeProgramDevirtResolution kind");
 
 9486    switch (Lex.getKind()) {
 
 9494      if (parseOptionalResByArg(WPDRes.
ResByArg))
 
 9498      return error(Lex.getLoc(),
 
 9499                   "expected optional WholeProgramDevirtResolution field");
 
 9516bool LLParser::parseOptionalResByArg(
 
 9517    std::map<std::vector<uint64_t>, WholeProgramDevirtResolution::ByArg>
 
 9525    std::vector<uint64_t> 
Args;
 
 9526    if (parseArgs(Args) || parseToken(
lltok::comma, 
"expected ',' here") ||
 
 9534    WholeProgramDevirtResolution::ByArg ByArg;
 
 9535    switch (Lex.getKind()) {
 
 9549      return error(Lex.getLoc(),
 
 9550                   "unexpected WholeProgramDevirtResolution::ByArg kind");
 
 9556      switch (Lex.getKind()) {
 
 9560            parseUInt64(ByArg.
Info))
 
 9566            parseUInt32(ByArg.
Byte))
 
 9572            parseUInt32(ByArg.
Bit))
 
 9576        return error(Lex.getLoc(),
 
 9577                     "expected optional whole program devirt field");
 
 9584    ResByArg[
Args] = ByArg;
 
 9595bool LLParser::parseArgs(std::vector<uint64_t> &Args) {
 
 9603    if (parseUInt64(Val))
 
 9605    Args.push_back(Val);
 
 9614static const auto FwdVIRef = (GlobalValueSummaryMapTy::value_type *)-8;
 
 9619  assert(!(ReadOnly && WriteOnly));
 
 
 9629bool LLParser::addGlobalValueToIndex(
 
 9631    unsigned ID, std::unique_ptr<GlobalValueSummary> Summary, 
LocTy Loc) {
 
 9636    VI = Index->getOrInsertValueInfo(GUID);
 
 9640      auto *GV = M->getNamedValue(Name);
 
 9642        return error(Loc, 
"Reference to undefined global \"" + Name + 
"\"");
 
 9644      VI = Index->getOrInsertValueInfo(GV);
 
 9648          "Need a source_filename to compute GUID for local");
 
 9651      VI = Index->getOrInsertValueInfo(GUID, Index->saveString(Name));
 
 9656  auto FwdRefVIs = ForwardRefValueInfos.find(
ID);
 
 9657  if (FwdRefVIs != ForwardRefValueInfos.end()) {
 
 9658    for (
auto VIRef : FwdRefVIs->second) {
 
 9660             "Forward referenced ValueInfo expected to be empty");
 
 9663    ForwardRefValueInfos.erase(FwdRefVIs);
 
 9667  auto FwdRefAliasees = ForwardRefAliasees.find(
ID);
 
 9668  if (FwdRefAliasees != ForwardRefAliasees.end()) {
 
 9669    for (
auto AliaseeRef : FwdRefAliasees->second) {
 
 9670      assert(!AliaseeRef.first->hasAliasee() &&
 
 9671             "Forward referencing alias already has aliasee");
 
 9672      assert(Summary && 
"Aliasee must be a definition");
 
 9673      AliaseeRef.first->setAliasee(VI, 
Summary.get());
 
 9675    ForwardRefAliasees.erase(FwdRefAliasees);
 
 9680    Index->addGlobalValueSummary(VI, std::move(Summary));
 
 9683  if (
ID == NumberedValueInfos.size())
 
 9684    NumberedValueInfos.push_back(VI);
 
 9687    if (
ID > NumberedValueInfos.size())
 
 9688      NumberedValueInfos.resize(
ID + 1);
 
 9689    NumberedValueInfos[
ID] = 
VI;
 
 9697bool LLParser::parseSummaryIndexFlags() {
 
 9704  if (parseUInt64(Flags))
 
 9707    Index->setFlags(Flags);
 
 9713bool LLParser::parseBlockCount() {
 
 9719  uint64_t BlockCount;
 
 9720  if (parseUInt64(BlockCount))
 
 9723    Index->setBlockCount(BlockCount);
 
 9731bool LLParser::parseGVEntry(
unsigned ID) {
 
 9739  LocTy Loc = Lex.getLoc();
 
 9742  switch (Lex.getKind()) {
 
 9746        parseStringConstant(Name))
 
 9752    if (parseToken(
lltok::colon, 
"expected ':' here") || parseUInt64(GUID))
 
 9756    return error(Lex.getLoc(), 
"expected name or guid tag");
 
 9779    switch (Lex.getKind()) {
 
 9781      if (parseFunctionSummary(Name, GUID, 
ID))
 
 9785      if (parseVariableSummary(Name, GUID, 
ID))
 
 9789      if (parseAliasSummary(Name, GUID, 
ID))
 
 9793      return error(Lex.getLoc(), 
"expected summary type");
 
 9811  LocTy Loc = Lex.getLoc();
 
 9815  StringRef ModulePath;
 
 9816  GlobalValueSummary::GVFlags GVFlags = GlobalValueSummary::GVFlags(
 
 9819      false, 
false, 
false,
 
 9823  FunctionSummary::TypeIdInfo TypeIdInfo;
 
 9824  std::vector<FunctionSummary::ParamAccess> ParamAccesses;
 
 9826  std::vector<CallsiteInfo> Callsites;
 
 9827  std::vector<AllocInfo> Allocs;
 
 9829  FunctionSummary::FFlags FFlags = {};
 
 9832      parseModuleReference(ModulePath) ||
 
 9833      parseToken(
lltok::comma, 
"expected ',' here") || parseGVFlags(GVFlags) ||
 
 9836      parseToken(
lltok::colon, 
"expected ':' here") || parseUInt32(InstCount))
 
 9841    switch (Lex.getKind()) {
 
 9843      if (parseOptionalFFlags(FFlags))
 
 9847      if (parseOptionalCalls(Calls))
 
 9851      if (parseOptionalTypeIdInfo(TypeIdInfo))
 
 9855      if (parseOptionalRefs(Refs))
 
 9859      if (parseOptionalParamAccesses(ParamAccesses))
 
 9863      if (parseOptionalAllocs(Allocs))
 
 9867      if (parseOptionalCallsites(Callsites))
 
 9871      return error(Lex.getLoc(), 
"expected optional function summary field");
 
 9878  auto FS = std::make_unique<FunctionSummary>(
 
 9879      GVFlags, InstCount, FFlags, std::move(Refs), std::move(Calls),
 
 9885      std::move(ParamAccesses), std::move(Callsites), std::move(Allocs));
 
 9887  FS->setModulePath(ModulePath);
 
 9889  return addGlobalValueToIndex(Name, GUID,
 
 9891                               std::move(FS), Loc);
 
 9899  LocTy Loc = Lex.getLoc();
 
 9903  StringRef ModulePath;
 
 9904  GlobalValueSummary::GVFlags GVFlags = GlobalValueSummary::GVFlags(
 
 9907      false, 
false, 
false,
 
 9909  GlobalVarSummary::GVarFlags GVarFlags( 
false,
 
 9917      parseModuleReference(ModulePath) ||
 
 9918      parseToken(
lltok::comma, 
"expected ',' here") || parseGVFlags(GVFlags) ||
 
 9920      parseGVarFlags(GVarFlags))
 
 9925    switch (Lex.getKind()) {
 
 9927      if (parseOptionalVTableFuncs(VTableFuncs))
 
 9931      if (parseOptionalRefs(Refs))
 
 9935      return error(Lex.getLoc(), 
"expected optional variable summary field");
 
 9943      std::make_unique<GlobalVarSummary>(GVFlags, GVarFlags, std::move(Refs));
 
 9945  GS->setModulePath(ModulePath);
 
 9946  GS->setVTableFuncs(std::move(VTableFuncs));
 
 9948  return addGlobalValueToIndex(Name, GUID,
 
 9950                               std::move(GS), Loc);
 
 9959  LocTy Loc = Lex.getLoc();
 
 9962  StringRef ModulePath;
 
 9963  GlobalValueSummary::GVFlags GVFlags = GlobalValueSummary::GVFlags(
 
 9966      false, 
false, 
false,
 
 9970      parseModuleReference(ModulePath) ||
 
 9971      parseToken(
lltok::comma, 
"expected ',' here") || parseGVFlags(GVFlags) ||
 
 9977  ValueInfo AliaseeVI;
 
 9979  if (parseGVReference(AliaseeVI, GVId))
 
 9985  auto AS = std::make_unique<AliasSummary>(GVFlags);
 
 9987  AS->setModulePath(ModulePath);
 
 9991    ForwardRefAliasees[GVId].emplace_back(AS.get(), Loc);
 
 9993    auto Summary = Index->findSummaryInModule(AliaseeVI, ModulePath);
 
 9994    assert(Summary && 
"Aliasee must be a definition");
 
 9995    AS->setAliasee(AliaseeVI, Summary);
 
 9998  return addGlobalValueToIndex(Name, GUID,
 
10000                               std::move(AS), Loc);
 
10005bool LLParser::parseFlag(
unsigned &Val) {
 
10006  if (Lex.getKind() != 
lltok::APSInt || Lex.getAPSIntVal().isSigned())
 
10007    return tokError(
"expected integer");
 
10008  Val = (unsigned)Lex.getAPSIntVal().getBoolValue();
 
10024bool LLParser::parseOptionalFFlags(FunctionSummary::FFlags &FFlags) {
 
10028  if (parseToken(
lltok::colon, 
"expected ':' in funcFlags") ||
 
10034    switch (Lex.getKind()) {
 
10037      if (parseToken(
lltok::colon, 
"expected ':'") || parseFlag(Val))
 
10043      if (parseToken(
lltok::colon, 
"expected ':'") || parseFlag(Val))
 
10049      if (parseToken(
lltok::colon, 
"expected ':'") || parseFlag(Val))
 
10055      if (parseToken(
lltok::colon, 
"expected ':'") || parseFlag(Val))
 
10061      if (parseToken(
lltok::colon, 
"expected ':'") || parseFlag(Val))
 
10067      if (parseToken(
lltok::colon, 
"expected ':'") || parseFlag(Val))
 
10073      if (parseToken(
lltok::colon, 
"expected ':'") || parseFlag(Val))
 
10079      if (parseToken(
lltok::colon, 
"expected ':'") || parseFlag(Val))
 
10085      if (parseToken(
lltok::colon, 
"expected ':'") || parseFlag(Val))
 
10091      if (parseToken(
lltok::colon, 
"expected ':'") || parseFlag(Val))
 
10096      return error(Lex.getLoc(), 
"expected function flag type");
 
10100  if (parseToken(
lltok::rparen, 
"expected ')' in funcFlags"))
 
10111bool LLParser::parseOptionalCalls(
 
10112    SmallVectorImpl<FunctionSummary::EdgeTy> &Calls) {
 
10116  if (parseToken(
lltok::colon, 
"expected ':' in calls") ||
 
10120  IdToIndexMapType IdToIndexMap;
 
10129    LocTy Loc = Lex.getLoc();
 
10131    if (parseGVReference(VI, GVId))
 
10135    unsigned RelBF = 0;
 
10136    unsigned HasTailCall = 
false;
 
10140      switch (Lex.getKind()) {
 
10143        if (parseToken(
lltok::colon, 
"expected ':'") || parseHotness(Hotness))
 
10148        if (parseToken(
lltok::colon, 
"expected ':'") || parseUInt32(RelBF))
 
10153        if (parseToken(
lltok::colon, 
"expected ':'") || parseFlag(HasTailCall))
 
10157        return error(Lex.getLoc(), 
"expected hotness, relbf, or tail");
 
10161      return tokError(
"Expected only one of hotness or relbf");
 
10166      IdToIndexMap[GVId].push_back(std::make_pair(Calls.
size(), Loc));
 
10176  for (
auto I : IdToIndexMap) {
 
10177    auto &Infos = ForwardRefValueInfos[
I.first];
 
10178    for (
auto P : 
I.second) {
 
10180             "Forward referenced ValueInfo expected to be empty");
 
10181      Infos.emplace_back(&Calls[
P.first].first, 
P.second);
 
10194  switch (Lex.getKind()) {
 
10198  case lltok::kw_cold:
 
10204  case lltok::kw_hot:
 
10211    return error(Lex.getLoc(), 
"invalid call edge hotness");
 
10220bool LLParser::parseOptionalVTableFuncs(
VTableFuncList &VTableFuncs) {
 
10224  if (parseToken(
lltok::colon, 
"expected ':' in vTableFuncs") ||
 
10228  IdToIndexMapType IdToIndexMap;
 
10232    if (parseToken(
lltok::lparen, 
"expected '(' in vTableFunc") ||
 
10237    LocTy Loc = Lex.getLoc();
 
10239    if (parseGVReference(VI, GVId))
 
10252      IdToIndexMap[GVId].push_back(std::make_pair(VTableFuncs.size(), Loc));
 
10253    VTableFuncs.push_back({
VI, 
Offset});
 
10255    if (parseToken(
lltok::rparen, 
"expected ')' in vTableFunc"))
 
10261  for (
auto I : IdToIndexMap) {
 
10262    auto &Infos = ForwardRefValueInfos[
I.first];
 
10263    for (
auto P : 
I.second) {
 
10265             "Forward referenced ValueInfo expected to be empty");
 
10266      Infos.emplace_back(&VTableFuncs[
P.first].FuncVI, 
P.second);
 
10270  if (parseToken(
lltok::rparen, 
"expected ')' in vTableFuncs"))
 
10277bool LLParser::parseParamNo(uint64_t &ParamNo) {
 
10279      parseToken(
lltok::colon, 
"expected ':' here") || parseUInt64(ParamNo))
 
10285bool LLParser::parseParamAccessOffset(ConstantRange &
Range) {
 
10288  auto ParseAPSInt = [&](
APSInt &Val) {
 
10290      return tokError(
"expected integer");
 
10291    Val = Lex.getAPSIntVal();
 
10293    Val.setIsSigned(
true);
 
10315bool LLParser::parseParamAccessCall(FunctionSummary::ParamAccess::Call &
Call,
 
10316                                    IdLocListType &IdLocList) {
 
10324  LocTy Loc = Lex.getLoc();
 
10325  if (parseGVReference(VI, GVId))
 
10329  IdLocList.emplace_back(GVId, Loc);
 
10332      parseParamNo(
Call.ParamNo) ||
 
10334      parseParamAccessOffset(
Call.Offsets))
 
10346bool LLParser::parseParamAccess(FunctionSummary::ParamAccess &Param,
 
10347                                IdLocListType &IdLocList) {
 
10349      parseParamNo(
Param.ParamNo) ||
 
10351      parseParamAccessOffset(
Param.Use))
 
10360      FunctionSummary::ParamAccess::Call 
Call;
 
10361      if (parseParamAccessCall(
Call, IdLocList))
 
10378bool LLParser::parseOptionalParamAccesses(
 
10379    std::vector<FunctionSummary::ParamAccess> &Params) {
 
10387  IdLocListType VContexts;
 
10388  size_t CallsNum = 0;
 
10390    FunctionSummary::ParamAccess ParamAccess;
 
10391    if (parseParamAccess(ParamAccess, VContexts))
 
10393    CallsNum += ParamAccess.
Calls.size();
 
10394    assert(VContexts.size() == CallsNum);
 
10396    Params.emplace_back(std::move(ParamAccess));
 
10404  IdLocListType::const_iterator ItContext = VContexts.begin();
 
10405  for (
auto &PA : Params) {
 
10406    for (
auto &
C : PA.Calls) {
 
10408        ForwardRefValueInfos[ItContext->first].emplace_back(&
C.Callee,
 
10409                                                            ItContext->second);
 
10413  assert(ItContext == VContexts.end());
 
10420bool LLParser::parseOptionalRefs(SmallVectorImpl<ValueInfo> &Refs) {
 
10424  if (parseToken(
lltok::colon, 
"expected ':' in refs") ||
 
10428  struct ValueContext {
 
10433  std::vector<ValueContext> VContexts;
 
10437    VC.Loc = Lex.getLoc();
 
10438    if (parseGVReference(
VC.VI, 
VC.GVId))
 
10440    VContexts.push_back(VC);
 
10446  llvm::sort(VContexts, [](
const ValueContext &VC1, 
const ValueContext &VC2) {
 
10447    return VC1.VI.getAccessSpecifier() < VC2.VI.getAccessSpecifier();
 
10450  IdToIndexMapType IdToIndexMap;
 
10451  for (
auto &VC : VContexts) {
 
10456      IdToIndexMap[
VC.GVId].push_back(std::make_pair(Refs.
size(), 
VC.Loc));
 
10462  for (
auto I : IdToIndexMap) {
 
10463    auto &Infos = ForwardRefValueInfos[
I.first];
 
10464    for (
auto P : 
I.second) {
 
10466             "Forward referenced ValueInfo expected to be empty");
 
10467      Infos.emplace_back(&Refs[
P.first], 
P.second);
 
10481bool LLParser::parseOptionalTypeIdInfo(
 
10482    FunctionSummary::TypeIdInfo &TypeIdInfo) {
 
10491    switch (Lex.getKind()) {
 
10493      if (parseTypeTests(TypeIdInfo.
TypeTests))
 
10517      return error(Lex.getLoc(), 
"invalid typeIdInfo list type");
 
10521  if (parseToken(
lltok::rparen, 
"expected ')' in typeIdInfo"))
 
10530bool LLParser::parseTypeTests(std::vector<GlobalValue::GUID> &TypeTests) {
 
10538  IdToIndexMapType IdToIndexMap;
 
10542      unsigned ID = Lex.getUIntVal();
 
10543      LocTy Loc = Lex.getLoc();
 
10547      IdToIndexMap[
ID].push_back(std::make_pair(TypeTests.size(), Loc));
 
10549    } 
else if (parseUInt64(GUID))
 
10551    TypeTests.push_back(GUID);
 
10556  for (
auto I : IdToIndexMap) {
 
10557    auto &Ids = ForwardRefTypeIds[
I.first];
 
10558    for (
auto P : 
I.second) {
 
10559      assert(TypeTests[
P.first] == 0 &&
 
10560             "Forward referenced type id GUID expected to be 0");
 
10561      Ids.emplace_back(&TypeTests[
P.first], 
P.second);
 
10565  if (parseToken(
lltok::rparen, 
"expected ')' in typeIdInfo"))
 
10573bool LLParser::parseVFuncIdList(
 
10574    lltok::Kind Kind, std::vector<FunctionSummary::VFuncId> &VFuncIdList) {
 
10575  assert(Lex.getKind() == Kind);
 
10582  IdToIndexMapType IdToIndexMap;
 
10584    FunctionSummary::VFuncId VFuncId;
 
10585    if (parseVFuncId(VFuncId, IdToIndexMap, VFuncIdList.size()))
 
10587    VFuncIdList.push_back(VFuncId);
 
10595  for (
auto I : IdToIndexMap) {
 
10596    auto &Ids = ForwardRefTypeIds[
I.first];
 
10597    for (
auto P : 
I.second) {
 
10598      assert(VFuncIdList[
P.first].GUID == 0 &&
 
10599             "Forward referenced type id GUID expected to be 0");
 
10600      Ids.emplace_back(&VFuncIdList[
P.first].GUID, 
P.second);
 
10609bool LLParser::parseConstVCallList(
 
10611    std::vector<FunctionSummary::ConstVCall> &ConstVCallList) {
 
10612  assert(Lex.getKind() == Kind);
 
10619  IdToIndexMapType IdToIndexMap;
 
10621    FunctionSummary::ConstVCall ConstVCall;
 
10622    if (parseConstVCall(ConstVCall, IdToIndexMap, ConstVCallList.size()))
 
10624    ConstVCallList.push_back(ConstVCall);
 
10632  for (
auto I : IdToIndexMap) {
 
10633    auto &Ids = ForwardRefTypeIds[
I.first];
 
10634    for (
auto P : 
I.second) {
 
10635      assert(ConstVCallList[
P.first].VFunc.GUID == 0 &&
 
10636             "Forward referenced type id GUID expected to be 0");
 
10637      Ids.emplace_back(&ConstVCallList[
P.first].VFunc.GUID, 
P.second);
 
10646bool LLParser::parseConstVCall(FunctionSummary::ConstVCall &ConstVCall,
 
10647                               IdToIndexMapType &IdToIndexMap, 
unsigned Index) {
 
10649      parseVFuncId(ConstVCall.
VFunc, IdToIndexMap, Index))
 
10653    if (parseArgs(ConstVCall.
Args))
 
10665bool LLParser::parseVFuncId(FunctionSummary::VFuncId &VFuncId,
 
10666                            IdToIndexMapType &IdToIndexMap, 
unsigned Index) {
 
10676    unsigned ID = Lex.getUIntVal();
 
10677    LocTy Loc = Lex.getLoc();
 
10681    IdToIndexMap[
ID].push_back(std::make_pair(Index, Loc));
 
10683  } 
else if (parseToken(
lltok::kw_guid, 
"expected 'guid' here") ||
 
10685             parseUInt64(VFuncId.
GUID))
 
10691      parseUInt64(VFuncId.
Offset) ||
 
10703bool LLParser::parseGVFlags(GlobalValueSummary::GVFlags &GVFlags) {
 
10713    switch (Lex.getKind()) {
 
10720      assert(HasLinkage && 
"Linkage not optional in summary entry");
 
10727      parseOptionalVisibility(Flag);
 
10732      if (parseToken(
lltok::colon, 
"expected ':'") || parseFlag(Flag))
 
10738      if (parseToken(
lltok::colon, 
"expected ':'") || parseFlag(Flag))
 
10744      if (parseToken(
lltok::colon, 
"expected ':'") || parseFlag(Flag))
 
10750      if (parseToken(
lltok::colon, 
"expected ':'") || parseFlag(Flag))
 
10759      if (parseOptionalImportType(Lex.getKind(), IK))
 
10761      GVFlags.
ImportType = 
static_cast<unsigned>(IK);
 
10765      return error(Lex.getLoc(), 
"expected gv flag type");
 
10779bool LLParser::parseGVarFlags(GlobalVarSummary::GVarFlags &GVarFlags) {
 
10787  auto ParseRest = [
this](
unsigned int &Val) {
 
10791    return parseFlag(Val);
 
10796    switch (Lex.getKind()) {
 
10797    case lltok::kw_readonly:
 
10798      if (ParseRest(Flag))
 
10802    case lltok::kw_writeonly:
 
10803      if (ParseRest(Flag))
 
10808      if (ParseRest(Flag))
 
10813      if (ParseRest(Flag))
 
10818      return error(Lex.getLoc(), 
"expected gvar flag type");
 
10826bool LLParser::parseModuleReference(StringRef &ModulePath) {
 
10833  unsigned ModuleID = Lex.getUIntVal();
 
10834  auto I = ModuleIdMap.find(ModuleID);
 
10836  assert(
I != ModuleIdMap.end());
 
10837  ModulePath = 
I->second;
 
10843bool LLParser::parseGVReference(ValueInfo &VI, 
unsigned &GVId) {
 
10846    WriteOnly = EatIfPresent(lltok::kw_writeonly);
 
10850  GVId = Lex.getUIntVal();
 
10852  if (GVId < NumberedValueInfos.size() && NumberedValueInfos[GVId]) {
 
10854    VI = NumberedValueInfos[GVId];
 
10871bool LLParser::parseOptionalAllocs(std::vector<AllocInfo> &Allocs) {
 
10875  if (parseToken(
lltok::colon, 
"expected ':' in allocs") ||
 
10887    SmallVector<uint8_t> Versions;
 
10890      if (parseAllocType(V))
 
10895    if (parseToken(
lltok::rparen, 
"expected ')' in versions") ||
 
10899    std::vector<MIBInfo> MIBs;
 
10900    if (parseMemProfs(MIBs))
 
10903    Allocs.push_back({Versions, MIBs});
 
10920bool LLParser::parseMemProfs(std::vector<MIBInfo> &MIBs) {
 
10924  if (parseToken(
lltok::colon, 
"expected ':' in memprof") ||
 
10930    if (parseToken(
lltok::lparen, 
"expected '(' in memprof") ||
 
10939    if (parseToken(
lltok::comma, 
"expected ',' in memprof") ||
 
10945    SmallVector<unsigned> StackIdIndices;
 
10949        uint64_t StackId = 0;
 
10950        if (parseUInt64(StackId))
 
10952        StackIdIndices.
push_back(Index->addOrGetStackIdIndex(StackId));
 
10973bool LLParser::parseAllocType(uint8_t &
AllocType) {
 
10974  switch (Lex.getKind()) {
 
10981  case lltok::kw_cold:
 
10984  case lltok::kw_hot:
 
10988    return error(Lex.getLoc(), 
"invalid alloc type");
 
11001bool LLParser::parseOptionalCallsites(std::vector<CallsiteInfo> &Callsites) {
 
11005  if (parseToken(
lltok::colon, 
"expected ':' in callsites") ||
 
11009  IdToIndexMapType IdToIndexMap;
 
11012    if (parseToken(
lltok::lparen, 
"expected '(' in callsite") ||
 
11019    LocTy Loc = Lex.getLoc();
 
11021      if (parseGVReference(VI, GVId))
 
11025    if (parseToken(
lltok::comma, 
"expected ',' in callsite") ||
 
11031    SmallVector<unsigned> Clones;
 
11034      if (parseUInt32(V))
 
11040        parseToken(
lltok::comma, 
"expected ',' in callsite") ||
 
11046    SmallVector<unsigned> StackIdIndices;
 
11050        uint64_t StackId = 0;
 
11051        if (parseUInt64(StackId))
 
11053        StackIdIndices.
push_back(Index->addOrGetStackIdIndex(StackId));
 
11064      IdToIndexMap[GVId].
push_back(std::make_pair(Callsites.size(), Loc));
 
11065    Callsites.push_back({
VI, Clones, StackIdIndices});
 
11073  for (
auto I : IdToIndexMap) {
 
11074    auto &Infos = ForwardRefValueInfos[
I.first];
 
11075    for (
auto P : 
I.second) {
 
11077             "Forward referenced ValueInfo expected to be empty");
 
11078      Infos.emplace_back(&Callsites[
P.first].Callee, 
P.second);
 
11082  if (parseToken(
lltok::rparen, 
"expected ')' in callsites"))
 
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
 
Unify divergent function exit nodes
 
This file implements the APSInt class, which is a simple class that represents an arbitrary sized int...
 
Function Alias Analysis false
 
Expand Atomic instructions
 
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
 
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
 
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
 
Analysis containing CSE Info
 
This file contains the declarations for the subclasses of Constant, which represent the different fla...
 
This file defines the DenseMap class.
 
This file contains constants used for implementing Dwarf debug support.
 
This file contains the declaration of the GlobalIFunc class, which represents a single indirect funct...
 
GlobalValue::SanitizerMetadata SanitizerMetadata
 
Module.h This file contains the declarations for the Module class.
 
static GlobalValue * createGlobalFwdRef(Module *M, PointerType *PTy)
 
static cl::opt< bool > AllowIncompleteIR("allow-incomplete-ir", cl::init(false), cl::Hidden, cl::desc("Allow incomplete IR on a best effort basis (references to unknown " "metadata will be dropped)"))
 
static void maybeSetDSOLocal(bool DSOLocal, GlobalValue &GV)
 
static bool upgradeMemoryAttr(MemoryEffects &ME, lltok::Kind Kind)
 
static std::optional< MemoryEffects::Location > keywordToLoc(lltok::Kind Tok)
 
static void resolveFwdRef(ValueInfo *Fwd, ValueInfo &Resolved)
 
static unsigned parseOptionalLinkageAux(lltok::Kind Kind, bool &HasLinkage)
 
static unsigned keywordToFPClassTest(lltok::Kind Tok)
 
#define CC_VLS_CASE(ABIVlen)
 
static std::optional< ModRefInfo > keywordToModRef(lltok::Kind Tok)
 
static bool isSanitizer(lltok::Kind Kind)
 
static void dropIntrinsicWithUnknownMetadataArgument(IntrinsicInst *II)
 
#define PARSE_MD_FIELDS()
 
static Attribute::AttrKind tokenToAttribute(lltok::Kind Kind)
 
#define GET_OR_DISTINCT(CLASS, ARGS)
 
bool isOldDbgFormatIntrinsic(StringRef Name)
 
static bool isValidVisibilityForLinkage(unsigned V, unsigned L)
 
static std::string getTypeString(Type *T)
 
static bool isValidDLLStorageClassForLinkage(unsigned S, unsigned L)
 
static const auto FwdVIRef
 
static bool InRange(int64_t Value, unsigned short Shift, int LBound, int HBound)
 
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
 
uint64_t IntrinsicInst * II
 
PowerPC Reduce CR logical Operation
 
static bool getVal(MDTuple *MD, const char *Key, uint64_t &Val)
 
const SmallVectorImpl< MachineOperand > & Cond
 
dot regions Print regions of function to dot file(with no function bodies)"
 
BaseType
A given derived pointer can have multiple base pointers through phi/selects.
 
This file provides utility classes that use RAII to save and restore values.
 
This file defines the make_scope_exit function, which executes user-defined cleanup logic at scope ex...
 
This file defines the SmallPtrSet class.
 
FunctionLoweringInfo::StatepointRelocationRecord RecordType
 
static SymbolRef::Type getType(const Symbol *Sym)
 
LocallyHashedType DenseMapInfo< LocallyHashedType >::Empty
 
static const fltSemantics & IEEEsingle()
 
static const fltSemantics & BFloat()
 
static const fltSemantics & IEEEdouble()
 
static constexpr roundingMode rmNearestTiesToEven
 
static const fltSemantics & IEEEhalf()
 
static APFloat getSNaN(const fltSemantics &Sem, bool Negative=false, const APInt *payload=nullptr)
Factory for SNaN values.
 
bool sge(const APInt &RHS) const
Signed greater or equal comparison.
 
APSInt extOrTrunc(uint32_t width) const
 
void setSwiftError(bool V)
Specify whether this alloca is used to represent a swifterror.
 
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.
 
static LLVM_ABI ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
 
static LLVM_ABI bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
 
void setWeak(bool IsWeak)
 
static bool isValidFailureOrdering(AtomicOrdering Ordering)
 
void setVolatile(bool V)
Specify whether this is a volatile cmpxchg.
 
static bool isValidSuccessOrdering(AtomicOrdering Ordering)
 
void setVolatile(bool V)
Specify whether this is a volatile RMW or not.
 
BinOp
This enumeration lists the possible modifications atomicrmw can make.
 
@ USubCond
Subtract only if no unsigned overflow.
 
@ FMinimum
*p = minimum(old, v) minimum matches the behavior of llvm.minimum.
 
@ Min
*p = old <signed v ? old : v
 
@ USubSat
*p = usub.sat(old, v) usub.sat matches the behavior of llvm.usub.sat.
 
@ FMaximum
*p = maximum(old, v) maximum matches the behavior of llvm.maximum.
 
@ 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.
 
static LLVM_ABI StringRef getOperationName(BinOp Op)
 
static LLVM_ABI AttributeSet get(LLVMContext &C, const AttrBuilder &B)
 
static LLVM_ABI bool canUseAsRetAttr(AttrKind Kind)
 
static bool isTypeAttrKind(AttrKind Kind)
 
static LLVM_ABI bool canUseAsFnAttr(AttrKind Kind)
 
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
 
@ None
No attributes have been set.
 
static LLVM_ABI bool canUseAsParamAttr(AttrKind Kind)
 
LLVM Basic Block Representation.
 
LLVM_ABI void insertDbgRecordBefore(DbgRecord *DR, InstListType::iterator Here)
Insert a DbgRecord into a block at the position given by Here.
 
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
 
static LLVM_ABI BinaryOperator * Create(BinaryOps Op, Value *S1, Value *S2, const Twine &Name=Twine(), InsertPosition InsertBefore=nullptr)
Construct a binary instruction, given the opcode and the two operands.
 
static LLVM_ABI BlockAddress * get(Function *F, BasicBlock *BB)
Return a BlockAddress for the specified function and basic block.
 
static BranchInst * Create(BasicBlock *IfTrue, InsertPosition InsertBefore=nullptr)
 
void setCallingConv(CallingConv::ID CC)
 
void setAttributes(AttributeList A)
Set the attributes for this call.
 
static CallBrInst * Create(FunctionType *Ty, Value *Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)
 
void setTailCallKind(TailCallKind TCK)
 
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
 
static CaptureInfo none()
Create CaptureInfo that does not capture any components of the pointer.
 
static LLVM_ABI CastInst * Create(Instruction::CastOps, Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Provides a way to construct any of the CastInst subclasses using an opcode instead of the subclass's ...
 
static LLVM_ABI 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="", InsertPosition InsertBefore=nullptr)
 
static CatchReturnInst * Create(Value *CatchPad, BasicBlock *BB, InsertPosition InsertBefore=nullptr)
 
static CatchSwitchInst * Create(Value *ParentPad, BasicBlock *UnwindDest, unsigned NumHandlers, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
 
static CleanupPadInst * Create(Value *ParentPad, ArrayRef< Value * > Args={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
 
static CleanupReturnInst * Create(Value *CleanupPad, BasicBlock *UnwindBB=nullptr, InsertPosition InsertBefore=nullptr)
 
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
 
@ FCMP_OEQ
0 0 0 1 True if ordered and equal
 
@ FCMP_TRUE
1 1 1 1 Always true (always folded)
 
@ ICMP_SLT
signed less than
 
@ ICMP_SLE
signed less or equal
 
@ FCMP_OLT
0 1 0 0 True if ordered and less than
 
@ FCMP_ULE
1 1 0 1 True if unordered, less than, or equal
 
@ FCMP_OGT
0 0 1 0 True if ordered and greater than
 
@ FCMP_OGE
0 0 1 1 True if ordered and greater than or equal
 
@ ICMP_UGE
unsigned greater or equal
 
@ ICMP_UGT
unsigned greater than
 
@ ICMP_SGT
signed greater than
 
@ FCMP_ULT
1 1 0 0 True if unordered or less than
 
@ FCMP_ONE
0 1 1 0 True if ordered and operands are unequal
 
@ FCMP_UEQ
1 0 0 1 True if unordered or equal
 
@ ICMP_ULT
unsigned less than
 
@ FCMP_UGT
1 0 1 0 True if unordered or greater than
 
@ FCMP_OLE
0 1 0 1 True if ordered and less than or equal
 
@ FCMP_ORD
0 1 1 1 True if ordered (no nans)
 
@ ICMP_SGE
signed greater or equal
 
@ FCMP_UNE
1 1 1 0 True if unordered or not equal
 
@ ICMP_ULE
unsigned less or equal
 
@ FCMP_UGE
1 0 1 1 True if unordered, greater than, or equal
 
@ FCMP_FALSE
0 0 0 0 Always false (always folded)
 
@ FCMP_UNO
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
 
@ 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 LLVM_ABI Constant * get(ArrayType *T, ArrayRef< Constant * > V)
 
static LLVM_ABI Constant * getString(LLVMContext &Context, StringRef Initializer, bool AddNull=true)
This method constructs a CDS and initializes it with a text string.
 
static LLVM_ABI Constant * getExtractElement(Constant *Vec, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
 
static LLVM_ABI Constant * getCast(unsigned ops, Constant *C, Type *Ty, bool OnlyIfReduced=false)
Convenience function for getting a Cast operation.
 
static LLVM_ABI Constant * getInsertElement(Constant *Vec, Constant *Elt, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
 
static LLVM_ABI 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 LLVM_ABI 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 Constant * getGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList, GEPNoWrapFlags NW=GEPNoWrapFlags::none(), std::optional< ConstantRange > InRange=std::nullopt, Type *OnlyIfReducedTy=nullptr)
Getelementptr form.
 
static LLVM_ABI bool isValueValidForType(Type *Ty, const APFloat &V)
Return true if Ty is big enough to represent V.
 
static LLVM_ABI ConstantInt * getTrue(LLVMContext &Context)
 
static ConstantInt * getSigned(IntegerType *Ty, int64_t V)
Return a ConstantInt with the specified value for the specified type.
 
static LLVM_ABI ConstantInt * getFalse(LLVMContext &Context)
 
unsigned getBitWidth() const
getBitWidth - Return the scalar bitwidth of this constant.
 
static LLVM_ABI ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
 
static LLVM_ABI ConstantPtrAuth * get(Constant *Ptr, ConstantInt *Key, ConstantInt *Disc, Constant *AddrDisc)
Return a pointer signed with the specified parameters.
 
static LLVM_ABI std::optional< ConstantRangeList > getConstantRangeList(ArrayRef< ConstantRange > RangesRef)
 
static ConstantRange getNonEmpty(APInt Lower, APInt Upper)
Create non-empty constant range with the given bounds.
 
static LLVM_ABI Constant * get(StructType *T, ArrayRef< Constant * > V)
 
static LLVM_ABI Constant * getSplat(ElementCount EC, Constant *Elt)
Return a ConstantVector with the specified constant in each element.
 
static LLVM_ABI Constant * get(ArrayRef< Constant * > V)
 
This is an important base class in LLVM.
 
static LLVM_ABI Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
 
static LLVM_ABI DIArgList * get(LLVMContext &Context, ArrayRef< ValueAsMetadata * > Args)
 
static DIAssignID * getDistinct(LLVMContext &Context)
 
DebugEmissionKind getEmissionKind() const
 
DebugNameTableKind getNameTableKind() const
 
static LLVM_ABI DICompositeType * buildODRType(LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name, Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType, Metadata *SizeInBits, uint32_t AlignInBits, Metadata *OffsetInBits, Metadata *Specification, uint32_t NumExtraInhabitants, DIFlags Flags, Metadata *Elements, unsigned RuntimeLang, std::optional< uint32_t > EnumKind, Metadata *VTableHolder, Metadata *TemplateParams, Metadata *Discriminator, Metadata *DataLocation, Metadata *Associated, Metadata *Allocated, Metadata *Rank, Metadata *Annotations, Metadata *BitStride)
Build a DICompositeType with the given ODR identifier.
 
static LLVM_ABI std::optional< ChecksumKind > getChecksumKind(StringRef CSKindStr)
 
ChecksumKind
Which algorithm (e.g.
 
static LLVM_ABI std::optional< FixedPointKind > getFixedPointKind(StringRef Str)
 
static LLVM_ABI DIFlags getFlag(StringRef Flag)
 
static LLVM_ABI DISPFlags toSPFlags(bool IsLocalToUnit, bool IsDefinition, bool IsOptimized, unsigned Virtuality=SPFlagNonvirtual, bool IsMainSubprogram=false)
 
static LLVM_ABI DISPFlags getFlag(StringRef Flag)
 
DISPFlags
Debug info subprogram flags.
 
static LLVM_ABI DSOLocalEquivalent * get(GlobalValue *GV)
Return a DSOLocalEquivalent for the specified global value.
 
static LLVM_ABI Expected< DataLayout > parse(StringRef LayoutString)
Parse a data layout string and return the layout.
 
static LLVM_ABI DbgLabelRecord * createUnresolvedDbgLabelRecord(MDNode *Label, MDNode *DL)
For use during parsing; creates a DbgLabelRecord from as-of-yet unresolved MDNodes.
 
Kind
Subclass discriminator.
 
static LLVM_ABI DbgVariableRecord * createUnresolvedDbgVariableRecord(LocationType Type, Metadata *Val, MDNode *Variable, MDNode *Expression, MDNode *AssignID, Metadata *Address, MDNode *AddressExpression, MDNode *DI)
Used to create DbgVariableRecords during parsing, where some metadata references may still be unresol...
 
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...
 
static constexpr ElementCount getFixed(ScalarTy MinVal)
 
Error takeError()
Take ownership of the stored error.
 
reference get()
Returns a reference to the stored T value.
 
std::pair< ValueInfo, CalleeInfo > EdgeTy
<CalleeValueInfo, CalleeInfo> call edge pair.
 
static LLVM_ABI bool isValidArgumentType(Type *ArgTy)
Return true if the specified type is valid as an argument type.
 
Type::subtype_iterator param_iterator
 
static LLVM_ABI bool isValidReturnType(Type *RetTy)
Return true if the specified type is valid as a return type.
 
static LLVM_ABI FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
 
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
 
void setPrefixData(Constant *PrefixData)
 
void setGC(std::string Str)
 
void setPersonalityFn(Constant *Fn)
 
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
 
void setAlignment(Align Align)
Sets the alignment attribute of the Function.
 
void setAttributes(AttributeList Attrs)
Set the attribute list for this Function.
 
void setPrologueData(Constant *PrologueData)
 
void setCallingConv(CallingConv::ID CC)
 
static GEPNoWrapFlags inBounds()
 
static GEPNoWrapFlags noUnsignedWrap()
 
static GEPNoWrapFlags noUnsignedSignedWrap()
 
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
 
static LLVM_ABI Type * getIndexedType(Type *Ty, ArrayRef< Value * > IdxList)
Returns the result type of a getelementptr with the given source element type and indexes.
 
static bool isValidLinkage(LinkageTypes L)
 
static LLVM_ABI 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 LLVM_ABI 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...
 
LLVM_ABI void setComdat(Comdat *C)
 
LLVM_ABI void setSection(StringRef S)
Change the section for this global.
 
LLVM_ABI void addMetadata(unsigned KindID, MDNode &MD)
Add a metadata attachment.
 
static LLVM_ABI GUID getGUIDAssumingExternalLinkage(StringRef GlobalName)
Return a 64-bit global unique ID constructed from the name of a global symbol.
 
LLVM_ABI const SanitizerMetadata & getSanitizerMetadata() const
 
static bool isLocalLinkage(LinkageTypes Linkage)
 
void setUnnamedAddr(UnnamedAddr Val)
 
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
 
void setDLLStorageClass(DLLStorageClassTypes C)
 
void setThreadLocalMode(ThreadLocalMode Val)
 
void setLinkage(LinkageTypes LT)
 
DLLStorageClassTypes
Storage classes of global values for PE targets.
 
@ DLLExportStorageClass
Function to be accessible from DLL.
 
@ DLLImportStorageClass
Function to be imported from DLL.
 
bool hasSanitizerMetadata() const
 
unsigned getAddressSpace() const
 
void setDSOLocal(bool Local)
 
LLVM_ABI void eraseFromParent()
This method unlinks 'this' from the containing module and deletes it.
 
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.
 
static bool isValidDeclarationLinkage(LinkageTypes Linkage)
 
static LLVM_ABI std::string getGlobalIdentifier(StringRef Name, GlobalValue::LinkageTypes Linkage, StringRef FileName)
Return the modified name for a global value suitable to be used as the key for a global lookup (e....
 
void setVisibility(VisibilityTypes V)
 
LLVM_ABI void setSanitizerMetadata(SanitizerMetadata Meta)
 
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.
 
Type * getValueType() const
 
LLVM_ABI void setPartition(StringRef Part)
 
LLVM_ABI void setInitializer(Constant *InitVal)
setInitializer - Sets the initializer for this global variable, removing any existing initializer if ...
 
void setAttributes(AttributeSet A)
Set attribute list for this global.
 
void setConstant(bool Val)
 
LLVM_ABI void setCodeModel(CodeModel::Model CM)
Change the code model for this global.
 
void setExternallyInitialized(bool Val)
 
void setAlignment(Align Align)
Sets the alignment attribute of the GlobalVariable.
 
LLVM_ABI void addDestination(BasicBlock *Dest)
Add a destination.
 
static IndirectBrInst * Create(Value *Address, unsigned NumDests, InsertPosition InsertBefore=nullptr)
 
static LLVM_ABI 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.
 
static LLVM_ABI Error verify(FunctionType *Ty, StringRef Constraints)
This static method can be used by the parser to check to see if the specified constraint string is le...
 
static InsertElementInst * Create(Value *Vec, Value *NewElt, Value *Idx, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
 
static LLVM_ABI bool isValidOperands(const Value *Vec, const Value *NewElt, const Value *Idx)
Return true if an insertelement instruction can be formed with the specified operands.
 
static InsertValueInst * Create(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
 
LLVM_ABI void setFastMathFlags(FastMathFlags FMF)
Convenience function for setting multiple fast-math flags on this instruction, which must be an opera...
 
LLVM_ABI void setNonNeg(bool b=true)
Set or clear the nneg flag on this instruction, which must be a zext instruction.
 
bool isTerminator() const
 
LLVM_ABI void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
 
LLVM_ABI InstListType::iterator insertInto(BasicBlock *ParentBB, InstListType::iterator It)
Inserts an unlinked instruction into ParentBB at position It and returns the iterator of the inserted...
 
A wrapper class for inspecting calls to intrinsic functions.
 
static InvokeInst * Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)
 
lltok::Kind getKind() const
 
bool parseDIExpressionBodyAtBeginning(MDNode *&Result, unsigned &Read, const SlotMapping *Slots)
 
LLVMContext & getContext()
 
bool parseTypeAtBeginning(Type *&Ty, unsigned &Read, const SlotMapping *Slots)
 
bool parseStandaloneConstantValue(Constant *&C, const SlotMapping *Slots)
 
bool Run(bool UpgradeDebugInfo, DataLayoutCallbackTy DataLayoutCallback=[](StringRef, StringRef) { return std::nullopt;})
Run: module ::= toplevelentity*.
 
static LLVM_ABI LandingPadInst * Create(Type *RetTy, unsigned NumReservedClauses, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructors - NumReservedClauses is a hint for the number of incoming clauses that this landingpad w...
 
static MDTuple * getDistinct(LLVMContext &Context, ArrayRef< Metadata * > MDs)
 
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
 
static LLVM_ABI MDString * get(LLVMContext &Context, StringRef Str)
 
static MDTuple * getDistinct(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Return a distinct node.
 
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
 
static TempMDTuple getTemporary(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Return a temporary node.
 
static MemoryEffectsBase readOnly()
 
MemoryEffectsBase getWithModRef(Location Loc, ModRefInfo MR) const
Get new MemoryEffectsBase with modified ModRefInfo for Loc.
 
static MemoryEffectsBase argMemOnly(ModRefInfo MR=ModRefInfo::ModRef)
 
static MemoryEffectsBase inaccessibleMemOnly(ModRefInfo MR=ModRefInfo::ModRef)
 
static MemoryEffectsBase writeOnly()
 
static MemoryEffectsBase inaccessibleOrArgMemOnly(ModRefInfo MR=ModRefInfo::ModRef)
 
static MemoryEffectsBase none()
 
static MemoryEffectsBase unknown()
 
A Module instance is used to store all the information related to an LLVM module.
 
StringMap< Comdat > ComdatSymTabType
The type of the comdat "symbol" table.
 
LLVM_ABI void addOperand(MDNode *M)
 
static LLVM_ABI 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="", InsertPosition InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
 
static LLVM_ABI bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
 
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
 
static LLVM_ABI PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
 
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
 
static ResumeInst * Create(Value *Exn, InsertPosition InsertBefore=nullptr)
 
static ReturnInst * Create(LLVMContext &C, Value *retVal=nullptr, InsertPosition InsertBefore=nullptr)
 
Represents a location in source code.
 
constexpr const char * getPointer() const
 
static LLVM_ABI const char * areInvalidOperands(Value *Cond, Value *True, Value *False)
Return a string if the specified operands are invalid for a select operation, otherwise return null.
 
static SelectInst * Create(Value *C, Value *S1, Value *S2, const Twine &NameStr="", InsertPosition InsertBefore=nullptr, const Instruction *MDFrom=nullptr)
 
ArrayRef< int > getShuffleMask() const
 
static LLVM_ABI bool isValidOperands(const Value *V1, const Value *V2, const Value *Mask)
Return true if a shufflevector instruction can be formed with the specified operands.
 
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
 
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
 
reference emplace_back(ArgTypes &&... Args)
 
void reserve(size_type N)
 
void push_back(const T &Elt)
 
pointer data()
Return a pointer to the vector's buffer, even if empty().
 
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
 
iterator find(StringRef Key)
 
StringMapIterBase< Comdat, false > iterator
 
StringRef - Represent a constant reference to a string, i.e.
 
constexpr bool empty() const
empty - Check if the string is empty.
 
static LLVM_ABI StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
 
static LLVM_ABI StructType * create(LLVMContext &Context, StringRef Name)
This creates an identified struct.
 
static LLVM_ABI bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
 
LLVM_ABI Error setBodyOrError(ArrayRef< Type * > Elements, bool isPacked=false)
Specify a body for an opaque identified type or return an error if it would make the type recursive.
 
LLVM_ABI bool isScalableTy(SmallPtrSetImpl< const Type * > &Visited) const
Returns true if this struct contains a scalable vector.
 
static SwitchInst * Create(Value *Value, BasicBlock *Default, unsigned NumCases, InsertPosition InsertBefore=nullptr)
 
@ HasZeroInit
zeroinitializer is valid for this target extension type.
 
static LLVM_ABI Expected< TargetExtType * > getOrError(LLVMContext &Context, StringRef Name, ArrayRef< Type * > Types={}, ArrayRef< unsigned > Ints={})
Return a target extension type having the specified name and optional type and integer parameters,...
 
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
 
The instances of the Type class are immutable: once they are created, they are never changed.
 
static LLVM_ABI IntegerType * getInt64Ty(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 LLVM_ABI Type * getTokenTy(LLVMContext &C)
 
LLVM_ABI bool isScalableTy(SmallPtrSetImpl< const Type * > &Visited) const
Return true if this is a type whose size is a known multiple of vscale.
 
bool isLabelTy() const
Return true if this is 'label'.
 
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.
 
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
 
bool isBFloatTy() const
Return true if this is 'bfloat', a 16-bit bfloat type.
 
static LLVM_ABI Type * getLabelTy(LLVMContext &C)
 
LLVM_ABI unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
 
LLVM_ABI bool isFirstClassType() const
Return true if the type is "first class", meaning it is a valid type for a Value.
 
static LLVM_ABI IntegerType * getInt8Ty(LLVMContext &C)
 
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
 
LLVM_ABI TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
 
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
 
bool isAggregateType() const
Return true if the type is an aggregate 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.
 
static LLVM_ABI IntegerType * getInt1Ty(LLVMContext &C)
 
bool isFloatingPointTy() const
Return true if this is one of the floating-point types.
 
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
 
bool isFunctionTy() const
True if this is an instance of FunctionType.
 
bool isIntegerTy() const
True if this is an instance of IntegerType.
 
bool isTokenTy() const
Return true if this is 'token'.
 
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
 
bool isVoidTy() const
Return true if this is 'void'.
 
bool isMetadataTy() const
Return true if this is 'metadata'.
 
static LLVM_ABI UnaryOperator * Create(UnaryOps Op, Value *S, const Twine &Name=Twine(), InsertPosition InsertBefore=nullptr)
Construct a unary instruction, given the opcode and an operand.
 
static LLVM_ABI UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
 
LLVM Value Representation.
 
Type * getType() const
All values are typed, get the type of this value.
 
static constexpr uint64_t MaximumAlignment
 
LLVM_ABI void setName(const Twine &Name)
Change the name of the value.
 
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
 
LLVM_ABI void deleteValue()
Delete a pointer to a generic Value.
 
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
 
static LLVM_ABI VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
 
static LLVM_ABI bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
 
self_iterator getIterator()
 
A raw_ostream that writes to an std::string.
 
std::string & str()
Returns the string's reference.
 
LLVM_ABI unsigned getSourceLanguageName(StringRef SourceLanguageNameString)
 
LLVM_ABI unsigned getOperationEncoding(StringRef OperationEncodingString)
 
LLVM_ABI unsigned getAttributeEncoding(StringRef EncodingString)
 
LLVM_ABI unsigned getTag(StringRef TagString)
 
LLVM_ABI unsigned getCallingConvention(StringRef LanguageString)
 
LLVM_ABI unsigned getLanguage(StringRef LanguageString)
 
LLVM_ABI unsigned getVirtuality(StringRef VirtualityString)
 
LLVM_ABI unsigned getEnumKind(StringRef EnumKindString)
 
LLVM_ABI unsigned getMacinfo(StringRef MacinfoString)
 
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 Align[]
Key for Kernel::Arg::Metadata::mAlign.
 
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.
 
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.
 
@ AArch64_VectorCall
Used between AArch64 Advanced SIMD functions.
 
@ X86_64_SysV
The C convention as specified in the x86-64 supplement to the System V ABI, used on most non-Windows ...
 
@ RISCV_VectorCall
Calling convention used for RISC-V V-extension.
 
@ AMDGPU_CS
Used for Mesa/AMDPAL compute shaders.
 
@ AMDGPU_VS
Used for Mesa vertex shaders, or AMDPAL last shader stage before rasterization (vertex shader if tess...
 
@ AVR_SIGNAL
Used for AVR signal routines.
 
@ Swift
Calling convention for Swift.
 
@ AMDGPU_KERNEL
Used for AMDGPU code object kernels.
 
@ AArch64_SVE_VectorCall
Used between AArch64 SVE functions.
 
@ ARM_APCS
ARM Procedure Calling Standard (obsolete, but still used on some targets).
 
@ CHERIoT_CompartmentCall
Calling convention used for CHERIoT when crossing a protection boundary.
 
@ CFGuard_Check
Special calling convention on Windows for calling the Control Guard Check ICall funtion.
 
@ AVR_INTR
Used for AVR interrupt routines.
 
@ PreserveMost
Used for runtime calls that preserves most registers.
 
@ AnyReg
OBSOLETED - Used for stack based JavaScript calls.
 
@ AMDGPU_Gfx
Used for AMD graphics targets.
 
@ DUMMY_HHVM
Placeholders for HHVM calling conventions (deprecated, removed).
 
@ AMDGPU_CS_ChainPreserve
Used on AMDGPUs to give the middle-end more control over argument placement.
 
@ AMDGPU_HS
Used for Mesa/AMDPAL hull shaders (= tessellation control shaders).
 
@ ARM_AAPCS
ARM Architecture Procedure Calling Standard calling convention (aka EABI).
 
@ CHERIoT_CompartmentCallee
Calling convention used for the callee of CHERIoT_CompartmentCall.
 
@ AMDGPU_GS
Used for Mesa/AMDPAL geometry shaders.
 
@ AArch64_SME_ABI_Support_Routines_PreserveMost_From_X2
Preserve X2-X15, X19-X29, SP, Z0-Z31, P0-P15.
 
@ CHERIoT_LibraryCall
Calling convention used for CHERIoT for cross-library calls to a stateless compartment.
 
@ CXX_FAST_TLS
Used for access functions.
 
@ X86_INTR
x86 hardware interrupt context.
 
@ AArch64_SME_ABI_Support_Routines_PreserveMost_From_X0
Preserve X0-X13, X19-X29, SP, Z0-Z31, P0-P15.
 
@ AMDGPU_CS_Chain
Used on AMDGPUs to give the middle-end more control over argument placement.
 
@ GHC
Used by the Glasgow Haskell Compiler (GHC).
 
@ AMDGPU_PS
Used for Mesa/AMDPAL pixel shaders.
 
@ Cold
Attempts to make code in the caller as efficient as possible under the assumption that the call is no...
 
@ AArch64_SME_ABI_Support_Routines_PreserveMost_From_X1
Preserve X1-X15, X19-X29, SP, Z0-Z31, P0-P15.
 
@ X86_ThisCall
Similar to X86_StdCall.
 
@ PTX_Device
Call to a PTX device function.
 
@ SPIR_KERNEL
Used for SPIR kernel functions.
 
@ PreserveAll
Used for runtime calls that preserves (almost) all registers.
 
@ X86_StdCall
stdcall is mostly used by the Win32 API.
 
@ SPIR_FUNC
Used for SPIR non-kernel device functions.
 
@ Fast
Attempts to make calls as fast as possible (e.g.
 
@ MSP430_INTR
Used for MSP430 interrupt routines.
 
@ X86_VectorCall
MSVC calling convention that passes vectors and vector aggregates in SSE registers.
 
@ Intel_OCL_BI
Used for Intel OpenCL built-ins.
 
@ PreserveNone
Used for runtime calls that preserves none general registers.
 
@ AMDGPU_ES
Used for AMDPAL shader stage before geometry shader if geometry is in use.
 
@ Tail
Attemps to make calls as fast as possible while guaranteeing that tail call optimization can always b...
 
@ Win64
The C convention as implemented on Windows/x86-64 and AArch64.
 
@ PTX_Kernel
Call to a PTX kernel. Passes all arguments in parameter space.
 
@ SwiftTail
This follows the Swift calling convention in how arguments are passed but guarantees tail calls will ...
 
@ GRAAL
Used by GraalVM. Two additional registers are reserved.
 
@ AMDGPU_LS
Used for AMDPAL vertex shader if tessellation is in use.
 
@ ARM_AAPCS_VFP
Same as ARM_AAPCS, but uses hard floating point ABI.
 
@ X86_RegCall
Register calling convention used for parameters transfer optimization.
 
@ M68k_RTD
Used for M68k rtd-based CC (similar to X86's stdcall).
 
@ C
The default llvm calling convention, compatible with C.
 
@ X86_FastCall
'fast' analog of X86_StdCall.
 
@ BasicBlock
Various leaf nodes.
 
LLVM_ABI Function * getOrInsertDeclaration(Module *M, ID id, ArrayRef< Type * > Tys={})
Look up the Function declaration of the intrinsic id in the Module M.
 
LLVM_ABI ID lookupIntrinsicID(StringRef Name)
This does the actual lookup of an intrinsic ID which matches the given function name.
 
LLVM_ABI bool getIntrinsicSignature(Intrinsic::ID, FunctionType *FT, SmallVectorImpl< Type * > &ArgTys)
Gets the type arguments of an intrinsic call by matching type contraints specified by the ....
 
Flag
These should be considered private to the implementation of the MCInstrDesc class.
 
@ System
Synchronized with respect to all concurrently executing threads.
 
@ Valid
The data is already valid.
 
initializer< Ty > init(const Ty &Val)
 
@ DW_TAG_invalid
LLVM mock tags (see also llvm/BinaryFormat/Dwarf.def).
 
@ DW_MACINFO_invalid
Macinfo type for invalid results.
 
@ DW_APPLE_ENUM_KIND_invalid
Enum kind for invalid results.
 
@ DW_VIRTUALITY_invalid
Virtuality for invalid results.
 
@ kw_aarch64_sme_preservemost_from_x1
 
@ kw_no_sanitize_hwaddress
 
@ kw_cheriot_librarycallcc
 
@ kw_cheriot_compartmentcalleecc
 
@ kw_typeCheckedLoadConstVCalls
 
@ kw_aarch64_sve_vector_pcs
 
@ kw_cheriot_compartmentcallcc
 
@ kw_amdgpu_gfx_whole_wave
 
@ kw_typeTestAssumeConstVCalls
 
@ kw_typeidCompatibleVTable
 
@ kw_typeCheckedLoadVCalls
 
@ kw_inaccessiblemem_or_argmemonly
 
@ kw_externally_initialized
 
@ kw_sanitize_address_dyninit
 
@ kw_amdgpu_cs_chain_preserve
 
@ kw_available_externally
 
@ kw_typeTestAssumeVCalls
 
@ kw_aarch64_sme_preservemost_from_x0
 
@ kw_dso_local_equivalent
 
@ kw_aarch64_sme_preservemost_from_x2
 
NodeAddr< NodeBase * > Node
 
friend class Instruction
Iterator for Instructions in a `BasicBlock.
 
LLVM_ABI StringRef filename(StringRef path LLVM_LIFETIME_BOUND, Style style=Style::native)
Get filename.
 
This is an optimization pass for GlobalISel generic memory operations.
 
FunctionAddr VTableAddr Value
 
std::tuple< const DIScope *, const DIScope *, const DILocalVariable * > VarID
A unique key that represents a debug variable.
 
LLVM_ABI 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...
 
LLVM_ABI void UpgradeSectionAttributes(Module &M)
 
std::vector< VirtFuncOffset > VTableFuncList
List of functions referenced by a particular vtable definition.
 
SaveAndRestore(T &) -> SaveAndRestore< T >
 
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.
 
detail::scope_exit< std::decay_t< Callable > > make_scope_exit(Callable &&F)
 
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
 
std::array< uint32_t, 5 > ModuleHash
160 bits SHA1
 
LLVM_ABI bool UpgradeIntrinsicFunction(Function *F, Function *&NewFn, bool CanUpgradeDebugIntrinsicsToRecords=true)
This is a more granular function that simply checks an intrinsic function for upgrading,...
 
LLVM_ABI void UpgradeCallsToIntrinsic(Function *F)
This is an auto-upgrade hook for any old intrinsic function syntaxes which need to have both the func...
 
LLVM_ABI void UpgradeNVVMAnnotations(Module &M)
Convert legacy nvvm.annotations metadata to appropriate function attributes.
 
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...
 
auto cast_or_null(const Y &Val)
 
LLVM_ABI bool UpgradeModuleFlags(Module &M)
This checks for module flags which should be upgraded.
 
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
 
MemoryEffectsBase< IRMemLocation > MemoryEffects
Summary of how a function affects memory in the program.
 
void copyModuleAttrToFunctions(Module &M)
Copies module attributes to the functions in the module.
 
auto dyn_cast_or_null(const Y &Val)
 
@ Async
"Asynchronous" unwind tables (instr precise)
 
@ Sync
"Synchronous" unwind tables
 
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
 
void sort(IteratorTy Start, IteratorTy End)
 
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
 
bool isPointerTy(const Type *T)
 
FunctionAddr VTableAddr Count
 
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
 
CaptureComponents
Components of the pointer that may be captured.
 
iterator_range< SplittingIterator > split(StringRef Str, StringRef Separator)
Split the specified string over a separator and return a range-compatible iterable over its partition...
 
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
 
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
 
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
 
AtomicOrdering
Atomic ordering for LLVM's memory model.
 
@ Ref
The access may reference the value stored in memory.
 
@ ModRef
The access may reference and may modify the value stored in memory.
 
@ Mod
The access may modify the value stored in memory.
 
@ NoModRef
The access neither references nor modifies the value stored in memory.
 
@ ArgMem
Access to memory via argument pointers.
 
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
 
@ InaccessibleMem
Memory that is inaccessible via LLVM IR.
 
llvm::function_ref< std::optional< std::string >(StringRef, StringRef)> DataLayoutCallbackTy
 
auto count(R &&Range, const E &Element)
Wrapper function around std::count to count the number of times an element Element occurs in the give...
 
DWARFExpression::Operation Op
 
ArrayRef(const T &OneElt) -> ArrayRef< T >
 
std::string toString(const APInt &I, unsigned Radix, bool Signed, bool formatAsCLiteral=false, bool UpperCase=true, bool InsertSeparators=false)
 
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.
 
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
 
PointerUnion< const Value *, const PseudoSourceValue * > ValueType
 
LLVM_ABI bool UpgradeDebugInfo(Module &M)
Check the debug info version number, if it is out-dated, drop the debug info.
 
std::vector< TypeIdOffsetVtableInfo > TypeIdCompatibleVtableInfo
List of vtable definitions decorated by a particular type identifier, and their corresponding offsets...
 
static int64_t upperBound(StackOffset Size)
 
bool capturesNothing(CaptureComponents CC)
 
LLVM_ABI MDNode * UpgradeTBAANode(MDNode &TBAANode)
If the given TBAA tag uses the scalar TBAA format, create a new node corresponding to the upgrade to ...
 
std::vector< uint64_t > Args
 
unsigned ReturnDoesNotAlias
 
unsigned MustBeUnreachable
 
static constexpr uint32_t RangeWidth
 
std::vector< Call > Calls
In the per-module summary, it summarizes the byte offset applied to each pointer parameter before pas...
 
std::vector< ConstVCall > TypeCheckedLoadConstVCalls
 
std::vector< VFuncId > TypeCheckedLoadVCalls
 
std::vector< ConstVCall > TypeTestAssumeConstVCalls
List of virtual calls made by this function using (respectively) llvm.assume(llvm....
 
std::vector< GlobalValue::GUID > TypeTests
List of type identifiers used by this function in llvm.type.test intrinsics referenced by something o...
 
std::vector< VFuncId > TypeTestAssumeVCalls
List of virtual calls made by this function using (respectively) llvm.assume(llvm....
 
unsigned DSOLocal
Indicates that the linker resolved the symbol to a definition from within the same linkage unit.
 
unsigned CanAutoHide
In the per-module summary, indicates that the global value is linkonce_odr and global unnamed addr (s...
 
unsigned ImportType
This field is written by the ThinLTO indexing step to postlink combined summary.
 
unsigned NotEligibleToImport
Indicate if the global value cannot be imported (e.g.
 
unsigned Linkage
The linkage type of the associated global value.
 
unsigned Visibility
Indicates the visibility.
 
unsigned Live
In per-module summary, indicate that the global value must be considered a live root for index-based ...
 
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
 
This struct contains the mappings from the slot numbers to unnamed metadata nodes,...
 
std::map< unsigned, Type * > Types
 
StringMap< Type * > NamedTypes
 
std::map< unsigned, TrackingMDNodeRef > MetadataNodes
 
NumberedValues< GlobalValue * > GlobalValues
 
std::map< uint64_t, WholeProgramDevirtResolution > WPDRes
Mapping from byte offset to whole-program devirt resolution for that (typeid, byte offset) pair.
 
@ Unknown
Unknown (analysis not performed, don't lower)
 
@ Single
Single element (last example in "Short Inline Bit Vectors")
 
@ Inline
Inlined bit vector ("Short Inline Bit Vectors")
 
@ Unsat
Unsatisfiable type (i.e. no global has this type metadata)
 
@ AllOnes
All-ones bit vector ("Eliminating Bit Vector Checks for           All-Ones Bit Vectors")
 
@ ByteArray
Test a byte array (first example)
 
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.
 
enum llvm::ValID::@273232264270353276247031231016211363171152164072 Kind
 
Struct that holds a reference to a particular GUID in a global value summary.
 
const GlobalValueSummaryMapTy::value_type * getRef() const
 
@ UniformRetVal
Uniform return value optimization.
 
@ VirtualConstProp
Virtual constant propagation.
 
@ UniqueRetVal
Unique return value optimization.
 
@ Indir
Just do a regular virtual call.
 
uint64_t Info
Additional information for the resolution:
 
enum llvm::WholeProgramDevirtResolution::ByArg::Kind TheKind
 
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
 
@ SingleImpl
Single implementation devirtualization.
 
@ Indir
Just do a regular virtual call.
 
@ BranchFunnel
When retpoline mitigation is enabled, use a branch funnel that is defined in the merged module.