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:
@@ -10,8 +10,8 @@
|
||||
//! single ISA instance.
|
||||
|
||||
use crate::binemit::{
|
||||
relax_branches, shrink_instructions, CodeInfo, FrameUnwindKind, FrameUnwindSink,
|
||||
MemoryCodeSink, RelocSink, StackmapSink, TrapSink,
|
||||
relax_branches, shrink_instructions, CodeInfo, MemoryCodeSink, RelocSink, StackmapSink,
|
||||
TrapSink,
|
||||
};
|
||||
use crate::dce::do_dce;
|
||||
use crate::dominator_tree::DominatorTree;
|
||||
@@ -231,19 +231,15 @@ impl Context {
|
||||
sink.info
|
||||
}
|
||||
|
||||
/// Emit unwind information.
|
||||
/// Creates unwind information for the function.
|
||||
///
|
||||
/// Requires that the function layout be calculated (see `relax_branches`).
|
||||
///
|
||||
/// Only some calling conventions (e.g. Windows fastcall) will have unwind information.
|
||||
/// This is a no-op if the function has no unwind information.
|
||||
pub fn emit_unwind_info(
|
||||
/// Returns `None` if the function has no unwind information.
|
||||
#[cfg(feature = "unwind")]
|
||||
pub fn create_unwind_info(
|
||||
&self,
|
||||
isa: &dyn TargetIsa,
|
||||
kind: FrameUnwindKind,
|
||||
sink: &mut dyn FrameUnwindSink,
|
||||
) -> CodegenResult<()> {
|
||||
isa.emit_unwind_info(&self.func, kind, sink)
|
||||
) -> CodegenResult<Option<crate::isa::unwind::UnwindInfo>> {
|
||||
isa.create_unwind_info(&self.func)
|
||||
}
|
||||
|
||||
/// Run the verifier on the function.
|
||||
|
||||
Reference in New Issue
Block a user