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]

[PATCH] Re: Fix nested functions


Jan Hubicka wrote:

> Hmm, this reminds me the i386 case - fixing one problem leads to other
> one.
> I guess adding the mark_jump_label after validate_change will lead to
> later crash in shorten_branches.

Yes, this is because mark_jump_label also ignores non-local labels.
If I change this, there is an ICE due to non-matching edge counts
somewhere, and then I've stopped debugging ...

> We really need to bail out earlier and give up idea of propagating
> nonlocal LABEL_REF into the jump I would say :( 

I did this for cse, but then combine attempted the same transformation,
and after I've fixed combine, local-alloc tried the same.

With these three places fixed, the jump finally stays indirect,
and my testcases are fixed.

Bootstrapped/regtested on s390-ibm-linux and s390x-ibm-linux.
OK for mainline?

Bye,
Ulrich


ChangeLog:

	* cse.c (cse_insn): Avoid creating direct non-local jumps.
	* combine.c (can_combine_p): Likewise.
	* local-alloc. (update_equiv_regs): Likewise.

Index: gcc/combine.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/combine.c,v
retrieving revision 1.456
diff -c -p -r1.456 combine.c
*** gcc/combine.c	26 Sep 2004 14:55:37 -0000	1.456
--- gcc/combine.c	28 Sep 2004 16:53:21 -0000
*************** can_combine_p (rtx insn, rtx i3, rtx pre
*** 1176,1181 ****
--- 1176,1183 ----
        /* Don't substitute into an incremented register.  */
        || FIND_REG_INC_NOTE (i3, dest)
        || (succ && FIND_REG_INC_NOTE (succ, dest))
+       /* Don't substitute into a non-local goto, this confuses CFG.  */
+       || (JUMP_P (i3) && find_reg_note (i3, REG_NON_LOCAL_GOTO, NULL_RTX))
  #if 0
        /* Don't combine the end of a libcall into anything.  */
        /* ??? This gives worse code, and appears to be unnecessary, since no
Index: gcc/cse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cse.c,v
retrieving revision 1.314
diff -c -p -r1.314 cse.c
*** gcc/cse.c	20 Sep 2004 20:38:17 -0000	1.314
--- gcc/cse.c	28 Sep 2004 16:53:22 -0000
*************** cse_insn (rtx insn, rtx libcall_insn)
*** 5395,5400 ****
--- 5395,5405 ----
  		  || (GET_CODE (trial) == LABEL_REF
  		      && ! condjump_p (insn))))
  	    {
+ 	      /* Don't substitute non-local labels, this confuses CFG.  */
+ 	      if (GET_CODE (trial) == LABEL_REF
+ 		  && LABEL_REF_NONLOCAL_P (trial))
+ 		continue;
+ 
  	      SET_SRC (sets[i].rtl) = trial;
  	      cse_jumps_altered = 1;
  	      break;
Index: gcc/local-alloc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/local-alloc.c,v
retrieving revision 1.138
diff -c -p -r1.138 local-alloc.c
*** gcc/local-alloc.c	10 Sep 2004 11:02:21 -0000	1.138
--- gcc/local-alloc.c	28 Sep 2004 16:53:23 -0000
*************** update_equiv_regs (void)
*** 1010,1015 ****
--- 1010,1020 ----
  	  if (! INSN_P (insn))
  	    continue;
  
+ 	  /* Don't substitute into a non-local goto, this confuses CFG.  */
+ 	  if (JUMP_P (insn)
+ 	      && find_reg_note (insn, REG_NON_LOCAL_GOTO, NULL_RTX))
+ 	    continue;
+ 
  	  for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
  	    {
  	      if (REG_NOTE_KIND (link) == REG_DEAD



-- 
  Dr. Ulrich Weigand
  weigand@informatik.uni-erlangen.de


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