Bug 18231 - [4.0 regression] Nested inline function not inlined
Summary: [4.0 regression] Nested inline function not inlined
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.0.0
: P2 critical
Target Milestone: 4.0.0
Assignee: Andrew Pinski
URL:
Keywords: missed-optimization, patch
Depends on:
Blocks:
 
Reported: 2004-10-30 18:46 UTC by Andreas Schwab
Modified: 2004-11-03 19:56 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2004-10-30 19:07:35


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Schwab 2004-10-30 18:46:08 UTC
When a nested inline function calls another nested inline function the latter 
is never inlined (even if marked always_inline).  This breaks glibc. 
 
void f (void) 
{ 
  auto inline __attribute__ ((always_inline)) void h (void) { } 
  auto inline __attribute__ ((always_inline)) void g (void) { h (); } 
  g (); 
}
Comment 1 Andreas Schwab 2004-10-30 18:52:23 UTC
The testcase was simplified too much. 
 
int f (int i) 
{ 
  auto inline __attribute__ ((always_inline)) int h (int i) { return i; } 
  auto inline __attribute__ ((always_inline)) int g (void) { return h (i); } 
  return g (); 
} 
 
Comment 2 Andrew Pinski 2004-10-30 19:07:35 UTC
Confirmed.
This changed between 2004-07-21 and 2004-07-25.
Comment 3 Andrew Pinski 2004-10-30 19:21:24 UTC
The problem is that we are introducing an indirection in .generic:
  h.0 = h;
  D.1126 = h.0 (i);
Comment 4 Andrew Pinski 2004-10-30 20:03:06 UTC
Hmm the problem is that ADDR_EXPR of the function is not declared as invariant so we creating a 
temprary variable for it.  This also caused us to produce much worse code for the following than 3.3 
and 3.4.0:
int f (int i)
{
  int h (int j) { return i; }
  int g (void) { return h (i); }
  return g ();
}

Mine, I am posting a patch for it right now.
Comment 5 Andrew Pinski 2004-10-30 20:30:01 UTC
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-10/msg02700.html>.
Comment 6 GCC Commits 2004-11-03 19:55:34 UTC
Subject: Bug 18231

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	pinskia@gcc.gnu.org	2004-11-03 19:55:31

Modified files:
	gcc            : ChangeLog tree.c 

Log message:
	2004-11-03  Andrew Pinski  <pinskia@physics.uc.edu>
	
	PR tree-opt/18231
	* tree.c (staticp) <case FUNCTION_DECL>: Nested functions are static
	also.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.6151&r2=2.6152
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree.c.diff?cvsroot=gcc&r1=1.443&r2=1.444

Comment 7 Andrew Pinski 2004-11-03 19:56:29 UTC
Fixed.