This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RE: [REPOST] Invalid Code when reading from unaligned zero-sized array
- From: Bernd Edlinger <bernd dot edlinger at hotmail dot de>
- To: Jeff Law <law at redhat dot com>, Richard Biener <richard dot guenther at gmail dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Jakub Jelinek <jakub at redhat dot com>
- Date: Fri, 6 Dec 2013 09:51:33 +0100
- Subject: RE: [REPOST] Invalid Code when reading from unaligned zero-sized array
- Authentication-results: sourceware.org; auth=none
- References: <DUB122-W20B5CD3C7B50824A33E21AE4D50 at phx dot gbl>,<CAFiYyc17fikBtmMsMGk7CsQhGWU430iku=PBpLyrQEsLBo5CuQ at mail dot gmail dot com>,<CAFiYyc0PgY3miKhjRYAvkWPiCxFc7AOcrN9G=mSL2rS0Qswy1w at mail dot gmail dot com>,<DUB122-W26170FA1F6D065B57F561FE4D40 at phx dot gbl>,<52A15D9F dot 6070309 at redhat dot com>
Hi,
On Thu, 5 Dec 2013 22:16:15, Jeff Law wrote:
>
> On 12/04/13 01:16, Bernd Edlinger wrote:
>
>>
>>> Looking for some more time your patch may be indeed the easiest
>>> without big re-factoring.
> Richard (or Bernd), can you comment on why? Something seems "off" here.
>
> Why do we need to handle inner references here specially? If feels
> like we're catering to broken code elsewhere in GCC.
>
My first attempt at fixing this was just a one-line change.
like:
@@ -9905,7 +9861,7 @@ expand_expr_real_1 (tree exp, rtx target
&& modifier != EXPAND_STACK_PARM
? target : NULL_RTX),
VOIDmode,
- modifier == EXPAND_SUM ? EXPAND_NORMAL : modifier);
+ EXPAND_MEMORY);
But the problem with that was, that it might loose too much information...
i.e. little we know what tem might be, and what a change to the original
expand_modifier would have done at other places where we had no
problems at all.
So this current version of the patch is a trying to get as much flexibility
as possible while changing as little as possible at the same time.
Technically we only have to switch off some places in MEM_REF,
and VIEW_CONVERT_EXPR, where an unaligned value is placed in a
register, which turns out to be unnecessary in this special context.
> As for the patch itself. In a few places within expand_expr_real_1 you
> changed calls to expand_expr to instead call expand_expr_real. ISTM
> you could have gotten the same effect by just adding your extra argument
> to the existing code?
>
Yes, but one goal is to keep the patch-file as small as possible,
and expand_expr is used everywhere.
Actually expand_expr is just a wrapper for
expand_expr_real (exp, target, mode, modifier, NULL, false)
Therefore I replaced expand_expr with expand_expr_real at these few
places, to keep the change smaller.
Another point is, that I do not want to pass true for expand_reference
at any other place than from exand_expr_real_1 where the inner
reference is expanded.
Thanks
Bernd.
>
> Jeff