From: Richard Biener <richard.guenther@gmail.com>
To: Tom de Vries <Tom_deVries@mentor.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
John David Anglin <dave.anglin@bell.net>
Subject: Re: [PATCH][PR65818][bootstrap,hppa] Return side-effect free result in gimplify_va_arg_internal
Date: Mon, 27 Apr 2015 08:17:00 -0000 [thread overview]
Message-ID: <CAFiYyc1AhuTe-pfBhoKUFLBF7KBGmR_CgQphcN=gT6aDwDzBsQ@mail.gmail.com> (raw)
In-Reply-To: <553B89FB.7000009@mentor.com>
On Sat, Apr 25, 2015 at 2:35 PM, Tom de Vries <Tom_deVries@mentor.com> wrote:
> Hi,
>
> this patch fixes PR65818, and hppa bootstrap.
>
> When compiling gcc/libiberty/vprintf-support.c, the following va_arg is
> compiled:
> ...
> (void) __builtin_va_arg(ap, double);
> ...
>
> This results in the following ifn_va_arg at gimple level, with a NULL_TREE
> lhs:
> ...
> VA_ARG (&ap, 0B);
> ...
>
> We start expanding the ifn_va_arg in expand_ifn_va_arg_1 by calling
> gimplify_va_arg_internal:
> ...
> expr = gimplify_va_arg_internal (ap, type, gimple_location (stmt),
> &pre, &post);
> ...
>
> Subsequently, because the lhs is NULL_TREE, we skip generating the assign to
> the lhs:
> ...
> lhs = gimple_call_lhs (stmt);
> if (lhs != NULL_TREE)
> {
> gcc_assert (useless_type_conversion_p (TREE_TYPE (lhs), type));
>
> if (gimple_call_num_args (stmt) == 3)
> {
> /* We've transported the size of with WITH_SIZE_EXPR here as
> the 3rd argument of the internal fn call. Now reinstate
> it. */
> tree size = gimple_call_arg (stmt, 2);
> expr = build2 (WITH_SIZE_EXPR, TREE_TYPE (expr), expr,
> size);
> }
>
> /* We use gimplify_assign here, rather than gimple_build_assign,
> because gimple_assign knows how to deal with variable-sized
> types. */
> gimplify_assign (lhs, expr, &pre);
> }
> ...
>
> We assume here that any side-effects related to updating ap have been
> generated into pre/post by gimplify_va_arg_internal, and that it's safe to
> ignore expr.
>
> Turns out, that's not the case for hppa. The target hook
> hppa_gimplify_va_arg_expr (called from gimplify_va_arg_internal) returns an
> expression that still contains a side-effect:
> ...
> *(double *) (ap = ap + 4294967288 & 4294967288B)
> ...
>
> This patch fixes that by gimplifying the address expression of the mem-ref
> returned by the target hook (borrowing code from gimplify_expr, case
> MEM_REF).
>
> Bootstrapped and reg-tested on x86_64.
>
> Bootstrapped and reg-tested on hppa2.0w-hp-hpux11.11.
>
> OK for trunk?
Hmm, that assert looks suspicious...
Can't you simply always do
gimplify_expr (expr, pre_p, post_p, is_gimple_lvalue, fb_lvalue);
?
Richard.
> Thanks,
> - Tom
>
next prev parent reply other threads:[~2015-04-27 8:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-25 12:35 Tom de Vries
2015-04-27 8:17 ` Richard Biener [this message]
2015-04-27 13:06 ` Tom de Vries
2015-04-27 13:40 ` Richard Biener
2015-04-27 15:04 ` Tom de Vries
2015-04-28 10:49 ` Richard Biener
2015-04-28 21:59 ` Tom de Vries
2015-04-29 9:53 ` Richard Biener
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAFiYyc1AhuTe-pfBhoKUFLBF7KBGmR_CgQphcN=gT6aDwDzBsQ@mail.gmail.com' \
--to=richard.guenther@gmail.com \
--cc=Tom_deVries@mentor.com \
--cc=dave.anglin@bell.net \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).