This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +41
-1
lines changed
compiler/rustc_data_structures/src/graph/dominators Expand file tree Collapse file tree 1 file changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -135,7 +135,47 @@ pub fn dominators<G: ControlFlowGraph>(graph: G) -> Dominators<G::Node> {
135135 // This loop computes the semi[w] for w.
136136 semi[ w] = w;
137137 for v in graph. predecessors ( pre_order_to_real[ w] ) {
138- // Reachable vertices may have unreachable predecessors, so ignore any of them
138+ // TL;DR: Reachable vertices may have unreachable predecessors, so ignore any of them.
139+ //
140+ // Ignore blocks which are not connected to the entry block.
141+ //
142+ // The algorithm that was used to traverse the graph and build the
143+ // `pre_order_to_real` and `real_to_pre_order` vectors does so by
144+ // starting from the entry block and following the successors.
145+ // Therefore, any blocks not reachable from the entry block will be
146+ // set to `None` in the `pre_order_to_real` vector.
147+ //
148+ // For example, in this graph, A and B should be skipped:
149+ //
150+ // ┌─────┐
151+ // │ │
152+ // └──┬──┘
153+ // │
154+ // ┌──▼──┐ ┌─────┐
155+ // │ │ │ A │
156+ // └──┬──┘ └──┬──┘
157+ // │ │
158+ // ┌───────┴───────┐ │
159+ // │ │ │
160+ // ┌──▼──┐ ┌──▼──┐ ┌──▼──┐
161+ // │ │ │ │ │ B │
162+ // └──┬──┘ └──┬──┘ └──┬──┘
163+ // │ └──────┬─────┘
164+ // ┌──▼──┐ │
165+ // │ │ │
166+ // └──┬──┘ ┌──▼──┐
167+ // │ │ │
168+ // │ └─────┘
169+ // ┌──▼──┐
170+ // │ │
171+ // └──┬──┘
172+ // │
173+ // ┌──▼──┐
174+ // │ │
175+ // └─────┘
176+ //
177+ // ...this may be the case if a MirPass modifies the CFG to remove
178+ // or rearrange certain blocks/edges.
139179 let Some ( v) = real_to_pre_order[ v] else {
140180 continue
141181 } ;
You can’t perform that action at this time.
0 commit comments