-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[OpenMP][LLVM] Update alloca IP after PrivCB
in OMPIRBUIlder
#93920
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 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
926cf8d
[OpenMP][][LLVM] Update alloca IP after `PrivCB` in `OMPIRBUIlder`
ergawy 99aa590
Merge remote-tracking branch 'upstream/main' into delayed_privatizati…
ergawy 659eec2
update ip
ergawy 5486126
Merge remote-tracking branch 'upstream/main' into delayed_privatizati…
ergawy b854083
Merge remote-tracking branch 'upstream/main' into delayed_privatizati…
ergawy d540386
fix clang expectations
ergawy 3cc5228
Merge remote-tracking branch 'upstream/main' into delayed_privatizati…
ergawy e2b82a3
Merge remote-tracking branch 'upstream/main' into delayed_privatizati…
ergawy 6dbc55a
Merge remote-tracking branch 'upstream/main' into delayed_privatizati…
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
23 changes: 23 additions & 0 deletions
23
flang/test/Lower/OpenMP/delayed-privatization-lower-allocatable-to-llvm.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,23 @@ | ||
! Tests the OMPIRBuilder can handle multiple privatization regions that contain | ||
! multiple BBs (for example, for allocatables). | ||
|
||
! RUN: %flang -S -emit-llvm -fopenmp -mmlir --openmp-enable-delayed-privatization \ | ||
! RUN: -o - %s 2>&1 | FileCheck %s | ||
|
||
subroutine foo(x) | ||
integer, allocatable :: x, y | ||
!$omp parallel private(x, y) | ||
x = y | ||
!$omp end parallel | ||
end | ||
|
||
! CHECK-LABEL: define void @foo_ | ||
! CHECK: ret void | ||
! CHECK-NEXT: } | ||
|
||
! CHECK-LABEL: define internal void @foo_..omp_par | ||
! CHECK-DAG: call ptr @malloc | ||
! CHECK-DAG: call ptr @malloc | ||
! CHECK-DAG: call void @free | ||
! CHECK-DAG: call void @free | ||
! CHECK: } |
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.
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.
So, the problem leading to this is that we've split the Alloca block [because the variable is allocatable], and the actual insert point is now the branch of the second block.
I don't think we want the new AllocaIP to be in that second block, in case someone adds more alloca ops - they should go into the first block.
My PR, that Kiran mentioned, has several of this kind of fixes [I will check if it fixes this case too,]. Whenever possible, I try to make the new location at the terminator of the original AllocaIP block.
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.
Thanks for looking at this @Leporacanthicus. I tried your PR with a reproducing example and so far it does not handle this case. If you like, you can take the test I added in this PR and add it to yours and handle that case in your PR as well. Either way is fine with me.
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.
See this comment.
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.
@kiranchandramohan @Leporacanthicus based on the above comment, and since neither PRs solves the "1 BB for all allocas" problem and since #92430 does not solve the crash handled by this PR, I think there is not conflict between this PR and #92430. I think we can proceed with both. WDYT?
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'm hitting further problems (in the real code that we're trying to make work), so I'm OK with this going in if it is helping you get the job done. I personally would prefer it going into the oriiginal allocaIP BB - I'm well aware that not ALL things go in the original BB, but we don't need to make it worse... :)
Also, if all places that need this fix use code like
builder.SetInsertPoint(allocaIP.getBlock()->getTerminator());
or perhaps:then it makes it a little easier to find ALL such places, and not have to find half a dozen different variants that do slightly different things.
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 can do that. I actually tried that locally and did not commit it since it did not make much difference in terms of generated IR. However, it makes sense to commit it given the point you mentioned about consistency.