Define return type for functions in debuginfo
This commit is contained in:
parent
0634aedbb7
commit
4f0cde1e51
@ -11,7 +11,7 @@
|
|||||||
use rustc_monomorphize::is_call_from_compiler_builtins_to_upstream_monomorphization;
|
use rustc_monomorphize::is_call_from_compiler_builtins_to_upstream_monomorphization;
|
||||||
|
|
||||||
use crate::constant::ConstantCx;
|
use crate::constant::ConstantCx;
|
||||||
use crate::debuginfo::FunctionDebugContext;
|
use crate::debuginfo::{FunctionDebugContext, TypeDebugContext};
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::pretty_clif::CommentWriter;
|
use crate::pretty_clif::CommentWriter;
|
||||||
|
|
||||||
@ -26,6 +26,7 @@ pub(crate) struct CodegenedFunction {
|
|||||||
pub(crate) fn codegen_fn<'tcx>(
|
pub(crate) fn codegen_fn<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
cx: &mut crate::CodegenCx,
|
cx: &mut crate::CodegenCx,
|
||||||
|
type_dbg: &mut TypeDebugContext<'tcx>,
|
||||||
cached_func: Function,
|
cached_func: Function,
|
||||||
module: &mut dyn Module,
|
module: &mut dyn Module,
|
||||||
instance: Instance<'tcx>,
|
instance: Instance<'tcx>,
|
||||||
@ -69,8 +70,10 @@ pub(crate) 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 fn_abi = RevealAllLayoutCx(tcx).fn_abi_of_instance(instance, ty::List::empty());
|
||||||
|
|
||||||
let func_debug_cx = if let Some(debug_context) = &mut cx.debug_context {
|
let func_debug_cx = if let Some(debug_context) = &mut cx.debug_context {
|
||||||
Some(debug_context.define_function(tcx, instance, &symbol_name, mir.span))
|
Some(debug_context.define_function(tcx, type_dbg, instance, fn_abi, &symbol_name, mir.span))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
@ -87,7 +90,7 @@ pub(crate) fn codegen_fn<'tcx>(
|
|||||||
instance,
|
instance,
|
||||||
symbol_name,
|
symbol_name,
|
||||||
mir,
|
mir,
|
||||||
fn_abi: RevealAllLayoutCx(tcx).fn_abi_of_instance(instance, ty::List::empty()),
|
fn_abi,
|
||||||
|
|
||||||
bcx,
|
bcx,
|
||||||
block_map,
|
block_map,
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
use rustc_hir::def_id::DefIdMap;
|
use rustc_hir::def_id::DefIdMap;
|
||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
use rustc_span::{SourceFileHash, StableSourceFileId};
|
use rustc_span::{SourceFileHash, StableSourceFileId};
|
||||||
|
use rustc_target::abi::call::FnAbi;
|
||||||
|
|
||||||
pub(crate) use self::emit::{DebugReloc, DebugRelocName};
|
pub(crate) use self::emit::{DebugReloc, DebugRelocName};
|
||||||
pub(crate) use self::types::TypeDebugContext;
|
pub(crate) use self::types::TypeDebugContext;
|
||||||
@ -188,7 +189,9 @@ fn item_namespace(&mut self, tcx: TyCtxt<'_>, def_id: DefId) -> UnitEntryId {
|
|||||||
pub(crate) fn define_function<'tcx>(
|
pub(crate) fn define_function<'tcx>(
|
||||||
&mut self,
|
&mut self,
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
|
type_dbg: &mut TypeDebugContext<'tcx>,
|
||||||
instance: Instance<'tcx>,
|
instance: Instance<'tcx>,
|
||||||
|
fn_abi: &'tcx FnAbi<'tcx, Ty<'tcx>>,
|
||||||
linkage_name: &str,
|
linkage_name: &str,
|
||||||
function_span: Span,
|
function_span: Span,
|
||||||
) -> FunctionDebugContext {
|
) -> FunctionDebugContext {
|
||||||
@ -240,7 +243,14 @@ pub(crate) fn define_function<'tcx>(
|
|||||||
entry.set(gimli::DW_AT_decl_file, AttributeValue::FileIndex(Some(file_id)));
|
entry.set(gimli::DW_AT_decl_file, AttributeValue::FileIndex(Some(file_id)));
|
||||||
entry.set(gimli::DW_AT_decl_line, AttributeValue::Udata(line));
|
entry.set(gimli::DW_AT_decl_line, AttributeValue::Udata(line));
|
||||||
|
|
||||||
|
if !fn_abi.ret.is_ignore() {
|
||||||
|
let return_dw_ty = self.debug_type(tcx, type_dbg, fn_abi.ret.layout.ty);
|
||||||
|
let entry = self.dwarf.unit.get_mut(entry_id);
|
||||||
|
entry.set(gimli::DW_AT_type, AttributeValue::UnitRef(return_dw_ty));
|
||||||
|
}
|
||||||
|
|
||||||
if tcx.is_reachable_non_generic(instance.def_id()) {
|
if tcx.is_reachable_non_generic(instance.def_id()) {
|
||||||
|
let entry = self.dwarf.unit.get_mut(entry_id);
|
||||||
entry.set(gimli::DW_AT_external, AttributeValue::FlagPresent);
|
entry.set(gimli::DW_AT_external, AttributeValue::FlagPresent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -470,6 +470,7 @@ fn module_codegen(
|
|||||||
let codegened_function = crate::base::codegen_fn(
|
let codegened_function = crate::base::codegen_fn(
|
||||||
tcx,
|
tcx,
|
||||||
&mut cx,
|
&mut cx,
|
||||||
|
&mut type_dbg,
|
||||||
Function::new(),
|
Function::new(),
|
||||||
&mut module,
|
&mut module,
|
||||||
inst,
|
inst,
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
use rustc_span::Symbol;
|
use rustc_span::Symbol;
|
||||||
|
|
||||||
|
use crate::debuginfo::TypeDebugContext;
|
||||||
use crate::{prelude::*, BackendConfig};
|
use crate::{prelude::*, BackendConfig};
|
||||||
use crate::{CodegenCx, CodegenMode};
|
use crate::{CodegenCx, CodegenMode};
|
||||||
|
|
||||||
@ -229,7 +230,14 @@ pub(crate) fn codegen_and_compile_fn<'tcx>(
|
|||||||
crate::PrintOnPanic(|| format!("{:?} {}", instance, tcx.symbol_name(instance).name));
|
crate::PrintOnPanic(|| format!("{:?} {}", instance, tcx.symbol_name(instance).name));
|
||||||
|
|
||||||
let cached_func = std::mem::replace(&mut cached_context.func, Function::new());
|
let cached_func = std::mem::replace(&mut cached_context.func, Function::new());
|
||||||
let codegened_func = crate::base::codegen_fn(tcx, cx, cached_func, module, instance);
|
let codegened_func = crate::base::codegen_fn(
|
||||||
|
tcx,
|
||||||
|
cx,
|
||||||
|
&mut TypeDebugContext::default(),
|
||||||
|
cached_func,
|
||||||
|
module,
|
||||||
|
instance,
|
||||||
|
);
|
||||||
|
|
||||||
crate::base::compile_fn(cx, cached_context, module, codegened_func);
|
crate::base::compile_fn(cx, cached_context, module, codegened_func);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user