From patchwork Sat Mar 5 08:08:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 51597 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 75F683858019 for ; Sat, 5 Mar 2022 08:08:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 75F683858019 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1646467729; bh=22RgGR2FLVDMuceoz0zJVfXfX3Lz0o+21aqfw57MI3A=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=gaSMgFbuMXxwu4wJtTQxk9+94k66mRxXTSfuYkaYv+MatzrzwXnbg6x0cLFliYok+ 8LqI1mOpLVXMYDsoV+W5zG7wTsDF9qyvdaXwgGsGaJjVH6Q7wbIHwBlhbpA3AZmzak iWaaVFBIxl9xmM/rh8+PKsIHCN4nurDH87/DWnbM= 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 99C223858D1E for ; Sat, 5 Mar 2022 08:08:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 99C223858D1E Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-590-7S9Qg1xCP-61_pFecb7yjw-1; Sat, 05 Mar 2022 03:08:18 -0500 X-MC-Unique: 7S9Qg1xCP-61_pFecb7yjw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 78587180A08B; Sat, 5 Mar 2022 08:08:17 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.81]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2379D5E279; Sat, 5 Mar 2022 08:08:16 +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 22588EWD2772052 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 5 Mar 2022 09:08:14 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 22588Da02772051; Sat, 5 Mar 2022 09:08:13 +0100 Date: Sat, 5 Mar 2022 09:08:13 +0100 To: Richard Biener , Jeff Law Subject: [PATCH] waccess: Remove visited bitmap and stop on EDGE_ABNORMAL Message-ID: References: <3a1b2fc6-a21a-14e4-c34f-b8b0c311d35f@gmail.com> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-5.3 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, Martin Sebor Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" On Fri, Mar 04, 2022 at 02:58:37PM +0100, Jakub Jelinek via Gcc-patches wrote: > On Thu, Mar 03, 2022 at 05:08:30PM -0700, Martin Sebor wrote: > > > 1) shouldn't it give up for EDGE_ABNORMAL too? I mean, e.g. > > > following a non-local goto forced edge from a noreturn call > > > to a non-local label (if there is just one) doesn't seem > > > right to me > > > > Possibly yes. I can add it but I don't have a lot of experience with > > these bits so if you can suggest a test case to exercise this that > > would be helpful. > > Something like: > void > foo (void) > { > __label__ l; > __attribute__((noreturn)) void bar (int x) { if (x) goto l; __builtin_trap (); } > bar (0); > l:; > } > shows a single EDGE_ABNORMAL from the bar call. > But it would need tweaking for the ptr use and clobber. > > > > 2) if EDGE_DFS_BACK is computed and 1) is done, is there any > > > reason why you need 2 levels of protection, i.e. the EDGE_DFS_BACK > > > check as well as the visited bitmap (and having them use > > > very different answers, if EDGE_DFS_BACK is seen, the function > > > will return false, if visited bitmap has a bb, it will return true)? > > > Can't the visited bitmap go away? > > > > Possibly. As I said above, I don't have enough experience with these > > bits to make (and test) the changes quickly, or enough bandwidth to > > come up to speed on them. Please feel free to make these improvements. > > I'll change that if it passes testing. Here is a patch to do both. I don't think we really need to have a testcase for the EDGE_ABNORMAL case (Martin, feel free to add it later), abnormal edges simply aren't normal control flow and what exactly it means varies. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2022-03-05 Jakub Jelinek * gimple-ssa-warn-access.cc (pass_waccess::use_after_inval_p): Remove visited bitmap and its use. Also punt on EDGE_ABNORMAL edges. Jakub --- gcc/gimple-ssa-warn-access.cc.jj 2022-03-03 22:09:22.073800776 +0100 +++ gcc/gimple-ssa-warn-access.cc 2022-03-04 19:21:18.840416075 +0100 @@ -3812,20 +3812,15 @@ pass_waccess::use_after_inval_p (gimple /* Proceed only when looking for uses of dangling pointers. */ auto gsi = gsi_for_stmt (use_stmt); - auto_bitmap visited; - /* A use statement in the last basic block in a function or one that falls through to it is after any other prior clobber of the used variable unless it's followed by a clobber of the same variable. */ basic_block bb = use_bb; while (bb != inval_bb && single_succ_p (bb) - && !(single_succ_edge (bb)->flags & (EDGE_EH|EDGE_DFS_BACK))) + && !(single_succ_edge (bb)->flags + & (EDGE_EH | EDGE_ABNORMAL | EDGE_DFS_BACK))) { - if (!bitmap_set_bit (visited, bb->index)) - /* Avoid cycles. */ - return true; - for (; !gsi_end_p (gsi); gsi_next_nondebug (&gsi)) { gimple *stmt = gsi_stmt (gsi);