Exception handling: split insns

Andrew Haley aph@cambridge.redhat.com
Fri Apr 27 11:01:00 GMT 2001


Divide exceptions aren't being caught in x86 Java.  This is because
when a divide insn gets split its EH notes aren't propagated.

This patch seems to fix the problem.  I thought of using
distribute_notes() but that function is static in combine.c and it
doesn't look ideal for this job.

Andrew.

2001-04-27  Andrew Haley  <aph@cambridge.redhat.com>

	* emit-rtl.c (try_split):  Copy EH notes to sequence.

Index: emit-rtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/emit-rtl.c,v
retrieving revision 1.172
diff -c -2 -p -r1.172 emit-rtl.c
*** emit-rtl.c	2001/04/25 16:14:24	1.172
--- emit-rtl.c	2001/04/27 17:59:10
*************** try_split (pat, trial, last)
*** 2586,2590 ****
  	{
  	  int i;
! 
  	  /* Avoid infinite loop if any insn of the result matches 
  	     the original pattern.  */
--- 2586,2591 ----
  	{
  	  int i;
! 	  rtx eh_note;
! 	  
  	  /* Avoid infinite loop if any insn of the result matches 
  	     the original pattern.  */
*************** try_split (pat, trial, last)
*** 2607,2610 ****
--- 2608,2624 ----
  		CALL_INSN_FUNCTION_USAGE (XVECEXP (seq, 0, i))
  		  = CALL_INSN_FUNCTION_USAGE (trial);
+ 
+ 	  /* Copy EH notes.  */
+ 	  if ((eh_note = find_reg_note (trial, REG_EH_REGION, NULL_RTX)))
+ 	    for (i = 0; i < XVECLEN (seq, 0); i++)
+ 	      {
+ 		rtx insn = XVECEXP (seq, 0, i);
+ 		if (GET_CODE (insn) == CALL_INSN
+ 		    || (flag_non_call_exceptions 
+ 			&& may_trap_p (PATTERN (insn))))
+ 		  REG_NOTES (insn) 
+ 		    = gen_rtx_EXPR_LIST (REG_EH_REGION, (XEXP (eh_note, 0)),
+ 					 REG_NOTES (insn));
+ 	      }
  
  	  /* If there are LABELS inside the split insns increment the



More information about the Gcc-patches mailing list