Refactor unwind generation in Cranelift.
This commit makes the following changes to unwind information generation in Cranelift: * Remove frame layout change implementation in favor of processing the prologue and epilogue instructions when unwind information is requested. This also means this work is no longer performed for Windows, which didn't utilize it. It also helps simplify the prologue and epilogue generation code. * Remove the unwind sink implementation that required each unwind information to be represented in final form. For FDEs, this meant writing a complete frame table per function, which wastes 20 bytes or so for each function with duplicate CIEs. This also enables Cranelift users to collect the unwind information and write it as a single frame table. * For System V calling convention, the unwind information is no longer stored in code memory (it's only a requirement for Windows ABI to do so). This allows for more compact code memory for modules with a lot of functions. * Deletes some duplicate code relating to frame table generation. Users can now simply use gimli to create a frame table from each function's unwind information. Fixes #1181.
This commit is contained in:
@@ -56,8 +56,8 @@ pub use crate::isa::stack::{StackBase, StackBaseMask, StackRef};
|
||||
use crate::binemit;
|
||||
use crate::flowgraph;
|
||||
use crate::ir;
|
||||
use crate::isa::fde::RegisterMappingError;
|
||||
#[cfg(feature = "unwind")]
|
||||
use crate::isa::unwind::systemv::RegisterMappingError;
|
||||
use crate::machinst::MachBackend;
|
||||
use crate::regalloc;
|
||||
use crate::result::CodegenResult;
|
||||
@@ -77,15 +77,15 @@ mod riscv;
|
||||
#[cfg(feature = "x86")]
|
||||
mod x86;
|
||||
|
||||
#[cfg(feature = "unwind")]
|
||||
pub mod fde;
|
||||
|
||||
#[cfg(feature = "arm32")]
|
||||
mod arm32;
|
||||
|
||||
#[cfg(feature = "arm64")]
|
||||
mod aarch64;
|
||||
|
||||
#[cfg(feature = "unwind")]
|
||||
pub mod unwind;
|
||||
|
||||
mod call_conv;
|
||||
mod constraints;
|
||||
mod enc_tables;
|
||||
@@ -394,17 +394,25 @@ pub trait TargetIsa: fmt::Display + Send + Sync {
|
||||
/// IntCC condition for Unsigned Subtraction Overflow (Borrow/Carry).
|
||||
fn unsigned_sub_overflow_condition(&self) -> ir::condcodes::IntCC;
|
||||
|
||||
/// Emit unwind information for the given function.
|
||||
/// Creates unwind information for the function.
|
||||
///
|
||||
/// Only some calling conventions (e.g. Windows fastcall) will have unwind information.
|
||||
fn emit_unwind_info(
|
||||
/// Returns `None` if there is no unwind information for the function.
|
||||
#[cfg(feature = "unwind")]
|
||||
fn create_unwind_info(
|
||||
&self,
|
||||
_func: &ir::Function,
|
||||
_kind: binemit::FrameUnwindKind,
|
||||
_sink: &mut dyn binemit::FrameUnwindSink,
|
||||
) -> CodegenResult<()> {
|
||||
// No-op by default
|
||||
Ok(())
|
||||
) -> CodegenResult<Option<unwind::UnwindInfo>> {
|
||||
// By default, an ISA has no unwind information
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
/// Creates a new System V Common Information Entry for the ISA.
|
||||
///
|
||||
/// Returns `None` if the ISA does not support System V unwind information.
|
||||
#[cfg(feature = "unwind")]
|
||||
fn create_systemv_cie(&self) -> Option<gimli::write::CommonInformationEntry> {
|
||||
// By default, an ISA cannot create a System V CIE
|
||||
None
|
||||
}
|
||||
|
||||
/// Get the new-style MachBackend, if this is an adapter around one.
|
||||
|
||||
Reference in New Issue
Block a user