Make the CFG metadata computation conditional on a flag.
This commit is contained in:
@@ -486,6 +486,7 @@ impl<I: VCodeInst> VCode<I> {
|
||||
let _tt = timing::vcode_emit();
|
||||
let mut buffer = MachBuffer::new();
|
||||
let mut state = I::State::new(&*self.abi);
|
||||
let cfg_metadata = self.flags().machine_code_cfg_info();
|
||||
let mut bb_starts: Vec<Option<CodeOffset>> = vec![];
|
||||
|
||||
// The first M MachLabels are reserved for block indices, the next N MachLabels for
|
||||
@@ -513,19 +514,21 @@ impl<I: VCodeInst> VCode<I> {
|
||||
buffer.bind_label(MachLabel::from_block(block));
|
||||
label_insn_iix[block as usize] = start;
|
||||
|
||||
// Track BB starts. If we have backed up due to MachBuffer
|
||||
// branch opts, note that the removed blocks were removed.
|
||||
let cur_offset = buffer.cur_offset();
|
||||
if last_offset.is_some() && cur_offset <= last_offset.unwrap() {
|
||||
for i in (0..bb_starts.len()).rev() {
|
||||
if bb_starts[i].is_some() && cur_offset > bb_starts[i].unwrap() {
|
||||
break;
|
||||
if cfg_metadata {
|
||||
// Track BB starts. If we have backed up due to MachBuffer
|
||||
// branch opts, note that the removed blocks were removed.
|
||||
let cur_offset = buffer.cur_offset();
|
||||
if last_offset.is_some() && cur_offset <= last_offset.unwrap() {
|
||||
for i in (0..bb_starts.len()).rev() {
|
||||
if bb_starts[i].is_some() && cur_offset > bb_starts[i].unwrap() {
|
||||
break;
|
||||
}
|
||||
bb_starts[i] = None;
|
||||
}
|
||||
bb_starts[i] = None;
|
||||
}
|
||||
bb_starts.push(Some(cur_offset));
|
||||
last_offset = Some(cur_offset);
|
||||
}
|
||||
bb_starts.push(Some(cur_offset));
|
||||
last_offset = Some(cur_offset);
|
||||
|
||||
for iix in start..end {
|
||||
let srcloc = self.srclocs[iix as usize];
|
||||
@@ -606,19 +609,21 @@ impl<I: VCodeInst> VCode<I> {
|
||||
// Create `bb_edges` and final (filtered) `bb_starts`.
|
||||
let mut final_bb_starts = vec![];
|
||||
let mut bb_edges = vec![];
|
||||
for block in 0..self.num_blocks() {
|
||||
if bb_starts[block].is_none() {
|
||||
// Block was deleted by MachBuffer; skip.
|
||||
continue;
|
||||
}
|
||||
let from = bb_starts[block].unwrap();
|
||||
if cfg_metadata {
|
||||
for block in 0..self.num_blocks() {
|
||||
if bb_starts[block].is_none() {
|
||||
// Block was deleted by MachBuffer; skip.
|
||||
continue;
|
||||
}
|
||||
let from = bb_starts[block].unwrap();
|
||||
|
||||
final_bb_starts.push(from);
|
||||
// Resolve each `succ` label and add edges.
|
||||
let succs = self.block_succs(BlockIx::new(block as u32));
|
||||
for succ in succs.iter() {
|
||||
let to = buffer.resolve_label_offset(MachLabel::from_block(succ.get()));
|
||||
bb_edges.push((from, to));
|
||||
final_bb_starts.push(from);
|
||||
// Resolve each `succ` label and add edges.
|
||||
let succs = self.block_succs(BlockIx::new(block as u32));
|
||||
for succ in succs.iter() {
|
||||
let to = buffer.resolve_label_offset(MachLabel::from_block(succ.get()));
|
||||
bb_edges.push((from, to));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user