Skip to content

Commit 89f45ed

Browse files
committed
Update match branches
This updates all places where match branches check on StatementKind or UseContext. This doesn't properly implement them, but adds TODOs where they are, and also adds some best guesses to what they should be in some cases.
1 parent 72c734d commit 89f45ed

File tree

19 files changed

+1346
-24
lines changed

19 files changed

+1346
-24
lines changed

compiler/rustc_codegen_ssa/src/mir/analyze.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,17 +293,15 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
293293
| MutatingUseContext::AsmOutput
294294
| MutatingUseContext::Borrow
295295
| MutatingUseContext::AddressOf
296-
| MutatingUseContext::Projection
297-
| MutatingUseContext::CopyNonOverlapping,
296+
| MutatingUseContext::Projection,
298297
)
299298
| PlaceContext::NonMutatingUse(
300299
NonMutatingUseContext::Inspect
301300
| NonMutatingUseContext::SharedBorrow
302301
| NonMutatingUseContext::UniqueBorrow
303302
| NonMutatingUseContext::ShallowBorrow
304303
| NonMutatingUseContext::AddressOf
305-
| NonMutatingUseContext::Projection
306-
| NonMutatingUseContext::CopyNonOverlapping,
304+
| NonMutatingUseContext::Projection,
307305
) => {
308306
self.not_ssa(local);
309307
}

compiler/rustc_codegen_ssa/src/mir/statement.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,22 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
120120
ref dst,
121121
ref size,
122122
}) => {
123-
let dst_val = self.codegen_place(&mut bx, dst.as_ref());
124-
let src_val = self.codegen_place(&mut bx, src.as_ref());
123+
let dst_val = self.codegen_operand(&mut bx, dst);
124+
let src_val = self.codegen_operand(&mut bx, src);
125125
let size_val = self.codegen_operand(&mut bx, size);
126126
let size = size_val.immediate_or_packed_pair(&mut bx);
127+
let dst = dst_val.immediate_or_packed_pair(&mut bx);
128+
let src = src_val.immediate_or_packed_pair(&mut bx);
129+
use crate::MemFlags;
130+
let flags =
131+
(!MemFlags::UNALIGNED) & (!MemFlags::VOLATILE) & (!MemFlags::NONTEMPORAL);
127132
bx.memcpy(
128-
dst_val.llval,
129-
dst_val.align,
130-
src_val.llval,
131-
src_val.align,
133+
dst,
134+
dst_val.layout.layout.align.pref,
135+
src,
136+
src_val.layout.layout.align.pref,
132137
size,
133-
// TODO probably want to have this change based on alignment above?
134-
crate::MemFlags::empty(),
138+
flags,
135139
);
136140
bx
137141
}

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,7 +1668,7 @@ impl Debug for Statement<'_> {
16681668
ref src,
16691669
ref dst,
16701670
ref size,
1671-
}) => write!(fmt, "copy_nonoverlapping(src={:?}, dst={:?},bytes={:?})", src, dst, size),
1671+
}) => write!(fmt, "copy_nonoverlapping(src={:?}, dst={:?}, size={:?})", src, dst, size),
16721672
Nop => write!(fmt, "nop"),
16731673
}
16741674
}
@@ -1682,8 +1682,8 @@ pub struct Coverage {
16821682

16831683
#[derive(Clone, Debug, PartialEq, TyEncodable, TyDecodable, HashStable, TypeFoldable)]
16841684
pub struct CopyNonOverlapping<'tcx> {
1685-
pub src: Place<'tcx>,
1686-
pub dst: Place<'tcx>,
1685+
pub src: Operand<'tcx>,
1686+
pub dst: Operand<'tcx>,
16871687
pub size: Operand<'tcx>,
16881688
}
16891689

compiler/rustc_middle/src/mir/visit.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -441,14 +441,12 @@ macro_rules! make_mir_visitor {
441441
ref $($mutability)? dst,
442442
ref $($mutability)? size,
443443
}) => {
444-
self.visit_place(
444+
self.visit_operand(
445445
src,
446-
PlaceContext::NonMutatingUse(NonMutatingUseContext::CopyNonOverlapping),
447446
location
448447
);
449-
self.visit_place(
448+
self.visit_operand(
450449
dst,
451-
PlaceContext::MutatingUse(MutatingUseContext::CopyNonOverlapping),
452450
location
453451
);
454452
self.visit_operand(size, location)
@@ -1168,8 +1166,6 @@ pub enum NonMutatingUseContext {
11681166
/// f(&x.y);
11691167
///
11701168
Projection,
1171-
/// Source from copy_nonoverlapping.
1172-
CopyNonOverlapping,
11731169
}
11741170

11751171
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
@@ -1199,8 +1195,6 @@ pub enum MutatingUseContext {
11991195
Projection,
12001196
/// Retagging, a "Stacked Borrows" shadow state operation
12011197
Retag,
1202-
/// Memory written to in copy_nonoverlapping.
1203-
CopyNonOverlapping,
12041198
}
12051199

12061200
#[derive(Copy, Clone, Debug, PartialEq, Eq)]

compiler/rustc_mir/src/borrow_check/invalidation.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,21 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
9292
self.consume_operand(location, input);
9393
}
9494
}
95+
StatementKind::CopyNonOverlapping(box rustc_middle::mir::CopyNonOverlapping {
96+
ref src,
97+
ref dst,
98+
ref size,
99+
}) => {
100+
self.consume_operand(location, src);
101+
self.consume_operand(location, dst);
102+
self.consume_operand(location, size);
103+
match dst {
104+
Operand::Move(ref place) | Operand::Copy(ref place) => {
105+
self.mutate_place(location, *place, Deep, JustWrite);
106+
}
107+
_ => {}
108+
}
109+
}
95110
StatementKind::Nop
96111
| StatementKind::Coverage(..)
97112
| StatementKind::AscribeUserType(..)

compiler/rustc_mir/src/borrow_check/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,8 @@ impl<'cx, 'tcx> dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tc
626626
self.consume_operand(location, (input, span), flow_state);
627627
}
628628
}
629+
630+
StatementKind::CopyNonOverlapping(..) => todo!(),
629631
StatementKind::Nop
630632
| StatementKind::Coverage(..)
631633
| StatementKind::AscribeUserType(..)

compiler/rustc_mir/src/borrow_check/type_check/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,6 +1520,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
15201520
);
15211521
}
15221522
}
1523+
StatementKind::CopyNonOverlapping(..) => todo!(),
15231524
StatementKind::FakeRead(..)
15241525
| StatementKind::StorageLive(..)
15251526
| StatementKind::StorageDead(..)

compiler/rustc_mir/src/dataflow/impls/borrows.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,8 @@ impl<'tcx> dataflow::GenKillAnalysis<'tcx> for Borrows<'_, 'tcx> {
306306
| mir::StatementKind::AscribeUserType(..)
307307
| mir::StatementKind::Coverage(..)
308308
| mir::StatementKind::Nop => {}
309+
310+
mir::StatementKind::CopyNonOverlapping(..) => todo!(),
309311
}
310312
}
311313

compiler/rustc_mir/src/dataflow/impls/storage_liveness.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ impl<'mir, 'tcx> dataflow::GenKillAnalysis<'tcx> for MaybeRequiresStorage<'mir,
150150
| StatementKind::Nop
151151
| StatementKind::Retag(..)
152152
| StatementKind::StorageLive(..) => {}
153+
154+
StatementKind::CopyNonOverlapping(..) => todo!(),
153155
}
154156
}
155157

compiler/rustc_mir/src/dataflow/move_paths/builder.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,8 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
319319
| StatementKind::AscribeUserType(..)
320320
| StatementKind::Coverage(..)
321321
| StatementKind::Nop => {}
322+
323+
StatementKind::CopyNonOverlapping(..) => todo!(),
322324
}
323325
}
324326

0 commit comments

Comments
 (0)