[flang-commits] [flang] [flang][nfc] Support volatile on ref, box, and class types (PR #134386)

Tom Eccles via flang-commits flang-commits at lists.llvm.org
Mon Apr 7 03:19:13 PDT 2025


================
@@ -215,6 +230,19 @@ mlir::Type getDerivedType(mlir::Type ty) {
       .Default([](mlir::Type t) { return t; });
 }
 
+mlir::Type updateTypeWithVolatility(mlir::Type type, bool isVolatile) {
+  // If we already have the volatility we asked for, return the type unchanged.
+  if (fir::isa_volatile_type(type) == isVolatile)
+    return type;
+  return mlir::TypeSwitch<mlir::Type, mlir::Type>(type)
+      .Case<fir::BoxType, fir::ClassType, fir::ReferenceType>(
+          [&](auto ty) -> mlir::Type {
+            using TYPE = decltype(ty);
+            return TYPE::get(ty.getEleTy(), isVolatile);
+          })
+      .Default([&](mlir::Type t) -> mlir::Type { return t; });
----------------
tblah wrote:

nit: perhaps the default case should trigger an assertion?

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


More information about the flang-commits mailing list