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 only the reader and writer source define; they are not listed here.
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]; recent, not documented |
52 | LAYERLOCLIST | [distinct, n × layerloc]; recent, not documented |
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 of these records are not described in the sources read and are not listed.
MODULE_STRTAB block (19)
| Code | Record | Operands |
|---|---|---|
1 | MST_ENTRY | [modid, namechar…] |
2 | MST_HASH | [5 × i32] |
Sources
- LLVMBitCodes.h – MetadataCodes, GlobalValueSummarySymtabCodes, ModulePathSymtabCodes, with their comments (main branch, November 2026)
- BitcodeWriter.cpp – the metadata strings blob, the attachment records and the kind records
- LLVM Bitcode File Format – METADATA_BLOCK and METADATA_ATTACHMENT (placeholders)