diff --git a/cranelift/codegen/src/machinst/lower.rs b/cranelift/codegen/src/machinst/lower.rs index 7cb1c8d769..89e184fd4e 100644 --- a/cranelift/codegen/src/machinst/lower.rs +++ b/cranelift/codegen/src/machinst/lower.rs @@ -804,6 +804,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), @@ -815,6 +819,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); diff --git a/cranelift/codegen/src/machinst/vcode.rs b/cranelift/codegen/src/machinst/vcode.rs index 6b554359b6..9fc46d9655 100644 --- a/cranelift/codegen/src/machinst/vcode.rs +++ b/cranelift/codegen/src/machinst/vcode.rs @@ -118,6 +118,10 @@ pub struct VCode { /// 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 @@ -251,6 +255,9 @@ impl VCodeBuilder { } } } + 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 { @@ -327,6 +334,7 @@ impl VCode { generate_debug_info, insts_layout: RefCell::new((vec![], vec![], 0)), constants, + has_value_labels: false, } } @@ -610,6 +618,10 @@ impl VCode { /// Generates value-label ranges. pub fn value_labels_ranges(&self) -> crate::result::CodegenResult> { + if !self.has_value_labels { + return Ok(None); + } + let layout = &self.insts_layout.borrow(); Ok(Some(debug::compute( &self.insts,