LLVM IR is written into the bitstream as
blocks and records. This page lists the block IDs and the records that describe a
module as a whole: its identification, globals and functions, attributes, types and
name tables. Record layouts are written as [field, field, …], the operands
in order. The sources are listed at the end; where LLVM’s
document and its current writer differ, both are shown.
Block IDs
| ID | Block |
|---|---|
0 | BLOCKINFO (part of the bitstream itself) |
1–7 | Reserved for the bitstream. |
8 | MODULE_BLOCK |
9 | PARAMATTR_BLOCK: attribute lists |
10 | PARAMATTR_GROUP_BLOCK: attribute groups |
11 | CONSTANTS_BLOCK: constants of the module or of a function |
12 | FUNCTION_BLOCK: one function body |
13 | IDENTIFICATION_BLOCK |
14 | VALUE_SYMTAB_BLOCK: value symbol table |
15 | METADATA_BLOCK |
16 | METADATA_ATTACHMENT |
17 | TYPE_BLOCK_NEW: the type table |
18 | USELIST_BLOCK |
19 | MODULE_STRTAB_BLOCK |
20 | GLOBALVAL_SUMMARY_BLOCK |
21 | OPERAND_BUNDLE_TAGS_BLOCK |
22 | METADATA_KIND_BLOCK |
23 | STRTAB_BLOCK: the string table |
24 | FULL_LTO_GLOBALVAL_SUMMARY_BLOCK |
25 | SYMTAB_BLOCK |
26 | SYNC_SCOPE_NAMES_BLOCK |
LLVM numbers its blocks from 8 (FIRST_APPLICATION_BLOCKID) in the order
above.
IDENTIFICATION block (13)
| Code | Record | Operands |
|---|---|---|
1 | STRING | [chars…]: identifies the producer |
2 | EPOCH | [epoch]: the bitcode epoch number |
Function offsets in the value symbol table are counted from one 32-bit word before this block.
MODULE block (8)
| Code | Record | Operands | Meaning |
|---|---|---|---|
1 | VERSION | [version] | Encoding version; see below. |
2 | TRIPLE | [chars…] | Target triple. |
3 | DATALAYOUT | [chars…] | Target data layout string. |
4 | ASM | [chars…] | Module-level inline assembly, pieces separated by newlines. |
5 | SECTIONNAME | [chars…] | One section name; globals and functions refer to these by 1-based index. |
6 | DEPLIB | [chars…] | A dependent library name. Deprecated; kept to read old files. |
7 | GLOBALVAR | see below | A global variable. |
8 | FUNCTION | see below | A function declaration or definition. |
9 | ALIAS_OLD | [alias type, aliasee val#, linkage, visibility] | Older form of an alias. (LLVM’s document describes its ALIAS record under this code.) |
10 | — | — | Not defined. |
11 | GCNAME | [chars…] | A garbage collector name; functions refer to these by 1-based index. |
12 | COMDAT | [strtab offset, strtab size, selection kind] | A COMDAT group; kinds below. (The header comment gives the older form [selection_kind, name].) |
13 | VSTOFFSET | [offset] | Where the module-level VALUE_SYMTAB block is: a 32-bit-word offset, written as a Fixed(32) field, counted from one word before the identification block. |
14 | ALIAS | [alias value type, addrspace, aliasee val#, linkage, visibility, …] | An alias. In version 2 the strtab offset and size come first. The document’s list continues: dllstorageclass, threadlocal, unnamed_addr, preemptionspecifier. |
15 | METADATA_VALUES_UNUSED | — | Not used. |
16 | SOURCE_FILENAME | [namechar…] | The source file name. |
17 | HASH | [5 × i32] | A hash of the module, five 32-bit words. |
18 | IFUNC | [ifunc value type, addrspace, resolver val#, linkage, visibility] | An indirect function. |
19 | ASM_PROPERTY | [name chars…, 0, value chars…] | A property of the module assembly record that follows it; see module records. |
20 | GUIDLIST | [2 words per GUID…] | A list of 64-bit GUIDs, each as two words; see module records. |
Module version
| Version | Meaning |
|---|---|
0 | The original encoding. |
1 | Instruction operands are relative value IDs; PHI operands are signed VBRs. |
2 | As 1, and names of globals, functions, aliases and COMDATs are in the STRTAB block, referred to by offset and size. The top-level value symbol table holds only FNENTRY records. |
GLOBALVAR record (7)
| Operand | Meaning |
|---|---|
| strtab offset, strtab size | The name in the STRTAB block (version 2). |
| pointer type | Type index (the document calls it the pointer type). |
| isconst | Current writer: bit 0 the variable is constant, bit 1 always set (explicit type), bits 2 and up the address space. |
| initid | 0 for no initialiser, otherwise the initialiser’s value ID plus 1. |
| linkage | Linkage code. |
| alignment | log₂ of the alignment plus 1. |
| section | 0, or a 1-based index into the SECTIONNAME records. |
| visibility | Visibility code. |
| threadlocal | Thread-local mode. |
| unnamed_addr | unnamed_addr code. |
| externally_initialized | Whether the variable is externally initialised. |
| dllstorageclass | DLL storage class. |
| comdat | The COMDAT of the variable (encoding not described in the document). |
| attributes | 0, or a 1-based index into the attribute lists. |
| preemptionspecifier | Preemption specifier. |
| partition offset, size | Current writer only, when needed: the partition name in the string table. |
| sanitizer metadata | Current writer only, or 0. |
| code model | Current writer only. |
The current writer uses a short form that leaves out the last twelve
operands: after the two name operands it writes 6 (type, isconst, initid, linkage,
alignment, section) instead of 18. The twelve left out are visibility, threadlocal,
unnamed_addr, externally_initialized, dllstorageclass, comdat, attributes,
preemptionspecifier, partition offset, partition size, sanitizer metadata and code
model. The full form is written when the variable is thread-local, has non-default
visibility, has an unnamed_addr, is externally initialised, has a non-default DLL
storage class, a comdat, attributes, is dso_local, has a partition, sanitizer
metadata or a code model (BitcodeWriter.cpp main, lines 1693 to 1736: the
operand comment at 1693-1696, the condition at 1706-1712, the twelve pushes at
1713-1731, the short-form abbreviation at 1733-1734).
FUNCTION record (8)
| Operand | Meaning |
|---|---|
| strtab offset, strtab size | The name in the STRTAB block (version 2). |
| type | Type index of the function type. |
| callingconv | Calling convention. |
| isproto | Non-zero for a declaration rather than a definition. |
| linkage | Linkage code. |
| paramattr | 0, or a 1-based index into the PARAMATTR_BLOCK’s ENTRY records. |
| alignment | log₂ of the alignment plus 1. |
| section | 0, or a 1-based SECTIONNAME index. |
| visibility | Visibility code. |
| gc | 0, or a 1-based GCNAME index. |
| unnamed_addr | unnamed_addr code. |
| prologuedata | 0, or the value ID of the prologue data plus 1. |
| dllstorageclass | DLL storage class. |
| comdat | The COMDAT of the function. |
| prefixdata | 0, or the value ID of the prefix data plus 1. |
| personalityfn | 0, or the value ID of the personality function plus 1. |
| preemptionspecifier | Preemption specifier. |
| address space, partition offset, partition size, preferred alignment | Appended by the current writer; not in the document. |
Code values
Linkage
| Code | Linkage (document) | Current writer |
|---|---|---|
0 | external | external |
1 | weak | — |
2 | appending | appending |
3 | internal | internal |
4 | linkonce | — |
5 | dllimport | — |
6 | dllexport | — |
7 | extern_weak | extern_weak |
8 | common | common |
9 | private | private |
10 | weak_odr | — |
11 | linkonce_odr | — |
12 | available_externally | available_externally |
13, 14 | deprecated | — |
16 | — | weak (weak_any) |
17 | — | weak_odr |
18 | — | linkonce (linkonce_any) |
19 | — | linkonce_odr |
The current writer (getEncodedLinkage) writes 16 to 19 for the weak and
linkonce linkages instead of the document’s 1, 4, 10 and 11. Code 15 is the obsolete
linkonce_odr_auto_hide: the reader (getDecodedLinkage) reads
it, and any code not listed, as external. What the reader makes of each code
is on module records.
Visibility
| Code | Visibility |
|---|---|
0 | default |
1 | hidden |
2 | protected |
Thread-local mode
| Code | Mode |
|---|---|
0 | not thread-local |
1 | thread-local, general dynamic (default) model |
2 | localdynamic |
3 | initialexec |
4 | localexec |
unnamed_addr
| Code | Value |
|---|---|
0 | not unnamed_addr |
1 | unnamed_addr |
2 | local_unnamed_addr |
DLL storage class
| Code | Class |
|---|---|
0 | default |
1 | dllimport |
2 | dllexport |
Preemption specifier
| Code | Value |
|---|---|
0 | dso_preemptable |
1 | dso_local |
COMDAT selection kind
| Code | Name in LLVMBitCodes.h |
|---|---|
1 | COMDAT_SELECTION_KIND_ANY |
2 | COMDAT_SELECTION_KIND_EXACT_MATCH |
3 | COMDAT_SELECTION_KIND_LARGEST |
4 | COMDAT_SELECTION_KIND_NO_DUPLICATES |
5 | COMDAT_SELECTION_KIND_SAME_SIZE |
Calling conventions
Names in lower case with cc are the document’s; the others are the
enumerator names in LLVM’s CallingConv.h. Codes 1 to 7, 12 (the removed
WebKit_JS), 22 to 63, 73 and 74 are not defined; the largest allowed
code is 1023.
| Code | Convention | Code | Convention |
|---|---|---|---|
0 | ccc | 85 | AVR_SIGNAL |
8 | fastcc | 86 | AVR_BUILTIN |
9 | coldcc | 87 | AMDGPU_VS |
10 | GHC | 88 | AMDGPU_GS |
11 | HiPE | 89 | AMDGPU_PS |
13 | anyregcc | 90 | AMDGPU_CS |
14 | preserve_mostcc | 91 | AMDGPU_KERNEL |
15 | preserve_allcc | 92 | X86_RegCall |
16 | swiftcc | 93 | AMDGPU_HS |
17 | cxx_fast_tlscc | 94 | MSP430_BUILTIN |
18 | tailcc | 95 | AMDGPU_LS |
19 | cfguard_checkcc | 96 | AMDGPU_ES |
20 | swifttailcc | 97 | AArch64_VectorCall |
21 | PreserveNone | 98 | AArch64_SVE_VectorCall |
64 | x86_stdcallcc (FirstTargetCC) | 99 | WASM_EmscriptenInvoke |
65 | x86_fastcallcc | 100 | AMDGPU_Gfx |
66 | arm_apcscc | 101 | M68k_INTR |
67 | arm_aapcscc | 102 | AArch64_SME_ABI_Support_Routines_PreserveMost_From_X0 |
68 | arm_aapcs_vfpcc | 103 | AArch64_SME_ABI_Support_Routines_PreserveMost_From_X2 |
69 | MSP430_INTR | 104 | AMDGPU_CS_Chain |
70 | X86_ThisCall | 105 | AMDGPU_CS_ChainPreserve |
71 | PTX_Kernel | 106 | M68k_RTD |
72 | PTX_Device | 107 | GRAAL |
75 | SPIR_FUNC | 108 | ARM64EC_Thunk_X64 |
76 | SPIR_KERNEL | 109 | ARM64EC_Thunk_Native |
77 | Intel_OCL_BI | 110 | RISCV_VectorCall |
78 | X86_64_SysV | 111 | AArch64_SME_ABI_Support_Routines_PreserveMost_From_X1 |
79 | Win64 | 112–123 | RISCV_VLSCall_32 to RISCV_VLSCall_65536 (32, 64, 128 … 65,536) |
80 | X86_VectorCall | 124 | AMDGPU_Gfx_WholeWave |
81, 82 | DUMMY_HHVM, DUMMY_HHVM_C (removed) | 125 | CHERIoT_CompartmentCall |
83 | X86_INTR | 126 | CHERIoT_CompartmentCallee |
84 | AVR_INTR | 127 | CHERIoT_LibraryCall |
Attribute blocks (9 and 10)
The PARAMATTR_GROUP block defines groups of attributes, each for one position. The PARAMATTR block lists attribute lists, each a list of group IDs; functions refer to a list by its 1-based number.
| Block | Code | Record | Operands |
|---|---|---|---|
| 9 | 1 | ENTRY_OLD | [paramidx0, attr0, paramidx1, attr1, …], LLVM 3.2 and earlier |
| 9 | 2 | ENTRY | [attrgrp0, attrgrp1, …] |
| 10 | 3 | GRP_CODE_ENTRY | [grpid, paramidx, attr0, attr1, …] |
paramidx: 0 is the return value, 0xFFFFFFFF the function,
and 1 upwards the parameters. Each attribute in a group entry starts with a kind
(the document gives 0, 1, 3 and 4; the current writer also writes 5 to 8):
| Kind | Followed by |
|---|---|
0 | an attribute code |
1 | an attribute code and an integer value |
3 | a string key with no value |
4 | a string key and a string value |
5 | a type attribute code with no type (writer) |
6 | a type attribute code and a type ID (writer) |
7 | an attribute code and a constant range, with its bit width (writer) |
8 | an attribute code, a count, a bit width, then the ranges (writer) |
Encoded values: allocsize is (EltSize << 32) | NumElts,
with −1 for an absent NumElts; vscale_range is
(Min << 32) | Max, a Max of 0 meaning no maximum. All the encodings are on
attributes.
Attribute codes
Codes from LLVMBitCodes.h; names are the textual names in
Attributes.td. Codes marked old have no entry in the current
Attributes.td and are shown by their ATTR_KIND_ name. Code 0
is unused.
| Code | Attribute | Code | Attribute |
|---|---|---|---|
1 | align | 57 | optforfuzzing |
2 | alwaysinline | 58 | shadowcallstack |
3 | byval | 59 | speculative_load_hardening |
4 | inlinehint | 60 | immarg |
5 | inreg | 61 | willreturn |
6 | minsize | 62 | nofree |
7 | naked | 63 | nosync |
8 | nest | 64 | sanitize_memtag |
9 | noalias | 65 | preallocated |
10 | nobuiltin | 66 | nomerge |
11 | NO_CAPTURE (old) | 67 | null_pointer_is_valid |
12 | noduplicate | 68 | noundef |
13 | noimplicitfloat | 69 | byref |
14 | noinline | 70 | mustprogress |
15 | nonlazybind | 71 | nocallback |
16 | noredzone | 72 | hot |
17 | noreturn | 73 | noprofile |
18 | nounwind | 74 | vscale_range |
19 | optsize | 75 | swiftasync |
20 | readnone | 76 | nosanitize_coverage |
21 | readonly | 77 | elementtype |
22 | returned | 78 | disable_sanitizer_instrumentation |
23 | returns_twice | 79 | nosanitize_bounds |
24 | signext | 80 | allocalign |
25 | alignstack | 81 | allocptr |
26 | ssp | 82 | allockind |
27 | sspreq | 83 | presplitcoroutine |
28 | sspstrong | 84 | fn_ret_thunk_extern |
29 | sret | 85 | skipprofile |
30 | sanitize_address | 86 | memory |
31 | sanitize_thread | 87 | nofpclass |
32 | sanitize_memory | 88 | optdebug |
33 | uwtable | 89 | writable |
34 | zeroext | 90 | coro_only_destroy_when_complete |
35 | builtin | 91 | dead_on_unwind |
36 | cold | 92 | range |
37 | optnone | 93 | sanitize_numerical_stability |
38 | inalloca | 94 | initializes |
39 | nonnull | 95 | hybrid_patchable |
40 | jumptable | 96 | sanitize_realtime |
41 | dereferenceable | 97 | sanitize_realtime_blocking |
42 | dereferenceable_or_null | 98 | coro_elide_safe |
43 | convergent | 99 | noext |
44 | safestack | 100 | nodivergencesource |
45 | ARGMEMONLY (old) | 101 | sanitize_type |
46 | swiftself | 102 | captures |
47 | swifterror | 103 | dead_on_return |
48 | norecurse | 104 | sanitize_alloc_token |
49 | INACCESSIBLEMEM_ONLY (old) | 105 | nocreateundeforpoison |
50 | INACCESSIBLEMEM_OR_ARGMEMONLY (old) | 106 | denormal_fpenv |
51 | allocsize | 107 | nooutline |
52 | writeonly | 108 | flatten |
53 | speculatable | 109 | noipa |
54 | strictfp | 110 | nofreeobj |
55 | sanitize_hwaddress | 111 | sanitize_concurrency |
56 | nocf_check | 112 | likely_module_local |
ENTRY_OLD attribute bits
In LLVM 3.2 and earlier each attribute set was one bitmap:
| Bit | Attribute | Bit | Attribute |
|---|---|---|---|
| 0 | zeroext | 11 | noinline |
| 1 | signext | 12 | alwaysinline |
| 2 | noreturn | 13 | optsize |
| 3 | inreg | 14 | ssp |
| 4 | sret | 15 | sspreq |
| 5 | nounwind | 16–31 | align: the alignment in bytes |
| 6 | noalias | 32 | nocapture |
| 7 | byval | 33 | noredzone |
| 8 | nest | 34 | noimplicitfloat |
| 9 | readnone | 35 | naked |
| 10 | readonly | 36 | inlinehint |
| 37–39 | alignstack n: log₂ of the alignment plus 1 | ||
| 40 | returns_twice | ||
| 41 | uwtable | ||
| 42 | nonlazybind | ||
| 43 | sanitize_address | ||
| 44 | minsize | ||
| 45 | noduplicate | ||
| 46 | sspstrong | ||
| 47 | sanitize_thread | ||
| 48 | sanitize_memory | ||
| 49 | nobuiltin | ||
| 50 | returned | ||
| 51 | cold |
Bits 52 and up are not read. The attributes page
gives the full table with the reader’s conversions (for example nocapture
becoming captures(none)).
TYPE block (17)
Types are numbered from 0 in the order of the records that define them; other records refer to types by that number.
| Code | Record | Operands | Type |
|---|---|---|---|
1 | NUMENTRY | [numentries] | Number of types. Defines no type. |
2 | VOID | — | void |
3 | FLOAT | — | 32-bit float |
4 | DOUBLE | — | 64-bit double |
5 | LABEL | — | label |
6 | OPAQUE | [ispacked] | An opaque structure; a STRUCT_NAME record before it gives its name. |
7 | INTEGER | [width] | iwidth |
8 | POINTER | [pointee type, address space] | A typed pointer. |
9 | FUNCTION_OLD | [vararg, attrid, retty, paramty…] | Old function type. |
10 | HALF | — | 16-bit half |
11 | ARRAY | [numelts, eltty] | Array |
12 | VECTOR | [numelts, eltty, scalable?] | Vector; the current writer adds a third operand, true, for a scalable vector, whose count is then the minimum. |
13 | X86_FP80 | — | x86 long double |
14 | FP128 | — | long double with a 112-bit mantissa |
15 | PPC_FP128 | — | PowerPC long double (two doubles) |
16 | METADATA | — | metadata |
17 | X86_MMX | — | x86_mmx (deprecated; the reader makes <1 x i64> of it, see types) |
18 | STRUCT_ANON | [ispacked, eltty…] | A literal structure. |
19 | STRUCT_NAME | [chars…] | Names the next structure. Defines no type. |
20 | STRUCT_NAMED | [ispacked, eltty…] | A named structure. |
21 | FUNCTION | [vararg, retty, paramty…] | A function type. |
22 | TOKEN | — | token |
23 | BFLOAT | — | brain floating point |
24 | X86_AMX | — | x86_amx |
25 | OPAQUE_POINTER | [addrspace] | ptr |
26 | TARGET_TYPE | [num type params, type params…, int params…] | A target extension type. |
27 | BYTE | [width] | A byte type, bwidth; see types. |
Name and symbol tables
VALUE_SYMTAB block (14)
| Code | Record | Operands | Meaning |
|---|---|---|---|
1 | ENTRY | [valueid, namechar…] | The name of a value. |
2 | BBENTRY | [bbid, namechar…] | The name of a basic block. |
3 | FNENTRY | [valueid, offset, namechar…] | A function and the position of its FUNCTION block: in 32-bit words, counted from one word before the identification block (the writer stores word offset + 1). In version 2 the name is left out. |
5 | COMBINED_ENTRY | not described | Used in combined summary indexes. |
STRTAB block (23)
One record, STRTAB_BLOB (code 1), whose Blob holds the names used by the
module, with no terminators. Records refer to a name by offset and size.
SYMTAB block (25)
One record, SYMTAB_BLOB (code 1), a Blob. Its contents are not described
in the bitcode document.
Other small blocks
| Block | Code | Record | Operands |
|---|---|---|---|
| OPERAND_BUNDLE_TAGS (21) | 1 | OPERAND_BUNDLE_TAG | [strchr…]: one tag name |
| SYNC_SCOPE_NAMES (26) | 1 | SYNC_SCOPE_NAME | one synchronisation scope name |
| METADATA_KIND (22) | 6 | KIND | [kind ID, name chars…] |
| USELIST (18) | 1 | DEFAULT | [index…, value-id] |
| USELIST (18) | 2 | BB | [index…, bb-id] |
Sources
- LLVM Bitcode File Format – “LLVM IR Encoding”: MODULE_BLOCK, PARAMATTR, PARAMATTR_GROUP, TYPE_BLOCK and STRTAB contents, linkage, visibility, TLS, unnamed_addr, DLL, preemption and calling-convention codes, ENTRY_OLD bits
- LLVMBitCodes.h – block IDs and every record, attribute and COMDAT code (main branch, November 2026)
- Attributes.td – textual attribute names
- CallingConv.h – calling-convention numbers
- BitcodeWriter.cpp – what the current writer emits: linkage codes, attribute kinds 5 to 8, isconst bits, extra GLOBALVAR and FUNCTION operands, VECTOR and OPAQUE operands, COMDAT operands, VSTOFFSET and FNENTRY offsets