Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit bc55576

Browse files
committed
Update Cranelift
1 parent 6b54b7c commit bc55576

File tree

3 files changed

+49
-57
lines changed

3 files changed

+49
-57
lines changed

Cargo.lock

Lines changed: 28 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ default-features = false
2626
features = ["read", "std", "write"] # We don't need WASM support
2727

2828
[dependencies.gimli]
29-
version = "0.20.0"
29+
version = "0.21.0"
3030
default-features = false
3131
features = ["write"] # We don't need read support
3232

src/debuginfo/mod.rs

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use cranelift_codegen::isa::TargetIsa;
99
use cranelift_codegen::ValueLocRange;
1010

1111
use gimli::write::{
12-
self, Address, AttributeValue, DwarfUnit, Expression, LineProgram,
13-
LineString, Location, LocationList, Range, RangeList, UnitEntryId, Writer,
12+
Address, AttributeValue, DwarfUnit, Expression, LineProgram,
13+
LineString, Location, LocationList, Range, RangeList, UnitEntryId,
1414
};
1515
use gimli::{Encoding, Format, LineEncoding, RunTimeEndian, X86_64};
1616

@@ -187,7 +187,7 @@ impl<'tcx> DebugContext<'tcx> {
187187
let type_entry = self.dwarf.unit.get_mut(type_id);
188188

189189
//type_entry.set(gimli::DW_AT_mutable, AttributeValue::Flag(mutbl == rustc_hir::Mutability::Mut));
190-
type_entry.set(gimli::DW_AT_type, AttributeValue::ThisUnitEntryRef(pointee));
190+
type_entry.set(gimli::DW_AT_type, AttributeValue::UnitRef(pointee));
191191

192192
type_id
193193
}
@@ -213,7 +213,7 @@ impl<'tcx> DebugContext<'tcx> {
213213

214214
field_entry.set(gimli::DW_AT_name, AttributeValue::String(field_def.ident.as_str().to_string().into_bytes()));
215215
field_entry.set(gimli::DW_AT_data_member_location, AttributeValue::Udata(field_offset.bytes()));
216-
field_entry.set(gimli::DW_AT_type, AttributeValue::ThisUnitEntryRef(field_type));
216+
field_entry.set(gimli::DW_AT_type, AttributeValue::UnitRef(field_type));
217217
}
218218

219219
type_id
@@ -291,7 +291,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> {
291291
let var_entry = self.debug_context.dwarf.unit.get_mut(var_id);
292292

293293
var_entry.set(gimli::DW_AT_name, AttributeValue::String(name.into_bytes()));
294-
var_entry.set(gimli::DW_AT_type, AttributeValue::ThisUnitEntryRef(dw_ty));
294+
var_entry.set(gimli::DW_AT_type, AttributeValue::UnitRef(dw_ty));
295295

296296
var_id
297297
}
@@ -341,15 +341,13 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> {
341341
let name = format!("{}{}", base_name, i);
342342

343343
let dw_ty = self.debug_context.dwarf_ty_for_clif_ty(param.value_type);
344-
let loc = Expression(
345-
translate_loc(isa, context.func.locations[val], &context.func.stack_slots).unwrap(),
346-
);
344+
let loc = translate_loc(isa, context.func.locations[val], &context.func.stack_slots).unwrap();
347345

348346
let arg_id = self.debug_context.dwarf.unit.add(self.entry_id, gimli::DW_TAG_formal_parameter);
349347
let var_entry = self.debug_context.dwarf.unit.get_mut(arg_id);
350348

351349
var_entry.set(gimli::DW_AT_name, AttributeValue::String(name.into_bytes()));
352-
var_entry.set(gimli::DW_AT_type, AttributeValue::ThisUnitEntryRef(dw_ty));
350+
var_entry.set(gimli::DW_AT_type, AttributeValue::UnitRef(dw_ty));
353351
var_entry.set(gimli::DW_AT_location, AttributeValue::Exprloc(loc));
354352
}
355353

@@ -413,9 +411,7 @@ fn place_location<'a, 'tcx>(
413411
symbol: func_debug_ctx.symbol,
414412
addend: i64::from(value_loc_range.end),
415413
},
416-
data: Expression(
417-
translate_loc(isa, value_loc_range.loc, &context.func.stack_slots).unwrap(),
418-
),
414+
data: translate_loc(isa, value_loc_range.loc, &context.func.stack_slots).unwrap(),
419415
})
420416
.collect(),
421417
);
@@ -425,40 +421,37 @@ fn place_location<'a, 'tcx>(
425421
} else {
426422
// FIXME set value labels for unused locals
427423

428-
AttributeValue::Exprloc(Expression(vec![]))
424+
AttributeValue::Exprloc(Expression::new())
429425
}
430426
}
431427
CPlaceInner::Addr(_, _) => {
432428
// FIXME implement this (used by arguments and returns)
433429

434-
AttributeValue::Exprloc(Expression(vec![]))
430+
AttributeValue::Exprloc(Expression::new())
435431

436432
// For PointerBase::Stack:
437-
//AttributeValue::Exprloc(Expression(translate_loc(ValueLoc::Stack(*stack_slot), &context.func.stack_slots).unwrap()))
433+
//AttributeValue::Exprloc(translate_loc(ValueLoc::Stack(*stack_slot), &context.func.stack_slots).unwrap())
438434
}
439435
}
440436
}
441437

442438
// Adapted from https://github.com/CraneStation/wasmtime/blob/5a1845b4caf7a5dba8eda1fef05213a532ed4259/crates/debug/src/transform/expression.rs#L59-L137
443-
fn translate_loc(isa: &dyn TargetIsa, loc: ValueLoc, stack_slots: &StackSlots) -> Option<Vec<u8>> {
439+
fn translate_loc(isa: &dyn TargetIsa, loc: ValueLoc, stack_slots: &StackSlots) -> Option<Expression> {
444440
match loc {
445441
ValueLoc::Reg(reg) => {
446442
let machine_reg = isa.map_dwarf_register(reg).unwrap();
447-
assert!(machine_reg <= 32); // FIXME
448-
Some(vec![gimli::constants::DW_OP_reg0.0 + machine_reg as u8])
443+
let mut expr = Expression::new();
444+
expr.op_reg(gimli::Register(machine_reg));
445+
Some(expr)
449446
}
450447
ValueLoc::Stack(ss) => {
451448
if let Some(ss_offset) = stack_slots[ss].offset {
452-
let endian = gimli::RunTimeEndian::Little;
453-
let mut writer = write::EndianVec::new(endian);
454-
writer
455-
.write_u8(gimli::constants::DW_OP_breg0.0 + X86_64::RBP.0 as u8)
456-
.expect("bp wr");
457-
writer.write_sleb128(ss_offset as i64 + 16).expect("ss wr");
458-
let buf = writer.into_vec();
459-
return Some(buf);
449+
let mut expr = Expression::new();
450+
expr.op_breg(X86_64::RBP, ss_offset as i64 + 16);
451+
Some(expr)
452+
} else {
453+
None
460454
}
461-
None
462455
}
463456
_ => None,
464457
}

0 commit comments

Comments
 (0)