]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
integrate.c (get_label_from_map): New function.
authorMark Mitchell <mmitchell@usa.net>
Mon, 9 Feb 1998 00:30:57 +0000 (00:30 +0000)
committerJeff Law <law@gcc.gnu.org>
Mon, 9 Feb 1998 00:30:57 +0000 (17:30 -0700)
        * integrate.c (get_label_from_map): New function.
        (expand_inline_function): Use it.  Initialize the label_map to
        NULL_RTX instead of gen_label_rtx.
        (copy_rtx_and_substitute): Use get_label_from_map.
        * integrate.h (get_label_from_map): New function.
        (set_label_from_map): New macro.
        * unroll.c (unroll_loop): Use them.
        (copy_loop_body): Ditto.
        * toplev.c (rest_of_compilation): Don't call save_for_inline_copy
        if all we're doing is dealing with -Wreturn-type.

From-SVN: r17795

gcc/ChangeLog
gcc/integrate.c
gcc/integrate.h
gcc/toplev.c
gcc/unroll.c

index a42af9a120bed2f7e4966a4cea4882eb8a4fe25b..3b5331034a3ace37359949325773353e25856e2b 100644 (file)
@@ -1,3 +1,17 @@
+Mon Feb  9 01:15:08 1998  Mark Mitchell  <mmitchell@usa.net>
+
+        * integrate.c (get_label_from_map): New function.
+        (expand_inline_function): Use it.  Initialize the label_map to
+        NULL_RTX instead of gen_label_rtx.
+        (copy_rtx_and_substitute): Use get_label_from_map.
+        * integrate.h (get_label_from_map): New function.
+        (set_label_from_map): New macro.
+        * unroll.c (unroll_loop): Use them.
+        (copy_loop_body): Ditto.
+
+        * toplev.c (rest_of_compilation): Don't call save_for_inline_copy
+        if all we're doing is dealing with -Wreturn-type.
+
 Mon Feb  9 01:07:41 1998  Jeffrey A Law  (law@cygnus.com)
 
         * i386/x-sco5 (CC): Remove trailing whitespace.
index 27aa4df6ebf0e3f521bf86b5e5666249f6b9e340..cf136d9846fe5341aa073f885bfbef37c32a07f3 100644 (file)
@@ -77,6 +77,25 @@ static void set_block_abstract_flags PROTO((tree, int));
 
 void set_decl_abstract_flags   PROTO((tree, int));
 \f
+/* Returns the Ith entry in the label_map contained in MAP.  If the
+   Ith entry has not yet been set, it is assumed to be a fresh label.
+   Essentially, we use this function to perform a lazy initialization
+   of label_map, thereby avoiding huge memory explosions when the
+   label_map gets very large.  */
+rtx
+get_label_from_map (map, i)
+     struct inline_remap* map;
+     int i;
+{
+  rtx x = map->label_map[i];
+
+  if (x == NULL_RTX)
+    x = map->label_map[i] = gen_label_rtx();
+
+  return x;
+}
+
+
 /* Zero if the current function (whose FUNCTION_DECL is FNDECL)
    is safe and reasonable to integrate into other functions.
    Nonzero means value is a warning message with a single %s
@@ -1738,7 +1757,7 @@ expand_inline_function (fndecl, parms, target, ignore, type,
 
   /* Make new label equivalences for the labels in the called function.  */
   for (i = min_labelno; i < max_labelno; i++)
-    map->label_map[i] = gen_label_rtx ();
+    map->label_map[i] = NULL_RTX;
 
   /* Perform postincrements before actually calling the function.  */
   emit_queue ();
@@ -1931,7 +1950,9 @@ expand_inline_function (fndecl, parms, target, ignore, type,
          break;
 
        case CODE_LABEL:
-         copy = emit_label (map->label_map[CODE_LABEL_NUMBER (insn)]);
+         copy = 
+           emit_label (get_label_from_map(map,
+                                          CODE_LABEL_NUMBER (insn)));
          LABEL_NAME (copy) = LABEL_NAME (insn);
          map->const_age++;
          break;
@@ -1954,7 +1975,8 @@ expand_inline_function (fndecl, parms, target, ignore, type,
              if (copy && (NOTE_LINE_NUMBER (copy) == NOTE_INSN_EH_REGION_BEG
                           || NOTE_LINE_NUMBER (copy) == NOTE_INSN_EH_REGION_END))
                {
-                 rtx label = map->label_map[NOTE_BLOCK_NUMBER (copy)];
+                 rtx label =
+                   get_label_from_map (map, NOTE_BLOCK_NUMBER (copy));
 
                  /* We have to forward these both to match the new exception
                     region.  */
@@ -2345,14 +2367,15 @@ copy_rtx_and_substitute (orig, map)
       return gen_rtx (code, VOIDmode, copy);
 
     case CODE_LABEL:
-      LABEL_PRESERVE_P (map->label_map[CODE_LABEL_NUMBER (orig)])
+      LABEL_PRESERVE_P (get_label_from_map (map, CODE_LABEL_NUMBER (orig)))
        = LABEL_PRESERVE_P (orig);
-      return map->label_map[CODE_LABEL_NUMBER (orig)];
+      return get_label_from_map (map, CODE_LABEL_NUMBER (orig));
 
     case LABEL_REF:
       copy = gen_rtx (LABEL_REF, mode,
                      LABEL_REF_NONLOCAL_P (orig) ? XEXP (orig, 0)
-                     : map->label_map[CODE_LABEL_NUMBER (XEXP (orig, 0))]);
+                     : get_label_from_map (map, 
+                                           CODE_LABEL_NUMBER (XEXP (orig, 0))));
       LABEL_OUTSIDE_LOOP_P (copy) = LABEL_OUTSIDE_LOOP_P (orig);
 
       /* The fact that this label was previously nonlocal does not mean
index b2acf5e5c1d0729bfab1f8ef123a121b02ac49a8..f0c46ff1ddceec1cbd67b3fc8b6e81c8b68474ac 100644 (file)
@@ -122,6 +122,13 @@ extern void try_constants PROTO((rtx, struct inline_remap *));
 
 extern void mark_stores PROTO((rtx, rtx));
 
+/* Return the label indicated.  */
+extern rtx get_label_from_map PROTO((struct inline_remap *, int));
+
+/* Set the label indicated.  */
+#define set_label_in_map(map, i, x) \
+  ((map)->label_map[i] = (x))
+
 /* Unfortunately, we need a global copy of const_equiv map for communication
    with a function called from note_stores.  Be *very* careful that this
    is used properly in the presence of recursion.  */
index a775fcf97347feebc32690c3406c95a6cd124f13..f612a532883afee15dd75d2d27e0b6f6f9952f37 100644 (file)
@@ -3071,35 +3071,48 @@ rest_of_compilation (decl)
        {
          DECL_DEFER_OUTPUT (decl) = 1;
 
-         /* If -Wreturn-type, we have to do a bit of compilation.  */
-         if (! warn_return_type)
+         /* If -Wreturn-type, we have to do a bit of compilation.
+            However, if we just fall through we will call
+            save_for_inline_copying() which results in excessive
+            memory use.  Instead, we just want to call
+            jump_optimize() to figure out whether or not we can fall
+            off the end of the function; we do the minimum amount of
+            work necessary to make that safe.  And, we set optimize
+            to zero to keep jump_optimize from working too hard.  */
+         if (warn_return_type)
            {
+             int saved_optimize = optimize;
+             optimize = 0;
+             find_exception_handler_labels ();
+             jump_optimize (get_insns(), 0, 0, 0);
+             optimize = saved_optimize;
+           }
+
 #ifdef DWARF_DEBUGGING_INFO
-             /* Generate the DWARF info for the "abstract" instance
-                of a function which we may later generate inlined and/or
-                out-of-line instances of.  */
-             if (write_symbols == DWARF_DEBUG)
-               {
-                 set_decl_abstract_flags (decl, 1);
-                 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
-                 set_decl_abstract_flags (decl, 0);
-               }
+         /* Generate the DWARF info for the "abstract" instance
+            of a function which we may later generate inlined and/or
+            out-of-line instances of.  */
+         if (write_symbols == DWARF_DEBUG)
+           {
+             set_decl_abstract_flags (decl, 1);
+             TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
+             set_decl_abstract_flags (decl, 0);
+           }
 #endif
 #ifdef DWARF2_DEBUGGING_INFO
-             /* Generate the DWARF2 info for the "abstract" instance
-                of a function which we may later generate inlined and/or
-                out-of-line instances of.  */
-             if (write_symbols == DWARF2_DEBUG)
-               {
-                 set_decl_abstract_flags (decl, 1);
-                 TIMEVAR (symout_time, dwarf2out_decl (decl));
-                 set_decl_abstract_flags (decl, 0);
-               }
-#endif
-             TIMEVAR (integration_time, save_for_inline_nocopy (decl));
-             RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlineable;
-             goto exit_rest_of_compilation;
+         /* Generate the DWARF2 info for the "abstract" instance
+            of a function which we may later generate inlined and/or
+            out-of-line instances of.  */
+         if (write_symbols == DWARF2_DEBUG)
+           {
+             set_decl_abstract_flags (decl, 1);
+             TIMEVAR (symout_time, dwarf2out_decl (decl));
+             set_decl_abstract_flags (decl, 0);
            }
+#endif
+         TIMEVAR (integration_time, save_for_inline_nocopy (decl));
+         RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable;
+         goto exit_rest_of_compilation;
        }
 
       /* If we have to compile the function now, save its rtl and subdecls
index eccd09f3232fc2b277341b50844f1f3938d5e552..4775c3a119dd4ea8f42e27efee3a741dfa4a6ffb 100644 (file)
@@ -690,8 +690,9 @@ unroll_loop (loop_end, insn_count, loop_start, end_insert_before,
       else if (GET_CODE (insn) == JUMP_INSN)
        {
          if (JUMP_LABEL (insn))
-           map->label_map[CODE_LABEL_NUMBER (JUMP_LABEL (insn))]
-             = JUMP_LABEL (insn);
+           set_label_in_map (map,
+                             CODE_LABEL_NUMBER (JUMP_LABEL (insn)),
+                             JUMP_LABEL (insn));
          else if (GET_CODE (PATTERN (insn)) == ADDR_VEC
                   || GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC)
            {
@@ -703,7 +704,9 @@ unroll_loop (loop_end, insn_count, loop_start, end_insert_before,
              for (i = 0; i < len; i++)
                {
                  label = XEXP (XVECEXP (pat, diff_vec_p, i), 0);
-                 map->label_map[CODE_LABEL_NUMBER (label)] = label;
+                 set_label_in_map (map,
+                                   CODE_LABEL_NUMBER (label),
+                                   label);
                }
            }
        }
@@ -1042,7 +1045,7 @@ unroll_loop (loop_end, insn_count, loop_start, end_insert_before,
 
              for (j = 0; j < max_labelno; j++)
                if (local_label[j])
-                 map->label_map[j] = gen_label_rtx ();
+                 set_label_in_map (map, j, gen_label_rtx ());
 
              for (j = FIRST_PSEUDO_REGISTER; j < max_reg_before_loop; j++)
                if (local_regno[j])
@@ -1204,7 +1207,7 @@ unroll_loop (loop_end, insn_count, loop_start, end_insert_before,
 
       for (j = 0; j < max_labelno; j++)
        if (local_label[j])
-         map->label_map[j] = gen_label_rtx ();
+         set_label_in_map (map, j, gen_label_rtx ());
 
       for (j = FIRST_PSEUDO_REGISTER; j < max_reg_before_loop; j++)
        if (local_regno[j])
@@ -1221,8 +1224,9 @@ unroll_loop (loop_end, insn_count, loop_start, end_insert_before,
          insn = PREV_INSN (copy_start);
          pattern = PATTERN (insn);
          
-         tem = map->label_map[CODE_LABEL_NUMBER
-                              (XEXP (SET_SRC (pattern), 0))];
+         tem = get_label_from_map (map,
+                                   CODE_LABEL_NUMBER
+                                   (XEXP (SET_SRC (pattern), 0)));
          SET_SRC (pattern) = gen_rtx (LABEL_REF, VOIDmode, tem);
 
          /* Set the jump label so that it can be used by later loop unrolling
@@ -1629,10 +1633,11 @@ copy_loop_body (copy_start, copy_end, map, exit_label, last_iteration,
   if (! last_iteration)
     {
       final_label = gen_label_rtx ();
-      map->label_map[CODE_LABEL_NUMBER (start_label)] = final_label;
+      set_label_in_map (map, CODE_LABEL_NUMBER (start_label),
+                       final_label); 
     }
   else
-    map->label_map[CODE_LABEL_NUMBER (start_label)] = start_label;
+    set_label_in_map (map, CODE_LABEL_NUMBER (start_label), start_label);
 
   start_sequence ();
   
@@ -1917,8 +1922,9 @@ copy_loop_body (copy_start, copy_end, map, exit_label, last_iteration,
              if (invert_exp (pattern, copy))
                {
                  if (! redirect_exp (&pattern,
-                                     map->label_map[CODE_LABEL_NUMBER
-                                                    (JUMP_LABEL (insn))],
+                                     get_label_from_map (map,
+                                                         CODE_LABEL_NUMBER
+                                                         (JUMP_LABEL (insn))),
                                      exit_label, copy))
                    abort ();
                }
@@ -1935,8 +1941,9 @@ copy_loop_body (copy_start, copy_end, map, exit_label, last_iteration,
                  emit_label_after (lab, jmp);
                  LABEL_NUSES (lab) = 0;
                  if (! redirect_exp (&pattern,
-                                     map->label_map[CODE_LABEL_NUMBER
-                                                    (JUMP_LABEL (insn))],
+                                     get_label_from_map (map,
+                                                         CODE_LABEL_NUMBER
+                                                         (JUMP_LABEL (insn))),
                                      lab, copy))
                    abort ();
                }
@@ -1979,7 +1986,8 @@ copy_loop_body (copy_start, copy_end, map, exit_label, last_iteration,
                     for a switch statement.  This label must have been mapped,
                     so just use the label_map to get the new jump label.  */
                  JUMP_LABEL (copy)
-                   = map->label_map[CODE_LABEL_NUMBER (JUMP_LABEL (insn))];
+                   = get_label_from_map (map, 
+                                         CODE_LABEL_NUMBER (JUMP_LABEL (insn))); 
                }
          
              /* If this is a non-local jump, then must increase the label
@@ -2057,7 +2065,8 @@ copy_loop_body (copy_start, copy_end, map, exit_label, last_iteration,
 
          if (insn != start_label)
            {
-             copy = emit_label (map->label_map[CODE_LABEL_NUMBER (insn)]);
+             copy = emit_label (get_label_from_map (map,
+                                                    CODE_LABEL_NUMBER (insn)));
              map->const_age++;
            }
          break;