Skip to content

Commit

Permalink
coverage: Store a BCB's list of basic blocks as a boxed slice
Browse files Browse the repository at this point in the history
  • Loading branch information
Zalathar committed Jan 2, 2024
1 parent c52498d commit 87c2c03
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions compiler/rustc_mir_transform/src/coverage/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ impl CoverageGraph {
let mut bb_to_bcb = IndexVec::from_elem_n(None, num_basic_blocks);

let mut add_basic_coverage_block = |basic_blocks: &mut Vec<BasicBlock>| {
// Take the accumulated list of blocks, but leave
// Take the accumulated list of blocks as a boxed slice, but leave
// the vector's capacity intact to be reused for subsequent BCBs.
let basic_blocks = basic_blocks.split_off(0);
let basic_blocks: Box<[BasicBlock]> = basic_blocks.split_off(0).into();

let bcb = bcbs.next_index();
for &bb in basic_blocks.iter() {
bb_to_bcb[bb] = Some(bcb);
}
let bcb_data = BasicCoverageBlockData::from(basic_blocks);
let bcb_data = BasicCoverageBlockData::new(basic_blocks);
debug!("adding bcb{}: {:?}", bcb.index(), bcb_data);
bcbs.push(bcb_data);
};
Expand Down Expand Up @@ -281,11 +281,11 @@ rustc_index::newtype_index! {
/// significance.
#[derive(Debug, Clone)]
pub(super) struct BasicCoverageBlockData {
pub basic_blocks: Vec<BasicBlock>,
pub basic_blocks: Box<[BasicBlock]>,
}

impl BasicCoverageBlockData {
pub fn from(basic_blocks: Vec<BasicBlock>) -> Self {
pub fn new(basic_blocks: Box<[BasicBlock]>) -> Self {
assert!(basic_blocks.len() > 0);
Self { basic_blocks }
}
Expand Down

0 comments on commit 87c2c03

Please sign in to comment.