[RFA] Fix the address of code label (Was:[PATCH/RFA] SH: Problem when compiling with -O0)

kaz Kojima kkojima@rr.iij4u.or.jp
Sat Jan 11 13:14:00 GMT 2003


Hi,

I believe that I've understood the problem and found that it was
argued once:

<URL:http://gcc.gnu.org/ml/gcc-patches/2002-02/msg01880.html>
<URL:http://gcc.gnu.org/ml/gcc-patches/2002-02/msg01978.html>

align_fuzz assumes that the code label insn has address "aligned
with current alignment" and its length is "current alignment".
So align_fuzz can compute the original address of a code label as
INSN_ADDRESSES minus insn length. When computing initial lengths
and addresses of insns in shorten_branches, this assumption doesn't
hold because INSN_ADDRESSES of the code label is set to the original
address itself but its length is set to the alignment.

For optimizing case, they are aligned in the last while loop of
shorten_branches so as to satisfy the above assumption and the
re-computation passes will make correct things. But in -O0 case,
align_fuzz may be called before INSN_ADDRESSES of the code label
is set to the aligned address and wrong fuzz makes bad conditional
branches in SH case. With the appended patch, the problem went away.
It bootstrapped without no new regressions on x86-pc-linux-gnu and
sh4-unknown-linux-gnu. Please review it.

Regards,
	kaz
--
2003-01-11  Kaz Kojima  <kkojima@gcc.gnu.org>

	* final.c (shorten_branches): Align the address of code label
	when computing initial lengths and addresses.

--- ORIG/gcc/gcc/final.c	Sat Jan  4 08:38:20 2003
+++ LOCAL/gcc/gcc/final.c	Sat Jan 11 16:36:37 2003
@@ -991,7 +991,7 @@ shorten_branches (first)
 	    }
 	}
 
-      INSN_ADDRESSES (uid) = insn_current_address;
+      INSN_ADDRESSES (uid) = insn_current_address + insn_lengths[uid];
 
       if (GET_CODE (insn) == NOTE || GET_CODE (insn) == BARRIER
 	  || GET_CODE (insn) == CODE_LABEL)



More information about the Gcc-patches mailing list