Rustfmt
This commit is contained in:
parent
e910a24d44
commit
c352f91b40
@ -81,9 +81,7 @@ fn main() {
|
||||
None,
|
||||
Some(Box::new(move |_| {
|
||||
Box::new(rustc_codegen_cranelift::CraneliftCodegenBackend {
|
||||
config: rustc_codegen_cranelift::BackendConfig {
|
||||
use_jit,
|
||||
}
|
||||
config: rustc_codegen_cranelift::BackendConfig { use_jit },
|
||||
})
|
||||
})),
|
||||
)
|
||||
|
@ -84,9 +84,8 @@ impl WriterRelocate {
|
||||
match reloc.name {
|
||||
super::DebugRelocName::Section(_) => unreachable!(),
|
||||
super::DebugRelocName::Symbol(sym) => {
|
||||
let addr = jit_product.lookup_func(
|
||||
cranelift_module::FuncId::from_u32(sym.try_into().unwrap()),
|
||||
);
|
||||
let addr = jit_product
|
||||
.lookup_func(cranelift_module::FuncId::from_u32(sym.try_into().unwrap()));
|
||||
let val = (addr as u64 as i64 + reloc.addend) as u64;
|
||||
self.writer
|
||||
.write_udata_at(reloc.offset as usize, val, reloc.size)
|
||||
@ -163,12 +162,7 @@ impl Writer for WriterRelocate {
|
||||
self.write_udata_at(offset, 0, size)
|
||||
}
|
||||
|
||||
fn write_eh_pointer(
|
||||
&mut self,
|
||||
address: Address,
|
||||
eh_pe: gimli::DwEhPe,
|
||||
size: u8,
|
||||
) -> Result<()> {
|
||||
fn write_eh_pointer(&mut self, address: Address, eh_pe: gimli::DwEhPe, size: u8) -> Result<()> {
|
||||
match address {
|
||||
// Address::Constant arm copied from gimli
|
||||
Address::Constant(val) => {
|
||||
@ -186,27 +180,25 @@ impl Writer for WriterRelocate {
|
||||
};
|
||||
self.write_eh_pointer_data(val, eh_pe.format(), size)
|
||||
}
|
||||
Address::Symbol { symbol, addend } => {
|
||||
match eh_pe.application() {
|
||||
gimli::DW_EH_PE_pcrel => {
|
||||
let size = match eh_pe.format() {
|
||||
gimli::DW_EH_PE_sdata4 => 4,
|
||||
_ => return Err(gimli::write::Error::UnsupportedPointerEncoding(eh_pe)),
|
||||
};
|
||||
self.relocs.push(DebugReloc {
|
||||
offset: self.len() as u32,
|
||||
size,
|
||||
name: DebugRelocName::Symbol(symbol),
|
||||
addend,
|
||||
kind: object::RelocationKind::Relative,
|
||||
});
|
||||
self.write_udata(0, size)
|
||||
}
|
||||
_ => {
|
||||
return Err(gimli::write::Error::UnsupportedPointerEncoding(eh_pe));
|
||||
}
|
||||
Address::Symbol { symbol, addend } => match eh_pe.application() {
|
||||
gimli::DW_EH_PE_pcrel => {
|
||||
let size = match eh_pe.format() {
|
||||
gimli::DW_EH_PE_sdata4 => 4,
|
||||
_ => return Err(gimli::write::Error::UnsupportedPointerEncoding(eh_pe)),
|
||||
};
|
||||
self.relocs.push(DebugReloc {
|
||||
offset: self.len() as u32,
|
||||
size,
|
||||
name: DebugRelocName::Symbol(symbol),
|
||||
addend,
|
||||
kind: object::RelocationKind::Relative,
|
||||
});
|
||||
self.write_udata(0, size)
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
return Err(gimli::write::Error::UnsupportedPointerEncoding(eh_pe));
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,8 @@ impl<'tcx> UnwindContext<'tcx> {
|
||||
|
||||
let cie_id = if let Some(mut cie) = isa.create_systemv_cie() {
|
||||
if isa.flags().is_pic() {
|
||||
cie.fde_address_encoding = gimli::DwEhPe(gimli::DW_EH_PE_pcrel.0 | gimli::DW_EH_PE_sdata4.0);
|
||||
cie.fde_address_encoding =
|
||||
gimli::DwEhPe(gimli::DW_EH_PE_pcrel.0 | gimli::DW_EH_PE_sdata4.0);
|
||||
}
|
||||
Some(frame_table.add_cie(cie))
|
||||
} else {
|
||||
|
@ -9,7 +9,7 @@ use rustc_codegen_ssa::CrateInfo;
|
||||
use crate::prelude::*;
|
||||
|
||||
pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! {
|
||||
use cranelift_simplejit::{SimpleJITModule, SimpleJITBuilder};
|
||||
use cranelift_simplejit::{SimpleJITBuilder, SimpleJITModule};
|
||||
|
||||
#[cfg(unix)]
|
||||
unsafe {
|
||||
|
15
src/trap.rs
15
src/trap.rs
@ -29,10 +29,7 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, impl Module>, msg: &str) {
|
||||
}
|
||||
|
||||
/// Trap code: user1
|
||||
pub(crate) fn trap_abort(
|
||||
fx: &mut FunctionCx<'_, '_, impl Module>,
|
||||
msg: impl AsRef<str>,
|
||||
) {
|
||||
pub(crate) fn trap_abort(fx: &mut FunctionCx<'_, '_, impl Module>, msg: impl AsRef<str>) {
|
||||
codegen_print(fx, msg.as_ref());
|
||||
fx.bcx.ins().trap(TrapCode::User(1));
|
||||
}
|
||||
@ -41,10 +38,7 @@ pub(crate) fn trap_abort(
|
||||
/// so you can **not** add instructions to it afterwards.
|
||||
///
|
||||
/// Trap code: user65535
|
||||
pub(crate) fn trap_unreachable(
|
||||
fx: &mut FunctionCx<'_, '_, impl Module>,
|
||||
msg: impl AsRef<str>,
|
||||
) {
|
||||
pub(crate) fn trap_unreachable(fx: &mut FunctionCx<'_, '_, impl Module>, msg: impl AsRef<str>) {
|
||||
codegen_print(fx, msg.as_ref());
|
||||
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
|
||||
}
|
||||
@ -68,10 +62,7 @@ pub(crate) fn trap_unreachable_ret_value<'tcx>(
|
||||
/// to it afterwards.
|
||||
///
|
||||
/// Trap code: user65535
|
||||
pub(crate) fn trap_unimplemented(
|
||||
fx: &mut FunctionCx<'_, '_, impl Module>,
|
||||
msg: impl AsRef<str>,
|
||||
) {
|
||||
pub(crate) fn trap_unimplemented(fx: &mut FunctionCx<'_, '_, impl Module>, msg: impl AsRef<str>) {
|
||||
codegen_print(fx, msg.as_ref());
|
||||
let true_ = fx.bcx.ins().iconst(types::I32, 1);
|
||||
fx.bcx.ins().trapnz(true_, TrapCode::User(!0));
|
||||
|
Loading…
x
Reference in New Issue
Block a user