Skip to content

Commit 418a73b

Browse files
committed
Fix load alignment being applied to referenced value
1 parent fb95096 commit 418a73b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/builder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -948,15 +948,15 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
948948
// NOTE: instead of returning the dereference here, we have to assign it to a variable in
949949
// the current basic block. Otherwise, it could be used in another basic block, causing a
950950
// dereference after a drop, for instance.
951+
let ptr = self.context.new_cast(self.location, ptr, pointee_ty.make_pointer());
952+
let deref = ptr.dereference(self.location).to_rvalue();
951953
// FIXME(antoyo): this check that we don't call get_aligned() a second time on a type.
952954
// Ideally, we shouldn't need to do this check.
953955
let aligned_type = if pointee_ty == self.cx.u128_type || pointee_ty == self.cx.i128_type {
954956
pointee_ty
955957
} else {
956958
pointee_ty.get_aligned(align.bytes())
957959
};
958-
let ptr = self.context.new_cast(self.location, ptr, aligned_type.make_pointer());
959-
let deref = ptr.dereference(self.location).to_rvalue();
960960
let loaded_value = function.new_local(
961961
self.location,
962962
aligned_type,

0 commit comments

Comments
 (0)