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 (); }
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 (); }
Confirmed. This changed between 2004-07-21 and 2004-07-25.
The problem is that we are introducing an indirection in .generic: h.0 = h; D.1126 = h.0 (i);
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.
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-10/msg02700.html>.
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
Fixed.