[flang-commits] [flang] [flang][nfc] Support volatility in Fir ops (PR #134858)
via flang-commits
flang-commits at lists.llvm.org
Wed Apr 23 01:21:38 PDT 2025
================
@@ -15,13 +15,26 @@
namespace fir {
-/// Return true iff the Operation is a non-volatile LoadOp or ArrayLoadOp.
-inline bool nonVolatileLoad(mlir::Operation *op) {
- if (auto load = mlir::dyn_cast<fir::LoadOp>(op))
- return !load->getAttr("volatile");
- if (auto arrLoad = mlir::dyn_cast<fir::ArrayLoadOp>(op))
- return !arrLoad->getAttr("volatile");
- return false;
+/// The LLVM dialect represents volatile memory accesses as read and write
+/// effects to an unknown memory location, but this may be overly conservative.
+/// LLVM Language Reference only specifies that volatile memory accesses
+/// must not be reordered relative to other volatile memory accesses, so it
+/// is more precise to use a separate memory resource for volatile memory
+/// accesses.
+inline void addVolatileMemoryEffects(
----------------
jeanPerier wrote:
No specific concerns, I just wanted to make sure this was not forgotten and that the `getEffects` of HLFIR opertations would also be updated when relevant.
We do not have a lot of code motion at high level currently, but it will also be important to make sure high level operations referencing volatile memory are not moved without care.
https://github.com/llvm/llvm-project/pull/134858
More information about the flang-commits
mailing list