Move FunctionDebugContext creation to codegen_fn
This commit is contained in:
parent
dbf5457308
commit
01be0ddacf
2 changed files with 22 additions and 2 deletions
22
src/base.rs
22
src/base.rs
|
@ -10,6 +10,7 @@ use rustc_middle::ty::SymbolName;
|
||||||
use indexmap::IndexSet;
|
use indexmap::IndexSet;
|
||||||
|
|
||||||
use crate::constant::ConstantCx;
|
use crate::constant::ConstantCx;
|
||||||
|
use crate::debuginfo::FunctionDebugContext;
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::pretty_clif::CommentWriter;
|
use crate::pretty_clif::CommentWriter;
|
||||||
|
|
||||||
|
@ -18,6 +19,7 @@ struct CodegenedFunction<'tcx> {
|
||||||
func_id: FuncId,
|
func_id: FuncId,
|
||||||
func: Function,
|
func: Function,
|
||||||
clif_comments: CommentWriter,
|
clif_comments: CommentWriter,
|
||||||
|
func_debug_cx: Option<FunctionDebugContext>,
|
||||||
function_span: Span,
|
function_span: Span,
|
||||||
source_info_set: IndexSet<SourceInfo>,
|
source_info_set: IndexSet<SourceInfo>,
|
||||||
}
|
}
|
||||||
|
@ -82,6 +84,12 @@ fn codegen_fn<'tcx>(
|
||||||
let pointer_type = target_config.pointer_type();
|
let pointer_type = target_config.pointer_type();
|
||||||
let clif_comments = crate::pretty_clif::CommentWriter::new(tcx, instance);
|
let clif_comments = crate::pretty_clif::CommentWriter::new(tcx, instance);
|
||||||
|
|
||||||
|
let func_debug_cx = if let Some(debug_context) = &mut cx.debug_context {
|
||||||
|
Some(debug_context.define_function(symbol_name.name))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
let mut fx = FunctionCx {
|
let mut fx = FunctionCx {
|
||||||
cx,
|
cx,
|
||||||
module,
|
module,
|
||||||
|
@ -89,6 +97,7 @@ fn codegen_fn<'tcx>(
|
||||||
target_config,
|
target_config,
|
||||||
pointer_type,
|
pointer_type,
|
||||||
constants_cx: ConstantCx::new(),
|
constants_cx: ConstantCx::new(),
|
||||||
|
func_debug_cx,
|
||||||
|
|
||||||
instance,
|
instance,
|
||||||
symbol_name,
|
symbol_name,
|
||||||
|
@ -109,6 +118,7 @@ fn codegen_fn<'tcx>(
|
||||||
|
|
||||||
// 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 clif_comments = fx.clif_comments;
|
let clif_comments = fx.clif_comments;
|
||||||
|
let func_debug_cx = fx.func_debug_cx;
|
||||||
let function_span = fx.mir.span;
|
let function_span = fx.mir.span;
|
||||||
let source_info_set = fx.source_info_set;
|
let source_info_set = fx.source_info_set;
|
||||||
|
|
||||||
|
@ -128,7 +138,15 @@ fn codegen_fn<'tcx>(
|
||||||
// Verify function
|
// Verify function
|
||||||
verify_func(tcx, &clif_comments, &func);
|
verify_func(tcx, &clif_comments, &func);
|
||||||
|
|
||||||
CodegenedFunction { symbol_name, func_id, func, clif_comments, function_span, source_info_set }
|
CodegenedFunction {
|
||||||
|
symbol_name,
|
||||||
|
func_id,
|
||||||
|
func,
|
||||||
|
clif_comments,
|
||||||
|
func_debug_cx,
|
||||||
|
function_span,
|
||||||
|
source_info_set,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn compile_fn<'tcx>(
|
fn compile_fn<'tcx>(
|
||||||
|
@ -214,7 +232,7 @@ fn compile_fn<'tcx>(
|
||||||
let unwind_context = &mut cx.unwind_context;
|
let unwind_context = &mut cx.unwind_context;
|
||||||
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(codegened_func.symbol_name.name).finalize(
|
codegened_func.func_debug_cx.unwrap().finalize(
|
||||||
debug_context,
|
debug_context,
|
||||||
tcx,
|
tcx,
|
||||||
codegened_func.func_id,
|
codegened_func.func_id,
|
||||||
|
|
|
@ -9,6 +9,7 @@ use rustc_target::abi::{Integer, Primitive};
|
||||||
use rustc_target::spec::{HasTargetSpec, Target};
|
use rustc_target::spec::{HasTargetSpec, Target};
|
||||||
|
|
||||||
use crate::constant::ConstantCx;
|
use crate::constant::ConstantCx;
|
||||||
|
use crate::debuginfo::FunctionDebugContext;
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub(crate) fn pointer_ty(tcx: TyCtxt<'_>) -> types::Type {
|
pub(crate) fn pointer_ty(tcx: TyCtxt<'_>) -> types::Type {
|
||||||
|
@ -238,6 +239,7 @@ pub(crate) struct FunctionCx<'m, 'clif, 'tcx: 'm> {
|
||||||
pub(crate) target_config: TargetFrontendConfig, // Cached from module
|
pub(crate) target_config: TargetFrontendConfig, // Cached from module
|
||||||
pub(crate) pointer_type: Type, // Cached from module
|
pub(crate) pointer_type: Type, // Cached from module
|
||||||
pub(crate) constants_cx: ConstantCx,
|
pub(crate) constants_cx: ConstantCx,
|
||||||
|
pub(crate) func_debug_cx: Option<FunctionDebugContext>,
|
||||||
|
|
||||||
pub(crate) instance: Instance<'tcx>,
|
pub(crate) instance: Instance<'tcx>,
|
||||||
pub(crate) symbol_name: SymbolName<'tcx>,
|
pub(crate) symbol_name: SymbolName<'tcx>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue