Make the CFG metadata computation conditional on a flag.
This commit is contained in:
@@ -341,10 +341,16 @@ pub struct MachCompileResult {
|
||||
/// Debug info: stackslots to stack pointer offsets.
|
||||
pub stackslot_offsets: PrimaryMap<StackSlot, u32>,
|
||||
/// Basic-block layout info: block start offsets.
|
||||
///
|
||||
/// This info is generated only if the `machine_code_cfg_info`
|
||||
/// flag is set.
|
||||
pub bb_starts: Vec<CodeOffset>,
|
||||
/// Basic-block layout info: block edges. Each edge is `(from,
|
||||
/// to)`, where `from` and `to` are basic-block start offsets of
|
||||
/// the respective blocks.
|
||||
///
|
||||
/// This info is generated only if the `machine_code_cfg_info`
|
||||
/// flag is set.
|
||||
pub bb_edges: Vec<(CodeOffset, CodeOffset)>,
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -511,6 +511,7 @@ enable_atomics = true
|
||||
enable_safepoints = false
|
||||
enable_llvm_abi_extensions = false
|
||||
unwind_info = true
|
||||
machine_code_cfg_info = false
|
||||
emit_all_ones_funcaddrs = false
|
||||
enable_probestack = true
|
||||
probestack_func_adjusts_sp = false
|
||||
|
||||
Reference in New Issue
Block a user