Parse the value symbol table at either the current parsing location or at the given bit offset if provided.
| 1947 | /// Parse the value symbol table at either the current parsing location or |
| 1948 | /// at the given bit offset if provided. |
| 1949 | Error BitcodeReader::parseValueSymbolTable(uint64_t Offset) { |
| 1950 | uint64_t CurrentBit; |
| 1951 | // Pass in the Offset to distinguish between calling for the module-level |
| 1952 | // VST (where we want to jump to the VST offset) and the function-level |
| 1953 | // VST (where we don't). |
| 1954 | if (Offset > 0) { |
| 1955 | CurrentBit = jumpToValueSymbolTable(Offset, Stream); |
| 1956 | // If this module uses a string table, read this as a module-level VST. |
| 1957 | if (UseStrtab) { |
| 1958 | if (Error Err = parseGlobalValueSymbolTable()) |
| 1959 | return Err; |
| 1960 | Stream.JumpToBit(CurrentBit); |
| 1961 | return Error::success(); |
| 1962 | } |
| 1963 | // Otherwise, the VST will be in a similar format to a function-level VST, |
| 1964 | // and will contain symbol names. |
| 1965 | } |
| 1966 | |
| 1967 | // Compute the delta between the bitcode indices in the VST (the word offset |
| 1968 | // to the word-aligned ENTER_SUBBLOCK for the function block, and that |
| 1969 | // expected by the lazy reader. The reader's EnterSubBlock expects to have |
| 1970 | // already read the ENTER_SUBBLOCK code (size getAbbrevIDWidth) and BlockID |
| 1971 | // (size BlockIDWidth). Note that we access the stream's AbbrevID width here |
| 1972 | // just before entering the VST subblock because: 1) the EnterSubBlock |
| 1973 | // changes the AbbrevID width; 2) the VST block is nested within the same |
| 1974 | // outer MODULE_BLOCK as the FUNCTION_BLOCKs and therefore have the same |
| 1975 | // AbbrevID width before calling EnterSubBlock; and 3) when we want to |
| 1976 | // jump to the FUNCTION_BLOCK using this offset later, we don't want |
| 1977 | // to rely on the stream's AbbrevID width being that of the MODULE_BLOCK. |
| 1978 | unsigned FuncBitcodeOffsetDelta = |
| 1979 | Stream.getAbbrevIDWidth() + bitc::BlockIDWidth; |
| 1980 | |
| 1981 | if (Stream.EnterSubBlock(bitc::VALUE_SYMTAB_BLOCK_ID)) |
| 1982 | return error("Invalid record"); |
| 1983 | |
| 1984 | SmallVector<uint64_t, 64> Record; |
| 1985 | |
| 1986 | Triple TT(TheModule->getTargetTriple()); |
| 1987 | |
| 1988 | // Read all the records for this value table. |
| 1989 | SmallString<128> ValueName; |
| 1990 | |
| 1991 | while (true) { |
| 1992 | BitstreamEntry Entry = Stream.advanceSkippingSubblocks(); |
| 1993 | |
| 1994 | switch (Entry.Kind) { |
| 1995 | case BitstreamEntry::SubBlock: // Handled for us already. |
| 1996 | case BitstreamEntry::Error: |
| 1997 | return error("Malformed block"); |
| 1998 | case BitstreamEntry::EndBlock: |
| 1999 | if (Offset > 0) |
| 2000 | Stream.JumpToBit(CurrentBit); |
| 2001 | return Error::success(); |
| 2002 | case BitstreamEntry::Record: |
| 2003 | // The interesting case. |
| 2004 | break; |
| 2005 | } |
| 2006 |
nothing calls this directly
no test coverage detected