Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: no_std fix use without unwind #9977

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cranelift/codegen/src/isa/pulley_shared/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ where
})
}

#[cfg(feature = "unwind")]
fn emit_unwind_info(
&self,
_result: &crate::CompiledCode,
Expand Down
1 change: 1 addition & 0 deletions cranelift/codegen/src/isa/unwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions cranelift/codegen/src/isa/x64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ mod lower;
mod pcc;
pub mod settings;

#[cfg(feature = "unwind")]
pub use inst::unwind::systemv::create_cie;

/// An X64 backend.
Expand Down Expand Up @@ -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<Final>,
kind: crate::isa::unwind::UnwindInfoKind,
Expand Down
9 changes: 9 additions & 0 deletions cranelift/codegen/src/machinst/vcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1064,8 +1064,14 @@ impl<I: VCodeInst> VCode<I> {
}

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 {
Expand Down Expand Up @@ -1121,6 +1127,7 @@ impl<I: VCodeInst> VCode<I> {
}
}

#[cfg(feature = "unwind")]
fn compute_value_labels_ranges(
&self,
regalloc: &regalloc2::Output,
Expand Down Expand Up @@ -1158,8 +1165,10 @@ impl<I: VCodeInst> VCode<I> {
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);
Expand Down
Loading