Bug 101551 - [offloading] Differences in diagnostics etc.
Summary: [offloading] Differences in diagnostics etc.
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 12.0
: P3 minor
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: openacc, openmp
Depends on:
Blocks:
 
Reported: 2021-07-21 12:34 UTC by Thomas Schwinge
Modified: 2022-07-12 19:51 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Schwinge 2021-07-21 12:34:12 UTC
There are differences in diagnostics etc. depending on whether offloading is disabled or enabled, as we already had found in <http://mid.mail-archive.com/87pmyg4y9s.fsf@euler.schwinge.homeip.net> "openacc: Warnings for strange partitioning choices for parallel regions" and following.

Additionally, I just noticed that calling 'lang_hooks.decl_printable_name (current_function_decl, 2)' in 'gcc/omp-offload.c:execute_oacc_device_lower' for an OpenACC 'routine' 'void ROUTINE (float)', for C that returns 'ROUTINE', for C++ 'ROUTINE(float)' for offloading enabled and 'void ROUTINE(float)' otherwise (notice difference regarding return type), for corresponding Fortran 'routine_' for offloading enabled and 'routine' otherwise (notice difference in '_' suffix).

Low priority certainly, but would be nice to fix/unify at some point, because this occasionally necessitates special care when writing testcases.
Comment 1 Thomas Schwinge 2021-07-21 13:01:35 UTC
Similarly, when calling 'lang_hooks.decl_printable_name (current_function_decl, 2)' in 'gcc/omp-offload.c:execute_oacc_device_lower' for:

    #pragma acc routine
    template <typename T> T
    ROUTINE(int val)
    { [...] }

..., for 'ROUTINE<float>' instantiated that returns 'ROUTINE<float>(int)float' for offloading enabled and 'T ROUTINE(int) [with T = float]' otherwise.
Comment 2 Thomas Schwinge 2021-09-06 13:42:22 UTC
I've noticed that with an offloading-enabled build of GCC we're losing "note: in expansion of macro '[...]'" diagnostics.  (Effectively '-ftrack-macro-expansion=0'?)

For example, 'libgomp.oacc-c-c++-common/vred2d-128.c' with '-fopenacc -Wuninitialized' for a (default) GCC build without '--enable-offload-targets=[...]':

    [...]
    [...]/libgomp.oacc-c-c++-common/vred2d-128.c: In function ‘test1’:
    [...]/libgomp.oacc-c-c++-common/vred2d-128.c:34:8: warning: ‘t1’ is used uninitialized [-Wuninitialized]
       34 |          "acc loop vector reduction(+:t1) reduction(-:t2)")
          |        ^ ~
    [...]/libgomp.oacc-c-c++-common/vred2d-128.c:11:14: note: ‘t1’ was declared here
       11 |   long i, j, t1, t2, t3;                        \
          |              ^~
    [...]/libgomp.oacc-c-c++-common/vred2d-128.c:33:1: note: in expansion of macro ‘gentest’
       33 | gentest (test1, "acc parallel loop gang vector_length (128) firstprivate (t1, t2)",
          | ^~~~~~~
    [...]/libgomp.oacc-c-c++-common/vred2d-128.c:34:8: warning: ‘t2’ is used uninitialized [-Wuninitialized]
    [...]

... vs. a GCC build with '--enable-offload-targets=[...]':

    [...]
    [...]/libgomp.oacc-c-c++-common/vred2d-128.c: In function ‘test1’:
    [...]/libgomp.oacc-c-c++-common/vred2d-128.c:34:8: warning: ‘t1’ is used uninitialized [-Wuninitialized]
       34 |          "acc loop vector reduction(+:t1) reduction(-:t2)")
          |        ^ ~
    [...]/libgomp.oacc-c-c++-common/vred2d-128.c:11:14: note: ‘t1’ was declared here
       11 |   long i, j, t1, t2, t3;                        \
          |              ^~
    [...]/libgomp.oacc-c-c++-common/vred2d-128.c:34:8: warning: ‘t2’ is used uninitialized [-Wuninitialized]
    [...]

Note that an explicit '-foffload=disable' does not cure this.
Comment 3 GCC Commits 2022-07-12 06:28:32 UTC
The master branch has been updated by Thomas Schwinge <tschwinge@gcc.gnu.org>:

https://gcc.gnu.org/g:3723aedaad20a129741c2f6f3c22b3dd1220a3fc

commit r13-1611-g3723aedaad20a129741c2f6f3c22b3dd1220a3fc
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Tue Jul 12 08:17:37 2022 +0200

    XFAIL 'offloading_enabled' diagnostics issue in 'libgomp.oacc-c-c++-common/reduction-5.c' [PR101551]
    
    Fix-up for recent commit 06b2a2abe26554c6f9365676683d67368cbba206
    "Enhance '_Pragma' diagnostics verification in OMP C/C++ test cases".
    Supposedly it's the same issue as in
    <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101551#c2>, where I'd
    noted that:
    
    | [...] with an offloading-enabled build of GCC we're losing
    | "note: in expansion of macro '[...]'" diagnostics.
    | (Effectively '-ftrack-macro-expansion=0'?)
    
            PR middle-end/101551
            libgomp/
            * testsuite/libgomp.oacc-c-c++-common/reduction-5.c: XFAIL
            'offloading_enabled' diagnostics issue.