This page gives, for every record of the MODULE_BLOCK (block 8) and the IDENTIFICATION
block (13), the operands in order, what each means and the versions that differ. The
operand order and the checks are taken from LLVM’s reader
(BitcodeReader.cpp, parseModule and the functions it calls) and
from what the current writer emits (BitcodeWriter.cpp). The record codes and
code values are on module blocks. Line numbers are
those of the files on LLVM’s main branch as read in November 2026 (see
sources). Records and codes the reader does not know are skipped,
so a file is read as far as it makes sense.
File and identification block
The reader walks the top level of the stream (getBitcodeFileContents,
lines 8813–8920) and applies these rules:
- The file size must be a multiple of 4, or the reader reports
Invalid bitcode signature(line 139). A wrapper header is skipped first (Invalid bitcode wrapper header), then the bytesB C 0 C E D(four 4-bit fields after the two letters) are required:file doesn't start with bitcode header; a file under 4 bytes givesfile too small to contain bitcode header(lines 114–153). - It reads blocks until fewer than 8 bytes remain, because some tools leave garbage at the end.
- An IDENTIFICATION block (13) must be followed directly by a MODULE block (8),
or the reader reports
Malformed block. A block end or an error entry at the top level is alsoMalformed block. - Each MODULE block starts a module. A STRTAB block (23) belongs to every earlier module that has none yet. A SYMTAB block (25) is kept only the first time. Other blocks and records at this level are skipped.
IDENTIFICATION block records
| Code | Record | Operands | Meaning and checks |
|---|---|---|---|
1 | STRING | [chars…] | The producer, for example LLVM22.1.0. The writer writes "LLVM" followed by LLVM’s version string, with a Char6 array abbreviation (writeIdentificationBlock, line 5545). The reader appends the producer to every later error message as (Producer: '…' Reader: 'LLVM …'). |
2 | EPOCH | [epoch] | Must equal BITCODE_CURRENT_EPOCH, which is 0. Any other value gives Incompatible epoch: Bitcode 'N' vs current: '0' (lines 214–221). The writer writes it as a VBR6. |
Any other record code in the block is rejected with Invalid value (line
210). LLVMBitCodes.h (lines 75–81) states the intent of the epoch: LLVM
guarantees that a minor release can read bitcode written by earlier minor releases, so
the reader accepts only bitcode with its own epoch, except that an X.0 release also
accepts the epoch before. The epoch has been 0 throughout.
MODULE_BLOCK records
A name is a string-table reference, strtab offset then strtab size, from module version 2 (see VERSION), and for earlier versions it is in the value symbol table. When the pair is present it is the first two operands of GLOBALVAR, FUNCTION, ALIAS, IFUNC and COMDAT. The reader checks that the offset and the size both lie inside the string table (lines 477–489); if not, it treats the name as absent and the record as too short. The operand numbers below do not count the pair. “Value ID” means an absolute index into the module’s value list.
| Code | Record | Operands | Reader’s rule |
|---|---|---|---|
1 | VERSION | [version] | Empty: Invalid version record. Above 2: Invalid value (lines 466–475). Version 0: absolute operand IDs, names in the VST. Version 1 and above: relative IDs (UseRelativeIDs). Version 2 and above: names in the string table (UseStrtab). The writer writes 2 (line 171). |
2 | TRIPLE | [chars…] | An error, target triple too late in module, if it comes after the first FUNCTION record or function block (lines 4906–4914). |
3 | DATALAYOUT | [chars…] | datalayout too late in module under the same condition. The string is upgraded and parsed when the first FUNCTION record, FUNCTION block or the end of the block is reached; a parse failure is reported then. |
4 | ASM | [chars…] | One piece of module-level assembly. It takes the properties set by the ASM_PROPERTY records just before it. |
5 | SECTIONNAME | [chars…] | Appends to the section table. GLOBALVAR and FUNCTION refer to it by 1-based number; a number past the end is Invalid ID. |
6 | DEPLIB | [chars…] | Read and ignored (deprecated). |
7 | GLOBALVAR | below | Adds one value. |
8 | FUNCTION | below | Adds one value. |
9 | ALIAS_OLD | below | Adds one value. |
11 | GCNAME | [chars…] | Appends to the GC table; FUNCTION refers to it by 1-based number. |
12 | COMDAT | below | Appends to the COMDAT list. |
13 | VSTOFFSET | [offset] | Empty: Invalid vstoffset record. The offset is in 32-bit words and is one more than the real position, counted from one word before the IDENTIFICATION block (or, with none, the MODULE block); the reader subtracts 1 (line 4995). The writer emits a Fixed(32) field and fills it in after the function blocks (lines 1517–1538, 3782–3793). |
14 | ALIAS | below | Adds one value. |
15 | METADATA_VALUES_UNUSED | — | No case in the reader: ignored. |
16 | SOURCE_FILENAME | [chars…] | The source file name. |
17 | HASH | [5 words] | No case in BitcodeReader::parseModule: ignored. The writer fills it with a SHA-1 over the names it added to the string table and the bytes of the module block, as five 32-bit words read big-endian from the digest (lines 5567–5586, 1496–1500). |
18 | IFUNC | below | Adds one value. |
19 | ASM_PROPERTY | [name chars…, 0, value chars…] | The reader splits the operands at the first zero. No zero: Invalid module asm record. A property name the module does not accept: Unknown module asm property. It applies to the next ASM record (lines 4922–4932). The writer writes one record per property before each ASM record (lines 1577–1588). |
20 | GUIDLIST | [2 words per GUID…] | The reader joins each pair of operands into one 64-bit GUID, the first word as the high half (lines 4997–5004), and the list is kept for the summary. An odd number of operands is an assertion failure, not a reader error. |
A record code not in this table is ignored (line 4898). A sub-block whose ID the module
does not handle is skipped. The sub-blocks it does handle are BLOCKINFO, PARAMATTR (9),
PARAMATTR_GROUP (10), TYPE (17), VALUE_SYMTAB (14), CONSTANTS (11), METADATA (15),
METADATA_KIND (22), FUNCTION (12), USELIST (18), OPERAND_BUNDLE_TAGS (21) and
SYNC_SCOPE_NAMES (26). A stream error anywhere in the block is Malformed
block.
Values are numbered in the order the records appear: each GLOBALVAR, FUNCTION, ALIAS, ALIAS_OLD and IFUNC record takes the next value ID. The current writer writes all variables, then all functions, then aliases, then ifuncs (lines 1690–1820), but the reader does not require that order. The module-level CONSTANTS block then continues the numbering. In a function body the arguments, the function’s constants and then the instructions that produce a value continue it again.
Operand layouts
GLOBALVAR (7)
The reader’s comment gives the layout as version 1: [pointer type, isconst, initid,
linkage, alignment, section, visibility, threadlocal, unnamed_addr, externally_initialized,
dllstorageclass, comdat, attributes, preemption specifier, partition strtab offset,
partition strtab size]; version 2 puts the strtab offset and size in front; and
“v3” adds the code model at the end (lines 4287–4293). Fewer than 6 operands is
Invalid global variable record.
| No. | Operand | Meaning |
|---|---|---|
| 0 | type | A type ID. When bit 1 of operand 1 is set it is the variable’s value type. When it is clear the type must be a pointer and the reader takes the pointer’s element type (old files); otherwise Invalid type for value or Missing element type for old-style global. An unknown type ID is Invalid global variable record. |
| 1 | flags | Bit 0: constant. Bit 1: explicit type (the writer always sets it). Bits 2 and up: address space (writer: addrspace << 2 | 2 | isconstant). |
| 2 | initid | 0 for no initialiser, otherwise the initialiser’s value ID plus 1. The initialiser is resolved after the CONSTANTS block has been read. |
| 3 | linkage | See linkage. |
| 4 | alignment | 0 for none, else log₂ of the alignment plus 1 (see alignment). |
| 5 | section | 0 for none, else a 1-based index into the SECTIONNAME records. |
| 6 | visibility | 0 default, 1 hidden, 2 protected; any other value reads as default. Ignored (default) for a local linkage. |
| 7 | threadlocal | 0 none, 1 general dynamic, 2 local dynamic, 3 initial exec, 4 local exec; any other non-zero value reads as 1. |
| 8 | unnamed_addr | 0 none, 1 unnamed_addr, 2 local_unnamed_addr; other values read as 0. |
| 9 | externally_initialized | Non-zero is true. |
| 10 | dllstorageclass | 0 default, 1 dllimport, 2 dllexport; others read as default. Ignored for a local linkage. When the operand is missing, linkage codes 5 and 6 supply it instead (non-local only). |
| 11 | comdat | 0 for none, else a 1-based index into the COMDAT records; past the end is Invalid global variable comdat ID. When the operand is missing and the linkage code is 1, 4, 10 or 11, the variable gets a COMDAT named after itself, if the target supports them. |
| 12 | attributes | 0 for none, else a 1-based index into the attribute lists; its function-position attributes are put on the variable. An index past the end gives an empty list. |
| 13 | preemption specifier | 0 dso_preemptable, 1 dso_local. When absent or 0, dso_local is still set for a local linkage, or for a non-default visibility that is not extern_weak (line 4267). |
| 14, 15 | partition | String-table offset and size of the partition name, read only when both are present. The reader does not check them against the string table size here. |
| 16 | sanitizer metadata | Bit 0 no_address, bit 1 no_hwaddress, bit 2 memtag, bit 3 dyn_init (deserializeSanitizerMetadata, line 4274). Read only when non-zero. |
| 17 | code model | 0 for none; 1 tiny, 2 small, 3 kernel, 4 medium, 5 large. Any other non-zero value: Invalid global variable code model (lines 1302–1317, 4402–4407). |
The writer emits only the first 6 operands (type to section, after the name) for a variable that is not
thread-local, has default visibility and unnamed_addr, is not externally initialised,
has default DLL storage, no comdat, no attributes, is not dso_local, has no
partition, no sanitizer metadata and no code model; that short record uses an
abbreviation made for it. Otherwise it writes all 18 operands, after the name (lines 1690–1738).
FUNCTION (8)
Layout from the reader (lines 4420–4424): [type, callingconv, isproto, linkage,
paramattr, alignment, section, visibility, gc, unnamed_addr, prologuedata,
dllstorageclass, comdat, prefixdata, personalityfn, preemption specifier,
addrspace], with the strtab pair in front for version 2. The reader also reads
three more operands the comment leaves out. Fewer than 8 operands is Invalid
function record.
| No. | Operand | Meaning |
|---|---|---|
| 0 | type | The function type’s ID. If the ID is a pointer type the reader takes its element type (old files). Anything that is not a function type is Invalid type for value; an unknown ID is Invalid function record. |
| 1 | callingconv | A calling convention. A value with any bit above the largest ID (1023) set is Invalid calling convention ID. |
| 2 | isproto | Non-zero for a declaration. Otherwise the function has a body in a FUNCTION block. |
| 3 | linkage | See linkage. |
| 4 | paramattr | 0 for none, else a 1-based index into the PARAMATTR lists. An index past the end gives an empty list, with no error. |
| 5 | alignment | 0, or log₂ plus 1. |
| 6 | section | 0, or a 1-based SECTIONNAME number (Invalid ID past the end). |
| 7 | visibility | As for GLOBALVAR; ignored for a local linkage. |
| 8 | gc | 0, or a 1-based GCNAME number (Invalid ID past the end). |
| 9 | unnamed_addr | As for GLOBALVAR. |
| 10 | prologuedata | 0, or a value ID plus 1. |
| 11 | dllstorageclass | As for GLOBALVAR; when absent, linkage 5 and 6 supply it. |
| 12 | comdat | 0, or a 1-based COMDAT number; past the end is Invalid function comdat ID. With the operand absent, linkage codes 1, 4, 10 and 11 imply a COMDAT with the function’s own name. |
| 13 | prefixdata | 0, or a value ID plus 1. |
| 14 | personalityfn | 0, or a value ID plus 1. |
| 15 | preemption specifier | As for GLOBALVAR. |
| 16 | address space | The function’s address space. Without it the reader uses the data layout’s program address space. |
| 17, 18 | partition | String-table offset and size; used only if both are present and fit inside the string table. |
| 19 | preferred alignment | 0, or log₂ plus 1 (Invalid alignment value if too large). |
The writer always writes all 20 operands (lines 1741–1778). After the record the reader
adds byval, sret and inalloca types to old
attribute lists from the argument types, and adds the byval type for the
first argument of an x86_intrcc function. A function with isproto 0 gets a
body from the next unused FUNCTION block, in the order the records appear.
ALIAS_OLD (9), ALIAS (14) and IFUNC (18)
One reader function handles all three (parseGlobalIndirectSymbolRecord,
lines 4603–4688). The fixed part is 3 operands for ALIAS_OLD and 4 for the others; fewer
is Invalid global indirect symbol record.
| No. | ALIAS_OLD | ALIAS | IFUNC |
|---|---|---|---|
| 0 | pointer type (the value type is its element type) | value type | value type |
| 1 | aliasee value ID | address space | address space |
| 2 | linkage | aliasee value ID | resolver value ID |
| 3 | visibility (optional) | linkage | linkage |
| 4 | DLL storage class (optional) | visibility (optional) | visibility (optional) |
| 5 | thread-local mode (optional) | DLL storage class (optional) | preemption specifier (optional) |
| 6 | unnamed_addr (optional) | thread-local mode (optional) | partition offset, size (optional) |
| 7 | preemption specifier (optional) | unnamed_addr (optional) | |
| 8 | partition offset, size (optional) | preemption specifier (optional) | |
| 9 | partition offset, size (optional) |
Each optional operand is read only if the record has not ended. The aliasee or resolver is
an absolute value ID and is resolved after the CONSTANTS block. For an IFUNC the reader
does not read DLL storage, thread-local mode or unnamed_addr, although the comment on
MODULE_CODE_IFUNC in LLVMBitCodes.h and the reader’s own
version-1 comment list them; the writer does not write them either (lines 1804–1820).
A partition that runs past the string table is Malformed partition, too large.
The writer writes ALIAS as [strtab, type, address space, aliasee, linkage,
visibility, dllstorageclass, threadlocal, unnamed_addr, dso_local, partition offset,
partition size] (lines 1781–1802).
COMDAT (12)
| Version | Operands |
|---|---|
| 2 | [strtab offset, strtab size, selection kind] |
| 0 and 1 | [selection kind, name length, name chars…] |
The selection kind is 1 any, 2 exact match, 3 largest, 4 no duplicates, 5 same size
(table); any other value reads as “any”.
An empty record is Invalid comdat record; in versions 0 and 1 a record
without the length is the same error, and a length larger than the remaining operands is
Comdat name size too large (lines 4240–4265). The writer’s record is the
version 2 form (lines 1502–1512). Variables and functions refer to a COMDAT by its
1-based position.
Encoded values
Linkage
What getDecodedLinkage (lines 1166–1206) makes of each code; the code
values are also on module blocks. An
unlisted code reads as external, which settles the code that page called
undescribed.
| Code | Decoded linkage | Notes |
|---|---|---|
0 | external | Written for external. |
1 | weak (weak_any) | Old value: implies a COMDAT of the same name when the record has no comdat operand. |
2 | appending | Written. |
3 | internal | Written. |
4 | linkonce (linkonce_any) | Old value; implicit COMDAT. |
5 | external | Obsolete dllimport: sets DLL import if there is no DLL operand and the linkage is not local. |
6 | external | Obsolete dllexport: likewise sets DLL export. |
7 | extern_weak | Written. |
8 | common | Written. |
9 | private | Written. |
10 | weak_odr | Old value; implicit COMDAT. |
11 | linkonce_odr | Old value; implicit COMDAT. |
12 | available_externally | Written. |
13 | private | Obsolete linker_private. |
14 | private | Obsolete linker_private_weak. |
15 | external | Obsolete linkonce_odr_auto_hide. |
16 | weak_any | Written. |
17 | weak_odr | Written. |
18 | linkonce_any | Written. |
19 | linkonce_odr | Written. |
Visibility, thread-local mode, unnamed_addr, DLL storage, preemption
These are small enumerations; each decoder maps an unknown value to a default instead of failing (lines 1275–1337, 1450–1477). The tables are on module blocks.
| Field | Values | Unknown value reads as |
|---|---|---|
| Visibility | 0 default, 1 hidden, 2 protected | default |
| Thread-local mode | 0 not thread-local, 1 general dynamic, 2 local dynamic, 3 initial exec, 4 local exec | general dynamic (1), for any non-zero value |
| unnamed_addr | 0 none, 1 global (unnamed_addr), 2 local (local_unnamed_addr) | none |
| DLL storage class | 0 default, 1 import, 2 export | default |
| Preemption specifier | 0 preemptable, 1 dso_local | preemptable |
| COMDAT selection kind | 1 any … 5 same size | any |
| Calling convention | 0 to 1023 (see module blocks) | An ID with a bit above 1023 is an error; other values with no known meaning are kept as a numbered convention. |
Alignment
Alignment operands hold the exponent plus 1, so 0 is “not given” and n is an
alignment of 2n−1. A value larger than the largest allowed exponent
plus 1 is Invalid alignment value (parseAlignmentValue, line
2364). The same rule is used by the load, store, alloca, cmpxchg and atomicrmw records.
Errors the module reader gives
These are the messages and the conditions that raise them in the MODULE block. Every message gets the producer suffix when an IDENTIFICATION block named one.
| Message | When |
|---|---|
Malformed block | The stream is damaged inside the block, or an IDENTIFICATION block is not followed by a MODULE block, or a block ends at the top level. |
Invalid version record, Invalid value | Empty VERSION record; version above 2. |
target triple too late in module, datalayout too late in module | After the first function record or body. |
Invalid triple record, Invalid data layout record, Invalid asm record, Invalid section name record, Invalid gcname record, Invalid deplib record, Invalid source filename record | The string conversion failed. |
Invalid global variable record, Invalid function record, Invalid global indirect symbol record, Invalid comdat record | Too few operands or an unknown type ID. |
Invalid type for value, Missing element type for old-style global and its function, indirect-symbol forms | The type is of the wrong kind, or an old-style pointer type has no recorded element type. |
Invalid ID | A section or GC number is past the table. |
Invalid global variable comdat ID, Invalid function comdat ID | A COMDAT number past the list. |
Invalid calling convention ID | A function’s convention has a bit above 1023. |
Invalid alignment value | An alignment exponent that is too large. |
Invalid global variable code model | Code model operand above 5. |
Malformed partition, too large. | An alias or ifunc partition outside the string table. |
Incompatible epoch: … | The identification epoch is not 0. |
Invalid module asm record, Unknown module asm property | Bad ASM_PROPERTY. |
Invalid vstoffset record, Expected value symbol table subblock | Empty VSTOFFSET; the offset does not point at a VALUE_SYMTAB block. |
Missing element type for old-style function (line 4438), Missing element type for old-style indirect symbol (line 4634) | An old FUNCTION record whose type is a pointer, or an old ALIAS or IFUNC record whose type is a pointer, and the pointer type has no recorded element type (typed-pointer files). |
Missing param element type for x86_intrcc upgrade (line 4509) | A function with the x86_intrcc calling convention has a first parameter without a byval attribute and the type table gives no element type for it. |
Invalid multiple synchronization scope names blocks (line 3009), Invalid empty synchronization scope names block (line 3024) | A second SYNC_SCOPE_NAMES block in the module; a SYNC_SCOPE_NAMES block with no name at its end. |
Expected a single module (line 9113) | A program asks the reader for the one module of a buffer (getSingleModule) and the buffer holds none or several. |
Sources
All read from raw.githubusercontent.com/llvm/llvm-project/main/ in
November 2026 as single files.
- llvm/lib/Bitcode/Reader/BitcodeReader.cpp – lines 109–153 (header and size checks), 178–224 (identification), 458–489 (errors, version, string table names), 1154–1337 (decoders), 2364 (alignment), 4240–4688 (comdat, global variable, function, indirect symbols), 4690–5018 (
parseModule), 8813–8920 (top level) - llvm/lib/Bitcode/Writer/BitcodeWriter.cpp – lines 169–172 (version), 1353–1523 (encoders, comdats), 1568–1823 (module info), 3782–3824 (VST and VSTOFFSET back-patch), 5545–5648 (identification, hash, module order)
- llvm/include/llvm/Bitcode/LLVMBitCodes.h – lines 70–128 (identification codes, epoch, module codes), 842–848 (COMDAT kinds)
- llvm/docs/BitCodeFormat.md – the document is now Markdown (
BitCodeFormat.rstno longer exists on main); its MODULE_BLOCK section lists the version 1 and 2 layouts