summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2007-09-04 16:07:50 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2007-09-04 16:07:50 +0000
commitb97510b29053cb58b214be015ce079c8d6728753 (patch)
tree75c149d77b7daa8ab6ece4c2f7b9b97094602534 /gcc
parente5be38c39eb9bbc650a9392eb0374311ee7bc849 (diff)
downloadgcc-b97510b29053cb58b214be015ce079c8d6728753.tar.gz
* gcc.dg/tree-ssa/loadpre8.c: Disable inlining.
* gcc.dg/tree-ssa/pr27236.c: Likewise. * gcc.dg/tree-ssa/predcom-1.c: Likewise. * gcc.dg/tree-ssa/predcom-2.c: Likewise. * gcc.dg/tree-ssa/flatten-2.c: Avoid overactive tail call ellim. * gcc.dg/tree-ssa/loadpre5.c: Likewise. * gcc.dg/vect/costmodel/i386/costmodel-fast-math-vect-pr29925.c: Likewise. * invoke.texi (-finline-small-functions): Document. * ipa-inline.c (cgraph_default_inline_p): Do not use DECL_INLINE when deciding what is inlinable. (cgraph_decide_recursive_inlining): Handle flag_inline_functions. (cgraph_decide_inlining_of_small_function): Handle new flags. (cgraph_decide_inlining_incrementally): Likewise. * opts.c (decode_options): Enable flag_inline_small_functions at -O2 * common.opt (finline-small-functions): New. * Makefile.in (build/gengtype.o-warn): Work around PR29478 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@128092 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog12
-rw-r--r--gcc/common.opt4
-rw-r--r--gcc/doc/invoke.texi12
-rw-r--r--gcc/ipa-inline.c24
-rw-r--r--gcc/opts.c8
-rw-r--r--gcc/testsuite/ChangeLog11
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/flatten-2.c4
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/loadpre5.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/loadpre8.c6
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr27236.c1
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/predcom-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/predcom-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/vect/costmodel/i386/costmodel-fast-math-vect-pr29925.c1
13 files changed, 78 insertions, 11 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3ade7f81d82..7cbdf9aebbd 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,15 @@
+2007-09-04 Jan Hubicka <jh@suse.cz>
+
+ * invoke.texi (-finline-small-functions): Document.
+ * ipa-inline.c (cgraph_default_inline_p): Do not use DECL_INLINE
+ when deciding what is inlinable.
+ (cgraph_decide_recursive_inlining): Handle flag_inline_functions.
+ (cgraph_decide_inlining_of_small_function): Handle new flags.
+ (cgraph_decide_inlining_incrementally): Likewise.
+ * opts.c (decode_options): Enable flag_inline_small_functions at -O2
+ * common.opt (finline-small-functions): New.
+ * Makefile.in (build/gengtype.o-warn): Work around PR29478
+
2007-09-04 Richard Guenther <rguenther@suse.de>
* tree-ssa-operands.c (add_virtual_operand): Only mark
diff --git a/gcc/common.opt b/gcc/common.opt
index 57ec1f27cc6..3f44ba8f1b8 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -562,6 +562,10 @@ finline
Common Report Var(flag_no_inline,0) Init(2)
Pay attention to the \"inline\" keyword
+finline-small-functions
+Common Report Var(flag_inline_small_functions) Optimization
+Integrate simple functions into their callers when code size is known to not growth
+
finline-functions
Common Report Var(flag_inline_functions) Optimization
Integrate simple functions into their callers
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 774f2f3709b..9164078b75f 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -328,7 +328,7 @@ Objective-C and Objective-C++ Dialects}.
-fgcse -fgcse-lm -fgcse-sm -fgcse-las -fgcse-after-reload @gol
-fcrossjumping -fif-conversion -fif-conversion2 @gol
-finline-functions -finline-functions-called-once @gol
--finline-limit=@var{n} -fkeep-inline-functions @gol
+-finline-small-functions -finline-limit=@var{n} -fkeep-inline-functions @gol
-fkeep-static-consts -fmerge-constants -fmerge-all-constants @gol
-fmodulo-sched -fmodulo-sched-allow-regmoves -fno-branch-count-reg @gol
-fno-default-inline -fno-defer-pop -fmove-loop-invariants @gol
@@ -5033,6 +5033,7 @@ compilation time.
-ftree-fre @gol
-ftree-ch @gol
-funit-at-a-time @gol
+-finline-small-functions @gol
-fmerge-constants}
@option{-O} also turns on @option{-fomit-frame-pointer} on machines
@@ -5172,6 +5173,15 @@ Don't pay attention to the @code{inline} keyword. Normally this option
is used to keep the compiler from expanding any functions inline.
Note that if you are not optimizing, no functions can be expanded inline.
+@item -finline-small-functions
+@opindex finline-small-functions
+Integrate functions into their callers when their body is smaller than expected
+function call code (so overall size of program gets smaller). The compiler
+heuristically decides which functions are simple enough to be worth integrating
+in this way.
+
+Enabled at level @option{-O2}.
+
@item -finline-functions
@opindex finline-functions
Integrate all simple functions into their callers. The compiler
diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c
index 647ec9faded..2ea5f73cdc9 100644
--- a/gcc/ipa-inline.c
+++ b/gcc/ipa-inline.c
@@ -404,10 +404,10 @@ cgraph_default_inline_p (struct cgraph_node *n, const char **reason)
if (n->inline_decl)
decl = n->inline_decl;
- if (!DECL_INLINE (decl))
+ if (!flag_inline_small_functions && !DECL_DECLARED_INLINE_P (decl))
{
if (reason)
- *reason = N_("function not inlinable");
+ *reason = N_("function not inline candidate");
return false;
}
@@ -666,7 +666,8 @@ cgraph_decide_recursive_inlining (struct cgraph_node *node)
int depth = 0;
int n = 0;
- if (optimize_size)
+ if (optimize_size
+ || (!flag_inline_functions && !DECL_DECLARED_INLINE_P (node->decl)))
return false;
if (DECL_DECLARED_INLINE_P (node->decl))
@@ -863,6 +864,7 @@ cgraph_decide_inlining_of_small_functions (void)
struct cgraph_node *where;
int growth =
cgraph_estimate_size_after_inlining (1, edge->caller, edge->callee);
+ const char *not_good = NULL;
growth -= edge->caller->global.insns;
@@ -916,13 +918,19 @@ cgraph_decide_inlining_of_small_functions (void)
}
}
- if ((!cgraph_maybe_hot_edge_p (edge) || optimize_size) && growth > 0)
+ if (!cgraph_maybe_hot_edge_p (edge))
+ not_good = N_("call is unlikely and code size would grow");
+ if (!flag_inline_functions
+ && !DECL_DECLARED_INLINE_P (edge->callee->decl))
+ not_good = N_("function not declared inline and code size would grow");
+ if (optimize_size)
+ not_good = N_("optimizing for size and code size would grow");
+ if (not_good && growth > 0)
{
if (!cgraph_recursive_inlining_p (edge->caller, edge->callee,
&edge->inline_failed))
{
- edge->inline_failed =
- N_("call is unlikely");
+ edge->inline_failed = not_good;
if (dump_file)
fprintf (dump_file, " inline_failed:%s.\n", edge->inline_failed);
}
@@ -1363,7 +1371,9 @@ cgraph_decide_inlining_incrementally (struct cgraph_node *node,
/* When the function body would grow and inlining the function won't
eliminate the need for offline copy of the function, don't inline.
*/
- if (mode == INLINE_SIZE
+ if ((mode == INLINE_SIZE
+ || (!flag_inline_functions
+ && !DECL_DECLARED_INLINE_P (e->callee->decl)))
&& (cgraph_estimate_size_after_inlining (1, e->caller, e->callee)
> e->caller->global.insns)
&& cgraph_estimate_growth (e->callee) > 0)
diff --git a/gcc/opts.c b/gcc/opts.c
index 735f942a883..f6c749f32c8 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -353,6 +353,7 @@ static bool profile_arc_flag_set, flag_profile_values_set;
static bool flag_unroll_loops_set, flag_tracer_set;
static bool flag_value_profile_transformations_set;
static bool flag_peel_loops_set, flag_branch_probabilities_set;
+static bool flag_inline_functions_set;
/* Functions excluded from profiling. */
@@ -821,6 +822,7 @@ decode_options (unsigned int argc, const char **argv)
if (optimize >= 2)
{
+ flag_inline_small_functions = 1;
flag_thread_jumps = 1;
flag_crossjumping = 1;
flag_optimize_sibling_calls = 1;
@@ -1605,6 +1607,10 @@ common_handle_option (size_t scode, const char *arg, int value,
profile_arc_flag_set = true;
break;
+ case OPT_finline_functions:
+ flag_inline_functions_set = true;
+ break;
+
case OPT_fprofile_use:
if (!flag_branch_probabilities_set)
flag_branch_probabilities = value;
@@ -1618,6 +1624,8 @@ common_handle_option (size_t scode, const char *arg, int value,
flag_tracer = value;
if (!flag_value_profile_transformations_set)
flag_value_profile_transformations = value;
+ if (!flag_inline_functions_set)
+ flag_inline_functions = value;
break;
case OPT_fprofile_generate:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5762c3204b6..89b16069f4a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,14 @@
+2007-09-04 Jan Hubicka <jh@suse.cz>
+
+ * gcc.dg/tree-ssa/loadpre8.c: Disable inlining.
+ * gcc.dg/tree-ssa/pr27236.c: Likewise.
+ * gcc.dg/tree-ssa/predcom-1.c: Likewise.
+ * gcc.dg/tree-ssa/predcom-2.c: Likewise.
+ * gcc.dg/tree-ssa/flatten-2.c: Avoid overactive tail call ellim.
+ * gcc.dg/tree-ssa/loadpre5.c: Likewise.
+ * gcc.dg/vect/costmodel/i386/costmodel-fast-math-vect-pr29925.c:
+ Likewise.
+
2007-09-04 Janus Weil <jaydub66@gmail.com>
Tobias Burnus <burnus@net-b.de>
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/flatten-2.c b/gcc/testsuite/gcc.dg/tree-ssa/flatten-2.c
index c8ec3fdda31..52a865dbd7c 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/flatten-2.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/flatten-2.c
@@ -1,6 +1,7 @@
/* { dg-do compile } */
/* { dg-options -O2 } */
+extern void do_something_usefull();
/* Check that we finish compiling even if instructed to
flatten a cyclic callgraph. Verify we correctly
flatten with another function marked flatten in the
@@ -27,6 +28,7 @@ void __attribute__((flatten)) doubleindirect(void);
static void doubleindirect2(void)
{
doubleindirect();
+ do_something_usefull ();
}
static void doubleindirect1(void)
{
@@ -42,6 +44,7 @@ static void subcycle1(void);
static void subcycle2(void)
{
subcycle1();
+ do_something_usefull ();
}
static void subcycle1(void)
{
@@ -58,6 +61,7 @@ static void doublesubcycle2(void);
static void doublesubcycle3(void)
{
doublesubcycle1();
+ do_something_usefull ();
}
static void doublesubcycle2(void)
{
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/loadpre5.c b/gcc/testsuite/gcc.dg/tree-ssa/loadpre5.c
index 37314ebe8fd..8948cf6ac7f 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/loadpre5.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/loadpre5.c
@@ -2,6 +2,8 @@
/* { dg-options "-O2 -fdump-tree-pre-stats" } */
int p;
int r;
+
+__attribute__ ((noinline))
int a(void)
{
return p;
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/loadpre8.c b/gcc/testsuite/gcc.dg/tree-ssa/loadpre8.c
index 86cb1e46bba..42b38d3a964 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/loadpre8.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/loadpre8.c
@@ -24,7 +24,7 @@ typedef struct VEC_edge_base
{
}
VEC_edge_base;
-edge
+__attribute__ ((noinline)) edge
VEC_edge_base_index (const VEC_edge_base * vec_, unsigned ix_)
{
}
@@ -56,7 +56,7 @@ ei_start_1 (VEC_edge_gc ** ev)
i.container = ev;
return i;
}
-ei_next (edge_iterator * i)
+__attribute__ ((noinline)) ei_next (edge_iterator * i)
{
}
static __inline__ edge
@@ -75,7 +75,7 @@ static __inline__ tree
get_def_from_ptr (def_operand_p def)
{
}
-tree
+__attribute__ ((noinline)) tree
phi_nodes (basic_block bb)
{
}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr27236.c b/gcc/testsuite/gcc.dg/tree-ssa/pr27236.c
index b623486294a..389b652069d 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr27236.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr27236.c
@@ -5,6 +5,7 @@ static inline int inline_read(volatile int *mem)
{
return *mem;
}
+__attribute__ ((noinline))
int foo_read(volatile int *mem)
{
return inline_read(mem);
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/predcom-1.c b/gcc/testsuite/gcc.dg/tree-ssa/predcom-1.c
index 584f9eb0231..16bd5c910d8 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/predcom-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/predcom-1.c
@@ -6,6 +6,7 @@ void abort (void);
unsigned fib[1000];
+__attribute__ ((noinline))
void count_fib(void)
{
int i;
@@ -18,6 +19,7 @@ void count_fib(void)
unsigned avg[1000];
+__attribute__ ((noinline))
void count_averages(int n)
{
int i;
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/predcom-2.c b/gcc/testsuite/gcc.dg/tree-ssa/predcom-2.c
index 3ad13eaeda0..7275f2868dd 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/predcom-2.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/predcom-2.c
@@ -6,6 +6,7 @@ void abort (void);
long int fib[1000];
+__attribute__ ((noinline))
void count_fib(void)
{
int i;
@@ -18,6 +19,7 @@ void count_fib(void)
int avg[1000];
+__attribute__ ((noinline))
void count_averages(void)
{
int i;
diff --git a/gcc/testsuite/gcc.dg/vect/costmodel/i386/costmodel-fast-math-vect-pr29925.c b/gcc/testsuite/gcc.dg/vect/costmodel/i386/costmodel-fast-math-vect-pr29925.c
index 9347d05ea2d..5d84017dd24 100644
--- a/gcc/testsuite/gcc.dg/vect/costmodel/i386/costmodel-fast-math-vect-pr29925.c
+++ b/gcc/testsuite/gcc.dg/vect/costmodel/i386/costmodel-fast-math-vect-pr29925.c
@@ -3,6 +3,7 @@
#include <stdlib.h>
#include "../../tree-vect.h"
+__attribute__ ((noinline))
void interp_pitch(float *exc, float *interp, int pitch, int len)
{
int i,k;