mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 19:58:32 +00:00
Reduce size of statements
This commit is contained in:
parent
2fb1fb7634
commit
0a97eee8df
@ -1452,7 +1452,7 @@ pub struct Statement<'tcx> {
|
|||||||
|
|
||||||
// `Statement` is used a lot. Make sure it doesn't unintentionally get bigger.
|
// `Statement` is used a lot. Make sure it doesn't unintentionally get bigger.
|
||||||
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
||||||
static_assert_size!(Statement<'_>, 40);
|
static_assert_size!(Statement<'_>, 32);
|
||||||
|
|
||||||
impl Statement<'_> {
|
impl Statement<'_> {
|
||||||
/// Changes a statement to a nop. This is both faster than deleting instructions and avoids
|
/// Changes a statement to a nop. This is both faster than deleting instructions and avoids
|
||||||
@ -1482,7 +1482,7 @@ pub enum StatementKind<'tcx> {
|
|||||||
///
|
///
|
||||||
/// Note that this also is emitted for regular `let` bindings to ensure that locals that are
|
/// Note that this also is emitted for regular `let` bindings to ensure that locals that are
|
||||||
/// never accessed still get some sanity checks for, e.g., `let x: ! = ..;`
|
/// never accessed still get some sanity checks for, e.g., `let x: ! = ..;`
|
||||||
FakeRead(FakeReadCause, Box<Place<'tcx>>),
|
FakeRead(Box<(FakeReadCause, Place<'tcx>)>),
|
||||||
|
|
||||||
/// Write the discriminant for a variant to the enum Place.
|
/// Write the discriminant for a variant to the enum Place.
|
||||||
SetDiscriminant { place: Box<Place<'tcx>>, variant_index: VariantIdx },
|
SetDiscriminant { place: Box<Place<'tcx>>, variant_index: VariantIdx },
|
||||||
@ -1628,7 +1628,9 @@ impl Debug for Statement<'_> {
|
|||||||
use self::StatementKind::*;
|
use self::StatementKind::*;
|
||||||
match self.kind {
|
match self.kind {
|
||||||
Assign(box (ref place, ref rv)) => write!(fmt, "{:?} = {:?}", place, rv),
|
Assign(box (ref place, ref rv)) => write!(fmt, "{:?} = {:?}", place, rv),
|
||||||
FakeRead(ref cause, ref place) => write!(fmt, "FakeRead({:?}, {:?})", cause, place),
|
FakeRead(box (ref cause, ref place)) => {
|
||||||
|
write!(fmt, "FakeRead({:?}, {:?})", cause, place)
|
||||||
|
}
|
||||||
Retag(ref kind, ref place) => write!(
|
Retag(ref kind, ref place) => write!(
|
||||||
fmt,
|
fmt,
|
||||||
"Retag({}{:?})",
|
"Retag({}{:?})",
|
||||||
|
@ -380,7 +380,7 @@ macro_rules! make_mir_visitor {
|
|||||||
) => {
|
) => {
|
||||||
self.visit_assign(place, rvalue, location);
|
self.visit_assign(place, rvalue, location);
|
||||||
}
|
}
|
||||||
StatementKind::FakeRead(_, place) => {
|
StatementKind::FakeRead(box (_, place)) => {
|
||||||
self.visit_place(
|
self.visit_place(
|
||||||
place,
|
place,
|
||||||
PlaceContext::NonMutatingUse(NonMutatingUseContext::Inspect),
|
PlaceContext::NonMutatingUse(NonMutatingUseContext::Inspect),
|
||||||
|
@ -1728,7 +1728,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||||||
impl<'tcx> Visitor<'tcx> for FakeReadCauseFinder<'tcx> {
|
impl<'tcx> Visitor<'tcx> for FakeReadCauseFinder<'tcx> {
|
||||||
fn visit_statement(&mut self, statement: &Statement<'tcx>, _: Location) {
|
fn visit_statement(&mut self, statement: &Statement<'tcx>, _: Location) {
|
||||||
match statement {
|
match statement {
|
||||||
Statement { kind: StatementKind::FakeRead(cause, box place), .. }
|
Statement { kind: StatementKind::FakeRead(box (cause, place)), .. }
|
||||||
if *place == self.place =>
|
if *place == self.place =>
|
||||||
{
|
{
|
||||||
self.cause = Some(*cause);
|
self.cause = Some(*cause);
|
||||||
|
@ -515,7 +515,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||||||
let block = &self.body.basic_blocks()[location.block];
|
let block = &self.body.basic_blocks()[location.block];
|
||||||
|
|
||||||
let kind = if let Some(&Statement {
|
let kind = if let Some(&Statement {
|
||||||
kind: StatementKind::FakeRead(FakeReadCause::ForLet(_), _),
|
kind: StatementKind::FakeRead(box (FakeReadCause::ForLet(_), _)),
|
||||||
..
|
..
|
||||||
}) = block.statements.get(location.statement_index)
|
}) = block.statements.get(location.statement_index)
|
||||||
{
|
{
|
||||||
|
@ -797,7 +797,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||||||
|
|
||||||
// StatementKind::FakeRead only contains a def_id if they are introduced as a result
|
// StatementKind::FakeRead only contains a def_id if they are introduced as a result
|
||||||
// of pattern matching within a closure.
|
// of pattern matching within a closure.
|
||||||
if let StatementKind::FakeRead(cause, box ref place) = stmt.kind {
|
if let StatementKind::FakeRead(box (cause, ref place)) = stmt.kind {
|
||||||
match cause {
|
match cause {
|
||||||
FakeReadCause::ForMatchedPlace(Some(closure_def_id))
|
FakeReadCause::ForMatchedPlace(Some(closure_def_id))
|
||||||
| FakeReadCause::ForLet(Some(closure_def_id)) => {
|
| FakeReadCause::ForLet(Some(closure_def_id)) => {
|
||||||
|
@ -63,7 +63,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
|
|||||||
|
|
||||||
self.mutate_place(location, *lhs, Shallow(None), JustWrite);
|
self.mutate_place(location, *lhs, Shallow(None), JustWrite);
|
||||||
}
|
}
|
||||||
StatementKind::FakeRead(_, _) => {
|
StatementKind::FakeRead(box (_, _)) => {
|
||||||
// Only relevant for initialized/liveness/safety checks.
|
// Only relevant for initialized/liveness/safety checks.
|
||||||
}
|
}
|
||||||
StatementKind::SetDiscriminant { place, variant_index: _ } => {
|
StatementKind::SetDiscriminant { place, variant_index: _ } => {
|
||||||
|
@ -574,7 +574,7 @@ impl<'cx, 'tcx> dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tc
|
|||||||
|
|
||||||
self.mutate_place(location, (*lhs, span), Shallow(None), JustWrite, flow_state);
|
self.mutate_place(location, (*lhs, span), Shallow(None), JustWrite, flow_state);
|
||||||
}
|
}
|
||||||
StatementKind::FakeRead(_, box ref place) => {
|
StatementKind::FakeRead(box (_, ref place)) => {
|
||||||
// Read for match doesn't access any memory and is used to
|
// Read for match doesn't access any memory and is used to
|
||||||
// assert that a place is safe and live. So we don't have to
|
// assert that a place is safe and live. So we don't have to
|
||||||
// do any checks here.
|
// do any checks here.
|
||||||
|
@ -293,8 +293,8 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
self.gather_rvalue(rval);
|
self.gather_rvalue(rval);
|
||||||
}
|
}
|
||||||
StatementKind::FakeRead(_, place) => {
|
StatementKind::FakeRead(box (_, place)) => {
|
||||||
self.create_move_path(**place);
|
self.create_move_path(*place);
|
||||||
}
|
}
|
||||||
StatementKind::LlvmInlineAsm(ref asm) => {
|
StatementKind::LlvmInlineAsm(ref asm) => {
|
||||||
for (output, kind) in iter::zip(&*asm.outputs, &asm.asm.outputs) {
|
for (output, kind) in iter::zip(&*asm.outputs, &asm.asm.outputs) {
|
||||||
|
@ -683,10 +683,10 @@ pub(super) fn filtered_statement_span(
|
|||||||
// and `_1` is the `Place` for `somenum`.
|
// and `_1` is the `Place` for `somenum`.
|
||||||
//
|
//
|
||||||
// If and when the Issue is resolved, remove this special case match pattern:
|
// If and when the Issue is resolved, remove this special case match pattern:
|
||||||
StatementKind::FakeRead(cause, _) if cause == FakeReadCause::ForGuardBinding => None,
|
StatementKind::FakeRead(box (cause, _)) if cause == FakeReadCause::ForGuardBinding => None,
|
||||||
|
|
||||||
// Retain spans from all other statements
|
// Retain spans from all other statements
|
||||||
StatementKind::FakeRead(_, _) // Not including `ForGuardBinding`
|
StatementKind::FakeRead(box (_, _)) // Not including `ForGuardBinding`
|
||||||
| StatementKind::CopyNonOverlapping(..)
|
| StatementKind::CopyNonOverlapping(..)
|
||||||
| StatementKind::Assign(_)
|
| StatementKind::Assign(_)
|
||||||
| StatementKind::SetDiscriminant { .. }
|
| StatementKind::SetDiscriminant { .. }
|
||||||
|
@ -80,7 +80,7 @@ impl<'tcx> CFG<'tcx> {
|
|||||||
cause: FakeReadCause,
|
cause: FakeReadCause,
|
||||||
place: Place<'tcx>,
|
place: Place<'tcx>,
|
||||||
) {
|
) {
|
||||||
let kind = StatementKind::FakeRead(cause, box place);
|
let kind = StatementKind::FakeRead(box (cause, place));
|
||||||
let stmt = Statement { source_info, kind };
|
let stmt = Statement { source_info, kind };
|
||||||
self.push(block, stmt);
|
self.push(block, stmt);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user