| 973 | } |
| 974 | |
| 975 | Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata( |
| 976 | SmallVectorImpl<uint64_t> &Record, unsigned Code, |
| 977 | PlaceholderQueue &Placeholders, StringRef Blob, unsigned &NextMetadataNo) { |
| 978 | |
| 979 | bool IsDistinct = false; |
| 980 | auto getMD = [&](unsigned ID) -> Metadata * { |
| 981 | if (ID < MDStringRef.size()) |
| 982 | return lazyLoadOneMDString(ID); |
| 983 | if (!IsDistinct) { |
| 984 | if (auto *MD = MetadataList.lookup(ID)) |
| 985 | return MD; |
| 986 | // If lazy-loading is enabled, we try recursively to load the operand |
| 987 | // instead of creating a temporary. |
| 988 | if (ID < (MDStringRef.size() + GlobalMetadataBitPosIndex.size())) { |
| 989 | // Create a temporary for the node that is referencing the operand we |
| 990 | // will lazy-load. It is needed before recursing in case there are |
| 991 | // uniquing cycles. |
| 992 | MetadataList.getMetadataFwdRef(NextMetadataNo); |
| 993 | lazyLoadOneMetadata(ID, Placeholders); |
| 994 | return MetadataList.lookup(ID); |
| 995 | } |
| 996 | // Return a temporary. |
| 997 | return MetadataList.getMetadataFwdRef(ID); |
| 998 | } |
| 999 | if (auto *MD = MetadataList.getMetadataIfResolved(ID)) |
| 1000 | return MD; |
| 1001 | return &Placeholders.getPlaceholderOp(ID); |
| 1002 | }; |
| 1003 | auto getMDOrNull = [&](unsigned ID) -> Metadata * { |
| 1004 | if (ID) |
| 1005 | return getMD(ID - 1); |
| 1006 | return nullptr; |
| 1007 | }; |
| 1008 | auto getMDOrNullWithoutPlaceholders = [&](unsigned ID) -> Metadata * { |
| 1009 | if (ID) |
| 1010 | return MetadataList.getMetadataFwdRef(ID - 1); |
| 1011 | return nullptr; |
| 1012 | }; |
| 1013 | auto getMDString = [&](unsigned ID) -> MDString * { |
| 1014 | // This requires that the ID is not really a forward reference. In |
| 1015 | // particular, the MDString must already have been resolved. |
| 1016 | auto MDS = getMDOrNull(ID); |
| 1017 | return cast_or_null<MDString>(MDS); |
| 1018 | }; |
| 1019 | |
| 1020 | // Support for old type refs. |
| 1021 | auto getDITypeRefOrNull = [&](unsigned ID) { |
| 1022 | return MetadataList.upgradeTypeRef(getMDOrNull(ID)); |
| 1023 | }; |
| 1024 | |
| 1025 | #define GET_OR_DISTINCT(CLASS, ARGS) \ |
| 1026 | (IsDistinct ? CLASS::getDistinct ARGS : CLASS::get ARGS) |
| 1027 | |
| 1028 | switch (Code) { |
| 1029 | default: // Default behavior: ignore. |
| 1030 | break; |
| 1031 | case bitc::METADATA_NAME: { |
| 1032 | // Read name of the named metadata. |
nothing calls this directly
no test coverage detected