Skip to content

[gfortran] Fixed cray_pointers_2.f90 aliasing issues. #252

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 2 commits into from
May 29, 2025

Conversation

vzakhari
Copy link
Contributor

The test started failing after llvm/llvm-project#140803
The issue is that the Cray pointee and the underlying storage
are both accessed in subroutines violating Fortran aliasing rules
for the dummy arguments.

GCC tried to "solve" that by using -fno-inline option, but
it should be better to make the aliasing explicit with proper TARGET
attribute placement.

@tarunprabhu
Copy link
Contributor

Thanks Slava.

We don't allow modifying these tests. For now, this test should be disabled instead by adding it to the "skipped" tests in Fortran/gfortran/regression/DisabledFiles.cmake. Please add a comment explaining why this was disabled (the contents of your commit message would work well).

If this test is useful, you could consider adding it with your modifications to Fortran/UnitTests. You can use the assign-goto test as a template. I believe that that test is a modified version of one from the gfortran test suite.

Copy link
Contributor

@tarunprabhu tarunprabhu left a comment

Choose a reason for hiding this comment

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

Please disable the test instead.

@ashermancinelli
Copy link
Contributor

Thanks for the explanation @tarunprabhu!

As you said Slava, this test appears to break the rules for cray pointers that the HPE docs lay out. Our own docs on aliasing explain this to our users and how they can get around the issues that come from their misuse of the feature. It may be a useful standalone test demonstrating that the workaround we recommend to our users really does allow their code to work as they intend. I don't like gfortran's approach of simply disabling some optimizations to get the test to pass. +1 for disabling the test and adding our own modified test.

The test started failing after llvm/llvm-project#140803
The issue is that the Cray pointee and the underlying storage
are both accessed in subroutines violating Fortran aliasing rules
for the dummy arguments.

GCC tried to "solve" that by using `-fno-inline` option, but
it should be better to make the aliasing explicit with proper `TARGET`
attribute placement.
@vzakhari vzakhari requested a review from tarunprabhu May 29, 2025 18:45
Comment on lines 1 to 3
! { dg-do run }
! { dg-options "-O3 -fcray-pointer -fbounds-check -fno-inline" }
! { dg-timeout-factor 4 }
Copy link
Contributor

Choose a reason for hiding this comment

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

These DejaGNU directives are not necessary. We may want to retain a comment with the command line options though. If any are ever supported in flang, we may need to update the flags with which this test is built. Perhaps something like

Suggested change
! { dg-do run }
! { dg-options "-O3 -fcray-pointer -fbounds-check -fno-inline" }
! { dg-timeout-factor 4 }
! The original gfortran test on which this is based is compiled with
! -fcray-pointer -fbounds-check -fno-inline. Of these, we may want to compile
! with -fbounds-check (or its equivalent) if it is ever supported in flang

Comment on lines 7 to 8
! Note: Some of the test cases violate Fortran's alias rules;
! the "-fno-inline option" for now prevents failures.
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of this, could we have a comment indicating what the original source of this test was and what changes were made to it? It may be a useful reference in the future.

@vzakhari vzakhari requested a review from tarunprabhu May 29, 2025 19:19
Copy link
Contributor

@tarunprabhu tarunprabhu left a comment

Choose a reason for hiding this comment

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

Thanks for the changes, Slava. LGTM.

@vzakhari
Copy link
Contributor Author

Thank you for the review, Tarun!

@vzakhari vzakhari merged commit 9faf63c into llvm:main May 29, 2025
1 check 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.

3 participants