Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 3e2bdb9

Browse files
committed
Don't store TyCtxt in UnwindContext
1 parent b09b8b1 commit 3e2bdb9

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

src/allocator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_span::symbol::sym;
1111
pub(crate) fn codegen(
1212
tcx: TyCtxt<'_>,
1313
module: &mut impl Module,
14-
unwind_context: &mut UnwindContext<'_>,
14+
unwind_context: &mut UnwindContext,
1515
) -> bool {
1616
let any_dynamic_crate = tcx.dependency_formats(LOCAL_CRATE).iter().any(|(_, list)| {
1717
use rustc_middle::middle::dependency_format::Linkage;
@@ -29,7 +29,7 @@ pub(crate) fn codegen(
2929

3030
fn codegen_inner(
3131
module: &mut impl Module,
32-
unwind_context: &mut UnwindContext<'_>,
32+
unwind_context: &mut UnwindContext,
3333
kind: AllocatorKind,
3434
) {
3535
let usize_ty = module.target_config().pointer_type();

src/debuginfo/unwind.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@ use crate::prelude::*;
55
use cranelift_codegen::isa::{unwind::UnwindInfo, TargetIsa};
66

77
use gimli::write::{Address, CieId, EhFrame, FrameTable, Section};
8+
use gimli::RunTimeEndian;
89

910
use crate::backend::WriteDebugInfo;
1011

11-
pub(crate) struct UnwindContext<'tcx> {
12-
tcx: TyCtxt<'tcx>,
12+
pub(crate) struct UnwindContext {
13+
endian: RunTimeEndian,
1314
frame_table: FrameTable,
1415
cie_id: Option<CieId>,
1516
}
1617

17-
impl<'tcx> UnwindContext<'tcx> {
18-
pub(crate) fn new(tcx: TyCtxt<'tcx>, isa: &dyn TargetIsa, pic_eh_frame: bool) -> Self {
18+
impl UnwindContext {
19+
pub(crate) fn new(tcx: TyCtxt<'_>, isa: &dyn TargetIsa, pic_eh_frame: bool) -> Self {
20+
let endian = super::target_endian(tcx);
1921
let mut frame_table = FrameTable::default();
2022

2123
let cie_id = if let Some(mut cie) = isa.create_systemv_cie() {
@@ -28,7 +30,7 @@ impl<'tcx> UnwindContext<'tcx> {
2830
None
2931
};
3032

31-
UnwindContext { tcx, frame_table, cie_id }
33+
UnwindContext { endian, frame_table, cie_id }
3234
}
3335

3436
pub(crate) fn add_function(&mut self, func_id: FuncId, context: &Context, isa: &dyn TargetIsa) {
@@ -54,8 +56,7 @@ impl<'tcx> UnwindContext<'tcx> {
5456
}
5557

5658
pub(crate) fn emit<P: WriteDebugInfo>(self, product: &mut P) {
57-
let mut eh_frame =
58-
EhFrame::from(super::emit::WriterRelocate::new(super::target_endian(self.tcx)));
59+
let mut eh_frame = EhFrame::from(super::emit::WriterRelocate::new(self.endian));
5960
self.frame_table.write_eh_frame(&mut eh_frame).unwrap();
6061

6162
if !eh_frame.0.writer.slice().is_empty() {
@@ -75,8 +76,7 @@ impl<'tcx> UnwindContext<'tcx> {
7576
self,
7677
jit_module: &cranelift_jit::JITModule,
7778
) -> Option<UnwindRegistry> {
78-
let mut eh_frame =
79-
EhFrame::from(super::emit::WriterRelocate::new(super::target_endian(self.tcx)));
79+
let mut eh_frame = EhFrame::from(super::emit::WriterRelocate::new(self.endian));
8080
self.frame_table.write_eh_frame(&mut eh_frame).unwrap();
8181

8282
if eh_frame.0.writer.slice().is_empty() {

src/driver/aot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn emit_module(
3131
kind: ModuleKind,
3232
module: ObjectModule,
3333
debug: Option<DebugContext<'_>>,
34-
unwind_context: UnwindContext<'_>,
34+
unwind_context: UnwindContext,
3535
) -> ModuleCodegenResult {
3636
let mut product = module.finish();
3737

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ struct CodegenCx<'m, 'tcx: 'm> {
124124
global_asm: String,
125125
cached_context: Context,
126126
debug_context: Option<DebugContext<'tcx>>,
127-
unwind_context: UnwindContext<'tcx>,
127+
unwind_context: UnwindContext,
128128
}
129129

130130
impl<'m, 'tcx> CodegenCx<'m, 'tcx> {
@@ -151,7 +151,7 @@ impl<'m, 'tcx> CodegenCx<'m, 'tcx> {
151151
}
152152
}
153153

154-
fn finalize(self) -> (String, Option<DebugContext<'tcx>>, UnwindContext<'tcx>) {
154+
fn finalize(self) -> (String, Option<DebugContext<'tcx>>, UnwindContext) {
155155
(self.global_asm, self.debug_context, self.unwind_context)
156156
}
157157
}

src/main_shim.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::prelude::*;
99
pub(crate) fn maybe_create_entry_wrapper(
1010
tcx: TyCtxt<'_>,
1111
module: &mut impl Module,
12-
unwind_context: &mut UnwindContext<'_>,
12+
unwind_context: &mut UnwindContext,
1313
) {
1414
let (main_def_id, use_start_lang_item) = match tcx.entry_fn(LOCAL_CRATE) {
1515
Some((def_id, entry_ty)) => (
@@ -32,7 +32,7 @@ pub(crate) fn maybe_create_entry_wrapper(
3232
fn create_entry_fn(
3333
tcx: TyCtxt<'_>,
3434
m: &mut impl Module,
35-
unwind_context: &mut UnwindContext<'_>,
35+
unwind_context: &mut UnwindContext,
3636
rust_main_def_id: DefId,
3737
use_start_lang_item: bool,
3838
) {

0 commit comments

Comments
 (0)