From patchwork Wed Apr 20 17:14:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1619672 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=e/lEaOR+; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4Kk6jr28XXz9sFx for ; Thu, 21 Apr 2022 03:14:54 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 58DBE3857C50 for ; Wed, 20 Apr 2022 17:14:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 58DBE3857C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1650474892; bh=iDopdCh8C0ZJXiV2Pvl4XyqSmYjfUHYr2n+Xm3PJW3M=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=e/lEaOR+NIk6Tvt/FETjsaA4b0l1fxE9/E3UgJsc/lWN9yVwvbbrX2ZPL23AzbKDR 7EANXeTdp88NKnTjhWnM9kMfCI5RpU86AIDD6ObG5Ek4qwzfZ2665pCrzUW32AMUju E4vtjyXNcz1fY6szdLPVdSfsxOZ8h5wrfH+4f5NI= 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 E443A3858D1E for ; Wed, 20 Apr 2022 17:14:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E443A3858D1E 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-450--XZchl_5OzOyO35vjNdeLQ-1; Wed, 20 Apr 2022 13:14:28 -0400 X-MC-Unique: -XZchl_5OzOyO35vjNdeLQ-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 C255D1C05144; Wed, 20 Apr 2022 17:14:27 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.52]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7BDA840CFD0A; Wed, 20 Apr 2022 17:14:27 +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 23KHEO0g2413663 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 20 Apr 2022 19:14:25 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 23KHENDc2413662; Wed, 20 Apr 2022 19:14:23 +0200 Date: Wed, 20 Apr 2022 19:14:23 +0200 To: Richard Biener , Jeff Law , Alexandre Oliva Subject: [PATCH] opts: Disable -gstatement-frontiers by default [PR103788] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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! As mentioned in those PRs and I think in others too, there are some long time unresolved -fcompare-debug issues with DEBUG_BEGIN_STMTs in the FEs and during gimplification, especially with statement expressions, where we end up with different code generation depending on whether there are DEBUG_BEGIN_STMTs (which force STATEMENT_LISTs) or not (in that case we often have just the single expression from the list). I've tried to fix that several times, but nothing worked. Furthermore, Alex mentioned in bugzilla that there are no consumers of the statement frontiers right now. This patch turns -gstatement-frontiers off by default because of those 2 reasons, consumers for those can still be added (one can test with explicit -gstatement-frontiers) and if/once that happens, perhaps somebody will have some great idea how to resolve those -fcompare-debug issues. Until then, can we go with this? Bootstrapped/regtested on powerpc64le-linux, ok for trunk if it also passes bootstrap/regtest on x86_64-linux/i686-linux? 2022-04-20 Jakub Jelinek PR debug/103788 PR middle-end/100733 PR debug/104180 * opts.cc (finish_options): Disable -gstatement-frontiers by default. * gcc.dg/pr103788.c: New test. * c-c++-common/ubsan/pr100733.c: New test. * g++.dg/debug/pr104180.C: New test. Jakub --- gcc/opts.cc.jj 2022-04-06 17:42:03.084190238 +0200 +++ gcc/opts.cc 2022-04-20 13:12:22.282322920 +0200 @@ -1317,12 +1317,16 @@ finish_options (struct gcc_options *opts debug_info_level = DINFO_LEVEL_NONE; } + /* Don't enable -gstatement-frontiers by default until some consumers + actually consume it and until the issues with DEBUG_BEGIN_STMTs + affecting code generation e.g. for statement expressions are resolved. + See PR103788, PR104180, PR100733. if (!OPTION_SET_P (debug_nonbind_markers_p)) debug_nonbind_markers_p = (optimize && debug_info_level >= DINFO_LEVEL_NORMAL && dwarf_debuginfo_p () - && !(flag_selective_scheduling || flag_selective_scheduling2)); + && !(flag_selective_scheduling || flag_selective_scheduling2)); */ /* Note -fvar-tracking is enabled automatically with OPT_LEVELS_1_PLUS and so we need to drop it if we are called from optimize attribute. */ --- gcc/testsuite/gcc.dg/pr103788.c.jj 2022-04-20 13:13:47.253141338 +0200 +++ gcc/testsuite/gcc.dg/pr103788.c 2022-04-20 13:13:29.301390970 +0200 @@ -0,0 +1,28 @@ +/* PR debug/103788 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fcompare-debug" } */ + +int +bar (void); + +int +foo (int x) +{ + int i; + + for (i = 0; i <= __INT_MAX__; ++i) + x += bar () < (x ? 2 : 1); + + return x; +} + +int +baz (int x) +{ + int i; + + for (i = 0; i <= __INT_MAX__; ++i) + x += bar () < ( + x ? 2 : 1 ); + return x; +} --- gcc/testsuite/c-c++-common/ubsan/pr100733.c.jj 2022-04-20 13:18:09.135499667 +0200 +++ gcc/testsuite/c-c++-common/ubsan/pr100733.c 2022-04-20 13:18:43.031028328 +0200 @@ -0,0 +1,9 @@ +/* PR middle-end/100733 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fsanitize=undefined -fcompare-debug -fdisable-tree-phiopt2" } */ + +int +foo (int x) +{ + return (__builtin_expect (({ x != 0; }) ? 0 : 1, 3) == 0) * -1 << 0; +} --- gcc/testsuite/g++.dg/debug/pr104180.C.jj 2022-04-20 13:14:51.468248383 +0200 +++ gcc/testsuite/g++.dg/debug/pr104180.C 2022-04-20 13:15:17.856881425 +0200 @@ -0,0 +1,14 @@ +/* PR debug/104180 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fcompare-debug" } */ + +int a[5]; + +void +foo (void) +{ + unsigned int b; + + for (b = 3; ; b--) + a[b] = ({ a[b + 1]; }); +}