Skip to content

Commit df64ba0

Browse files
committed
Rustup to rustc 1.41.0-nightly (e87a205c2 2019-11-27)
1 parent 7ae0b40 commit df64ba0

File tree

2 files changed

+75
-59
lines changed

2 files changed

+75
-59
lines changed

src/constant.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter {
411411
_: &mut InterpCx<'mir, 'tcx, Self>,
412412
_: Instance<'tcx>,
413413
_: &[OpTy<'tcx>],
414-
_: Option<PlaceTy<'tcx>>,
415-
_: Option<BasicBlock>,
414+
_: Option<(PlaceTy<'tcx>, BasicBlock)>,
416415
_: Option<BasicBlock>,
417416
) -> InterpResult<'tcx, Option<&'mir Body<'tcx>>> {
418417
panic!();
@@ -423,8 +422,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter {
423422
_: Span,
424423
_: Instance<'tcx>,
425424
_: &[OpTy<'tcx>],
426-
_: Option<PlaceTy<'tcx>>,
427-
_: Option<BasicBlock>,
425+
_: Option<(PlaceTy<'tcx>, BasicBlock)>,
428426
_: Option<BasicBlock>,
429427
) -> InterpResult<'tcx> {
430428
panic!();
@@ -468,7 +466,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter {
468466
_: &mut InterpCx<'mir, 'tcx, Self>,
469467
_: !,
470468
_: &[OpTy<'tcx, ()>],
471-
_: Option<PlaceTy<'tcx, ()>>,
469+
_: Option<(PlaceTy<'tcx, ()>, BasicBlock)>,
472470
_: Option<BasicBlock>,
473471
) -> InterpResult<'tcx> {
474472
unreachable!();

src/debuginfo/mod.rs

+72-54
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ mod line_info;
33

44
use crate::prelude::*;
55

6-
use cranelift::codegen::ir::{StackSlots, ValueLoc};
6+
use cranelift::codegen::ir::{StackSlots, ValueLabel, ValueLoc};
77
use cranelift::codegen::isa::RegUnit;
8+
use cranelift::codegen::ValueLocRange;
89

910
use gimli::write::{
1011
self, Address, AttributeValue, DwarfUnit, Expression, LineProgram, LineString, Location,
@@ -228,22 +229,14 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> {
228229
}
229230
}
230231

231-
fn define_local(&mut self, local: mir::Local) -> UnitEntryId {
232-
let local_decl = &self.mir.local_decls[local];
233-
232+
fn define_local(&mut self, name: String, ty: Ty<'tcx>) -> UnitEntryId {
234233
let ty = self.debug_context.tcx.subst_and_normalize_erasing_regions(
235234
self.instance.substs,
236235
ty::ParamEnv::reveal_all(),
237-
&local_decl.ty,
236+
&ty,
238237
);
239238
let dw_ty = self.debug_context.dwarf_ty(ty);
240239

241-
let name = if let Some(name) = local_decl.name {
242-
format!("{}{:?}", name.as_str(), local)
243-
} else {
244-
format!("{:?}", local)
245-
};
246-
247240
let var_id = self
248241
.debug_context
249242
.dwarf
@@ -280,57 +273,82 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> {
280273
let value_labels_ranges = context.build_value_labels_ranges(isa).unwrap();
281274

282275
for (local, _local_decl) in self.mir.local_decls.iter_enumerated() {
283-
let var_id = self.define_local(local);
284-
let value_label = cranelift::codegen::ir::ValueLabel::from_u32(local.as_u32());
285-
286-
let location = match local_map[&local].inner() {
287-
CPlaceInner::Var(_) => {
288-
if let Some(value_loc_ranges) = value_labels_ranges.get(&value_label) {
289-
let loc_list = LocationList(
290-
value_loc_ranges
291-
.iter()
292-
.map(|value_loc_range| Location::StartEnd {
293-
begin: Address::Symbol {
294-
symbol: self.symbol,
295-
addend: i64::from(value_loc_range.start),
296-
},
297-
end: Address::Symbol {
298-
symbol: self.symbol,
299-
addend: i64::from(value_loc_range.end),
300-
},
301-
data: Expression(
302-
translate_loc(value_loc_range.loc, &context.func.stack_slots).unwrap(),
303-
),
304-
})
305-
.collect(),
306-
);
307-
let loc_list_id = self.debug_context.dwarf.unit.locations.add(loc_list);
308-
309-
AttributeValue::LocationListRef(loc_list_id)
310-
} else {
311-
// FIXME set value labels for unused locals
312-
313-
AttributeValue::Exprloc(Expression(vec![]))
314-
}
315-
}
316-
CPlaceInner::Addr(_, _) => {
317-
// FIXME implement this (used by arguments and returns)
318-
319-
AttributeValue::Exprloc(Expression(vec![]))
320-
}
321-
CPlaceInner::Stack(stack_slot) => {
322-
AttributeValue::Exprloc(Expression(translate_loc(ValueLoc::Stack(*stack_slot), &context.func.stack_slots).unwrap()))
323-
}
324-
CPlaceInner::NoPlace => AttributeValue::Exprloc(Expression(vec![])),
325-
};
276+
let var_id = self.define_local(format!("{:?}", local), &self.mir.local_decls[local].ty);
277+
278+
let location = place_location(
279+
self,
280+
context,
281+
&local_map,
282+
&value_labels_ranges,
283+
Place {
284+
base: PlaceBase::Local(local),
285+
projection: ty::List::empty(),
286+
},
287+
);
326288

327289
let var_entry = self.debug_context.dwarf.unit.get_mut(var_id);
328290
var_entry.set(gimli::DW_AT_location, location);
329291
}
292+
293+
// FIXME create locals for all entries in mir.var_debug_info
330294
}
331295
}
332296

297+
fn place_location<'a, 'tcx>(
298+
func_debug_ctx: &mut FunctionDebugContext<'a, 'tcx>,
299+
context: &Context,
300+
local_map: &HashMap<mir::Local, CPlace<'tcx>>,
301+
value_labels_ranges: &HashMap<ValueLabel, Vec<ValueLocRange>>,
302+
place: Place<'tcx>,
303+
) -> AttributeValue {
304+
assert!(place.projection.is_empty()); // FIXME implement them
305+
let cplace = match place.base {
306+
PlaceBase::Local(local) => local_map[&local],
307+
PlaceBase::Static(_) => bug!("Unenforced invariant that the place is based on a Local violated: {:?}", place),
308+
};
309+
310+
match cplace.inner() {
311+
CPlaceInner::Var(local) => {
312+
let value_label = cranelift::codegen::ir::ValueLabel::from_u32(local.as_u32());
313+
if let Some(value_loc_ranges) = value_labels_ranges.get(&value_label) {
314+
let loc_list = LocationList(
315+
value_loc_ranges
316+
.iter()
317+
.map(|value_loc_range| Location::StartEnd {
318+
begin: Address::Symbol {
319+
symbol: func_debug_ctx.symbol,
320+
addend: i64::from(value_loc_range.start),
321+
},
322+
end: Address::Symbol {
323+
symbol: func_debug_ctx.symbol,
324+
addend: i64::from(value_loc_range.end),
325+
},
326+
data: Expression(
327+
translate_loc(value_loc_range.loc, &context.func.stack_slots).unwrap(),
328+
),
329+
})
330+
.collect(),
331+
);
332+
let loc_list_id = func_debug_ctx.debug_context.dwarf.unit.locations.add(loc_list);
333+
334+
AttributeValue::LocationListRef(loc_list_id)
335+
} else {
336+
// FIXME set value labels for unused locals
337+
338+
AttributeValue::Exprloc(Expression(vec![]))
339+
}
340+
}
341+
CPlaceInner::Addr(_, _) => {
342+
// FIXME implement this (used by arguments and returns)
333343

344+
AttributeValue::Exprloc(Expression(vec![]))
345+
}
346+
CPlaceInner::Stack(stack_slot) => {
347+
AttributeValue::Exprloc(Expression(translate_loc(ValueLoc::Stack(*stack_slot), &context.func.stack_slots).unwrap()))
348+
}
349+
CPlaceInner::NoPlace => AttributeValue::Exprloc(Expression(vec![])),
350+
}
351+
}
334352

335353

336354

0 commit comments

Comments
 (0)