From 602006ff9d1c8751eafb51c8a6fc1bde6ef06330 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 4 Feb 2021 11:46:20 +0100 Subject: [PATCH] Fix build_value_labels_ranges for newBE when there are no labels --- cranelift/codegen/src/isa/aarch64/mod.rs | 2 +- cranelift/codegen/src/isa/arm32/mod.rs | 2 +- cranelift/codegen/src/machinst/mod.rs | 2 +- cranelift/codegen/src/machinst/vcode.rs | 6 +++--- cranelift/codegen/src/value_label.rs | 8 ++------ 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/cranelift/codegen/src/isa/aarch64/mod.rs b/cranelift/codegen/src/isa/aarch64/mod.rs index fa7aa4ea60..f36fbbd55e 100644 --- a/cranelift/codegen/src/isa/aarch64/mod.rs +++ b/cranelift/codegen/src/isa/aarch64/mod.rs @@ -81,7 +81,7 @@ impl MachBackend for AArch64Backend { frame_size, disasm, unwind_info, - value_labels_ranges: None, + value_labels_ranges: Default::default(), stackslot_offsets, }) } diff --git a/cranelift/codegen/src/isa/arm32/mod.rs b/cranelift/codegen/src/isa/arm32/mod.rs index da557c4beb..98a5608e95 100644 --- a/cranelift/codegen/src/isa/arm32/mod.rs +++ b/cranelift/codegen/src/isa/arm32/mod.rs @@ -76,7 +76,7 @@ impl MachBackend for Arm32Backend { frame_size, disasm, unwind_info: None, - value_labels_ranges: None, + value_labels_ranges: Default::default(), stackslot_offsets, }) } diff --git a/cranelift/codegen/src/machinst/mod.rs b/cranelift/codegen/src/machinst/mod.rs index daece77ab5..a6354ac3b5 100644 --- a/cranelift/codegen/src/machinst/mod.rs +++ b/cranelift/codegen/src/machinst/mod.rs @@ -343,7 +343,7 @@ pub struct MachCompileResult { /// Unwind info. pub unwind_info: Option>, /// Debug info: value labels to registers/stackslots at code offsets. - pub value_labels_ranges: Option, + pub value_labels_ranges: ValueLabelsRanges, /// Debug info: stackslots to stack pointer offsets. pub stackslot_offsets: PrimaryMap, } diff --git a/cranelift/codegen/src/machinst/vcode.rs b/cranelift/codegen/src/machinst/vcode.rs index cb81610e95..8846103188 100644 --- a/cranelift/codegen/src/machinst/vcode.rs +++ b/cranelift/codegen/src/machinst/vcode.rs @@ -617,13 +617,13 @@ impl VCode { } /// Generates value-label ranges. - pub fn value_labels_ranges(&self) -> Option { + pub fn value_labels_ranges(&self) -> ValueLabelsRanges { if !self.has_value_labels { - return None; + return ValueLabelsRanges::default(); } let layout = &self.insts_layout.borrow(); - Some(debug::compute(&self.insts, &layout.0[..], &layout.1[..])) + debug::compute(&self.insts, &layout.0[..], &layout.1[..]) } /// Get the offsets of stackslots. diff --git a/cranelift/codegen/src/value_label.rs b/cranelift/codegen/src/value_label.rs index 3d3ca2ea99..82bfd3e30c 100644 --- a/cranelift/codegen/src/value_label.rs +++ b/cranelift/codegen/src/value_label.rs @@ -113,12 +113,8 @@ pub fn build_value_labels_ranges( where T: From + Deref + Ord + Copy, { - if mach_compile_result.is_some() && mach_compile_result.unwrap().value_labels_ranges.is_some() { - return mach_compile_result - .unwrap() - .value_labels_ranges - .clone() - .unwrap(); + if let Some(mach_compile_result) = mach_compile_result { + return mach_compile_result.value_labels_ranges.clone(); } let values_labels = build_value_labels_index::(func);