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.
This commit is contained in:
parent
0405aa0065
commit
a225f0a66b
@ -652,7 +652,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
|
|||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load(&mut self, _ty: Type<'gcc>, ptr: RValue<'gcc>, _align: Align) -> RValue<'gcc> {
|
fn load(&mut self, _pointee_ty: Type<'gcc>, ptr: RValue<'gcc>, _align: Align) -> RValue<'gcc> {
|
||||||
// TODO(antoyo): use ty.
|
// TODO(antoyo): use ty.
|
||||||
let block = self.llbb();
|
let block = self.llbb();
|
||||||
let function = block.get_function();
|
let function = block.get_function();
|
||||||
@ -715,7 +715,11 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
|
|||||||
OperandValue::Ref(place.llval, Some(llextra), place.align)
|
OperandValue::Ref(place.llval, Some(llextra), place.align)
|
||||||
}
|
}
|
||||||
else if place.layout.is_gcc_immediate() {
|
else if place.layout.is_gcc_immediate() {
|
||||||
let load = self.load(place.llval.get_type(), place.llval, place.align);
|
let load = self.load(
|
||||||
|
place.layout.gcc_type(self, false),
|
||||||
|
place.llval,
|
||||||
|
place.align,
|
||||||
|
);
|
||||||
if let abi::Abi::Scalar(ref scalar) = place.layout.abi {
|
if let abi::Abi::Scalar(ref scalar) = place.layout.abi {
|
||||||
scalar_load_metadata(self, load, scalar);
|
scalar_load_metadata(self, load, scalar);
|
||||||
}
|
}
|
||||||
@ -727,7 +731,8 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
|
|||||||
|
|
||||||
let mut load = |i, scalar: &abi::Scalar, align| {
|
let mut load = |i, scalar: &abi::Scalar, align| {
|
||||||
let llptr = self.struct_gep(pair_type, place.llval, i as u64);
|
let llptr = self.struct_gep(pair_type, place.llval, i as u64);
|
||||||
let load = self.load(llptr.get_type(), llptr, align);
|
let llty = place.layout.scalar_pair_element_gcc_type(self, i, false);
|
||||||
|
let load = self.load(llty, llptr, align);
|
||||||
scalar_load_metadata(self, load, scalar);
|
scalar_load_metadata(self, load, scalar);
|
||||||
if scalar.is_bool() { self.trunc(load, self.type_i1()) } else { load }
|
if scalar.is_bool() { self.trunc(load, self.type_i1()) } else { load }
|
||||||
};
|
};
|
||||||
@ -980,7 +985,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
|
|||||||
fn memmove(&mut self, dst: RValue<'gcc>, dst_align: Align, src: RValue<'gcc>, src_align: Align, size: RValue<'gcc>, flags: MemFlags) {
|
fn memmove(&mut self, dst: RValue<'gcc>, dst_align: Align, src: RValue<'gcc>, src_align: Align, size: RValue<'gcc>, flags: MemFlags) {
|
||||||
if flags.contains(MemFlags::NONTEMPORAL) {
|
if flags.contains(MemFlags::NONTEMPORAL) {
|
||||||
// HACK(nox): This is inefficient but there is no nontemporal memmove.
|
// HACK(nox): This is inefficient but there is no nontemporal memmove.
|
||||||
let val = self.load(src.get_type(), src, src_align);
|
let val = self.load(src.get_type().get_pointee().expect("get_pointee"), src, src_align);
|
||||||
let ptr = self.pointercast(dst, self.type_ptr_to(self.val_ty(val)));
|
let ptr = self.pointercast(dst, self.type_ptr_to(self.val_ty(val)));
|
||||||
self.store_with_flags(val, ptr, dst_align, flags);
|
self.store_with_flags(val, ptr, dst_align, flags);
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user