Skip to content
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

Fix semantic analysis failures of LBOUND/UBOUND in type specification #1422

Merged
merged 1 commit into from
Nov 14, 2023

Conversation

wanbinchen-hnc
Copy link
Contributor

@wanbinchen-hnc wanbinchen-hnc commented Sep 25, 2023

An issue occurs when LBOUND/UBOUND appears in the type specification
of a function result and the DIM argument is missing.

The root cause of this issue is that LBOUND/UBOUND is converted to
runtime call in semantic phase, which is too early for type-spec of
a function result. On the calling side of the function, we have no
way of knowing whether LBOUND/UBOUND exists or its reference to the
function's dummy arguments.

We fix the issue by delaying the conversion to the tranform phase.
In particular, we perform the conversion in dummy-actual argument
replacement if the array argument of LBOUND/UBOUND is an assumed-shape
array dummy.

In addition, we fix an ICE that occurs when LBOUND/UBOUND appears in
subscript expressions in type-spec, fix the link error that occurs
when both DIM and KIND arguments are present, fix an issue with LBOUND
on the last dimension of an assumed-size array, and add support for
LBOUND/UBOUND on an assumed-rank array.

@bryanpkc
Copy link
Collaborator

bryanpkc commented Oct 4, 2023

There are typos and format errors in your commit message; please reword it. It should start with a commit title, with a topic prefix, and separated from the message body with a blank line. For example:

[flang1] Fix handling of LBOUND/UBOUND in type specification

An issue occurs when LBOUND/UBOUND appears in the type specification
of a function result and the DIM argument is missing.

The root cause of this issue is that LBOUND/UBOUND is converted to
runtime call in semantic phase, which is too early for type-spec of
a function result. On the calling side of the function, we have no
way of knowing whether LBOUND/UBOUND exists or its reference to the
function's dummy arguments.

We fix the issue by delaying the conversion to the tranform phase.
In particular, we perform the conversion in dummy-actual argument
replacement if the array argument of LBOUND/UBOUND is an assumed-shape
array dummy.

In addition, we fix an ICE that occurs when LBOUND/UBOUND appears in
subscript expressions in type-spec, fix the link error that occurs
when both DIM and KIND arguments are present, fix an issue with LBOUND
on the last dimension of an assumed-size array, and add support for
LBOUND/UBOUND on an assumed-rank array.

@bryanpkc bryanpkc changed the title The issue occurs when LBOUND/UBOUND appears in the type-spec of a fun… Fix semantic analysis failures of LBOUND/UBOUND in type specification Oct 4, 2023
@wanbinchen-hnc
Copy link
Contributor Author

@bryanpkc Thanks for your comments, I have updated the commit message.

Copy link
Collaborator

@pawosm-arm pawosm-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can give you a tentative approval. This is an extensive change where it would be difficult to prove validity of the consequences of all the possible interactions. Therefore I've hauled this commit through various flows of our CI, and it didn't break any of the workloads, also NAG tests seemed to be happy with it.

Copy link
Collaborator

@bryanpkc bryanpkc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has passed our internal testing.

An issue occurs when LBOUND/UBOUND appears in the type specification
of a function result and the DIM argument is missing.

The root cause of this issue is that LBOUND/UBOUND is converted to
runtime call in semantic phase, which is too early for type-spec of
a function result. On the calling side of the function, we have no
way of knowing whether LBOUND/UBOUND exists or its reference to the
function's dummy arguments.

We fix the issue by delaying the conversion to the tranform phase.
In particular, we perform the conversion in dummy-actual argument
replacement if the array argument of LBOUND/UBOUND is an assumed-shape
array dummy.

In addition, we fix an ICE that occurs when LBOUND/UBOUND appears in
subscript expressions in type-spec, fix the link error that occurs
when both DIM and KIND arguments are present, fix an issue with LBOUND
on the last dimension of an assumed-size array, and add support for
LBOUND/UBOUND on an assumed-rank array.
@bryanpkc bryanpkc merged commit 2693fba into flang-compiler:master Nov 14, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants