Skip to content

Commit 7e84472

Browse files
committed
Inserted a local variable in volatile_load, to ensure reads don't move across blocks.
1 parent b7091ec commit 7e84472

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/builder.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,11 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
980980

981981
fn volatile_load(&mut self, ty: Type<'gcc>, ptr: RValue<'gcc>) -> RValue<'gcc> {
982982
let ptr = self.context.new_cast(self.location, ptr, ty.make_volatile().make_pointer());
983-
ptr.dereference(self.location).to_rvalue()
983+
// (FractalFir): We insert a local here, to ensure this volatile load can't move across
984+
// blocks.
985+
let local = self.current_func().new_local(self.location, ty, "volatile_tmp");
986+
self.block.add_assignment(self.location, local, ptr.dereference(self.location).to_rvalue());
987+
local.to_rvalue()
984988
}
985989

986990
fn atomic_load(

0 commit comments

Comments
 (0)