Remove TyCtxt dependency from UnwindContext
This commit is contained in:
parent
ad5966ed4c
commit
9089c305da
@ -10,7 +10,7 @@ use crate::prelude::*;
|
||||
use rustc_index::vec::IndexVec;
|
||||
|
||||
use cranelift_codegen::entity::EntityRef;
|
||||
use cranelift_codegen::ir::{LabelValueLoc, ValueLabel};
|
||||
use cranelift_codegen::ir::{Endianness, LabelValueLoc, ValueLabel};
|
||||
use cranelift_codegen::isa::TargetIsa;
|
||||
use cranelift_codegen::ValueLocRange;
|
||||
|
||||
@ -23,15 +23,6 @@ use gimli::{Encoding, Format, LineEncoding, RunTimeEndian, X86_64};
|
||||
pub(crate) use emit::{DebugReloc, DebugRelocName};
|
||||
pub(crate) use unwind::UnwindContext;
|
||||
|
||||
fn target_endian(tcx: TyCtxt<'_>) -> RunTimeEndian {
|
||||
use rustc_target::abi::Endian;
|
||||
|
||||
match tcx.data_layout.endian {
|
||||
Endian::Big => RunTimeEndian::Big,
|
||||
Endian::Little => RunTimeEndian::Little,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct DebugContext<'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
|
||||
@ -60,6 +51,11 @@ impl<'tcx> DebugContext<'tcx> {
|
||||
address_size: isa.frontend_config().pointer_bytes(),
|
||||
};
|
||||
|
||||
let endian = match isa.endianness() {
|
||||
Endianness::Little => RunTimeEndian::Little,
|
||||
Endianness::Big => RunTimeEndian::Big,
|
||||
};
|
||||
|
||||
let mut dwarf = DwarfUnit::new(encoding);
|
||||
|
||||
let producer = format!(
|
||||
@ -108,7 +104,7 @@ impl<'tcx> DebugContext<'tcx> {
|
||||
DebugContext {
|
||||
tcx,
|
||||
|
||||
endian: target_endian(tcx),
|
||||
endian,
|
||||
|
||||
dwarf,
|
||||
unit_range_list: RangeList(Vec::new()),
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
use cranelift_codegen::ir::Endianness;
|
||||
use cranelift_codegen::isa::{unwind::UnwindInfo, TargetIsa};
|
||||
|
||||
use cranelift_object::ObjectProduct;
|
||||
@ -17,8 +18,11 @@ pub(crate) struct UnwindContext {
|
||||
}
|
||||
|
||||
impl UnwindContext {
|
||||
pub(crate) fn new(tcx: TyCtxt<'_>, isa: &dyn TargetIsa, pic_eh_frame: bool) -> Self {
|
||||
let endian = super::target_endian(tcx);
|
||||
pub(crate) fn new(isa: &dyn TargetIsa, pic_eh_frame: bool) -> Self {
|
||||
let endian = match isa.endianness() {
|
||||
Endianness::Little => RunTimeEndian::Little,
|
||||
Endianness::Big => RunTimeEndian::Big,
|
||||
};
|
||||
let mut frame_table = FrameTable::default();
|
||||
|
||||
let cie_id = if let Some(mut cie) = isa.create_systemv_cie() {
|
||||
|
@ -243,7 +243,7 @@ pub(crate) fn run_aot(
|
||||
let isa = crate::build_isa(tcx.sess, &backend_config);
|
||||
let mut allocator_module = make_module(tcx.sess, isa, "allocator_shim".to_string());
|
||||
assert_eq!(pointer_ty(tcx), allocator_module.target_config().pointer_type());
|
||||
let mut allocator_unwind_context = UnwindContext::new(tcx, allocator_module.isa(), true);
|
||||
let mut allocator_unwind_context = UnwindContext::new(allocator_module.isa(), true);
|
||||
let created_alloc_shim =
|
||||
crate::allocator::codegen(tcx, &mut allocator_module, &mut allocator_unwind_context);
|
||||
|
||||
|
@ -141,7 +141,7 @@ impl<'tcx> CodegenCx<'tcx> {
|
||||
assert_eq!(pointer_ty(tcx), isa.pointer_type());
|
||||
|
||||
let unwind_context =
|
||||
UnwindContext::new(tcx, isa, matches!(backend_config.codegen_mode, CodegenMode::Aot));
|
||||
UnwindContext::new(isa, matches!(backend_config.codegen_mode, CodegenMode::Aot));
|
||||
let debug_context = if debug_info { Some(DebugContext::new(tcx, isa)) } else { None };
|
||||
CodegenCx {
|
||||
tcx,
|
||||
|
Loading…
x
Reference in New Issue
Block a user