Skip to content

Commit 8a9af5f

Browse files
authored
Merge pull request #733 from FractalFir/volatile_load_tmp
Inserted a local variable in volatile_load, to ensure reads don't move across blocks.
2 parents 35bdf8b + 7e84472 commit 8a9af5f

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
@@ -975,7 +975,11 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
975975

976976
fn volatile_load(&mut self, ty: Type<'gcc>, ptr: RValue<'gcc>) -> RValue<'gcc> {
977977
let ptr = self.context.new_cast(self.location, ptr, ty.make_volatile().make_pointer());
978-
ptr.dereference(self.location).to_rvalue()
978+
// (FractalFir): We insert a local here, to ensure this volatile load can't move across
979+
// blocks.
980+
let local = self.current_func().new_local(self.location, ty, "volatile_tmp");
981+
self.block.add_assignment(self.location, local, ptr.dereference(self.location).to_rvalue());
982+
local.to_rvalue()
979983
}
980984

981985
fn atomic_load(

0 commit comments

Comments
 (0)