diff --git a/cranelift/codegen/src/isa/pulley_shared/mod.rs b/cranelift/codegen/src/isa/pulley_shared/mod.rs index 16aba8304e72..4b800670132d 100644 --- a/cranelift/codegen/src/isa/pulley_shared/mod.rs +++ b/cranelift/codegen/src/isa/pulley_shared/mod.rs @@ -193,6 +193,7 @@ where }) } + #[cfg(feature = "unwind")] fn emit_unwind_info( &self, _result: &crate::CompiledCode, diff --git a/cranelift/codegen/src/isa/unwind.rs b/cranelift/codegen/src/isa/unwind.rs index ada37b03ccbb..7b842ac7e4ab 100644 --- a/cranelift/codegen/src/isa/unwind.rs +++ b/cranelift/codegen/src/isa/unwind.rs @@ -15,6 +15,7 @@ pub mod winx64; pub mod winarm64; /// CFA-based unwind information used on SystemV. +#[cfg(feature = "unwind")] pub type CfaUnwindInfo = systemv::UnwindInfo; /// Expected unwind info type. diff --git a/cranelift/codegen/src/isa/x64/mod.rs b/cranelift/codegen/src/isa/x64/mod.rs index 7545a6f14835..c250d7402bf9 100644 --- a/cranelift/codegen/src/isa/x64/mod.rs +++ b/cranelift/codegen/src/isa/x64/mod.rs @@ -28,6 +28,7 @@ mod lower; mod pcc; pub mod settings; +#[cfg(feature = "unwind")] pub use inst::unwind::systemv::create_cie; /// An X64 backend. @@ -184,6 +185,7 @@ impl TargetIsa for X64Backend { } /// Emit unwind info for an x86 target. +#[cfg(feature = "unwind")] pub fn emit_unwind_info( buffer: &MachBufferFinalized, kind: crate::isa::unwind::UnwindInfoKind, diff --git a/cranelift/codegen/src/machinst/vcode.rs b/cranelift/codegen/src/machinst/vcode.rs index 12c816530f04..f11de1c3c1c6 100644 --- a/cranelift/codegen/src/machinst/vcode.rs +++ b/cranelift/codegen/src/machinst/vcode.rs @@ -1064,8 +1064,14 @@ impl VCode { } self.monotonize_inst_offsets(&mut inst_offsets[..], func_body_len); + + #[cfg(feature = "unwind")] let value_labels_ranges = self.compute_value_labels_ranges(regalloc, &inst_offsets[..], func_body_len); + // when unwind information is disabled, ValueLabelsRanges are meaningless anyway + #[cfg(not(feature = "unwind"))] + let value_labels_ranges = ValueLabelsRanges::default(); + let frame_size = self.abi.frame_size(); EmitResult { @@ -1121,6 +1127,7 @@ impl VCode { } } + #[cfg(feature = "unwind")] fn compute_value_labels_ranges( &self, regalloc: ®alloc2::Output, @@ -1158,8 +1165,10 @@ impl VCode { let slot = alloc.as_stack().unwrap(); let slot_offset = self.abi.get_spillslot_offset(slot); let slot_base_to_caller_sp_offset = self.abi.slot_base_to_caller_sp_offset(); + let caller_sp_to_cfa_offset = crate::isa::unwind::systemv::caller_sp_to_cfa_offset(); + // NOTE: this is a negative offset because it's relative to the caller's SP let cfa_to_sp_offset = -((slot_base_to_caller_sp_offset + caller_sp_to_cfa_offset) as i64);