* [PATCH] Fix gimplify_parameters (PR middle-end/36125)
@ 2008-11-11 13:20 Jakub Jelinek
2008-11-11 15:37 ` Richard Guenther
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2008-11-11 13:20 UTC (permalink / raw)
To: gcc-patches
Hi!
If gimplify_parameters for callee copied parameters copies a PARM_DECL
into a local VAR_DECL, which is used by all other references in the function
instead of the PARM_DECL and the PARM_DECL has TREE_ADDRESSABLE flag,
invalid GIMPLE is emitted. The TREE_ADDRESSABLE flag in this case can
mean just that the address of the parameter has been taken somewhere within
the function (PARM_DECLs with TREE_ADDRESSABLE types aren't callee copied),
so very likely during gimplification the local copy VAR_DECL is marked
TREE_ADDRESSABLE as well, and assigning from TREE_ADDRESSABLE PARM_DECL
into TREE_ADDRESSABLE var directly is not valid in GIMPLE.
IMHO we don't need to mark the PARM_DECL as TREE_ADDRESSABLE, its
address is certainly not taken anywhere in the function (as they take
address of the local copy instead). So the following patch just moves
the TREE_ADDRESSABLE flag from the PARM_DECL to the VAR_DECL that is
stored in DECL_VALUE_EXPR of the PARM_DECL.
I've bootstrapped/regtested this on x86_64-linux, John, can you please
bootstrap it on hppa? Ok for trunk?
2008-11-11 Jakub Jelinek <jakub@redhat.com>
PR middle-end/36125
* function.c (gimplify_parameters): For callee copies parameters,
move TREE_ADDRESSABLE flag from the PARM_DECL to the local copy.
* gcc.c-torture/compile/pr36125.c: New test.
--- gcc/function.c.jj 2008-10-31 22:28:21.000000000 +0100
+++ gcc/function.c 2008-11-11 11:09:53.000000000 +0100
@@ -3265,6 +3265,14 @@ gimplify_parameters (void)
{
local = create_tmp_var (type, get_name (parm));
DECL_IGNORED_P (local) = 0;
+ /* If PARM was addressable, move that flag over
+ to the local copy, as its address will be taken,
+ not the PARMs. */
+ if (TREE_ADDRESSABLE (parm))
+ {
+ TREE_ADDRESSABLE (parm) = 0;
+ TREE_ADDRESSABLE (local) = 1;
+ }
}
else
{
--- gcc/testsuite/gcc.c-torture/compile/pr36125.c.jj 2008-11-11 11:11:51.000000000 +0100
+++ gcc/testsuite/gcc.c-torture/compile/pr36125.c 2008-11-11 11:10:34.000000000 +0100
@@ -0,0 +1,10 @@
+/* PR middle-end/36125 */
+
+extern void bar (long double *);
+
+int
+foo (long double x)
+{
+ bar (&x);
+ return 0;
+}
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix gimplify_parameters (PR middle-end/36125)
2008-11-11 13:20 [PATCH] Fix gimplify_parameters (PR middle-end/36125) Jakub Jelinek
@ 2008-11-11 15:37 ` Richard Guenther
0 siblings, 0 replies; 2+ messages in thread
From: Richard Guenther @ 2008-11-11 15:37 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
On Tue, Nov 11, 2008 at 7:06 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> If gimplify_parameters for callee copied parameters copies a PARM_DECL
> into a local VAR_DECL, which is used by all other references in the function
> instead of the PARM_DECL and the PARM_DECL has TREE_ADDRESSABLE flag,
> invalid GIMPLE is emitted. The TREE_ADDRESSABLE flag in this case can
> mean just that the address of the parameter has been taken somewhere within
> the function (PARM_DECLs with TREE_ADDRESSABLE types aren't callee copied),
> so very likely during gimplification the local copy VAR_DECL is marked
> TREE_ADDRESSABLE as well, and assigning from TREE_ADDRESSABLE PARM_DECL
> into TREE_ADDRESSABLE var directly is not valid in GIMPLE.
>
> IMHO we don't need to mark the PARM_DECL as TREE_ADDRESSABLE, its
> address is certainly not taken anywhere in the function (as they take
> address of the local copy instead). So the following patch just moves
> the TREE_ADDRESSABLE flag from the PARM_DECL to the VAR_DECL that is
> stored in DECL_VALUE_EXPR of the PARM_DECL.
> I've bootstrapped/regtested this on x86_64-linux, John, can you please
> bootstrap it on hppa? Ok for trunk?
Makes sense. Ok if it works on hppa.
Thanks,
Richard.
> 2008-11-11 Jakub Jelinek <jakub@redhat.com>
>
> PR middle-end/36125
> * function.c (gimplify_parameters): For callee copies parameters,
> move TREE_ADDRESSABLE flag from the PARM_DECL to the local copy.
>
> * gcc.c-torture/compile/pr36125.c: New test.
>
> --- gcc/function.c.jj 2008-10-31 22:28:21.000000000 +0100
> +++ gcc/function.c 2008-11-11 11:09:53.000000000 +0100
> @@ -3265,6 +3265,14 @@ gimplify_parameters (void)
> {
> local = create_tmp_var (type, get_name (parm));
> DECL_IGNORED_P (local) = 0;
> + /* If PARM was addressable, move that flag over
> + to the local copy, as its address will be taken,
> + not the PARMs. */
> + if (TREE_ADDRESSABLE (parm))
> + {
> + TREE_ADDRESSABLE (parm) = 0;
> + TREE_ADDRESSABLE (local) = 1;
> + }
> }
> else
> {
> --- gcc/testsuite/gcc.c-torture/compile/pr36125.c.jj 2008-11-11 11:11:51.000000000 +0100
> +++ gcc/testsuite/gcc.c-torture/compile/pr36125.c 2008-11-11 11:10:34.000000000 +0100
> @@ -0,0 +1,10 @@
> +/* PR middle-end/36125 */
> +
> +extern void bar (long double *);
> +
> +int
> +foo (long double x)
> +{
> + bar (&x);
> + return 0;
> +}
>
> Jakub
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-11-11 15:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-11 13:20 [PATCH] Fix gimplify_parameters (PR middle-end/36125) Jakub Jelinek
2008-11-11 15:37 ` Richard Guenther
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).