llvm-c166/llvm/docs/Reference.md
Zachary Yedidia f7b7ec8d55
[MC][X86] Reintroduce aligned instruction bundling (#175830)
Aligned bundling partitions instructions into fixed-size, naturally
aligned groups called bundles and guarantees that no instruction
crosses a bundle boundary, giving the instruction stream a single
canonical decoding. It is a building block for software-based fault
isolation: control flow cannot jump into the middle of an instruction
to manufacture a different, unchecked sequence, and when combined with
masking of indirect branch targets it constrains control flow to a
statically verifiable set of locations.

The previous target-independent implementation was removed in #148781,
which simplified MC by eliminating per-fragment BundlePadding, the
virtual emitInstToData, and BundleGroupBeforeFirstInst. This change
reimplements the feature in the X86 backend on top of the existing
MCBoundaryAlignFragment infrastructure added for branch alignment,
keeping the generic MC surface smaller:

* AsmParser parses .bundle_align_mode, .bundle_lock and .bundle_unlock
  and dispatches them through new MCStreamer hooks.
* MCAssembler holds the bundle size, MCObjectStreamer tracks whether a
  locked group is open, and MCBoundaryAlignFragment gains an
  align_to_end bit. No new per-fragment padding state.
* Padding is decided at layout time by computeBoundaryAlignSize, which
  pads only when an instruction or a locked group would cross a
  boundary, and NOP emission goes through writeControlledNops.
* X86AsmBackend opens a boundary-align fragment for each instruction, or
  one for a whole bundle-locked group, and reports the group size error
  at layout.

Improvements over the prior implementation:

* NOPs never span a bundle boundary.
* Labels never move.
* Bundle locks may not nest.
* Padding can be folded into neighboring instructions as otherwise
  ignored prefixes rather than standalone NOPs, reusing the existing
  --x86-pad-max-prefix-size option. Padding is only ever traded within
  the bundle that holds it, so nothing moves across a boundary.
* No codegen change and no extra layout work when the directives are not
  used.

Bundling is supported for X86 ELF only and the directives are rejected
elsewhere. Restrictions: bundle mode may be set once per file and cannot
be changed or turned off, it is incompatible with -x86-align-branch and
-mbranches-within-32B-boundaries, locked groups are allowed only in
executable sections, must fit within one bundle, must be closed before a
section change, and may not end in a bare instruction prefix.

Documented in llvm/docs/AlignedBundling.rst, with tests in
llvm/test/MC/X86/AlignedBundling.

---------

Co-authored-by: Taehyun Noh <taehyun@utexas.edu>
Co-authored-by: Fangrui Song <i@maskray.me>
2026-08-03 16:26:51 -07:00

6.3 KiB

Reference

LLVM and API reference documentation.

:hidden:

HowToUseAttributes
CommandGuide/index
OptBisect
SymbolizerMarkupFormat
PDB/index
GarbageCollection
Statepoints
LibFuzzer
FuzzingLLVM
LangRef
UndefinedBehavior
InAlloca
BitCodeFormat
MIRLangRef
GlobalISel/index
ConvergentOperations
TestingGuide
GwpAsan
XRay
XRayExample
FaultMaps
Atomics
ExceptionHandling
Extensions
AlignedBundling
HowToSetUpLLVMStyleRTTI
BlockFrequencyTerminology
BranchWeightMetadata
GetElementPtr
ScudoHardenedAllocator
MemoryModelRelaxationAnnotations
MemTagSanitizer
DependenceGraphs/index
SpeculativeLoadHardening
SegmentedStacks
MarkedUpDisassembly
StackMaps
Coroutines
PointerAuth
YamlIO
ConvergenceAndUniformity
MLGO
ContentAddressableStorage
CIBestPractices
GitHubActionsRunners
AIToolPolicy
CallGraphSection
InterfaceExportAnnotations
PCSectionsMetadata
QualGroup
Security
SecurityTransparencyReports
SystemLibrary
TransformMetadata
TypeMetadata
XRayFDRFormat

API Reference

Doxygen generated documentation
(classes)
{doc}HowToUseAttributes
Answers some questions about the new Attributes infrastructure.

LLVM Reference

Command Line Utilities

{doc}LLVM Command Guide <CommandGuide/index>
A reference manual for the LLVM command line utilities ("man" pages for LLVM tools).
{doc}llvm-reduce <CommandGuide/llvm-reduce>
Automatic bug finder and test-case reducer description and usage information.
{doc}OptBisect
A command line option for debugging optimization-induced failures.
{doc}SymbolizerMarkupFormat
A reference for the log symbolizer markup accepted by llvm-symbolizer.
{doc}The Microsoft PDB File Format <PDB/index>
A detailed description of the Microsoft PDB (Program Database) file format.

Garbage Collection

{doc}GarbageCollection
The interfaces source-language compilers should use for compiling GC'd programs.
{doc}Statepoints
This describes a set of experimental extensions for garbage collection support.

LibFuzzer

{doc}LibFuzzer
A library for writing in-process guided fuzzers.
{doc}FuzzingLLVM
Information on writing and using Fuzzers to find bugs in LLVM.

LLVM IR

{doc}LLVM Language Reference Manual <LangRef>
Defines the LLVM intermediate representation and the assembly form of the different nodes.
{doc}Undefined Behavior (UB) <UndefinedBehavior>
A guide on what UB/undef/poison are and when to use each one.
{doc}InAlloca
Description of the inalloca argument attribute.
{doc}BitCodeFormat
This describes the file format and encoding used for LLVM "bc" files.
{doc}Machine IR (MIR) Format Reference Manual <MIRLangRef>
A reference manual for the MIR serialization format, which is used to test LLVM's code generation passes.
{doc}GlobalISel/index
This describes the prototype instruction selection replacement, GlobalISel.
{doc}ConvergentOperations
Description of convergent operation semantics and related intrinsics.

Testing and Debugging

{doc}LLVM Testing Infrastructure Guide <TestingGuide>
A reference manual for using the LLVM testing infrastructure.
{doc}TestSuiteGuide
Describes how to compile and run the test-suite benchmarks.
{doc}GwpAsan
A sampled heap memory error detection toolkit designed for production use.

XRay

{doc}XRay
High-level documentation of how to use XRay in LLVM.
{doc}XRayExample
An example of how to debug an application with XRay.

Additional Topics

{doc}FaultMaps
LLVM support for folding control flow into faulting machine instructions.
{doc}Atomics
Information about LLVM's concurrency model.
{doc}ExceptionHandling
This document describes the design and implementation of exception handling in LLVM.
{doc}Extensions
LLVM-specific extensions to tools and formats LLVM seeks compatibility with.
{doc}AlignedBundling
The .bundle_align_mode, .bundle_lock, and .bundle_unlock assembler directives.
{doc}HowToSetUpLLVMStyleRTTI
How to make isa<>, dyn_cast<>, etc. available for clients of your class hierarchy.
{doc}BlockFrequencyTerminology
Provides information about terminology used in the BlockFrequencyInfo analysis pass.
{doc}BranchWeightMetadata
Provides information about Branch Prediction Information.
{doc}GetElementPtr
Answers to some very frequent questions about LLVM's most frequently misunderstood instruction.
{doc}ScudoHardenedAllocator
A library that implements a security-hardened malloc().
{doc}MemoryModelRelaxationAnnotations
Target-defined relaxation to LLVM's concurrency model.
{doc}MemTagSanitizer
Security hardening for production code aiming to mitigate memory related vulnerabilities. Based on the Armv8.5-A Memory Tagging Extension.
{doc}Dependence Graphs <DependenceGraphs/index>
A description of the design of the various dependence graphs such as the DDG (Data Dependence Graph).
{doc}SpeculativeLoadHardening
A description of the Speculative Load Hardening mitigation for Spectre v1.
{doc}SegmentedStacks
This document describes segmented stacks and how they are used in LLVM.
{doc}MarkedUpDisassembly
This document describes the optional rich disassembly output syntax.
{doc}StackMaps
LLVM support for mapping instruction addresses to the location of values and allowing code to be patched.
{doc}Coroutines
LLVM support for coroutines.
{doc}PointerAuth
A description of pointer authentication, its LLVM IR representation, and its support in the backend.
{doc}YamlIO
A reference guide for using LLVM's YAML I/O library.
{doc}ConvergenceAndUniformity
A description of uniformity analysis in the presence of irreducible control flow, and its implementation.
{doc}MLGO
Facilities for ML-Guided Optimization, such as collecting IR corpora from a build, interfacing with ML models, an exposing features for training.
{doc}ContentAddressableStorage
A reference guide for using LLVM's CAS library.
{doc}CIBestPractices
A list of guidelines and best practices to use when working on LLVM's CI systems.
{doc}GitHubActionsRunners
A reference for LLVM's GitHub Actions runner pools and their platform-specific constraints.