public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98991] New: ICE: Max. number of generated reload insns per insn is achieved (90)
@ 2021-02-07 23:00 zhan3299 at purdue dot edu
  2021-02-08  9:06 ` [Bug c++/98991] " marxin at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: zhan3299 at purdue dot edu @ 2021-02-07 23:00 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98991
           Summary: ICE: Max. number of generated reload insns per insn is
                    achieved (90)
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhan3299 at purdue dot edu
  Target Milestone: ---

Created attachment 50140
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50140&action=edit
poc.cc

Hi all,

I am not sure whether it is indeed an ICE, so I do apologize in advance for any
possible inconvenience. 

I have a file generated by my little toy fuzzer, named poc.cc.

When I compile it with: "g++ poc.cc -fpermissive", I got an "internal compiler
error: Max. number of generated reload insns per insn is achieved (90)".

Followings are the detailed information.

--- poc.cc starts ---
namespace{thread_local;__attribute((e()))n(){int;long;float
f;__attribute(())((((__builtin_constant_p(0)))==0));try{}catch(int){}sizeof(reinterpret_cast<int>(0));asm("":"=rmf"(f),"=d"([t(reinterpret_cast<int>(0))]{}):"0"(((0))),""((0)));static_assert(1);__attribute(())class{}t;{__builtin_unreachable;int{reinterpret_cast<int>(0)};(&f);}}y(){float;}}short;namespace{int;template<typename>f(){}}struct
s;
--- poc.cc ends ---


--- md5 of poc.cc starts ---
c11f34bb78474a2a8bdcb5c5de6d19a2 
--- md5 of poc.cc ends ---


--- error trace starts ---
$ ./xg++ poc.cc -fpermissive

poc.cc:1:11: warning: declaration does not declare anything [-fpermissive]
    1 | namespace{thread_local;__attribute((e()))n(){int;long;float
f;__attribute(())((((__builtin_constant_p(0)))==0));try{}catch(int){}sizeof(reinterpret_cast<int>(0));asm("":"=rmf"(f),"=d"([t(reinterpret_cast<int>(0))]{}):"0"(((0))),""((0)));static_assert(1);__attribute(())class{}t;{__builtin_unreachable;int{reinterpret_cast<int>(0)};(&f);}}y(){float;}}short;namespace{int;template<typename>f(){}}struct
s;
      |           ^~~~~~~~~~~~
poc.cc:1:42: warning: ISO C++ forbids declaration of ‘n’ with no type
[-fpermissive]
    1 | namespace{thread_local;__attribute((e()))n(){int;long;float
f;__attribute(())((((__builtin_constant_p(0)))==0));try{}catch(int){}sizeof(reinterpret_cast<int>(0));asm("":"=rmf"(f),"=d"([t(reinterpret_cast<int>(0))]{}):"0"(((0))),""((0)));static_assert(1);__attribute(())class{}t;{__builtin_unreachable;int{reinterpret_cast<int>(0)};(&f);}}y(){float;}}short;namespace{int;template<typename>f(){}}struct
s;
      |                                          ^
poc.cc:1:44: warning: ‘e’ attribute directive ignored [-Wattributes]
    1 | namespace{thread_local;__attribute((e()))n(){int;long;float
f;__attribute(())((((__builtin_constant_p(0)))==0));try{}catch(int){}sizeof(reinterpret_cast<int>(0));asm("":"=rmf"(f),"=d"([t(reinterpret_cast<int>(0))]{}):"0"(((0))),""((0)));static_assert(1);__attribute(())class{}t;{__builtin_unreachable;int{reinterpret_cast<int>(0)};(&f);}}y(){float;}}short;namespace{int;template<typename>f(){}}struct
s;
      |                                            ^
poc.cc: In function ‘int {anonymous}::n()’:
poc.cc:1:46: warning: declaration does not declare anything [-fpermissive]
    1 | namespace{thread_local;__attribute((e()))n(){int;long;float
f;__attribute(())((((__builtin_constant_p(0)))==0));try{}catch(int){}sizeof(reinterpret_cast<int>(0));asm("":"=rmf"(f),"=d"([t(reinterpret_cast<int>(0))]{}):"0"(((0))),""((0)));static_assert(1);__attribute(())class{}t;{__builtin_unreachable;int{reinterpret_cast<int>(0)};(&f);}}y(){float;}}short;namespace{int;template<typename>f(){}}struct
s;
      |                                              ^~~
poc.cc:1:50: warning: declaration does not declare anything [-fpermissive]
    1 | namespace{thread_local;__attribute((e()))n(){int;long;float
f;__attribute(())((((__builtin_constant_p(0)))==0));try{}catch(int){}sizeof(reinterpret_cast<int>(0));asm("":"=rmf"(f),"=d"([t(reinterpret_cast<int>(0))]{}):"0"(((0))),""((0)));static_assert(1);__attribute(())class{}t;{__builtin_unreachable;int{reinterpret_cast<int>(0)};(&f);}}y(){float;}}short;namespace{int;template<typename>f(){}}struct
s;
      |                                                  ^~~~
poc.cc:1:237: warning: using rvalue as lvalue [-fpermissive]
    1 | ocal;__attribute((e()))n(){int;long;float
f;__attribute(())((((__builtin_constant_p(0)))==0));try{}catch(int){}sizeof(reinterpret_cast<int>(0));asm("":"=rmf"(f),"=d"([t(reinterpret_cast<int>(0))]{}):"0"(((0))),""((0)));static_assert(1);__attribute(())class{}t;{__builtin_unreachable;int{reinterpret_cast<int>(0)};(&f);}}y(){float;}}short;namespace{int;template<typename>f(){}}struct
s;
      |                                                                        
                                                                               
                                                                  ^

poc.cc:1:338: warning: no return statement in function returning non-void
[-Wreturn-type]
    1 |
tch(int){}sizeof(reinterpret_cast<int>(0));asm("":"=rmf"(f),"=d"([t(reinterpret_cast<int>(0))]{}):"0"(((0))),""((0)));static_assert(1);__attribute(())class{}t;{__builtin_unreachable;int{reinterpret_cast<int>(0)};(&f);}}y(){float;}}short;namespace{int;template<typename>f(){}}struct
s;
      |                                                                        
                                                                               
                                                                  ^

poc.cc: At global scope:
poc.cc:1:339: warning: ISO C++ forbids declaration of ‘y’ with no type
[-fpermissive]
    1 |
ch(int){}sizeof(reinterpret_cast<int>(0));asm("":"=rmf"(f),"=d"([t(reinterpret_cast<int>(0))]{}):"0"(((0))),""((0)));static_assert(1);__attribute(())class{}t;{__builtin_unreachable;int{reinterpret_cast<int>(0)};(&f);}}y(){float;}}short;namespace{int;template<typename>f(){}}struct
s;
      |                                                                        
                                                                               
                                                                  ^

poc.cc: In function ‘int {anonymous}::y()’:
poc.cc:1:343: warning: declaration does not declare anything [-fpermissive]
    1 |
nt){}sizeof(reinterpret_cast<int>(0));asm("":"=rmf"(f),"=d"([t(reinterpret_cast<int>(0))]{}):"0"(((0))),""((0)));static_assert(1);__attribute(())class{}t;{__builtin_unreachable;int{reinterpret_cast<int>(0)};(&f);}}y(){float;}}short;namespace{int;template<typename>f(){}}struct
s;
      |                                                                        
                                                                               
                                                                  ^~~~~

poc.cc:1:349: warning: no return statement in function returning non-void
[-Wreturn-type]
    1 |
izeof(reinterpret_cast<int>(0));asm("":"=rmf"(f),"=d"([t(reinterpret_cast<int>(0))]{}):"0"(((0))),""((0)));static_assert(1);__attribute(())class{}t;{__builtin_unreachable;int{reinterpret_cast<int>(0)};(&f);}}y(){float;}}short;namespace{int;template<typename>f(){}}struct
s;
      |                                                                        
                                                                               
                                                                  ^

poc.cc: At global scope:
poc.cc:1:351: warning: declaration does not declare anything [-fpermissive]
    1 |
eof(reinterpret_cast<int>(0));asm("":"=rmf"(f),"=d"([t(reinterpret_cast<int>(0))]{}):"0"(((0))),""((0)));static_assert(1);__attribute(())class{}t;{__builtin_unreachable;int{reinterpret_cast<int>(0)};(&f);}}y(){float;}}short;namespace{int;template<typename>f(){}}struct
s;
      |                                                                        
                                                                               
                                                                  ^~~~~

poc.cc:1:367: warning: declaration does not declare anything [-fpermissive]
    1 |
cast<int>(0));asm("":"=rmf"(f),"=d"([t(reinterpret_cast<int>(0))]{}):"0"(((0))),""((0)));static_assert(1);__attribute(())class{}t;{__builtin_unreachable;int{reinterpret_cast<int>(0)};(&f);}}y(){float;}}short;namespace{int;template<typename>f(){}}struct
s;
      |                                                                        
                                                                               
                                                                  ^~~

poc.cc:1:389: warning: ISO C++ forbids declaration of ‘f’ with no type
[-fpermissive]
    1 |
=rmf"(f),"=d"([t(reinterpret_cast<int>(0))]{}):"0"(((0))),""((0)));static_assert(1);__attribute(())class{}t;{__builtin_unreachable;int{reinterpret_cast<int>(0)};(&f);}}y(){float;}}short;namespace{int;template<typename>f(){}}struct
s;
      |                                                                        
                                                                               
                                                                  ^

poc.cc: In function ‘int {anonymous}::f()’:
poc.cc:1:393: warning: no return statement in function returning non-void
[-Wreturn-type]
    1 |
"(f),"=d"([t(reinterpret_cast<int>(0))]{}):"0"(((0))),""((0)));static_assert(1);__attribute(())class{}t;{__builtin_unreachable;int{reinterpret_cast<int>(0)};(&f);}}y(){float;}}short;namespace{int;template<typename>f(){}}struct
s;
      |                                                                        
                                                                               
                                                                  ^

during RTL pass: reload
poc.cc: In function ‘int {anonymous}::n()’:
poc.cc:1:338: internal compiler error: maximum number of generated reload insns
per insn achieved (90)
    1 |
tch(int){}sizeof(reinterpret_cast<int>(0));asm("":"=rmf"(f),"=d"([t(reinterpret_cast<int>(0))]{}):"0"(((0))),""((0)));static_assert(1);__attribute(())class{}t;{__builtin_unreachable;int{reinterpret_cast<int>(0)};(&f);}}y(){float;}}short;namespace{int;template<typename>f(){}}struct
s;
      |                                                                        
                                                                               
                                                                  ^

0xb37790 lra_constraints(bool)
        ../../gcc/gcc/lra-constraints.c:4952
0xb259e4 lra(_IO_FILE*)
        ../../gcc/gcc/lra.c:2440
0xae38d1 do_reload
        ../../gcc/gcc/ira.c:5523
0xae38d1 execute
        ../../gcc/gcc/ira.c:5709
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
--- error trace ends ---

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

* [Bug c++/98991] ICE: Max. number of generated reload insns per insn is achieved (90)
  2021-02-07 23:00 [Bug c++/98991] New: ICE: Max. number of generated reload insns per insn is achieved (90) zhan3299 at purdue dot edu
@ 2021-02-08  9:06 ` marxin at gcc dot gnu.org
  2021-02-08  9:34 ` [Bug inline-asm/98991] " rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-02-08  9:06 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marxin at gcc dot gnu.org
   Last reconfirmed|                            |2021-02-08
             Status|UNCONFIRMED                 |WAITING
     Ever confirmed|0                           |1

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Is it a valid or invalid code, please?

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

* [Bug inline-asm/98991] ICE: Max. number of generated reload insns per insn is achieved (90)
  2021-02-07 23:00 [Bug c++/98991] New: ICE: Max. number of generated reload insns per insn is achieved (90) zhan3299 at purdue dot edu
  2021-02-08  9:06 ` [Bug c++/98991] " marxin at gcc dot gnu.org
@ 2021-02-08  9:34 ` rguenth at gcc dot gnu.org
  2021-02-08 15:31 ` zhan3299 at purdue dot edu
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-02-08  9:34 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid
          Component|c++                         |inline-asm

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
it looks reduced ad absurdum but the issue must lie in

 asm("":"=rmf"(f),"=d"([t(reinterpret_cast<int>(0))]{}):"0"(((0))),""((0)));

which I can't really parse but we expand from

int {anonymous}::n ()
{
  int D.2351;
  struct ._anon_1 t;
  float f;
  int D.2422;
  struct ._anon_0 D.2374;
  register int * D.2360;
  void * _1;
  int _5;

;;   basic block 2, loop depth 0
;;    pred:       ENTRY
  D.2374.__t = 0;
  __asm__("" : "=rmf" f, "=d" D.2374 : "0" 0, "" 0);

likely D.2374 is not re-loadable into DREG.  The zero seems to be SFmode:

(insn 6 2 7 2 (set (reg:SI 86)
        (const_int 0 [0])) "t.ii":1:163 75 {*movsi_internal}
     (nil))
(insn 7 6 11 2 (parallel [
            (set (mem/c:SF (plus:DI (reg/f:DI 19 frame)
                        (const_int -4 [0xfffffffffffffffc])) [1 f+0 S4 A32])
                (asm_operands:SF ("") ("=rmf") 0 [
                        (reg:SI 86)
                        (const_int 0 [0])
                    ]
                     [
                        (asm_input:SI ("0") t.ii:1)
                        (asm_input:SI ("") t.ii:1)
                    ]
                     [] t.ii:1))
            (set (reg:SI 84 [ D.2374 ])
                (asm_operands:SI ("") ("=d") 1 [
                        (reg:SI 86)
                        (const_int 0 [0])
                    ]
                     [
                        (asm_input:SI ("0") t.ii:1)
                        (asm_input:SI ("") t.ii:1)
                    ]
                     [] t.ii:1))
            (clobber (reg:CC 17 flags))
        ]) "t.ii":1:163 -1
     (expr_list:REG_DEAD (reg:SI 86)
        (expr_list:REG_UNUSED (reg:SI 84 [ D.2374 ])
            (expr_list:REG_UNUSED (reg:CC 17 flags)
                (nil)))))

and we fail to reload.  It _looks_ similar to

void foo(float f)
{
  struct { float f; } x;
  asm("": "=f" (f), "=d" (x) : "0" (0), "" (0));
}

but we reject this via

t.i: In function 'void foo(float)':
t.i:4:3: error: inconsistent operand constraints in an 'asm'
    4 |   asm("": "=f" (f), "=d" (x) : "0" (0), "" (0));
      |   ^~~

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

* [Bug inline-asm/98991] ICE: Max. number of generated reload insns per insn is achieved (90)
  2021-02-07 23:00 [Bug c++/98991] New: ICE: Max. number of generated reload insns per insn is achieved (90) zhan3299 at purdue dot edu
  2021-02-08  9:06 ` [Bug c++/98991] " marxin at gcc dot gnu.org
  2021-02-08  9:34 ` [Bug inline-asm/98991] " rguenth at gcc dot gnu.org
@ 2021-02-08 15:31 ` zhan3299 at purdue dot edu
  2021-02-08 15:36 ` zhan3299 at purdue dot edu
  2021-09-14  7:34 ` [Bug target/98991] " pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: zhan3299 at purdue dot edu @ 2021-02-08 15:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from zhan3299 at purdue dot edu ---
(In reply to Martin Liška from comment #1)
> Is it a valid or invalid code, please?

Hi, sorry for the confusion. I used a simple delta debugging to reduce the
test-case, and it seems very confused.

Currently, I use C-Reduce to get a simple test-case:


--- poc.cc starts ---
void a() {
  float b;
  asm("" : "=rmf"(b) : "0"(0));
  &b;
}
--- poc.cc ends ---


run 'gcc poc.cc -fpermissive' and we can get the same ICE.


--- error trace starts ---
during RTL pass: reload
poc.cc: In function 'void a()':
poc.cc:5:1: internal compiler error: maximum number of generated reload insns
per insn achieved (90)
    5 | }
      | ^
0x20cb324 lra_constraints(bool)
        ../../gcc/gcc/lra-constraints.c:4951
0x20ab2c8 lra(_IO_FILE*)
        ../../gcc/gcc/lra.c:2440
0x1ff80de do_reload()
        ../../gcc/gcc/ira.c:5523
0x1ff80de (anonymous namespace)::pass_reload::execute(function*)
        ../../gcc/gcc/ira.c:5709
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
--- error trace ends ---


I test it with gcc 10.2.0, but it seems my native 7.5.0 also failed.

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

* [Bug inline-asm/98991] ICE: Max. number of generated reload insns per insn is achieved (90)
  2021-02-07 23:00 [Bug c++/98991] New: ICE: Max. number of generated reload insns per insn is achieved (90) zhan3299 at purdue dot edu
                   ` (2 preceding siblings ...)
  2021-02-08 15:31 ` zhan3299 at purdue dot edu
@ 2021-02-08 15:36 ` zhan3299 at purdue dot edu
  2021-09-14  7:34 ` [Bug target/98991] " pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: zhan3299 at purdue dot edu @ 2021-02-08 15:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from zhan3299 at purdue dot edu ---
Seems '-fpermissive' is useless. I can reproduce the ICE simply via 'gcc
poc.cc'

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

* [Bug target/98991] ICE: Max. number of generated reload insns per insn is achieved (90)
  2021-02-07 23:00 [Bug c++/98991] New: ICE: Max. number of generated reload insns per insn is achieved (90) zhan3299 at purdue dot edu
                   ` (3 preceding siblings ...)
  2021-02-08 15:36 ` zhan3299 at purdue dot edu
@ 2021-09-14  7:34 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-14  7:34 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW
          Component|inline-asm                  |target

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Small testcase which ICEs all the back to GCC 4.1.2:
void g(float*);
void n()
{
    float f;
    int t;
    asm("":"=rmf"(f):"0"(0));
    g(&f);
}

The ICE between 4.4 and 4.7 is:
<source>: In function 'n':
<source>:8:1: internal compiler error: in inline_secondary_memory_needed, at
config/i386/i386.c:31107
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

4.1.2 ICE:
<source>: In function 'n':
<source>:8: internal compiler error: in ix86_secondary_memory_needed, at
config/i386/i386.c:15992
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.


The change of the function was r0-82161.

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

end of thread, other threads:[~2021-09-14  7:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-07 23:00 [Bug c++/98991] New: ICE: Max. number of generated reload insns per insn is achieved (90) zhan3299 at purdue dot edu
2021-02-08  9:06 ` [Bug c++/98991] " marxin at gcc dot gnu.org
2021-02-08  9:34 ` [Bug inline-asm/98991] " rguenth at gcc dot gnu.org
2021-02-08 15:31 ` zhan3299 at purdue dot edu
2021-02-08 15:36 ` zhan3299 at purdue dot edu
2021-09-14  7:34 ` [Bug target/98991] " pinskia 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).