From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666687656; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type; bh=HVY177p46LwKikltFBqeFa+//TGe4bFhKei2v7Ty1xY=; b=flgAuq0HWq+LI6ZYZClsFZDZ1FWxJh0hYnHfl4wDgONRZ1806ZD3JuUUJldVFGSaqZblAS FSUfXvC2ypDC/BGaiPJsv1ocbRd66io2Da+7fNyE8+1YnJydObOk4z+ESCZCzTgoZiaam0 sOp23t9evxhCFE901NBva12XPNTgB2Y= 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 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] gimplify: Don't add GIMPLE_ASSUME if errors were seen [PR107369] Message-ID: Reply-To: Jakub Jelinek 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-Type: text/plain; charset=us-ascii 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 List-Id: 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. --- 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 } Jakub