From patchwork Fri Apr 22 07:25:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1620740 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=kz2kBGK/; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KlBcL6R4Qz9ryY for ; Fri, 22 Apr 2022 21:13:54 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0B19D3857369 for ; Fri, 22 Apr 2022 11:13:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0B19D3857369 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1650626033; bh=ov+WscKgK6mbMydwcrgBV0P79X3ormZoY+n71mR6XJ4=; h=Resent-From:Resent-Date:Resent-To:Date:To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:Cc:From; b=kz2kBGK/NnSVxoM7CDsf08SUXwWplqFCB07pXV+o+BxCg4HkwlkYDiK+bERce0iHB nMBeqXlxQ4Dz0di//mD5bx0rlLCSZFSXu0g7rNWiHcj5Dwp9OeN7J9BibybuV+5PyH b3WvLjfoOXt4GqUtIM//Yhafnf8bXQtbGePRg3pg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id BE17F3857369 for ; Fri, 22 Apr 2022 11:13:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BE17F3857369 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-287-td3hx7DQMYadE2Vpkn6mqw-1; Fri, 22 Apr 2022 07:13:11 -0400 X-MC-Unique: td3hx7DQMYadE2Vpkn6mqw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 21DAA383974F; Fri, 22 Apr 2022 11:13:11 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D6EF52026985; Fri, 22 Apr 2022 11:13:10 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 23MBD8RG2228558 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 22 Apr 2022 13:13:08 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 23MBD7QQ2228557; Fri, 22 Apr 2022 13:13:07 +0200 Resent-From: Jakub Jelinek Resent-Date: Fri, 22 Apr 2022 13:13:07 +0200 Resent-Message-ID: Resent-To: Uros Bizjak , gcc-patches@gcc.gnu.org Date: Fri, 22 Apr 2022 09:25:04 +0200 To: Uros Bizjak Subject: [PATCH] i386: Fix up ix86_gimplify_va_arg [PR105331] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "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 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 --- 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 + +int +foo (va_list *va) +{ + return va_arg (*va, double _Complex); /* { dg-bogus "may be used uninitialized" } */ +}