From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id 4F61E385781D; Fri, 6 May 2022 23:44:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4F61E385781D MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-9964] i386: Fix up ix86_gimplify_va_arg [PR105331] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: 79265f689bd831809d7d9a86f756d5dd3254d347 X-Git-Newrev: 65c1c480b33ea36e9505ed444eed09a0cc1c9256 Message-Id: <20220506234414.4F61E385781D@sourceware.org> Date: Fri, 6 May 2022 23:44:14 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 May 2022 23:44:14 -0000 https://gcc.gnu.org/g:65c1c480b33ea36e9505ed444eed09a0cc1c9256 commit r11-9964-g65c1c480b33ea36e9505ed444eed09a0cc1c9256 Author: Jakub Jelinek Date: Thu Apr 28 12:33:59 2022 +0200 i386: Fix up ix86_gimplify_va_arg [PR105331] 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. 2022-04-28 Jakub Jelinek PR target/105331 * config/i386/i386.c (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. (cherry picked from commit 89dbf9a5f55e0f7565865d1b38e681ef7d76afaf) Diff: --- gcc/config/i386/i386.c | 1 + gcc/testsuite/gcc.dg/pr105331.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 48300af9a09..16fde42a9e0 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -4754,6 +4754,7 @@ ix86_gimplify_va_arg (tree valist, tree type, gimple_seq *pre_p, { 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); diff --git a/gcc/testsuite/gcc.dg/pr105331.c b/gcc/testsuite/gcc.dg/pr105331.c new file mode 100644 index 00000000000..06cf6d6d901 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr105331.c @@ -0,0 +1,11 @@ +/* PR target/105331 */ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +#include + +int +foo (va_list *va) +{ + return va_arg (*va, double _Complex); /* { dg-bogus "may be used uninitialized" } */ +}