public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/107028] New: [13 Regression][OpenACC] ICE in install_var_field, at omp-low.cc:797
@ 2022-09-24 18:58 burnus at gcc dot gnu.org
  2022-09-24 21:35 ` [Bug middle-end/107028] " burnus at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2022-09-24 18:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107028

            Bug ID: 107028
           Summary: [13 Regression][OpenACC] ICE in install_var_field, at
                    omp-low.cc:797
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code, openacc
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
                CC: tschwinge at gcc dot gnu.org
  Target Milestone: ---

The following fails with an ICE
 
https://github.com/OpenACCUserGroup/OpenACCV-V/blob/master/Tests/routine_bind_nonprototype_function_nonstring_function.cpp

(I find it a bit surprising that even bunch of compile errors still reach this
function, giving the ICE.)

In any case, the following reduced code (which compiles without errors) gives
an ICE,
when compiled with  'g++ -fopenacc':


class data_container {
 public:
  int data;
};

void test2() {
  data_container a;
#pragma acc data copyin(a, a.data)
{ }
}


Namely:

during GIMPLE pass: omplower
test2.cc: In function ‘void test2()’:
test2.cc:8:9: internal compiler error: in install_var_field, at omp-low.cc:797
    8 | #pragma acc data copyin(a, a.data)
      |         ^~~
0x83f00d install_var_field
        ../../repos/gcc-trunk-commit/gcc/omp-low.cc:797
0x109ab6c scan_sharing_clauses
        ../../repos/gcc-trunk-commit/gcc/omp-low.cc:1677
0x109c557 scan_omp_target
        ../../repos/gcc-trunk-commit/gcc/omp-low.cc:3110
0x109d340 scan_omp_1_stmt
        ../../repos/gcc-trunk-commit/gcc/omp-low.cc:4326
0xefcc7a walk_gimple_stmt(gimple_stmt_iterator*, tree_node*
(*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**,
int*, void*), walk_stmt_info*)
        ../../repos/gcc-trunk-commit/gcc/gimple-walk.cc:602
0xefce80 walk_gimple_seq_mod(gimple**, tree_node* (*)(gimple_stmt_iterator*,
bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*),
walk_stmt_info*)
        ../../repos/gcc-trunk-commit/gcc/gimple-walk.cc:51
0xefcd91 walk_gimple_stmt(gimple_stmt_iterator*, tree_node*
(*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**,
int*, void*), walk_stmt_info*)
        ../../repos/gcc-trunk-commit/gcc/gimple-walk.cc:665
0xefce80 walk_gimple_seq_mod(gimple**, tree_node* (*)(gimple_stmt_iterator*,
bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*),
walk_stmt_info*)
        ../../repos/gcc-trunk-commit/gcc/gimple-walk.cc:51
0xefcd39 walk_gimple_stmt(gimple_stmt_iterator*, tree_node*
(*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**,
int*, void*), walk_stmt_info*)
        ../../repos/gcc-trunk-commit/gcc/gimple-walk.cc:711
0xefce80 walk_gimple_seq_mod(gimple**, tree_node* (*)(gimple_stmt_iterator*,
bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*),
walk_stmt_info*)
        ../../repos/gcc-trunk-commit/gcc/gimple-walk.cc:51
0x10aadba scan_omp
        ../../repos/gcc-trunk-commit/gcc/omp-low.cc:4376
0x10aadba execute_lower_omp
        ../../repos/gcc-trunk-commit/gcc/omp-low.cc:14670

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug middle-end/107028] [13 Regression][OpenACC] ICE in install_var_field, at omp-low.cc:797
  2022-09-24 18:58 [Bug middle-end/107028] New: [13 Regression][OpenACC] ICE in install_var_field, at omp-low.cc:797 burnus at gcc dot gnu.org
@ 2022-09-24 21:35 ` burnus at gcc dot gnu.org
  2022-09-25  5:51 ` burnus at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2022-09-24 21:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107028

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jules at gcc dot gnu.org

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
The problem is that for
    8 | #pragma acc data copyin(a, a.data)

the function install_var_field is called twice, both times with:
  install_var_field (var=0x7ffff6fd8d80, by_ref=true, mask=3, ctx=0x30abd50)
where var is  var_decl 'a'. This then runs into the assert:

797       gcc_assert ((mask & 1) == 0
798                   || !splay_tree_lookup (ctx->field_map, key));

 * * *

BTW, in GCC 12 (and OG12), the omplower dump is:
        #pragma omp target oacc_data map(to:a [len: 4]) map(to:a.data [len: 4])

* * *

Unless I messed up with bisecting, the culprit is
  r13-2665-g23baa717c991d77f206a9358ce2c04960ccf9eea
  OpenMP/OpenACC struct sibling list gimplification extension and rework

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug middle-end/107028] [13 Regression][OpenACC] ICE in install_var_field, at omp-low.cc:797
  2022-09-24 18:58 [Bug middle-end/107028] New: [13 Regression][OpenACC] ICE in install_var_field, at omp-low.cc:797 burnus at gcc dot gnu.org
  2022-09-24 21:35 ` [Bug middle-end/107028] " burnus at gcc dot gnu.org
@ 2022-09-25  5:51 ` burnus at gcc dot gnu.org
  2022-09-26  9:20 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2022-09-25  5:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107028

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Minor postscript: While the following (reduced testcase in comment 0) looks a
bit odd,

  int data;
  ...
  #pragma acc data copyin(a, a.data)

the original uses a pointer. Thus, something like
  int *data;
  ...
  #pragma acc data copyin(a, a.data[0:n])

which is more sensible. This variant still gives an ICE.
However, either variant shouldn't ICE

BTW: GCC 12 has the following omplower dump for this variant:
   #pragma omp target oacc_data \
        map(to:a [len: 8]) map(alloc:a.data [len: 8]) \
        map(to:*_8 [len: _7]) map(attach:a.data [bias: 0])

--------------------------------------
long long n = 10;

class data_container {
 public:
  int *data;
};

void test2() {
  data_container a;
  a.data = (int*)__builtin_malloc (n * sizeof (int));
#pragma acc data copyin(a, a.data[0:n])
{ }
}

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug middle-end/107028] [13 Regression][OpenACC] ICE in install_var_field, at omp-low.cc:797
  2022-09-24 18:58 [Bug middle-end/107028] New: [13 Regression][OpenACC] ICE in install_var_field, at omp-low.cc:797 burnus at gcc dot gnu.org
  2022-09-24 21:35 ` [Bug middle-end/107028] " burnus at gcc dot gnu.org
  2022-09-25  5:51 ` burnus at gcc dot gnu.org
@ 2022-09-26  9:20 ` rguenth at gcc dot gnu.org
  2022-09-29 14:05 ` cvs-commit at gcc dot gnu.org
  2022-09-29 17:35 ` burnus at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-09-26  9:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107028

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.0

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug middle-end/107028] [13 Regression][OpenACC] ICE in install_var_field, at omp-low.cc:797
  2022-09-24 18:58 [Bug middle-end/107028] New: [13 Regression][OpenACC] ICE in install_var_field, at omp-low.cc:797 burnus at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2022-09-26  9:20 ` rguenth at gcc dot gnu.org
@ 2022-09-29 14:05 ` cvs-commit at gcc dot gnu.org
  2022-09-29 17:35 ` burnus at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-09-29 14:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107028

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Julian Brown <jules@gcc.gnu.org>:

https://gcc.gnu.org/g:8ace67ddb97698709a622b2f8ba2718524aa5eeb

commit r13-2957-g8ace67ddb97698709a622b2f8ba2718524aa5eeb
Author: Julian Brown <julian@codesourcery.com>
Date:   Tue Sep 27 17:39:59 2022 +0000

    OpenACC: whole struct vs. component mappings (PR107028)

    This patch fixes an ICE when both a complete struct variable and
    components of that struct are mapped on the same directive for OpenACC,
    using a modified version of the scheme used for OpenMP in the following
    patch:

      https://gcc.gnu.org/pipermail/gcc-patches/2022-September/601558.html

    A new function has been added to make sure that the mapping kinds of
    the whole struct and the member access are compatible -- conservatively,
    so as not to copy more to/from the device than the user expects.

    This version of the patch uses a different method to detect duplicate
    clauses for OpenACC in oacc_resolve_clause_dependencies, and removes
    the now-redundant check in omp_accumulate_sibling_lists.  (The latter
    check would no longer trigger when we map the whole struct on the same
    directive because the component-mapping clauses are now deleted before
    the check is executed.)

    2022-09-28  Julian Brown  <julian@codesourcery.com>

    gcc/
            PR middle-end/107028
            * gimplify.cc (omp_check_mapping_compatibility,
            oacc_resolve_clause_dependencies): New functions.
            (omp_accumulate_sibling_list): Remove redundant duplicate clause
            detection for OpenACC.
            (build_struct_sibling_lists): Skip deleted groups.  Don't build
sibling
            list for struct variables that are fully mapped on the same
directive
            for OpenACC.
            (gimplify_scan_omp_clauses): Call oacc_resolve_clause_dependencies.

    gcc/testsuite/
            PR middle-end/107028
            * c-c++-common/goacc/struct-component-kind-1.c: New test.
            * g++.dg/goacc/pr107028-1.C: New test.
            * g++.dg/goacc/pr107028-2.C: New test.
            * gfortran.dg/goacc/mapping-tests-5.f90: New test.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug middle-end/107028] [13 Regression][OpenACC] ICE in install_var_field, at omp-low.cc:797
  2022-09-24 18:58 [Bug middle-end/107028] New: [13 Regression][OpenACC] ICE in install_var_field, at omp-low.cc:797 burnus at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2022-09-29 14:05 ` cvs-commit at gcc dot gnu.org
@ 2022-09-29 17:35 ` burnus at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2022-09-29 17:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107028

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Close as FIXED - thanks for the patch!

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-09-29 17:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-24 18:58 [Bug middle-end/107028] New: [13 Regression][OpenACC] ICE in install_var_field, at omp-low.cc:797 burnus at gcc dot gnu.org
2022-09-24 21:35 ` [Bug middle-end/107028] " burnus at gcc dot gnu.org
2022-09-25  5:51 ` burnus at gcc dot gnu.org
2022-09-26  9:20 ` rguenth at gcc dot gnu.org
2022-09-29 14:05 ` cvs-commit at gcc dot gnu.org
2022-09-29 17:35 ` burnus at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).