[flang-commits] [PATCH] D122467: [flang][lowering] Handle zero extent case in LBOUND

Jean Perier via Phabricator via flang-commits flang-commits at lists.llvm.org
Fri Mar 25 02:25:19 PDT 2022


jeanPerier created this revision.
jeanPerier added reviewers: clementval, schweitz.
jeanPerier added a project: Flang.
Herald added subscribers: mehdi_amini, jdoerfert.
Herald added a project: All.
jeanPerier requested review of this revision.

Follow up of https://reviews.llvm.org/D121488. Ensure lower bounds
are `1` when the related dimension extent is zero. Note that lower
bounds from descriptors are now guaranteed to fulfill this property
after the runtime/codegen patches.

Also fixes explicit shape array extent lowering when instantiating
variables to deal with negative extent cases (issue found while testing
LBOUND edge case). This notably caused allocation crashes when dealing
with automatic arrays with reversed bounds or negative size
specification expression. The standard specifies that the extent of such
arrays is zero. This change has some ripple effect in the current lit
tests.

Add move two helpers as part of this change:

- Add a helper to tell if a fir::ExtendedValue describes an assumed size array (last dimension extent is unknown to the compiler, both at compile time and runtime).

- Move and share getIntIfConstant from Character.cpp so that it can be used elsewhere (NFC).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122467

Files:
  flang/include/flang/Optimizer/Builder/BoxValue.h
  flang/include/flang/Optimizer/Builder/FIRBuilder.h
  flang/lib/Lower/ConvertVariable.cpp
  flang/lib/Lower/IntrinsicCall.cpp
  flang/lib/Optimizer/Builder/BoxValue.cpp
  flang/lib/Optimizer/Builder/Character.cpp
  flang/lib/Optimizer/Builder/FIRBuilder.cpp
  flang/test/Lower/array-expression.f90
  flang/test/Lower/call-parenthesized-arg.f90
  flang/test/Lower/character-local-variables.f90
  flang/test/Lower/forall/test9.f90

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122467.418162.patch
Type: text/x-patch
Size: 22860 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220325/702d346e/attachment-0001.bin>


More information about the flang-commits mailing list