-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[flang][stack-arrays] Extend pass to work on declare ops and within omp regions #98810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
64ee7b3
[flang][stack-arrays] Extend pass to work on declare ops and within o…
ergawy 9d642d8
further detections of declare ops
ergawy 5f12f91
Merge remote-tracking branch 'upstream/main' into stack_arrays_decl_o…
ergawy be24abb
format
ergawy 460be2e
more testing
ergawy 36ad5c8
Merge remote-tracking branch 'upstream/main' into stack_arrays_decl_o…
ergawy f72049c
Merge remote-tracking branch 'upstream/main' into stack_arrays_decl_o…
ergawy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,55 @@ | ||
! Similar to stack-arrays.f90; i.e. both test the stack-arrays pass for different | ||
! kinds of supported inputs. This one differs in that it takes the hlfir lowering | ||
! path in flag rather than the fir one. For example, temp arrays are lowered | ||
! differently in hlfir vs. fir and the IR that reaches the stack arrays pass looks | ||
! quite different. | ||
|
||
|
||
! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - \ | ||
! RUN: | fir-opt --lower-hlfir-ordered-assignments \ | ||
! RUN: --bufferize-hlfir \ | ||
! RUN: --convert-hlfir-to-fir \ | ||
! RUN: --array-value-copy \ | ||
! RUN: --stack-arrays \ | ||
! RUN: | FileCheck %s | ||
|
||
subroutine temp_array | ||
implicit none | ||
integer (8) :: lV | ||
integer (8), dimension (2) :: iaVS | ||
|
||
lV = 202 | ||
|
||
iaVS = [lV, lV] | ||
end subroutine temp_array | ||
! CHECK-LABEL: func.func @_QPtemp_array{{.*}} { | ||
! CHECK-NOT: fir.allocmem | ||
! CHECK-NOT: fir.freemem | ||
! CHECK: fir.alloca !fir.array<2xi64> | ||
! CHECK-NOT: fir.allocmem | ||
! CHECK-NOT: fir.freemem | ||
! CHECK: return | ||
! CHECK-NEXT: } | ||
|
||
subroutine omp_temp_array | ||
implicit none | ||
integer (8) :: lV | ||
integer (8), dimension (2) :: iaVS | ||
|
||
lV = 202 | ||
|
||
!$omp target | ||
iaVS = [lV, lV] | ||
!$omp end target | ||
end subroutine omp_temp_array | ||
! CHECK-LABEL: func.func @_QPomp_temp_array{{.*}} { | ||
! CHECK: omp.target {{.*}} { | ||
! CHECK-NOT: fir.allocmem | ||
! CHECK-NOT: fir.freemem | ||
! CHECK: fir.alloca !fir.array<2xi64> | ||
! CHECK-NOT: fir.allocmem | ||
! CHECK-NOT: fir.freemem | ||
! CHECK: omp.terminator | ||
! CHECK-NEXT: } | ||
! CHECK: return | ||
! CHECK-NEXT: } |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure this a proper use of the DFA framework in this case or not.
In particular, should I instead propagate the information through the
fir.declare
op instead of doing this indirect check of the operand? The problem is that this will complicate things a bit more:allocmem
and the value returned from thedeclare
op asAllocated
. I don't think this will be correct.AllocationState
, for example:AllocDeclare
(?) to mark the results offir.declare
ops. If the current approach in the PR does not fit how the framework should be used, I think this option might be better.Let me know if you have any thoughts on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have the context on the
fir
dialect to comment on the memory effects model here, but what I can say is this should be fine. What you want is if the allocation state of the result ofdeclareOp
is modified, that this function gets re-invoked on the right user, which the DFA framework should ensure happens properly.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree this is fine and a lot simpler than tracking both references to the
allocated
variable