cfglayout.c (insn_scope): New static function
authorJan Hubicka <jh@suse.cz>
Sun, 8 Jun 2003 19:35:54 +0000 (21:35 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Sun, 8 Jun 2003 19:35:54 +0000 (19:35 +0000)
* cfglayout.c (insn_scope): New static function
(block_locators_*, line_locators*, file_locators*): New static varrays.
(scope_to_insns_initialize): Use them.
(insn_line, insn_file): New functions.
(scope_to_insns_finalize): Use insn_scope.
(prologue_locator, epilogue_locator): New global variables.
* emit-rt.c (try_split, make_insn_raw, make_jump_insn_raw,
make_call_insn_raw, emit_copy_of_insn_after): Use locators.
(emit_insn_after_scope, emit_insn_before_scope
emit_jump_insn_after_scope, emit_jump_insn_before_scope
emit_call_insn_after_scope, emit_call_insn_before_scope): Rename to...
(emit_insn_after_setloc, emit_insn_before_setloc
emit_jump_insn_after_setloc, emit_jump_insn_before_setloc
emit_call_insn_after_setloc, emit_call_insn_before_setloc): ... these;
use locators.
* final.c (notice_source_line): Use locators.
(final_start_function): Set initial source file and line.
(final_scan_insn): Use locators.
* ifcvt.c (noce_try_store_flag, noce_try_store_flag_constants,
noce_try_addcc, noce_try_store_flag_mask, noce_try_cmove,
noce_try_cmove_arith, noce_try_minmax, noce_try_abs,
noce_process_if_block, find_cond_trap): Likewise.
* integrate.c (copy_insn_list): Likewise.
* jump.c (duplicate_loop_exit_test): LIkewise.
* print-rtl.c (print_rtx): Print locators.
* recog.c (peephole2_optimize): Likewise.
* rtl.h (INSN_SCOPE): Remove.
(emit_insn_after_scope, emit_insn_before_scope
emit_jump_insn_after_scope, emit_jump_insn_before_scope
emit_call_insn_after_scope, emit_call_insn_before_scope): Rename to...
(emit_insn_after_setloc, emit_insn_before_setloc
emit_jump_insn_after_setloc, emit_jump_insn_before_setloc
emit_call_insn_after_setloc, emit_call_insn_before_setloc): ... these;
(insn_file, insn_line, prologue_locator, epilogue_locator): Declare.
* unroll.c (copy_loop_body): Use locators.
* function.c (set_insn_locators): New function.
(thread_prologue_and_epilogue_insns): Set the locators accordingly.

From-SVN: r67637

17 files changed:
gcc/ChangeLog
gcc/Makefile.in
gcc/cfglayout.c
gcc/cfglayout.h
gcc/combine.c
gcc/emit-rtl.c
gcc/final.c
gcc/function.c
gcc/ifcvt.c
gcc/integrate.c
gcc/jump.c
gcc/print-rtl.c
gcc/recog.c
gcc/rtl.def
gcc/rtl.h
gcc/toplev.c
gcc/unroll.c

index 33c4a2304fe6b4fd50c8a79088d3ae4d8ae8902b..ccf8cccf6cd4046ad6048a158657cd0ae5f7a20c 100644 (file)
@@ -1,3 +1,43 @@
+Sun Jun  8 21:27:41 CEST 2003  Jan Hubicka  <jh@suse.cz>
+
+       * cfglayout.c (insn_scope): New static function
+       (block_locators_*, line_locators*, file_locators*): New static varrays.
+       (scope_to_insns_initialize): Use them.
+       (insn_line, insn_file): New functions.
+       (scope_to_insns_finalize): Use insn_scope.
+       (prologue_locator, epilogue_locator): New global variables.
+       * emit-rt.c (try_split, make_insn_raw, make_jump_insn_raw,
+       make_call_insn_raw, emit_copy_of_insn_after): Use locators.
+       (emit_insn_after_scope, emit_insn_before_scope
+       emit_jump_insn_after_scope, emit_jump_insn_before_scope
+       emit_call_insn_after_scope, emit_call_insn_before_scope): Rename to...
+       (emit_insn_after_setloc, emit_insn_before_setloc
+       emit_jump_insn_after_setloc, emit_jump_insn_before_setloc
+       emit_call_insn_after_setloc, emit_call_insn_before_setloc): ... these;
+       use locators.
+       * final.c (notice_source_line): Use locators.
+       (final_start_function): Set initial source file and line.
+       (final_scan_insn): Use locators.
+       * ifcvt.c (noce_try_store_flag, noce_try_store_flag_constants,
+       noce_try_addcc, noce_try_store_flag_mask, noce_try_cmove,
+       noce_try_cmove_arith, noce_try_minmax, noce_try_abs,
+       noce_process_if_block, find_cond_trap): Likewise.
+       * integrate.c (copy_insn_list): Likewise.
+       * jump.c (duplicate_loop_exit_test): LIkewise.
+       * print-rtl.c (print_rtx): Print locators.
+       * recog.c (peephole2_optimize): Likewise.
+       * rtl.h (INSN_SCOPE): Remove.
+       (emit_insn_after_scope, emit_insn_before_scope
+       emit_jump_insn_after_scope, emit_jump_insn_before_scope
+       emit_call_insn_after_scope, emit_call_insn_before_scope): Rename to...
+       (emit_insn_after_setloc, emit_insn_before_setloc
+       emit_jump_insn_after_setloc, emit_jump_insn_before_setloc
+       emit_call_insn_after_setloc, emit_call_insn_before_setloc): ... these;
+       (insn_file, insn_line, prologue_locator, epilogue_locator): Declare.
+       * unroll.c (copy_loop_body): Use locators.
+       * function.c (set_insn_locators): New function.
+       (thread_prologue_and_epilogue_insns): Set the locators accordingly.
+
 2003-06-08  Kazu Hirata  <kazu@cs.umass.edu>
 
        * config/h8300/h8300.h (LONG_LONG_TYPE_SIZE): Set to 64.
index 11ab0c24806860cf671aa0d1a1331eb633321569..535e50f04a2185d25254685c323de2e39c7f8225 100644 (file)
@@ -1775,7 +1775,7 @@ tracer.o : tracer.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(TREE_
    $(PARAMS_H) $(COVERAGE_H)
 cfglayout.o : cfglayout.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
    $(RTL_H) $(TREE_H) insn-config.h $(BASIC_BLOCK_H) hard-reg-set.h output.h \
-   function.h cfglayout.h cfgloop.h $(TARGET_H)
+   function.h cfglayout.h cfgloop.h $(TARGET_H) gt-cfglayout.h $(GGC_H)
 timevar.o : timevar.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TIMEVAR_H) flags.h \
    intl.h toplev.h
 regrename.o : regrename.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
@@ -1995,7 +1995,7 @@ GTFILES = $(srcdir)/input.h $(srcdir)/coretypes.h $(srcdir)/cpplib.h \
   $(srcdir)/fold-const.c $(srcdir)/function.c \
   $(srcdir)/gcse.c $(srcdir)/integrate.c $(srcdir)/lists.c $(srcdir)/optabs.c \
   $(srcdir)/profile.c $(srcdir)/ra-build.c $(srcdir)/regclass.c \
-  $(srcdir)/reg-stack.c \
+  $(srcdir)/reg-stack.c $(srcdir)/cfglayout.c \
   $(srcdir)/sdbout.c $(srcdir)/stmt.c $(srcdir)/stor-layout.c \
   $(srcdir)/stringpool.c $(srcdir)/tree.c $(srcdir)/varasm.c \
   $(out_file) \
@@ -2013,7 +2013,7 @@ gt-lists.h gt-alias.h gt-cselib.h gt-fold-const.h gt-gcse.h \
 gt-expr.h gt-sdbout.h gt-optabs.h gt-bitmap.h \
 gt-dwarf2out.h gt-ra-build.h gt-reg-stack.h gt-dwarf2asm.h \
 gt-dbxout.h gt-c-common.h gt-c-decl.h gt-c-parse.h \
-gt-c-pragma.h gt-c-objc-common.h gtype-c.h gt-input.h \
+gt-c-pragma.h gt-c-objc-common.h gtype-c.h gt-input.h gt-cfglayout.h \
 gt-stringpool.h : s-gtype ; @true
 
 gtyp-gen.h: Makefile
index 83634dd3d3a397785f535271e26e952cb3559fb3..5bd3ca056559c9acf2e51ffe9f3c6ea7027f15ee 100644 (file)
@@ -33,6 +33,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "cfglayout.h"
 #include "cfgloop.h"
 #include "target.h"
+#include "ggc.h"
 
 /* The contents of the current function definition are allocated
    in this obstack, and all are freed at the end of the function.  */
@@ -54,6 +55,7 @@ static void cleanup_unconditional_jumps       PARAMS ((struct loops *));
 static void fixup_fallthru_exit_predecessor PARAMS ((void));
 static rtx duplicate_insn_chain PARAMS ((rtx, rtx));
 static void break_superblocks PARAMS ((void));
+static tree insn_scope PARAMS ((rtx));
 \f
 rtx
 unlink_insn_chain (first, last)
@@ -212,22 +214,83 @@ record_effective_endpoints ()
     cfg_layout_function_footer = unlink_insn_chain (cfg_layout_function_footer, get_last_insn ());
 }
 \f
-/* Build a varray mapping INSN_UID to lexical block.  Return it.  */
+/* Data structures representing mapping of INSN_LOCATOR into scope blocks, line
+   numbers and files.  In order to be GGC friendly we need to use separate
+   varrays.  This also slightly improve the memory locality in binary search.
+   The _locs array contains locators where the given property change.  The
+   block_locators_blocks contains the scope block that is used for all insn
+   locator greater than corresponding block_locators_locs value and smaller
+   than the following one.  Similarly for the other properties.  */
+static GTY(()) varray_type block_locators_locs;
+static GTY(()) varray_type block_locators_blocks;
+static GTY(()) varray_type line_locators_locs;
+static GTY(()) varray_type line_locators_lines;
+static GTY(()) varray_type file_locators_locs;
+static GTY(()) varray_type file_locators_files;
+int prologue_locator;
+int epilogue_locator;
+
+/* During the RTL expansion the lexical blocks and line numbers are
+   represented via INSN_NOTEs.  Replace them by representation using
+   INSN_LOCATORs.  */
 
 void
-scope_to_insns_initialize ()
+insn_locators_initialize ()
 {
   tree block = NULL;
+  tree last_block = NULL;
   rtx insn, next;
+  int loc = 0;
+  int line_number = 0, last_line_number = 0;
+  char *file_name = NULL, *last_file_name = NULL;
+
+  prologue_locator = epilogue_locator = 0;
+
+  VARRAY_INT_INIT (block_locators_locs, 32, "block_locators_locs");
+  VARRAY_TREE_INIT (block_locators_blocks, 32, "block_locators_blocks");
+  VARRAY_INT_INIT (line_locators_locs, 32, "line_locators_locs");
+  VARRAY_INT_INIT (line_locators_lines, 32, "line_locators_lines");
+  VARRAY_INT_INIT (file_locators_locs, 32, "file_locators_locs");
+  VARRAY_CHAR_PTR_INIT (file_locators_files, 32, "file_locators_files");
 
   for (insn = get_insns (); insn; insn = next)
     {
       next = NEXT_INSN (insn);
 
-      if (active_insn_p (insn)
-         && GET_CODE (PATTERN (insn)) != ADDR_VEC
-         && GET_CODE (PATTERN (insn)) != ADDR_DIFF_VEC)
-        INSN_SCOPE (insn) = block;
+      if ((active_insn_p (insn)
+          && GET_CODE (PATTERN (insn)) != ADDR_VEC
+          && GET_CODE (PATTERN (insn)) != ADDR_DIFF_VEC)
+         || !NEXT_INSN (insn)
+         || (!prologue_locator && file_name))
+       {
+         if (last_block != block)
+           {
+             loc++;
+             VARRAY_PUSH_INT (block_locators_locs, loc);
+             VARRAY_PUSH_TREE (block_locators_blocks, block);
+             last_block = block;
+           }
+         if (last_line_number != line_number)
+           {
+             loc++;
+             VARRAY_PUSH_INT (line_locators_locs, loc);
+             VARRAY_PUSH_INT (line_locators_lines, line_number);
+             last_line_number = line_number;
+           }
+         if (last_file_name != file_name)
+           {
+             loc++;
+             VARRAY_PUSH_INT (file_locators_locs, loc);
+             VARRAY_PUSH_CHAR_PTR (file_locators_files, file_name);
+             last_file_name = file_name;
+           }
+       }
+      if (!prologue_locator && file_name)
+       prologue_locator = loc;
+      if (!NEXT_INSN (insn))
+       epilogue_locator = loc;
+      if (active_insn_p (insn))
+        INSN_LOCATOR (insn) = loc;
       else if (GET_CODE (insn) == NOTE)
        {
          switch (NOTE_LINE_NUMBER (insn))
@@ -243,6 +306,11 @@ scope_to_insns_initialize ()
              delete_insn (insn);
              break;
            default:
+             if (NOTE_LINE_NUMBER (insn) > 0)
+               {
+                 line_number = NOTE_LINE_NUMBER (insn);
+                 file_name = (char *)NOTE_SOURCE_FILE (insn);
+               }
              break;
            }
        }
@@ -330,11 +398,98 @@ change_scope (orig_insn, s1, s2)
     }
 }
 
+/* Return lexical scope block insn belong to.  */
+static tree
+insn_scope (insn)
+   rtx insn;
+{
+  int max = VARRAY_ACTIVE_SIZE (block_locators_locs);
+  int min = 0;
+  int loc = INSN_LOCATOR (insn);
+
+  if (!max || !loc)
+    return NULL;
+  while (1)
+    {
+      int pos = (min + max) / 2;
+      int tmp = VARRAY_INT (block_locators_locs, pos);
+
+      if (tmp <= loc && min != pos)
+       min = pos;
+      else if (tmp > loc && max != pos)
+       max = pos;
+      else
+       {
+         min = pos;
+         break;
+       }
+    }
+   return VARRAY_TREE (block_locators_blocks, min);
+}
+
+/* Return line number of the statement that produced this insn.  */
+int
+insn_line (insn)
+   rtx insn;
+{
+  int max = VARRAY_ACTIVE_SIZE (line_locators_locs);
+  int min = 0;
+  int loc = INSN_LOCATOR (insn);
+
+  if (!max || !loc)
+    return 0;
+  while (1)
+    {
+      int pos = (min + max) / 2;
+      int tmp = VARRAY_INT (line_locators_locs, pos);
+
+      if (tmp <= loc && min != pos)
+       min = pos;
+      else if (tmp > loc && max != pos)
+       max = pos;
+      else
+       {
+         min = pos;
+         break;
+       }
+    }
+   return VARRAY_INT (line_locators_lines, min);
+}
+
+/* Return source file of the statement that produced this insn.  */
+const char *
+insn_file (insn)
+   rtx insn;
+{
+  int max = VARRAY_ACTIVE_SIZE (file_locators_locs);
+  int min = 0;
+  int loc = INSN_LOCATOR (insn);
+
+  if (!max || !loc)
+    return NULL;
+  while (1)
+    {
+      int pos = (min + max) / 2;
+      int tmp = VARRAY_INT (file_locators_locs, pos);
+
+      if (tmp <= loc && min != pos)
+       min = pos;
+      else if (tmp > loc && max != pos)
+       max = pos;
+      else
+       {
+         min = pos;
+         break;
+       }
+    }
+   return VARRAY_CHAR_PTR (file_locators_files, min);
+}
+
 /* Rebuild all the NOTE_INSN_BLOCK_BEG and NOTE_INSN_BLOCK_END notes based
    on the scope tree and the newly reordered instructions.  */
 
 void
-scope_to_insns_finalize ()
+reemit_insn_block_notes ()
 {
   tree cur_block = DECL_INITIAL (cfun->decl);
   rtx insn, note;
@@ -346,7 +501,7 @@ scope_to_insns_finalize ()
     {
       tree this_block;
 
-      this_block = INSN_SCOPE (insn);
+      this_block = insn_scope (insn);
       /* For sequences compute scope resulting from merging all scopes
          of instructions nested inside.  */
       if (GET_CODE (PATTERN (insn)) == SEQUENCE)
@@ -357,7 +512,7 @@ scope_to_insns_finalize ()
          this_block = NULL;
          for (i = 0; i < XVECLEN (body, 0); i++)
            this_block = choose_inner_scope (this_block,
-                                        INSN_SCOPE (XVECEXP (body, 0, i)));
+                                        insn_scope (XVECEXP (body, 0, i)));
        }
       if (! this_block)
        continue;
@@ -1051,3 +1206,5 @@ cfg_layout_finalize ()
   verify_flow_info ();
 #endif
 }
+
+#include "gt-cfglayout.h"
index 48f11af753bb15c63e66200547411a0e0710772e..4ae8b6677c9955366fa2658acfa17eeaf995382c 100644 (file)
@@ -41,5 +41,5 @@ extern void cfg_layout_initialize     PARAMS ((struct loops *));
 extern void cfg_layout_finalize                PARAMS ((void));
 extern bool cfg_layout_can_duplicate_bb_p PARAMS ((basic_block));
 extern basic_block cfg_layout_duplicate_bb PARAMS ((basic_block, edge));
-extern void scope_to_insns_initialize  PARAMS ((void));
-extern void scope_to_insns_finalize    PARAMS ((void));
+extern void insn_locators_initialize   PARAMS ((void));
+extern void reemit_insn_block_notes    PARAMS ((void));
index 68214e9b19882911f1b727295092cce6c4f65232..3e2f089bed978f1f77427b8968d9b1f3b621832d 100644 (file)
@@ -1702,7 +1702,7 @@ try_combine (rtx i3, rtx i2, rtx i1, int *new_direct_jump_p)
             as I2 will not cause a problem.  */
 
          i1 = gen_rtx_INSN (VOIDmode, INSN_UID (i2), NULL_RTX, i2,
-                            BLOCK_FOR_INSN (i2), INSN_SCOPE (i2),
+                            BLOCK_FOR_INSN (i2), INSN_LOCATOR (i2),
                             XVECEXP (PATTERN (i2), 0, 1), -1, NULL_RTX,
                             NULL_RTX);
 
index de6e94cb5506f2fa62fe5cee7f7baba68c5b032c..208af572c6dd642091191faf050819394691c9e3 100644 (file)
@@ -3586,7 +3586,7 @@ try_split (pat, trial, last)
        }
     }
 
-  tem = emit_insn_after_scope (seq, trial, INSN_SCOPE (trial));
+  tem = emit_insn_after_setloc (seq, trial, INSN_LOCATOR (trial));
 
   delete_insn (trial);
   if (has_barrier)
@@ -3624,7 +3624,7 @@ make_insn_raw (pattern)
   INSN_CODE (insn) = -1;
   LOG_LINKS (insn) = NULL;
   REG_NOTES (insn) = NULL;
-  INSN_SCOPE (insn) = NULL;
+  INSN_LOCATOR (insn) = 0;
   BLOCK_FOR_INSN (insn) = NULL;
 
 #ifdef ENABLE_RTL_CHECKING
@@ -3658,7 +3658,7 @@ make_jump_insn_raw (pattern)
   LOG_LINKS (insn) = NULL;
   REG_NOTES (insn) = NULL;
   JUMP_LABEL (insn) = NULL;
-  INSN_SCOPE (insn) = NULL;
+  INSN_LOCATOR (insn) = 0;
   BLOCK_FOR_INSN (insn) = NULL;
 
   return insn;
@@ -3680,7 +3680,7 @@ make_call_insn_raw (pattern)
   LOG_LINKS (insn) = NULL;
   REG_NOTES (insn) = NULL;
   CALL_INSN_FUNCTION_USAGE (insn) = NULL;
-  INSN_SCOPE (insn) = NULL;
+  INSN_LOCATOR (insn) = 0;
   BLOCK_FOR_INSN (insn) = NULL;
 
   return insn;
@@ -4653,11 +4653,11 @@ emit_line_note_after (file, line, after)
   return note;
 }
 \f
-/* Like emit_insn_after, but set INSN_SCOPE according to SCOPE.  */
+/* Like emit_insn_after, but set INSN_LOCATOR according to SCOPE.  */
 rtx
-emit_insn_after_scope (pattern, after, scope)
+emit_insn_after_setloc (pattern, after, loc)
      rtx pattern, after;
-     tree scope;
+     int loc;
 {
   rtx last = emit_insn_after (pattern, after);
 
@@ -4665,7 +4665,7 @@ emit_insn_after_scope (pattern, after, scope)
   while (1)
     {
       if (active_insn_p (after))
-       INSN_SCOPE (after) = scope;
+       INSN_LOCATOR (after) = loc;
       if (after == last)
        break;
       after = NEXT_INSN (after);
@@ -4673,11 +4673,11 @@ emit_insn_after_scope (pattern, after, scope)
   return last;
 }
 
-/* Like emit_jump_insn_after, but set INSN_SCOPE according to SCOPE.  */
+/* Like emit_jump_insn_after, but set INSN_LOCATOR according to SCOPE.  */
 rtx
-emit_jump_insn_after_scope (pattern, after, scope)
+emit_jump_insn_after_setloc (pattern, after, loc)
      rtx pattern, after;
-     tree scope;
+     int loc;
 {
   rtx last = emit_jump_insn_after (pattern, after);
 
@@ -4685,7 +4685,7 @@ emit_jump_insn_after_scope (pattern, after, scope)
   while (1)
     {
       if (active_insn_p (after))
-       INSN_SCOPE (after) = scope;
+       INSN_LOCATOR (after) = loc;
       if (after == last)
        break;
       after = NEXT_INSN (after);
@@ -4693,11 +4693,11 @@ emit_jump_insn_after_scope (pattern, after, scope)
   return last;
 }
 
-/* Like emit_call_insn_after, but set INSN_SCOPE according to SCOPE.  */
+/* Like emit_call_insn_after, but set INSN_LOCATOR according to SCOPE.  */
 rtx
-emit_call_insn_after_scope (pattern, after, scope)
+emit_call_insn_after_setloc (pattern, after, loc)
      rtx pattern, after;
-     tree scope;
+     int loc;
 {
   rtx last = emit_call_insn_after (pattern, after);
 
@@ -4705,7 +4705,7 @@ emit_call_insn_after_scope (pattern, after, scope)
   while (1)
     {
       if (active_insn_p (after))
-       INSN_SCOPE (after) = scope;
+       INSN_LOCATOR (after) = loc;
       if (after == last)
        break;
       after = NEXT_INSN (after);
@@ -4713,11 +4713,11 @@ emit_call_insn_after_scope (pattern, after, scope)
   return last;
 }
 
-/* Like emit_insn_before, but set INSN_SCOPE according to SCOPE.  */
+/* Like emit_insn_before, but set INSN_LOCATOR according to SCOPE.  */
 rtx
-emit_insn_before_scope (pattern, before, scope)
+emit_insn_before_setloc (pattern, before, loc)
      rtx pattern, before;
-     tree scope;
+     int loc;
 {
   rtx first = PREV_INSN (before);
   rtx last = emit_insn_before (pattern, before);
@@ -4726,7 +4726,7 @@ emit_insn_before_scope (pattern, before, scope)
   while (1)
     {
       if (active_insn_p (first))
-       INSN_SCOPE (first) = scope;
+       INSN_LOCATOR (first) = loc;
       if (first == last)
        break;
       first = NEXT_INSN (first);
@@ -5798,7 +5798,7 @@ emit_copy_of_insn_after (insn, after)
   /* Update LABEL_NUSES.  */
   mark_jump_label (PATTERN (new), new, 0);
 
-  INSN_SCOPE (new) = INSN_SCOPE (insn);
+  INSN_LOCATOR (new) = INSN_LOCATOR (insn);
 
   /* Copy all REG_NOTES except REG_LABEL since mark_jump_label will
      make them.  */
index ab7a635e1e7e6a9de7d59c7fda0cec007d3b454e..dae455d2990b8c8c4b8228ae4db1b2bf94f82d4a 100644 (file)
@@ -205,7 +205,7 @@ static int asm_insn_count   PARAMS ((rtx));
 #endif
 static void profile_function   PARAMS ((FILE *));
 static void profile_after_prologue PARAMS ((FILE *));
-static void notice_source_line PARAMS ((rtx));
+static bool notice_source_line PARAMS ((rtx));
 static rtx walk_alter_subreg   PARAMS ((rtx *));
 static void output_asm_name    PARAMS ((void));
 static void output_alternate_entry_point PARAMS ((FILE *, rtx));
@@ -1338,7 +1338,7 @@ asm_insn_count (body)
 
 void
 final_start_function (first, file, optimize)
-     rtx first;
+     rtx first ATTRIBUTE_UNUSED;
      FILE *file;
      int optimize ATTRIBUTE_UNUSED;
 {
@@ -1359,8 +1359,8 @@ final_start_function (first, file, optimize)
     }
 #endif
 
-  if (NOTE_LINE_NUMBER (first) != NOTE_INSN_DELETED)
-    notice_source_line (first);
+  last_linenum = 0;
+  last_filename = 0;
   high_block_linenum = high_function_linenum = last_linenum;
 
   (*debug_hooks->begin_prologue) (last_linenum, last_filename);
@@ -1392,7 +1392,7 @@ final_start_function (first, file, optimize)
   if (write_symbols)
     {
       remove_unnecessary_notes ();
-      scope_to_insns_finalize ();
+      reemit_insn_block_notes ();
       number_blocks (current_function_decl);
       /* We never actually put out begin/end notes for the top-level
         block in the function.  But, conceptually, that block is
@@ -1821,51 +1821,6 @@ final_scan_insn (insn, file, optimize, prescan, nopeepholes)
        default:
          if (NOTE_LINE_NUMBER (insn) <= 0)
            abort ();
-
-         /* This note is a line-number.  */
-         {
-           rtx note;
-           int note_after = 0;
-
-           /* If there is anything real after this note, output it.
-              If another line note follows, omit this one.  */
-           for (note = NEXT_INSN (insn); note; note = NEXT_INSN (note))
-             {
-               if (GET_CODE (note) != NOTE && GET_CODE (note) != CODE_LABEL)
-                 break;
-
-               /* These types of notes can be significant
-                  so make sure the preceding line number stays.  */
-               else if (GET_CODE (note) == NOTE
-                        && (NOTE_LINE_NUMBER (note) == NOTE_INSN_BLOCK_BEG
-                            || NOTE_LINE_NUMBER (note) == NOTE_INSN_BLOCK_END
-                            || NOTE_LINE_NUMBER (note) == NOTE_INSN_FUNCTION_BEG))
-                 break;
-               else if (GET_CODE (note) == NOTE && NOTE_LINE_NUMBER (note) > 0)
-                 {
-                   /* Another line note follows; we can delete this note
-                      if no intervening line numbers have notes elsewhere.  */
-                   int num;
-                   for (num = NOTE_LINE_NUMBER (insn) + 1;
-                        num < NOTE_LINE_NUMBER (note);
-                        num++)
-                     if (line_note_exists[num])
-                       break;
-
-                   if (num >= NOTE_LINE_NUMBER (note))
-                     note_after = 1;
-                   break;
-                 }
-             }
-
-           /* Output this line note if it is the first or the last line
-              note in a row.  */
-           if (!note_after)
-             {
-               notice_source_line (insn);
-               (*debug_hooks->source_line) (last_linenum, last_filename);
-             }
-         }
          break;
        }
       break;
@@ -2091,6 +2046,12 @@ final_scan_insn (insn, file, optimize, prescan, nopeepholes)
 
            break;
          }
+       /* Output this line note if it is the first or the last line
+          note in a row.  */
+       if (notice_source_line (insn))
+         {
+           (*debug_hooks->source_line) (last_linenum, last_filename);
+         }
 
        if (GET_CODE (body) == ASM_INPUT)
          {
@@ -2561,16 +2522,22 @@ final_scan_insn (insn, file, optimize, prescan, nopeepholes)
 /* Output debugging info to the assembler file FILE
    based on the NOTE-insn INSN, assumed to be a line number.  */
 
-static void
+static bool
 notice_source_line (insn)
      rtx insn;
 {
-  const char *filename = NOTE_SOURCE_FILE (insn);
+  const char *filename = insn_file (insn);
+  int linenum = insn_line (insn);
 
-  last_filename = filename;
-  last_linenum = NOTE_LINE_NUMBER (insn);
-  high_block_linenum = MAX (last_linenum, high_block_linenum);
-  high_function_linenum = MAX (last_linenum, high_function_linenum);
+  if (filename && (filename != last_filename || last_linenum != linenum))
+    {
+      last_filename = filename;
+      last_linenum = linenum;
+      high_block_linenum = MAX (last_linenum, high_block_linenum);
+      high_function_linenum = MAX (last_linenum, high_function_linenum);
+      return true;
+    }
+  return false;
 }
 \f
 /* For each operand in INSN, simplify (subreg (reg)) so that it refers
index 9924bb589b7474201128a075fdfef9abdb9a84b9..e59bf6a954c59f8b9ab4c357e116873837c5042b 100644 (file)
@@ -300,6 +300,7 @@ static void do_clobber_return_reg PARAMS ((rtx, void *));
 static void do_use_return_reg PARAMS ((rtx, void *));
 static void instantiate_virtual_regs_lossage PARAMS ((rtx));
 static tree split_complex_args (tree);
+static void set_insn_locators (rtx, int);
 \f
 /* Pointer to chain of `struct function' for containing functions.  */
 static GTY(()) struct function *outer_function_chain;
@@ -7348,6 +7349,20 @@ record_insns (insns, vecp)
     }
 }
 
+/* Set the specified locator to the insn chain.  */
+static void
+set_insn_locators (insn, loc)
+  rtx insn;
+  int loc;
+{
+  while (insn != NULL_RTX)
+    {
+      if (INSN_P (insn))
+       INSN_LOCATOR (insn) = loc;
+      insn = NEXT_INSN (insn);
+    }
+}
+
 /* Determine how many INSN_UIDs in VEC are part of INSN.  Because we can
    be running after reorg, SEQUENCE rtl is possible.  */
 
@@ -7754,6 +7769,7 @@ thread_prologue_and_epilogue_insns (f)
 
       seq = get_insns ();
       end_sequence ();
+      set_insn_locators (seq, prologue_locator);
 
       /* Can't deal with multiple successors of the entry block
          at the moment.  Function should always have at least one
@@ -7901,6 +7917,7 @@ thread_prologue_and_epilogue_insns (f)
 
       /* Retain a map of the epilogue insns.  */
       record_insns (seq, &epilogue);
+      set_insn_locators (seq, epilogue_locator);
 
       seq = get_insns ();
       end_sequence ();
@@ -7936,6 +7953,7 @@ epilogue_done:
         avoid getting rid of sibcall epilogue insns.  Do this before we
         actually emit the sequence.  */
       record_insns (seq, &sibcall_epilogue);
+      set_insn_locators (seq, epilogue_locator);
 
       i = PREV_INSN (insn);
       newinsn = emit_insn_before (seq, insn);
index 87479060784b264db663bdcdf1607ed1be22a436..84788f0bd3a8e7141ea459dea6a1ccd077e3c492 100644 (file)
@@ -718,7 +718,7 @@ noce_try_store_flag (if_info)
 
       seq = get_insns ();
       end_sequence ();
-      emit_insn_before_scope (seq, if_info->jump, INSN_SCOPE (if_info->insn_a));
+      emit_insn_before_setloc (seq, if_info->jump, INSN_LOCATOR (if_info->insn_a));
 
       return TRUE;
     }
@@ -853,7 +853,7 @@ noce_try_store_flag_constants (if_info)
       if (seq_contains_jump (seq))
        return FALSE;
 
-      emit_insn_before_scope (seq, if_info->jump, INSN_SCOPE (if_info->insn_a));
+      emit_insn_before_setloc (seq, if_info->jump, INSN_LOCATOR (if_info->insn_a));
 
       return TRUE;
     }
@@ -901,8 +901,8 @@ noce_try_addcc (if_info)
 
              seq = get_insns ();
              end_sequence ();
-             emit_insn_before_scope (seq, if_info->jump,
-                                     INSN_SCOPE (if_info->insn_a));
+             emit_insn_before_setloc (seq, if_info->jump,
+                                     INSN_LOCATOR (if_info->insn_a));
              return TRUE;
            }
          end_sequence ();
@@ -943,8 +943,8 @@ noce_try_addcc (if_info)
              if (seq_contains_jump (seq))
                return FALSE;
 
-             emit_insn_before_scope (seq, if_info->jump,
-                                     INSN_SCOPE (if_info->insn_a));
+             emit_insn_before_setloc (seq, if_info->jump,
+                                     INSN_LOCATOR (if_info->insn_a));
 
              return TRUE;
            }
@@ -996,8 +996,8 @@ noce_try_store_flag_mask (if_info)
          if (seq_contains_jump (seq))
            return FALSE;
 
-         emit_insn_before_scope (seq, if_info->jump,
-                                 INSN_SCOPE (if_info->insn_a));
+         emit_insn_before_setloc (seq, if_info->jump,
+                                 INSN_LOCATOR (if_info->insn_a));
 
          return TRUE;
        }
@@ -1092,8 +1092,8 @@ noce_try_cmove (if_info)
 
          seq = get_insns ();
          end_sequence ();
-         emit_insn_before_scope (seq, if_info->jump,
-                                 INSN_SCOPE (if_info->insn_a));
+         emit_insn_before_setloc (seq, if_info->jump,
+                                 INSN_LOCATOR (if_info->insn_a));
          return TRUE;
        }
       else
@@ -1255,7 +1255,7 @@ noce_try_cmove_arith (if_info)
 
   tmp = get_insns ();
   end_sequence ();
-  emit_insn_before_scope (tmp, if_info->jump, INSN_SCOPE (if_info->insn_a));
+  emit_insn_before_setloc (tmp, if_info->jump, INSN_LOCATOR (if_info->insn_a));
   return TRUE;
 
  end_seq_and_fail:
@@ -1507,7 +1507,7 @@ noce_try_minmax (if_info)
   if (seq_contains_jump (seq))
     return FALSE;
 
-  emit_insn_before_scope (seq, if_info->jump, INSN_SCOPE (if_info->insn_a));
+  emit_insn_before_setloc (seq, if_info->jump, INSN_LOCATOR (if_info->insn_a));
   if_info->cond = cond;
   if_info->cond_earliest = earliest;
 
@@ -1625,7 +1625,7 @@ noce_try_abs (if_info)
   if (seq_contains_jump (seq))
     return FALSE;
 
-  emit_insn_before_scope (seq, if_info->jump, INSN_SCOPE (if_info->insn_a));
+  emit_insn_before_setloc (seq, if_info->jump, INSN_LOCATOR (if_info->insn_a));
   if_info->cond = cond;
   if_info->cond_earliest = earliest;
 
@@ -1945,7 +1945,7 @@ noce_process_if_block (ce_info)
       insn_b = get_insns ();
       end_sequence ();
 
-      emit_insn_after_scope (insn_b, test_bb->end, INSN_SCOPE (insn_a));
+      emit_insn_after_setloc (insn_b, test_bb->end, INSN_LOCATOR (insn_a));
     }
 
   /* Merge the blocks!  */
@@ -2548,7 +2548,7 @@ find_cond_trap (test_bb, then_edge, else_edge)
     return FALSE;
 
   /* Emit the new insns before cond_earliest.  */
-  emit_insn_before_scope (seq, cond_earliest, INSN_SCOPE (trap));
+  emit_insn_before_setloc (seq, cond_earliest, INSN_LOCATOR (trap));
 
   /* Delete the trap block if possible.  */
   remove_edge (trap_bb == then_bb ? then_edge : else_edge);
index 4f31c79fa2d938b6bff71e3b4ad2f366819ee711..4152fb27fa4f37734051f747db50156267aed407 100644 (file)
@@ -1546,7 +1546,7 @@ copy_insn_list (insns, map, static_chain_value)
 #else
          try_constants (copy, map);
 #endif
-         INSN_SCOPE (copy) = INSN_SCOPE (insn);
+         INSN_LOCATOR (copy) = INSN_LOCATOR (insn);
          break;
 
        case JUMP_INSN:
@@ -1567,7 +1567,7 @@ copy_insn_list (insns, map, static_chain_value)
          cc0_insn = 0;
 #endif
          try_constants (copy, map);
-         INSN_SCOPE (copy) = INSN_SCOPE (insn);
+         INSN_LOCATOR (copy) = INSN_LOCATOR (insn);
 
          /* If this used to be a conditional jump insn but whose branch
             direction is now know, we must do something special.  */
@@ -1635,7 +1635,7 @@ copy_insn_list (insns, map, static_chain_value)
 
          SIBLING_CALL_P (copy) = SIBLING_CALL_P (insn);
          CONST_OR_PURE_CALL_P (copy) = CONST_OR_PURE_CALL_P (insn);
-         INSN_SCOPE (copy) = INSN_SCOPE (insn);
+         INSN_LOCATOR (copy) = INSN_LOCATOR (insn);
 
          /* Because the USAGE information potentially contains objects other
             than hard registers, we need to copy it.  */
index f15e2abae107d66e240f802f65d7d57790e3d09c..40166b40e31169a6f04403d42cd3fe52209b96cb 100644 (file)
@@ -429,7 +429,7 @@ duplicate_loop_exit_test (loop_start)
            replace_regs (PATTERN (copy), reg_map, max_reg, 1);
 
          mark_jump_label (PATTERN (copy), copy, 0);
-         INSN_SCOPE (copy) = INSN_SCOPE (insn);
+         INSN_LOCATOR (copy) = INSN_LOCATOR (insn);
 
          /* Copy all REG_NOTES except REG_LABEL since mark_jump_label will
             make them.  */
@@ -455,7 +455,7 @@ duplicate_loop_exit_test (loop_start)
        case JUMP_INSN:
          copy = emit_jump_insn_before (copy_insn (PATTERN (insn)),
                                        loop_start);
-         INSN_SCOPE (copy) = INSN_SCOPE (insn);
+         INSN_LOCATOR (copy) = INSN_LOCATOR (insn);
          if (reg_map)
            replace_regs (PATTERN (copy), reg_map, max_reg, 1);
          mark_jump_label (PATTERN (copy), copy, 0);
index 3002ccb382b931c843ac07c184d307de3e3e2bd3..165db771e35df4aee7d33d07c5c96b2bf1d9f5d8 100644 (file)
@@ -379,7 +379,17 @@ print_rtx (in_rtx)
        break;
 
       case 'i':
-       if (i == 6 && GET_CODE (in_rtx) == NOTE)
+       if (i == 4 && GET_RTX_CLASS (GET_CODE (in_rtx)) == 'i')
+         {
+#ifndef GENERATOR_FILE
+           /*  Pretty-print insn locators.  Ignore scoping as it is mostly
+               redundant with line number information and do not print anything
+               when there is no location information available.  */
+           if (INSN_LOCATOR (in_rtx) && insn_file (in_rtx))
+             fprintf(outfile, " %s:%i", insn_file (in_rtx), insn_line (in_rtx));
+#endif
+         }
+       else if (i == 6 && GET_CODE (in_rtx) == NOTE)
          {
            /* This field is only used for NOTE_INSN_DELETED_LABEL, and
               other times often contains garbage from INSN->NOTE death.  */
index 6f4a73335e2c4236ebd3b94c8b3e206afc58e49a..8ea1e8d58dc7453572104d0c8bbf10111a3e7fe4 100644 (file)
@@ -3249,8 +3249,8 @@ peephole2_optimize (dump_file)
                                        REG_EH_REGION, NULL_RTX);
 
                  /* Replace the old sequence with the new.  */
-                 try = emit_insn_after_scope (try, peep2_insn_data[i].insn,
-                                              INSN_SCOPE (peep2_insn_data[i].insn));
+                 try = emit_insn_after_setloc (try, peep2_insn_data[i].insn,
+                                               INSN_LOCATOR (peep2_insn_data[i].insn));
                  before_try = PREV_INSN (insn);
                  delete_insn_chain (insn, peep2_insn_data[i].insn);
 
index 6fc29b77ccd6e6f52cdf76375dadb0d19fd23387..1388b6ffd5584678a6e836b36d4861d965468701 100644 (file)
@@ -603,18 +603,18 @@ DEF_RTL_EXPR (ATTR_FLAG, "attr_flag", "s", 'x')
    ---------------------------------------------------------------------- */
 
 /* An instruction that cannot jump.  */
-DEF_RTL_EXPR(INSN, "insn", "iuuBteiee", 'i')
+DEF_RTL_EXPR(INSN, "insn", "iuuBieiee", 'i')
 
 /* An instruction that can possibly jump.
    Fields ( rtx->fld[] ) have exact same meaning as INSN's.  */
-DEF_RTL_EXPR(JUMP_INSN, "jump_insn", "iuuBteiee0", 'i')
+DEF_RTL_EXPR(JUMP_INSN, "jump_insn", "iuuBieiee0", 'i')
 
 /* An instruction that can possibly call a subroutine
    but which will not change which instruction comes next
    in the current function.
    Field ( rtx->fld[9] ) is CALL_INSN_FUNCTION_USAGE.
    All other fields ( rtx->fld[] ) have exact same meaning as INSN's.  */
-DEF_RTL_EXPR(CALL_INSN, "call_insn", "iuuBteieee", 'i')
+DEF_RTL_EXPR(CALL_INSN, "call_insn", "iuuBieieee", 'i')
 
 /* A marker that indicates that control will not flow through.  */
 DEF_RTL_EXPR(BARRIER, "barrier", "iuu000000", 'x')
index 3e4a1c02d85caa4d5d02445055fc9123efd705fa..8b2ae092ebbedaa98267369e8401be079bb273cd 100644 (file)
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -538,7 +538,7 @@ do {                                \
 #define NEXT_INSN(INSN)        XEXP (INSN, 2)
 
 #define BLOCK_FOR_INSN(INSN) XBBDEF (INSN, 3)
-#define INSN_SCOPE(INSN) XTREE (INSN, 4)
+#define INSN_LOCATOR(INSN) XINT (INSN, 4)
 /* The body of an insn.  */
 #define PATTERN(INSN)  XEXP (INSN, 5)
 
@@ -1513,20 +1513,20 @@ extern rtx assign_stack_temp_for_type   PARAMS ((enum machine_mode,
 extern rtx assign_temp                 PARAMS ((tree, int, int, int));
 /* In emit-rtl.c */
 extern rtx emit_insn_before            PARAMS ((rtx, rtx));
-extern rtx emit_insn_before_scope      PARAMS ((rtx, rtx, tree));
+extern rtx emit_insn_before_setloc     PARAMS ((rtx, rtx, int));
 extern rtx emit_jump_insn_before       PARAMS ((rtx, rtx));
-extern rtx emit_jump_insn_before_scope PARAMS ((rtx, rtx, tree));
+extern rtx emit_jump_insn_before_setloc        PARAMS ((rtx, rtx, int));
 extern rtx emit_call_insn_before       PARAMS ((rtx, rtx));
-extern rtx emit_call_insn_before_scope PARAMS ((rtx, rtx, tree));
+extern rtx emit_call_insn_before_setloc        PARAMS ((rtx, rtx, int));
 extern rtx emit_barrier_before         PARAMS ((rtx));
 extern rtx emit_label_before           PARAMS ((rtx, rtx));
 extern rtx emit_note_before            PARAMS ((int, rtx));
 extern rtx emit_insn_after             PARAMS ((rtx, rtx));
-extern rtx emit_insn_after_scope       PARAMS ((rtx, rtx, tree));
+extern rtx emit_insn_after_setloc      PARAMS ((rtx, rtx, int));
 extern rtx emit_jump_insn_after                PARAMS ((rtx, rtx));
-extern rtx emit_jump_insn_after_scope  PARAMS ((rtx, rtx, tree));
+extern rtx emit_jump_insn_after_setloc PARAMS ((rtx, rtx, int));
 extern rtx emit_call_insn_after                PARAMS ((rtx, rtx));
-extern rtx emit_call_insn_after_scope  PARAMS ((rtx, rtx, tree));
+extern rtx emit_call_insn_after_setloc PARAMS ((rtx, rtx, int));
 extern rtx emit_barrier_after          PARAMS ((rtx));
 extern rtx emit_label_after            PARAMS ((rtx, rtx));
 extern rtx emit_note_after             PARAMS ((int, rtx));
@@ -1558,6 +1558,9 @@ extern rtx prev_cc0_setter                PARAMS ((rtx));
 
 /* In cfglayout.c  */
 extern tree choose_inner_scope         PARAMS ((tree, tree));
+extern int insn_line                   PARAMS ((rtx));
+extern const char * insn_file          PARAMS ((rtx));
+extern int prologue_locator, epilogue_locator;
 
 /* In jump.c */
 extern rtx next_nondeleted_insn                PARAMS ((rtx));
index ea9388ca4552a0b591805b1fb8eb409b0b0935b4..85157e7bb0ddfae08ff587c423b004e240f6f9e0 100644 (file)
@@ -3570,7 +3570,7 @@ rest_of_compilation (tree decl)
 
   timevar_pop (TV_JUMP);
 
-  scope_to_insns_initialize ();
+  insn_locators_initialize ();
   /* Complete generation of exception handling code.  */
   if (doing_eh (0))
     {
index 396ec42b93b56a8f346d6aaac952361bd4b5d6cd..43539c34eaf49aa932376d8e5802ead2ebc2d345 100644 (file)
@@ -2040,7 +2040,7 @@ copy_loop_body (loop, copy_start, copy_end, map, exit_label, last_iteration,
              copy = emit_insn (pattern);
            }
          REG_NOTES (copy) = initial_reg_note_copy (REG_NOTES (insn), map);
-         INSN_SCOPE (copy) = INSN_SCOPE (insn);
+         INSN_LOCATOR (copy) = INSN_LOCATOR (insn);
 
          /* If there is a REG_EQUAL note present whose value
             is not loop invariant, then delete it, since it
@@ -2094,7 +2094,7 @@ copy_loop_body (loop, copy_start, copy_end, map, exit_label, last_iteration,
          pattern = copy_rtx_and_substitute (PATTERN (insn), map, 0);
          copy = emit_jump_insn (pattern);
          REG_NOTES (copy) = initial_reg_note_copy (REG_NOTES (insn), map);
-         INSN_SCOPE (copy) = INSN_SCOPE (insn);
+         INSN_LOCATOR (copy) = INSN_LOCATOR (insn);
 
          if (JUMP_LABEL (insn))
            {
@@ -2218,7 +2218,7 @@ copy_loop_body (loop, copy_start, copy_end, map, exit_label, last_iteration,
          pattern = copy_rtx_and_substitute (PATTERN (insn), map, 0);
          copy = emit_call_insn (pattern);
          REG_NOTES (copy) = initial_reg_note_copy (REG_NOTES (insn), map);
-         INSN_SCOPE (copy) = INSN_SCOPE (insn);
+         INSN_LOCATOR (copy) = INSN_LOCATOR (insn);
          SIBLING_CALL_P (copy) = SIBLING_CALL_P (insn);
          CONST_OR_PURE_CALL_P (copy) = CONST_OR_PURE_CALL_P (insn);