rename AddressOf -> RawBorrow inside the compiler
This commit is contained in:
parent
b8464961a2
commit
35709be02d
51 changed files with 92 additions and 92 deletions
|
@ -131,9 +131,9 @@ impl<'tcx> MirPass<'tcx> for AddRetag {
|
|||
// Ptr-creating operations already do their own internal retagging, no
|
||||
// need to also add a retag statement.
|
||||
// *Except* if we are deref'ing a Box, because those get desugared to directly working
|
||||
// with the inner raw pointer! That's relevant for `AddressOf` as Miri otherwise makes it
|
||||
// with the inner raw pointer! That's relevant for `RawPtr` as Miri otherwise makes it
|
||||
// a NOP when the original pointer is already raw.
|
||||
Rvalue::AddressOf(_mutbl, place) => {
|
||||
Rvalue::RawPtr(_mutbl, place) => {
|
||||
// Using `is_box_global` here is a bit sketchy: if this code is
|
||||
// generic over the allocator, we'll not add a retag! This is a hack
|
||||
// to make Stacked Borrows compatible with custom allocator code.
|
||||
|
|
|
@ -71,7 +71,7 @@ struct PointerFinder<'tcx, 'a> {
|
|||
impl<'tcx, 'a> Visitor<'tcx> for PointerFinder<'tcx, 'a> {
|
||||
fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext, location: Location) {
|
||||
// We want to only check reads and writes to Places, so we specifically exclude
|
||||
// Borrows and AddressOf.
|
||||
// Borrow and RawBorrow.
|
||||
match context {
|
||||
PlaceContext::MutatingUse(
|
||||
MutatingUseContext::Store
|
||||
|
|
|
@ -40,7 +40,7 @@ impl<'tcx> Visitor<'tcx> for DeduceReadOnly {
|
|||
// This is a mutation, so mark it as such.
|
||||
true
|
||||
}
|
||||
PlaceContext::NonMutatingUse(NonMutatingUseContext::AddressOf) => {
|
||||
PlaceContext::NonMutatingUse(NonMutatingUseContext::RawBorrow) => {
|
||||
// Whether mutating though a `&raw const` is allowed is still undecided, so we
|
||||
// disable any sketchy `readonly` optimizations for now.
|
||||
// But we only need to do this if the pointer would point into the argument.
|
||||
|
|
|
@ -576,7 +576,7 @@ impl WriteInfo {
|
|||
Rvalue::ThreadLocalRef(_)
|
||||
| Rvalue::NullaryOp(_, _)
|
||||
| Rvalue::Ref(_, _, _)
|
||||
| Rvalue::AddressOf(_, _)
|
||||
| Rvalue::RawPtr(_, _)
|
||||
| Rvalue::Len(_)
|
||||
| Rvalue::Discriminant(_)
|
||||
| Rvalue::CopyForDeref(_) => (),
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
//!
|
||||
//! # Handling of references
|
||||
//!
|
||||
//! We handle references by assigning a different "provenance" index to each Ref/AddressOf rvalue.
|
||||
//! We handle references by assigning a different "provenance" index to each Ref/RawPtr rvalue.
|
||||
//! This ensure that we do not spuriously merge borrows that should not be merged. Meanwhile, we
|
||||
//! consider all the derefs of an immutable reference to a freeze type to give the same value:
|
||||
//! ```ignore (MIR)
|
||||
|
@ -832,7 +832,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
|
|||
self.simplify_place_projection(place, location);
|
||||
return self.new_pointer(*place, AddressKind::Ref(borrow_kind));
|
||||
}
|
||||
Rvalue::AddressOf(mutbl, ref mut place) => {
|
||||
Rvalue::RawPtr(mutbl, ref mut place) => {
|
||||
self.simplify_place_projection(place, location);
|
||||
return self.new_pointer(*place, AddressKind::Address(mutbl));
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ impl<'tcx> InstSimplifyContext<'tcx, '_> {
|
|||
|
||||
/// Transform `&(*a)` ==> `a`.
|
||||
fn simplify_ref_deref(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
|
||||
if let Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) = rvalue {
|
||||
if let Rvalue::Ref(_, _, place) | Rvalue::RawPtr(_, place) = rvalue {
|
||||
if let Some((base, ProjectionElem::Deref)) = place.as_ref().last_projection() {
|
||||
if rvalue.ty(self.local_decls, self.tcx) != base.ty(self.local_decls, self.tcx).ty {
|
||||
return;
|
||||
|
|
|
@ -419,8 +419,8 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
|||
}
|
||||
|
||||
// Do not try creating references (#67862)
|
||||
Rvalue::AddressOf(_, place) | Rvalue::Ref(_, _, place) => {
|
||||
trace!("skipping AddressOf | Ref for {:?}", place);
|
||||
Rvalue::RawPtr(_, place) | Rvalue::Ref(_, _, place) => {
|
||||
trace!("skipping RawPtr | Ref for {:?}", place);
|
||||
|
||||
// This may be creating mutable references or immutable references to cells.
|
||||
// If that happens, the pointed to value could be mutated via that reference.
|
||||
|
@ -616,7 +616,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
|||
ImmTy::from_scalar(Scalar::from_target_usize(len, self), layout).into()
|
||||
}
|
||||
|
||||
Ref(..) | AddressOf(..) => return None,
|
||||
Ref(..) | RawPtr(..) => return None,
|
||||
|
||||
NullaryOp(ref null_op, ty) => {
|
||||
let op_layout = self.use_ecx(|this| this.ecx.layout_of(ty))?;
|
||||
|
@ -969,9 +969,9 @@ impl<'tcx> Visitor<'tcx> for CanConstProp {
|
|||
// mutation.
|
||||
| NonMutatingUse(NonMutatingUseContext::SharedBorrow)
|
||||
| NonMutatingUse(NonMutatingUseContext::FakeBorrow)
|
||||
| NonMutatingUse(NonMutatingUseContext::AddressOf)
|
||||
| NonMutatingUse(NonMutatingUseContext::RawBorrow)
|
||||
| MutatingUse(MutatingUseContext::Borrow)
|
||||
| MutatingUse(MutatingUseContext::AddressOf) => {
|
||||
| MutatingUse(MutatingUseContext::RawBorrow) => {
|
||||
trace!("local {:?} can't be propagated because it's used: {:?}", local, context);
|
||||
self.can_const_prop[local] = ConstPropMode::NoPropagation;
|
||||
}
|
||||
|
|
|
@ -214,7 +214,7 @@ impl EnumSizeOpt {
|
|||
source_info,
|
||||
kind: StatementKind::Assign(Box::new((
|
||||
dst,
|
||||
Rvalue::AddressOf(Mutability::Mut, *lhs),
|
||||
Rvalue::RawPtr(Mutability::Mut, *lhs),
|
||||
))),
|
||||
};
|
||||
|
||||
|
@ -238,7 +238,7 @@ impl EnumSizeOpt {
|
|||
source_info,
|
||||
kind: StatementKind::Assign(Box::new((
|
||||
src,
|
||||
Rvalue::AddressOf(Mutability::Not, *rhs),
|
||||
Rvalue::RawPtr(Mutability::Not, *rhs),
|
||||
))),
|
||||
};
|
||||
|
||||
|
|
|
@ -551,7 +551,7 @@ impl<'tcx> Validator<'_, 'tcx> {
|
|||
self.validate_operand(rhs)?;
|
||||
}
|
||||
|
||||
Rvalue::AddressOf(_, place) => {
|
||||
Rvalue::RawPtr(_, place) => {
|
||||
// We accept `&raw *`, i.e., raw reborrows -- creating a raw pointer is
|
||||
// no problem, only using it is.
|
||||
if let Some((place_base, ProjectionElem::Deref)) = place.as_ref().last_projection()
|
||||
|
|
|
@ -227,7 +227,7 @@ fn compute_replacement<'tcx>(
|
|||
}
|
||||
}
|
||||
}
|
||||
Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => {
|
||||
Rvalue::Ref(_, _, place) | Rvalue::RawPtr(_, place) => {
|
||||
let mut place = *place;
|
||||
// Try to see through `place` in order to collapse reborrow chains.
|
||||
if place.projection.first() == Some(&PlaceElem::Deref)
|
||||
|
|
|
@ -343,7 +343,7 @@ impl<'tcx> AsyncDestructorCtorShimBuilder<'tcx> {
|
|||
.tcx
|
||||
.mk_place_elems(&[PlaceElem::Deref, PlaceElem::Field(field, field_ty)]),
|
||||
};
|
||||
self.put_temp_rvalue(Rvalue::AddressOf(Mutability::Mut, place))
|
||||
self.put_temp_rvalue(Rvalue::RawPtr(Mutability::Mut, place))
|
||||
}
|
||||
|
||||
/// If given Self is an enum puts `to_drop: *mut FieldTy` on top of
|
||||
|
@ -363,7 +363,7 @@ impl<'tcx> AsyncDestructorCtorShimBuilder<'tcx> {
|
|||
PlaceElem::Field(field, field_ty),
|
||||
]),
|
||||
};
|
||||
self.put_temp_rvalue(Rvalue::AddressOf(Mutability::Mut, place))
|
||||
self.put_temp_rvalue(Rvalue::RawPtr(Mutability::Mut, place))
|
||||
}
|
||||
|
||||
/// If given Self is an enum puts `to_drop: *mut FieldTy` on top of
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
//! 1/ They are only assigned-to once, either as a function parameter, or in an assign statement;
|
||||
//! 2/ This single assignment dominates all uses;
|
||||
//!
|
||||
//! As we do not track indirect assignments, a local that has its address taken (either by
|
||||
//! AddressOf or by borrowing) is considered non-SSA. However, it is UB to modify through an
|
||||
//! immutable borrow of a `Freeze` local. Those can still be considered to be SSA.
|
||||
//! As we do not track indirect assignments, a local that has its address taken (via a borrow or raw
|
||||
//! borrow operator) is considered non-SSA. However, it is UB to modify through an immutable borrow
|
||||
//! of a `Freeze` local. Those can still be considered to be SSA.
|
||||
|
||||
use rustc_data_structures::graph::dominators::Dominators;
|
||||
use rustc_index::bit_set::BitSet;
|
||||
|
@ -262,7 +262,7 @@ impl<'tcx> Visitor<'tcx> for SsaVisitor<'tcx, '_> {
|
|||
PlaceContext::MutatingUse(MutatingUseContext::Projection)
|
||||
| PlaceContext::NonMutatingUse(NonMutatingUseContext::Projection) => bug!(),
|
||||
// Anything can happen with raw pointers, so remove them.
|
||||
PlaceContext::NonMutatingUse(NonMutatingUseContext::AddressOf)
|
||||
PlaceContext::NonMutatingUse(NonMutatingUseContext::RawBorrow)
|
||||
| PlaceContext::MutatingUse(_) => {
|
||||
self.assignments[local] = Set1::Many;
|
||||
}
|
||||
|
|
|
@ -1345,7 +1345,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
|
|||
}
|
||||
Rvalue::Repeat(_, _)
|
||||
| Rvalue::ThreadLocalRef(_)
|
||||
| Rvalue::AddressOf(_, _)
|
||||
| Rvalue::RawPtr(_, _)
|
||||
| Rvalue::NullaryOp(NullOp::SizeOf | NullOp::AlignOf | NullOp::UbChecks, _)
|
||||
| Rvalue::Discriminant(_) => {}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue