Rollup merge of #146298 - cjgillot:gvn-derefer, r=nnethercote
GVN: Ensure indirect is first projection in try_as_place. I haven't found any report for this bug on existing code, but managed to trigger it with rust-lang/rust#143333
This commit is contained in:
commit
9a1feef5d8
1 changed files with 5 additions and 0 deletions
|
|
@ -1644,6 +1644,11 @@ impl<'tcx> VnState<'_, 'tcx> {
|
|||
let place =
|
||||
Place { local, projection: self.tcx.mk_place_elems(projection.as_slice()) };
|
||||
return Some(place);
|
||||
} else if projection.last() == Some(&PlaceElem::Deref) {
|
||||
// `Deref` can only be the first projection in a place.
|
||||
// If we are here, we failed to find a local, and we already have a `Deref`.
|
||||
// Trying to add projections will only result in an ill-formed place.
|
||||
return None;
|
||||
} else if let Value::Projection(pointer, proj) = *self.get(index)
|
||||
&& (allow_complex_projection || proj.is_stable_offset())
|
||||
&& let Some(proj) = self.try_as_place_elem(self.ty(index), proj, loc)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue