Bug 103836 - '-fcompare-debug' failure (length) w/ -fopenacc --param openacc-kernels=decompose
Summary: '-fcompare-debug' failure (length) w/ -fopenacc --param openacc-kernels=decom...
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 12.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: compare-debug-failure, openacc
Depends on:
Blocks:
 
Reported: 2021-12-26 16:17 UTC by Arseny Solokha
Modified: 2025-09-03 01:12 UTC (History)
6 users (show)

See Also:
Host:
Target: x86_64-unknown-linux-gnu
Build:
Known to work:
Known to fail: 11.2.0, 12.0
Last reconfirmed: 2021-12-27 00:00:00


Attachments
diff -u o5cia6mf.*.gkd (1.23 KB, text/plain)
2021-12-26 16:17 UTC, Arseny Solokha
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Arseny Solokha 2021-12-26 16:17:44 UTC
Created attachment 52061 [details]
diff -u o5cia6mf.*.gkd

g++ 12.0.0 20211219 snapshot (g:fcbf94a5be9e0c1ecad92da773a6632b86b7f70a) fails -fcompare-debug check when compiling the following testcase w/, extracted from gcc/testsuite/c-c++-common/goacc/nesting-1.c, w/ -fopenacc --param openacc-kernels=decompose:

extern int i;

void
f_acc_kernels (void)
{
#pragma acc kernels
  {
#pragma acc loop
    for (i = 0; i < 2; ++i)
      ;
  }
}

% x86_64-unknown-linux-gnu-g++-12.0.0 -O1 -fcompare-debug -fopenacc --param openacc-kernels=decompose -c o5cia6mf.c
x86_64-unknown-linux-gnu-g++-12.0.0: error: o5cia6mf.c: '-fcompare-debug' failure (length)

Diff between two gkd files attached. I can reproduce the issue only w/ C++ front-end.
Comment 1 Jakub Jelinek 2021-12-27 13:18:58 UTC
 void foo ()
 {
+  # DEBUG BEGIN_STMT
   #pragma omp target oacc_kernels
     {
       int i.0;
 
+      # DEBUG BEGIN_STMT
+      # DEBUG BEGIN_STMT
       #pragma acc loop private(i.0) private(i)
       for (i.0 = 0; i.0 < 2; i.0 = i.0 + 1)
         {
           i = i.0;
+          # DEBUG BEGIN_STMT
         }
     }
 }

difference at gimplification time is ok, but
 void foo ()
 {
+  # DEBUG BEGIN_STMT
   #pragma omp target oacc_data_kernels
     {
       try
@@ -10,12 +11,18 @@ void foo ()
           {
             int i.0;
 
+            #pragma omp target oacc_parallel_kernels_gang_single async(-1) num_gangs(1)
+              {
+                # DEBUG BEGIN_STMT
+                # DEBUG BEGIN_STMT
+              }
             #pragma omp target oacc_kernels async(-1)
               {
                 #pragma acc loop private(i.0) private(i)
                 for (i.0 = 0; i.0 < 2; i.0 = i.0 + 1)
                   {
                     i = i.0;
+                    # DEBUG BEGIN_STMT
                   }
               }
             __builtin_GOACC_wait (-2, 0);
from omp_oacc_kernels_decompose is not.  Debug stmts shouldn't affect code-generation decisions.
Comment 2 Martin Liška 2021-12-28 10:45:18 UTC
Started with r11-8242-g3395dfc4da8ad1fc.
Comment 3 GCC Commits 2022-03-04 13:25:51 UTC
The master branch has been updated by Thomas Schwinge <tschwinge@gcc.gnu.org>:

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

commit r12-7478-gc14ea6a72fb1ae66e3d32ac8329558497c6e4403
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Wed Jan 19 14:04:42 2022 +0100

    Catch 'GIMPLE_DEBUG' misbehavior in OpenACC 'kernels' decomposition [PR100400, PR103836, PR104061]
    
    Actually fixing it is a separate task, but it seems prudent to at least catch
    it, and document via a few test cases.
    
            gcc/
            PR middle-end/100400
            PR middle-end/103836
            PR middle-end/104061
            * omp-oacc-kernels-decompose.cc (decompose_kernels_region_body):
            Catch 'GIMPLE_DEBUG'.
            gcc/testsuite/
            PR middle-end/100400
            PR middle-end/103836
            PR middle-end/104061
            * c-c++-common/goacc/kernels-decompose-pr100400-1-1.c: New.
            * c-c++-common/goacc/kernels-decompose-pr100400-1-2.c: New.
            * c-c++-common/goacc/kernels-decompose-pr100400-1-3.c: New.
            * c-c++-common/goacc/kernels-decompose-pr100400-1-4.c: New.
            * c-c++-common/goacc/kernels-decompose-pr103836-1-1.c: New.
            * c-c++-common/goacc/kernels-decompose-pr103836-1-2.c: New.
            * c-c++-common/goacc/kernels-decompose-pr103836-1-3.c: New.
            * c-c++-common/goacc/kernels-decompose-pr103836-1-4.c: New.
            * c-c++-common/goacc/kernels-decompose-pr104061-1-1.c: New.
            * c-c++-common/goacc/kernels-decompose-pr104061-1-2.c: New.
            * c-c++-common/goacc/kernels-decompose-pr104061-1-3.c: New.
            * c-c++-common/goacc/kernels-decompose-pr104061-1-4.c: New.