Bug 64485 - [5 Regression] ICE at -Os and above on x86_64-linux-gnu in compute_inlined_call_time, at ipa-inline.c:550
Summary: [5 Regression] ICE at -Os and above on x86_64-linux-gnu in compute_inlined_ca...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: ipa (show other bugs)
Version: 5.0
: P3 normal
Target Milestone: 5.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-03 21:48 UTC by Zhendong Su
Modified: 2015-01-13 11:39 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zhendong Su 2015-01-03 21:48:52 UTC
The following code causes an ICE when compiled with the current gcc trunk at -Os and above on x86_64-linux-gnu in both 32-bit and 64-bit modes. 

It is a regression from 4.9.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 20150103 (experimental) [trunk revision 219158] (GCC) 

$ 
$ gcc-trunk -O1 -c small.c
$ gcc-4.9 -Os -c small.c
$ 
$ gcc-trunk -Os -c small.c
small.c:26:1: internal compiler error: in compute_inlined_call_time, at ipa-inline.c:550
 }
 ^
0x110a06d compute_inlined_call_time(cgraph_edge*, int)
	../../gcc-trunk/gcc/ipa-inline.c:550
0x11003b1 big_speedup_p
	../../gcc-trunk/gcc/ipa-inline.c:561
0x1104cb6 want_inline_small_function_p
	../../gcc-trunk/gcc/ipa-inline.c:613
0x1107623 inline_small_functions
	../../gcc-trunk/gcc/ipa-inline.c:1640
0x1107623 ipa_inline
	../../gcc-trunk/gcc/ipa-inline.c:2185
0x1107623 execute
	../../gcc-trunk/gcc/ipa-inline.c:2558
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.
$ 


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


int a, b, c, d;

void
fn1 (int p)
{
  b = ~c;
  for (;;)
    ;
}

static int
fn2 (int p)
{
  if (p)
    d = 0;
  if (!p)
    fn1 (0);
  return a;
}

void
fn3 ()
{
  a = 0;
  fn2 (a);
}
Comment 1 Zhendong Su 2015-01-03 21:52:28 UTC
The following (somewhat simpler) test case triggers the same ICE: 

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

int a, b, c;

int
fn1 ()
{
  return a || b;
}

static void 
fn2 (int p)
{
  if (p)
    c = fn1 ();
  for (;;)
    ;
}

void
fn3 ()
{
  fn2 (1);
}
Comment 2 H.J. Lu 2015-01-04 15:37:15 UTC
It is caused by r219076.
Comment 3 Jan Hubicka 2015-01-04 16:39:58 UTC
This is caused by fact that we calculate times in fixed point, but compensate them later in sreal.  The patch https://gcc.gnu.org/ml/gcc-patches/2015-01/msg00004.html ought to solve the issue.
Comment 4 Richard Biener 2015-01-13 11:39:34 UTC
Seems to be fixed.