Skip to content

Commit 59eb476

Browse files
committed
Skip value-label analysis if no value labels are present.
1 parent c1e0be1 commit 59eb476

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

cranelift/codegen/src/machinst/lower.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,10 @@ impl<'func, I: VCodeInst> Lower<'func, I> {
783783
}
784784

785785
fn emit_value_label_markers_for_inst(&mut self, inst: Inst) {
786+
if self.f.dfg.values_labels.is_none() {
787+
return;
788+
}
789+
786790
debug!(
787791
"value labeling: srcloc {}: inst {}",
788792
self.srcloc(inst),
@@ -794,6 +798,10 @@ impl<'func, I: VCodeInst> Lower<'func, I> {
794798
}
795799

796800
fn emit_value_label_markers_for_block_args(&mut self, block: Block) {
801+
if self.f.dfg.values_labels.is_none() {
802+
return;
803+
}
804+
797805
debug!("value labeling: block {}", block);
798806
for &arg in self.f.dfg.block_params(block) {
799807
self.emit_value_label_marks_for_value(arg);

cranelift/codegen/src/machinst/vcode.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ pub struct VCode<I: VCodeInst> {
118118

119119
/// Constants.
120120
constants: VCodeConstants,
121+
122+
/// Are any debug value-labels present? If not, we can skip the
123+
/// post-emission analysis.
124+
has_value_labels: bool,
121125
}
122126

123127
/// A builder for a VCode function body. This builder is designed for the
@@ -251,6 +255,9 @@ impl<I: VCodeInst> VCodeBuilder<I> {
251255
}
252256
}
253257
}
258+
if insn.defines_value_label().is_some() {
259+
self.vcode.has_value_labels = true;
260+
}
254261
self.vcode.insts.push(insn);
255262
self.vcode.srclocs.push(self.cur_srcloc);
256263
if is_safepoint {
@@ -327,6 +334,7 @@ impl<I: VCodeInst> VCode<I> {
327334
generate_debug_info,
328335
insts_layout: RefCell::new((vec![], vec![], 0)),
329336
constants,
337+
has_value_labels: false,
330338
}
331339
}
332340

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

611619
/// Generates value-label ranges.
612620
pub fn value_labels_ranges(&self) -> crate::result::CodegenResult<Option<ValueLabelsRanges>> {
621+
if !self.has_value_labels {
622+
return Ok(None);
623+
}
624+
613625
let layout = &self.insts_layout.borrow();
614626
Ok(Some(debug::compute(
615627
&self.insts,

0 commit comments

Comments
 (0)