* [PATCH] i386: Fix up ix86_gimplify_va_arg [PR105331]
@ 2022-04-22 7:25 Jakub Jelinek
2022-04-28 8:31 ` Patch ping " Jakub Jelinek
0 siblings, 1 reply; 6+ messages in thread
From: Jakub Jelinek @ 2022-04-22 7:25 UTC (permalink / raw)
To: Uros Bizjak; +Cc: gcc-patches
Hi!
On the following testcase we emit a bogus
'va_arg_tmp.5' may be used uninitialized
warning. The reason is that when gimplifying the addr = &temp;
statement, the va_arg_tmp temporary var for which we emit ADDR_EXPR
is not TREE_ADDRESSABLE, prepare_gimple_addressable emits some extra
code to initialize the newly addressable var from its previous value,
but it is a new variable which hasn't been initialized yet and will
be later, so we end up initializing it with uninitialized SSA_NAME:
va_arg_tmp.6 = va_arg_tmp.5_14(D);
addr.2_16 = &va_arg_tmp.6;
_17 = MEM[(double *)sse_addr.4_13];
MEM[(double * {ref-all})addr.2_16] = _17;
and with -O1 we actually don't DSE it before the warning is emitted.
If we make the temp TREE_ADDRESSABLE before the gimplification, then
this prepare_gimple_addressable path isn't taken and we effectively
omit the first statement above and so the bogus warning is gone.
I went through other backends and didn't find another instance of this
problem.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2022-04-22 Jakub Jelinek <jakub@redhat.com>
PR target/105331
* config/i386/i386.cc (ix86_gimplify_va_arg): Mark va_arg_tmp
temporary TREE_ADDRESSABLE before trying to gimplify ADDR_EXPR
of it.
* gcc.dg/pr105331.c: New test.
--- gcc/config/i386/i386.cc.jj 2022-04-12 09:20:07.566662842 +0200
+++ gcc/config/i386/i386.cc 2022-04-21 12:03:32.201951522 +0200
@@ -4891,6 +4891,7 @@ ix86_gimplify_va_arg (tree valist, tree
{
int i, prev_size = 0;
tree temp = create_tmp_var (type, "va_arg_tmp");
+ TREE_ADDRESSABLE (temp) = 1;
/* addr = &temp; */
t = build1 (ADDR_EXPR, build_pointer_type (type), temp);
--- gcc/testsuite/gcc.dg/pr105331.c.jj 2022-04-21 12:09:34.398906718 +0200
+++ gcc/testsuite/gcc.dg/pr105331.c 2022-04-21 12:09:07.304283903 +0200
@@ -0,0 +1,11 @@
+/* PR target/105331 */
+/* { dg-do compile } */
+/* { dg-options "-O -Wuninitialized" } */
+
+#include <stdarg.h>
+
+int
+foo (va_list *va)
+{
+ return va_arg (*va, double _Complex); /* { dg-bogus "may be used uninitialized" } */
+}
Jakub
^ permalink raw reply [flat|nested] 6+ messages in thread
* Patch ping Re: [PATCH] i386: Fix up ix86_gimplify_va_arg [PR105331]
2022-04-22 7:25 [PATCH] i386: Fix up ix86_gimplify_va_arg [PR105331] Jakub Jelinek
@ 2022-04-28 8:31 ` Jakub Jelinek
2022-04-28 8:39 ` Uros Bizjak
0 siblings, 1 reply; 6+ messages in thread
From: Jakub Jelinek @ 2022-04-28 8:31 UTC (permalink / raw)
To: Uros Bizjak, gcc-patches
Hi!
I'd like to ping this patch. I know it isn't a full week yet, but we are
almost out of P1s and GCC 12 branching is any time now.
Thanks:
On Fri, Apr 22, 2022 at 09:25:04AM +0200, Jakub Jelinek via Gcc-patches wrote:
> On the following testcase we emit a bogus
> 'va_arg_tmp.5' may be used uninitialized
> warning. The reason is that when gimplifying the addr = &temp;
> statement, the va_arg_tmp temporary var for which we emit ADDR_EXPR
> is not TREE_ADDRESSABLE, prepare_gimple_addressable emits some extra
> code to initialize the newly addressable var from its previous value,
> but it is a new variable which hasn't been initialized yet and will
> be later, so we end up initializing it with uninitialized SSA_NAME:
> va_arg_tmp.6 = va_arg_tmp.5_14(D);
> addr.2_16 = &va_arg_tmp.6;
> _17 = MEM[(double *)sse_addr.4_13];
> MEM[(double * {ref-all})addr.2_16] = _17;
> and with -O1 we actually don't DSE it before the warning is emitted.
> If we make the temp TREE_ADDRESSABLE before the gimplification, then
> this prepare_gimple_addressable path isn't taken and we effectively
> omit the first statement above and so the bogus warning is gone.
>
> I went through other backends and didn't find another instance of this
> problem.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2022-04-22 Jakub Jelinek <jakub@redhat.com>
>
> PR target/105331
> * config/i386/i386.cc (ix86_gimplify_va_arg): Mark va_arg_tmp
> temporary TREE_ADDRESSABLE before trying to gimplify ADDR_EXPR
> of it.
>
> * gcc.dg/pr105331.c: New test.
Jakub
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Patch ping Re: [PATCH] i386: Fix up ix86_gimplify_va_arg [PR105331]
2022-04-28 8:31 ` Patch ping " Jakub Jelinek
@ 2022-04-28 8:39 ` Uros Bizjak
2022-04-28 10:30 ` Jakub Jelinek
0 siblings, 1 reply; 6+ messages in thread
From: Uros Bizjak @ 2022-04-28 8:39 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
On Thu, Apr 28, 2022 at 10:31 AM Jakub Jelinek <jakub@redhat.com> wrote:
>
> Hi!
>
> I'd like to ping this patch. I know it isn't a full week yet, but we are
> almost out of P1s and GCC 12 branching is any time now.
>
> Thanks:
> On Fri, Apr 22, 2022 at 09:25:04AM +0200, Jakub Jelinek via Gcc-patches wrote:
> > On the following testcase we emit a bogus
> > 'va_arg_tmp.5' may be used uninitialized
> > warning. The reason is that when gimplifying the addr = &temp;
> > statement, the va_arg_tmp temporary var for which we emit ADDR_EXPR
> > is not TREE_ADDRESSABLE, prepare_gimple_addressable emits some extra
> > code to initialize the newly addressable var from its previous value,
> > but it is a new variable which hasn't been initialized yet and will
> > be later, so we end up initializing it with uninitialized SSA_NAME:
> > va_arg_tmp.6 = va_arg_tmp.5_14(D);
> > addr.2_16 = &va_arg_tmp.6;
> > _17 = MEM[(double *)sse_addr.4_13];
> > MEM[(double * {ref-all})addr.2_16] = _17;
> > and with -O1 we actually don't DSE it before the warning is emitted.
> > If we make the temp TREE_ADDRESSABLE before the gimplification, then
> > this prepare_gimple_addressable path isn't taken and we effectively
> > omit the first statement above and so the bogus warning is gone.
> >
> > I went through other backends and didn't find another instance of this
> > problem.
> >
> > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> >
> > 2022-04-22 Jakub Jelinek <jakub@redhat.com>
> >
> > PR target/105331
> > * config/i386/i386.cc (ix86_gimplify_va_arg): Mark va_arg_tmp
> > temporary TREE_ADDRESSABLE before trying to gimplify ADDR_EXPR
> > of it.
> >
> > * gcc.dg/pr105331.c: New test.
Sorry, I have no idea if this patch is correct or not.
Uros.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Patch ping Re: [PATCH] i386: Fix up ix86_gimplify_va_arg [PR105331]
2022-04-28 8:39 ` Uros Bizjak
@ 2022-04-28 10:30 ` Jakub Jelinek
2022-04-28 10:31 ` Richard Biener
0 siblings, 1 reply; 6+ messages in thread
From: Jakub Jelinek @ 2022-04-28 10:30 UTC (permalink / raw)
To: Richard Biener, Jeff Law; +Cc: gcc-patches
On Thu, Apr 28, 2022 at 10:39:39AM +0200, Uros Bizjak wrote:
> > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> > >
> > > 2022-04-22 Jakub Jelinek <jakub@redhat.com>
> > >
> > > PR target/105331
> > > * config/i386/i386.cc (ix86_gimplify_va_arg): Mark va_arg_tmp
> > > temporary TREE_ADDRESSABLE before trying to gimplify ADDR_EXPR
> > > of it.
> > >
> > > * gcc.dg/pr105331.c: New test.
>
> Sorry, I have no idea if this patch is correct or not.
Richard or Jeff, could you please review it instead?
Thanks.
Jakub
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Patch ping Re: [PATCH] i386: Fix up ix86_gimplify_va_arg [PR105331]
2022-04-28 10:30 ` Jakub Jelinek
@ 2022-04-28 10:31 ` Richard Biener
2022-04-28 13:16 ` Jeff Law
0 siblings, 1 reply; 6+ messages in thread
From: Richard Biener @ 2022-04-28 10:31 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Jeff Law, gcc-patches
On Thu, 28 Apr 2022, Jakub Jelinek wrote:
> On Thu, Apr 28, 2022 at 10:39:39AM +0200, Uros Bizjak wrote:
> > > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> > > >
> > > > 2022-04-22 Jakub Jelinek <jakub@redhat.com>
> > > >
> > > > PR target/105331
> > > > * config/i386/i386.cc (ix86_gimplify_va_arg): Mark va_arg_tmp
> > > > temporary TREE_ADDRESSABLE before trying to gimplify ADDR_EXPR
> > > > of it.
> > > >
> > > > * gcc.dg/pr105331.c: New test.
> >
> > Sorry, I have no idea if this patch is correct or not.
>
> Richard or Jeff, could you please review it instead?
OK.
Thanks,
Richard.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Patch ping Re: [PATCH] i386: Fix up ix86_gimplify_va_arg [PR105331]
2022-04-28 10:31 ` Richard Biener
@ 2022-04-28 13:16 ` Jeff Law
0 siblings, 0 replies; 6+ messages in thread
From: Jeff Law @ 2022-04-28 13:16 UTC (permalink / raw)
To: Richard Biener, Jakub Jelinek; +Cc: gcc-patches
On 4/28/2022 4:31 AM, Richard Biener wrote:
> On Thu, 28 Apr 2022, Jakub Jelinek wrote:
>
>> On Thu, Apr 28, 2022 at 10:39:39AM +0200, Uros Bizjak wrote:
>>>>> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>>>>>
>>>>> 2022-04-22 Jakub Jelinek <jakub@redhat.com>
>>>>>
>>>>> PR target/105331
>>>>> * config/i386/i386.cc (ix86_gimplify_va_arg): Mark va_arg_tmp
>>>>> temporary TREE_ADDRESSABLE before trying to gimplify ADDR_EXPR
>>>>> of it.
>>>>>
>>>>> * gcc.dg/pr105331.c: New test.
>>> Sorry, I have no idea if this patch is correct or not.
>> Richard or Jeff, could you please review it instead?
> OK.
Agreed. In fact I'd fixed something very similar in our port a while ago.
Jeff
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-04-28 13:16 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-22 7:25 [PATCH] i386: Fix up ix86_gimplify_va_arg [PR105331] Jakub Jelinek
2022-04-28 8:31 ` Patch ping " Jakub Jelinek
2022-04-28 8:39 ` Uros Bizjak
2022-04-28 10:30 ` Jakub Jelinek
2022-04-28 10:31 ` Richard Biener
2022-04-28 13:16 ` Jeff Law
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).