[flang-commits] [PATCH] D133857: [flang] Limit shape inquiries rewrite to associate construct entity

Jean Perier via Phabricator via flang-commits flang-commits at lists.llvm.org
Wed Sep 14 06:26:58 PDT 2022


jeanPerier created this revision.
jeanPerier added reviewers: klausler, vdonaldson, PeteSteinfeld.
jeanPerier added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
jeanPerier requested review of this revision.

The previous code was rewriting all shape inquires on associate
construct entities to inquires on the associated expression or variable.

This is is incorrect because at the point of inquiry, some statement
between the association and the inquiry may have modified the expression
operands or variable in a way that changes its shapes or bounds.

For instance, in the example below, expression rewrites was previously
replacing `size(x, 1)` by `size(p, 1)` which is invalid if p is a
pointer.

  associate(x => p + 1)
   call call_that_may_modify_p_shape()
   print *, size(x, 1)
  end associate

This change restricts rewrites of shape inquiries on associate construct entity
to use the associated expression shape and bounds if and only if the
shape/bounds are compile time constant. Otherwise, this may be invalid.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133857

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133857.460065.patch
Type: text/x-patch
Size: 7700 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220914/777f4327/attachment.bin>


More information about the flang-commits mailing list