llvm-project
82c036e2 - [flang] Restructured TBAA trees in AddAliasTags pass. (#136725)

Commit
191 days ago
[flang] Restructured TBAA trees in AddAliasTags pass. (#136725) This patch produces the following TBAA tree for a function: ``` Function root | "any access" | |- "descriptor member" |- "any data access" | |- "dummy arg data" |- "target data" | |- "allocated data" |- "direct data" |- "global data" ``` The TBAA tags are assigned using the following logic: * All POINTER variables point to the root of "target data". * Dummy arguments without POINTER/TARGET point to their leafs under "dummy arg data". * Dummy arguments with TARGET point to the root of "target data". * Global variables without descriptors point to their leafs under "global data" (including the ones with TARGET). * Global variables with descriptors point to their leafs under "direct data" (including the ones with TARGET). * Locally allocated variables point to their leafs under "allocated data" (including the ones with TARGET). This change makes it possible to disambiguate globals like: ``` module data real, allocatable :: a(:) real, allocatable, target :: b(:) end ``` Indeed, two direct references to global vars cannot alias even if any/both of them have TARGET attribute. In addition, the dummy arguments without POINTER/TARGET cannot alias any other variable even with POINTER/TARGET. This was not expressed in TBAA before this change. As before, any "unknown" memory references (such as with Indirect source, as classified by FIR alias analysis) may alias with anything, as long as they point to the root of "any access". Please think of the counterexamples for which this structure may not work.
Author
Parents
Loading