Support ConstantIndex in debuginfo.
This commit is contained in:
parent
2ec0071913
commit
7de9aac4fb
@ -8,7 +8,7 @@
|
||||
use rustc_session::config::DebugInfo;
|
||||
use rustc_span::symbol::{kw, Symbol};
|
||||
use rustc_span::{BytePos, Span};
|
||||
use rustc_target::abi::{Abi, FieldIdx, Size, VariantIdx};
|
||||
use rustc_target::abi::{Abi, FieldIdx, FieldsShape, Size, VariantIdx};
|
||||
|
||||
use super::operand::{OperandRef, OperandValue};
|
||||
use super::place::PlaceRef;
|
||||
@ -83,6 +83,7 @@ trait DebugInfoOffsetLocation<'tcx, Bx> {
|
||||
fn deref(&self, bx: &mut Bx) -> Self;
|
||||
fn layout(&self) -> TyAndLayout<'tcx>;
|
||||
fn project_field(&self, bx: &mut Bx, field: FieldIdx) -> Self;
|
||||
fn project_constant_index(&self, bx: &mut Bx, offset: u64) -> Self;
|
||||
fn downcast(&self, bx: &mut Bx, variant: VariantIdx) -> Self;
|
||||
}
|
||||
|
||||
@ -101,6 +102,11 @@ fn project_field(&self, bx: &mut Bx, field: FieldIdx) -> Self {
|
||||
PlaceRef::project_field(*self, bx, field.index())
|
||||
}
|
||||
|
||||
fn project_constant_index(&self, bx: &mut Bx, offset: u64) -> Self {
|
||||
let lloffset = bx.cx().const_usize(offset);
|
||||
self.project_index(bx, lloffset)
|
||||
}
|
||||
|
||||
fn downcast(&self, bx: &mut Bx, variant: VariantIdx) -> Self {
|
||||
self.project_downcast(bx, variant)
|
||||
}
|
||||
@ -123,6 +129,10 @@ fn project_field(&self, bx: &mut Bx, field: FieldIdx) -> Self {
|
||||
self.field(bx.cx(), field.index())
|
||||
}
|
||||
|
||||
fn project_constant_index(&self, bx: &mut Bx, index: u64) -> Self {
|
||||
self.field(bx.cx(), index as usize)
|
||||
}
|
||||
|
||||
fn downcast(&self, bx: &mut Bx, variant: VariantIdx) -> Self {
|
||||
self.for_variant(bx.cx(), variant)
|
||||
}
|
||||
@ -168,6 +178,18 @@ fn calculate_debuginfo_offset<
|
||||
mir::ProjectionElem::Downcast(_, variant) => {
|
||||
place = place.downcast(bx, variant);
|
||||
}
|
||||
mir::ProjectionElem::ConstantIndex {
|
||||
offset: index,
|
||||
min_length: _,
|
||||
from_end: false,
|
||||
} => {
|
||||
let offset = indirect_offsets.last_mut().unwrap_or(&mut direct_offset);
|
||||
let FieldsShape::Array { stride, count: _ } = place.layout().fields else {
|
||||
span_bug!(var.source_info.span, "ConstantIndex on non-array type {:?}", place.layout())
|
||||
};
|
||||
*offset += stride * index;
|
||||
place = place.project_constant_index(bx, index);
|
||||
}
|
||||
_ => {
|
||||
// Sanity check for `can_use_in_debuginfo`.
|
||||
debug_assert!(!elem.can_use_in_debuginfo());
|
||||
|
@ -1554,8 +1554,11 @@ pub fn is_field_to(&self, f: FieldIdx) -> bool {
|
||||
/// Returns `true` if this is accepted inside `VarDebugInfoContents::Place`.
|
||||
pub fn can_use_in_debuginfo(&self) -> bool {
|
||||
match self {
|
||||
Self::Deref | Self::Downcast(_, _) | Self::Field(_, _) => true,
|
||||
Self::ConstantIndex { .. }
|
||||
Self::ConstantIndex { from_end: false, .. }
|
||||
| Self::Deref
|
||||
| Self::Downcast(_, _)
|
||||
| Self::Field(_, _) => true,
|
||||
Self::ConstantIndex { from_end: true, .. }
|
||||
| Self::Index(_)
|
||||
| Self::OpaqueCast(_)
|
||||
| Self::Subslice { .. } => false,
|
||||
|
@ -21,9 +21,9 @@
|
||||
let _13: &T; // in scope 1 at $DIR/issue_76432.rs:+3:18: +3:24
|
||||
let _14: &T; // in scope 1 at $DIR/issue_76432.rs:+3:26: +3:32
|
||||
scope 2 {
|
||||
debug v1 => _12; // in scope 2 at $DIR/issue_76432.rs:+3:10: +3:16
|
||||
debug v2 => _13; // in scope 2 at $DIR/issue_76432.rs:+3:18: +3:24
|
||||
debug v3 => _14; // in scope 2 at $DIR/issue_76432.rs:+3:26: +3:32
|
||||
debug v1 => &(*_2)[0 of 3]; // in scope 2 at $DIR/issue_76432.rs:+3:10: +3:16
|
||||
debug v2 => &(*_2)[1 of 3]; // in scope 2 at $DIR/issue_76432.rs:+3:18: +3:24
|
||||
debug v3 => &(*_2)[2 of 3]; // in scope 2 at $DIR/issue_76432.rs:+3:26: +3:32
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,15 +52,6 @@
|
||||
}
|
||||
|
||||
bb2: {
|
||||
StorageLive(_12); // scope 1 at $DIR/issue_76432.rs:+3:10: +3:16
|
||||
_12 = &(*_2)[0 of 3]; // scope 1 at $DIR/issue_76432.rs:+3:10: +3:16
|
||||
StorageLive(_13); // scope 1 at $DIR/issue_76432.rs:+3:18: +3:24
|
||||
_13 = &(*_2)[1 of 3]; // scope 1 at $DIR/issue_76432.rs:+3:18: +3:24
|
||||
StorageLive(_14); // scope 1 at $DIR/issue_76432.rs:+3:26: +3:32
|
||||
_14 = &(*_2)[2 of 3]; // scope 1 at $DIR/issue_76432.rs:+3:26: +3:32
|
||||
StorageDead(_14); // scope 1 at $DIR/issue_76432.rs:+3:84: +3:85
|
||||
StorageDead(_13); // scope 1 at $DIR/issue_76432.rs:+3:84: +3:85
|
||||
StorageDead(_12); // scope 1 at $DIR/issue_76432.rs:+3:84: +3:85
|
||||
StorageDead(_5); // scope 0 at $DIR/issue_76432.rs:+6:1: +6:2
|
||||
StorageDead(_2); // scope 0 at $DIR/issue_76432.rs:+6:1: +6:2
|
||||
return; // scope 0 at $DIR/issue_76432.rs:+6:2: +6:2
|
||||
|
Loading…
Reference in New Issue
Block a user