1
Fork 0

Remove Instance param of DebugContext::define_function

This commit is contained in:
bjorn3 2022-08-18 15:19:29 +00:00
parent a49416da6d
commit e5493a5ea2
2 changed files with 7 additions and 7 deletions

View file

@ -14,11 +14,11 @@ use crate::prelude::*;
use crate::pretty_clif::CommentWriter; use crate::pretty_clif::CommentWriter;
struct CodegenedFunction<'tcx> { struct CodegenedFunction<'tcx> {
instance: Instance<'tcx>,
symbol_name: SymbolName<'tcx>, symbol_name: SymbolName<'tcx>,
func_id: FuncId, func_id: FuncId,
func: Function, func: Function,
clif_comments: CommentWriter, clif_comments: CommentWriter,
function_span: Span,
source_info_set: IndexSet<SourceInfo>, source_info_set: IndexSet<SourceInfo>,
} }
@ -108,8 +108,8 @@ fn codegen_fn<'tcx>(
tcx.sess.time("codegen clif ir", || codegen_fn_body(&mut fx, start_block)); tcx.sess.time("codegen clif ir", || codegen_fn_body(&mut fx, start_block));
// Recover all necessary data from fx, before accessing func will prevent future access to it. // Recover all necessary data from fx, before accessing func will prevent future access to it.
let instance = fx.instance;
let clif_comments = fx.clif_comments; let clif_comments = fx.clif_comments;
let function_span = fx.mir.span;
let source_info_set = fx.source_info_set; let source_info_set = fx.source_info_set;
fx.constants_cx.finalize(fx.tcx, &mut *fx.module); fx.constants_cx.finalize(fx.tcx, &mut *fx.module);
@ -128,7 +128,7 @@ fn codegen_fn<'tcx>(
// Verify function // Verify function
verify_func(tcx, &clif_comments, &func); verify_func(tcx, &clif_comments, &func);
CodegenedFunction { instance, symbol_name, func_id, func, clif_comments, source_info_set } CodegenedFunction { symbol_name, func_id, func, clif_comments, function_span, source_info_set }
} }
fn compile_fn<'tcx>( fn compile_fn<'tcx>(
@ -214,10 +214,10 @@ fn compile_fn<'tcx>(
cx.profiler.verbose_generic_activity("generate debug info").run(|| { cx.profiler.verbose_generic_activity("generate debug info").run(|| {
if let Some(debug_context) = debug_context { if let Some(debug_context) = debug_context {
debug_context.define_function( debug_context.define_function(
codegened_func.instance,
codegened_func.func_id, codegened_func.func_id,
codegened_func.symbol_name.name, codegened_func.symbol_name.name,
context, context,
codegened_func.function_span,
&codegened_func.source_info_set, &codegened_func.source_info_set,
); );
} }

View file

@ -97,14 +97,13 @@ impl<'tcx> DebugContext<'tcx> {
pub(crate) fn define_function( pub(crate) fn define_function(
&mut self, &mut self,
instance: Instance<'tcx>,
func_id: FuncId, func_id: FuncId,
name: &str, name: &str,
context: &Context, context: &Context,
function_span: Span,
source_info_set: &indexmap::IndexSet<SourceInfo>, source_info_set: &indexmap::IndexSet<SourceInfo>,
) { ) {
let symbol = func_id.as_u32() as usize; let symbol = func_id.as_u32() as usize;
let mir = self.tcx.instance_mir(instance.def);
// FIXME: add to appropriate scope instead of root // FIXME: add to appropriate scope instead of root
let scope = self.dwarf.unit.root(); let scope = self.dwarf.unit.root();
@ -116,7 +115,8 @@ impl<'tcx> DebugContext<'tcx> {
entry.set(gimli::DW_AT_name, AttributeValue::StringRef(name_id)); entry.set(gimli::DW_AT_name, AttributeValue::StringRef(name_id));
entry.set(gimli::DW_AT_linkage_name, AttributeValue::StringRef(name_id)); entry.set(gimli::DW_AT_linkage_name, AttributeValue::StringRef(name_id));
let end = self.create_debug_lines(symbol, entry_id, context, mir.span, source_info_set); let end =
self.create_debug_lines(symbol, entry_id, context, function_span, source_info_set);
self.unit_range_list.0.push(Range::StartLength { self.unit_range_list.0.push(Range::StartLength {
begin: Address::Symbol { symbol, addend: 0 }, begin: Address::Symbol { symbol, addend: 0 },