From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id CA3AB3858D1E; Sat, 5 Mar 2022 11:22:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CA3AB3858D1E MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-7503] waccess: Remove visited bitmap and stop on EDGE_ABNORMAL X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/master X-Git-Oldrev: 8ea4a34bd0b0a46277b5e077c89cbd86dfb09c48 X-Git-Newrev: dab41c9d9fabe86bdc65d97ba1c1e898488d4810 Message-Id: <20220305112211.CA3AB3858D1E@sourceware.org> Date: Sat, 5 Mar 2022 11:22:11 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Mar 2022 11:22:11 -0000 https://gcc.gnu.org/g:dab41c9d9fabe86bdc65d97ba1c1e898488d4810 commit r12-7503-gdab41c9d9fabe86bdc65d97ba1c1e898488d4810 Author: Jakub Jelinek Date: Sat Mar 5 12:20:47 2022 +0100 waccess: Remove visited bitmap and stop on EDGE_ABNORMAL 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. 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. Diff: --- gcc/gimple-ssa-warn-access.cc | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/gcc/gimple-ssa-warn-access.cc b/gcc/gimple-ssa-warn-access.cc index b519712d76e..b5f9e4c2f9e 100644 --- a/gcc/gimple-ssa-warn-access.cc +++ b/gcc/gimple-ssa-warn-access.cc @@ -3812,20 +3812,15 @@ pass_waccess::use_after_inval_p (gimple *inval_stmt, gimple *use_stmt, /* 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);