diff options
| author | antoyo <antoyo@users.noreply.github.com> | 2025-07-09 17:11:30 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-09 17:11:30 -0400 |
| commit | 8a9af5f7ef94a67dceb042d90ddc5d0fcd60c930 (patch) | |
| tree | 119ff8c1fc70b41a970d8836ba55848243d9f092 | |
| parent | 35bdf8b4e22a787929686f5078d221d214764a25 (diff) | |
| parent | 7e844720bdedc7b8bb4ed1d5414e557d7358e7df (diff) | |
| download | rust-8a9af5f7ef94a67dceb042d90ddc5d0fcd60c930.tar.gz rust-8a9af5f7ef94a67dceb042d90ddc5d0fcd60c930.zip | |
Merge pull request #733 from FractalFir/volatile_load_tmp
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 b1785af444a..1f3d3a3d5c8 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -975,7 +975,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( |
