diff options
| author | FractalFir <fractalfirdev@gmail.com> | 2025-07-08 23:00:40 +0200 |
|---|---|---|
| committer | FractalFir <fractalfirdev@gmail.com> | 2025-07-09 20:50:08 +0200 |
| commit | 7e844720bdedc7b8bb4ed1d5414e557d7358e7df (patch) | |
| tree | 115a4c101bbbdde71426bc28da26b601b8549d6b | |
| parent | b7091eca6d8eb0fe88b58cc9a7aec405d8de5b85 (diff) | |
| download | rust-7e844720bdedc7b8bb4ed1d5414e557d7358e7df.tar.gz rust-7e844720bdedc7b8bb4ed1d5414e557d7358e7df.zip | |
Inserted a local variable in volatile_load, to ensure reads don't move across blocks.
| -rw-r--r-- | src/builder.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/builder.rs b/src/builder.rs index 100091692ba..e65eea6d599 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -980,7 +980,11 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> { fn volatile_load(&mut self, ty: Type<'gcc>, ptr: RValue<'gcc>) -> RValue<'gcc> { let ptr = self.context.new_cast(self.location, ptr, ty.make_volatile().make_pointer()); - ptr.dereference(self.location).to_rvalue() + // (FractalFir): We insert a local here, to ensure this volatile load can't move across + // blocks. + let local = self.current_func().new_local(self.location, ty, "volatile_tmp"); + self.block.add_assignment(self.location, local, ptr.dereference(self.location).to_rvalue()); + local.to_rvalue() } fn atomic_load( |
