[flang-commits] [PATCH] D104385: [flang] preserve symbol in DescriptorInquiry

Jean Perier via Phabricator via flang-commits flang-commits at lists.llvm.org
Wed Jun 16 07:48:00 PDT 2021


jeanPerier created this revision.
jeanPerier added reviewers: klausler, PeteSteinfeld.
jeanPerier added a project: Flang.
Herald added a subscriber: jdoerfert.
jeanPerier requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, sstefan1.
Herald added a project: LLVM.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104385

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


Index: flang/lib/Evaluate/variable.cpp
===================================================================
--- flang/lib/Evaluate/variable.cpp
+++ flang/lib/Evaluate/variable.cpp
@@ -269,7 +269,7 @@
       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;
Index: flang/lib/Evaluate/shape.cpp
===================================================================
--- flang/lib/Evaluate/shape.cpp
+++ flang/lib/Evaluate/shape.cpp
@@ -490,16 +490,10 @@
           [&](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 {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104385.352433.patch
Type: text/x-patch
Size: 1351 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20210616/d3c0e909/attachment.bin>


More information about the flang-commits mailing list