From patchwork Mon Feb 10 09:57:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 106231 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6F3D73858CDA for ; Mon, 10 Feb 2025 09:58:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6F3D73858CDA Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=wZefKvV4; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=W9UwaoUw; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=wZefKvV4; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=W9UwaoUw X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id 20F283858D26; Mon, 10 Feb 2025 09:57:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 20F283858D26 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 20F283858D26 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1739181445; cv=none; b=EwLO7GTMg2DBSGHq4oanxW9ATP1wqPaiUwNYFFOofBloG+4YjNG+1coP9AuItU7EKiMs20qPLXSIrG36UFFL+isqHcLcOogLG5yo79wqsNDyHSrlj6OuYfcKIPMFD1hk+Joh4Rv94w/jeh572YIAjr7lZoRP/Sopra8JgV5bgMU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1739181445; c=relaxed/simple; bh=gR54eZiipy4tMqZIxodHHc693fPUpqkKx38rLYwWkq8=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=lBmzHk24GbcMcDrfNrAy4PmhPKYJmZIlvdwbafQU1f2ts83jThYnyAcOlud9z8AbjupsjbAnhAiqhMz3BRjlLG1bOTEyhncLtFb3DDj2WAaHm+qrW1UR5wnFsalPkzBycz1AODG1DdoKo3v1hm4Lty/KHnxGZ7MEtoxU9MePyg4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 20F283858D26 Received: from murzim.nue2.suse.org (unknown [10.168.4.243]) (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 smtp-out1.suse.de (Postfix) with ESMTPS id 185D5210EC; Mon, 10 Feb 2025 09:57:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1739181444; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=R6Cadhe1M3/VX/jbZabqBgsEFa4Booyuu2ycd8HV1s4=; b=wZefKvV4atSPuFJVkqC7LMxTxpb3Ir7ImBanoSGng1FYpwFsTy20deYODNnOo28mPvG471 N7HejFjv7X65zGBKr6KsxndDMTKiuo63A2W+iGM+Y6yUUrDXeRBnsP14qzjrNn7LW5k4Xd WZhzN6CHw+jwvcgWwxI3fwqCzItJdn4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1739181444; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=R6Cadhe1M3/VX/jbZabqBgsEFa4Booyuu2ycd8HV1s4=; b=W9UwaoUwI6FUeyGmH/vhCXXN/aagUhix4v/N6UA/9WubfilSIKRyyCZUV49NP1A+kB4ixV YnoY2Nv5lJsjypBA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1739181444; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=R6Cadhe1M3/VX/jbZabqBgsEFa4Booyuu2ycd8HV1s4=; b=wZefKvV4atSPuFJVkqC7LMxTxpb3Ir7ImBanoSGng1FYpwFsTy20deYODNnOo28mPvG471 N7HejFjv7X65zGBKr6KsxndDMTKiuo63A2W+iGM+Y6yUUrDXeRBnsP14qzjrNn7LW5k4Xd WZhzN6CHw+jwvcgWwxI3fwqCzItJdn4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1739181444; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=R6Cadhe1M3/VX/jbZabqBgsEFa4Booyuu2ycd8HV1s4=; b=W9UwaoUwI6FUeyGmH/vhCXXN/aagUhix4v/N6UA/9WubfilSIKRyyCZUV49NP1A+kB4ixV YnoY2Nv5lJsjypBA== Date: Mon, 10 Feb 2025 10:57:23 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: Jakub Jelinek , aoliva@gcc.gnu.org Subject: [PATCH] middle-end/118801 - excessive redundant DEBUG BEGIN_STMT MIME-Version: 1.0 X-Spam-Level: X-Spamd-Result: default: False [0.38 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MISSING_MID(2.50)[]; NEURAL_SPAM_SHORT(1.79)[0.596]; NEURAL_HAM_LONG(-0.80)[-0.805]; MIME_GOOD(-0.10)[text/plain]; ARC_NA(0.00)[]; MISSING_XM_UA(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_ZERO(0.00)[0]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCPT_COUNT_THREE(0.00)[3] X-Spam-Score: 0.38 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, SPF_HELO_NONE, SPF_PASS, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org Message-Id: <20250210095816.6F3D73858CDA@sourceware.org> The following addresses the fact that we keep an excessive amount of redundant DEBUG BEGIN_STMTs - in the testcase it sums up to 99.999% of all stmts, sucking up compile-time in IL walks. The patch amends the GIMPLE DCE code that elides redundant DEBUG BIND stmts, also pruning uninterrupted sequences of DEBUG BEGIN_STMTs, keeping only the last one. Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. For the testcase this brings down compile-time to 150% of -g0 levels (and only 215 out of originally 1981380 DEBUG BEGIN_STMTs kept). OK for trunk and possibly backports? There's the open question of whether a mix of (redundant) DEBUG BIND and BEGIN_STMT could be pruned and how, or whether a DEBUG BEGIN_STMT without any following other DEBUG stmt but followed by a real stmt with location is meaningful at all. Thanks, Richard. PR middle-end/118801 * tree-ssa-dce.cc (eliminate_unnecessary_stmts): Prune sequences of uninterrupted DEBUG BEGIN_STMTs, keeping only the last. --- gcc/tree-ssa-dce.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gcc/tree-ssa-dce.cc b/gcc/tree-ssa-dce.cc index be21a2d0b50..064e47cbf23 100644 --- a/gcc/tree-ssa-dce.cc +++ b/gcc/tree-ssa-dce.cc @@ -1508,6 +1508,7 @@ eliminate_unnecessary_stmts (bool aggressive) /* Remove dead statements. */ auto_bitmap debug_seen; + bool debug_begin_seen = false; for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi); gsi = psi) { stmt = gsi_stmt (gsi); @@ -1670,6 +1671,16 @@ eliminate_unnecessary_stmts (bool aggressive) remove_dead_stmt (&gsi, bb, to_remove_edges); continue; } + else if (gimple_debug_begin_stmt_p (stmt)) + { + /* We are only keeping the last debug-begin in a series of + debug-begin stmts. */ + if (debug_begin_seen) + remove_dead_stmt (&gsi, bb, to_remove_edges); + debug_begin_seen = true; + continue; + } + debug_begin_seen = false; bitmap_clear (debug_seen); }