[all-commits] [llvm/llvm-project] 7d1a8f: [flang] Fix FIR AliasAnalysis for zero-offset view...
khaki3 via All-commits
all-commits at lists.llvm.org
Tue May 5 14:23:36 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 7d1a8f197c57ee2d36c18a2920344f34111394b8
https://github.com/llvm/llvm-project/commit/7d1a8f197c57ee2d36c18a2920344f34111394b8
Author: khaki3 <47756807+khaki3 at users.noreply.github.com>
Date: 2026-05-05 (Tue, 05 May 2026)
Changed paths:
M flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
M flang/test/Analysis/AliasAnalysis/alias-analysis-pack-array.fir
A flang/test/Analysis/AliasAnalysis/alias-analysis-zero-offset-view-chain.fir
M flang/test/Transforms/OpenACC/acc-implicit-data.fir
Log Message:
-----------
[flang] Fix FIR AliasAnalysis for zero-offset view chains (#192710)
When subroutine `f` below is inlined, the `ACCImplicitData` pass fails
to recognize that `b` is already covered by the enclosing `!$acc data
deviceptr`. The deviceptr clause operates on a box (`fir.embox` result)
while the inner `acc.serial` uses the underlying ref.
`fir::AliasAnalysis` traces both back through the full def-chain, where
an upstream sliced `fir.embox` (from `a(:,5)`) sets
`approximateSource=true`, causing `MayAlias` instead of `MustAlias`. The
pass falls back to implicit `copyin`/`copyout`, causing a segfault.
```fortran
module test_mod
real, allocatable :: a(:,:)
contains
subroutine f(b)
real, dimension(*) :: b
!$acc data deviceptr(b(1:100))
!$acc serial
print *, b(10)
!$acc end serial
!$acc end data
end subroutine f
end module test_mod
program test
use test_mod
call alloc_a
!$acc data present(a)
!$acc host_data use_device(a)
call f( a(:,5) )
!$acc end host_data
!$acc end data
end program
```
Fix: add `getZeroOffsetViewRoot()` as a short-circuit in `alias(Source,
Source, Value, Value)`. Before consulting `approximateSource`, it walks
each value backward through `FortranObjectViewOpInterface` ops with zero
offset (embox without slice, declare, box_addr) to find its root. If
both values share the same root, `MustAlias` is returned immediately,
avoiding the conservative `MayAlias` caused by distant
`approximateSource` flags.
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