Monomorphize locals
This commit is contained in:
parent
a962835685
commit
21f0dfd014
2 changed files with 18 additions and 10 deletions
|
@ -17,7 +17,7 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>(
|
||||||
let mut debug_context = cx
|
let mut debug_context = cx
|
||||||
.debug_context
|
.debug_context
|
||||||
.as_mut()
|
.as_mut()
|
||||||
.map(|debug_context| FunctionDebugContext::new(debug_context, mir, func_id, &name, &sig));
|
.map(|debug_context| FunctionDebugContext::new(debug_context, instance, func_id, &name, &sig));
|
||||||
|
|
||||||
// Make FunctionBuilder
|
// Make FunctionBuilder
|
||||||
let mut func = Function::with_name_signature(ExternalName::user(0, 0), sig);
|
let mut func = Function::with_name_signature(ExternalName::user(0, 0), sig);
|
||||||
|
@ -92,7 +92,7 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>(
|
||||||
let isa = cx.module.isa();
|
let isa = cx.module.isa();
|
||||||
debug_context
|
debug_context
|
||||||
.as_mut()
|
.as_mut()
|
||||||
.map(|x| x.define(tcx, context, isa, &source_info_set));
|
.map(|x| x.define(context, isa, &source_info_set));
|
||||||
|
|
||||||
// Clear context to make it usable for the next function
|
// Clear context to make it usable for the next function
|
||||||
context.clear();
|
context.clear();
|
||||||
|
|
|
@ -260,18 +260,20 @@ pub struct FunctionDebugContext<'a, 'tcx> {
|
||||||
debug_context: &'a mut DebugContext<'tcx>,
|
debug_context: &'a mut DebugContext<'tcx>,
|
||||||
entry_id: UnitEntryId,
|
entry_id: UnitEntryId,
|
||||||
symbol: usize,
|
symbol: usize,
|
||||||
mir_span: Span,
|
instance: Instance<'tcx>,
|
||||||
local_decls: rustc_index::vec::IndexVec<mir::Local, mir::LocalDecl<'tcx>>,
|
mir: &'tcx mir::Body<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> {
|
impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
debug_context: &'a mut DebugContext<'tcx>,
|
debug_context: &'a mut DebugContext<'tcx>,
|
||||||
mir: &'tcx Body,
|
instance: Instance<'tcx>,
|
||||||
func_id: FuncId,
|
func_id: FuncId,
|
||||||
name: &str,
|
name: &str,
|
||||||
_sig: &Signature,
|
_sig: &Signature,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
let mir = debug_context.tcx.instance_mir(instance.def);
|
||||||
|
|
||||||
let (symbol, _) = debug_context.symbols.insert_full(func_id, name.to_string());
|
let (symbol, _) = debug_context.symbols.insert_full(func_id, name.to_string());
|
||||||
|
|
||||||
// FIXME: add to appropriate scope intead of root
|
// FIXME: add to appropriate scope intead of root
|
||||||
|
@ -299,18 +301,19 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> {
|
||||||
debug_context,
|
debug_context,
|
||||||
entry_id,
|
entry_id,
|
||||||
symbol,
|
symbol,
|
||||||
mir_span: mir.span,
|
instance,
|
||||||
local_decls: mir.local_decls.clone(),
|
mir,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn define(
|
pub fn define(
|
||||||
&mut self,
|
&mut self,
|
||||||
tcx: TyCtxt,
|
|
||||||
context: &Context,
|
context: &Context,
|
||||||
isa: &dyn cranelift::codegen::isa::TargetIsa,
|
isa: &dyn cranelift::codegen::isa::TargetIsa,
|
||||||
source_info_set: &indexmap::IndexSet<(Span, mir::SourceScope)>,
|
source_info_set: &indexmap::IndexSet<(Span, mir::SourceScope)>,
|
||||||
) {
|
) {
|
||||||
|
let tcx = self.debug_context.tcx;
|
||||||
|
|
||||||
let line_program = &mut self.debug_context.dwarf.unit.line_program;
|
let line_program = &mut self.debug_context.dwarf.unit.line_program;
|
||||||
|
|
||||||
line_program.begin_sequence(Some(Address::Symbol {
|
line_program.begin_sequence(Some(Address::Symbol {
|
||||||
|
@ -351,7 +354,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> {
|
||||||
let source_info = *source_info_set.get_index(srcloc.bits() as usize).unwrap();
|
let source_info = *source_info_set.get_index(srcloc.bits() as usize).unwrap();
|
||||||
create_row_for_span(line_program, source_info.0);
|
create_row_for_span(line_program, source_info.0);
|
||||||
} else {
|
} else {
|
||||||
create_row_for_span(line_program, self.mir_span);
|
create_row_for_span(line_program, self.mir.span);
|
||||||
}
|
}
|
||||||
end = offset + size;
|
end = offset + size;
|
||||||
}
|
}
|
||||||
|
@ -386,7 +389,12 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> {
|
||||||
);
|
);
|
||||||
let live_ranges_id = self.debug_context.dwarf.unit.ranges.add(live_ranges);
|
let live_ranges_id = self.debug_context.dwarf.unit.ranges.add(live_ranges);
|
||||||
|
|
||||||
let local_type = self.debug_context.dwarf_ty(self.local_decls[mir::Local::from_u32(value_label.as_u32())].ty);
|
let local_ty = tcx.subst_and_normalize_erasing_regions(
|
||||||
|
self.instance.substs,
|
||||||
|
ty::ParamEnv::reveal_all(),
|
||||||
|
&self.mir.local_decls[mir::Local::from_u32(value_label.as_u32())].ty,
|
||||||
|
);
|
||||||
|
let local_type = self.debug_context.dwarf_ty(local_ty);
|
||||||
|
|
||||||
let var_id = self
|
let var_id = self
|
||||||
.debug_context
|
.debug_context
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue