Bug 97782 - [Fortran] Confused location information for OpenACC compute constructs
Summary: [Fortran] Confused location information for OpenACC compute constructs
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 11.0
: P3 normal
Target Milestone: ---
Assignee: Tobias Burnus
URL:
Keywords: openacc
Depends on:
Blocks:
 
Reported: 2020-11-10 13:23 UTC by Thomas Schwinge
Modified: 2020-11-12 19:21 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
testcase (307 bytes, text/plain)
2020-11-10 13:23 UTC, Thomas Schwinge
Details
Draft patch (318 bytes, patch)
2020-11-10 14:14 UTC, Tobias Burnus
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Schwinge 2020-11-10 13:23:34 UTC
Created attachment 49539 [details]
testcase

Tobias, please see the '-fdump-tree-original-lineno' dump of the testcase I'm attaching.  Instead of expected line 9, the '#pragma acc kernels' has location information for line 18, which happens to be the second '#pragma acc loop'.  The same happens for other OpenACC compute constructs.  I have not checked OpenMP.

Amongst other things, this confuses the '-fopt-info-omp-all' checking (that one's specific to OpenACC 'kernels').
Comment 1 Tobias Burnus 2020-11-10 14:14:26 UTC
Created attachment 49540 [details]
Draft patch

There are probably more – like 'omp sections', 'omp parallel', if I glanced at it correctly. (Search for 'input_location' after 'gfc_trans_omp_code'.)
Comment 2 Tobias Burnus 2020-11-10 14:15:52 UTC
Technically, the issue is (was): The input_location is used which is obtained when finishing the the block (= '!$acc end kernels') - or rather whatever comes before and bumps the line location.
Comment 3 GCC Commits 2020-11-12 13:14:02 UTC
The master branch has been updated by Tobias Burnus <burnus@gcc.gnu.org>:

https://gcc.gnu.org/g:b71ff8c15f5a7d6b1cc1524b4d27843f0d88dbda

commit r11-4942-gb71ff8c15f5a7d6b1cc1524b4d27843f0d88dbda
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Thu Nov 12 14:13:45 2020 +0100

    Fortran: improve location data for OpenACC/OpenMP directives [PR97782]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/97782
            * trans-openmp.c (gfc_trans_oacc_construct, gfc_trans_omp_parallel_do,
            gfc_trans_omp_parallel_do_simd, gfc_trans_omp_parallel_sections,
            gfc_trans_omp_parallel_workshare, gfc_trans_omp_sections
            gfc_trans_omp_single, gfc_trans_omp_task, gfc_trans_omp_teams
            gfc_trans_omp_target, gfc_trans_omp_target_data,
            gfc_trans_omp_workshare): Use code->loc instead of input_location
            when building the OMP_/OACC_ construct.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/97782
            * gfortran.dg/goacc/classify-kernels-unparallelized.f95: Move dg-message
            one line up.
            * gfortran.dg/goacc/classify-kernels.f95: Likewise.
Comment 4 GCC Commits 2020-11-12 14:42:11 UTC
The releases/gcc-10 branch has been updated by Tobias Burnus <burnus@gcc.gnu.org>:

https://gcc.gnu.org/g:5eebaff9f992814a2f8f915e436716b1b2c983df

commit r10-9018-g5eebaff9f992814a2f8f915e436716b1b2c983df
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Thu Nov 12 14:16:53 2020 +0100

    Fortran: improve location data for OpenACC/OpenMP directives [PR97782]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/97782
            * trans-openmp.c (gfc_trans_oacc_construct, gfc_trans_omp_parallel_do,
            gfc_trans_omp_parallel_do_simd, gfc_trans_omp_parallel_sections,
            gfc_trans_omp_parallel_workshare, gfc_trans_omp_sections
            gfc_trans_omp_single, gfc_trans_omp_task, gfc_trans_omp_teams
            gfc_trans_omp_target, gfc_trans_omp_target_data,
            gfc_trans_omp_workshare): Use code->loc instead of input_location
            when building the OMP_/OACC_ construct.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/97782
            * gfortran.dg/goacc/classify-kernels-unparallelized.f95: Move dg-message
            one line up.
            * gfortran.dg/goacc/classify-kernels.f95: Likewise.
    
    Reviewed-by: Thomas Schwinge <thomas@codesourcery.com>
    
    (cherry picked from commit b71ff8c15f5a7d6b1cc1524b4d27843f0d88dbda)
Comment 5 Tobias Burnus 2020-11-12 15:44:38 UTC
FIXED for mainline (GCC 11) and GCC 10.

If the testcase is not covered by your upcoming patch merges, feel free to commit it yourself (or tell me to commit it for you).

Thanks for the report!
Comment 6 GCC Commits 2020-11-12 19:21:51 UTC
The master branch has been updated by Thomas Schwinge <tschwinge@gcc.gnu.org>:

https://gcc.gnu.org/g:9106c51e57c06e88a0dddf994fb5432b4bbe68c0

commit r11-4951-g9106c51e57c06e88a0dddf994fb5432b4bbe68c0
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Thu Nov 12 20:07:25 2020 +0100

    Adjust 'libgomp.oacc-fortran/attach-descriptor-1.f90' for improved location information
    
    Fix-up for commit b71ff8c15f5a7d6b1cc1524b4d27843f0d88dbda "Fortran: improve
    location data for OpenACC/OpenMP directives [PR97782]".
    
            libgomp/
            PR fortran/97782
            * testsuite/libgomp.oacc-fortran/attach-descriptor-1.f90: Adjust.