Skip to content

Commit

Permalink
make emit_fde Result-y as well
Browse files Browse the repository at this point in the history
  • Loading branch information
iximeow committed Apr 9, 2020
1 parent 6f0bdbe commit 87b7017
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cranelift/codegen/src/isa/x86/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ pub fn emit_unwind_info(
}
FrameUnwindKind::Libunwind => {
if func.frame_layout.is_some() {
emit_fde(func, isa, sink);
emit_fde(func, isa, sink)?;
}
}
}
Expand Down
13 changes: 10 additions & 3 deletions cranelift/codegen/src/isa/x86/fde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use crate::binemit::{FrameUnwindOffset, FrameUnwindSink, Reloc};
use crate::ir::{FrameLayoutChange, Function};
use crate::isa::{CallConv, RegUnit, TargetIsa};
use crate::result::CodegenResult;
use alloc::vec::Vec;
use core::convert::TryInto;
use gimli::write::{
Expand Down Expand Up @@ -169,7 +170,11 @@ fn to_cfi(
}

/// Creates FDE structure from FrameLayout.
pub fn emit_fde(func: &Function, isa: &dyn TargetIsa, sink: &mut dyn FrameUnwindSink) {
pub fn emit_fde(
func: &Function,
isa: &dyn TargetIsa,
sink: &mut dyn FrameUnwindSink,
) -> CodegenResult<()> {
assert!(isa.name() == "x86");

// Expecting function with System V prologue
Expand Down Expand Up @@ -257,6 +262,8 @@ pub fn emit_fde(func: &Function, isa: &dyn TargetIsa, sink: &mut dyn FrameUnwind

// Need 0 marker for GCC unwind to end FDE "list".
sink.bytes(&[0, 0, 0, 0]);

Ok(())
}

#[cfg(test)]
Expand Down Expand Up @@ -305,7 +312,7 @@ mod tests {
context.compile(&*isa).expect("expected compilation");

let mut sink = SimpleUnwindSink(Vec::new(), 0, Vec::new());
emit_fde(&context.func, &*isa, &mut sink);
emit_fde(&context.func, &*isa, &mut sink).expect("can emit fde");

assert_eq!(
sink.0,
Expand Down Expand Up @@ -367,7 +374,7 @@ mod tests {
context.compile(&*isa).expect("expected compilation");

let mut sink = SimpleUnwindSink(Vec::new(), 0, Vec::new());
emit_fde(&context.func, &*isa, &mut sink);
emit_fde(&context.func, &*isa, &mut sink).expect("can emit fde");

assert_eq!(
sink.0,
Expand Down

0 comments on commit 87b7017

Please sign in to comment.