]> git.lizzy.rs Git - rust.git/commitdiff
Monomorphize locals
authorbjorn3 <bjorn3@users.noreply.github.com>
Mon, 11 Nov 2019 19:49:20 +0000 (20:49 +0100)
committerbjorn3 <bjorn3@users.noreply.github.com>
Mon, 16 Dec 2019 11:04:34 +0000 (12:04 +0100)
src/base.rs
src/debuginfo.rs

index bb0ffb51bcec14882b7fd7056130d697f20b5325..ed587bf739d5b67fc88b2b0bbd45f297a7a052a8 100644 (file)
@@ -17,7 +17,7 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>(
     let mut debug_context = cx
         .debug_context
         .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
     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();
     debug_context
         .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
     context.clear();
index b3de6449ff4b437abea97654af39ba1197bbd7b8..8de7ab673849d1b59472322733c153447dcae967 100644 (file)
@@ -260,18 +260,20 @@ pub struct FunctionDebugContext<'a, 'tcx> {
     debug_context: &'a mut DebugContext<'tcx>,
     entry_id: UnitEntryId,
     symbol: usize,
-    mir_span: Span,
-    local_decls: rustc_index::vec::IndexVec<mir::Local, mir::LocalDecl<'tcx>>,
+    instance: Instance<'tcx>,
+    mir: &'tcx mir::Body<'tcx>,
 }
 
 impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> {
     pub fn new(
         debug_context: &'a mut DebugContext<'tcx>,
-        mir: &'tcx Body,
+        instance: Instance<'tcx>,
         func_id: FuncId,
         name: &str,
         _sig: &Signature,
     ) -> Self {
+        let mir = debug_context.tcx.instance_mir(instance.def);
+
         let (symbol, _) = debug_context.symbols.insert_full(func_id, name.to_string());
 
         // FIXME: add to appropriate scope intead of root
@@ -299,18 +301,19 @@ pub fn new(
             debug_context,
             entry_id,
             symbol,
-            mir_span: mir.span,
-            local_decls: mir.local_decls.clone(),
+            instance,
+            mir,
         }
     }
 
     pub fn define(
         &mut self,
-        tcx: TyCtxt,
         context: &Context,
         isa: &dyn cranelift::codegen::isa::TargetIsa,
         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;
 
         line_program.begin_sequence(Some(Address::Symbol {
@@ -351,7 +354,7 @@ pub fn define(
                     let source_info = *source_info_set.get_index(srcloc.bits() as usize).unwrap();
                     create_row_for_span(line_program, source_info.0);
                 } else {
-                    create_row_for_span(line_program, self.mir_span);
+                    create_row_for_span(line_program, self.mir.span);
                 }
                 end = offset + size;
             }
@@ -386,7 +389,12 @@ pub fn define(
                 );
                 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
                     .debug_context