diff options
| author | Erik Desjardins <erikdesjardins@users.noreply.github.com> | 2020-08-20 18:59:52 -0400 |
|---|---|---|
| committer | Erik Desjardins <erikdesjardins@users.noreply.github.com> | 2020-08-30 14:58:03 -0400 |
| commit | 24e0913e37cc6fc363b37d13bf519db212f175a2 (patch) | |
| tree | 822e4cafc7346bc9497c1b2025195a48590107bd /compiler/rustc_codegen_ssa/src/mir/place.rs | |
| parent | 6fc1d8bc13124bb134d7ab54e56237821a55912e (diff) | |
| download | rust-24e0913e37cc6fc363b37d13bf519db212f175a2.tar.gz rust-24e0913e37cc6fc363b37d13bf519db212f175a2.zip | |
handle vector layout
Diffstat (limited to 'compiler/rustc_codegen_ssa/src/mir/place.rs')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/mir/place.rs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/compiler/rustc_codegen_ssa/src/mir/place.rs b/compiler/rustc_codegen_ssa/src/mir/place.rs index 7c0eddea522..799f3b3a575 100644 --- a/compiler/rustc_codegen_ssa/src/mir/place.rs +++ b/compiler/rustc_codegen_ssa/src/mir/place.rs @@ -96,7 +96,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> { let llval = match self.layout.abi { _ if offset.bytes() == 0 => { // Unions and newtypes only use an offset of 0. - // Also handles the first field of Scalar and ScalarPair layouts. + // Also handles the first field of Scalar, ScalarPair, and Vector layouts. self.llval } Abi::ScalarPair(ref a, ref b) @@ -105,16 +105,20 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> { // Offset matches second field. bx.struct_gep(self.llval, 1) } - Abi::ScalarPair(..) | Abi::Scalar(_) => { - // ZST fields are not included in Scalar and ScalarPair layouts, so manually offset the pointer. - assert!( - field.is_zst(), - "non-ZST field offset does not match layout: {:?}", - field - ); + Abi::Scalar(_) | Abi::ScalarPair(..) | Abi::Vector { .. } if field.is_zst() => { + // ZST fields are not included in Scalar, ScalarPair, and Vector layouts, so manually offset the pointer. let byte_ptr = bx.pointercast(self.llval, bx.cx().type_i8p()); bx.gep(byte_ptr, &[bx.const_usize(offset.bytes())]) } + Abi::Scalar(_) | Abi::ScalarPair(..) => { + // All fields of Scalar and ScalarPair layouts must have been handled by this point. + // Vector layouts have additional fields for each element of the vector, so don't panic in that case. + bug!( + "offset of non-ZST field `{:?}` does not match layout `{:#?}`", + field, + self.layout + ); + } _ => bx.struct_gep(self.llval, bx.cx().backend_field_index(self.layout, ix)), }; PlaceRef { |
