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

Tom Eccles via flang-commits flang-commits at lists.llvm.org
Mon Mar 24 10:56:02 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());
----------------
tblah wrote:

Thanks for the answers everyone.

I meant "unknown memory effects" as in not specifying any at all. This would force passes to be as pessimistic as possible about this operation as they would have no way to reason about it.

However, I now think Slava is right that being maximally pessimistic could be overkill in the long run. Anyway, doing the same as the LLVM dialect is great for this PR.

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


More information about the flang-commits mailing list