[flang-commits] [PATCH] D113309: [flang] Don't reference non-invariant symbols in shape expressions

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Fri Nov 5 12:31:30 PDT 2021


klausler created this revision.
klausler added a reviewer: jeanPerier.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a reviewer: sscalpone.
klausler requested review of this revision.

When an array's shape involves references to symbols that are not
invariant in a scope -- the classic example being a dummy array
with an explicit shape involving other dummy arguments -- the
compiler was creating shape expressions that referenced those
symbols.  This might be valid if those symbols are somehow
captured and copied at each entry point to a subprogram, and
the copies referenced in the shapes instead, but that's not
the case.

This patch introduces a new expression predicate IsScopeInvariantExpr(),
which defines a class of expressions that contains constant expressions
(in the sense that the standard uses that term) as well as references
to items that may be safely accessed in a context-free way throughout
their scopes.   This includes dummy arguments that are INTENT(IN)
and not VALUE, descriptor inquiries into descriptors that cannot
change, and bare LEN type parameters within the definitions of
derived types.  The new predicate is then used in shape analysis
to winnow out results that would have otherwise been contextual.


https://reviews.llvm.org/D113309

Files:
  flang/include/flang/Evaluate/check-expression.h
  flang/lib/Evaluate/check-expression.cpp
  flang/lib/Evaluate/shape.cpp
  flang/test/Semantics/modfile33.f90
  flang/test/Semantics/offsets01.f90

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113309.385154.patch
Type: text/x-patch
Size: 11394 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20211105/4a3a4cdc/attachment-0001.bin>


More information about the flang-commits mailing list