]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
decl.c (duplicate_decls): Remove code deadling with DECL_SAVED_INSNS.
authorMark Mitchell <mark@codesourcery.com>
Tue, 4 Sep 2001 21:04:59 +0000 (21:04 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Tue, 4 Sep 2001 21:04:59 +0000 (21:04 +0000)
* decl.c (duplicate_decls): Remove code deadling with
DECL_SAVED_INSNS.
* decl2.c (finish_file): Likewise.
* pt.c (instantiate_decl): Likewise.
* semantics.c (expand_body): Don't defer local functions if
they wouldn't be deferred for some other reason.  Don't
generate RTL for functions that will not be emitted.
(genrtl_start_function): Remove code deadling with
DECL_SAVED_INSNS.
(genrtl_finish_function): Likewise.

From-SVN: r45386

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/decl2.c
gcc/cp/pt.c
gcc/cp/semantics.c

index 28ef9f7ee6b88193a240d4b4a55e895b87c1e081..4efd48db8aeb86bd519248bb795225cb7c6f1ee6 100644 (file)
@@ -1,3 +1,16 @@
+2001-09-04  Mark Mitchell  <mark@codesourcery.com>
+
+       * decl.c (duplicate_decls): Remove code deadling with
+       DECL_SAVED_INSNS.
+       * decl2.c (finish_file): Likewise.
+       * pt.c (instantiate_decl): Likewise.
+       * semantics.c (expand_body): Don't defer local functions if
+       they wouldn't be deferred for some other reason.  Don't
+       generate RTL for functions that will not be emitted.
+       (genrtl_start_function): Remove code deadling with
+       DECL_SAVED_INSNS.
+       (genrtl_finish_function): Likewise.
+
 2001-09-04  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/4203
index 234977a5c57c0ce7b1370573d8d9b571da751e0a..9020bb32188ec0604e7123255e77d29b2e3f5474 100644 (file)
@@ -3676,10 +3676,6 @@ duplicate_decls (newdecl, olddecl)
            DECL_NUM_STMTS (newdecl) = DECL_NUM_STMTS (olddecl);
 
          DECL_RESULT (newdecl) = DECL_RESULT (olddecl);
-         if ((DECL_SAVED_INSNS (newdecl) = DECL_SAVED_INSNS (olddecl)))
-           /* Previously saved insns go together with
-              the function's previous definition.  */
-           DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
          /* Don't clear out the arguments if we're redefining a function.  */
          if (DECL_ARGUMENTS (olddecl))
            DECL_ARGUMENTS (newdecl) = DECL_ARGUMENTS (olddecl);
index cb84d2648f14f6dd377c190f0e5f9179ec033d30..749b8b5cb9f986c4243c024077e7e3c4ba5e539f 100644 (file)
@@ -3517,7 +3517,6 @@ finish_file ()
          if (!DECL_EXTERNAL (decl)
              && DECL_NEEDED_P (decl)
              && DECL_SAVED_TREE (decl)
-             && !DECL_SAVED_INSNS (decl)
              && !TREE_ASM_WRITTEN (decl))
            {
              int saved_not_really_extern;
index 471a629a465625d80373404202b97f7d677cef86..36e6cb504f7f695d3b50667878b1c2c52926c3be 100644 (file)
@@ -9881,7 +9881,8 @@ instantiate_decl (d, defer_ok)
   /* Reject all external templates except inline functions.  */
   else if (DECL_INTERFACE_KNOWN (d)
           && ! DECL_NOT_REALLY_EXTERN (d)
-          && ! (TREE_CODE (d) == FUNCTION_DECL && DECL_INLINE (d)))
+          && ! (TREE_CODE (d) == FUNCTION_DECL 
+                && DECL_INLINE (d)))
     goto out;
   /* Defer all other templates, unless we have been explicitly
      forbidden from doing so.  We restore the source position here
index fbfd756d8ae25789a8daaae9b7e62b25bd80eb92..6564f8e41695b64cd7265ef28edade9f8a889ac4 100644 (file)
@@ -2443,12 +2443,10 @@ expand_body (fn)
      to decide whether to write it out or not.  */
   if (/* We have to generate RTL if it's not an inline function.  */
       (DECL_INLINE (fn) || DECL_COMDAT (fn))
-      /* Or if we have to keep all inline functions anyhow.  */
+      /* Or if we have to emit code for inline functions anyhow.  */
       && !flag_keep_inline_functions
       /* Or if we actually have a reference to the function.  */
-      && !DECL_NEEDED_P (fn)
-      /* Or if this is a nested function.  */
-      && !decl_function_context (fn))
+      && !DECL_NEEDED_P (fn))
     {
       /* Set DECL_EXTERNAL so that assemble_external will be called as
         necessary.  We'll clear it again in finish_file.  */
@@ -2470,6 +2468,14 @@ expand_body (fn)
   if (DECL_DECLARED_INLINE_P (fn))
     import_export_decl (fn);
 
+  /* If FN is external, then there's no point in generating RTL for
+     it.  This situation can arise with an inline function under
+     `-fexternal-tempaltes'; we instantiate the function, even though
+     we're not planning on emitting it, in case we get a chance to
+     inline it.  */
+  if (DECL_EXTERNAL (fn))
+    return;
+
   /* Emit any thunks that should be emitted at the same time as FN.  */
   emit_associated_thunks (fn);
 
@@ -2610,9 +2616,6 @@ genrtl_start_function (fn)
 
   /* Create a binding level for the parameters.  */
   expand_start_bindings (2);
-  /* Clear out any previously saved instructions for this function, in
-     case it was defined more than once.  */
-  DECL_SAVED_INSNS (fn) = NULL;
   /* Go through the PARM_DECLs for this function to see if any need
      cleanups.  */
   for (parm = DECL_ARGUMENTS (fn); parm; parm = TREE_CHAIN (parm))
@@ -2643,6 +2646,7 @@ genrtl_finish_function (fn)
      tree fn;
 {
   tree no_return_label = NULL_TREE;
+  tree t;
 
 #if 0
   if (write_symbols != NO_DEBUG)
@@ -2753,16 +2757,6 @@ genrtl_finish_function (fn)
   if (function_depth > 1)
     ggc_pop_context ();
 
-  if (DECL_SAVED_INSNS (fn) && ! TREE_ASM_WRITTEN (fn))
-    {
-      /* Set DECL_EXTERNAL so that assemble_external will be called as
-        necessary.  We'll clear it again in finish_file.  */
-      if (! DECL_EXTERNAL (fn))
-       DECL_NOT_REALLY_EXTERN (fn) = 1;
-      DECL_EXTERNAL (fn) = 1;
-      defer_fn (fn);
-    }
-
 #if 0
   /* Keep this code around in case we later want to control debug info
      based on whether a type is "used".  (jason 1999-11-11) */
@@ -2785,32 +2779,30 @@ genrtl_finish_function (fn)
 
   --function_depth;
 
-  /* If we don't need the RTL for this function anymore, stop pointing
-     to it.  That's especially important for LABEL_DECLs, since you
-     can reach all the instructions in the function from the
-     CODE_LABEL stored in the DECL_RTL for the LABEL_DECL.  */
-  if (!DECL_SAVED_INSNS (fn))
-    {
-      tree t;
-
-      /* Walk the BLOCK-tree, clearing DECL_RTL for LABEL_DECLs and
-        non-static local variables.  */
-      walk_tree_without_duplicates (&DECL_SAVED_TREE (fn),
-                                   clear_decl_rtl,
-                                   NULL);
+  /* In C++, we should never be saving RTL for the function.  */
+  my_friendly_assert (!DECL_SAVED_INSNS (fn), 20010903);
 
-      /* Clear out the RTL for the arguments.  */
-      for (t = DECL_ARGUMENTS (fn); t; t = TREE_CHAIN (t))
-       {
-         SET_DECL_RTL (t, NULL_RTX);
-         DECL_INCOMING_RTL (t) = NULL_RTX;
-       }
+  /* Since we don't need the RTL for this function anymore, stop
+     pointing to it.  That's especially important for LABEL_DECLs,
+     since you can reach all the instructions in the function from the
+     CODE_LABEL stored in the DECL_RTL for the LABEL_DECL.  Walk the
+     BLOCK-tree, clearing DECL_RTL for LABEL_DECLs and non-static
+     local variables.  */
+  walk_tree_without_duplicates (&DECL_SAVED_TREE (fn),
+                               clear_decl_rtl,
+                               NULL);
 
-      if (!(flag_inline_trees && DECL_INLINE (fn)))
-       /* DECL_INITIAL must remain nonzero so we know this was an
-          actual function definition.  */
-       DECL_INITIAL (fn) = error_mark_node;
+  /* Clear out the RTL for the arguments.  */
+  for (t = DECL_ARGUMENTS (fn); t; t = TREE_CHAIN (t))
+    {
+      SET_DECL_RTL (t, NULL_RTX);
+      DECL_INCOMING_RTL (t) = NULL_RTX;
     }
+
+  if (!(flag_inline_trees && DECL_INLINE (fn)))
+    /* DECL_INITIAL must remain nonzero so we know this was an
+       actual function definition.  */
+    DECL_INITIAL (fn) = error_mark_node;
   
   /* Let the error reporting routines know that we're outside a
      function.  For a nested function, this value is used in