This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] PR63404, gcc 5 miscompiles linux block layer
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: Richard Henderson <rth at redhat dot com>, Jiong Wang <Jiong dot Wang at arm dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Cc: Jeff Law <law at redhat dot com>
- Date: Tue, 30 Sep 2014 15:15:27 +0100
- Subject: Re: [PATCH] PR63404, gcc 5 miscompiles linux block layer
- Authentication-results: sourceware.org; auth=none
- References: <5429A102 dot 4000602 at arm dot com> <5429A5D9 dot 9040404 at redhat dot com>
On 29/09/14 19:32, Richard Henderson wrote:
> On 09/29/2014 11:12 AM, Jiong Wang wrote:
>> +inline rtx single_set_no_clobber_use (const rtx_insn *insn)
>> +{
>> + if (!INSN_P (insn))
>> + return NULL_RTX;
>> +
>> + if (GET_CODE (PATTERN (insn)) == SET)
>> + return PATTERN (insn);
>> +
>> + /* Defer to the more expensive case, and return NULL_RTX if there is
>> + USE or CLOBBER. */
>> + return single_set_2 (insn, PATTERN (insn), true);
>> }
>
> What more expensive case?
>
> If you're disallowing USE and CLOBBER, then single_set is just GET_CODE == SET.
>
> I think this function is somewhat useless, and should not be added.
>
> An adjustment to move_insn_for_shrink_wrap may be reasonable though. I haven't
> tried to understand the miscompilation yet. I can imagine that this would
> disable quite a bit of shrink wrapping for x86 though. Can we do better in
> understanding when the clobbered register is live at the location to which we'd
> like to move then insns?
>
>
> r~
>
I think part of the problem is in the naming of single_set(). From the
name it's not entirely obvious to users that this includes insns that
clobber registers or which write other registers that are unused after
that point. I've previously had to fix a bug where this assumption was
made (eg https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54300)
Most uses of single_set prior to register allocation are probably safe;
but later uses are fraught with potential problems of this nature and
may well be bugs waiting to happen.
R.