http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60026

            Bug ID: 60026
           Summary: ICE at -O3 on valid code (with the optimize pragma) on
                    x86_64-linux-gnu
           Product: gcc
           Version: 4.9.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 using the optimize pragma causes an ICE when compiled with
the current gcc trunk and 4.8.x at -O3 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/4.9.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 4.9.0 20140131 (experimental) [trunk revision 207368] (GCC) 
$ 
$ gcc-trunk -O2 small.c; a.out
$ gcc-4.7.3 -O3 small.c; a.out
$ 
$ gcc-trunk -O3 small.c
small.c: In function ‘foo.constprop’:
small.c:8:10: internal compiler error: in parm_preserved_before_stmt_p, at
ipa-prop.c:760
 struct S foo (int p1, struct S p2)
          ^
0x84d137 parm_preserved_before_stmt_p
    ../../gcc-trunk/gcc/ipa-prop.c:760
0x84ecb4 ipa_load_from_parm_agg_1
    ../../gcc-trunk/gcc/ipa-prop.c:885
0x8531fa ipcp_transform_function(cgraph_node*)
    ../../gcc-trunk/gcc/ipa-prop.c:4776
0x915260 execute_one_ipa_transform_pass
    ../../gcc-trunk/gcc/passes.c:2066
0x915260 execute_all_ipa_transforms()
    ../../gcc-trunk/gcc/passes.c:2107
0x6a022a expand_function
    ../../gcc-trunk/gcc/cgraphunit.c:1767
0x6a2116 expand_all_functions
    ../../gcc-trunk/gcc/cgraphunit.c:1908
0x6a2116 compile()
    ../../gcc-trunk/gcc/cgraphunit.c:2252
0x6a2994 finalize_compilation_unit()
    ../../gcc-trunk/gcc/cgraphunit.c:2329
0x55c5e2 c_write_global_declarations()
    ../../gcc-trunk/gcc/c/c-decl.c:10401
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.
$ 


------------------------------


struct S
{
  int f;
} a;

#pragma GCC push_options
#pragma GCC optimize ("-O0")
struct S foo (int p1, struct S p2)
{
  int b = p2.f;
  return a; 
}
#pragma GCC pop_options

void
bar ()
{
  for (;a.f;)
    {
      struct S c = {0};
      foo (0, c);
    }
}

int
main ()
{
  bar(); 
  return 0;
}

Reply via email to