public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/100872] New: [OpenMP] internal compiler error: tree check: expected integer_cst, have mult_expr in simd_clone_clauses_extract, at omp-simd-clone.c:253
@ 2021-06-02  8:22 burnus at gcc dot gnu.org
  2021-06-02 11:03 ` [Bug middle-end/100872] " burnus at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2021-06-02  8:22 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100872
           Summary: [OpenMP] internal compiler error: tree check: expected
                    integer_cst, have mult_expr in
                    simd_clone_clauses_extract, at omp-simd-clone.c:253
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code, openmp
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
                CC: jakub at gcc dot gnu.org
  Target Milestone: ---

Found when compiling clang's OpenMP testsuite for for

* declare_simd_ast_print.cpp:
 
https://github.com/llvm/llvm-project/blob/main/clang/test/OpenMP/declare_simd_ast_print.cpp
* declare_simd_codegen.cpp:
 
https://github.com/llvm/llvm-project/blob/main/clang/test/OpenMP/declare_simd_codegen.cpp


template <int X, typename T>
class TVV {
public:
  #pragma omp declare simd aligned(a : X * 2) aligned(b) linear(ref(b): X)
  float taddpf(float *a, T *&b) { return *a + *b; }
};

TVV<16, float> t16;

void f() {
  float a = 1.0f, b = 2.0f;
  float *p = &b;
  float r = t16.taddpf(&a, p);
}


foo.C:14:1: internal compiler error: tree check: expected integer_cst, have
mult_expr in simd_clone_clauses_extract, at omp-simd-clone.c:253
   14 | }
      | ^
0x8828a4 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ../../repos/gcc/gcc/tree.c:8684
0x97210e tree_int_cst_elt_check(tree_node*, int, char const*, int, char const*)
        ../../repos/gcc/gcc/tree.h:3571
0x97210e simd_clone_clauses_extract
        ../../repos/gcc/gcc/omp-simd-clone.c:253
0x97210e expand_simd_clones(cgraph_node*)
        ../../repos/gcc/gcc/omp-simd-clone.c:1695
0x1cf40a7 ipa_omp_simd_clone
        ../../repos/gcc/gcc/omp-simd-clone.c:1798

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

* [Bug middle-end/100872] [OpenMP] internal compiler error: tree check: expected integer_cst, have mult_expr in simd_clone_clauses_extract, at omp-simd-clone.c:253
  2021-06-02  8:22 [Bug middle-end/100872] New: [OpenMP] internal compiler error: tree check: expected integer_cst, have mult_expr in simd_clone_clauses_extract, at omp-simd-clone.c:253 burnus at gcc dot gnu.org
@ 2021-06-02 11:03 ` burnus at gcc dot gnu.org
  2021-06-02 14:26 ` [Bug middle-end/100872] [12 Regression] " jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2021-06-02 11:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
The problem is that
   aligned(a : X * 2)

In pt.c's apply_late_template_attributes, we have:
 <tree_list 0x7ffff71372f8
    purpose <identifier_node 0x7ffff7131840 operator bindings
        normal local bindings <(nil)>>
    value <tree_list 0x7ffff7137320
        purpose <identifier_node 0x7ffff6fc4400 operator+ tree_2
            simple-op local bindings <(nil)>> value <error_mark
0x7ffff6fabeb8>>
    chain <tree_list 0x7ffff7137118 tree_0
        purpose <identifier_node 0x7ffff71317c0 omp declare simd
            normal local bindings <(nil)>>
        value <tree_list 0x7ffff71370f0
            value <omp_clause 0x7ffff6fb6f30 aligned
                op-0: <integer_cst 0x7ffff6fcc288 1>
                op-1: <mult_expr 0x7ffff71370c8>>>>>

The comment in apply_late_template_attributes states:

  /* save_template_attributes puts the dependent attributes at the beginning of
     the list; find the non-dependent ones.  */
  for (t = attributes; t; t = TREE_CHAIN (t))
    if (!ATTR_IS_DEPENDENT (t))
      break;

But as the first item is !ATTR_IS_DEPEND, attributes == nondep and the
following loop is skipped - also for 'tree_0', which contains our 'omp declare
simd':

  for (t = attributes; t != nondep; t = TREE_CHAIN (t))
    {
      *q = tsubst_attribute (t, decl_p, args, complain, in_decl);

The latter, i.e. 'tree_0' has a proper
43480               ATTR_IS_DEPENDENT (c) = 1;
set in cp_parser_late_parsing_omp_declare_simd.

However, the problem seems to be that save_template_attributes is never run for
the fndel.

* It is run for 'class TVV' itself.
* And then there is the call:
  tsubst_decl -> tsubst_function_decl
  -> apply_late_template_attributes
  which has the tree as shown above.

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

* [Bug middle-end/100872] [12 Regression] [OpenMP] internal compiler error: tree check: expected integer_cst, have mult_expr in simd_clone_clauses_extract, at omp-simd-clone.c:253
  2021-06-02  8:22 [Bug middle-end/100872] New: [OpenMP] internal compiler error: tree check: expected integer_cst, have mult_expr in simd_clone_clauses_extract, at omp-simd-clone.c:253 burnus at gcc dot gnu.org
  2021-06-02 11:03 ` [Bug middle-end/100872] " burnus at gcc dot gnu.org
@ 2021-06-02 14:26 ` jakub at gcc dot gnu.org
  2021-06-02 14:26 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-06-02 14:26 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-06-02
     Ever confirmed|0                           |1
   Target Milestone|---                         |12.0
            Summary|[OpenMP] internal compiler  |[12 Regression] [OpenMP]
                   |error: tree check: expected |internal compiler error:
                   |integer_cst, have mult_expr |tree check: expected
                   |in                          |integer_cst, have mult_expr
                   |simd_clone_clauses_extract, |in
                   |at omp-simd-clone.c:253     |simd_clone_clauses_extract,
                   |                            |at omp-simd-clone.c:253

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with the PR51577 fix r12-702-g6ab1176667734bd6de20833f8d263c03a418c452

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

* [Bug middle-end/100872] [12 Regression] [OpenMP] internal compiler error: tree check: expected integer_cst, have mult_expr in simd_clone_clauses_extract, at omp-simd-clone.c:253
  2021-06-02  8:22 [Bug middle-end/100872] New: [OpenMP] internal compiler error: tree check: expected integer_cst, have mult_expr in simd_clone_clauses_extract, at omp-simd-clone.c:253 burnus at gcc dot gnu.org
  2021-06-02 11:03 ` [Bug middle-end/100872] " burnus at gcc dot gnu.org
  2021-06-02 14:26 ` [Bug middle-end/100872] [12 Regression] " jakub at gcc dot gnu.org
@ 2021-06-02 14:26 ` jakub at gcc dot gnu.org
  2021-06-04  9:17 ` cvs-commit at gcc dot gnu.org
  2021-06-04  9:21 ` jakub at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-06-02 14:26 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 50909
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50909&action=edit
gcc12-pr100872.patch

Untested fix.

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

* [Bug middle-end/100872] [12 Regression] [OpenMP] internal compiler error: tree check: expected integer_cst, have mult_expr in simd_clone_clauses_extract, at omp-simd-clone.c:253
  2021-06-02  8:22 [Bug middle-end/100872] New: [OpenMP] internal compiler error: tree check: expected integer_cst, have mult_expr in simd_clone_clauses_extract, at omp-simd-clone.c:253 burnus at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-06-02 14:26 ` jakub at gcc dot gnu.org
@ 2021-06-04  9:17 ` cvs-commit at gcc dot gnu.org
  2021-06-04  9:21 ` jakub at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-06-04  9:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:3011f1046628d5ce5e6e5f8e917a6aea1385fdc3

commit r12-1204-g3011f1046628d5ce5e6e5f8e917a6aea1385fdc3
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Jun 4 11:17:05 2021 +0200

    c++: Fix up attribute handling in methods in templates [PR100872]

    The following testcase FAILs because a dependent (late) attribute is never
    tsubsted.  While the testcase is OpenMP, I think it is a generic C++ FE
problem
    that could affect any other dependent attribute.

    apply_late_template_attributes documents that it relies on
      /* save_template_attributes puts the dependent attributes at the
beginning of
         the list; find the non-dependent ones.  */
    The "operator binding" attributes that are sometimes added are added to the
    head of DECL_ATTRIBUTES list though and because it doesn't have
    ATTR_IS_DEPENDENT set it violates this requirement.

    The following patch fixes it by adding that attribute after all
    ATTR_IS_DEPENDENT attributes.  I'm not 100% sure if DECL_ATTRIBUTES can't
be
    shared by multiple functions (e.g. the cdtor clones), but the code uses
    later remove_attribute which could break that too.

    Other option would be to copy_list the ATTR_IS_DEPENDENT portion of the
    DECL_ATTRIBUTES list if we need to do this, that would be the same as this
    patch but replace that *ap = op_attr; at the end with
          *ap = NULL_TREE;
          DECL_ATTRIBUTES (cfn) = chainon (copy_list (DECL_ATTRIBUTES (cfn)),
                                           op_attr);
    Or perhaps set ATTR_IS_DEPENDENT on the "operator bindings" attribute,
    though it would need to be studied what would it try to do with the
    attribute during tsubst.

    2021-06-04  Jakub Jelinek  <jakub@redhat.com>

            PR c++/100872
            * name-lookup.c (maybe_save_operator_binding): Add op_attr after
all
            ATTR_IS_DEPENDENT attributes in the DECL_ATTRIBUTES list rather
than
            to the start.

            * g++.dg/gomp/declare-simd-8.C: New test.

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

* [Bug middle-end/100872] [12 Regression] [OpenMP] internal compiler error: tree check: expected integer_cst, have mult_expr in simd_clone_clauses_extract, at omp-simd-clone.c:253
  2021-06-02  8:22 [Bug middle-end/100872] New: [OpenMP] internal compiler error: tree check: expected integer_cst, have mult_expr in simd_clone_clauses_extract, at omp-simd-clone.c:253 burnus at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-06-04  9:17 ` cvs-commit at gcc dot gnu.org
@ 2021-06-04  9:21 ` jakub at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-06-04  9:21 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

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

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2021-06-04  9:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-02  8:22 [Bug middle-end/100872] New: [OpenMP] internal compiler error: tree check: expected integer_cst, have mult_expr in simd_clone_clauses_extract, at omp-simd-clone.c:253 burnus at gcc dot gnu.org
2021-06-02 11:03 ` [Bug middle-end/100872] " burnus at gcc dot gnu.org
2021-06-02 14:26 ` [Bug middle-end/100872] [12 Regression] " jakub at gcc dot gnu.org
2021-06-02 14:26 ` jakub at gcc dot gnu.org
2021-06-04  9:17 ` cvs-commit at gcc dot gnu.org
2021-06-04  9:21 ` jakub 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).