Message ID | 20230323203507.2960052-1-jason@redhat.com |
---|---|
State | Accepted |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp3121884wrt; Thu, 23 Mar 2023 13:36:35 -0700 (PDT) X-Google-Smtp-Source: AKy350ZXDPEoN9Dc6YXMcYmmcjx0iXhJroimTdztWdcqN7d1BXfAYaOdu9S1tvetQFt8KwHbBeH+ X-Received: by 2002:aa7:d50e:0:b0:502:1cd3:d0fb with SMTP id y14-20020aa7d50e000000b005021cd3d0fbmr704541edq.20.1679603795493; Thu, 23 Mar 2023 13:36:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679603795; cv=none; d=google.com; s=arc-20160816; b=XQlbrHi5P66FpflOu+HzInjrvu4ntOhs/wVmfNRhGKdPPrzV3WGfiq/wXRFJ4YpPoA RlgiQmz2p6mG/y8MzWFMo6x+6UjyttD+lO2WfnGyrFYVGUZZ7zuWepMJ3NTjLMzwA6lN mWTbVj8VFBNwUc6yStW0BFedsAD2HR7rfI5shlxNLLUgBxdiaXIvYA/lWqjOdg5tJXiE 0hhiW9VbiKLY3jX7wgkeOhq0dHMAdbJFX4KR9p0Yrmm+JthF7W/EeNaxAW7XGQRDMhXH TmCgbg1rqoSuyXbq5BtadNqU6zO+JqGU/0km/VSfiBzpCMrbyU46lsdBAIpcugAt7M6y 7SoQ== 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-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=iRG0GFW4ve530Oyd0ikM8rVAdLjjdcAe+FjXU4WL87c=; b=a8QZeMt3K3hlpdd1Govxn8pnGXAz3EcaXXbsoJNqWK4ivYN5dO/+GvC15ahKgOMB7o s9+x7KHbrcn3YSFNxnqd98bN3YlyEIIBAb6f1gTY4vJYDk+CWDSrOafNq7evw2Or++nj f/+HXsEg7bi3Nd1/p/357yXKY3Wk+HQa6iEdPWJ1YVwKhJMFnGFM/bxv3FTjjIZiB09+ LCNEOZK14d0C0Uti7ISG+QNcHL14PI7yCYCofMQKSQ8HFUhv9ZqEItwCAAiw7mYwvtxz 7XIoiTA4NOt0MqfsqQ58lZjKHKD9GTJBRyqr1Lu73DspBcjB+/zy8xwlpTK/ip4CfQca 2RHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=BUHIWr6h; 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 r9-20020aa7d589000000b004fd23c65267si20593403edq.569.2023.03.23.13.36.35 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Mar 2023 13:36:35 -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=BUHIWr6h; 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 3A7203858C50 for <ouuuleilei@gmail.com>; Thu, 23 Mar 2023 20:36:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3A7203858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679603794; bh=iRG0GFW4ve530Oyd0ikM8rVAdLjjdcAe+FjXU4WL87c=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=BUHIWr6hk4lIz6K6atXJRQU/IUCTpmmDw1flcZPixTCnLcdKTSL1w0H/Y5tbU1Izi ugzJXRcdlCMtUUucGN1Iqc9zEiCYrWCivCcelGE18rZF9qTNEBBpiRgsmMX3tDfR0J irCdTNm7H6sXXLddZXuSOd4P/5T7928xZga7OvOw= 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 3A6053858C50 for <gcc-patches@gcc.gnu.org>; Thu, 23 Mar 2023 20:35:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3A6053858C50 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-675-VH9N7dw9MAeT6Jck7O7EkA-1; Thu, 23 Mar 2023 16:35:18 -0400 X-MC-Unique: VH9N7dw9MAeT6Jck7O7EkA-1 Received: by mail-qv1-f69.google.com with SMTP id a10-20020a0ccdca000000b005d70160fbb0so3275010qvn.21 for <gcc-patches@gcc.gnu.org>; Thu, 23 Mar 2023 13:35:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679603711; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=iRG0GFW4ve530Oyd0ikM8rVAdLjjdcAe+FjXU4WL87c=; b=0xbi9PW/np1L3B0hv2hRBiq0b3j8kK99CJL1ikPucrlYj4oI7EIq1tyGMQ6KHbDaSA EcJrcJfoIN5T18cECAJ9B/A+mC7KwTAez24wHXizihUuyTjaJkfQ7uNq0cAxBvL39ovZ XMCrnQAFRs2pFvHu1+266q1ZrqbZk8vI0w/6Gj14+s35eysPChSbwk91Zw3/50QM3RlR MQI/qolNM4X0/oaFGkWnbC4b1bJ9qMO7JFXTGZ78W0jbSbBVyCyjDejUsfGiz/R0hK1Z pnaD6355x79xzc4z7ale0vN958OfsFcXdp+VzgcoVXGbCoKbGLUeHsCM4JSSmx/nQfKr RQ/A== X-Gm-Message-State: AAQBX9cyJCtvuw7FrgrgpS58bgiSluUx99poAyJ6BBRnUUFEHlbIPAAp WTeqNHCnmR48eDNOVS/2kxPLhWbTlMxIGVSy6OcfE6UO9KwBSNkw2ZWSqTa0jmArF8ypRs/TIvo FUV6KyvV+SA7b3ev9RAt47oERdv2xfIdNF/K4LboM29cQuFjHnEbdxLgab9iiOl5NbFs5dn2CjQ == X-Received: by 2002:a05:6214:27c6:b0:5cd:f9fd:f66a with SMTP id ge6-20020a05621427c600b005cdf9fdf66amr530974qvb.0.1679603710872; Thu, 23 Mar 2023 13:35:10 -0700 (PDT) X-Received: by 2002:a05:6214:27c6:b0:5cd:f9fd:f66a with SMTP id ge6-20020a05621427c600b005cdf9fdf66amr530927qvb.0.1679603710451; Thu, 23 Mar 2023 13:35:10 -0700 (PDT) Received: from jason.cygnus.com (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id h26-20020ac846da000000b003bfb5fd72a7sm12188273qto.86.2023.03.23.13.35.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Mar 2023 13:35:10 -0700 (PDT) To: gcc-patches@gcc.gnu.org, Jakub Jelinek <jakub@redhat.com> Subject: [PATCH RFC] c-family: -Wsequence-point and COMPONENT_REF [PR107163] Date: Thu, 23 Mar 2023 16:35:07 -0400 Message-Id: <20230323203507.2960052-1-jason@redhat.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Jason Merrill via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Jason Merrill <jason@redhat.com> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761192229521862560?= X-GMAIL-MSGID: =?utf-8?q?1761192229521862560?= |
Series |
[RFC] c-family: -Wsequence-point and COMPONENT_REF [PR107163]
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | success | Github commit url |
Commit Message
Jason Merrill
March 23, 2023, 8:35 p.m. UTC
Tested x86_64-pc-linux-gnu. Jakub, does this make sense to you? Do we have a way of testing for compile-hog regressions? -- 8< -- The patch for PR91415 fixed -Wsequence-point to treat shifts and ARRAY_REF as sequenced in C++17, and COMPONENT_REF as well. But this is unnecessary for COMPONENT_REF, since the RHS is just a FIELD_DECL with no actual evaluation, and in this testcase handling COMPONENT_REF as sequenced blows up fast in a deep inheritance tree. PR c++/107163 gcc/c-family/ChangeLog: * c-common.cc (verify_tree): Don't use sequenced handling for COMPONENT_REF. --- gcc/c-family/c-common.cc | 1 - 1 file changed, 1 deletion(-) base-commit: 4872e46e080c6695dfe1f9dc9db26b4703bc348c
Comments
On Thu, Mar 23, 2023 at 04:35:07PM -0400, Jason Merrill wrote: > Tested x86_64-pc-linux-gnu. Jakub, does this make sense to you? Do we have a > way of testing for compile-hog regressions? > > -- 8< -- > > The patch for PR91415 fixed -Wsequence-point to treat shifts and ARRAY_REF > as sequenced in C++17, and COMPONENT_REF as well. But this is unnecessary > for COMPONENT_REF, since the RHS is just a FIELD_DECL with no actual > evaluation, and in this testcase handling COMPONENT_REF as sequenced blows > up fast in a deep inheritance tree. > > PR c++/107163 > > gcc/c-family/ChangeLog: > > * c-common.cc (verify_tree): Don't use sequenced handling > for COMPONENT_REF. When we touch this for COMPONENT_REF, shouldn't we then handle it as unary given that the second operand is FIELD_DECL and third/fourth will likely be NULL and even if not, aren't user expressions that should be inspected? So, instead of doing this do: case COMPONENT_REF: x = TREE_OPERAND (x, 0); writer = 0; goto restart; ? As for compile-hog, depends on how long it will take it to compile before fix/after fix. If before fix can be above the normal timeout on reasonably fast matchines and after fix can take a few seconds, great, if after fix would take longer but still not horribly long, one way to do it is guard the test with run_expensive_tests effective target. Or another way is have the test smaller in complexity normally and // { dg-additional-options "-DEXPENSIVE" { target run_expensive_tests } } and #ifdef EXPENSIVE make it more complex. Jakub
On 3/23/23 17:03, Jakub Jelinek wrote: > On Thu, Mar 23, 2023 at 04:35:07PM -0400, Jason Merrill wrote: >> Tested x86_64-pc-linux-gnu. Jakub, does this make sense to you? Do we have a >> way of testing for compile-hog regressions? >> >> -- 8< -- >> >> The patch for PR91415 fixed -Wsequence-point to treat shifts and ARRAY_REF >> as sequenced in C++17, and COMPONENT_REF as well. But this is unnecessary >> for COMPONENT_REF, since the RHS is just a FIELD_DECL with no actual >> evaluation, and in this testcase handling COMPONENT_REF as sequenced blows >> up fast in a deep inheritance tree. >> >> PR c++/107163 >> >> gcc/c-family/ChangeLog: >> >> * c-common.cc (verify_tree): Don't use sequenced handling >> for COMPONENT_REF. > > When we touch this for COMPONENT_REF, shouldn't we then handle it as > unary given that the second operand is FIELD_DECL and third/fourth > will likely be NULL and even if not, aren't user expressions that should be > inspected? > So, instead of doing this do: > case COMPONENT_REF: > x = TREE_OPERAND (x, 0); > writer = 0; > goto restart; > ? Is clearing 'writer' what we want, since an access to COMPONENT_REF is an access to (a subobject of) its op0? > As for compile-hog, depends on how long it will take it to compile before > fix/after fix. If before fix can be above the normal timeout on reasonably > fast matchines and after fix can take a few seconds, great Currently with the fix it takes <1s while gcc12 takes ~80s. > if after fix > would take longer but still not horribly long, one way to do it is > guard the test with run_expensive_tests effective target. Or another way > is have the test smaller in complexity normally and > // { dg-additional-options "-DEXPENSIVE" { target run_expensive_tests } } > and #ifdef EXPENSIVE make it more complex. Curiously, making the recursion much deeper doesn't work for that; I guess at some point the -Wsequence-point code decides the expression is too complex and gives up? But repeating the assignment brings it up over the timeout. How about this?
On Fri, Mar 24, 2023 at 06:11:44PM -0400, Jason Merrill wrote: > > When we touch this for COMPONENT_REF, shouldn't we then handle it as > > unary given that the second operand is FIELD_DECL and third/fourth > > will likely be NULL and even if not, aren't user expressions that should be > > inspected? > > So, instead of doing this do: > > case COMPONENT_REF: > > x = TREE_OPERAND (x, 0); > > writer = 0; > > goto restart; > > ? > > Is clearing 'writer' what we want, since an access to COMPONENT_REF is an > access to (a subobject of) its op0? I've just mindlessly copied the unary op case. writer is set for pre/post increments and lhs of MODIFY_EXPR, and it is true that VIEW_CONVERT_EXPR doesn't clear it, but e.g. ARRAY_REF clears it for all operands. > Currently with the fix it takes <1s while gcc12 takes ~80s. Perfect. > PR c++/107163 > > gcc/c-family/ChangeLog: > > * c-common.cc (verify_tree): Don't use sequenced handling > for COMPONENT_REF. > > gcc/testsuite/ChangeLog: > > * g++.dg/template/recurse5.C: New test. LGTM, thanks. Maybe the testcase would be better as warn/Wsequence-point-5.C, dunno. Jakub
On 3/24/23 18:25, Jakub Jelinek wrote: > On Fri, Mar 24, 2023 at 06:11:44PM -0400, Jason Merrill wrote: >>> When we touch this for COMPONENT_REF, shouldn't we then handle it as >>> unary given that the second operand is FIELD_DECL and third/fourth >>> will likely be NULL and even if not, aren't user expressions that should be >>> inspected? >>> So, instead of doing this do: >>> case COMPONENT_REF: >>> x = TREE_OPERAND (x, 0); >>> writer = 0; >>> goto restart; >>> ? >> >> Is clearing 'writer' what we want, since an access to COMPONENT_REF is an >> access to (a subobject of) its op0? > > I've just mindlessly copied the unary op case. > writer is set for pre/post increments and lhs of MODIFY_EXPR, and it is > true that VIEW_CONVERT_EXPR doesn't clear it, but e.g. ARRAY_REF clears it > for all operands. For whatever reason leaving writer set led to lots of false positives, so I've gone with your suggestion. >> Currently with the fix it takes <1s while gcc12 takes ~80s. > > Perfect. > >> PR c++/107163 >> >> gcc/c-family/ChangeLog: >> >> * c-common.cc (verify_tree): Don't use sequenced handling >> for COMPONENT_REF. >> >> gcc/testsuite/ChangeLog: >> >> * g++.dg/template/recurse5.C: New test. > > LGTM, thanks. Maybe the testcase would be better as > warn/Wsequence-point-5.C, dunno. Done. Jason
diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc index bfb950e56db..a803cf94c68 100644 --- a/gcc/c-family/c-common.cc +++ b/gcc/c-family/c-common.cc @@ -2154,7 +2154,6 @@ verify_tree (tree x, struct tlist **pbefore_sp, struct tlist **pno_sp, case LSHIFT_EXPR: case RSHIFT_EXPR: - case COMPONENT_REF: case ARRAY_REF: if (cxx_dialect >= cxx17) goto sequenced_binary;