Remove TyCtxt from DebugContext
And explicitly thread it through everwhere it is needed.
This commit is contained in:
parent
e5493a5ea2
commit
259b21fd46
8 changed files with 28 additions and 27 deletions
10
src/base.rs
10
src/base.rs
|
@ -24,7 +24,7 @@ struct CodegenedFunction<'tcx> {
|
|||
|
||||
pub(crate) fn codegen_and_compile_fn<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
cx: &mut crate::CodegenCx<'tcx>,
|
||||
cx: &mut crate::CodegenCx,
|
||||
cached_context: &mut Context,
|
||||
module: &mut dyn Module,
|
||||
instance: Instance<'tcx>,
|
||||
|
@ -35,12 +35,12 @@ pub(crate) fn codegen_and_compile_fn<'tcx>(
|
|||
let cached_func = std::mem::replace(&mut cached_context.func, Function::new());
|
||||
let codegened_func = codegen_fn(tcx, cx, cached_func, module, instance);
|
||||
|
||||
compile_fn(cx, cached_context, module, codegened_func);
|
||||
compile_fn(tcx, cx, cached_context, module, codegened_func);
|
||||
}
|
||||
|
||||
fn codegen_fn<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
cx: &mut crate::CodegenCx<'tcx>,
|
||||
cx: &mut crate::CodegenCx,
|
||||
cached_func: Function,
|
||||
module: &mut dyn Module,
|
||||
instance: Instance<'tcx>,
|
||||
|
@ -132,7 +132,8 @@ fn codegen_fn<'tcx>(
|
|||
}
|
||||
|
||||
fn compile_fn<'tcx>(
|
||||
cx: &mut crate::CodegenCx<'tcx>,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
cx: &mut crate::CodegenCx,
|
||||
cached_context: &mut Context,
|
||||
module: &mut dyn Module,
|
||||
codegened_func: CodegenedFunction<'tcx>,
|
||||
|
@ -214,6 +215,7 @@ fn compile_fn<'tcx>(
|
|||
cx.profiler.verbose_generic_activity("generate debug info").run(|| {
|
||||
if let Some(debug_context) = debug_context {
|
||||
debug_context.define_function(
|
||||
tcx,
|
||||
codegened_func.func_id,
|
||||
codegened_func.symbol_name.name,
|
||||
context,
|
||||
|
|
|
@ -232,7 +232,7 @@ pub(crate) fn type_sign(ty: Ty<'_>) -> bool {
|
|||
}
|
||||
|
||||
pub(crate) struct FunctionCx<'m, 'clif, 'tcx: 'm> {
|
||||
pub(crate) cx: &'clif mut crate::CodegenCx<'tcx>,
|
||||
pub(crate) cx: &'clif mut crate::CodegenCx,
|
||||
pub(crate) module: &'m mut dyn Module,
|
||||
pub(crate) tcx: TyCtxt<'tcx>,
|
||||
pub(crate) target_config: TargetFrontendConfig, // Cached from module
|
||||
|
|
|
@ -9,7 +9,7 @@ use gimli::{RunTimeEndian, SectionId};
|
|||
use super::object::WriteDebugInfo;
|
||||
use super::DebugContext;
|
||||
|
||||
impl DebugContext<'_> {
|
||||
impl DebugContext {
|
||||
pub(crate) fn emit(&mut self, product: &mut ObjectProduct) {
|
||||
let unit_range_list_id = self.dwarf.unit.ranges.add(self.unit_range_list.clone());
|
||||
let root = self.dwarf.unit.root();
|
||||
|
|
|
@ -96,9 +96,9 @@ fn line_program_add_file(
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> DebugContext<'tcx> {
|
||||
pub(super) fn emit_location(&mut self, entry_id: UnitEntryId, span: Span) {
|
||||
let loc = self.tcx.sess.source_map().lookup_char_pos(span.lo());
|
||||
impl DebugContext {
|
||||
fn emit_location(&mut self, tcx: TyCtxt<'_>, entry_id: UnitEntryId, span: Span) {
|
||||
let loc = tcx.sess.source_map().lookup_char_pos(span.lo());
|
||||
|
||||
let file_id = line_program_add_file(
|
||||
&mut self.dwarf.unit.line_program,
|
||||
|
@ -115,13 +115,13 @@ impl<'tcx> DebugContext<'tcx> {
|
|||
|
||||
pub(super) fn create_debug_lines(
|
||||
&mut self,
|
||||
tcx: TyCtxt<'_>,
|
||||
symbol: usize,
|
||||
entry_id: UnitEntryId,
|
||||
context: &Context,
|
||||
function_span: Span,
|
||||
source_info_set: &indexmap::IndexSet<SourceInfo>,
|
||||
) -> CodeOffset {
|
||||
let tcx = self.tcx;
|
||||
let line_program = &mut self.dwarf.unit.line_program;
|
||||
|
||||
let line_strings = &mut self.dwarf.line_strings;
|
||||
|
@ -211,7 +211,7 @@ impl<'tcx> DebugContext<'tcx> {
|
|||
);
|
||||
entry.set(gimli::DW_AT_high_pc, AttributeValue::Udata(u64::from(func_end)));
|
||||
|
||||
self.emit_location(entry_id, function_span);
|
||||
self.emit_location(tcx, entry_id, function_span);
|
||||
|
||||
func_end
|
||||
}
|
||||
|
|
|
@ -16,17 +16,15 @@ use gimli::{Encoding, Format, LineEncoding, RunTimeEndian};
|
|||
pub(crate) use emit::{DebugReloc, DebugRelocName};
|
||||
pub(crate) use unwind::UnwindContext;
|
||||
|
||||
pub(crate) struct DebugContext<'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
|
||||
pub(crate) struct DebugContext {
|
||||
endian: RunTimeEndian,
|
||||
|
||||
dwarf: DwarfUnit,
|
||||
unit_range_list: RangeList,
|
||||
}
|
||||
|
||||
impl<'tcx> DebugContext<'tcx> {
|
||||
pub(crate) fn new(tcx: TyCtxt<'tcx>, isa: &dyn TargetIsa) -> Self {
|
||||
impl DebugContext {
|
||||
pub(crate) fn new(tcx: TyCtxt<'_>, isa: &dyn TargetIsa) -> Self {
|
||||
let encoding = Encoding {
|
||||
format: Format::Dwarf32,
|
||||
// FIXME this should be configurable
|
||||
|
@ -92,11 +90,12 @@ impl<'tcx> DebugContext<'tcx> {
|
|||
root.set(gimli::DW_AT_low_pc, AttributeValue::Address(Address::Constant(0)));
|
||||
}
|
||||
|
||||
DebugContext { tcx, endian, dwarf, unit_range_list: RangeList(Vec::new()) }
|
||||
DebugContext { endian, dwarf, unit_range_list: RangeList(Vec::new()) }
|
||||
}
|
||||
|
||||
pub(crate) fn define_function(
|
||||
&mut self,
|
||||
tcx: TyCtxt<'_>,
|
||||
func_id: FuncId,
|
||||
name: &str,
|
||||
context: &Context,
|
||||
|
@ -116,7 +115,7 @@ impl<'tcx> DebugContext<'tcx> {
|
|||
entry.set(gimli::DW_AT_linkage_name, AttributeValue::StringRef(name_id));
|
||||
|
||||
let end =
|
||||
self.create_debug_lines(symbol, entry_id, context, function_span, source_info_set);
|
||||
self.create_debug_lines(tcx, symbol, entry_id, context, function_span, source_info_set);
|
||||
|
||||
self.unit_range_list.0.push(Range::StartLength {
|
||||
begin: Address::Symbol { symbol, addend: 0 },
|
||||
|
|
|
@ -120,7 +120,7 @@ fn emit_cgu(
|
|||
prof: &SelfProfilerRef,
|
||||
name: String,
|
||||
module: ObjectModule,
|
||||
debug: Option<DebugContext<'_>>,
|
||||
debug: Option<DebugContext>,
|
||||
unwind_context: UnwindContext,
|
||||
global_asm_object_file: Option<PathBuf>,
|
||||
) -> Result<ModuleCodegenResult, String> {
|
||||
|
|
|
@ -61,11 +61,11 @@ impl UnsafeMessage {
|
|||
}
|
||||
}
|
||||
|
||||
fn create_jit_module<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
fn create_jit_module(
|
||||
tcx: TyCtxt<'_>,
|
||||
backend_config: &BackendConfig,
|
||||
hotswap: bool,
|
||||
) -> (JITModule, CodegenCx<'tcx>) {
|
||||
) -> (JITModule, CodegenCx) {
|
||||
let crate_info = CrateInfo::new(tcx, "dummy_target_cpu".to_string());
|
||||
let imported_symbols = load_imported_symbols_for_jit(tcx.sess, crate_info);
|
||||
|
||||
|
@ -353,7 +353,7 @@ fn load_imported_symbols_for_jit(
|
|||
|
||||
fn codegen_shim<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
cx: &mut CodegenCx<'tcx>,
|
||||
cx: &mut CodegenCx,
|
||||
cached_context: &mut Context,
|
||||
module: &mut JITModule,
|
||||
inst: Instance<'tcx>,
|
||||
|
|
|
@ -122,20 +122,20 @@ impl<F: Fn() -> String> Drop for PrintOnPanic<F> {
|
|||
|
||||
/// The codegen context holds any information shared between the codegen of individual functions
|
||||
/// inside a single codegen unit with the exception of the Cranelift [`Module`](cranelift_module::Module).
|
||||
struct CodegenCx<'tcx> {
|
||||
struct CodegenCx {
|
||||
profiler: SelfProfilerRef,
|
||||
output_filenames: Arc<OutputFilenames>,
|
||||
should_write_ir: bool,
|
||||
global_asm: String,
|
||||
inline_asm_index: Cell<usize>,
|
||||
debug_context: Option<DebugContext<'tcx>>,
|
||||
debug_context: Option<DebugContext>,
|
||||
unwind_context: UnwindContext,
|
||||
cgu_name: Symbol,
|
||||
}
|
||||
|
||||
impl<'tcx> CodegenCx<'tcx> {
|
||||
impl CodegenCx {
|
||||
fn new(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
tcx: TyCtxt<'_>,
|
||||
backend_config: BackendConfig,
|
||||
isa: &dyn TargetIsa,
|
||||
debug_info: bool,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue