[flang-commits] [flang] [flang] AliasAnalysis: Fix pointer component logic (PR #94242)
via flang-commits
flang-commits at lists.llvm.org
Wed Jun 19 03:31:43 PDT 2024
================
@@ -60,7 +60,15 @@ void AliasAnalysis::Source::print(llvm::raw_ostream &os) const {
attributes.Dump(os, EnumToString);
}
-bool AliasAnalysis::Source::isPointerReference(mlir::Type ty) {
+bool AliasAnalysis::isRecordWithPointerComponent(mlir::Type ty) {
+ auto eleTy = fir::dyn_cast_ptrEleTy(ty);
----------------
jeanPerier wrote:
Not directly related to your patch (since you only moved that code), but I found it while testing the logic below.
This should actually be `fir::unwrapSequenceType(dyn_cast_ptrOrBoxEleTy(ty))` in order to also unwrap fir.box type and arrays.
Otherwise, this will miss cases as the one below where the descriptor address of "p" may alias with the data of "c".
```
module m
type t
real, pointer :: p
end type
type(t) :: a(1)
type(t) :: b(1)
contains
subroutine test(p, c)
real, pointer :: p
type(t), target :: c(:)
p = 42
c = b
print *, p
end subroutine
end module
use m
real, target :: x1 = 1
real, target :: x2 = 2
a(1)%p => x1
b(1)%p => x2
call test(a(1)%p, a)
end
```
https://github.com/llvm/llvm-project/pull/94242
More information about the flang-commits
mailing list