diff options
| author | Scott McMurray <scottmcm@users.noreply.github.com> | 2025-02-15 16:07:18 -0800 |
|---|---|---|
| committer | Scott McMurray <scottmcm@users.noreply.github.com> | 2025-02-19 12:03:40 -0800 |
| commit | 6f9cfd694d67ad24af6c7e2235a2da5d22918df0 (patch) | |
| tree | 476873c2bb132949bdfc0178229f4dfb753666c6 /compiler/rustc_codegen_llvm/src/builder.rs | |
| parent | 642a705f714eaa73875b9bc9e7848568efc4b890 (diff) | |
| download | rust-6f9cfd694d67ad24af6c7e2235a2da5d22918df0.tar.gz rust-6f9cfd694d67ad24af6c7e2235a2da5d22918df0.zip | |
Rework `OperandRef::extract_field` to stop calling `to_immediate_scalar` on things which are already immediates
That means it stops trying to truncate things that are already `i1`s.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/builder.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/builder.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs index 5d1a133e808..e1609e31c07 100644 --- a/compiler/rustc_codegen_llvm/src/builder.rs +++ b/compiler/rustc_codegen_llvm/src/builder.rs @@ -746,10 +746,12 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { let load = self.load(llty, place.val.llval, place.val.align); if let abi::BackendRepr::Scalar(scalar) = place.layout.backend_repr { scalar_load_metadata(self, load, scalar, place.layout, Size::ZERO); + self.to_immediate_scalar(load, scalar) + } else { + load } - load }); - OperandValue::Immediate(self.to_immediate(llval, place.layout)) + OperandValue::Immediate(llval) } else if let abi::BackendRepr::ScalarPair(a, b) = place.layout.backend_repr { let b_offset = a.size(self).align_to(b.align(self).abi); @@ -943,6 +945,8 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { } fn unchecked_utrunc(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { + debug_assert_ne!(self.val_ty(val), dest_ty); + let trunc = self.trunc(val, dest_ty); if llvm_util::get_version() >= (19, 0, 0) { unsafe { @@ -955,6 +959,8 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { } fn unchecked_strunc(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { + debug_assert_ne!(self.val_ty(val), dest_ty); + let trunc = self.trunc(val, dest_ty); if llvm_util::get_version() >= (19, 0, 0) { unsafe { |
