This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
gcse bugfix
- From: law at redhat dot com
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 19 Nov 2001 14:48:16 -0500
- Subject: gcse bugfix
- Reply-to: law at redhat dot com
gcse can turn conditional jumps into nop-jumps ie they can be turned into
(set (pc) (pc))
When this happens we properly decrement the LABEL_NUSES for the CODE_LABEL
associated with the jump. However, we leave the JUMP_LABEL field alone.
This causes problems when cse (or some other pass) removes the nop jump
via delete_insn. Why? Because delete_insn decrements LABEL_NUSES for
any code label associated with a jump that's being deleted. Thus we
can end up decrementing LABEL_NUSES twice.
The incorrect reference counting can potentially cause any number of
problems. In my particular case it was causing cse.c to believe it
could extend a basic block, when in fact it should not have (we thought
we passed the only label reference, when in fact there were 2 label
references). Extension of the block ultimately led to incorrect code as
we had incorrect equivalences in the hash table.
This has survived a bootstrap on PA32 hpux11 as well as x86-linux. No
regressions in the testsuite on either platform -- and of course it fixes
a number of PA execution failures.
* gcse.c (cprop_jump): Clear JUMP_LABEL field when we create
a nop-jump.
Index: gcse.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/gcse.c,v
retrieving revision 1.125
diff -c -3 -p -r1.125 gcse.c
*** gcse.c 2001/10/22 08:35:07 1.125
--- gcse.c 2001/11/19 18:59:51
*************** cprop_jump (bb, insn, from, src)
*** 4256,4262 ****
SET_SRC (set) = new;
if (JUMP_LABEL (insn) != 0)
! --LABEL_NUSES (JUMP_LABEL (insn));
}
/* Otherwise, this must be a valid instruction. */
--- 4256,4265 ----
SET_SRC (set) = new;
if (JUMP_LABEL (insn) != 0)
! {
! --LABEL_NUSES (JUMP_LABEL (insn));
! JUMP_LABEL (insn) = NULL_RTX;
! }
}
/* Otherwise, this must be a valid instruction. */