[all-commits] [llvm/llvm-project] e7b8e1: [flang] Set SAVE attribute for EQUIVALENCEd symbol...
Slava Zakharin via All-commits
all-commits at lists.llvm.org
Mon Sep 25 09:35:27 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: e7b8e18fc359c0de380e89b27898d18913ca9c50
https://github.com/llvm/llvm-project/commit/e7b8e18fc359c0de380e89b27898d18913ca9c50
Author: Slava Zakharin <szakharin at nvidia.com>
Date: 2023-09-25 (Mon, 25 Sep 2023)
Changed paths:
M flang/lib/Lower/HostAssociations.cpp
M flang/lib/Semantics/resolve-names-utils.cpp
M flang/lib/Semantics/resolve-names.cpp
A flang/test/Lower/equivalence-with-host-assoc.f90
M flang/test/Semantics/data13.f90
M flang/test/Semantics/offsets03.f90
A flang/test/Semantics/resolve121.f90
Log Message:
-----------
[flang] Set SAVE attribute for EQUIVALENCEd symbols consistently. (#67078)
Example:
```
subroutine global_sub()
integer, dimension(4) :: iarr4=(/1,2,3,4/)
integer, dimension(4) :: jarr4
equivalence(iarr4,jarr4)
call sub1
print *, iarr4
contains
subroutine sub1
iarr4=jarr4((/4:1:-1/))
end subroutine sub1
end subroutine global_sub
```
`iarr4` and `jarr4` are equivalenced via a global aggregate storage,
but the references inside `sub1` are lowered differently.
`iarr4` is accessed via the global aggregate storage, while `jarr4`
is accessed via the argument tuple. This confuses the FIR alias
analysis,
that claims that a host associated entity cannot alias with a global
(if they have different source and do not have Target/Pointer
attributes deduced by the alias analysis).
I am not convinced that there is an issue in the alias analysis yet.
I think we'd better lower the accesses uniformly, i.e. if one variable
from an equivalence is lowered via the global aggregate storage, then
any other variable from this equivalence should be lowered the same way
(even if they are used via host association).
This patch makes sure that all symbols from an EQUIVALENCE get
and implicit SAVE attribute, if they do not have it already and
any symbol from the EQUIVALENCE is SAVEd (explicitly or implicitly).
This makes the further lowering consistent.
More information about the All-commits
mailing list