Remove some of line number notes maintaining code

Jan Hubicka jh@suse.cz
Sat Nov 11 09:35:00 GMT 2006


Hi,
this patch remove some of line number note maintainance and in some
cases adds code to properly handle locators.
I've left out some of scheduling bits, as this needs more consideration
how to nicely deal with the few remaining note insns (the current bits
are definitly overdesigned for the few cases).

Bootstrapped/regtested i686-linux, OK?
:ADDPATCH middle-end:
Honza

	* tree-pass.h (pass_purge_lineno_notes): Remove declaration.
	* modulo-sched.c (find_line_note): Remove.
	(loop_canon_p): Do not worry about line number notes.
	(sms_schedule): Likewise.
	* cse.c (cse_main): Likewise.
	* regmove.c (fixup_match_1): Likewise
	* function.c (emit_return_info_block): Likewise.
	(expand_function_end): Likewise.
	(thread_prologue_an_epilogue_insns): Likewise.
	* cfgrtl.c (try_redirect_by_replacing_jump, rtl_tidy_fallthru_edge):
	Likewise.
	* emit-rtl.c (find_line_note, emit_insn_after_with_line_notes,
	emit_note_copy_after): Kill.
	(emit_note_copy): Do not worry about line numbers.
	* jump.c (purge_line_number_notes): Kill.
	(pass_purge_lineno_notes): Kill.
	* cfgcleanup.c (rest_of_handle_jump2): Kill purge_line_number_notes
	call.
	* rtl.h (emit_note_copy_after, emit_insn_after_with_line_notes): Kill.
	* passes.c (init_optimization_passes): Don't purge_lineno_notes.
	* sched-ebb.c (schedule_ebbs): Don't do rm_redundant_line_notes.
	* tree-pass.h (pass_purge_lineno_notes): Kill.
	* sched-ebb.c (schedule_ebb): Don't rm_line_notes,
	rm_redundant_line_notes.
	* sched-rgb.c (schedule_region): Don't rm_line_notes,
	rm_redundant_line_notes.
	* sched-int.h (rm_line_notes, rm_redundant_line_notes): Kill.
	* haifa-sched.c: Update comment about handling notes.
 	(unlink_line_notes): Kill.
	(rm_line_notes): Kill.
	(save_line_notes): Simplify.
	(rm_redundant_line_notes): Kill.
Index: tree-pass.h
===================================================================
*** tree-pass.h	(revision 118649)
--- tree-pass.h	(working copy)
*************** extern struct tree_opt_pass pass_duplica
*** 386,392 ****
  extern struct tree_opt_pass pass_variable_tracking;
  extern struct tree_opt_pass pass_free_cfg;
  extern struct tree_opt_pass pass_machine_reorg;
- extern struct tree_opt_pass pass_purge_lineno_notes;
  extern struct tree_opt_pass pass_cleanup_barriers;
  extern struct tree_opt_pass pass_delay_slots;
  extern struct tree_opt_pass pass_split_for_shorten_branches;
--- 386,391 ----
Index: modulo-sched.c
===================================================================
*** modulo-sched.c	(revision 118649)
--- modulo-sched.c	(working copy)
*************** generate_prolog_epilog (partial_schedule
*** 761,779 ****
    end_sequence ();
  }
  
- /* Return the line note insn preceding INSN, for debugging.  Taken from
-    emit-rtl.c.  */
- static rtx
- find_line_note (rtx insn)
- {
-   for (; insn; insn = PREV_INSN (insn))
-     if (NOTE_P (insn)
- 	&& NOTE_LINE_NUMBER (insn) >= 0)
-       break;
- 
-   return insn;
- }
- 
  /* Return true if all the BBs of the loop are empty except the
     loop header.  */
  static bool
--- 761,766 ----
*************** loop_canon_p (struct loop *loop)
*** 831,846 ****
      {
        if (dump_file)
  	{
- 	  rtx line_note = find_line_note (BB_END (loop->header));
- 
  	  fprintf (dump_file, "SMS loop many exits ");
- 	  if (line_note)
- 	    {
- 	      expanded_location xloc;
- 	      NOTE_EXPANDED_LOCATION (xloc, line_note);
- 	      fprintf (dump_file, " %s %d (file, line)\n",
- 		       xloc.file, xloc.line);
- 	    }
  	}
        return false;
      }
--- 818,824 ----
*************** loop_canon_p (struct loop *loop)
*** 849,864 ****
      {
        if (dump_file)
  	{
- 	  rtx line_note = find_line_note (BB_END (loop->header));
- 
  	  fprintf (dump_file, "SMS loop many BBs. ");
- 	  if (line_note)
- 	    {
- 	      expanded_location xloc;
-   	      NOTE_EXPANDED_LOCATION (xloc, line_note);
- 	      fprintf (dump_file, " %s %d (file, line)\n",
- 		       xloc.file, xloc.line);
- 	    }
  	}
        return false;
      }
--- 827,833 ----
*************** sms_schedule (void)
*** 986,1000 ****
  	{
  	  if (dump_file)
  	    {
- 	      rtx line_note = find_line_note (tail);
- 
- 	      if (line_note)
- 		{
- 		  expanded_location xloc;
- 		  NOTE_EXPANDED_LOCATION (xloc, line_note);
- 		  fprintf (dump_file, "SMS bb %s %d (file, line)\n",
- 			   xloc.file, xloc.line);
- 		}
  	      fprintf (dump_file, "SMS single-bb-loop\n");
  	      if (profile_info && flag_branch_probabilities)
  	    	{
--- 955,960 ----
*************** sms_schedule (void)
*** 1084,1098 ****
  
        if (dump_file)
  	{
- 	  rtx line_note = find_line_note (tail);
- 
- 	  if (line_note)
- 	    {
- 	      expanded_location xloc;
- 	      NOTE_EXPANDED_LOCATION (xloc, line_note);
- 	      fprintf (dump_file, "SMS bb %s %d (file, line)\n",
- 		       xloc.file, xloc.line);
- 	    }
  	  fprintf (dump_file, "SMS single-bb-loop\n");
  	  if (profile_info && flag_branch_probabilities)
  	    {
--- 1044,1049 ----
Index: cse.c
===================================================================
*** cse.c	(revision 118649)
--- cse.c	(working copy)
*************** cse_main (rtx f, int nregs)
*** 6138,6156 ****
  
    /* Compute the mapping from uids to cuids.
       CUIDs are numbers assigned to insns, like uids,
!      except that cuids increase monotonically through the code.
!      Don't assign cuids to line-number NOTEs, so that the distance in cuids
!      between two insns is not affected by -g.  */
  
    for (insn = f, i = 0; insn; insn = NEXT_INSN (insn))
!     {
!       if (!NOTE_P (insn)
! 	  || NOTE_LINE_NUMBER (insn) < 0)
! 	INSN_CUID (insn) = ++i;
!       else
! 	/* Give a line number note the same cuid as preceding insn.  */
! 	INSN_CUID (insn) = i;
!     }
  
    /* Loop over basic blocks.
       Compute the maximum number of qty's needed for each basic block
--- 6138,6147 ----
  
    /* Compute the mapping from uids to cuids.
       CUIDs are numbers assigned to insns, like uids,
!      except that cuids increase monotonically through the code.  */
  
    for (insn = f, i = 0; insn; insn = NEXT_INSN (insn))
!     INSN_CUID (insn) = ++i;
  
    /* Loop over basic blocks.
       Compute the maximum number of qty's needed for each basic block
Index: jump.c
===================================================================
*** jump.c	(revision 118649)
--- jump.c	(working copy)
*************** struct tree_opt_pass pass_cleanup_barrie
*** 140,201 ****
    0                                     /* letter */
  };
  
- unsigned int
- purge_line_number_notes (void)
- {
-   rtx last_note = 0;
-   rtx insn;
-   /* Delete extraneous line number notes.
-      Note that two consecutive notes for different lines are not really
-      extraneous.  There should be some indication where that line belonged,
-      even if it became empty.  */
- 
-   for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
-     if (NOTE_P (insn))
-       {
- 	if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_FUNCTION_BEG)
- 	  /* Any previous line note was for the prologue; gdb wants a new
- 	     note after the prologue even if it is for the same line.  */
- 	  last_note = NULL_RTX;
- 	else if (NOTE_LINE_NUMBER (insn) >= 0)
- 	  {
- 	    /* Delete this note if it is identical to previous note.  */
- 	    if (last_note
- #ifdef USE_MAPPED_LOCATION
- 		&& NOTE_SOURCE_LOCATION (insn) == NOTE_SOURCE_LOCATION (last_note)
- #else
- 		&& NOTE_SOURCE_FILE (insn) == NOTE_SOURCE_FILE (last_note)
- 		&& NOTE_LINE_NUMBER (insn) == NOTE_LINE_NUMBER (last_note)
- #endif
- )
- 	      {
- 		delete_related_insns (insn);
- 		continue;
- 	      }
- 
- 	    last_note = insn;
- 	  }
-       }
-   return 0;
- }
- 
- struct tree_opt_pass pass_purge_lineno_notes =
- {
-   "elnotes",                            /* name */
-   NULL,                                 /* gate */
-   purge_line_number_notes,              /* execute */
-   NULL,                                 /* sub */
-   NULL,                                 /* next */
-   0,                                    /* static_pass_number */
-   0,                                    /* tv_id */
-   0,                                    /* properties_required */
-   0,                                    /* properties_provided */
-   0,                                    /* properties_destroyed */
-   0,                                    /* todo_flags_start */
-   TODO_dump_func,                       /* todo_flags_finish */
-   0                                     /* letter */
- };
- 
  
  /* Initialize LABEL_NUSES and JUMP_LABEL fields.  Delete any REG_LABEL
     notes whose labels don't occur in the insn any more.  Returns the
--- 140,145 ----
Index: regmove.c
===================================================================
*** regmove.c	(revision 118649)
--- regmove.c	(working copy)
*************** fixup_match_1 (rtx insn, rtx set, rtx sr
*** 1894,1908 ****
  	{
  	  rtx notes = REG_NOTES (insn);
  
! 	  emit_insn_after_with_line_notes (pat, PREV_INSN (p), insn);
  	  delete_insn (insn);
! 	  /* emit_insn_after_with_line_notes has no
! 	     return value, so search for the new insn.  */
! 	  insn = p;
! 	  while (! INSN_P (insn) || PATTERN (insn) != pat)
! 	    insn = PREV_INSN (insn);
! 
! 	  REG_NOTES (insn) = notes;
  	}
      }
    /* Sometimes we'd generate src = const; src += n;
--- 1894,1902 ----
  	{
  	  rtx notes = REG_NOTES (insn);
  
! 	  p = emit_insn_after_setloc (pat, PREV_INSN (p), INSN_LOCATOR (insn));
  	  delete_insn (insn);
! 	  REG_NOTES (p) = notes;
  	}
      }
    /* Sometimes we'd generate src = const; src += n;
Index: function.c
===================================================================
*** function.c	(revision 118649)
--- function.c	(working copy)
*************** extern tree debug_find_var_in_block_tree
*** 203,209 ****
  static void record_insns (rtx, VEC(int,heap) **) ATTRIBUTE_UNUSED;
  static int contains (rtx, VEC(int,heap) **);
  #ifdef HAVE_return
! static void emit_return_into_block (basic_block, rtx);
  #endif
  #if defined(HAVE_epilogue) && defined(INCOMING_RETURN_ADDR_RTX)
  static rtx keep_stack_depressed (rtx);
--- 203,209 ----
  static void record_insns (rtx, VEC(int,heap) **) ATTRIBUTE_UNUSED;
  static int contains (rtx, VEC(int,heap) **);
  #ifdef HAVE_return
! static void emit_return_into_block (basic_block);
  #endif
  #if defined(HAVE_epilogue) && defined(INCOMING_RETURN_ADDR_RTX)
  static rtx keep_stack_depressed (rtx);
*************** expand_function_end (void)
*** 4340,4353 ****
       without returning a value.  */
    emit_note (NOTE_INSN_FUNCTION_END);
  
-   /* Must mark the last line number note in the function, so that the test
-      coverage code can avoid counting the last line twice.  This just tells
-      the code to ignore the immediately following line note, since there
-      already exists a copy of this note somewhere above.  This line number
-      note is still needed for debugging though, so we can't delete it.  */
-   if (flag_test_coverage)
-     emit_note (NOTE_INSN_REPEATED_LINE_NUMBER);
- 
    /* Output a linenumber for the end of the function.
       SDB depends on this.  */
    force_next_line_note ();
--- 4340,4345 ----
*************** sibcall_epilogue_contains (rtx insn)
*** 4653,4663 ****
     block_for_insn appropriately.  */
  
  static void
! emit_return_into_block (basic_block bb, rtx line_note)
  {
    emit_jump_insn_after (gen_return (), BB_END (bb));
-   if (line_note)
-     emit_note_copy_after (line_note, PREV_INSN (BB_END (bb)));
  }
  #endif /* HAVE_return */
  
--- 4645,4653 ----
     block_for_insn appropriately.  */
  
  static void
! emit_return_into_block (basic_block bb)
  {
    emit_jump_insn_after (gen_return (), BB_END (bb));
  }
  #endif /* HAVE_return */
  
*************** thread_prologue_and_epilogue_insns (rtx 
*** 5123,5140 ****
        if (BB_HEAD (last) == label && LABEL_P (label))
  	{
  	  edge_iterator ei2;
- 	  rtx epilogue_line_note = NULL_RTX;
- 
- 	  /* Locate the line number associated with the closing brace,
- 	     if we can find one.  */
- 	  for (seq = get_last_insn ();
- 	       seq && ! active_insn_p (seq);
- 	       seq = PREV_INSN (seq))
- 	    if (NOTE_P (seq) && NOTE_LINE_NUMBER (seq) > 0)
- 	      {
- 		epilogue_line_note = seq;
- 		break;
- 	      }
  
  	  for (ei2 = ei_start (last->preds); (e = ei_safe_edge (ei2)); )
  	    {
--- 5113,5118 ----
*************** thread_prologue_and_epilogue_insns (rtx 
*** 5158,5164 ****
  		 with a simple return instruction.  */
  	      if (simplejump_p (jump))
  		{
! 		  emit_return_into_block (bb, epilogue_line_note);
  		  delete_insn (jump);
  		}
  
--- 5136,5142 ----
  		 with a simple return instruction.  */
  	      if (simplejump_p (jump))
  		{
! 		  emit_return_into_block (bb);
  		  delete_insn (jump);
  		}
  
*************** thread_prologue_and_epilogue_insns (rtx 
*** 5195,5201 ****
  	     this is still reachable will be determined later.  */
  
  	  emit_barrier_after (BB_END (last));
! 	  emit_return_into_block (last, epilogue_line_note);
  	  epilogue_end = BB_END (last);
  	  single_succ_edge (last)->flags &= ~EDGE_FALLTHRU;
  	  goto epilogue_done;
--- 5173,5179 ----
  	     this is still reachable will be determined later.  */
  
  	  emit_barrier_after (BB_END (last));
! 	  emit_return_into_block (last);
  	  epilogue_end = BB_END (last);
  	  single_succ_edge (last)->flags &= ~EDGE_FALLTHRU;
  	  goto epilogue_done;
*************** epilogue_done:
*** 5297,5357 ****
      }
  #endif
  
- #ifdef HAVE_prologue
-   /* This is probably all useless now that we use locators.  */
-   if (prologue_end)
-     {
-       rtx insn, prev;
- 
-       /* GDB handles `break f' by setting a breakpoint on the first
- 	 line note after the prologue.  Which means (1) that if
- 	 there are line number notes before where we inserted the
- 	 prologue we should move them, and (2) we should generate a
- 	 note before the end of the first basic block, if there isn't
- 	 one already there.
- 
- 	 ??? This behavior is completely broken when dealing with
- 	 multiple entry functions.  We simply place the note always
- 	 into first basic block and let alternate entry points
- 	 to be missed.
-        */
- 
-       for (insn = prologue_end; insn; insn = prev)
- 	{
- 	  prev = PREV_INSN (insn);
- 	  if (NOTE_P (insn) && NOTE_LINE_NUMBER (insn) > 0)
- 	    {
- 	      /* Note that we cannot reorder the first insn in the
- 		 chain, since rest_of_compilation relies on that
- 		 remaining constant.  */
- 	      if (prev == NULL)
- 		break;
- 	      reorder_insns (insn, insn, prologue_end);
- 	    }
- 	}
- 
-       /* Find the last line number note in the first block.  */
-       for (insn = BB_END (ENTRY_BLOCK_PTR->next_bb);
- 	   insn != prologue_end && insn;
- 	   insn = PREV_INSN (insn))
- 	if (NOTE_P (insn) && NOTE_LINE_NUMBER (insn) > 0)
- 	  break;
- 
-       /* If we didn't find one, make a copy of the first line number
- 	 we run across.  */
-       if (! insn)
- 	{
- 	  for (insn = next_active_insn (prologue_end);
- 	       insn;
- 	       insn = PREV_INSN (insn))
- 	    if (NOTE_P (insn) && NOTE_LINE_NUMBER (insn) > 0)
- 	      {
- 		emit_note_copy_after (insn, prologue_end);
- 		break;
- 	      }
- 	}
-     }
- #endif
  #ifdef HAVE_epilogue
    if (epilogue_end)
      {
--- 5275,5280 ----
*************** epilogue_done:
*** 5366,5373 ****
  	{
  	  next = NEXT_INSN (insn);
  	  if (NOTE_P (insn) 
! 	      && (NOTE_LINE_NUMBER (insn) > 0
! 		  || NOTE_LINE_NUMBER (insn) == NOTE_INSN_FUNCTION_BEG
  		  || NOTE_LINE_NUMBER (insn) == NOTE_INSN_FUNCTION_END))
  	    reorder_insns (insn, insn, PREV_INSN (epilogue_end));
  	}
--- 5289,5295 ----
  	{
  	  next = NEXT_INSN (insn);
  	  if (NOTE_P (insn) 
! 	      && (NOTE_LINE_NUMBER (insn) == NOTE_INSN_FUNCTION_BEG
  		  || NOTE_LINE_NUMBER (insn) == NOTE_INSN_FUNCTION_END))
  	    reorder_insns (insn, insn, PREV_INSN (epilogue_end));
  	}
Index: emit-rtl.c
===================================================================
*** emit-rtl.c	(revision 118649)
--- emit-rtl.c	(working copy)
*************** static GTY ((if_marked ("ggc_marked_p"),
*** 166,172 ****
  #define first_label_num (cfun->emit->x_first_label_num)
  
  static rtx make_call_insn_raw (rtx);
- static rtx find_line_note (rtx);
  static rtx change_address_1 (rtx, enum machine_mode, rtx, int);
  static void unshare_all_decls (tree);
  static void reset_used_decls (tree);
--- 166,171 ----
*************** reorder_insns (rtx from, rtx to, rtx aft
*** 3663,3684 ****
      }
  }
  
- /* Return the line note insn preceding INSN.  */
- 
- static rtx
- find_line_note (rtx insn)
- {
-   if (no_line_numbers)
-     return 0;
- 
-   for (; insn; insn = PREV_INSN (insn))
-     if (NOTE_P (insn)
- 	&& NOTE_LINE_NUMBER (insn) >= 0)
-       break;
- 
-   return insn;
- }
- 
  
  /* Emit insn(s) of given code and pattern
     at a specified place within the doubly-linked list.
--- 3662,3667 ----
*************** emit_insn_after_noloc (rtx x, rtx after)
*** 3963,3984 ****
    return last;
  }
  
- /* Similar to emit_insn_after, except that line notes are to be inserted so
-    as to act as if this insn were at FROM.  */
- 
- void
- emit_insn_after_with_line_notes (rtx x, rtx after, rtx from)
- {
-   rtx from_line = find_line_note (from);
-   rtx after_line = find_line_note (after);
-   rtx insn = emit_insn_after (x, after);
- 
-   if (from_line)
-     emit_note_copy_after (from_line, after);
- 
-   if (after_line)
-     emit_note_copy_after (after_line, insn);
- }
  
  /* Make an insn of code JUMP_INSN with body X
     and output it after the insn AFTER.  */
--- 3946,3951 ----
*************** emit_note_after (int subtype, rtx after)
*** 4098,4125 ****
    add_insn_after (note, after);
    return note;
  }
- 
- /* Emit a copy of note ORIG after the insn AFTER.  */
- 
- rtx
- emit_note_copy_after (rtx orig, rtx after)
- {
-   rtx note;
- 
-   if (NOTE_LINE_NUMBER (orig) >= 0 && no_line_numbers)
-     {
-       cur_insn_uid++;
-       return 0;
-     }
- 
-   note = rtx_alloc (NOTE);
-   INSN_UID (note) = cur_insn_uid++;
-   NOTE_LINE_NUMBER (note) = NOTE_LINE_NUMBER (orig);
-   NOTE_DATA (note) = NOTE_DATA (orig);
-   BLOCK_FOR_INSN (note) = NULL;
-   add_insn_after (note, after);
-   return note;
- }
  
  /* Like emit_insn_after_noloc, but set INSN_LOCATOR according to SCOPE.  */
  rtx
--- 4065,4070 ----
*************** emit_note_copy (rtx orig)
*** 4504,4515 ****
  {
    rtx note;
    
-   if (NOTE_LINE_NUMBER (orig) >= 0 && no_line_numbers)
-     {
-       cur_insn_uid++;
-       return NULL_RTX;
-     }
-   
    note = rtx_alloc (NOTE);
    
    INSN_UID (note) = cur_insn_uid++;
--- 4449,4454 ----
Index: cfgcleanup.c
===================================================================
*** cfgcleanup.c	(revision 118649)
--- cfgcleanup.c	(working copy)
*************** rest_of_handle_jump2 (void)
*** 2312,2319 ****
    cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0)
  	       | (flag_thread_jumps ? CLEANUP_THREADING : 0));
  
-   purge_line_number_notes ();
- 
    if (optimize)
      cleanup_cfg (CLEANUP_EXPENSIVE);
  
--- 2307,2312 ----
Index: rtl.h
===================================================================
*** rtl.h	(revision 118649)
--- rtl.h	(working copy)
*************** extern rtx emit_call_insn_after_setloc (
*** 1552,1558 ****
  extern rtx emit_barrier_after (rtx);
  extern rtx emit_label_after (rtx, rtx);
  extern rtx emit_note_after (int, rtx);
- extern rtx emit_note_copy_after (rtx, rtx);
  extern rtx emit_insn (rtx);
  extern rtx emit_jump_insn (rtx);
  extern rtx emit_call_insn (rtx);
--- 1552,1557 ----
*************** extern void add_insn (rtx);
*** 2064,2070 ****
  extern void add_insn_before (rtx, rtx);
  extern void add_insn_after (rtx, rtx);
  extern void remove_insn (rtx);
- extern void emit_insn_after_with_line_notes (rtx, rtx, rtx);
  extern rtx emit (rtx);
  extern void renumber_insns (void);
  extern rtx delete_insn (rtx);
--- 2063,2068 ----
Index: passes.c
===================================================================
*** passes.c	(revision 118649)
--- passes.c	(working copy)
*************** init_optimization_passes (void)
*** 683,689 ****
    NEXT_PASS (pass_variable_tracking);
    NEXT_PASS (pass_free_cfg);
    NEXT_PASS (pass_machine_reorg);
-   NEXT_PASS (pass_purge_lineno_notes);
    NEXT_PASS (pass_cleanup_barriers);
    NEXT_PASS (pass_delay_slots);
    NEXT_PASS (pass_split_for_shorten_branches);
--- 683,688 ----
Index: cfgrtl.c
===================================================================
*** cfgrtl.c	(revision 118649)
--- cfgrtl.c	(working copy)
*************** try_redirect_by_replacing_jump (edge e, 
*** 866,877 ****
    e->probability = REG_BR_PROB_BASE;
    e->count = src->count;
  
-   /* We don't want a block to end on a line-number note since that has
-      the potential of changing the code between -g and not -g.  */
-   while (NOTE_P (BB_END (e->src))
- 	 && NOTE_LINE_NUMBER (BB_END (e->src)) >= 0)
-     delete_insn (BB_END (e->src));
- 
    if (e->dest != target)
      redirect_edge_succ (e, target);
  
--- 866,871 ----
*************** rtl_tidy_fallthru_edge (edge e)
*** 1233,1243 ****
  #endif
  
        q = PREV_INSN (q);
- 
-       /* We don't want a block to end on a line-number note since that has
- 	 the potential of changing the code between -g and not -g.  */
-       while (NOTE_P (q) && NOTE_LINE_NUMBER (q) >= 0)
- 	q = PREV_INSN (q);
      }
  
    /* Selectively unlink the sequence.  */
--- 1227,1232 ----
Index: sched-ebb.c
===================================================================
--- sched-ebb.c	(revision 118649)
+++ sched-ebb.c	(working copy)
@@ -482,7 +482,6 @@ schedule_ebb (rtx head, rtx tail)
   if (write_symbols != NO_DEBUG)
     {
       save_line_notes (first_bb->index, head, tail);
-      rm_line_notes (head, tail);
     }
 
   /* rm_other_notes only removes notes which are _inside_ the
@@ -681,9 +680,6 @@ schedule_ebbs (void)
   if (reload_completed)
     reposition_prologue_and_epilogue_notes (get_insns ());
 
-  if (write_symbols != NO_DEBUG)
-    rm_redundant_line_notes ();
-
   sched_finish ();
 }
 
Index: sched-rgn.c
===================================================================
--- sched-rgn.c	(revision 118649)
+++ sched-rgn.c	(working copy)
@@ -2787,7 +2787,6 @@ schedule_region (int rgn)
       if (write_symbols != NO_DEBUG)
 	{
 	  save_line_notes (b, head, tail);
-	  rm_line_notes (head, tail);
 	}
 
       /* rm_other_notes only removes notes which are _inside_ the
@@ -3045,10 +3044,6 @@ schedule_insns (void)
   if (reload_completed)
     reposition_prologue_and_epilogue_notes (get_insns ());
 
-  /* Delete redundant line notes.  */
-  if (write_symbols != NO_DEBUG)
-    rm_redundant_line_notes ();
-
   if (sched_verbose)
     {
       if (reload_completed == 0 && flag_schedule_interblock)
Index: sched-int.h
===================================================================
--- sched-int.h	(revision 118649)
+++ sched-int.h	(working copy)
@@ -634,10 +634,8 @@ extern int haifa_classify_insn (rtx);
 extern void get_ebb_head_tail (basic_block, basic_block, rtx *, rtx *);
 extern int no_real_insns_p (rtx, rtx);
 
-extern void rm_line_notes (rtx, rtx);
 extern void save_line_notes (int, rtx, rtx);
 extern void restore_line_notes (rtx, rtx);
-extern void rm_redundant_line_notes (void);
 extern void rm_other_notes (rtx, rtx);
 
 extern int insn_cost (rtx, rtx, rtx);
Index: haifa-sched.c
===================================================================
--- haifa-sched.c	(revision 118649)
+++ haifa-sched.c	(working copy)
@@ -511,26 +511,18 @@ static void advance_one_cycle (void);
    Generally, NOTES are saved before scheduling and restored after scheduling.
    The scheduler distinguishes between three types of notes:
 
-   (1) LINE_NUMBER notes, generated and used for debugging.  Here,
-   before scheduling a region, a pointer to the LINE_NUMBER note is
-   added to the insn following it (in save_line_notes()), and the note
-   is removed (in rm_line_notes() and unlink_line_notes()).  After
-   scheduling the region, this pointer is used for regeneration of
-   the LINE_NUMBER note (in restore_line_notes()).
-
-   (2) LOOP_BEGIN, LOOP_END, SETJMP, EHREGION_BEG, EHREGION_END notes:
+   (1) LOOP_BEGIN, LOOP_END, SETJMP, EHREGION_BEG, EHREGION_END notes:
    Before scheduling a region, a pointer to the note is added to the insn
    that follows or precedes it.  (This happens as part of the data dependence
    computation).  After scheduling an insn, the pointer contained in it is
    used for regenerating the corresponding note (in reemit_notes).
 
-   (3) All other notes (e.g. INSN_DELETED):  Before scheduling a block,
+   (2) All other notes (e.g. INSN_DELETED):  Before scheduling a block,
    these notes are put in a list (in rm_other_notes() and
    unlink_other_notes ()).  After scheduling the block, these notes are
    inserted at the beginning of the block (in schedule_block()).  */
 
 static rtx unlink_other_notes (rtx, rtx);
-static rtx unlink_line_notes (rtx, rtx);
 static void reemit_notes (rtx);
 
 static rtx *ready_lastpos (struct ready_list *);
@@ -1276,50 +1268,6 @@ unlink_other_notes (rtx insn, rtx tail)
   return insn;
 }
 
-/* Delete line notes beginning with INSN. Record line-number notes so
-   they can be reused.  Returns the insn following the notes.  */
-
-static rtx
-unlink_line_notes (rtx insn, rtx tail)
-{
-  rtx prev = PREV_INSN (insn);
-
-  while (insn != tail && NOTE_NOT_BB_P (insn))
-    {
-      rtx next = NEXT_INSN (insn);
-
-      if (write_symbols != NO_DEBUG && NOTE_LINE_NUMBER (insn) > 0)
-	{
-          basic_block bb = BLOCK_FOR_INSN (insn);
-
-	  /* Delete the note from its current position.  */
-	  if (prev)
-	    NEXT_INSN (prev) = next;
-	  if (next)
-	    PREV_INSN (next) = prev;
-
-          if (bb)
-            {
-              /* Basic block can begin with either LABEL or
-                 NOTE_INSN_BASIC_BLOCK.  */
-              gcc_assert (BB_HEAD (bb) != insn);
-
-              /* Check if we are removing last insn in the BB.  */
-              if (BB_END (bb) == insn)
-                BB_END (bb) = prev;
-            }
-
-	  /* Record line-number notes so they can be reused.  */
-	  LINE_NOTE (insn) = insn;
-	}
-      else
-	prev = insn;
-
-      insn = next;
-    }
-  return insn;
-}
-
 /* Return the head and tail pointers of ebb starting at BEG and ending
    at END.  */
 
@@ -1373,34 +1321,6 @@ no_real_insns_p (rtx head, rtx tail)
   return 1;
 }
 
-/* Delete line notes from one block. Save them so they can be later restored
-   (in restore_line_notes).  HEAD and TAIL are the boundaries of the
-   block in which notes should be processed.  */
-
-void
-rm_line_notes (rtx head, rtx tail)
-{
-  rtx next_tail;
-  rtx insn;
-
-  next_tail = NEXT_INSN (tail);
-  for (insn = head; insn != next_tail; insn = NEXT_INSN (insn))
-    {
-      rtx prev;
-
-      /* Farm out notes, and maybe save them in NOTE_LIST.
-         This is needed to keep the debugger from
-         getting completely deranged.  */
-      if (NOTE_NOT_BB_P (insn))
-	{
-	  prev = insn;
-	  insn = unlink_line_notes (insn, next_tail);
-
-	  gcc_assert (prev != tail && prev != head && insn != next_tail);
-	}
-    }
-}
-
 /* Save line number notes for each insn in block B.  HEAD and TAIL are
    the boundaries of the block in which notes should be processed.  */
 
@@ -1420,10 +1340,7 @@ save_line_notes (int b, rtx head, rtx ta
   next_tail = NEXT_INSN (tail);
 
   for (insn = head; insn != next_tail; insn = NEXT_INSN (insn))
-    if (NOTE_P (insn) && NOTE_LINE_NUMBER (insn) > 0)
-      line = insn;
-    else
-      LINE_NOTE (insn) = line;
+    LINE_NOTE (insn) = line;
 }
 
 /* After a block was scheduled, insert line notes into the insns list.
@@ -1497,58 +1414,6 @@ restore_line_notes (rtx head, rtx tail)
     fprintf (sched_dump, ";; added %d line-number notes\n", added_notes);
 }
 
-/* After scheduling the function, delete redundant line notes from the
-   insns list.  */
-
-void
-rm_redundant_line_notes (void)
-{
-  rtx line = 0;
-  rtx insn = get_insns ();
-  int active_insn = 0;
-  int notes = 0;
-
-  /* Walk the insns deleting redundant line-number notes.  Many of these
-     are already present.  The remainder tend to occur at basic
-     block boundaries.  */
-  for (insn = get_last_insn (); insn; insn = PREV_INSN (insn))
-    if (NOTE_P (insn) && NOTE_LINE_NUMBER (insn) > 0)
-      {
-	/* If there are no active insns following, INSN is redundant.  */
-	if (active_insn == 0)
-	  {
-	    notes++;
-	    SET_INSN_DELETED (insn);
-	  }
-	/* If the line number is unchanged, LINE is redundant.  */
-	else if (line
-#ifdef USE_MAPPED_LOCATION
-		 && NOTE_SOURCE_LOCATION (line) == NOTE_SOURCE_LOCATION (insn)
-#else
-		 && NOTE_LINE_NUMBER (line) == NOTE_LINE_NUMBER (insn)
-		 && NOTE_SOURCE_FILE (line) == NOTE_SOURCE_FILE (insn)
-#endif
-)
-	  {
-	    notes++;
-	    SET_INSN_DELETED (line);
-	    line = insn;
-	  }
-	else
-	  line = insn;
-	active_insn = 0;
-      }
-    else if (!((NOTE_P (insn)
-		&& NOTE_LINE_NUMBER (insn) == NOTE_INSN_DELETED)
-	       || (NONJUMP_INSN_P (insn)
-		   && (GET_CODE (PATTERN (insn)) == USE
-		       || GET_CODE (PATTERN (insn)) == CLOBBER))))
-      active_insn++;
-
-  if (sched_verbose && notes)
-    fprintf (sched_dump, ";; deleted %d line-number notes\n", notes);
-}
-
 /* Delete notes between HEAD and TAIL and put them in the chain
    of notes ended by NOTE_LIST.  */
 



More information about the Gcc-patches mailing list