Skip to content

Commit

Permalink
Fix load alignment being applied to referenced value
Browse files Browse the repository at this point in the history
  • Loading branch information
sapir committed Aug 5, 2024
1 parent fb95096 commit 418a73b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -948,15 +948,15 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
// NOTE: instead of returning the dereference here, we have to assign it to a variable in
// the current basic block. Otherwise, it could be used in another basic block, causing a
// dereference after a drop, for instance.
let ptr = self.context.new_cast(self.location, ptr, pointee_ty.make_pointer());
let deref = ptr.dereference(self.location).to_rvalue();
// FIXME(antoyo): this check that we don't call get_aligned() a second time on a type.
// Ideally, we shouldn't need to do this check.
let aligned_type = if pointee_ty == self.cx.u128_type || pointee_ty == self.cx.i128_type {
pointee_ty
} else {
pointee_ty.get_aligned(align.bytes())
};
let ptr = self.context.new_cast(self.location, ptr, aligned_type.make_pointer());
let deref = ptr.dereference(self.location).to_rvalue();
let loaded_value = function.new_local(
self.location,
aligned_type,
Expand Down

0 comments on commit 418a73b

Please sign in to comment.