This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, GCC/Thumb-1]Mishandle the label type insn in function thumb1_reorg
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: Terry Guo <terry dot guo at arm dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Ramana Radhakrishnan <Ramana dot Radhakrishnan at arm dot com>
- Date: Wed, 18 Jun 2014 09:30:52 +0100
- Subject: Re: [Patch, GCC/Thumb-1]Mishandle the label type insn in function thumb1_reorg
- Authentication-results: sourceware.org; auth=none
- References: <000701cf84a1$1ed04340$5c70c9c0$ at arm dot com>
On 10/06/14 12:42, Terry Guo wrote:
> Hi There,
>
> The thumb1_reorg function use macro INSN_CODE to find expected instructions.
> But the macro INSN_CODE doesnât work for label type instruction. The
> INSN_CODE(label_insn) will return the label number. When we have a lot of
> labels and current label_insn is the first insn of basic block, the
> INSN_CODE(label_insn) could accidentally equal to CODE_FOR_cbranchsi4_insn
> in this case. This leads to ICE due to SET_SRC(label_insn) in subsequent
> code. In general we should skip all such improper insns. This is the purpose
> of attached small patch.
>
> Some failures in recent gcc regression test on thumb1 target are caused by
> this reason. So with this patch, all of them passed and no new failures. Is
> it ok to trunk?
>
> BR,
> Terry
>
> 2014-06-10 Terry Guo <terry.guo@arm.com>
>
> * config/arm/arm.c (thumb1_reorg): Move to next basic block if the head
> of current basic block isnât a proper insn.
>
I think you should just test that "insn != BB_HEAD (bb)". The loop
immediately above this deals with the !NON-DEBUG insns, so the logic is
confusing the way you've written it.
R.
>
> thumb1-reorg-v2.txt
>
>
> diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
> index ccad548..3ebe424 100644
> --- a/gcc/config/arm/arm.c
> +++ b/gcc/config/arm/arm.c
> @@ -16939,7 +16939,8 @@ thumb1_reorg (void)
> insn = PREV_INSN (insn);
>
> /* Find the last cbranchsi4_insn in basic block BB. */
> - if (INSN_CODE (insn) != CODE_FOR_cbranchsi4_insn)
> + if (!NONDEBUG_INSN_P (insn)
> + || INSN_CODE (insn) != CODE_FOR_cbranchsi4_insn)
> continue;
>
> /* Get the register with which we are comparing. */
>