[flang-commits] [flang] [flang][rfc] Add represention of volatile references (PR #132486)
via flang-commits
flang-commits at lists.llvm.org
Mon Mar 24 10:14:59 PDT 2025
================
@@ -223,8 +223,37 @@ class HlfirDesignatorBuilder {
designatorNode, getConverter().getFoldingContext(),
/*namedConstantSectionsAreAlwaysContiguous=*/false))
return fir::BoxType::get(resultValueType);
+
+ bool isVolatile = false;
+
+ // Check if the base type is volatile
+ if (partInfo.base.has_value()) {
+ mlir::Type baseType = partInfo.base.value().getType();
+ isVolatile = fir::isa_volatile_ref_type(baseType);
+ }
+
+ auto isVolatileSymbol = [](const Fortran::semantics::Symbol &symbol) {
+ return symbol.GetUltimate().attrs().test(
+ Fortran::semantics::Attr::VOLATILE);
+ };
+
+ // Check if this should be a volatile reference
+ if constexpr (std::is_same_v<std::decay_t<T>,
+ Fortran::evaluate::SymbolRef>) {
+ if (isVolatileSymbol(designatorNode.get()))
+ isVolatile = true;
+ } else if constexpr (std::is_same_v<std::decay_t<T>,
+ Fortran::evaluate::Component>) {
+ if (isVolatileSymbol(designatorNode.GetLastSymbol()))
+ isVolatile = true;
+ }
+
+ // If it's a reference to a ref, account for it
+ if (auto refTy = mlir::dyn_cast<fir::ReferenceType>(resultValueType))
+ resultValueType = refTy.getEleTy();
----------------
jeanPerier wrote:
I do not get that change, do you have an example that would illustrate the motivation?
https://github.com/llvm/llvm-project/pull/132486
More information about the flang-commits
mailing list