diff options
| author | bors <bors@rust-lang.org> | 2024-10-22 14:16:37 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-10-22 14:16:37 +0000 |
| commit | 86d69c705a552236a622eee3fdea94bf13c5f102 (patch) | |
| tree | 72f24a717c7f566c4e9283f4bf8541aca419522c /compiler/rustc_mir_transform/src | |
| parent | bca5fdebe0e539d123f33df5f2149d5976392e76 (diff) | |
| parent | 6db5f332af58fe9bccf6dd5f78be0768ff7e463d (diff) | |
| download | rust-86d69c705a552236a622eee3fdea94bf13c5f102.tar.gz rust-86d69c705a552236a622eee3fdea94bf13c5f102.zip | |
Auto merge of #132035 - matthiaskrgr:rollup-ty1e4q0, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #125205 (Fixup Windows verbatim paths when used with the `include!` macro) - #131049 (Validate args are correct for `UnevaluatedConst`, `ExistentialTraitRef`/`ExistentialProjection`) - #131549 (Add a note for `?` on a `impl Future<Output = Result<..>>` in sync function) - #131731 (add `TestFloatParse` to `tools.rs` for bootstrap) - #131732 (Add doc(plugins), doc(passes), etc. to INVALID_DOC_ATTRIBUTES) - #132006 (don't stage-off to previous compiler when CI rustc is available) - #132022 (Move `cmp_in_dominator_order` out of graph dominator computation) - #132033 (compiletest: Make `line_directive` return a `DirectiveLine`) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_mir_transform/src')
| -rw-r--r-- | compiler/rustc_mir_transform/src/coverage/graph.rs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/compiler/rustc_mir_transform/src/coverage/graph.rs b/compiler/rustc_mir_transform/src/coverage/graph.rs index d839f46cfbd..930fa129ef2 100644 --- a/compiler/rustc_mir_transform/src/coverage/graph.rs +++ b/compiler/rustc_mir_transform/src/coverage/graph.rs @@ -21,6 +21,10 @@ pub(crate) struct CoverageGraph { pub(crate) successors: IndexVec<BasicCoverageBlock, Vec<BasicCoverageBlock>>, pub(crate) predecessors: IndexVec<BasicCoverageBlock, Vec<BasicCoverageBlock>>, dominators: Option<Dominators<BasicCoverageBlock>>, + /// Allows nodes to be compared in some total order such that _if_ + /// `a` dominates `b`, then `a < b`. If neither node dominates the other, + /// their relative order is consistent but arbitrary. + dominator_order_rank: IndexVec<BasicCoverageBlock, u32>, } impl CoverageGraph { @@ -54,10 +58,27 @@ impl CoverageGraph { } } - let mut this = Self { bcbs, bb_to_bcb, successors, predecessors, dominators: None }; + let num_nodes = bcbs.len(); + let mut this = Self { + bcbs, + bb_to_bcb, + successors, + predecessors, + dominators: None, + dominator_order_rank: IndexVec::from_elem_n(0, num_nodes), + }; + assert_eq!(num_nodes, this.num_nodes()); this.dominators = Some(dominators::dominators(&this)); + // The dominator rank of each node is just its index in a reverse-postorder traversal. + let reverse_post_order = graph::iterate::reverse_post_order(&this, this.start_node()); + // The coverage graph is created by traversal, so all nodes are reachable. + assert_eq!(reverse_post_order.len(), this.num_nodes()); + for (rank, bcb) in (0u32..).zip(reverse_post_order) { + this.dominator_order_rank[bcb] = rank; + } + // The coverage graph's entry-point node (bcb0) always starts with bb0, // which never has predecessors. Any other blocks merged into bcb0 can't // have multiple (coverage-relevant) predecessors, so bcb0 always has @@ -162,7 +183,7 @@ impl CoverageGraph { a: BasicCoverageBlock, b: BasicCoverageBlock, ) -> Ordering { - self.dominators.as_ref().unwrap().cmp_in_dominator_order(a, b) + self.dominator_order_rank[a].cmp(&self.dominator_order_rank[b]) } /// Returns the source of this node's sole in-edge, if it has exactly one. |
