Skip to content

Commit

Permalink
Skip value-label analysis if no value labels are present.
Browse files Browse the repository at this point in the history
  • Loading branch information
cfallin committed Jan 10, 2021
1 parent c1e0be1 commit 59eb476
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cranelift/codegen/src/machinst/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,10 @@ impl<'func, I: VCodeInst> Lower<'func, I> {
}

fn emit_value_label_markers_for_inst(&mut self, inst: Inst) {
if self.f.dfg.values_labels.is_none() {
return;
}

debug!(
"value labeling: srcloc {}: inst {}",
self.srcloc(inst),
Expand All @@ -794,6 +798,10 @@ impl<'func, I: VCodeInst> Lower<'func, I> {
}

fn emit_value_label_markers_for_block_args(&mut self, block: Block) {
if self.f.dfg.values_labels.is_none() {
return;
}

debug!("value labeling: block {}", block);
for &arg in self.f.dfg.block_params(block) {
self.emit_value_label_marks_for_value(arg);
Expand Down
12 changes: 12 additions & 0 deletions cranelift/codegen/src/machinst/vcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ pub struct VCode<I: VCodeInst> {

/// Constants.
constants: VCodeConstants,

/// Are any debug value-labels present? If not, we can skip the
/// post-emission analysis.
has_value_labels: bool,
}

/// A builder for a VCode function body. This builder is designed for the
Expand Down Expand Up @@ -251,6 +255,9 @@ impl<I: VCodeInst> VCodeBuilder<I> {
}
}
}
if insn.defines_value_label().is_some() {
self.vcode.has_value_labels = true;
}
self.vcode.insts.push(insn);
self.vcode.srclocs.push(self.cur_srcloc);
if is_safepoint {
Expand Down Expand Up @@ -327,6 +334,7 @@ impl<I: VCodeInst> VCode<I> {
generate_debug_info,
insts_layout: RefCell::new((vec![], vec![], 0)),
constants,
has_value_labels: false,
}
}

Expand Down Expand Up @@ -610,6 +618,10 @@ impl<I: VCodeInst> VCode<I> {

/// Generates value-label ranges.
pub fn value_labels_ranges(&self) -> crate::result::CodegenResult<Option<ValueLabelsRanges>> {
if !self.has_value_labels {
return Ok(None);
}

let layout = &self.insts_layout.borrow();
Ok(Some(debug::compute(
&self.insts,
Expand Down

0 comments on commit 59eb476

Please sign in to comment.