@@ -1077,6 +1077,25 @@ pub struct VarDebugInfo<'tcx> {
10771077// BasicBlock
10781078
10791079rustc_index:: newtype_index! {
1080+ /// A node in the MIR [control-flow graph][CFG].
1081+ ///
1082+ /// There are no branches (e.g., `if`s, function calls, etc.) within a basic block, which makes
1083+ /// it easier to do [data-flow analyses] and optimizations. Instead, branches are represented
1084+ /// as an edge in a graph between basic blocks.
1085+ ///
1086+ /// Basic blocks consist of a series of [statements][Statement], ending with a
1087+ /// [terminator][Terminator]. Basic blocks can have multiple predecessors and successors,
1088+ /// however there is a MIR pass ([`CriticalCallEdges`]) that removes *critical edges*, which
1089+ /// are edges that go from a multi-successor node to a multi-predecessor node. This pass is
1090+ /// needed because some analyses require that there are no critical edges in the CFG.
1091+ ///
1092+ /// Read more about basic blocks in the [rustc-dev-guide][guide-mir].
1093+ ///
1094+ /// [CFG]: https://rustc-dev-guide.rust-lang.org/appendix/background.html#cfg
1095+ /// [data-flow analyses]:
1096+ /// https://rustc-dev-guide.rust-lang.org/appendix/background.html#what-is-a-dataflow-analysis
1097+ /// [`CriticalCallEdges`]: ../../rustc_mir/transform/add_call_guards/enum.AddCallGuards.html#variant.CriticalCallEdges
1098+ /// [guide-mir]: https://rustc-dev-guide.rust-lang.org/mir/
10801099 pub struct BasicBlock {
10811100 derive [ HashStable ]
10821101 DEBUG_FORMAT = "bb{}" ,
@@ -1093,6 +1112,7 @@ impl BasicBlock {
10931112///////////////////////////////////////////////////////////////////////////
10941113// BasicBlockData and Terminator
10951114
1115+ /// See [`BasicBlock`] for documentation on what basic blocks are at a high level.
10961116#[ derive( Clone , Debug , TyEncodable , TyDecodable , HashStable , TypeFoldable ) ]
10971117pub struct BasicBlockData < ' tcx > {
10981118 /// List of statements in this block.
0 commit comments