[flang-commits] [flang] 1a4af2e - [flang] preserve symbol in DescriptorInquiry

Jean Perier via flang-commits flang-commits at lists.llvm.org
Thu Jun 17 03:42:42 PDT 2021


Author: Jean Perier
Date: 2021-06-17T12:42:08+02:00
New Revision: 1a4af2e45ee59cff3d577986b9b7f3f5bd5ab01f

URL: https://github.com/llvm/llvm-project/commit/1a4af2e45ee59cff3d577986b9b7f3f5bd5ab01f
DIFF: https://github.com/llvm/llvm-project/commit/1a4af2e45ee59cff3d577986b9b7f3f5bd5ab01f.diff

LOG: [flang] preserve symbol in DescriptorInquiry

Do not use ultimate symbols in DescriptorInquiry. Using the ultimate
symbol may lead to issues later for at least two reasons:

- The original symbols may have volatile/asynchronous attributes that
  the ultimate may not have. Later phases working on the DescriptorInquiry
  would then not apply potential care required by these attributes.
- HostAssociatedDetails symbols are used by OpenMP for symbols with
  special OpenMP attributes inside OpenMP region (e.g variables with
  private attribute), so it is very important to preserve this
  aspect in the DescriptorInquiry, that would otherwise apply on the
  symbol outside of the region.

Differential Revision: https://reviews.llvm.org/D104385

Added: 
    

Modified: 
    flang/lib/Evaluate/shape.cpp
    flang/lib/Evaluate/variable.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Evaluate/shape.cpp b/flang/lib/Evaluate/shape.cpp
index a1b48135235fa..988d11e92051c 100644
--- a/flang/lib/Evaluate/shape.cpp
+++ b/flang/lib/Evaluate/shape.cpp
@@ -514,16 +514,10 @@ auto GetShapeHelper::operator()(const Symbol &symbol) const -> Result {
           [&](const semantics::ProcBindingDetails &binding) {
             return (*this)(binding.symbol());
           },
-          [&](const semantics::UseDetails &use) {
-            return (*this)(use.symbol());
-          },
-          [&](const semantics::HostAssocDetails &assoc) {
-            return (*this)(assoc.symbol());
-          },
           [](const semantics::TypeParamDetails &) { return ScalarShape(); },
           [](const auto &) { return Result{}; },
       },
-      symbol.details());
+      symbol.GetUltimate().details());
 }
 
 auto GetShapeHelper::operator()(const Component &component) const -> Result {

diff  --git a/flang/lib/Evaluate/variable.cpp b/flang/lib/Evaluate/variable.cpp
index 2f8f887a59c7e..6b5f4caeb884b 100644
--- a/flang/lib/Evaluate/variable.cpp
+++ b/flang/lib/Evaluate/variable.cpp
@@ -269,7 +269,7 @@ static std::optional<Expr<SubscriptInteger>> SymbolLEN(const Symbol &symbol) {
       return len;
     } else if (IsDescriptor(ultimate) && !ultimate.owner().IsDerivedType()) {
       return Expr<SubscriptInteger>{DescriptorInquiry{
-          NamedEntity{ultimate}, DescriptorInquiry::Field::Len}};
+          NamedEntity{symbol}, DescriptorInquiry::Field::Len}};
     }
   }
   return std::nullopt;


        


More information about the flang-commits mailing list