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]
Other format: [Raw text]

Re: [3.4] fixup_reorder_chain fix


> this is patch I am testing to fix the bug.

Thanks.

> Since this code is so rarely excercised I would welcome if you run the Ada 
> testsuite on it. 

Yes, I'll give it a whirl.

> To summarize some of offlist discussion.  The actual problem is
> -fnon-call-exception (enabled by default by Ada) preventing GCC from
> removing the conditional branch to next instruction.  THis results in
> fallthru and branch edge to be indentified excercising interesting side
> corners of cfglayout code previously used only by HP-PA.

In other words, there is only one normal edge, which is FALLTHRU, although the 
basic block ends with a conditional jump.

> The orignal hack created duplicated edge that resulted in CFG breaking
> our invariants and since we added more sanity checking, it fires now.

My understanding is that the problem was not the duplicate edge, but the 
mismatch between the target of the edge and the target of the jump, because 
the latter has been redirected to itself.

> The current workaround is to redirect the branch edge to form self-loop
> around the current BB and redirect it properly later in function.  I
> tried this once before in past but it falled into cracks when the
> conditonal formed infinite self loop, so I went the way of duplicated
> edges.  Alternate sollution is to create new basic block destination in
> this very side case that I am doing now.

Do we really need to work so hard?  Why can't we simply create the duplicate 
edge and let force_nonfallthru un-duplicate it?  IIUC it will create a new 
basic block and a new fallthru edge targetting it, so the former duplicated 
edge and the new fallthru edge will not target the same block anymore.

-- 
Eric Botcazou
*** gcc/cfglayout.c.0	2005-10-02 17:51:18.993262360 +0200
--- gcc/cfglayout.c	2005-10-02 17:51:28.970745552 +0200
*************** fixup_reorder_chain (void)
*** 694,706 ****
  		continue;
  
  	      /* The degenerated case of conditional jump jumping to the next
! 		 instruction can happen on target having jumps with side
! 		 effects.
! 
! 		 Create temporarily the duplicated edge representing branch.
! 		 It will get unidentified by force_nonfallthru_and_redirect
! 		 that would otherwise get confused by fallthru edge not pointing
! 		 to the next basic block.  */
  	      if (!e_taken)
  		{
  		  rtx note;
--- 694,703 ----
  		continue;
  
  	      /* The degenerated case of conditional jump jumping to the next
! 		 instruction can happen for jumps with side effects.  Create
! 		 temporarily the duplicated edge representing the branch, as
! 		 this will cause force_nonfallthru to redirect the fallthru
! 		 edge to a new block, thus eliminating the duplication.  */
  	      if (!e_taken)
  		{
  		  rtx note;
*************** fixup_reorder_chain (void)
*** 708,715 ****
  
  		  e_fake = unchecked_make_edge (bb, e_fall->dest, 0);
  
- 		  if (!redirect_jump (BB_END (bb), block_label (bb), 0))
- 		    abort ();
  		  note = find_reg_note (BB_END (bb), REG_BR_PROB, NULL_RTX);
  		  if (note)
  		    {
--- 705,710 ----
*************** fixup_reorder_chain (void)
*** 725,731 ****
  			e_fall->count = 0;
  		    }
  		}
! 	      /* There is one special case: if *neither* block is next,
  		 such as happens at the very end of a function, then we'll
  		 need to add a new unconditional jump.  Choose the taken
  		 edge based on known or assumed probability.  */
--- 720,727 ----
  			e_fall->count = 0;
  		    }
  		}
! 
! 	      /* There is another special case: if *neither* block is next,
  		 such as happens at the very end of a function, then we'll
  		 need to add a new unconditional jump.  Choose the taken
  		 edge based on known or assumed probability.  */

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