-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flang][Lower] get ultimate symbol when querying if pointer or alloca…
…table (#99528) This fixes a bug in OpenMP privatisation. The privatised variables are created as though they are host associated clones of the original variables. These privatised variables do not contain the allocatable attribute themselves and so we need to check if the ultimate symbol is allocatable. Having or not having this flag influences whether lowering determines that this is a whole allocatable assignment, which then causes hlfir.assign not to get the realloc flag, which cases the allocatable not to be allocated when it is assigned to (leading to a segfault running the newly added test). I also did the same for pointer variables because I would imagine they could experience the same issue. There is no fallout on tests outside of OpenMP, and the gfortran test suite still passes, so I think this doesn't break host other kinds of host associated symbols.
- Loading branch information
Showing
4 changed files
with
30 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
! RUN: bbc -emit-hlfir -fopenmp -o - %s | FileCheck %s | ||
! RUN: %flang_fc1 -emit-hlfir -fopenmp -o - %s | FileCheck %s | ||
|
||
program firstprivateallocatable | ||
Integer, Allocatable :: a,u | ||
a = 137 | ||
|
||
!$omp parallel firstprivate(a,u) | ||
u = a**2 | ||
!$omp end parallel | ||
end program | ||
|
||
|
||
! CHECK-LABEL: func.func @_QQmain() | ||
! [...] | ||
! CHECK: omp.parallel { | ||
! [...] | ||
! CHECK: %[[VAL_50:.*]] = arith.constant 2 : i32 | ||
! CHECK: %[[VAL_51:.*]] = math.ipowi %{{.*}}, %[[VAL_50]] : i32 | ||
! this is what we are really checking: the hlfir.assign must have realloc so that | ||
! u is allocated when the assignment occurs | ||
! CHECK: hlfir.assign %[[VAL_51]] to %{{.*}}#0 realloc : i32, !fir.ref<!fir.box<!fir.heap<i32>>> | ||
! [...] | ||
! CHECK: omp.terminator | ||
! CHECK: } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters