Skip to content

Commit a225f0a

Browse files
committed
Pass a pointee type to <Builder as BuilderMethods>::load when calling it ourselves
The parameter name isn't very descriptive, but it actually supposed to take a pointee type. When calling it ourselves, we've been passing a *pointer* type, which made it impossible to make any meaningful uses of this parameter in the method implementation. This commit intends to rectify that.
1 parent 0405aa0 commit a225f0a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/builder.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
652652
unimplemented!();
653653
}
654654

655-
fn load(&mut self, _ty: Type<'gcc>, ptr: RValue<'gcc>, _align: Align) -> RValue<'gcc> {
655+
fn load(&mut self, _pointee_ty: Type<'gcc>, ptr: RValue<'gcc>, _align: Align) -> RValue<'gcc> {
656656
// TODO(antoyo): use ty.
657657
let block = self.llbb();
658658
let function = block.get_function();
@@ -715,7 +715,11 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
715715
OperandValue::Ref(place.llval, Some(llextra), place.align)
716716
}
717717
else if place.layout.is_gcc_immediate() {
718-
let load = self.load(place.llval.get_type(), place.llval, place.align);
718+
let load = self.load(
719+
place.layout.gcc_type(self, false),
720+
place.llval,
721+
place.align,
722+
);
719723
if let abi::Abi::Scalar(ref scalar) = place.layout.abi {
720724
scalar_load_metadata(self, load, scalar);
721725
}
@@ -727,7 +731,8 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
727731

728732
let mut load = |i, scalar: &abi::Scalar, align| {
729733
let llptr = self.struct_gep(pair_type, place.llval, i as u64);
730-
let load = self.load(llptr.get_type(), llptr, align);
734+
let llty = place.layout.scalar_pair_element_gcc_type(self, i, false);
735+
let load = self.load(llty, llptr, align);
731736
scalar_load_metadata(self, load, scalar);
732737
if scalar.is_bool() { self.trunc(load, self.type_i1()) } else { load }
733738
};
@@ -980,7 +985,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
980985
fn memmove(&mut self, dst: RValue<'gcc>, dst_align: Align, src: RValue<'gcc>, src_align: Align, size: RValue<'gcc>, flags: MemFlags) {
981986
if flags.contains(MemFlags::NONTEMPORAL) {
982987
// HACK(nox): This is inefficient but there is no nontemporal memmove.
983-
let val = self.load(src.get_type(), src, src_align);
988+
let val = self.load(src.get_type().get_pointee().expect("get_pointee"), src, src_align);
984989
let ptr = self.pointercast(dst, self.type_ptr_to(self.val_ty(val)));
985990
self.store_with_flags(val, ptr, dst_align, flags);
986991
return;

0 commit comments

Comments
 (0)