public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/104880] New: regression ICE in expand_expr_addr_expr_1, at expr.c:8231
@ 2022-03-11 11:31 dimitar.yordanov at sap dot com
  2022-03-11 12:29 ` [Bug middle-end/104880] [11/12 Regression] ICE in expand_expr_addr_expr_1, at expr.c:8231 since r11-165-geb72dc663e9070 marxin at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: dimitar.yordanov at sap dot com @ 2022-03-11 11:31 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104880
           Summary: regression ICE in expand_expr_addr_expr_1, at
                    expr.c:8231
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dimitar.yordanov at sap dot com
  Target Milestone: ---

Hi,

I hit an ICE with the following reduced example:

cat > foo.cc << EOF

class c {
  long b;
};
class B {
public:
  typedef void *d;
};
class aa {
public:
  aa(B::d, char *);
};
class e : public B {
public:
  e();
};
__uint128_t f;
struct g {
  struct h : c {
    h(__uint128_t &i) : c(reinterpret_cast<c &>(i)) {}
    __uint128_t ad();
  };
};
class n : g {
public:
  n(int);
  void j() {
    __uint128_t a;
    h k(a);
    __atomic_compare_exchange_n(&f, &a, k.ad(), true, 3, 0);
  }
};
int l;
class m : e {
  void ar() {
    n b(l);
    b.j();
  }
  virtual c bd() { aa(d(&m::ar), ""); }
};
void o() { new m; }

EOF

g++ -mcx16 -O2 -c foo.cc

during RTL pass: expand
foo.cc: In member function ‘void m::ar()’:
foo.cc:29:32: internal compiler error: in expand_expr_addr_expr_1, at
expr.c:8231
   29 |     __atomic_compare_exchange_n(&f, &a, k.ad(), true, 3, 0);

Regression appeared first with:

https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=eb72dc663e9070b281be83a80f6f838a3a878822

Best regards
Dimitar

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

* [Bug middle-end/104880] [11/12 Regression] ICE in expand_expr_addr_expr_1, at expr.c:8231 since r11-165-geb72dc663e9070
  2022-03-11 11:31 [Bug middle-end/104880] New: regression ICE in expand_expr_addr_expr_1, at expr.c:8231 dimitar.yordanov at sap dot com
@ 2022-03-11 12:29 ` marxin at gcc dot gnu.org
  2022-03-11 12:53 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-03-11 12:29 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|regression ICE in           |[11/12 Regression] ICE in
                   |expand_expr_addr_expr_1, at |expand_expr_addr_expr_1, at
                   |expr.c:8231                 |expr.c:8231 since
                   |                            |r11-165-geb72dc663e9070
             Status|UNCONFIRMED                 |NEW
   Target Milestone|---                         |11.3
   Last reconfirmed|                            |2022-03-11
                 CC|                            |marxin at gcc dot gnu.org,
                   |                            |rguenth at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Thanks for the report.

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

* [Bug middle-end/104880] [11/12 Regression] ICE in expand_expr_addr_expr_1, at expr.c:8231 since r11-165-geb72dc663e9070
  2022-03-11 11:31 [Bug middle-end/104880] New: regression ICE in expand_expr_addr_expr_1, at expr.c:8231 dimitar.yordanov at sap dot com
  2022-03-11 12:29 ` [Bug middle-end/104880] [11/12 Regression] ICE in expand_expr_addr_expr_1, at expr.c:8231 since r11-165-geb72dc663e9070 marxin at gcc dot gnu.org
@ 2022-03-11 12:53 ` rguenth at gcc dot gnu.org
  2022-03-11 14:03 ` [Bug middle-end/104880] [11 " cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-03-11 12:53 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
           Keywords|                            |ice-on-valid-code

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Interestingly it only fails with -fno-checking, with -fchecking it works fine.

A diff -fchecking vs -fno-checking reveals

--- a/t.cc.031t.einline 2022-03-11 13:42:58.925057781 +0100
+++ b/t.cc.031t.einline 2022-03-11 13:43:04.713135650 +0100
@@ -47,25 +47,25 @@
 void n::j (struct n * const this)
 {
   struct h k(address-taken);
-  __int128 unsigned a(address-taken);
+  __int128 unsigned a;
   __int128 unsigned _1;
   __int128 unsigned _5;

   <bb 2> :
   k(address-taken) ={v} {CLOBBER};
-  k(address-taken).D.2425 = MEM[(const struct c &)&a(address-taken)];
+  k(address-taken).D.2425 = MEM[(const struct c &)&a];
   _5 = g::h::ad (&k(address-taken));

   <bb 3> :
   _1 = _5;
-  __atomic_compare_exchange_16 (&f(address-taken), &a(address-taken), _1, 1,
3, 0);
-  a(address-taken) ={v} {CLOBBER(eol)};
+  __atomic_compare_exchange_16 (&f(address-taken), &a, _1, 1, 3, 0);
+  a ={v} {CLOBBER(eol)};
   k(address-taken) ={v} {CLOBBER(eol)};
   return;

   <bb 4> :
 <L0>:
-  a(address-taken) ={v} {CLOBBER(eol)};
+  a ={v} {CLOBBER(eol)};
   k(address-taken) ={v} {CLOBBER(eol)};
   resx 1

where the -fno-checking case loses the TREE_ADDRESSABLE flag as part of
early inlining.  We have

              if (optimize_atomic_compare_exchange_p (stmt))
                {
                  /* For __atomic_compare_exchange_N if the second argument
                     is &var, don't mark var addressable;
                     if it becomes non-addressable, we'll rewrite it into
                     ATOMIC_COMPARE_EXCHANGE call.  */
                  tree arg = gimple_call_arg (stmt, 1);
                  gimple_call_set_arg (stmt, 1, null_pointer_node);
                  gimple_ior_addresses_taken (addresses_taken, stmt);
                  gimple_call_set_arg (stmt, 1, arg);
                }

but that rewriting doesn't actually happen, that's because 'a' has partial
defs (but we cannot rely on that here).  So this optimization looks
premature.  What restores the TREE_ADDRESSABLE bit with -fchecking is
verify_ssa_operands which also fails to diagnose a missing bit
(and to restore the non-set status here).

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

* [Bug middle-end/104880] [11 Regression] ICE in expand_expr_addr_expr_1, at expr.c:8231 since r11-165-geb72dc663e9070
  2022-03-11 11:31 [Bug middle-end/104880] New: regression ICE in expand_expr_addr_expr_1, at expr.c:8231 dimitar.yordanov at sap dot com
  2022-03-11 12:29 ` [Bug middle-end/104880] [11/12 Regression] ICE in expand_expr_addr_expr_1, at expr.c:8231 since r11-165-geb72dc663e9070 marxin at gcc dot gnu.org
  2022-03-11 12:53 ` rguenth at gcc dot gnu.org
@ 2022-03-11 14:03 ` cvs-commit at gcc dot gnu.org
  2022-03-14 16:25 ` dimitar.yordanov at sap dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-11 14:03 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

commit r12-7613-geb5edcf3f3ae008a1c55c88f08a886a5f350a759
Author: Richard Biener <rguenther@suse.de>
Date:   Fri Mar 11 14:09:33 2022 +0100

    tree-optimization/104880 - update-address-taken and cmpxchg

    The following addresses optimistic non-addressable marking of
    an argument of __atomic_compare_exchange_n which broke when
    I added DECL_NOT_GIMPLE_REG_P since we cannot guarantee we can
    rewrite it when TREE_ADDRESSABLE is unset.  Instead we have to
    restore TREE_ADDRESSABLE in that case.

    2022-03-11  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/104880
            * tree-ssa.cc (execute_update_address_taken): Remember if we
            optimistically made something not addressable and
            prepare to undo it.

            * g++.dg/opt/pr104880.cc: New testcase.

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

* [Bug middle-end/104880] [11 Regression] ICE in expand_expr_addr_expr_1, at expr.c:8231 since r11-165-geb72dc663e9070
  2022-03-11 11:31 [Bug middle-end/104880] New: regression ICE in expand_expr_addr_expr_1, at expr.c:8231 dimitar.yordanov at sap dot com
                   ` (2 preceding siblings ...)
  2022-03-11 14:03 ` [Bug middle-end/104880] [11 " cvs-commit at gcc dot gnu.org
@ 2022-03-14 16:25 ` dimitar.yordanov at sap dot com
  2022-04-07  8:58 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: dimitar.yordanov at sap dot com @ 2022-03-14 16:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Dimitar Yordanov <dimitar.yordanov at sap dot com> ---
Thanks, works for me!

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

* [Bug middle-end/104880] [11 Regression] ICE in expand_expr_addr_expr_1, at expr.c:8231 since r11-165-geb72dc663e9070
  2022-03-11 11:31 [Bug middle-end/104880] New: regression ICE in expand_expr_addr_expr_1, at expr.c:8231 dimitar.yordanov at sap dot com
                   ` (3 preceding siblings ...)
  2022-03-14 16:25 ` dimitar.yordanov at sap dot com
@ 2022-04-07  8:58 ` cvs-commit at gcc dot gnu.org
  2022-04-07  8:59 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-07  8:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:

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

commit r11-9780-gcf6c812718673cbf89bb96fb2427ee9923bf2a90
Author: Richard Biener <rguenther@suse.de>
Date:   Fri Mar 11 14:09:33 2022 +0100

    tree-optimization/104880 - update-address-taken and cmpxchg

    The following addresses optimistic non-addressable marking of
    an argument of __atomic_compare_exchange_n which broke when
    I added DECL_NOT_GIMPLE_REG_P since we cannot guarantee we can
    rewrite it when TREE_ADDRESSABLE is unset.  Instead we have to
    restore TREE_ADDRESSABLE in that case.

    2022-03-11  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/104880
            * tree-ssa.c (execute_update_address_taken): Remember if we
            optimistically made something not addressable and
            prepare to undo it.

            * g++.dg/opt/pr104880.cc: New testcase.

    (cherry picked from commit eb5edcf3f3ae008a1c55c88f08a886a5f350a759)

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

* [Bug middle-end/104880] [11 Regression] ICE in expand_expr_addr_expr_1, at expr.c:8231 since r11-165-geb72dc663e9070
  2022-03-11 11:31 [Bug middle-end/104880] New: regression ICE in expand_expr_addr_expr_1, at expr.c:8231 dimitar.yordanov at sap dot com
                   ` (4 preceding siblings ...)
  2022-04-07  8:58 ` cvs-commit at gcc dot gnu.org
@ 2022-04-07  8:59 ` rguenth at gcc dot gnu.org
  2022-04-19 12:31 ` cvs-commit at gcc dot gnu.org
  2022-04-19 12:32 ` cvs-commit at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-04-07  8:59 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |11.2.0
         Resolution|---                         |FIXED
      Known to work|                            |11.2.1
             Status|ASSIGNED                    |RESOLVED

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.

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

* [Bug middle-end/104880] [11 Regression] ICE in expand_expr_addr_expr_1, at expr.c:8231 since r11-165-geb72dc663e9070
  2022-03-11 11:31 [Bug middle-end/104880] New: regression ICE in expand_expr_addr_expr_1, at expr.c:8231 dimitar.yordanov at sap dot com
                   ` (5 preceding siblings ...)
  2022-04-07  8:59 ` rguenth at gcc dot gnu.org
@ 2022-04-19 12:31 ` cvs-commit at gcc dot gnu.org
  2022-04-19 12:32 ` cvs-commit at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-19 12:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:214d2860f4e1573f04ef57bfea59da0cc66883ce

commit r12-8192-g214d2860f4e1573f04ef57bfea59da0cc66883ce
Author: Richard Biener <rguenther@suse.de>
Date:   Tue Apr 19 13:48:02 2022 +0200

    tree-optimization/104880 - move testcase

    This renames the testcase to something picked up by the suites regexp.

    2022-04-19  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/104880
            * g++.dg/opt/pr104880.cc: Rename to ...
            * g++.dg/opt/pr104880.C: ... this.

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

* [Bug middle-end/104880] [11 Regression] ICE in expand_expr_addr_expr_1, at expr.c:8231 since r11-165-geb72dc663e9070
  2022-03-11 11:31 [Bug middle-end/104880] New: regression ICE in expand_expr_addr_expr_1, at expr.c:8231 dimitar.yordanov at sap dot com
                   ` (6 preceding siblings ...)
  2022-04-19 12:31 ` cvs-commit at gcc dot gnu.org
@ 2022-04-19 12:32 ` cvs-commit at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-19 12:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:4b790d6e2e3d886e3116bd5591d57b29dc059910

commit r11-9887-g4b790d6e2e3d886e3116bd5591d57b29dc059910
Author: Richard Biener <rguenther@suse.de>
Date:   Tue Apr 19 13:48:02 2022 +0200

    tree-optimization/104880 - move testcase

    This renames the testcase to something picked up by the suites regexp.

    2022-04-19  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/104880
            * g++.dg/opt/pr104880.cc: Rename to ...
            * g++.dg/opt/pr104880.C: ... this.

    (cherry picked from commit 214d2860f4e1573f04ef57bfea59da0cc66883ce)

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

end of thread, other threads:[~2022-04-19 12:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-11 11:31 [Bug middle-end/104880] New: regression ICE in expand_expr_addr_expr_1, at expr.c:8231 dimitar.yordanov at sap dot com
2022-03-11 12:29 ` [Bug middle-end/104880] [11/12 Regression] ICE in expand_expr_addr_expr_1, at expr.c:8231 since r11-165-geb72dc663e9070 marxin at gcc dot gnu.org
2022-03-11 12:53 ` rguenth at gcc dot gnu.org
2022-03-11 14:03 ` [Bug middle-end/104880] [11 " cvs-commit at gcc dot gnu.org
2022-03-14 16:25 ` dimitar.yordanov at sap dot com
2022-04-07  8:58 ` cvs-commit at gcc dot gnu.org
2022-04-07  8:59 ` rguenth at gcc dot gnu.org
2022-04-19 12:31 ` cvs-commit at gcc dot gnu.org
2022-04-19 12:32 ` cvs-commit 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).