Rollup merge of #92203 - Aaron1011:mir-adt-def, r=oli-obk
Store a `DefId` instead of an `AdtDef` in `AggregateKind::Adt` The `AggregateKind` enum ends up in the final mir `Body`. Currently, any changes to `AdtDef` (regardless of how significant they are) will legitimately cause the overall result of `optimized_mir` to change, invalidating any codegen re-use involving that mir. This will get worse once we start hashing the `Span` inside `FieldDef` (which is itself contained in `AdtDef`). To try to reduce these kinds of invalidations, this commit changes `AggregateKind::Adt` to store just the `DefId`, instead of the full `AdtDef`. This allows the result of `optimized_mir` to be unchanged if the `AdtDef` changes in a way that doesn't actually affect any of the MIR we build.
This commit is contained in:
commit
8a61ae0479
11 changed files with 32 additions and 31 deletions
|
@ -117,8 +117,8 @@ impl<'tcx> Visitor<'tcx> for UnsafetyChecker<'_, 'tcx> {
|
|||
match rvalue {
|
||||
Rvalue::Aggregate(box ref aggregate, _) => match aggregate {
|
||||
&AggregateKind::Array(..) | &AggregateKind::Tuple => {}
|
||||
&AggregateKind::Adt(ref def, ..) => {
|
||||
match self.tcx.layout_scalar_valid_range(def.did) {
|
||||
&AggregateKind::Adt(adt_did, ..) => {
|
||||
match self.tcx.layout_scalar_valid_range(adt_did) {
|
||||
(Bound::Unbounded, Bound::Unbounded) => {}
|
||||
_ => self.require_unsafe(
|
||||
UnsafetyViolationKind::General,
|
||||
|
|
|
@ -243,7 +243,7 @@ impl<'tcx> TransformVisitor<'tcx> {
|
|||
val: Operand<'tcx>,
|
||||
source_info: SourceInfo,
|
||||
) -> impl Iterator<Item = Statement<'tcx>> {
|
||||
let kind = AggregateKind::Adt(self.state_adt_ref, idx, self.state_substs, None, None);
|
||||
let kind = AggregateKind::Adt(self.state_adt_ref.did, idx, self.state_substs, None, None);
|
||||
assert_eq!(self.state_adt_ref.variants[idx].fields.len(), 1);
|
||||
let ty = self
|
||||
.tcx
|
||||
|
|
|
@ -777,7 +777,7 @@ pub fn build_adt_ctor(tcx: TyCtxt<'_>, ctor_id: DefId) -> Body<'_> {
|
|||
adt_def.variants[variant_index].fields.iter().enumerate().map(|(idx, field_def)| {
|
||||
(Operand::Move(Place::from(Local::new(idx + 1))), field_def.ty(tcx, substs))
|
||||
}),
|
||||
AggregateKind::Adt(adt_def, variant_index, substs, None, None),
|
||||
AggregateKind::Adt(adt_def.did, variant_index, substs, None, None),
|
||||
source_info,
|
||||
tcx,
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue