This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix inlining of always_inline functions
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Jan Hubicka <jh at suse dot de>
- Date: Wed, 6 Jan 2010 16:35:23 +0100 (CET)
- Subject: [PATCH] Fix inlining of always_inline functions
This fixes a testcase I produced reducing PR42632. During
early inlining we inline a non-always-inline function into
an always-inline function. This breaks inlining when
being in a cycle and part of it is marked always-inline.
Note that inlining into an always-inline function incrementally
is always bogus - this either pessimizes size of callers of
the always-inline function or is premature as the function would
be inlined into the caller of the always-inline function anyway.
It might save some compile-time but I consider this unlikely
and it does indeed break inlining in cycles as seen by the testcase.
Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
Honza, any objections to this?
Thanks,
Richard.
2010-01-06 Richard Guenther <rguenther@suse.de>
* ipa-inline.c (cgraph_decide_inlining_incrementally): Do
not inline regular functions into always-inline functions.
* gcc.c-torture/compile/pr42632.c: New testcase.
Index: gcc/testsuite/gcc.c-torture/compile/pr42632.c
===================================================================
*** gcc/testsuite/gcc.c-torture/compile/pr42632.c (revision 0)
--- gcc/testsuite/gcc.c-torture/compile/pr42632.c (revision 0)
***************
*** 0 ****
--- 1,16 ----
+ static inline __attribute__((always_inline)) int
+ __pskb_trim(void)
+ {
+ return ___pskb_trim();
+ }
+ static inline __attribute__((always_inline))
+ int pskb_trim(void)
+ {
+ return __pskb_trim();
+ }
+ int ___pskb_trim(void)
+ {
+ pskb_trim();
+ return 0;
+ }
+
Index: gcc/ipa-inline.c
===================================================================
*** gcc/ipa-inline.c (revision 155644)
--- gcc/ipa-inline.c (working copy)
*************** cgraph_decide_inlining_incrementally (st
*** 1506,1512 ****
}
/* Now do the automatic inlining. */
! if (mode != INLINE_ALL && mode != INLINE_ALWAYS_INLINE)
for (e = node->callees; e; e = e->next_callee)
{
int allowed_growth = 0;
--- 1506,1515 ----
}
/* Now do the automatic inlining. */
! if (mode != INLINE_ALL && mode != INLINE_ALWAYS_INLINE
! /* Never inline regular functions into always-inline functions
! during incremental inlining. */
! && !node->local.disregard_inline_limits)
for (e = node->callees; e; e = e->next_callee)
{
int allowed_growth = 0;