12 Commits

Author SHA1 Message Date
Tom Eccles
6242c8ca18 [flang] add TBAA tags to global and direct variables
These turn out to be useful for spec2017/fotonik3d and safe so long as
they are not used along side TBAA tags for local allocations. LLVM may
be able to figure out local allocations by itself anyway.

PR #68727
2023-10-25 10:47:51 +00:00
Slava Zakharin
f1ea831dbc
[flang][hlfir] Make alias analysis trace through box designators. (#67353)
The changes are needed to get leslie3d same performance with HLFIR
as with FIR lowering. The two module allocatable variables cannot
alias, so the optimized bufferization should be able to elide
the temporary and inline the assignment loop.
2023-09-25 11:27:28 -07:00
Renaud Kauffmann
575a648306
[flang] Follow memory source through more operations (#66713)
Add support for fir.box_addr, fir.array_corr, fir.coordinate, fir.embox,
fir.rebox and fir.load.

1) Through the use of boolean `followBoxAddr` determine whether the
analysis should apply to the address of the box or the address wrapped
by the box.
2) Some asserts have been removed to allow for more SourceKinds though
the flow, in a particular SourceKind::Direct
3) getSource was a public method but the returned type (SourceKind) was
not public making it impossible to be called publicly
4) About 12 tests have been added to check for real Fortran scenarios 
5) More tests will be added with HLFIR
6) A few TODOs have been identified and will need to be addressed in
follow-up patches. I felt that more changes would increase the
complexity of the patch.
2023-09-19 11:10:49 -07:00
Slava Zakharin
10388c74e2
[flang] Fixed -Werror build after #65919. (#66679) 2023-09-18 11:10:07 -07:00
Slava Zakharin
47025af639
[flang][hlfir] Alias analysis for host associated accesses. (#65919)
This patch adds `host_assoc` attribute for operations that implement
FortranVariableInterface (e.g. `hlfir.declare`). The attribute is used
by the alias analysis to make better conclusions about memory overlap.
For example, a dummy argument of an inner subroutine and a host's
variable used inside the inner subroutine cannot refer to the same
object (if the dummy argument does not satisify exceptions in F2018
15.5.2.13).
This closes a performance gap between HLFIR optimization pipeline
and FIR ArrayValueCopy for Polyhedron/nf.
2023-09-18 09:59:06 -07:00
Tom Eccles
c3f060b026 [flang] approximate alias analysis support for hlfir.designate
Add a rough alias analysis rule for hlfir.designate which just follows
the memref argument. This could be extended in the future to take into
account the indices or derived type fields accessed to spot for provably
non-overlapping cases. In the meantime, we need a flag to ensure we
never say "MustAlias" when following a value through a hlfir.designate
because the designate analysis is only approximate.

Differential Revision: https://reviews.llvm.org/D157718
2023-08-14 09:58:20 +00:00
Tom Eccles
6a0a19abf4 [flang] support (hl)fir.declare in alias analysis
Differential Revision: https://reviews.llvm.org/D157106
2023-08-10 14:16:37 +00:00
Tom Eccles
4492ec775c Revert "[flang] support (hl)fir.declare in alias analysis"
Reverting because of buildbot failure

This reverts commit c732a452ea15d4b7b682b35a72f78c1cdc13f60b.
2023-08-08 10:11:23 +00:00
Tom Eccles
c732a452ea [flang] support (hl)fir.declare in alias analysis
Differential Revision: https://reviews.llvm.org/D157106
2023-08-08 09:44:06 +00:00
Tom Eccles
d82a1581d6 [flang][nfc] Add debug prints to FIR alias analysis
These make it easier to debug and improve alias analysis. Enable with
--debug-only=fir-alias-analysis.

Differential Revision: https://reviews.llvm.org/D157105
2023-08-08 09:44:06 +00:00
Slava Zakharin
33a7f162d6 [flang] Added coarse grained alias analysis for FIR.
These are experimental changes in Flang AA to provide
at least some means to disambiguate memory accesses in some
simple cases. This AA is still not used by any transformation,
so the LIT tests are the only way to trigger it currently.
I will further look into applying this AA within Flang
to address some of the known performance issues in the benchmarks.

Credits to @Renaud-K for the initial implementation.

Differential Revision: https://reviews.llvm.org/D141410
2023-01-11 10:25:21 -08:00
Renaud-K
ba65584d15 Alias Analysis infra in Flang
Differential revision: https://reviews.llvm.org/D136889
2022-11-04 13:39:00 -07:00