This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
sh.c (barrier_align)
- To: amylaar at cygnus dot com
- Subject: sh.c (barrier_align)
- From: Andrew Haley <aph at cambridge dot redhat dot com>
- Date: Wed, 18 Jul 2001 16:42:58 +0100 (BST)
- Cc: gcc-patches at gcc dot gnu dot org
In barrier_align() we don't check that the insn we're looking at realy
is an insn before checking its INSN_CODE. I had a compiler crash when
that insn was a BARRIER. This patch adds an INSN_P check before
checking the INSN_CODE.
Andrew.
2001-07-18 Andrew Haley <aph@cambridge.redhat.com>
* config/sh/sh.c (barrier_align): Check that an operand really is
an insn before extracting its INSN_CODE.
Index: sh.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/config/sh/sh.c,v
retrieving revision 1.239
diff -p -4 -c -r1.239 sh.c
*** sh.c 2001/07/02 13:37:29 1.239
--- sh.c 2001/07/18 15:25:38
*************** barrier_align (barrier_or_label)
*** 3327,3358 ****
get_attr_in_delay_slot (prev) == IN_DELAY_SLOT_YES)
slot = 0;
credit -= get_attr_length (prev);
}
if (prev
&& GET_CODE (prev) == JUMP_INSN
! && JUMP_LABEL (prev)
! && (jump_to_next || next_real_insn (JUMP_LABEL (prev)) == next
/* If relax_delay_slots() decides NEXT was redundant
with some previous instruction, it will have
redirected PREV's jump to the following insn. */
|| JUMP_LABEL (prev) == next_nonnote_insn (next)
/* There is no upper bound on redundant instructions that
! might have been skipped, but we must not put an alignment
! where none had been before. */
! || (INSN_CODE (NEXT_INSN (NEXT_INSN (PREV_INSN (prev))))
! == CODE_FOR_block_branch_redirect)
! || (INSN_CODE (NEXT_INSN (NEXT_INSN (PREV_INSN (prev))))
! == CODE_FOR_indirect_jump_scratch)))
! {
! rtx pat = PATTERN (prev);
! if (GET_CODE (pat) == PARALLEL)
! pat = XVECEXP (pat, 0, 0);
! if (credit - slot >= (GET_CODE (SET_SRC (pat)) == PC ? 2 : 0))
! return 0;
! }
}
!
return CACHE_LOG;
}
/* If we are inside a phony loop, almost any kind of label can turn up as the
--- 3329,3365 ----
get_attr_in_delay_slot (prev) == IN_DELAY_SLOT_YES)
slot = 0;
credit -= get_attr_length (prev);
}
+
if (prev
&& GET_CODE (prev) == JUMP_INSN
! && JUMP_LABEL (prev))
! {
! rtx maybe_jmp;
! if (jump_to_next
! || next_real_insn (JUMP_LABEL (prev)) == next
/* If relax_delay_slots() decides NEXT was redundant
with some previous instruction, it will have
redirected PREV's jump to the following insn. */
|| JUMP_LABEL (prev) == next_nonnote_insn (next)
/* There is no upper bound on redundant instructions that
! might have been skipped, but we must not put an
! alignment where none had been before. */
! || (maybe_jmp = (NEXT_INSN (NEXT_INSN (PREV_INSN (prev)))),
! (INSN_P (maybe_jmp)
! && (INSN_CODE (maybe_jmp) == CODE_FOR_block_branch_redirect
! || INSN_CODE (maybe_jmp) == CODE_FOR_indirect_jump_scratch))))
! {
! rtx pat = PATTERN (prev);
! if (GET_CODE (pat) == PARALLEL)
! pat = XVECEXP (pat, 0, 0);
! if (credit - slot >= (GET_CODE (SET_SRC (pat)) == PC ? 2 : 0))
! return 0;
! }
! }
}
!
return CACHE_LOG;
}
/* If we are inside a phony loop, almost any kind of label can turn up as the