This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: inlining default


Jason Merrill wrote:-

> > Please.  Though while we're at it, it would be reasonable to be able to say
> > -O0 -finline; I would think that would just mean changing flag_no_inline to
> > default to 1 and clearing it if optimize>0.
> 
> No, that wouldn't work, of course.  It would need to be a three-state flag,
> like so many others.

OK, like this?  Let's do it properly and make this front-end
independent.

Neil.

	* c-common.c (c_common_post_options): Move inlining flag logic
	to toplev.c.
	* flags.h (flag_inline_trees): New.
	* toplev.c (flag_no_inline): Start at -1.
	(flag_inline_trees): New.
	(process_options): Set flag_no_inline and flag_inline_trees
	as appropriate.
	* tree-inline.h (flag_inline_trees): Move to flags.h.
	* tree-inline.c (flag_inline_trees): Move to toplev.c.

Index: gcc/c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.281
diff -u -p -r1.281 c-common.c
--- c-common.c	2001/12/11 19:42:32	1.281
+++ c-common.c	2001/12/13 15:50:56
@@ -3915,22 +3915,6 @@ c_common_post_options ()
 {
   cpp_post_options (parse_in);
 
-  /* Use tree inlining if possible.  Function instrumentation is only
-     done in the RTL level, so we disable tree inlining.  */
-  if (! flag_instrument_function_entry_exit)
-    {
-      if (!flag_no_inline)
-	{
-	  flag_inline_trees = 1;
-	  flag_no_inline = 1;
-	}
-      if (flag_inline_functions)
-	{
-	  flag_inline_trees = 2;
-	  flag_inline_functions = 0;
-	}
-    }
-
   /* If still "unspecified", make it match -fbounded-pointers.  */
   if (flag_bounds_check == -1)
     flag_bounds_check = flag_bounded_pointers;
Index: gcc/flags.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/flags.h,v
retrieving revision 1.74
diff -u -p -r1.74 flags.h
--- flags.h	2001/12/13 11:34:05	1.74
+++ flags.h	2001/12/13 15:50:59
@@ -375,6 +375,15 @@ extern int flag_keep_inline_functions;
 
 extern int flag_no_inline;
 
+/* 0 if we should not perform inlining.
+   1 if we should expand functions calls inline at the tree level.  
+   2 if we should consider *all* functions to be inline 
+   candidates.
+
+   Only meaningful for front ends that use tree-inline.c.  */
+
+extern int flag_inline_trees;
+
 /* Nonzero if we are only using compiler to check syntax errors.  */
 
 extern int flag_syntax_only;
Index: gcc/toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.556
diff -u -p -r1.556 toplev.c
--- toplev.c	2001/12/13 11:34:07	1.556
+++ toplev.c	2001/12/13 15:51:12
@@ -678,10 +678,20 @@ int flag_inline_functions;
 
 int flag_keep_inline_functions;
 
-/* Nonzero means that functions will not be inlined.  */
+/* Nonzero means that functions will not be inlined.  -1 means
+   indeterminate until options are processed.  */
 
-int flag_no_inline;
+int flag_no_inline = -1;
 
+/* 0 if we should not perform inlining.
+   1 if we should expand functions calls inline at the tree level.  
+   2 if we should consider *all* functions to be inline 
+   candidates.
+
+   Only meaningful for front ends that use tree-inline.c.  */
+
+int flag_inline_trees;
+
 /* Nonzero means that we should emit static const variables
    regardless of whether or not optimization is turned on.  */
 
@@ -4771,18 +4781,40 @@ parse_options_and_default_flags (argc, a
 static void
 process_options ()
 {
-  if (optimize == 0)
+  /* Determine an appropriate setting for flag_no_inline.  */
+  if (flag_no_inline == -1)
     {
-      /* Inlining does not work if not optimizing,
-	 so force it not to be done.  */
-      flag_no_inline = 1;
-      warn_inline = 0;
-
-      /* The c_decode_option function and decode_option hook set
-	 this to `2' if -Wall is used, so we can avoid giving out
-	 lots of errors for people who don't realize what -Wall does.  */
-      if (warn_uninitialized == 1)
-	warning ("-Wuninitialized is not supported without -O");
+      if (optimize == 0)
+	{
+	  flag_no_inline = 1;
+	  warn_inline = 0;
+	}
+      else
+	flag_no_inline = 0;
+    }
+
+  /* The c_decode_option function and decode_option hook set
+     warn_uninitialized to `2' if -Wall is used, so we can avoid
+     giving out lots of errors for people who don't realize what -Wall
+     does.  */
+  if (optimize == 0 && warn_uninitialized == 1)
+    warning ("-Wuninitialized is not supported without -O");
+
+  /* Use tree inlining if possible.  Function instrumentation is only
+     done in the RTL level, so we disable tree inlining.  */
+  if (! flag_instrument_function_entry_exit)
+    {
+      if (!flag_no_inline)
+	{
+	  flag_inline_trees = 1;
+	  flag_no_inline = 1;
+	}
+
+      if (flag_inline_functions)
+	{
+	  flag_inline_trees = 2;
+	  flag_inline_functions = 0;
+	}
     }
 
 #ifdef OVERRIDE_OPTIONS
Index: gcc/tree-inline.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v
retrieving revision 1.13
diff -u -p -r1.13 tree-inline.c
--- tree-inline.c	2001/12/06 17:58:23	1.13
+++ tree-inline.c	2001/12/13 15:51:15
@@ -40,13 +40,6 @@ Boston, MA 02111-1307, USA.  */
    this would require a shared function-as-trees infrastructure.  */
 #include "c-common.h" 
 
-/* 0 if we should not perform inlining.
-   1 if we should expand functions calls inline at the tree level.  
-   2 if we should consider *all* functions to be inline 
-   candidates.  */
-
-int flag_inline_trees = 0;
-
 /* To Do:
 
    o In order to make inlining-on-trees work, we pessimized
Index: gcc/tree-inline.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-inline.h,v
retrieving revision 1.3
diff -u -p -r1.3 tree-inline.h
--- tree-inline.h	2001/10/08 20:54:07	1.3
+++ tree-inline.h	2001/12/13 15:51:15
@@ -32,11 +32,4 @@ tree copy_tree_r PARAMS ((tree*, int*, v
 void clone_body PARAMS ((tree, tree, void*));
 void remap_save_expr PARAMS ((tree*, void*, tree, int*));
 
-/* 0 if we should not perform inlining.
-   1 if we should expand functions calls inline at the tree level.  
-   2 if we should consider *all* functions to be inline 
-   candidates.  */
-
-extern int flag_inline_trees;
-
 #endif /* GCC_TREE_INLINE_H */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]