1
Fork 0

Compute unsizing casts in GVN.

This commit is contained in:
Camille GILLOT 2023-12-17 22:30:20 +00:00
parent 1f544ca0cc
commit 304b4ad8b9
7 changed files with 33 additions and 21 deletions

View file

@ -551,6 +551,16 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
}
value.offset(Size::ZERO, to, &self.ecx).ok()?
}
CastKind::PointerCoercion(ty::adjustment::PointerCoercion::Unsize) => {
let src = self.evaluated[value].as_ref()?;
let to = self.ecx.layout_of(to).ok()?;
let dest = self.ecx.allocate(to, MemoryKind::Stack).ok()?;
self.ecx.unsize_into(src, to, &dest.clone().into()).ok()?;
self.ecx
.alloc_mark_immutable(dest.ptr().provenance.unwrap().alloc_id())
.ok()?;
dest.into()
}
_ => return None,
},
};