patch: always_inline attribute

Aldy Hernandez aldyh@redhat.com
Wed Mar 20 18:09:00 GMT 2002


On Sat, Feb 23, 2002 at 04:47:42PM +0000, Jason Merrill wrote:

finally...

> > +   if (optimize == 0
> > +       && lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn)) == NULL)
> > +     return 1;
> 
> Woops, looks like my earlier mail came too late.  Please conditionalize
> this stuff on a flag other than optimize, so that -O1 -fno-inline still
> works.  You'll probably have to add Yet Another inlining flag.  While

i don't understand why we clobber flag_no_inline to 1 inside
c_common_post_options:

  if (! flag_instrument_function_entry_exit)
    {
      if (!flag_no_inline)
        flag_no_inline = 1;

so yes, we need yet another inlining flag.

> While you're at it, you might as well make -O0 -finline work.

what were the issues?  i think inlining works just fine at -O0 with
the new tree inliner.  perhaps in another patch i can remove the code
disabling inlining at -O0, and change the documentation accordingly?

patch fixing "-O1 -fno-inline" below.  this is for branch and trunk.

ok?

aldy

2002-03-21  Aldy Hernandez  <aldyh@redhat.com>

        * langhooks.c (lhd_tree_inlining_cannot_inline_tree_fn): Check
        flag_really_no_inline instead of optimize == 0.

        * c-objc-common.c (c_cannot_inline_tree_fn): Same.

        * cp/tree.c (cp_cannot_inline_tree_fn): Same.

        * flags.h (flag_really_no_inline): New.

        * c-common.c (c_common_post_options): Initialzie
        flag_really_no_inline.

        * toplev.c (flag_really_no_inline): New.

Index: langhooks.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/langhooks.c,v
retrieving revision 1.16
diff -c -p -r1.16 langhooks.c
*** langhooks.c	2002/02/22 04:23:21	1.16
--- langhooks.c	2002/03/21 02:07:51
*************** int
*** 156,162 ****
  lhd_tree_inlining_cannot_inline_tree_fn (fnp)
       tree *fnp;
  {
!   if (optimize == 0
        && lookup_attribute ("always_inline", DECL_ATTRIBUTES (*fnp)) == NULL)
      return 1;
  
--- 156,162 ----
  lhd_tree_inlining_cannot_inline_tree_fn (fnp)
       tree *fnp;
  {
!   if (flag_really_no_inline
        && lookup_attribute ("always_inline", DECL_ATTRIBUTES (*fnp)) == NULL)
      return 1;
  
Index: c-objc-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-objc-common.c,v
retrieving revision 1.3
diff -c -p -r1.3 c-objc-common.c
*** c-objc-common.c	2002/02/22 00:08:59	1.3
--- c-objc-common.c	2002/03/21 02:07:51
*************** c_cannot_inline_tree_fn (fnp)
*** 145,151 ****
    tree fn = *fnp;
    tree t;
  
!   if (optimize == 0
        && lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn)) == NULL)
      return 1;
  
--- 145,151 ----
    tree fn = *fnp;
    tree t;
  
!   if (flag_really_no_inline
        && lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn)) == NULL)
      return 1;
  
Index: flags.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/flags.h,v
retrieving revision 1.76
diff -c -p -r1.76 flags.h
*** flags.h	2002/01/10 18:51:14	1.76
--- flags.h	2002/03/21 02:07:52
*************** extern int flag_keep_inline_functions;
*** 380,385 ****
--- 380,390 ----
  
  extern int flag_no_inline;
  
+ /* Nonzero means that we don't want inlining by virtue of -fno-inline,
+    not just because the tree inliner turned us off.  */
+ 
+ extern int flag_really_no_inline;
+ 
  /* Nonzero if we are only using compiler to check syntax errors.  */
  
  extern int flag_syntax_only;
Index: c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.294.2.1
diff -c -p -r1.294.2.1 c-common.c
*** c-common.c	2002/03/16 01:07:51	1.294.2.1
--- c-common.c	2002/03/21 02:07:55
*************** c_common_post_options ()
*** 4110,4115 ****
--- 4110,4118 ----
  {
    cpp_post_options (parse_in);
  
+   /* Save no-inline information we may clobber below.  */
+   flag_really_no_inline = flag_no_inline;
+ 
    flag_inline_trees = 1;
  
    /* Use tree inlining if possible.  Function instrumentation is only
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.574.2.3
diff -c -p -r1.574.2.3 toplev.c
*** toplev.c	2002/03/15 09:59:17	1.574.2.3
--- toplev.c	2002/03/21 02:07:59
*************** int flag_keep_inline_functions;
*** 655,660 ****
--- 655,665 ----
  
  int flag_no_inline;
  
+ /* Nonzero means that we don't want inlining by virtue of -fno-inline,
+    not just because the tree inliner turned us off.  */
+ 
+ int flag_really_no_inline;
+ 
  /* Nonzero means that we should emit static const variables
     regardless of whether or not optimization is turned on.  */
  
Index: cp/tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/tree.c,v
retrieving revision 1.268.2.1
diff -c -p -r1.268.2.1 tree.c
*** tree.c	2002/03/16 01:08:04	1.268.2.1
--- tree.c	2002/03/21 02:08:01
*************** cp_cannot_inline_tree_fn (fnp)
*** 2132,2138 ****
  {
    tree fn = *fnp;
  
!   if (optimize == 0
        && lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn)) == NULL)
      return 1;
  
--- 2132,2138 ----
  {
    tree fn = *fnp;
  
!   if (flag_really_no_inline
        && lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn)) == NULL)
      return 1;
  



More information about the Gcc-patches mailing list