[flang-commits] [flang] [flang][rfc] Add represention of volatile references (PR #132486)

via flang-commits flang-commits at lists.llvm.org
Mon Mar 24 08:09:37 PDT 2025


================
@@ -37,6 +37,15 @@ namespace {
 #include "flang/Optimizer/Dialect/CanonicalizationPatterns.inc"
 } // namespace
 
+static void addVolatileMemoryEffects(
+    mlir::Type type, llvm::SmallVectorImpl<mlir::SideEffects::EffectInstance<
+                         mlir::MemoryEffects::Effect>> &effects) {
+  if (fir::isa_volatile_ref_type(type)) {
+    effects.emplace_back(mlir::MemoryEffects::Read::get());
+    effects.emplace_back(mlir::MemoryEffects::Write::get());
----------------
jeanPerier wrote:

There is a precedent with  the LLVM dialect: https://github.com/llvm/llvm-project/commit/feb7beaf70bace1c3ffafc7f732c8fadca5e8c9d

It cites LLVM documentation that mentions Volatile read are considered to can have any read/write effects:
See https://llvm.org/docs/LangRef.html#volatile-memory-accesses

https://github.com/llvm/llvm-project/pull/132486


More information about the flang-commits mailing list