about summary refs log tree commit diff
path: root/src/librustc_codegen_ssa/mir
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-12-11 23:00:38 +0000
committerbors <bors@rust-lang.org>2019-12-11 23:00:38 +0000
commitde0abf7599023b71dd72b44f0165e86c040ee7ea (patch)
treebe49c0cf5e2200c6d31133d7c336d99dee41d90c /src/librustc_codegen_ssa/mir
parent27d6f55f47e8875e71083a28ed84ea5a88e1b596 (diff)
parentd96485d49e3745a9b9f4b2ed6ba9cebf265f142e (diff)
downloadrust-de0abf7599023b71dd72b44f0165e86c040ee7ea.tar.gz
rust-de0abf7599023b71dd72b44f0165e86c040ee7ea.zip
Auto merge of #66650 - matthewjasper:nonuniform-array-move, r=pnkfelix
Remove uniform array move MIR passes

This PR fixes a number of bugs caused by limitations of this pass

* Projections from constant indexes weren't being canonicalized
* Constant indexes from the start weren't being canonicalized (they could have different min_lengths)
* It didn't apply to non-moves

This PR makes the following changes to support removing this pass:

* ConstantIndex of arrays are now generated in a canonical form (from the start, min_length is the actual length).
* Subslices are now split when generating move paths and when checking subslices have been moved.

Additionally

* The parent move path of a projection from an array element is now calculated correctly

closes #66502
Diffstat (limited to 'src/librustc_codegen_ssa/mir')
-rw-r--r--src/librustc_codegen_ssa/mir/place.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/librustc_codegen_ssa/mir/place.rs b/src/librustc_codegen_ssa/mir/place.rs
index e60b8861faf..5e13cabced0 100644
--- a/src/librustc_codegen_ssa/mir/place.rs
+++ b/src/librustc_codegen_ssa/mir/place.rs
@@ -565,7 +565,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
                         let llindex = bx.sub(lllen, lloffset);
                         cg_base.project_index(bx, llindex)
                     }
-                    mir::ProjectionElem::Subslice { from, to } => {
+                    mir::ProjectionElem::Subslice { from, to, from_end } => {
                         let mut subslice = cg_base.project_index(bx,
                             bx.cx().const_usize(*from as u64));
                         let projected_ty = PlaceTy::from_ty(cg_base.layout.ty)
@@ -573,6 +573,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
                         subslice.layout = bx.cx().layout_of(self.monomorphize(&projected_ty));
 
                         if subslice.layout.is_unsized() {
+                            assert!(from_end, "slice subslices should be `from_end`");
                             subslice.llextra = Some(bx.sub(cg_base.llextra.unwrap(),
                                 bx.cx().const_usize((*from as u64) + (*to as u64))));
                         }