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]

C++ PATCH: Fix -O3



It was reported yesterday that -O3 was broken in C++.

This patch fixes it.

Tested on i686-pc-linux-gnu, applied on the mainline and on the
branch.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

2001-05-03  Mark Mitchell  <mark@codesourcery.com>

	* cp-tree.h (flag_inline_trees): Update documentation.
	* decl.c (init_decl_processing): Adjust handling of
	flag_inline_functions and flag_inline_trees to support -O3.
	(grokfndecl): Set DECL_INLINE on all functions if that's what
	the user requested.
	(save_function_data): Clear DECL_INLINE in
	current_function_cannot_inline is non-NULL.
	* decl2.c (flag_inline_trees): Update documentation.

Index: cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.572.2.23
diff -c -p -r1.572.2.23 cp-tree.h
*** cp-tree.h	2001/05/01 12:54:43	1.572.2.23
--- cp-tree.h	2001/05/04 02:58:51
*************** extern int flag_implicit_templates;
*** 3472,3479 ****
  
  extern int flag_weak;
  
! /* Nonzero if we should expand functions calls inline at the tree
!    level, rather than at the RTL level.  */
  
  extern int flag_inline_trees;
  
--- 3472,3481 ----
  
  extern int flag_weak;
  
! /* 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;
  
Index: decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.747.2.23
diff -c -p -r1.747.2.23 decl.c
*** decl.c	2001/05/02 17:59:37	1.747.2.23
--- decl.c	2001/05/04 02:58:53
*************** init_decl_processing ()
*** 6354,6359 ****
--- 6354,6364 ----
        flag_inline_trees = 1;
        flag_no_inline = 1;
      }
+   if (flag_inline_functions)
+     {
+       flag_inline_trees = 2;
+       flag_inline_functions = 0;
+     }
  
    /* Initially, C.  */
    current_lang_name = lang_name_c;
*************** init_decl_processing ()
*** 6534,6543 ****
  
    if (flag_exceptions)
      init_exception_processing ();
-   if (flag_no_inline)
-     {
-       flag_inline_functions = 0;
-     }
  
    if (! supports_one_only ())
      flag_weak = 0;
--- 6539,6544 ----
*************** grokfndecl (ctype, type, declarator, ori
*** 8821,8828 ****
        DECL_NOT_REALLY_EXTERN (decl) = 1;
      }
  
    if (inlinep)
!     DECL_DECLARED_INLINE_P (decl) = DECL_INLINE (decl) = 1;
  
    DECL_EXTERNAL (decl) = 1;
    if (quals != NULL_TREE && TREE_CODE (type) == FUNCTION_TYPE)
--- 8822,8834 ----
        DECL_NOT_REALLY_EXTERN (decl) = 1;
      }
  
+   /* If the declaration was declared inline, mark it as such.  */
    if (inlinep)
!     DECL_DECLARED_INLINE_P (decl) = 1;
!   /* We inline functions that are explicitly declared inline, or, when
!      the user explicitly asks us to, all functions.  */
!   if (DECL_DECLARED_INLINE_P (decl) || flag_inline_trees == 2)
!     DECL_INLINE (decl) = 1;
  
    DECL_EXTERNAL (decl) = 1;
    if (quals != NULL_TREE && TREE_CODE (type) == FUNCTION_TYPE)
*************** save_function_data (decl)
*** 13749,13755 ****
    /* If we've already decided that we cannot inline this function, we
       must remember that fact when we actually go to expand the
       function.  */
!   f->cannot_inline = current_function_cannot_inline;
  }
  
  /* At the end of every constructor we generate to code to return
--- 13755,13765 ----
    /* If we've already decided that we cannot inline this function, we
       must remember that fact when we actually go to expand the
       function.  */
!   if (current_function_cannot_inline)
!     {
!       f->cannot_inline = current_function_cannot_inline;
!       DECL_INLINE (decl) = 0;
!     }
  }
  
  /* At the end of every constructor we generate to code to return
Index: decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.437.2.18
diff -c -p -r1.437.2.18 decl2.c
*** decl2.c	2001/05/03 11:03:11	1.437.2.18
--- decl2.c	2001/05/04 02:58:55
*************** int flag_use_cxa_atexit;
*** 411,418 ****
  
  int flag_honor_std = ENABLE_STD_NAMESPACE;
  
! /* Nonzero if we should expand functions calls inline at the tree
!    level, rather than at the RTL level.  */
  
  int flag_inline_trees = 0;
  
--- 411,420 ----
  
  int flag_honor_std = ENABLE_STD_NAMESPACE;
  
! /* 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;
  


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