@@ -1077,6 +1077,25 @@ pub struct VarDebugInfo<'tcx> {
1077
1077
// BasicBlock
1078
1078
1079
1079
rustc_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/
1080
1099
pub struct BasicBlock {
1081
1100
derive [ HashStable ]
1082
1101
DEBUG_FORMAT = "bb{}" ,
@@ -1093,6 +1112,7 @@ impl BasicBlock {
1093
1112
///////////////////////////////////////////////////////////////////////////
1094
1113
// BasicBlockData and Terminator
1095
1114
1115
+ /// See [`BasicBlock`] for documentation on what basic blocks are at a high level.
1096
1116
#[ derive( Clone , Debug , TyEncodable , TyDecodable , HashStable , TypeFoldable ) ]
1097
1117
pub struct BasicBlockData < ' tcx > {
1098
1118
/// List of statements in this block.
0 commit comments