This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


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

Re: Suggested (easier) fix to ... RE: Regressions problem (200 failures)


Sigh, forgot the patch.


r~

        * function.c (emit_return_into_block): New line_note arg; emit it.
        (thread_prologue_and_epilogue_insns): Attempt to locate a line note
        for the close brace to accompany HAVE_return.  Move all line notes
        following the epilogue to before the NOTE_INSN_EPILOGUE_BEG.

Index: function.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/function.c,v
retrieving revision 1.200
diff -c -p -d -r1.200 function.c
*** function.c	2000/05/28 12:31:40	1.200
--- function.c	2000/05/29 08:14:41
*************** static tree *get_block_vector   PARAMS (
*** 290,296 ****
  static void record_insns	PARAMS ((rtx, varray_type *)) ATTRIBUTE_UNUSED;
  static int contains		PARAMS ((rtx, varray_type));
  #ifdef HAVE_return
! static void emit_return_into_block PARAMS ((basic_block));
  #endif
  static void put_addressof_into_stack PARAMS ((rtx, struct hash_table *));
  static boolean purge_addressof_1 PARAMS ((rtx *, rtx, int, int, 
--- 290,296 ----
  static void record_insns	PARAMS ((rtx, varray_type *)) ATTRIBUTE_UNUSED;
  static int contains		PARAMS ((rtx, varray_type));
  #ifdef HAVE_return
! static void emit_return_into_block PARAMS ((basic_block, rtx));
  #endif
  static void put_addressof_into_stack PARAMS ((rtx, struct hash_table *));
  static boolean purge_addressof_1 PARAMS ((rtx *, rtx, int, int, 
*************** sibcall_epilogue_contains (insn)
*** 6798,6816 ****
     block_for_insn appropriately.  */
  
  static void
! emit_return_into_block (bb)
       basic_block bb;
  {
    rtx p, end;
  
-   end = emit_jump_insn_after (gen_return (), bb->end);
    p = NEXT_INSN (bb->end); 
    while (1)
      {
        set_block_for_insn (p, bb);
!       if (p == end)
  	break;
!       p = NEXT_INSN (p);
      }
    bb->end = end;
  }
--- 6798,6821 ----
     block_for_insn appropriately.  */
  
  static void
! emit_return_into_block (bb, line_note)
       basic_block bb;
+      rtx line_note;
  {
    rtx p, end;
  
    p = NEXT_INSN (bb->end); 
+   end = emit_jump_insn_after (gen_return (), bb->end);
+   if (line_note)
+     emit_line_note_after (NOTE_SOURCE_FILE (line_note),
+ 			  NOTE_LINE_NUMBER (line_note), bb->end);
+ 
    while (1)
      {
        set_block_for_insn (p, bb);
!       if (p == bb->end)
  	break;
!       p = PREV_INSN (p);
      }
    bb->end = end;
  }
*************** thread_prologue_and_epilogue_insns (f)
*** 6830,6835 ****
--- 6835,6843 ----
  #ifdef HAVE_prologue
    rtx prologue_end = NULL_RTX;
  #endif
+ #if defined (HAVE_epilogue) || defined(HAVE_return)
+   rtx epilogue_end = NULL_RTX;
+ #endif
  
  #ifdef HAVE_prologue
    if (HAVE_prologue)
*************** thread_prologue_and_epilogue_insns (f)
*** 6902,6907 ****
--- 6910,6928 ----
  
        if (last->head == label && GET_CODE (label) == CODE_LABEL)
  	{
+           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 (GET_CODE (seq) == NOTE && NOTE_LINE_NUMBER (seq) > 0)
+ 	      {
+ 		epilogue_line_note = seq;
+ 		break;
+ 	      }
+ 
  	  for (e = last->pred; e ; e = e_next)
  	    {
  	      basic_block bb = e->src;
*************** thread_prologue_and_epilogue_insns (f)
*** 6919,6925 ****
  		 with a simple return instruction.  */
  	      if (simplejump_p (jump))
  		{
! 		  emit_return_into_block (bb);
  		  flow_delete_insn (jump);
  		}
  
--- 6940,6946 ----
  		 with a simple return instruction.  */
  	      if (simplejump_p (jump))
  		{
! 		  emit_return_into_block (bb, epilogue_line_note);
  		  flow_delete_insn (jump);
  		}
  
*************** thread_prologue_and_epilogue_insns (f)
*** 6951,6979 ****
  		continue;
  
  	      /* Fix up the CFG for the successful change we just made.  */
! 	      remove_edge (e);
! 	      make_edge (NULL, bb, EXIT_BLOCK_PTR, 0);
  	    }
  
  	  /* Emit a return insn for the exit fallthru block.  Whether
  	     this is still reachable will be determined later.  */
  
  	  emit_barrier_after (last->end);
! 	  emit_return_into_block (last);
! 	}
!       else 
! 	{
! 	  /* The exit block wasn't empty.  We have to use insert_insn_on_edge,
! 	     as it may be the exit block can go elsewhere as well
! 	     as exiting.  */
! 	  start_sequence ();
! 	  emit_jump_insn (gen_return ());
! 	  seq = gen_sequence ();
! 	  end_sequence ();
! 	  insert_insn_on_edge (seq, e);
! 	  inserted = 1;
  	}
-       goto epilogue_done;
      }
  #endif
  #ifdef HAVE_epilogue
--- 6972,6988 ----
  		continue;
  
  	      /* Fix up the CFG for the successful change we just made.  */
! 	      redirect_edge_succ (e, EXIT_BLOCK_PTR);
  	    }
  
  	  /* Emit a return insn for the exit fallthru block.  Whether
  	     this is still reachable will be determined later.  */
  
  	  emit_barrier_after (last->end);
! 	  emit_return_into_block (last, epilogue_line_note);
! 	  epilogue_end = last->end;
!           goto epilogue_done;
  	}
      }
  #endif
  #ifdef HAVE_epilogue
*************** thread_prologue_and_epilogue_insns (f)
*** 6991,6997 ****
  	goto epilogue_done;
  
        start_sequence ();
!       emit_note (NULL, NOTE_INSN_EPILOGUE_BEG);
  
        seq = gen_epilogue ();
        emit_jump_insn (seq);
--- 7000,7006 ----
  	goto epilogue_done;
  
        start_sequence ();
!       epilogue_end = emit_note (NULL, NOTE_INSN_EPILOGUE_BEG);
  
        seq = gen_epilogue ();
        emit_jump_insn (seq);
*************** epilogue_done:
*** 7091,7096 ****
--- 7100,7121 ----
  				      prologue_end);
  		break;
  	      }
+ 	}
+     }
+ #endif
+ #ifdef HAVE_epilogue
+   if (epilogue_end)
+     {
+       rtx insn, next;
+ 
+       /* Similarly, move any line notes that appear after the epilogue.
+          There is no need, however, to be quite so anal about the existance
+ 	 of such a note.  */
+       for (insn = epilogue_end; insn ; insn = next)
+ 	{
+ 	  next = NEXT_INSN (insn);
+ 	  if (GET_CODE (insn) == NOTE && NOTE_LINE_NUMBER (insn) > 0)
+ 	    reorder_insns (insn, insn, PREV_INSN (epilogue_end));
  	}
      }
  #endif

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