Metadata carries debug information and other data attached to a module. LLVM’s
Bitcode File Format document leaves the metadata blocks as placeholders; the codes
below are those in LLVM’s LLVMBitCodes.h with the operand lists from its
comments, and the layouts of the strings, attachment and kind records from LLVM’s
writer (see sources). Operand lists that end in “…” continue
with fields that the operand layouts below give, from the
reader’s source.
METADATA block (15)
| Code | Record | Operands (header comment) |
|---|---|---|
1 | STRING_OLD | [values] |
2 | VALUE | [type num, value num] |
3 | NODE | [n × md num] |
4 | NAME | [values] |
5 | DISTINCT_NODE | [n × md num] |
6 | KIND | [n × [id, name]] |
7 | LOCATION | [distinct, line, col, scope, inlined-at?] |
8 | OLD_NODE | [n × (type num, value num)] |
9 | OLD_FN_NODE | [n × (type num, value num)] |
10 | NAMED_NODE | [n × mdnodes] |
11 | ATTACHMENT | [m × [value, [n × [id, mdnode]]]] |
12 | GENERIC_DEBUG | [distinct, tag, vers, header, n × md num] |
13 | SUBRANGE | [distinct, count, lo] |
14 | ENUMERATOR | [isUnsigned|distinct, value, name] |
15 | BASIC_TYPE | [distinct, tag, name, size, align, enc] |
16 | FILE | [distinct, filename, directory, checksumkind, checksum] |
17 | DERIVED_TYPE | [distinct, …] |
18 | COMPOSITE_TYPE | [distinct, …] |
19 | SUBROUTINE_TYPE | [distinct, flags, types, cc] |
20 | COMPILE_UNIT | [distinct, …] |
21 | SUBPROGRAM | [distinct, …] |
22 | LEXICAL_BLOCK | [distinct, scope, file, line, column] |
23 | LEXICAL_BLOCK_FILE | [distinct, scope, file, discriminator] |
24 | NAMESPACE | [distinct, scope, file, name, line, exportSymbols] |
25 | TEMPLATE_TYPE | [distinct, scope, name, type, …] |
26 | TEMPLATE_VALUE | [distinct, scope, name, type, value, …] |
27 | GLOBAL_VAR | [distinct, …] |
28 | LOCAL_VAR | [distinct, …] |
29 | EXPRESSION | [distinct, n × element] |
30 | OBJC_PROPERTY | [distinct, name, file, line, …] |
31 | IMPORTED_ENTITY | [distinct, tag, scope, entity, line, name] |
32 | MODULE | [distinct, scope, name, …] |
33 | MACRO | [distinct, macinfo, line, name, value] |
34 | MACRO_FILE | [distinct, macinfo, line, file, …] |
35 | STRINGS | [count, offset] blob([lengths][chars]); below |
36 | GLOBAL_DECL_ATTACHMENT | [valueid, n × [id, mdnode]] |
37 | GLOBAL_VAR_EXPR | [distinct, var, expr] |
38 | INDEX_OFFSET | [offset] |
39 | INDEX | [bitpos] |
40 | LABEL | [distinct, scope, name, file, line] |
41 | STRING_TYPE | [distinct, name, size, align, …] |
42, 43 | — | reserved for Fortran array debug information |
44 | COMMON_BLOCK | [distinct, scope, name, variable, …] |
45 | GENERIC_SUBRANGE | [distinct, count, lo, up, stride] |
46 | ARG_LIST | [n × [type num, value num]] |
47 | ASSIGN_ID | [distinct, …] |
48 | SUBRANGE_TYPE | [distinct, …] |
49 | FIXED_POINT_TYPE | [distinct, …] |
50 | PROPERTY | [distinct, name, file, line, type, backing_storage] |
51 | LAYERLOC | [distinct, line, column, file, kind]; layout below |
52 | LAYERLOCLIST | [distinct, n × layerloc]; layout below |
Operand layouts of the METADATA records
The order in which MetadataLoader.cpp (parseOneMetadata, main
branch, lines 1291 to 2556, compared case by case on 2026-11-19 for codes 1 to 49) reads
the operands, which is what the viewer names field by field. Where LLVM 22
(release/22.x) reads fewer operands, the row says “main only”. The operand count the
reader accepts is given in each row; any other count is Invalid record
(see the reader’s errors). Operand 0 of most
debug-information records holds flags: bit 0 is “distinct” (the node is not uniqued) and
the next bits are version or layout flags, named in the table. A reference to another
node is that node’s ID plus one (0 is null), except where the table says “ID”, which is
the ID itself. Metadata IDs count from 0: first every string of a STRINGS
record, then every node, in record order; a function’s own METADATA block continues
after the module’s. Sizes and offsets of types are plain numbers unless a flag says they
are metadata (a variable-length array’s size). The names of DWARF tags, encodings,
languages and operations, and of the DIFlag… and DISPFlag…
values, are the ones llvm-dis prints.
| Code | Record | Operands, in order (main reader) |
|---|---|---|
1 | STRING_OLD | the characters of one string, which takes one ID |
2 | VALUE | type, value number: a constant or other value used as metadata |
3, 5 | NODE, DISTINCT_NODE | for each element, a reference |
4, 10 | NAME, NAMED_NODE | NAME: the characters of a name; NAMED_NODE, which must follow it: for each element, an ID |
6 | KIND | kind ID, the characters of its name |
7 | LOCATION | distinct, line, column, scope (ID), inlined-at (reference), is-implicit-code, atom group, atom rank, IR layers (a reference to a LAYERLOCLIST); 5, 6, 8 or 9 operands (the reader on the main branch refuses 7 and more than 9) |
8, 9 | OLD_NODE, OLD_FN_NODE | old forms: pairs of type, value number; read for old files only |
11 | ATTACHMENT | see attachment |
12 | GENERIC_DEBUG | distinct, tag (below 65536), version (must be 0), header (string), then references; at least 4 operands |
13 | SUBRANGE | distinct and version (bit 0, bits 1 and up), then version 2: count, lower bound, upper bound, stride (references); versions 0 and 1: count (number, or reference), lower bound (number, sign-rotated); a version above 2 is refused |
14 | ENUMERATOR | flags (distinct, unsigned, wide integer), value (sign-rotated) or bit width, name, and for a wide integer its 64-bit words; at least 3 operands |
15 | BASIC_TYPE | flags (distinct, size is metadata), tag, name, size, align, encoding, flags, number of extra inhabitants, data size, file, line, scope (6 to 12 operands; the last three, operands 9 to 11, are main only, and LLVM 22 accepts 6 to 9) |
16 | FILE | distinct, filename, directory, checksum kind, checksum, source: exactly 3, 5 or 6 operands (a checksum is made only when both the kind and the checksum string are not 0) |
17 | DERIVED_TYPE | flags (distinct, size is metadata), tag, name, file, line, scope, base type, size, align, offset, flags, extra data, DWARF address space plus one, annotations, pointer-authentication data (12 to 15 operands; operands 13 and 14 are read only when both are present) |
18 | COMPOSITE_TYPE | flags (distinct, not used in a type reference, size is metadata), tag, name, file, line, scope, base type, size, align, offset, flags, elements, runtime language, vtable holder, template parameters, identifier, discriminator, data location, associated, allocated, rank, annotations, number of extra inhabitants, specification, enumeration kind, bit stride (16 to 26 operands; the alignment must fit in 32 bits; the enumeration kind is read when it is not DW_APPLE_ENUM_KIND_invalid) |
19 | SUBROUTINE_TYPE | distinct and version (below 2: an old type-reference array), flags, types, calling convention (3 or 4 operands) |
20 | COMPILE_UNIT | distinct (always), language (bit 63: a versioned language name), file, producer, is-optimised, flags, runtime version, split debug file name, emission kind, enums, retained types, subprograms (old), globals, imports, DWO ID, macros, split debug inlining, debug info for profiling, name table kind, ranges base address, sysroot, SDK, language version, language dialect (14 to 24 operands; the dialect, operand 23, is main only, LLVM 22 accepts 14 to 23, and a dialect above DW_LLVM_LANG_DIALECT_max is refused) |
21 | SUBPROGRAM | flags (distinct, has unit, has SP flags), scope, name, linkage name, file, line, type, scope line, containing type, SP flags, virtual index, flags, unit, template parameters, declaration, retained nodes, this-adjustment, thrown types, annotations, target function name, key instructions (18 to 22 operands: annotations from 19, target function name from 20, key instructions from 21; flags bit 0 distinct, 1 has unit, 2 has SP flags. A record with the SP flags but no unit is refused, as is an old-form record with a unit and fewer than 19 operands; files from before the SP flags have the older order the reader still accepts) |
22, 23 | LEXICAL_BLOCK, LEXICAL_BLOCK_FILE | distinct, scope, file, then line and column (exactly 5 operands); or discriminator (exactly 4) |
24 | NAMESPACE | flags (distinct, export symbols), scope, name (three operands; five in files that still had a file and a line) |
25, 26 | TEMPLATE_TYPE, TEMPLATE_VALUE | TEMPLATE_TYPE (3 or 4 operands): distinct, name, type, is-default (optional); TEMPLATE_VALUE (5 or 6): distinct, tag, name, type, is-default (only in the 6-operand form), value |
27 | GLOBAL_VAR | distinct and version (2 now), scope, name, linkage name, file, line, type, is-local, is-definition, declaration, template parameters, align, annotations (11 to 13 operands; the version is operand 0 shifted right by one: versions 0 and 1 are the older orders the reader upgrades, any other version is refused; in version 0 the declaration slot holds a variable reference or a constant, and an alignment above 32 bits is refused) |
28 | LOCAL_VAR | flags (distinct, has alignment), scope, name, file, line, type, argument number, flags, align, annotations (8 to 10 operands; files without the alignment flag and with more than 8 operands carry a tag after the first operand; the alignment must fit in 32 bits) |
29 | EXPRESSION | distinct and version (3 now; a version above 3 is refused), then the DWARF operations and their arguments as numbers; at least 1 operand. Versions 0 to 2 are upgraded as they are read (bit pieces become fragments, DW_OP_plus becomes DW_OP_plus_uconst, and so on) |
30 | OBJC_PROPERTY | distinct, name, file, line, setter, getter, attributes, type (exactly 8 operands) |
31 | IMPORTED_ENTITY | distinct, tag, scope, entity, line, name, file, elements (6 to 8 operands; the file is read from 7 operands and the line only then, the elements from 8) |
32 | MODULE | distinct, file, scope, name, configuration macros, include path, API notes file, line, is-declaration (5 to 9 operands; with 8 or more the file comes first as above, with 5 to 7 the record starts at the scope and has no file, line or is-declaration) |
33, 34 | MACRO, MACRO_FILE | distinct, macro type, line, then name and value; or file and nodes (each exactly 5 operands) |
35 | STRINGS | count, offset; the blob, below |
36 | GLOBAL_DECL_ATTACHMENT | value number, then pairs of kind, ID (an even operand count, or a value number beyond the module’s values, is refused) |
37 | GLOBAL_VAR_EXPR | distinct, variable, expression (null means the empty expression); exactly 3 operands |
38, 39 | INDEX_OFFSET, INDEX | the low and high 32 bits of the distance in bits from the end of the INDEX_OFFSET record to the INDEX record; for each node, the distance in bits from the node before |
40 | LABEL | flags (distinct, artificial), scope, name, file, line, column, coroutine suspend index (5 to 7 operands; an index of 2⁶⁴−1 means none, any other must fit in 32 bits) |
41 | STRING_TYPE | flags (distinct, size is metadata), tag, name, string length, length expression, location expression, size, align, encoding, character type (8 to 10 operands: the location expression, operand 5, is there from 9 operands, and everything after it moves up by one; the character type, operand 9, is read from 10 operands and is main only, LLVM 22 accepts 8 or 9) |
44 | COMMON_BLOCK | distinct, scope, declaration, name, file, line (the reader checks no operand count) |
45 | GENERIC_SUBRANGE | distinct, count, lower bound, upper bound, stride (references; the reader checks no operand count) |
46 | ARG_LIST | for each argument, an ID of a value used as metadata (not a forward reference, and every argument must be a value, not a node) |
47 | ASSIGN_ID | distinct (always 1: exactly 1 operand, and bit 0 must be set) |
48 | SUBRANGE_TYPE | flags (distinct, size is metadata), name, file, line, scope, size, align, flags, base type, lower bound, upper bound, stride, bias (exactly 13 operands) |
49 | FIXED_POINT_TYPE | flags (distinct, size is metadata), tag, name, size, align, encoding, flags, kind, factor, then the numerator and the denominator, each a word giving the bit width (low 32 bits) and the number of words (high 32 bits), then the words; then, in main only, optionally file, line and scope (at least 11 operands; after the two numbers either nothing or exactly three operands may follow) |
Codes 50 to 52 are in LLVM’s main branch (MetadataLoader.cpp, read
2026-11-19) and are not written or read by LLVM 22: llvm-bcanalyzer 22 shows
them as unknown codes.
| Code | Record | Operands, in order (main branch) |
|---|---|---|
50 | PROPERTY | exactly 6 operands: distinct, name (string), file (reference), line, type (reference), backing storage (reference). It is a DIProperty, written by llvm-dis as !DIProperty(name: "prop", file: !5, line: 12, type: !6, backing_storage: !N); an empty name, a null reference and a line of 0 are left out. |
51 | LAYERLOC | exactly 5 operands: distinct, line, column, file (ID), kind (ID of a string; the reader accepts any metadata and leaves a wrong type to the verifier). It is a DILayerLoc: !DILayerLoc(line: 13, column: 4, file: !5, kind: "glsl"); the line, the file and the kind are always written, the column only when not 0. |
52 | LAYERLOCLIST | at least 1 operand: distinct, then for each element the ID of a LAYERLOC. It is a DILayerLocList: !DILayerLocList(!8, !9). |
The IR-layers operand of a LOCATION (operand 8, a reference: ID plus one, 0 for
none) and the 8th operand of the function block’s DEBUG_LOC point at a
LAYERLOCLIST; llvm-dis writes it as irlayers: !N at the end of
the !DILocation(…), after atomGroup and atomRank. The sample
newrec-layers.bc, written by hand because no released tool can, holds one of each
record; llvm-bcanalyzer reads its records, and the viewer’s text follows the
writer functions of AsmWriter.cpp (writeDILocation,
writeDILayerLoc, writeDILayerLocList, writeDIProperty).
The STRINGS record
As written by LLVM: [count, offset] and a Blob. The blob starts with
count string lengths, each written as a VBR6 in bitstream form, padded to a
32-bit boundary; offset is the position in the blob where the characters
start, and the characters of all the strings follow one after another.
METADATA_ATTACHMENT block (16)
Inside a FUNCTION block. As written by LLVM, the function’s own attachments come
first in an ATTACHMENT record (code 11) of (kind, metadata)
pairs with no instruction number; then one ATTACHMENT record per
instruction that has attachments, starting with the instruction’s number and followed
by its pairs. Debug locations are not written here (they use DEBUG_LOC
records in the function block).
METADATA_KIND block (22)
One KIND record (code 6) per metadata kind name: the kind ID, then the
name’s characters. The writer leaves the block out when there are no names.
Summary blocks (19, 20, 24)
GLOBALVAL_SUMMARY (20), FULL_LTO_GLOBALVAL_SUMMARY (24) and MODULE_STRTAB (19) carry the summaries used for link-time optimisation. Record codes of the summary blocks:
| Code | Record | Code | Record |
|---|---|---|---|
1 | FS_PERMODULE | 18 | FS_CFI_FUNCTION_DECLS |
2 | FS_PERMODULE_PROFILE | 19 | FS_PERMODULE_RELBF |
3 | FS_PERMODULE_GLOBALVAR_INIT_REFS | 20 | FS_FLAGS |
4 | FS_COMBINED | 21 | FS_TYPE_ID |
5 | FS_COMBINED_PROFILE | 22 | FS_TYPE_ID_METADATA |
6 | FS_COMBINED_GLOBALVAR_INIT_REFS | 23 | FS_PERMODULE_VTABLE_GLOBALVAR_INIT_REFS |
7 | FS_ALIAS | 24 | FS_BLOCK_COUNT |
8 | FS_COMBINED_ALIAS | 25 | FS_PARAM_ACCESS |
9 | FS_COMBINED_ORIGINAL_NAME | 26 | FS_PERMODULE_CALLSITE_INFO |
10 | FS_VERSION | 27 | FS_PERMODULE_ALLOC_INFO |
11 | FS_TYPE_TESTS | 28 | FS_COMBINED_CALLSITE_INFO |
12 | FS_TYPE_TEST_ASSUME_VCALLS | 29 | FS_COMBINED_ALLOC_INFO |
13 | FS_TYPE_CHECKED_LOAD_VCALLS | 30 | FS_STACK_IDS |
14 | FS_TYPE_TEST_ASSUME_CONST_VCALL | 31 | FS_ALLOC_CONTEXT_IDS |
15 | FS_TYPE_CHECKED_LOAD_CONST_VCALL | 32 | FS_CONTEXT_RADIX_TREE_ARRAY |
16 | FS_VALUE_GUID | 33 | FS_COMBINED_ALLOC_INFO_NO_CONTEXT |
17 | FS_CFI_FUNCTION_DEFS |
The operands, as parseEntireSummary in the BitcodeReader.cpp of
llvm-project main reads them (lines 7975 to 8666, read 2026-11-19).
The block’s first record, FS_VERSION, gives the summary version. Main’s
ModuleSummaryIndex::BitcodeSummaryVersion is 14
(ModuleSummaryIndex.h line 1670) and its reader accepts 1 to 14; LLVM 22
(release/22.x, ModuleSummaryIndex.h line 1569) writes 12 and accepts 1 to 12.
An operand marked with a version is there only from that version on. The viewer reads
both layouts by the version the file states.
What differs between LLVM 22 and main
| Where | LLVM 22 (version 12) | Main (versions 13 and 14) |
|---|---|---|
Global value flags, bit 11 (getDecodedGVSummaryFlags, BitcodeReader.cpp line 1235; getEncodedGVSummaryFlags, BitcodeWriter.cpp line 1421) | Not read; the writer never sets it | NoRenameOnPromotion: the symbol keeps its name when promoted. Read whatever the summary version is |
Call edge word, bit 4 (getDecodedHotnessCallEdgeInfo, line 1262; getEncodedHotnessCallEdgeInfo, BitcodeWriter.cpp line 1437) | Not read; the writer never sets it | HasIndirectCall: at least one call to the callee is indirect (from value-profile metadata or !callees). Read whatever the version is |
FS_FLAGS, bit 11 (0x800; ModuleSummaryIndex.cpp getFlags line 119, setFlags line 170) | Not known; setFlags asserts the flags are at most 0x7ff | Speculative devirtualisation was enabled during the thin link. setFlags asserts at most 0xfff. Bit 2 (0x4) stays reserved and must not be reused |
MemProf records (codes 26 to 29 and 33), version 13 (BitcodeReader.cpp line 7999) | They precede the function summary they belong to and are kept in pending lists until it arrives | From version 13 they follow it. The reader attaches them to the last function summary (CurrentPrevailingFS) and skips them when that summary was not the prevailing copy |
FS_CFI_FUNCTION_DEFS and FS_CFI_FUNCTION_DECLS, version 14 (lines 8414 and 8435) | Pairs [string table offset, size]; the reader makes the GUID from the name | Triples [GUID, string table offset, size]; from version 14 the GUID is the one the writer stored. Before 14 the main reader still reads pairs |
Whole-program devirtualisation resolution kind (FS_TYPE_ID) | 0 Indir, 1 SingleImpl, 2 BranchFunnel | 3 Speculative as well (ModuleSummaryIndex.h line 1374) |
| Version check (line 8000) | “Invalid summary version N. Version should be in the range [1-12].” | “Invalid summary version N in module 'path'. Version should be in the range [1-14].” |
The rest of this section is common to both. When the first record of the block is
not FS_VERSION the reader fails with Invalid Summary Block: record for
version expected (the block starts with a sub-block or ends, line 7988) or
Invalid Summary Block: version expected (another record code, line 7993).
Further description of the operands:
A “value ID” is a global value’s number in the module (per-module records), or a
number given a GUID by FS_VALUE_GUID (combined records). A flags word is
the global value’s: bits 0 to 3 the linkage (the in-memory numbering, 0 external,
1 available externally, 2 linkonce, 3 linkonce ODR, 4 weak, 5 weak ODR, 6 appending,
7 internal, 8 private, 9 extern weak, 10 common), bit 4 not eligible to import, bit 5
live, bit 6 local, bit 7 can auto-hide, bits 8 and 9 the visibility, bit 10 import
as a declaration, bit 11 no rename on promotion (main only). Function flags: bit 0 read-none, 1 read-only, 2 no-recurse,
3 return-does-not-alias, 4 no-inline, 5 always-inline, 6 no-unwind, 7 may-throw,
8 has-unknown-call, 9 must-be-unreachable. Variable flags: bit 0 maybe read-only,
1 maybe write-only, 2 constant, bits 3 and up the virtual-call visibility (0 public,
1 linkage unit, 2 translation unit). A call edge is a callee value ID, followed in
the profile forms by a word whose bits 0 to 2 are the hotness (0 unknown, 1 cold,
2 none, 3 hot, 4 critical), bit 3 a tail-call flag and (main) bit 4 a has-indirect-call
flag, or in the relative-frequency form by a 28-bit relative block frequency and a
tail-call flag in bit 28 (a deprecated form that main still reads).
| Code | Record | Operands, in order |
|---|---|---|
1, 2, 19 | FS_PERMODULE, _PROFILE, _RELBF | value ID, flags, instruction count, function flags (version 4), number of references, read-only references (5), write-only references (7), the references (value IDs), then the call edges |
3 | FS_PERMODULE_GLOBALVAR_INIT_REFS | value ID, flags, variable flags (5), the references |
7 | FS_ALIAS | value ID, flags, aliasee value ID |
23 | FS_PERMODULE_VTABLE_GLOBALVAR_INIT_REFS | value ID, flags, variable flags, number of references, the references, then pairs of virtual function value ID, offset |
4, 5 | FS_COMBINED, _PROFILE | value ID, module ID, flags, instruction count, function flags (4), entry count (6), number of references, read-only references (5), write-only references (7), the references, then the call edges |
6, 8, 9 | FS_COMBINED_GLOBALVAR_INIT_REFS, _ALIAS, _ORIGINAL_NAME | value ID, module ID, flags, variable flags (5), the references; value ID, module ID, flags, aliasee value ID; the hash of the original name |
10, 20, 24 | FS_VERSION, FS_FLAGS, FS_BLOCK_COUNT | the version; the index flags (bit 0 dead stripping, 1 skip module by the distributed backend, 3 split LTO unit, 4 partially split, 5 attribute propagation, 6 DSO-local propagation, 7 whole-program visibility, 8 hot/cold new, 9 unified LTO, 10 internalise and promote, 11 speculative devirtualisation (main only); bit 2 is reserved); the number of basic blocks |
11 | FS_TYPE_TESTS | type identifier GUIDs the next function tests |
12, 13 | FS_TYPE_TEST_ASSUME_VCALLS, FS_TYPE_CHECKED_LOAD_VCALLS | pairs of type identifier, offset |
14, 15 | FS_TYPE_TEST_ASSUME_CONST_VCALL, FS_TYPE_CHECKED_LOAD_CONST_VCALL | type identifier, offset, the constant arguments |
16 | FS_VALUE_GUID | value ID, GUID (version 11: its upper and lower 32 bits) |
17, 18 | FS_CFI_FUNCTION_DEFS, _DECLS | up to version 13 pairs of string table offset, size of a function name; from version 14 triples of GUID, string table offset, size |
21 | FS_TYPE_ID | name offset and size in the string table, type test resolution kind (0 unsat, 1 byte array, 2 inline, 3 single, 4 all ones, 5 unknown), size-minus-1 bit width, alignment (log 2), size minus 1, bit mask, inline bits, then for each devirtualization slot: slot, kind (0 indirect, 1 single implementation, 2 branch funnel, 3 speculative (main only)), implementation name offset and size, the number of by-argument entries and each entry’s arguments, kind, info, byte and bit |
22 | FS_TYPE_ID_METADATA | name offset and size, then pairs of offset, vtable value ID |
25 | FS_PARAM_ACCESS | for each parameter: its number, the lower and upper bound of the offsets it is accessed at (sign-rotated), the number of calls, and for each call the callee’s parameter number, callee value ID and lower and upper bound |
26, 28 | FS_PERMODULE_CALLSITE_INFO, FS_COMBINED_CALLSITE_INFO | value ID, the stack ID indexes; combined: value ID, number of stack IDs, number of versions, the stack ID indexes, the versions. From version 13 these follow the function summary they belong to (before: they precede it) |
27, 29, 33 | FS_PERMODULE_ALLOC_INFO, FS_COMBINED_ALLOC_INFO, _NO_CONTEXT | the number of profiled contexts (and of versions, combined), then for each an allocation type (0 none, 1 not cold, 2 cold, 4 hot) and its stack IDs (a count and indexes, or an index into the radix tree array), then the versions. From version 13 these also follow the function summary they belong to (before: they precede it) |
30, 31, 32 | FS_STACK_IDS, FS_ALLOC_CONTEXT_IDS, FS_CONTEXT_RADIX_TREE_ARRAY | stack IDs (from version 12, each a pair of 32-bit halves, high first); full context IDs, likewise; the radix tree: a frame count, then frames or negative jumps |
1, 2 in block 19 | MST_ENTRY, MST_HASH | see below |
MODULE_STRTAB block (19)
| Code | Record | Operands |
|---|---|---|
1 | MST_ENTRY | [modid, namechar…] |
2 | MST_HASH | [5 × i32] |
What the readers refuse
Every error string of MetadataLoader.cpp (main branch, read 2026-11-19; line
numbers are those of that file) and the summary and MODULE_STRTAB errors of
BitcodeReader.cpp, each with its condition. A string is returned as the
error message of the whole read: the loader stops at the first one. The record layouts
above give the operand counts that decide most of the “Invalid record” cases.
METADATA, METADATA_ATTACHMENT and METADATA_KIND (MetadataLoader.cpp)
| Message | Line | Record or block | Condition |
|---|---|---|---|
Malformed block | 831, 1040, 1169, 2628, 2741 | METADATA (lazy scan, global declaration scan, eager load), METADATA_ATTACHMENT, METADATA_KIND | The next entry is a sub-block or a bitstream error where a record or the end of the block was expected |
Invalid record | 648 | EXPRESSION | The version (operand 0 shifted right by one) is above 3 |
Invalid record | 875 | INDEX_OFFSET | It does not have exactly 2 operands (the offset is operand 0 plus operand 1 shifted left by 32) |
Corrupted Metadata block | 909 | INDEX | The lazy scan meets an INDEX record by itself: it is only read by jumping to it from INDEX_OFFSET |
Invalid record | 1072, 1075, 2519, 2522 | GLOBAL_DECL_ATTACHMENT | The operand count is even (a value number and pairs make an odd count), or the value number is not below the number of values |
Invalid metadata: fwd refs into function blocks | 1103 | METADATA block inside a function | The module-level metadata still has forward references that were never resolved |
METADATA_NAME not followed by METADATA_NAMED_NODE | 1360 | NAME | The record after a NAME is not a NAMED_NODE |
Invalid named metadata: expect fwd ref to MDNode | 1370 | NAMED_NODE | An operand is not the ID of a node (a string, a value or an ID that is out of range) |
Invalid record | 1380, 1412 | OLD_FN_NODE, OLD_NODE | The operand count is odd |
Invalid value reference from old fn metadata | 1403 | OLD_FN_NODE | The value number cannot be resolved as a forward reference of the stated type |
Invalid record | 1420 | OLD_NODE | A type ID is not a known type |
Invalid value reference from old metadata | 1426 | OLD_NODE | The value number cannot be resolved as a forward reference of the stated type |
Invalid record | 1441, 1446 | VALUE | The operand count is not 2, or the type is unknown, metadata or void |
Invalid value reference from metadata | 1450 | VALUE | The value number cannot be resolved as a forward reference of the stated type |
Invalid record | 1475 | LOCATION | Fewer than 5 operands, exactly 7, or more than 9 (LLVM 22 accepts only 5, 6 and 8) |
Invalid record | 1496 | LAYERLOC (main only) | Not exactly 5 operands |
Invalid record | 1513 | LAYERLOCLIST (main only) | No operands at all |
Invalid record | 1526, 1533 | GENERIC_DEBUG | Fewer than 4 operands, or a tag of 65536 or more, or a version other than 0 |
Invalid record: Unsupported version of DISubrange | 1570 | SUBRANGE | The version (operand 0 shifted right by one) is above 2 |
Invalid record | 1592 | ENUMERATOR | Fewer than 3 operands |
Invalid record | 1615 | BASIC_TYPE | Fewer than 6 or more than 12 operands (22: more than 9) |
Invalid record | 1644, 1675 | FIXED_POINT_TYPE | Fewer than 11 operands; or the operands left after the numerator and denominator are neither none nor exactly 3 |
Invalid record | 1688 | STRING_TYPE | Fewer than 8 or more than 10 operands (22: more than 9) |
Invalid record | 1723 | DERIVED_TYPE | Fewer than 12 or more than 15 operands |
Invalid record | 1765 | SUBRANGE_TYPE | Not exactly 13 operands |
Invalid record | 1787 | COMPOSITE_TYPE | Fewer than 16 or more than 26 operands |
Alignment value is too large | 1801, 2300, 2369 | COMPOSITE_TYPE (operand 8), GLOBAL_VAR version 0 (operand 11), LOCAL_VAR with the alignment flag (operand 8) | The alignment does not fit in 32 bits |
Invalid record | 1910 | SUBROUTINE_TYPE | Fewer than 3 or more than 4 operands |
Invalid record | 1929 | MODULE | Fewer than 5 or more than 9 operands |
Invalid record | 1949 | FILE | The operand count is not 3, 5 or 6 |
Invalid record | 1972 | COMPILE_UNIT | Fewer than 14 or more than 24 operands (22: more than 23) |
Invalid DICompileUnit dialect value | 1988 | COMPILE_UNIT (main only) | Operand 23 is above DW_LLVM_LANG_DIALECT_max |
Invalid record | 2025, 2065, 2067 | SUBPROGRAM | Fewer than 18 or more than 22 operands; or no SP flags (operand 0 bit 2) but a unit (bit 1) and fewer than 19 operands; or the SP flags but no unit |
Invalid record | 2143, 2156 | LEXICAL_BLOCK, LEXICAL_BLOCK_FILE | Not exactly 5 or exactly 4 operands |
Invalid record | 2186 | NAMESPACE | The operand count is not 3 or 5 |
Invalid record | 2199, 2212 | MACRO, MACRO_FILE | Not exactly 5 operands |
Invalid record | 2225, 2240 | TEMPLATE_TYPE, TEMPLATE_VALUE | Not 3 or 4 operands, not 5 or 6 operands |
Invalid record | 2258, 2337 | GLOBAL_VAR | Fewer than 11 or more than 13 operands; or a version (operand 0 shifted right by one) above 2 |
Invalid DIAssignID record. | 2343 | ASSIGN_ID | Not exactly 1 operand |
Invalid DIAssignID record. Must be distinct | 2347 | ASSIGN_ID | Operand 0 bit 0 is not set |
Invalid record | 2356 | LOCAL_VAR | Fewer than 8 or more than 10 operands |
Invalid record | 2388 | LABEL | Fewer than 5 or more than 7 operands |
CoroSuspendIdx value is too large | 2399 | LABEL | Operand 6 is not 2⁶⁴−1 and does not fit in 32 bits |
Invalid record | 2415 | EXPRESSION | No operands |
Invalid record | 2432 | GLOBAL_VAR_EXPR | Not exactly 3 operands |
Invalid record | 2447 | OBJC_PROPERTY | Not exactly 8 operands |
Invalid record | 2463 | PROPERTY (main only) | Not exactly 6 operands |
Invalid DIImportedEntity record | 2477 | IMPORTED_ENTITY | Fewer than 6 or more than 8 operands |
Invalid record: DIArgList should not contain forward refs | 2543 | ARG_LIST | An operand is a temporary node (a forward reference) |
Invalid record | 2545 | ARG_LIST | An operand is not a value used as metadata |
Invalid record: metadata strings layout | 2565 | STRINGS | Not exactly 2 operands (count, offset) |
Invalid record: metadata strings with no strings | 2570 | STRINGS | The count is 0 |
Invalid record: metadata strings corrupt offset | 2572 | STRINGS | The offset is beyond the end of the blob |
Invalid record: metadata strings bad length | 2580 | STRINGS | The lengths run out (end of the length area) before all strings are read |
Invalid record: metadata strings truncated chars | 2586 | STRINGS | A length is larger than the characters left in the blob |
Invalid ID | 2601, 2664 | GLOBAL_DECL_ATTACHMENT, function attachment, instruction attachment | A kind ID was not defined by a METADATA_KIND record |
Invalid metadata attachment: expect fwd ref to MDNode | 2605 | GLOBAL_DECL_ATTACHMENT, function attachment | The attached ID is not a node |
Invalid record | 2650 | ATTACHMENT | No operands |
Invalid metadata attachment | 2685 | ATTACHMENT (instruction) | The attached ID is not a node (a function-local value is dropped without an error) |
Invalid record | 2714 | KIND | Fewer than 2 operands |
Conflicting METADATA_KIND records | 2721 | KIND | Two records give the same kind ID |
four report_fatal_error messages: lazyLoadOneMetadata failed jumping: …, lazyLoadOneMetadata failed advanceSkippingSubblocks: …, Can't lazyload MD, parseOneMetadata: …, Can't lazyload MD: … | 1218, 1223, 1230, 1233 | Lazy loading of one node | The jump, the next entry, the record read or the record’s own parse failed after the block was accepted; the process is aborted instead of returning an error |
An operand count that the reader does not check (COMMON_BLOCK, GENERIC_SUBRANGE, the operands past the checked count of DERIVED_TYPE and the like) is read as it stands: a short record makes the reader index past the end of the operands. A code that is not in the table, and 42 and 43, are ignored.
Summary and MODULE_STRTAB blocks (BitcodeReader.cpp)
| Message | Line | Record or block | Condition |
|---|---|---|---|
Invalid Summary Block: record for version expected | 7988 | GLOBALVAL_SUMMARY, FULL_LTO_GLOBALVAL_SUMMARY | The first entry of the block is not a record |
Invalid Summary Block: version expected | 7993 | same | The first record is not FS_VERSION |
Invalid summary version N in module 'path'. Version should be in the range [1-14]. | 8001 | FS_VERSION | The version is 0 or above 14 (LLVM 22: the message has no module path, and the range is [1-12]) |
Malformed block | 8043, 8688 | summary block, MODULE_STRTAB | A sub-block or a bitstream error where a record was expected |
Malformed block | 7568, 7648 | VALUE_SYMTAB and MODULE blocks, as the summary reader skims them | A sub-block or a bitstream error where a record was expected |
Invalid vst_code_entry record, Invalid vst_code_fnentry record | 7589, 7603 | VST_ENTRY, VST_FNENTRY (module versions below 2, with no string table) | The name characters are not all valid characters (convertToString fails); LLVM 22 says Invalid record for both |
Invalid source filename record | 7716 | SOURCE_FILENAME | The characters are not all valid |
Invalid hash length N | 7723 | MODULE_CODE_HASH | The operand count is not 5 |
Invalid vstoffset record | 7735 | VSTOFFSET | No operands |
Invalid global record | 7759 | GLOBALVAR, FUNCTION, ALIAS | After the two string table operands there are 3 operands or fewer (the linkage is operand 3 of what is left) |
Alias expects aliasee summary to be parsed | 8197 | FS_ALIAS | The aliasee value ID has no summary in this module yet (the aliasee’s record must come before the alias) |
Name attachment that does not follow a combined record | 8379 | FS_COMBINED_ORIGINAL_NAME | No combined function, variable or alias record came before it, or one already took the name |
Invalid code_entry record | 8708 | MST_ENTRY (main; LLVM 22: Invalid record) | The name operands are not all characters (convertToString fails) |
Invalid hash length N | 8719 | MST_HASH | The operand count is not 5 |
Invalid hash that does not follow a module path | 8721 | MST_HASH | No MST_ENTRY came before it, or the previous one already got a hash |
How the MODULE_STRTAB block is read
parseModuleStringTable (BitcodeReader.cpp lines 8670 to 8727) reads
only the combined index’s module table. MST_ENTRY (1): operand 0 is the module
ID and the rest are the characters of the module path; the reader adds the path to the
index and remembers the ID for it. MST_HASH (2): exactly five 32-bit words,
stored as the hash of the module whose MST_ENTRY came just before; each
hash applies once (after it is read no module is current). Any other code is ignored.
The only writer is IndexBitcodeWriter::writeModStrings
(BitcodeWriter.cpp lines 4402 to 4470), used when a combined index file is
written: for each module, in module-ID order, an MST_ENTRY (module ID, then the
path as 8-bit, 7-bit or char6 array, whichever abbreviation fits) and, only when some
word of the module’s hash is not 0, an MST_HASH with the five 32-bit words
(block abbreviation width 3).
Sources
- LLVMBitCodes.h – MetadataCodes, GlobalValueSummarySymtabCodes, ModulePathSymtabCodes, with their comments (main branch, November 2026)
- MetadataLoader.cpp – the operand layouts of records 1 to 52 and every error message (main branch, read 2026-11-19; release/22.x compared for the differences)
- BitcodeReader.cpp –
parseEntireSummary,parseModuleStringTable, the flag decoders and the summary reader’s errors (main branch and release/22.x, read 2026-11-19) - ModuleSummaryIndex.h and ModuleSummaryIndex.cpp –
BitcodeSummaryVersion(14 on main, 12 on release/22.x), the index flags, the devirtualisation resolution kinds - BitcodeWriter.cpp –
getEncodedGVSummaryFlags,getEncodedHotnessCallEdgeInfo, the CFI records andwriteModStrings - AsmWriter.cpp – the text of
DILocation,DILayerLoc,DILayerLocListandDIProperty - BitcodeWriter.cpp – the metadata strings blob, the attachment records and the kind records
- LLVM Bitcode File Format – METADATA_BLOCK and METADATA_ATTACHMENT (placeholders)