5 Commits

Author SHA1 Message Date
Jean Perier
0446bfcc5c [flang][hlfir] Codegen of hlfir.region_assign where LHS conflicts
When the analysis of hlfir.region_assign determined that the LHS region
evaluation may be impacted by the assignment effects, all LHS must be
fully evaluated and saved before any assignment is done.

This patch adds TemporaryStorage variants to save address, including
vector subscripted entities addresses whose shape must be saved.
It uses the DescriptorStack runtime to deal with complex cases inside
forall. For the sake of simplicity, this is also used for vector
subscripted LHS outside of foralls (each element address is saved as
a descriptor on this stack. This is a bit suboptimal, but it is a safe
start that will work with all kinds of type (polymorphic, PDTs...)
without further work). Another approach would be to saved only the
values that are conflicting in the LHS computation, but this would
require a much more complex analysis of the LHS region DAG.

Differential Revision: https://reviews.llvm.org/D154057
2023-06-30 09:20:52 +02:00
Jean Perier
b361e1c025 [flang][hlfir] address post-commit comments from D151247 and D151251
Addresses comments not addressed in https://reviews.llvm.org/D151251
and https://reviews.llvm.org/D151247

- Fix typo in comments.
- Update an expected test output to include the fir.allocmem argument.
- Make a more generic type comparisons and cast when fetching value
  back from the AnyValueStack temporary storage.

Differential Revision: https://reviews.llvm.org/D151428
2023-05-25 16:34:54 +02:00
Jean Perier
f3c3f63672 [flang][hlfir] Generate temporary storage in Forall/Where [2/2]
Generate temporary storage inside WHERE and FORALL using the temporary
stack runtime. This covers all cases outside of LHS temporary, where the
descriptor stack will have to be used.

Reviewed By: vzakhari

Differential Revision: https://reviews.llvm.org/D151251
2023-05-25 11:56:29 +02:00
Jean Perier
d7578116b8 [flang][hlfir] Generate temporary storage in Forall/Where [1/2]
Generate temporary storage inline inside WHERE and FORALL when possible.
A following patch will use the runtime to cover the generic cases.

Reviewed By: vzakhari

Differential Revision: https://reviews.llvm.org/D151247
2023-05-25 11:51:32 +02:00
Jean Perier
9ac452b286 [flang][NFC] Move Array constructor inlined temp management into a utility
This patch moves the counter and storage management part of the array
constructor inlined temporary strategy into its own utility so that it
can be reused for the simple cases of temporary creations inside WHERE
and FORALL.

It actually fixes a bug where the counter first value  used for addressing
was "2" leading to read/write after the allocated storage... It seems
I ran the tests end-to-end without the HLFIR flag when previously testing
this. So this may clear some segfaults.

Differential Revision: https://reviews.llvm.org/D151106
2023-05-23 17:00:31 +02:00