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]

thread_prologue_epilogue_insns cleanup


Hi
This is literary my patch from November. Now once stupid is dead it ought
to be OK.

It makes thread_prologue_and_epilouge_insns to use flow's infrastructure
and thus to not disturb flowgraph.
Also removes unnecesary USE handling code.


Tue Nov  2 17:22:16 MET 1999  Jan Hubicka  <hubicka@freesoft.cz>
	* function.c (thread_prologue_and_epilogue_insns): Rewrite epilogue
	emiting code.
	* flow.c (commit_edge_insertions): Call verify_flow_info when
	ENABLE_CHECKING.

*** function.c.old	Tue Nov  2 15:48:38 1999
--- function.c	Tue Nov  2 16:52:07 1999
*************** thread_prologue_and_epilogue_insns (f)
*** 6587,6598 ****
    if (HAVE_epilogue)
      {
        edge e;
!       basic_block bb = 0;
!       rtx tail = get_last_insn ();
! 
!       /* ??? This is gastly.  If function returns were not done via uses,
! 	 but via mark_regs_live_at_end, we could use insert_insn_on_edge
! 	 and all of this uglyness would go away.  */
  
        switch (optimize)
  	{
--- 6587,6593 ----
    if (HAVE_epilogue)
      {
        edge e;
!       rtx seq;
  
        switch (optimize)
  	{
*************** thread_prologue_and_epilogue_insns (f)
*** 6615,6708 ****
  
  	     ??? Fix epilogue expanders to not assume they are the
  	     last thing done compiling the function.  Either that
! 	     or copy_rtx each insn.
  
! 	     ??? Blah, it's not a simple expression to assert that
! 	     we've exactly one fallthru exit edge.  */
  
! 	  bb = e->src;
! 	  tail = bb->end;
  
! 	  /* ??? If the last insn of the basic block is a jump, then we
! 	     are creating a new basic block.  Wimp out and leave these
! 	     insns outside any block.  */
! 	  if (GET_CODE (tail) == JUMP_INSN)
! 	    bb = 0;
  
! 	  /* FALLTHRU */
! 	case 0:
! 	  {
! 	    rtx prev, seq, first_use;
  
! 	    /* Move the USE insns at the end of a function onto a list.  */
! 	    prev = tail;
! 	    if (GET_CODE (prev) == BARRIER
! 		|| GET_CODE (prev) == NOTE)
! 	      prev = prev_nonnote_insn (prev);
! 
! 	    first_use = 0;
! 	    if (prev
! 		&& GET_CODE (prev) == INSN
! 		&& GET_CODE (PATTERN (prev)) == USE)
! 	      {
! 		/* If the end of the block is the use, grab hold of something
! 		   else so that we emit barriers etc in the right place.  */
! 		if (prev == tail)
! 		  {
! 		    do 
! 		      tail = PREV_INSN (tail);
! 		    while (GET_CODE (tail) == INSN
! 			   && GET_CODE (PATTERN (tail)) == USE);
! 		  }
! 
! 		do
! 		  {
! 		    rtx use = prev;
! 		    prev = prev_nonnote_insn (prev);
! 
! 		    remove_insn (use);
! 		    if (first_use)
! 		      {
! 			NEXT_INSN (use) = first_use;
! 			PREV_INSN (first_use) = use;
! 		      }
! 		    else
! 		      NEXT_INSN (use) = NULL_RTX;
! 		    first_use = use;
! 		  }
! 		while (prev
! 		       && GET_CODE (prev) == INSN
! 		       && GET_CODE (PATTERN (prev)) == USE);
! 	      }
! 
! 	    /* The last basic block ends with a NOTE_INSN_EPILOGUE_BEG, the
! 	       epilogue insns, the USE insns at the end of a function,
! 	       the jump insn that returns, and then a BARRIER.  */
! 
! 	    if (GET_CODE (tail) != BARRIER)
! 	      {
! 		prev = next_nonnote_insn (tail);
! 		if (!prev || GET_CODE (prev) != BARRIER)
! 		  emit_barrier_after (tail);
! 	      }
! 
! 	    seq = gen_epilogue ();
! 	    prev = tail;
! 	    tail = emit_jump_insn_after (seq, tail);
! 
! 	    /* Insert the USE insns immediately before the return insn, which
! 	       must be the last instruction emitted in the sequence.  */
! 	    if (first_use)
! 	      emit_insns_before (first_use, tail);
! 	    emit_note_after (NOTE_INSN_EPILOGUE_BEG, prev);
! 
! 	    /* Update the tail of the basic block.  */
! 	    if (bb)
! 	      bb->end = tail;
! 
! 	    /* Retain a map of the epilogue insns.  */
! 	    epilogue = record_insns (GET_CODE (seq) == SEQUENCE ? seq : tail);
! 	  }
  	}
      }
  #endif
--- 6610,6661 ----
  
  	     ??? Fix epilogue expanders to not assume they are the
  	     last thing done compiling the function.  Either that
! 	     or copy_insn each insn.  */
! 
! 	  /* FALLTHRU */
  
! 	case 0:
  
! 	  start_sequence ();
! 	  emit_note (NULL, NOTE_INSN_EPILOGUE_BEG);
  
! 	  seq = gen_epilogue ();
! 	  emit_jump_insn (seq);
  
! 	  /* Retain a map of the epilogue insns.  */
! 	  if (GET_CODE (seq) != SEQUENCE)
! 	    seq = get_insns ();
! 	  epilogue = record_insns (seq);
! 
! 	  emit_barrier ();
! 
! 	  seq = gen_sequence ();
! 
! 	  end_sequence();
! 
! 	  /* When we are not optimizing we can't use flow's infrastructure.
! 	     Sad.  */
! 
! 	  if (optimize)
! 	    {
! 	      /* Can't deal with multiple successsors of the entry block.
! 		 This can be easy job to do in future - just copy_insn
! 		 the sequence for each emit.  */
! 	      if (EXIT_BLOCK_PTR->pred->pred_next)
! 		abort ();
! 
! 	      insert_insn_on_edge (seq, EXIT_BLOCK_PTR->pred);
! 	      insertted = 1;
! 	    }
! 	  else
! 	    {
! 	      rtx tail = get_last_insn ();
! 	      if (GET_CODE (tail) == BARRIER
! 		  || GET_CODE (tail) == NOTE)
! 		tail = prev_nonnote_insn (tail);
  
! 	      emit_insn_after (seq, tail);
! 	    }
  	}
      }
  #endif
*** flow.c.old1	Tue Nov  2 17:01:20 1999
--- flow.c	Tue Nov  2 17:24:09 1999
*************** commit_edge_insertions ()
*** 1631,1636 ****
--- 1631,1640 ----
    int i;
    basic_block bb;
  
+ #ifdef ENABLE_CHECKING
+   verify_flow_info ();
+ #endif
+  
    i = -1;
    bb = ENTRY_BLOCK_PTR;
    while (1)

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