jit: Fix volatile loads and stores
Related to PR d/110516 but for libgccjit.
2024-01-03 Martin Rodriguez Reboredo <yakoyoku@gmail.com>
gcc/jit/
* jit-playback.cc: Append TREE_THIS_VOLATILE and TREE_SIDE_EFFECTS to
a dereference if underlying type is volatile.
Signed-off-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc
index 231b8bc..e487822 100644
--- a/gcc/jit/jit-playback.cc
+++ b/gcc/jit/jit-playback.cc
@@ -1981,6 +1981,10 @@
tree datum = fold_build1 (INDIRECT_REF, type, ptr);
if (loc)
set_tree_location (datum, loc);
+ if (TYPE_VOLATILE (type)) {
+ TREE_THIS_VOLATILE (datum) = 1;
+ TREE_SIDE_EFFECTS (datum) = 1;
+ }
return datum;
}