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]

[C++ patch] Cleanup way functions are deferred


Hi,
the DECL_EXTERNAL/DECL_PUBLIC/DECL_COMDAT flags are set back and forth by C++
frontend during finish_file apparently just to avoid confusion of DECL_NEEDED.
This confuses my unit-at-a-time code as it sees wrong attributes of the
declarations once finish_file is done.

This patch replaces this mechanizm by simple bookeeping of what functions from
the deffered_fns list are still deffered and what has been already processed
via DECL_DEFER_OUTPUT flag (DECL_DEFER_OUTPUT flag is set for each deferred
function and cleared once expand_body is called on it).

I also removed wrapup_global_declarations for deferred functions as it does
nothing now when RTL inlining is gone only clears DECL_DEFER_OUTPUT flag that
is not exactly what I like :)

Bootstrapped/regtested i386 (c/C++ bootstrap only), OK?

Honza

Sat Jun 21 19:11:28 CEST 2003  Jan Hubicka  <jh@suse.cz>
	* decl2.c (defer_fn): Set DECL_DEFER_OUTPUT.
	(finish-file): Do not process function with DECL_DEFER_OUTPUT clear;
	clear DECL_DEFER_OUTPUT once function is processed; avoid flags
	massaging.

*** gcc.old/cp/decl2.c	Thu May 22 01:27:50 2003
--- gcc/cp/decl2.c	Sat Jun 21 19:06:29 2003
*************** defer_fn (tree fn)
*** 1193,1198 ****
--- 1195,1201 ----
    if (DECL_DEFERRED_FN (fn))
      return;
    DECL_DEFERRED_FN (fn) = 1;
+   DECL_DEFER_OUTPUT (fn) = 1;
    if (!deferred_fns)
      VARRAY_TREE_INIT (deferred_fns, 32, "deferred_fns");
  
*************** finish_file ()
*** 2746,2752 ****
  	     instantiation "static", which will result in errors about
  	     the use of undefined functions if there is no body for
  	     the function.  */
! 	  if (!DECL_SAVED_TREE (decl))
  	    continue;
  
  	  import_export_decl (decl);
--- 2795,2801 ----
  	     instantiation "static", which will result in errors about
  	     the use of undefined functions if there is no body for
  	     the function.  */
! 	  if (!DECL_SAVED_TREE (decl) || !DECL_DEFER_OUTPUT (decl))
  	    continue;
  
  	  import_export_decl (decl);
*************** finish_file ()
*** 2775,2792 ****
  	      && DECL_SAVED_TREE (decl)
  	      && !TREE_ASM_WRITTEN (decl))
  	    {
! 	      int saved_not_really_extern;
! 
! 	      /* When we call finish_function in expand_body, it will
! 		 try to reset DECL_NOT_REALLY_EXTERN so we save and
! 		 restore it here.  */
! 	      saved_not_really_extern = DECL_NOT_REALLY_EXTERN (decl);
  	      /* Generate RTL for this function now that we know we
  		 need it.  */
  	      expand_body (decl);
- 	      /* Undo the damage done by finish_function.  */
- 	      DECL_EXTERNAL (decl) = 0;
- 	      DECL_NOT_REALLY_EXTERN (decl) = saved_not_really_extern;
  	      /* If we're compiling -fsyntax-only pretend that this
  		 function has been written out so that we don't try to
  		 expand it again.  */
--- 2824,2835 ----
  	      && DECL_SAVED_TREE (decl)
  	      && !TREE_ASM_WRITTEN (decl))
  	    {
! 	      /* We will output the function; no longer consider it in this
! 		 loop.  */
! 	      DECL_DEFER_OUTPUT (decl) = 0;
  	      /* Generate RTL for this function now that we know we
  		 need it.  */
  	      expand_body (decl);
  	      /* If we're compiling -fsyntax-only pretend that this
  		 function has been written out so that we don't try to
  		 expand it again.  */
*************** finish_file ()
*** 2813,2822 ****
  	    }
  	}
  
-       if (deferred_fns_used
- 	  && wrapup_global_declarations (&VARRAY_TREE (deferred_fns, 0),
- 					 deferred_fns_used))
- 	reconsider = true;
        if (walk_namespaces (wrapup_globals_for_namespace, /*data=*/0))
  	reconsider = true;
  
--- 2828,2833 ----


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