rename MIR int2ptr casts to match library name

This commit is contained in:
Ralf Jung 2024-03-23 12:21:20 +01:00
parent 67b9d7d184
commit 038e7c6c38
15 changed files with 16 additions and 16 deletions

View file

@ -2263,7 +2263,7 @@ fn check_rvalue(&mut self, body: &Body<'tcx>, rvalue: &Rvalue<'tcx>, location: L
}
}
CastKind::PointerFromExposedAddress => {
CastKind::PointerWithExposedProvenance => {
let ty_from = op.ty(body, tcx);
let cast_ty_from = CastTy::from_ty(ty_from);
let cast_ty_to = CastTy::from_ty(*ty);
@ -2273,7 +2273,7 @@ fn check_rvalue(&mut self, body: &Body<'tcx>, rvalue: &Rvalue<'tcx>, location: L
span_mirbug!(
self,
rvalue,
"Invalid PointerFromExposedAddress cast {:?} -> {:?}",
"Invalid PointerWithExposedProvenance cast {:?} -> {:?}",
ty_from,
ty
)

View file

@ -642,7 +642,7 @@ fn codegen_stmt<'tcx>(
| CastKind::FnPtrToPtr
| CastKind::PtrToPtr
| CastKind::PointerExposeAddress
| CastKind::PointerFromExposedAddress,
| CastKind::PointerWithExposedProvenance,
ref operand,
to_ty,
) => {

View file

@ -508,7 +508,7 @@ pub fn codegen_rvalue_operand(
// Since int2ptr can have arbitrary integer types as input (so we have to do
// sign extension and all that), it is currently best handled in the same code
// path as the other integer-to-X casts.
| mir::CastKind::PointerFromExposedAddress => {
| mir::CastKind::PointerWithExposedProvenance => {
assert!(bx.cx().is_backend_immediate(cast));
let ll_t_out = bx.cx().immediate_backend_type(cast);
if operand.layout.abi.is_uninhabited() {

View file

@ -40,7 +40,7 @@ pub fn cast(
self.write_immediate(*res, dest)?;
}
CastKind::PointerFromExposedAddress => {
CastKind::PointerWithExposedProvenance => {
let src = self.read_immediate(src)?;
let res = self.pointer_from_exposed_address_cast(&src, cast_layout)?;
self.write_immediate(*res, dest)?;

View file

@ -547,7 +547,7 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {
Rvalue::Cast(CastKind::PointerExposeAddress, _, _) => {
self.check_op(ops::RawPtrToIntCast);
}
Rvalue::Cast(CastKind::PointerFromExposedAddress, _, _) => {
Rvalue::Cast(CastKind::PointerWithExposedProvenance, _, _) => {
// Since no pointer can ever get exposed (rejected above), this is easy to support.
}

View file

@ -1057,7 +1057,7 @@ macro_rules! check_kinds {
// FIXME(dyn-star): make sure nothing needs to be done here.
}
// FIXME: Add Checks for these
CastKind::PointerFromExposedAddress
CastKind::PointerWithExposedProvenance
| CastKind::PointerExposeAddress
| CastKind::PointerCoercion(_) => {}
CastKind::IntToInt | CastKind::IntToFloat => {

View file

@ -426,7 +426,7 @@ pub fn is_safe_to_remove(&self) -> bool {
| CastKind::FnPtrToPtr
| CastKind::PtrToPtr
| CastKind::PointerCoercion(_)
| CastKind::PointerFromExposedAddress
| CastKind::PointerWithExposedProvenance
| CastKind::DynStar
| CastKind::Transmute,
_,

View file

@ -1319,7 +1319,7 @@ pub enum CastKind {
PointerExposeAddress,
/// An address-to-pointer cast that picks up an exposed provenance.
/// See the docs on `with_exposed_provenance` for more details.
PointerFromExposedAddress,
PointerWithExposedProvenance,
/// Pointer related casts that are done by coercions. Note that reference-to-raw-ptr casts are
/// translated into `&raw mut/const *r`, i.e., they are not actually casts.
PointerCoercion(PointerCoercion),

View file

@ -85,7 +85,7 @@ pub fn mir_cast_kind<'tcx>(from_ty: Ty<'tcx>, cast_ty: Ty<'tcx>) -> mir::CastKin
(Some(CastTy::Ptr(_) | CastTy::FnPtr), Some(CastTy::Int(_))) => {
mir::CastKind::PointerExposeAddress
}
(Some(CastTy::Int(_)), Some(CastTy::Ptr(_))) => mir::CastKind::PointerFromExposedAddress,
(Some(CastTy::Int(_)), Some(CastTy::Ptr(_))) => mir::CastKind::PointerWithExposedProvenance,
(_, Some(CastTy::DynStar)) => mir::CastKind::DynStar,
(Some(CastTy::Int(_)), Some(CastTy::Int(_))) => mir::CastKind::IntToInt,
(Some(CastTy::FnPtr), Some(CastTy::Ptr(_))) => mir::CastKind::FnPtrToPtr,

View file

@ -274,7 +274,7 @@ fn stable(&self, tables: &mut Tables<'_>) -> Self::T {
use rustc_middle::mir::CastKind::*;
match self {
PointerExposeAddress => stable_mir::mir::CastKind::PointerExposeAddress,
PointerFromExposedAddress => stable_mir::mir::CastKind::PointerFromExposedAddress,
PointerWithExposedProvenance => stable_mir::mir::CastKind::PointerWithExposedProvenance,
PointerCoercion(c) => stable_mir::mir::CastKind::PointerCoercion(c.stable(tables)),
DynStar => stable_mir::mir::CastKind::DynStar,
IntToInt => stable_mir::mir::CastKind::IntToInt,

View file

@ -968,7 +968,7 @@ pub enum PointerCoercion {
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum CastKind {
PointerExposeAddress,
PointerFromExposedAddress,
PointerWithExposedProvenance,
PointerCoercion(PointerCoercion),
DynStar,
IntToInt,

View file

@ -112,7 +112,7 @@ fn check_rvalue<'tcx>(
Rvalue::Repeat(operand, _)
| Rvalue::Use(operand)
| Rvalue::Cast(
CastKind::PointerFromExposedAddress
CastKind::PointerWithExposedProvenance
| CastKind::IntToInt
| CastKind::FloatToInt
| CastKind::IntToFloat

View file

@ -4,7 +4,7 @@ fn int_to_ptr(_1: usize) -> *const i32 {
let mut _0: *const i32;
bb0: {
_0 = _1 as *const i32 (PointerFromExposedAddress);
_0 = _1 as *const i32 (PointerWithExposedProvenance);
return;
}
}

View file

@ -16,7 +16,7 @@
_3 = main as fn() (PointerCoercion(ReifyFnPointer));
_2 = move _3 as usize (PointerExposeAddress);
StorageDead(_3);
_1 = move _2 as *const fn() (PointerFromExposedAddress);
_1 = move _2 as *const fn() (PointerWithExposedProvenance);
StorageDead(_2);
StorageDead(_1);
_0 = const ();

View file

@ -5,6 +5,6 @@ fn main() {
// CHECK-LABEL: fn main(
// CHECK: [[ptr:_.*]] = main as fn() (PointerCoercion(ReifyFnPointer));
// CHECK: [[addr:_.*]] = move [[ptr]] as usize (PointerExposeAddress);
// CHECK: [[back:_.*]] = move [[addr]] as *const fn() (PointerFromExposedAddress);
// CHECK: [[back:_.*]] = move [[addr]] as *const fn() (PointerWithExposedProvenance);
let _ = main as usize as *const fn();
}