diff options
| author | bors <bors@rust-lang.org> | 2023-05-07 05:20:29 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-05-07 05:20:29 +0000 |
| commit | 8cc75b56a67ab33407b43faa0efc0f6483ff5664 (patch) | |
| tree | fead80264db3a06644bf70fb262f1a546c7b0c49 /compiler/rustc_codegen_ssa/src | |
| parent | 70a779cb7d827c0007dde1751d272bfdb58dded5 (diff) | |
| parent | 8372eaee0b0f613a008df0102098e925ac0f5830 (diff) | |
| download | rust-8cc75b56a67ab33407b43faa0efc0f6483ff5664.tar.gz rust-8cc75b56a67ab33407b43faa0efc0f6483ff5664.zip | |
Auto merge of #111311 - JohnTitor:rollup-vfpjm0d, r=JohnTitor
Rollup of 7 pull requests Successful merges: - #105583 (Operand::extract_field: only cast llval if it's a pointer and replace bitcast w/ pointercast.) - #110094 (clean up `transmute`s in `core`) - #111150 (added TraitAlias to check_item() for missing_docs) - #111293 (rustc --explain E0726 - grammar fixing (it's => its + add a `the` where it felt right to do so)) - #111300 (Emit while_true lint spanning the entire loop condition) - #111301 (Remove calls to `mem::forget` and `mem::replace` in `Option::get_or_insert_with`.) - #111303 (update Rust Unstable Book docs for `--extern force`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/mir/operand.rs | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/compiler/rustc_codegen_ssa/src/mir/operand.rs b/compiler/rustc_codegen_ssa/src/mir/operand.rs index b37797fef4c..9efbb34b515 100644 --- a/compiler/rustc_codegen_ssa/src/mir/operand.rs +++ b/compiler/rustc_codegen_ssa/src/mir/operand.rs @@ -2,6 +2,7 @@ use super::place::PlaceRef; use super::{FunctionCx, LocalRef}; use crate::base; +use crate::common::TypeKind; use crate::glue; use crate::traits::*; use crate::MemFlags; @@ -236,19 +237,47 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> { }; match (&mut val, field.abi) { - (OperandValue::Immediate(llval), _) => { + ( + OperandValue::Immediate(llval), + Abi::Scalar(_) | Abi::ScalarPair(..) | Abi::Vector { .. }, + ) => { // Bools in union fields needs to be truncated. *llval = bx.to_immediate(*llval, field); // HACK(eddyb) have to bitcast pointers until LLVM removes pointee types. - *llval = bx.bitcast(*llval, bx.cx().immediate_backend_type(field)); + let ty = bx.cx().immediate_backend_type(field); + if bx.type_kind(ty) == TypeKind::Pointer { + *llval = bx.pointercast(*llval, ty); + } } (OperandValue::Pair(a, b), Abi::ScalarPair(a_abi, b_abi)) => { // Bools in union fields needs to be truncated. *a = bx.to_immediate_scalar(*a, a_abi); *b = bx.to_immediate_scalar(*b, b_abi); // HACK(eddyb) have to bitcast pointers until LLVM removes pointee types. - *a = bx.bitcast(*a, bx.cx().scalar_pair_element_backend_type(field, 0, true)); - *b = bx.bitcast(*b, bx.cx().scalar_pair_element_backend_type(field, 1, true)); + let a_ty = bx.cx().scalar_pair_element_backend_type(field, 0, true); + let b_ty = bx.cx().scalar_pair_element_backend_type(field, 1, true); + if bx.type_kind(a_ty) == TypeKind::Pointer { + *a = bx.pointercast(*a, a_ty); + } + if bx.type_kind(b_ty) == TypeKind::Pointer { + *b = bx.pointercast(*b, b_ty); + } + } + // Newtype vector of array, e.g. #[repr(simd)] struct S([i32; 4]); + (OperandValue::Immediate(llval), Abi::Aggregate { sized: true }) => { + assert!(matches!(self.layout.abi, Abi::Vector { .. })); + + let llty = bx.cx().backend_type(self.layout); + let llfield_ty = bx.cx().backend_type(field); + + // Can't bitcast an aggregate, so round trip through memory. + let lltemp = bx.alloca(llfield_ty, field.align.abi); + let llptr = bx.pointercast(lltemp, bx.cx().type_ptr_to(llty)); + bx.store(*llval, llptr, field.align.abi); + *llval = bx.load(llfield_ty, lltemp, field.align.abi); + } + (OperandValue::Immediate(_), Abi::Uninhabited | Abi::Aggregate { sized: false }) => { + bug!() } (OperandValue::Pair(..), _) => bug!(), (OperandValue::Ref(..), _) => bug!(), |
