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:
@@ -3,27 +3,20 @@
|
||||
mod abi;
|
||||
mod binemit;
|
||||
mod enc_tables;
|
||||
#[cfg(feature = "unwind")]
|
||||
mod fde;
|
||||
mod registers;
|
||||
pub mod settings;
|
||||
#[cfg(feature = "unwind")]
|
||||
mod unwind;
|
||||
|
||||
#[cfg(feature = "unwind")]
|
||||
pub use fde::map_reg;
|
||||
pub mod unwind;
|
||||
|
||||
use super::super::settings as shared_settings;
|
||||
#[cfg(feature = "testing_hooks")]
|
||||
use crate::binemit::CodeSink;
|
||||
use crate::binemit::{emit_function, MemoryCodeSink};
|
||||
#[cfg(feature = "unwind")]
|
||||
use crate::binemit::{FrameUnwindKind, FrameUnwindSink};
|
||||
use crate::ir;
|
||||
use crate::isa::enc_tables::{self as shared_enc_tables, lookup_enclist, Encodings};
|
||||
use crate::isa::Builder as IsaBuilder;
|
||||
#[cfg(feature = "unwind")]
|
||||
use crate::isa::{fde::RegisterMappingError, RegUnit};
|
||||
use crate::isa::{unwind::systemv::RegisterMappingError, RegUnit};
|
||||
use crate::isa::{EncInfo, RegClass, RegInfo, TargetIsa};
|
||||
use crate::regalloc;
|
||||
use crate::result::CodegenResult;
|
||||
@@ -95,7 +88,7 @@ impl TargetIsa for Isa {
|
||||
|
||||
#[cfg(feature = "unwind")]
|
||||
fn map_dwarf_register(&self, reg: RegUnit) -> Result<u16, RegisterMappingError> {
|
||||
map_reg(self, reg).map(|r| r.0)
|
||||
unwind::systemv::map_reg(self, reg).map(|r| r.0)
|
||||
}
|
||||
|
||||
fn encoding_info(&self) -> EncInfo {
|
||||
@@ -168,17 +161,17 @@ impl TargetIsa for Isa {
|
||||
ir::condcodes::IntCC::UnsignedLessThan
|
||||
}
|
||||
|
||||
/// Emit unwind information for the given function.
|
||||
///
|
||||
/// Only some calling conventions (e.g. Windows fastcall) will have unwind information.
|
||||
#[cfg(feature = "unwind")]
|
||||
fn emit_unwind_info(
|
||||
fn create_unwind_info(
|
||||
&self,
|
||||
func: &ir::Function,
|
||||
kind: FrameUnwindKind,
|
||||
sink: &mut dyn FrameUnwindSink,
|
||||
) -> CodegenResult<()> {
|
||||
abi::emit_unwind_info(func, self, kind, sink)
|
||||
) -> CodegenResult<Option<super::unwind::UnwindInfo>> {
|
||||
abi::create_unwind_info(func, self)
|
||||
}
|
||||
|
||||
#[cfg(feature = "unwind")]
|
||||
fn create_systemv_cie(&self) -> Option<gimli::write::CommonInformationEntry> {
|
||||
Some(unwind::systemv::create_cie())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user