[flang-commits] [flang] [flang] Fix volatile attribute propagation on allocatables (PR #139183)
via flang-commits
flang-commits at lists.llvm.org
Fri May 9 00:53:05 PDT 2025
================
@@ -207,20 +207,25 @@ static bool hasExplicitLowerBounds(mlir::Value shape) {
mlir::isa<fir::ShapeShiftType, fir::ShiftType>(shape.getType());
}
-static std::pair<mlir::Type, mlir::Value> updateDeclareInputTypeWithVolatility(
+static std::pair<mlir::Type, mlir::Value> updateDeclaredInputTypeWithVolatility(
mlir::Type inputType, mlir::Value memref, mlir::OpBuilder &builder,
fir::FortranVariableFlagsAttr fortran_attrs) {
if (fortran_attrs &&
bitEnumContainsAny(fortran_attrs.getFlags(),
fir::FortranVariableFlagsEnum::fortran_volatile)) {
+ // A volatile pointer's pointee is volatile.
const bool isPointer = bitEnumContainsAny(
fortran_attrs.getFlags(), fir::FortranVariableFlagsEnum::pointer);
+ // An allocatable's inner type's volatility matches that of the reference.
+ const bool isAllocatable = bitEnumContainsAny(
+ fortran_attrs.getFlags(), fir::FortranVariableFlagsEnum::allocatable);
auto updateType = [&](auto t) {
using FIRT = decltype(t);
- // A volatile pointer's pointee is volatile.
auto elementType = t.getEleTy();
- const bool elementTypeIsVolatile =
- isPointer || fir::isa_volatile_type(elementType);
+ const bool elementTypeIsBox = mlir::isa<fir::BoxType>(elementType);
----------------
jeanPerier wrote:
Shouldn't this be `mlir::isa<fir::BaseBoxType>` to cover the fir.class case?
https://github.com/llvm/llvm-project/pull/139183
More information about the flang-commits
mailing list