From patchwork Mon Nov 8 15:19:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 47215 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 8A15E385843F for ; Mon, 8 Nov 2021 15:20:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8A15E385843F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1636384801; bh=+31RyVJW1zYCN6t0nvOXxrbO1+m8EyjE7ppRU+3Ybjw=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ytFo3SJlDRhhj8w1xXM8Ku8UDsAUB0OMe99GOR6amYmzJxXWd1HemFZ4p8d3aFGwz CzM/IkXOasd5Q3kp1iR1MA7nvfMlx+B4gX5Wn/sqKvZh1QM7CszajdCIKy3dNWXDam O3WHIAbfd1RN6dT85EJdHD0XvWz7KjLvQFQf5jK4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 6B62F3858C2C for ; Mon, 8 Nov 2021 15:19:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6B62F3858C2C Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 312AE1FDB8 for ; Mon, 8 Nov 2021 15:19:30 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 1D29113BA7 for ; Mon, 8 Nov 2021 15:19:30 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id GAD9BQJAiWHYQgAAMHmgww (envelope-from ) for ; Mon, 08 Nov 2021 15:19:30 +0000 Date: Mon, 8 Nov 2021 16:19:29 +0100 (CET) To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix spurious valgrind errors in irred loop verification Message-ID: <47pqo19-nss9-p6s3-5qs6-73811p7553@fhfr.qr> MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP 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: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" The sbitmap bitmap_{set,clear}_bit changes trigger spurious uninit value use reportings from valgrind since we now read the old value before setting/clearing a bit so verify_loop_structures optimization to not clear the sbitmap is reported. Fixed by using a temporary BB flag which should also be more efficient in terms of cache re-use. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. 2021-11-08 Richard Biener * cfgloop.c (verify_loop_structure): Use a temporary BB flag instead of an sbitmap to cache irreducible state. --- gcc/cfgloop.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c index 2ba9918bfa2..20c24c13c36 100644 --- a/gcc/cfgloop.c +++ b/gcc/cfgloop.c @@ -1567,19 +1567,17 @@ verify_loop_structure (void) /* Check irreducible loops. */ if (loops_state_satisfies_p (LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS)) { - auto_edge_flag saved_irr_mask (cfun); - /* Record old info. */ - auto_sbitmap irreds (last_basic_block_for_fn (cfun)); + auto_edge_flag saved_edge_irr (cfun); + auto_bb_flag saved_bb_irr (cfun); + /* Save old info. */ FOR_EACH_BB_FN (bb, cfun) { edge_iterator ei; if (bb->flags & BB_IRREDUCIBLE_LOOP) - bitmap_set_bit (irreds, bb->index); - else - bitmap_clear_bit (irreds, bb->index); + bb->flags |= saved_bb_irr; FOR_EACH_EDGE (e, ei, bb->succs) if (e->flags & EDGE_IRREDUCIBLE_LOOP) - e->flags |= saved_irr_mask; + e->flags |= saved_edge_irr; } /* Recount it. */ @@ -1591,34 +1589,35 @@ verify_loop_structure (void) edge_iterator ei; if ((bb->flags & BB_IRREDUCIBLE_LOOP) - && !bitmap_bit_p (irreds, bb->index)) + && !(bb->flags & saved_bb_irr)) { error ("basic block %d should be marked irreducible", bb->index); err = 1; } else if (!(bb->flags & BB_IRREDUCIBLE_LOOP) - && bitmap_bit_p (irreds, bb->index)) + && (bb->flags & saved_bb_irr)) { error ("basic block %d should not be marked irreducible", bb->index); err = 1; } + bb->flags &= ~saved_bb_irr; FOR_EACH_EDGE (e, ei, bb->succs) { if ((e->flags & EDGE_IRREDUCIBLE_LOOP) - && !(e->flags & saved_irr_mask)) + && !(e->flags & saved_edge_irr)) { error ("edge from %d to %d should be marked irreducible", e->src->index, e->dest->index); err = 1; } else if (!(e->flags & EDGE_IRREDUCIBLE_LOOP) - && (e->flags & saved_irr_mask)) + && (e->flags & saved_edge_irr)) { error ("edge from %d to %d should not be marked irreducible", e->src->index, e->dest->index); err = 1; } - e->flags &= ~saved_irr_mask; + e->flags &= ~saved_edge_irr; } } }