From patchwork Tue Oct 25 08:47:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 10591 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp884706wru; Tue, 25 Oct 2022 01:48:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6vsYkuyJ/uyMzPs6QKIhPc4OLHl69Hqd2desX4h23nnSIcSGLeKblygcJxS4TLmEAF43Dd X-Received: by 2002:a17:906:d54d:b0:78e:2fbf:ca2a with SMTP id cr13-20020a170906d54d00b0078e2fbfca2amr32137628ejc.488.1666687706386; Tue, 25 Oct 2022 01:48:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666687706; cv=none; d=google.com; s=arc-20160816; b=mXXcoBQH99Vh61WO5825djp0wodJGjCurTOmun0FUs/K+D6lzPdsDBYwqZqSACvMfc SyEvZvhXx4OzMxyZc2/S5rLX9gNkiBCxjUOO7v67XamkiQTXYa25zQsqiySDfvBLmlhV ToM20r0k2OaBtkZ0y9iGrN+MJjeVdZPHRzfVY9OjWR43sKPfX47Yqq3P9vRUUk+mfcfT bJZ5oZ25ILl+Av1ztMZhQY7UUSYzo8HxRy31ILNUZJ7+LRNqKokVmmvtKbJ01VN5GKez 9e1akJ2f3VU/kWr8qecE1jfJszmBgF+r1dK2KzthhVJktFe5B4kLxFbMJMoIs8fNKxy8 BRzA== 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 :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=HVY177p46LwKikltFBqeFa+//TGe4bFhKei2v7Ty1xY=; b=PFsdIFCWVPvlpoNViLihZEs4tPlGkJJD0ZU0K1MHDqYQzNLSPlW4y27gfCMeC07LqE NOJ4CUgaqHsEfRWiashF+xxMIvmG7EpbNs3yqJWZh3g21SwW7XIoxbo6uk/auZz4++Qe 0L/yQ2YJxLJ0EjGVRtuEwaOISndbqp0Q/ICuSI/xSEHfpVXQqoWHExWjx5M0PX1H2GHr ZNKCfAlDLa584SrAzWxA2XIY7eEXOOwcAowmbxva+i4ppD9lRGmVqHXO+2cN/rzXrV+q 4oVF+mcoa0VLFL3EulJM/SjaZcYyEvEE6KZT238vwXaaUkkKX8UYTVHQ37wmuAtRCRCl Z5zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="ZNK/fRZW"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id lf16-20020a170906ae5000b007a9e6f0f82fsi1943094ejb.516.2022.10.25.01.48.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 01:48:26 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="ZNK/fRZW"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 32D623857C63 for ; Tue, 25 Oct 2022 08:48:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 32D623857C63 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666687705; bh=HVY177p46LwKikltFBqeFa+//TGe4bFhKei2v7Ty1xY=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ZNK/fRZWcFp8T2S6cdQROpD1+LPfIcxu+Vd29iNJZahgkm05GsovdcYQ/TIh0xloQ U8u0sybLP9zzk+8rHe9t/hFKXiE2MpQ+fwK+grDtmkqwTGNir6JIiqpPYitWxqNd7w Zmf3uQQ9vfZGkcMS1+XrqyK7U1som0D4jEiwShoY= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id 46B1B3858406 for ; Tue, 25 Oct 2022 08:47:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 46B1B3858406 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-256-Be_aMyEYPi6RJzkzVWddyw-1; Tue, 25 Oct 2022 04:47:33 -0400 X-MC-Unique: Be_aMyEYPi6RJzkzVWddyw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4922E8027EB for ; Tue, 25 Oct 2022 08:47:33 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.193.252]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 09D6740C2140 for ; Tue, 25 Oct 2022 08:47:32 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 29P8lUfS710765 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT) for ; Tue, 25 Oct 2022 10:47:31 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 29P8lUaP710764 for gcc-patches@gcc.gnu.org; Tue, 25 Oct 2022 10:47:30 +0200 Date: Tue, 25 Oct 2022 10:47:29 +0200 To: gcc-patches@gcc.gnu.org Subject: [committed] gimplify: Don't add GIMPLE_ASSUME if errors were seen [PR107369] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP 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: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek 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?1747648728155502067?= X-GMAIL-MSGID: =?utf-8?q?1747648728155502067?= Hi! The FEs emit errors about jumps into assume attribute conditions, but when we add GIMPLE_ASSUME for the condition which is reachable through those jumps, we can run into cfg verification diagnostics. Fixed by throwing the IFN_ASSUME away during gimplification if seen_error () - like we already do for -O0. GIMPLE_ASSUME in the middle-end is a pure optimization thing and if errors were reported, the optimizations will not be beneficial for anything. Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk. 2022-10-25 Jakub Jelinek PR tree-optimization/107369 * gimplify.cc (gimplify_call_expr): If seen_error, handle complex IFN_ASSUME the same as for -O0. * gcc.dg/attr-assume-4.c: New test. * g++.dg/cpp23/attr-assume8.C: New test. Jakub --- gcc/gimplify.cc.jj 2022-10-18 10:38:48.146406234 +0200 +++ gcc/gimplify.cc 2022-10-24 10:22:08.590902730 +0200 @@ -3570,7 +3570,7 @@ gimplify_call_expr (tree *expr_p, gimple return GS_OK; } /* If not optimizing, ignore the assumptions. */ - if (!optimize) + if (!optimize || seen_error ()) { *expr_p = NULL_TREE; return GS_ALL_DONE; --- gcc/testsuite/gcc.dg/attr-assume-4.c.jj 2022-10-24 10:31:30.654197800 +0200 +++ gcc/testsuite/gcc.dg/attr-assume-4.c 2022-10-24 10:33:21.214682782 +0200 @@ -0,0 +1,12 @@ +/* PR tree-optimization/107369 */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -O1" } */ + +void +foo (int x) +{ + if (x == 1) + goto l1; /* { dg-error "jump into statement expression" } */ + + [[gnu::assume (({ l1:; 1; }))]]; /* { dg-message "label 'l1' defined here" } */ +} --- gcc/testsuite/g++.dg/cpp23/attr-assume8.C.jj 2022-10-24 10:48:35.550198403 +0200 +++ gcc/testsuite/g++.dg/cpp23/attr-assume8.C 2022-10-24 10:35:52.025616208 +0200 @@ -0,0 +1,12 @@ +// PR tree-optimization/107369 +// { dg-do compile { target c++11 } } +// { dg-options "-O1" } + +void +foo (int x) +{ + if (x == 1) + goto l1; // { dg-message "from here" } + + [[assume (({ l1:; 1; }))]]; // { dg-error "jump to label 'l1'" } +} // { dg-message "enters statement expression" "" { target *-*-* } .-1 }