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

Slava Zakharin via flang-commits flang-commits at lists.llvm.org
Mon Mar 31 20:00:09 PDT 2025


================
@@ -672,17 +683,18 @@ mlir::Value fir::FirOpBuilder::createBox(mlir::Location loc,
         << itemAddr.getType();
     llvm_unreachable("not a memory reference type");
   }
+  const bool isVolatile = fir::isa_volatile_type(itemAddr.getType());
   mlir::Type boxTy;
   mlir::Value tdesc;
   // Avoid to wrap a box/class with box/class.
   if (mlir::isa<fir::BaseBoxType>(elementType)) {
     boxTy = elementType;
   } else {
-    boxTy = fir::BoxType::get(elementType);
+    boxTy = fir::BoxType::get(elementType, isVolatile);
     if (isPolymorphic) {
       elementType = fir::updateTypeForUnlimitedPolymorphic(elementType);
       if (isAssumedType)
-        boxTy = fir::BoxType::get(elementType);
+        boxTy = fir::BoxType::get(elementType, isVolatile);
       else
         boxTy = fir::ClassType::get(elementType);
----------------
vzakhari wrote:

Not in this PR, but we probably have to add volatile support for `!fir.class` as well.

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


More information about the flang-commits mailing list