[PATCH] D110928: [fir] add fir.array_modify op

Valentin Clement via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 1 05:57:50 PDT 2021


clementval created this revision.
clementval added reviewers: jeanPerier, svedanayagam, sscalpone, kiranchandramohan, jdoerfert, schweitz, pmccormick, mehdi_amini, rovka, AlexisPerry.
Herald added a project: Flang.
clementval requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

fir.array_update is only handling intrinsic assignments.
They are two big differences with user defined assignments:

1. The LHS and RHS types may not match, this does not play well with fir.array_update that relies on both the merge and the updated element to have the same type.
2. user defined assignment has a call semantics, with potential side effects. So if a fir.array_update can hide a call, it traits would need to be updated.

Instead of hiding more semantic in the fir.array_update, introduce
a new fir.array_modify op that allows de-correlating indicating that
an array value element is modified, and how it is modified.
This allow the ArrayValueCopy pass to still perform copy elision
while not having to implement the call itself, and could in general
be used for all kind of assignments (e.g. character assignment).

Update the alias analysis to not rely on the merge arguments (since
fir.array_modify has none).
Instead, analyze what is done with the element address.
This implies adding the ability to follow the users of fir.array_modify,
as well as being able to go through fir.store that may be generated to
store the RHS value in order to pass it to a user define routine.
This is done by adding a ReachCollector class to gather all array
accesses.

This patch is part of the upstreaming effort from fir-dev branch.

Co-authored-by: Jean Perier <jperier at nvidia.com>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110928

Files:
  flang/include/flang/Optimizer/Dialect/FIROps.td
  flang/lib/Optimizer/Dialect/FIROps.cpp
  flang/test/Fir/fir-ops.fir
  flang/test/Fir/invalid.fir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110928.376495.patch
Type: text/x-patch
Size: 6222 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211001/cb243236/attachment.bin>


More information about the llvm-commits mailing list