-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[flang][OpenMP] Don't privatize pre-determined symbols declare by nested BLOCKs
#152652
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
ergawy
merged 2 commits into
main
from
users/ergawy/do_not_privaize_nested_declarations
Aug 11, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
32 changes: 32 additions & 0 deletions
32
flang/test/Lower/OpenMP/block_predetermined_privatization.f90
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,32 @@ | ||
| ! Fixes a bug when a block variable is marked as pre-determined private. In such | ||
| ! case, we can simply ignore privatizing that symbol within the context of the | ||
| ! currrent OpenMP construct since the "private" allocation for the symbol will | ||
| ! be emitted within the nested block anyway. | ||
|
|
||
| ! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s | ||
|
|
||
| subroutine block_predetermined_privatization | ||
| implicit none | ||
| integer :: i | ||
|
|
||
| !$omp parallel | ||
| do i=1,10 | ||
| block | ||
| integer :: j | ||
| do j=1,10 | ||
| end do | ||
| end block | ||
| end do | ||
| !$omp end parallel | ||
| end subroutine | ||
|
|
||
| ! CHECK-LABEL: func.func @_QPblock_predetermined_privatization() { | ||
| ! CHECK: %[[I_DECL:.*]]:2 = hlfir.declare %{{.*}} {uniq_name = "{{.*}}Ei"} | ||
| ! CHECK: omp.parallel private(@{{.*}}Ei_private_i32 %[[I_DECL]]#0 -> %{{.*}} : !fir.ref<i32>) { | ||
| ! CHECK: fir.do_loop {{.*}} { | ||
| ! Verify that `j` is allocated whithin the same scope of its block (i.e. inside | ||
| ! the `parallel` loop). | ||
| ! CHECK: fir.alloca i32 {bindc_name = "j", {{.*}}} | ||
| ! CHECK: } | ||
| ! CHECK: } | ||
| ! CHECK: } |
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.
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.
If it doesn't break things, consider making this change for implicit symbols too, as they seem to have the same issue. Reproducer:
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.
It breaks 2 tests:
So I will do that in a follow up PR.
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.
Done in #152973.