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

            Bug ID: 62209
           Summary: ICE with LTO on valid code on x86_64-linux-gnu
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu

The following code causes an ICE when compiled with the current gcc trunk (as
well as 4.8.x and 4.9.x) with LTO on x86_64-linux-gnu in both 32-bit and 64-bit
modes.

It is a regression from 4.7.x.

$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/5.0.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure --prefix=/usr/local/gcc-trunk
--enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
gcc version 5.0.0 20140820 (experimental) [trunk revision 214209] (GCC) 
$ 
$ gcc-trunk -O0 -c fn1.c
$ gcc-trunk -O0 -c main.c
$ gcc-trunk -O1 *.o  
$ ./a.out
$ 
$ gcc-trunk -flto -O0 -c fn1.c
$ gcc-trunk -flto -O0 -c main.c
$ gcc-trunk -flto -O1 *.o
fn1.c: In function ‘fn1’:
fn1.c:9:5: internal compiler error: in as_a, at is-a.h:192
 int fn1 (void)
     ^
0x90de17 gimple_statement_phi const* as_a<gimple_statement_phi const*,
gimple_statement_base const>(gimple_statement_base const*)
    ../../gcc-trunk/gcc/is-a.h:192
0x9210c7 gimple_statement_phi const* as_a<gimple_statement_phi const*,
gimple_statement_base const>(gimple_statement_base const*)
    ../../gcc-trunk/gcc/is-a.h:192
0x9210c7 gimple_phi_result
    ../../gcc-trunk/gcc/gimple.h:3791
0x9210c7 verify_gimple_phi
    ../../gcc-trunk/gcc/tree-cfg.c:4532
0x9210c7 verify_gimple_in_cfg(function*, bool)
    ../../gcc-trunk/gcc/tree-cfg.c:4864
0x82f136 execute_function_todo
    ../../gcc-trunk/gcc/passes.c:1749
0x82fc53 execute_todo
    ../../gcc-trunk/gcc/passes.c:1806
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
lto-wrapper: fatal error: gcc-trunk returned 1 exit status
compilation terminated.
/usr/bin/ld: fatal error: lto-wrapper failed
collect2: error: ld returned 1 exit status
$ 
$ gcc-4.7 -flto -O0 -c fn1.c
$ gcc-4.7 -flto -O0 -c main.c
$ gcc-4.7 -flto -O1 *.o
$ ./a.out
$ 
$ cat fn1.c  
struct S
{
  int f0;
  unsigned int f1:1;
} b;

int a, c, d;

int fn1 (void)
{
  unsigned int t1 = 0;
  struct S t2 = { 0, 0 };
  if (c)
    {
      struct S t3 = { 0, 0 };
      for (; a;)
    t3 = b;
      d = ((65531 && t1) < t3.f1) & t3.f1;
    }
  return t2.f0;
}
$ cat main.c
extern int fn1 (void); 

int main ()
{
  fn1 (); 
  return 0;
}
$

Reply via email to