Impl StatementKind::CopyNonOverlapping
This commit is contained in:
parent
3a5d45f68c
commit
0fdc07e197
4 changed files with 57 additions and 2 deletions
|
@ -293,7 +293,8 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
|
||||||
| MutatingUseContext::AsmOutput
|
| MutatingUseContext::AsmOutput
|
||||||
| MutatingUseContext::Borrow
|
| MutatingUseContext::Borrow
|
||||||
| MutatingUseContext::AddressOf
|
| MutatingUseContext::AddressOf
|
||||||
| MutatingUseContext::Projection,
|
| MutatingUseContext::Projection
|
||||||
|
| MutatingUseContext::CopyNonOverlapping,
|
||||||
)
|
)
|
||||||
| PlaceContext::NonMutatingUse(
|
| PlaceContext::NonMutatingUse(
|
||||||
NonMutatingUseContext::Inspect
|
NonMutatingUseContext::Inspect
|
||||||
|
@ -301,7 +302,8 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
|
||||||
| NonMutatingUseContext::UniqueBorrow
|
| NonMutatingUseContext::UniqueBorrow
|
||||||
| NonMutatingUseContext::ShallowBorrow
|
| NonMutatingUseContext::ShallowBorrow
|
||||||
| NonMutatingUseContext::AddressOf
|
| NonMutatingUseContext::AddressOf
|
||||||
| NonMutatingUseContext::Projection,
|
| NonMutatingUseContext::Projection
|
||||||
|
| NonMutatingUseContext::CopyNonOverlapping,
|
||||||
) => {
|
) => {
|
||||||
self.not_ssa(local);
|
self.not_ssa(local);
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,6 +115,21 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
self.codegen_coverage(&mut bx, coverage.clone());
|
self.codegen_coverage(&mut bx, coverage.clone());
|
||||||
bx
|
bx
|
||||||
}
|
}
|
||||||
|
mir::StatementKind::CopyNonOverlapping(box mir::CopyNonOverlapping {
|
||||||
|
ref src,
|
||||||
|
ref dst,
|
||||||
|
ref size,
|
||||||
|
}) => {
|
||||||
|
bx.memcpy(
|
||||||
|
dst,
|
||||||
|
todo!(),
|
||||||
|
src,
|
||||||
|
todo!(),
|
||||||
|
size,
|
||||||
|
todo!(),
|
||||||
|
);
|
||||||
|
bx
|
||||||
|
}
|
||||||
mir::StatementKind::FakeRead(..)
|
mir::StatementKind::FakeRead(..)
|
||||||
| mir::StatementKind::Retag { .. }
|
| mir::StatementKind::Retag { .. }
|
||||||
| mir::StatementKind::AscribeUserType(..)
|
| mir::StatementKind::AscribeUserType(..)
|
||||||
|
|
|
@ -1541,6 +1541,11 @@ pub enum StatementKind<'tcx> {
|
||||||
/// counter varible at runtime, each time the code region is executed.
|
/// counter varible at runtime, each time the code region is executed.
|
||||||
Coverage(Box<Coverage>),
|
Coverage(Box<Coverage>),
|
||||||
|
|
||||||
|
/// Denotes a call to the intrinsic function copy_overlapping, where `src_dst` denotes the
|
||||||
|
/// memory being read from and written to(one field to save memory), and size
|
||||||
|
/// indicates how many bytes are being copied over.
|
||||||
|
CopyNonOverlapping(Box<CopyNonOverlapping<'tcx>>),
|
||||||
|
|
||||||
/// No-op. Useful for deleting instructions without affecting statement indices.
|
/// No-op. Useful for deleting instructions without affecting statement indices.
|
||||||
Nop,
|
Nop,
|
||||||
}
|
}
|
||||||
|
@ -1659,6 +1664,11 @@ impl Debug for Statement<'_> {
|
||||||
write!(fmt, "Coverage::{:?}", coverage.kind)
|
write!(fmt, "Coverage::{:?}", coverage.kind)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
CopyNonOverlapping(box crate::mir::CopyNonOverlapping {
|
||||||
|
ref src,
|
||||||
|
ref dst,
|
||||||
|
ref size,
|
||||||
|
}) => write!(fmt, "src {:?} -> dst {:?}, {:?} bytes", src, dst, size),
|
||||||
Nop => write!(fmt, "nop"),
|
Nop => write!(fmt, "nop"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1670,6 +1680,13 @@ pub struct Coverage {
|
||||||
pub code_region: Option<CodeRegion>,
|
pub code_region: Option<CodeRegion>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, TyEncodable, TyDecodable, HashStable, TypeFoldable)]
|
||||||
|
pub struct CopyNonOverlapping<'tcx> {
|
||||||
|
pub src: Place<'tcx>,
|
||||||
|
pub dst: Place<'tcx>,
|
||||||
|
pub size: Operand<'tcx>,
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// Places
|
// Places
|
||||||
|
|
||||||
|
|
|
@ -436,6 +436,23 @@ macro_rules! make_mir_visitor {
|
||||||
location
|
location
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
StatementKind::CopyNonOverlapping(box crate::mir::CopyNonOverlapping{
|
||||||
|
ref $($mutability)? src,
|
||||||
|
ref $($mutability)? dst,
|
||||||
|
ref $($mutability)? size,
|
||||||
|
}) => {
|
||||||
|
self.visit_place(
|
||||||
|
src,
|
||||||
|
PlaceContext::NonMutatingUse(NonMutatingUseContext::CopyNonOverlapping),
|
||||||
|
location
|
||||||
|
);
|
||||||
|
self.visit_place(
|
||||||
|
dst,
|
||||||
|
PlaceContext::MutatingUse(MutatingUseContext::CopyNonOverlapping),
|
||||||
|
location
|
||||||
|
);
|
||||||
|
self.visit_operand(size, location)
|
||||||
|
}
|
||||||
StatementKind::Nop => {}
|
StatementKind::Nop => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1151,6 +1168,8 @@ pub enum NonMutatingUseContext {
|
||||||
/// f(&x.y);
|
/// f(&x.y);
|
||||||
///
|
///
|
||||||
Projection,
|
Projection,
|
||||||
|
/// Source from copy_nonoverlapping.
|
||||||
|
CopyNonOverlapping,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
|
@ -1180,6 +1199,8 @@ pub enum MutatingUseContext {
|
||||||
Projection,
|
Projection,
|
||||||
/// Retagging, a "Stacked Borrows" shadow state operation
|
/// Retagging, a "Stacked Borrows" shadow state operation
|
||||||
Retag,
|
Retag,
|
||||||
|
/// Memory written to in copy_nonoverlapping.
|
||||||
|
CopyNonOverlapping,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue