From patchwork Fri Aug 26 10:58:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 780 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:ecc5:0:0:0:0:0 with SMTP id s5csp176240wro; Fri, 26 Aug 2022 03:59:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR4gZIWtiJMnMabhQd91FN4lFGCnboZaqIl2ucxc4Fv1eLXEifFzeN6mZmuZA2PLCCTxLkS7 X-Received: by 2002:a05:6402:3590:b0:447:a871:c48a with SMTP id y16-20020a056402359000b00447a871c48amr6253065edc.356.1661511561001; Fri, 26 Aug 2022 03:59:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661511560; cv=none; d=google.com; s=arc-20160816; b=iBbssgmMSg8N6F1EZIjh5OMTlHPfhFw4LKGC4GAmQNXYIPccy/ikfiWcdukm89aFGQ rCyUke2g+budMUMwzuWOQ6rckNc6/ZJw2rvkR5tDuICA9C/xgGlOSelhgBcTdxODFIWr I5II+RTVXvJc+Cm94/xvKZHWHLaC2j5UPacXcZBhT/Nbl9jnTZpQBob9XgbuMnNXdcDA tqwvAM7y+DHRA3bgYkM9mDYDmYKxzBzHeC1ByqNCwymd7BXeuICAU0A8ubHgiOpCkjEw REsCouw3OjmIkWXXzGf4LZOw8P3/7qhW6z9I1xoDBy5zfJ3SD/vo/hiLOdN4jMuHUU3Q 19+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:message-id :mime-version:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=jnAVANwdyJ1kL/0xpcRvW5bILGx8jPKVzTARsKMp1Fk=; b=POziFtkJczhGRdbZikNwT06M3mawA616Bnocf8XXlnlmZzlE0T/+57x0YquM+LlzJM ZMfTFeEZSvMBZYDZuFeJpw8fP7CQWllLEFqVK7wk+R1+fkboRmAMd9Ex1P/gKgKuZAbD pM/3HE88u0FCQSODbkX9tX6Lejukw463bB0QhpIC6Imx9ec3bFw3SGEOIPhdX0/5oyau s27domx0J5XWmeTMbPD7GWz6uS0++G/sYYvuK3jPQ6Yl5Fc7UKZgyYTWv0nj+v3PhO4U v1hg5cSLlqBK+plfZnM3YB3WnowJStbmIV4hS8y/vfcY9j36kEyh32cemg83uSNExaV9 pdAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=psUdjYMi; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id l21-20020a17090615d500b0073d5b705ac7si977815ejd.477.2022.08.26.03.59.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 03:59:20 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=psUdjYMi; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D79893851AB7 for ; Fri, 26 Aug 2022 10:59:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D79893851AB7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1661511559; bh=jnAVANwdyJ1kL/0xpcRvW5bILGx8jPKVzTARsKMp1Fk=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=psUdjYMiU8md5jBfQyrVXJIAJjvF+nJ2qCUtXCS15ZiwqKcGz7nel3grREb2Vv5hQ dNHXfNpJ1HnIr/U9zaDqbWe+qReoQd9dNeCWUlPee7dEv0HWX3Pm8+O0F/Tj/JrXOE TSAVEVqQPlg3PptXItdPZshZ08yHW0N0OhKZI+qs= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 6C3DF3858404 for ; Fri, 26 Aug 2022 10:58:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6C3DF3858404 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 787CA1FDBD for ; Fri, 26 Aug 2022 10:58:34 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 675CD13A7E for ; Fri, 26 Aug 2022 10:58:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id SEE+GFqnCGMmaQAAMHmgww (envelope-from ) for ; Fri, 26 Aug 2022 10:58:34 +0000 Date: Fri, 26 Aug 2022 12:58:34 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] New testcase for uninit MIME-Version: 1.0 Message-Id: <20220826105834.675CD13A7E@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1742221146360706322?= X-GMAIL-MSGID: =?utf-8?q?1742221146360706322?= The following adds a testcase that illustrates a defect in compute_control_dep_chain and its attempt to identify loop exits as special to continue walking post-dominators but failing to do so for following post-dominators. On trunk there is now simple_control_dep_chain saving the day, avoiding the false positive but with GCC 12 we get a bogus diagnostic. Pushed. * gcc.dg/uninit-pred-11.c: New testcase. --- gcc/testsuite/gcc.dg/uninit-pred-11.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/uninit-pred-11.c diff --git a/gcc/testsuite/gcc.dg/uninit-pred-11.c b/gcc/testsuite/gcc.dg/uninit-pred-11.c new file mode 100644 index 00000000000..734df379ef7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/uninit-pred-11.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wmaybe-uninitialized" } */ + +extern unsigned bar (void); +extern void quux (void); +int z; +unsigned foo (unsigned v, int y) +{ + unsigned u; + if (v != 1) + u = bar (); + + // Prevent the "dom" pass from changing the CFG layout based on the inference + // 'if (v != 1) is false then (v != 2) is true'. (Now it would have to + // duplicate the loop in order to do so, which is deemed expensive.) + for (int i = 0; i < 10; i++) + quux (); + + // This variation from uninit-25.c causes compute_control_dep_chain + // to run into a defect but simple_control_dep_chain saves us here + if (y) + z = 1; + if (v != 1) + return u; /* { dg-bogus "may be used uninitialized" } */ + + return 0; +}