[all-commits] [llvm/llvm-project] 82c036: [flang] Restructured TBAA trees in AddAliasTags pa...

Slava Zakharin via All-commits all-commits at lists.llvm.org
Tue Apr 29 10:17:34 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 82c036e2de4eba0e286a94c9b3240e4b14d8aee4
      https://github.com/llvm/llvm-project/commit/82c036e2de4eba0e286a94c9b3240e4b14d8aee4
  Author: Slava Zakharin <szakharin at nvidia.com>
  Date:   2025-04-29 (Tue, 29 Apr 2025)

  Changed paths:
    M flang/include/flang/Optimizer/Analysis/AliasAnalysis.h
    M flang/include/flang/Optimizer/Analysis/TBAAForest.h
    M flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
    M flang/lib/Optimizer/Analysis/TBAAForest.cpp
    M flang/lib/Optimizer/Transforms/AddAliasTags.cpp
    M flang/test/Transforms/tbaa-with-dummy-scope.fir
    M flang/test/Transforms/tbaa-with-dummy-scope2.fir
    M flang/test/Transforms/tbaa.fir
    M flang/test/Transforms/tbaa2.fir
    A flang/test/Transforms/tbaa3.fir
    A flang/test/Transforms/tbaa4.fir

  Log Message:
  -----------
  [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.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list