-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[flang] Retrieve shape from selector when generating assoc sym type #137117
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
Open
ergawy
wants to merge
1
commit into
main
Choose a base branch
from
users/ergawy/gen_shape_from_expr_for_assoc_entities
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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,22 @@ | ||
! RUN: %flang_fc1 -emit-hlfir -o - %s | FileCheck %s | ||
|
||
subroutine local_assoc | ||
implicit none | ||
integer i | ||
real, dimension(2:11) :: aa | ||
|
||
associate(a => aa(4:)) | ||
do concurrent (i = 4:11) local(a) | ||
a(i) = 0 | ||
end do | ||
end associate | ||
end subroutine local_assoc | ||
|
||
! CHECK: %[[C8:.*]] = arith.constant 8 : index | ||
|
||
! CHECK: fir.do_loop {{.*}} unordered { | ||
! CHECK: %[[LOCAL_ALLOC:.*]] = fir.alloca !fir.array<8xf32> {bindc_name = "a", pinned, uniq_name = "{{.*}}local_assocEa"} | ||
! CHECK: %[[LOCAL_SHAPE:.*]] = fir.shape %[[C8]] : | ||
! CHECK: %[[LOCAL_DECL:.*]]:2 = hlfir.declare %[[LOCAL_ALLOC]](%[[LOCAL_SHAPE]]) | ||
! CHECK: hlfir.designate %[[LOCAL_DECL]]#0 (%{{.*}}) | ||
! 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.
Not very familiar with this part of the codebase, so hopefully this is a sane fix.
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.
Did you look into why
ultimate.IsObjectArray
is returning false for that case?That seems a bit odd to 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.
Thanks for the review and sorry for the late response, was busy doing other stuff.
This is because it calls
Symbol::GetShape
andSymbol::GetShape
returns the shape only in the case ofObjectEntityDetails
. ForAssocEntityDetails
(and other variants), it returns null. See https://github.com/llvm/llvm-project/blob/main/flang/lib/Semantics/symbol.cpp#L401.Do you think we should extend
GetShape
to work withAssocEntityDetails
as well instead of what I am doing here?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.
Sorry for the very late reply, I missed the mails, do not hesitate to call me back for review when I am late to reply. Thanks for the reply, I can understand why Symbol::GetShape returns nothing given there is no textual shape-spec in the source for selectors.
However,
evaluate::GetShape
that is called here in lowering is supposed to work directly with AssocEntityDetails (I see some handling for it here).So to avoid duplicating code, maybe the best is just to simplify the code to do: