[RFA] attribute((inline_everything)) (was Re: [RFA] Kill artificial inlining limit)

Richard Guenther rguenth@tat.physik.uni-tuebingen.de
Tue May 13 16:27:00 GMT 2003


On 13 May 2003, Steven Bosscher wrote:

> Op di 13-05-2003, om 17:03 schreef Richard Guenther:

> > Oh, btw. I'm currently trying to teach gcc to honour a
> > __attribute__((inline_everything)) function attribute that would work
> > without changing the heuristics and would enable me to get those flat
> > inner loops that I need for cse/gcse to do their work.
> >
> > Stay tuned.
> >
>
> That'll be fun: inline_everything with unit-at-a-time, wha-hoooo!!!  :-)
> BTW with unit-at-a-time, once it works for C++, all static functions
> have higher probability to be inlined.  Maybe that will help you as
> well.

I'm currently experimenting with the patch below. To get it work, you
need to declare your to-be-flat function as both
__attribute__((inline_everything)) and __attribute__((noinline)). This
comes from touching the minimum possible lines of code and possibly is
a good idea anyway to prevent everything from blowing up. So you get
flat functions, but only if they are not inlined itself. Makes sense.

Thoughts?

Richard.

Index: gcc/c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.393.2.3
diff -u -u -r1.393.2.3 c-common.c
--- gcc/c-common.c	9 Mar 2003 19:31:11 -0000	1.393.2.3
+++ gcc/c-common.c	13 May 2003 16:22:25 -0000
@@ -812,6 +812,8 @@
 			      handle_noinline_attribute },
   { "always_inline",          0, 0, true,  false, false,
 			      handle_always_inline_attribute },
+  { "inline_everything",      0, 0, true,  false, false,
+			      NULL },
   { "used",                   0, 0, true,  false, false,
 			      handle_used_attribute },
   { "unused",                 0, 0, false, false, false,
Index: gcc/tree-inline.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v
retrieving revision 1.38.2.8
diff -u -u -r1.38.2.8 tree-inline.c
--- gcc/tree-inline.c	2 May 2003 19:52:01 -0000	1.38.2.8
+++ gcc/tree-inline.c	13 May 2003 16:22:25 -0000
@@ -51,6 +51,7 @@
    candidates.  */

 int flag_inline_trees = 0;
+static int inline_everything = 0;

 /* To Do:

@@ -1002,7 +1003,8 @@

   /* In case we don't disregard the inlining limits and we basically
      can inline this function, investigate further.  */
-  if (! (*lang_hooks.tree_inlining.disregard_inline_limits) (fn)
+  if (! inline_everything
+      && ! (*lang_hooks.tree_inlining.disregard_inline_limits) (fn)
       && inlinable)
     {
       int sum_insns = (id ? id->inlined_stmts : 0) * INSNS_PER_STMT
@@ -1011,7 +1013,7 @@
          limit by a huge factor (128), we just say no. Should not happen
          in real life.  */
       if (sum_insns > MAX_INLINE_INSNS * 128)
-	 inlinable = 0;
+        inlinable = 0;
       /* If we did not hit the extreme limit, we use a linear function
          with slope -1/MAX_INLINE_SLOPE to exceedingly decrease the
          allowable size. We always allow a size of MIN_INLINE_INSNS
@@ -1468,11 +1470,18 @@
      real inlining is represented in ID.FNS.  */
   id.first_inlined_fn = VARRAY_ACTIVE_SIZE (id.fns);

+  if (lookup_attribute ("inline_everything", DECL_ATTRIBUTES (fn)) != NULL) {
+    warning("inlining everything now");
+    inline_everything = 1;
+  }
+
   /* Replace all calls to inline functions with the bodies of those
      functions.  */
   id.tree_pruner = htab_create (37, htab_hash_pointer,
 				htab_eq_pointer, NULL);
   expand_calls_inline (&DECL_SAVED_TREE (fn), &id);
+
+  inline_everything = 0;

   /* Clean up.  */
   htab_delete (id.tree_pruner);



More information about the Gcc-patches mailing list