From patchwork Tue Jul 11 16:36:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 1806467 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.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=aeKnvSLQ; dkim-atps=neutral Received: from server2.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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R0mjt2HMnz20WT for ; Wed, 12 Jul 2023 02:37:06 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 47D35385842A for ; Tue, 11 Jul 2023 16:37:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 47D35385842A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689093424; bh=H5/OMqRTsHCRmZ5Kdge6m+GG57BSIoWGFM0cOvr4zXw=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=aeKnvSLQpH+tS2NUgOF6r9Njn5MYUzWgrhkVFP0MtElGvE4+6zAY5CsOb/GFIzqZN xC8nRFpHkHrgtFkUVhEkGy3gNWR8F7qFMHRHz7qrhA8ZESHZNRufqrjZv8TxvAkd6R NGGm7GlsWCoVA/HX5l7Iuu2dHEYDYcDz6DUOKi2o= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by sourceware.org (Postfix) with ESMTPS id F2A173858D1E for ; Tue, 11 Jul 2023 16:36:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F2A173858D1E Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-51e5da802afso2535228a12.3 for ; Tue, 11 Jul 2023 09:36:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689093388; x=1691685388; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=H5/OMqRTsHCRmZ5Kdge6m+GG57BSIoWGFM0cOvr4zXw=; b=idPjjZLiNBRcad6A6Lbr4DpRSdj3ht53nQulVmA4uSuzYFuVnfO+m/kdY2IIDmTlYG 5Fm6wDUqq+Yo1wk9FB26Csuv0VwTa3HBrDC50JIQr/qZdYCRxFK/5KKbkG4SHVbBfJzF 4bmHmxdjTmK0pV2UL70gK1NSRSfIv1cdwsbmFLZC8+niT9yYw54bxscAxggJ5ugzI72w puHDo2sfR1iud9wtua4jo3ATynapN0b91jB8YyRX29Re+Qoz5FNvYJ0bUlGYCZ2ilikG iketBo9O5OJDP+SoSf07XqZq9uqRFj25GHFtNOewvNw321OXn9cWnNsic29XwbSLl2pO QYrg== X-Gm-Message-State: ABy/qLZ7QxbQWIM+DMsvVJD04ZidtYjHQQqfLhQapyVUYIEsPkCOWM2I 84OQeI01eIhVKPEOwtnIKFLe1JVt7iw7GMbTCyzN+Cr1wZfXSQ== X-Google-Smtp-Source: APBJJlG/4a2OQhYSHanWHa9TOjXyJAn9JCZD0NcGygeWQRDfU72Mmm3oel9nu1q6/jRdx929/Bl+XY0V/sEsNVCnHVg= X-Received: by 2002:a05:6402:1ac4:b0:51b:cee4:fc21 with SMTP id ba4-20020a0564021ac400b0051bcee4fc21mr15593092edb.39.1689093388219; Tue, 11 Jul 2023 09:36:28 -0700 (PDT) MIME-Version: 1.0 Date: Tue, 11 Jul 2023 18:36:16 +0200 Message-ID: Subject: [committed] cfg+gcse: Change return type of predicate functions from int to bool To: "gcc-patches@gcc.gnu.org" X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Uros Bizjak via Gcc-patches From: Uros Bizjak Reply-To: Uros Bizjak Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Also change some internal variables from int to bool. gcc/ChangeLog: * cfghooks.cc (verify_flow_info): Change "err" variable to bool. * cfghooks.h (struct cfg_hooks): Change return type of verify_flow_info from integer to bool. * cfgrtl.cc (can_delete_note_p): Change return type from int to bool. (can_delete_label_p): Ditto. (rtl_verify_flow_info): Change return type from int to bool and adjust function body accordingly. Change "err" variable to bool. (rtl_verify_flow_info_1): Ditto. (free_bb_for_insn): Change return type to void. (rtl_merge_blocks): Change "b_empty" variable to bool. (try_redirect_by_replacing_jump): Change "fallthru" variable to bool. (verify_hot_cold_block_grouping): Change return type from int to bool. Change "err" variable to bool. (rtl_verify_edges): Ditto. (rtl_verify_bb_insns): Ditto. (rtl_verify_bb_pointers): Ditto. (rtl_verify_bb_insn_chain): Ditto. (rtl_verify_fallthru): Ditto. (rtl_verify_bb_layout): Ditto. (purge_all_dead_edges): Change "purged" variable to bool. * cfgrtl.h (free_bb_for_insn): Change return type from int to void. * postreload-gcse.cc (expr_hasher::equal): Change "equiv_p" to bool. (load_killed_in_block_p): Change return type from int to bool and adjust function body accordingly. (oprs_unchanged_p): Return true/false. (rest_of_handle_gcse2): Change return type to void. * tree-cfg.cc (gimple_verify_flow_info): Change return type from int to bool. Change "err" variable to bool. Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}. Uros. diff --git a/gcc/cfghooks.cc b/gcc/cfghooks.cc index 54564035415..37e0dbc1a13 100644 --- a/gcc/cfghooks.cc +++ b/gcc/cfghooks.cc @@ -102,7 +102,7 @@ DEBUG_FUNCTION void verify_flow_info (void) { size_t *edge_checksum; - int err = 0; + bool err = false; basic_block bb, last_bb_seen; basic_block *last_visited; @@ -118,14 +118,14 @@ verify_flow_info (void) && bb != BASIC_BLOCK_FOR_FN (cfun, bb->index)) { error ("bb %d on wrong place", bb->index); - err = 1; + err = true; } if (bb->prev_bb != last_bb_seen) { error ("prev_bb of %d should be %d, not %d", bb->index, last_bb_seen->index, bb->prev_bb->index); - err = 1; + err = true; } last_bb_seen = bb; @@ -142,18 +142,18 @@ verify_flow_info (void) { error ("verify_flow_info: Block %i has loop_father, but there are no loops", bb->index); - err = 1; + err = true; } if (bb->loop_father == NULL && current_loops != NULL) { error ("verify_flow_info: Block %i lacks loop_father", bb->index); - err = 1; + err = true; } if (!bb->count.verify ()) { error ("verify_flow_info: Wrong count of block %i", bb->index); - err = 1; + err = true; } /* FIXME: Graphite and SLJL and target code still tends to produce edges with no probability. */ @@ -161,13 +161,13 @@ verify_flow_info (void) && !bb->count.initialized_p () && !flag_graphite && 0) { error ("verify_flow_info: Missing count of block %i", bb->index); - err = 1; + err = true; } if (bb->flags & ~cfun->cfg->bb_flags_allocated) { error ("verify_flow_info: unallocated flag set on BB %d", bb->index); - err = 1; + err = true; } FOR_EACH_EDGE (e, ei, bb->succs) @@ -176,7 +176,7 @@ verify_flow_info (void) { error ("verify_flow_info: Duplicate edge %i->%i", e->src->index, e->dest->index); - err = 1; + err = true; } /* FIXME: Graphite and SLJL and target code still tends to produce edges with no probability. */ @@ -185,13 +185,13 @@ verify_flow_info (void) { error ("Uninitialized probability of edge %i->%i", e->src->index, e->dest->index); - err = 1; + err = true; } if (!e->probability.verify ()) { error ("verify_flow_info: Wrong probability of edge %i->%i", e->src->index, e->dest->index); - err = 1; + err = true; } last_visited [e->dest->index] = bb; @@ -208,14 +208,14 @@ verify_flow_info (void) fprintf (stderr, "\nSuccessor: "); dump_edge_info (stderr, e, TDF_DETAILS, 1); fprintf (stderr, "\n"); - err = 1; + err = true; } if (e->flags & ~cfun->cfg->edge_flags_allocated) { error ("verify_flow_info: unallocated edge flag set on %d -> %d", e->src->index, e->dest->index); - err = 1; + err = true; } edge_checksum[e->dest->index] += (size_t) e; @@ -223,7 +223,7 @@ verify_flow_info (void) if (n_fallthru > 1) { error ("wrong amount of branch edges after unconditional jump %i", bb->index); - err = 1; + err = true; } FOR_EACH_EDGE (e, ei, bb->preds) @@ -236,7 +236,7 @@ verify_flow_info (void) fputs ("\nSuccessor: ", stderr); dump_edge_info (stderr, e, TDF_DETAILS, 1); fputc ('\n', stderr); - err = 1; + err = true; } if (ei.index != e->dest_idx) @@ -249,7 +249,7 @@ verify_flow_info (void) fputs ("\nSuccessor: ", stderr); dump_edge_info (stderr, e, TDF_DETAILS, 1); fputc ('\n', stderr); - err = 1; + err = true; } edge_checksum[e->dest->index] -= (size_t) e; @@ -272,7 +272,7 @@ verify_flow_info (void) if (edge_checksum[bb->index]) { error ("basic block %i edge lists are corrupted", bb->index); - err = 1; + err = true; } /* Clean up. */ @@ -280,7 +280,9 @@ verify_flow_info (void) free (edge_checksum); if (cfg_hooks->verify_flow_info) - err |= cfg_hooks->verify_flow_info (); + if (cfg_hooks->verify_flow_info ()) + err = true; + if (err) internal_error ("verify_flow_info failed"); timevar_pop (TV_CFG_VERIFY); diff --git a/gcc/cfghooks.h b/gcc/cfghooks.h index 7c87712c8d7..fe405ef8d1c 100644 --- a/gcc/cfghooks.h +++ b/gcc/cfghooks.h @@ -78,7 +78,7 @@ struct cfg_hooks const char *name; /* Debugging. */ - int (*verify_flow_info) (void); + bool (*verify_flow_info) (void); void (*dump_bb) (FILE *, basic_block, int, dump_flags_t); void (*dump_bb_for_graph) (pretty_printer *, basic_block); diff --git a/gcc/cfgrtl.cc b/gcc/cfgrtl.cc index 1d84b29ce61..36e43d0d737 100644 --- a/gcc/cfgrtl.cc +++ b/gcc/cfgrtl.cc @@ -83,11 +83,11 @@ static void fixup_reorder_chain (void); void verify_insn_chain (void); static void fixup_fallthru_exit_predecessor (void); -static int can_delete_note_p (const rtx_note *); -static int can_delete_label_p (const rtx_code_label *); +static bool can_delete_note_p (const rtx_note *); +static bool can_delete_label_p (const rtx_code_label *); static basic_block rtl_split_edge (edge); static bool rtl_move_block_after (basic_block, basic_block); -static int rtl_verify_flow_info (void); +static bool rtl_verify_flow_info (void); static basic_block cfg_layout_split_block (basic_block, void *); static edge cfg_layout_redirect_edge_and_branch (edge, basic_block); static basic_block cfg_layout_redirect_edge_and_branch_force (edge, basic_block); @@ -97,14 +97,14 @@ static basic_block rtl_redirect_edge_and_branch_force (edge, basic_block); static edge rtl_redirect_edge_and_branch (edge, basic_block); static basic_block rtl_split_block (basic_block, void *); static void rtl_dump_bb (FILE *, basic_block, int, dump_flags_t); -static int rtl_verify_flow_info_1 (void); +static bool rtl_verify_flow_info_1 (void); static void rtl_make_forwarder_block (edge); static bool rtl_bb_info_initialized_p (basic_block bb); /* Return true if NOTE is not one of the ones that must be kept paired, so that we may simply delete it. */ -static int +static bool can_delete_note_p (const rtx_note *note) { switch (NOTE_KIND (note)) @@ -121,7 +121,7 @@ can_delete_note_p (const rtx_note *note) /* True if a given label can be deleted. */ -static int +static bool can_delete_label_p (const rtx_code_label *label) { return (!LABEL_PRESERVE_P (label) @@ -450,14 +450,13 @@ compute_bb_for_insn (void) /* Release the basic_block_for_insn array. */ -unsigned int +void free_bb_for_insn (void) { rtx_insn *insn; for (insn = get_insns (); insn; insn = NEXT_INSN (insn)) if (!BARRIER_P (insn)) BLOCK_FOR_INSN (insn) = NULL; - return 0; } namespace { @@ -865,7 +864,7 @@ rtl_merge_blocks (basic_block a, basic_block b) rtx_insn *b_head = BB_HEAD (b), *b_end = BB_END (b), *a_end = BB_END (a); rtx_insn *del_first = NULL, *del_last = NULL; rtx_insn *b_debug_start = b_end, *b_debug_end = b_end; - int b_empty = 0; + bool b_empty = false; if (dump_file) fprintf (dump_file, "Merging block %d into block %d...\n", b->index, @@ -880,7 +879,7 @@ rtl_merge_blocks (basic_block a, basic_block b) /* Detect basic blocks with nothing but a label. This can happen in particular at the end of a function. */ if (b_head == b_end) - b_empty = 1; + b_empty = true; del_first = del_last = b_head; b_head = NEXT_INSN (b_head); @@ -891,7 +890,7 @@ rtl_merge_blocks (basic_block a, basic_block b) if (NOTE_INSN_BASIC_BLOCK_P (b_head)) { if (b_head == b_end) - b_empty = 1; + b_empty = true; if (! del_last) del_first = b_head; @@ -1056,7 +1055,7 @@ try_redirect_by_replacing_jump (edge e, basic_block target, bool in_cfglayout) basic_block src = e->src; rtx_insn *insn = BB_END (src); rtx set; - int fallthru = 0; + bool fallthru = false; /* If we are partitioning hot/cold basic blocks, we don't want to mess up unconditional or indirect jumps that cross between hot @@ -1096,7 +1095,7 @@ try_redirect_by_replacing_jump (edge e, basic_block target, bool in_cfglayout) { if (dump_file) fprintf (dump_file, "Removing jump %i.\n", INSN_UID (insn)); - fallthru = 1; + fallthru = true; /* Selectively unlink whole insn chain. */ if (in_cfglayout) @@ -2496,11 +2495,11 @@ fixup_partitions (void) between hot/cold partitions. This condition will not be true until after reorder_basic_blocks is called. */ -static int +static bool verify_hot_cold_block_grouping (void) { basic_block bb; - int err = 0; + bool err = false; bool switched_sections = false; int current_partition = BB_UNPARTITIONED; @@ -2520,7 +2519,7 @@ verify_hot_cold_block_grouping (void) { error ("multiple hot/cold transitions found (bb %i)", bb->index); - err = 1; + err = true; } else switched_sections = true; @@ -2541,10 +2540,10 @@ verify_hot_cold_block_grouping (void) successor edges. Also verify that the dominance relationship between hot/cold blocks is sane. */ -static int +static bool rtl_verify_edges (void) { - int err = 0; + bool err = false; basic_block bb; FOR_EACH_BB_REVERSE_FN (bb, cfun) @@ -2567,7 +2566,7 @@ rtl_verify_edges (void) { error ("verify_flow_info: " "REG_BR_PROB is set but cfg probability is not"); - err = 1; + err = true; } } else if (XINT (note, 0) @@ -2577,7 +2576,7 @@ rtl_verify_edges (void) error ("verify_flow_info: REG_BR_PROB does not match cfg %i %i", XINT (note, 0), BRANCH_EDGE (bb)->probability.to_reg_br_prob_note ()); - err = 1; + err = true; } } @@ -2597,31 +2596,31 @@ rtl_verify_edges (void) if (!is_crossing) { error ("EDGE_CROSSING incorrectly set across same section"); - err = 1; + err = true; } if (e->flags & EDGE_FALLTHRU) { error ("fallthru edge crosses section boundary in bb %i", e->src->index); - err = 1; + err = true; } if (e->flags & EDGE_EH) { error ("EH edge crosses section boundary in bb %i", e->src->index); - err = 1; + err = true; } if (JUMP_P (BB_END (bb)) && !CROSSING_JUMP_P (BB_END (bb))) { error ("No region crossing jump at section boundary in bb %i", bb->index); - err = 1; + err = true; } } else if (is_crossing) { error ("EDGE_CROSSING missing across section boundary"); - err = 1; + err = true; } if ((e->flags & ~(EDGE_DFS_BACK @@ -2652,18 +2651,18 @@ rtl_verify_edges (void) print_rtl_with_bb (stderr, get_insns (), TDF_BLOCKS | TDF_DETAILS); error ("Region crossing jump across same section in bb %i", bb->index); - err = 1; + err = true; } if (n_eh && !find_reg_note (BB_END (bb), REG_EH_REGION, NULL_RTX)) { error ("missing REG_EH_REGION note at the end of bb %i", bb->index); - err = 1; + err = true; } if (n_eh > 1) { error ("too many exception handling edges in bb %i", bb->index); - err = 1; + err = true; } if (n_branch && (!JUMP_P (BB_END (bb)) @@ -2671,35 +2670,35 @@ rtl_verify_edges (void) || any_condjump_p (BB_END (bb)))))) { error ("too many outgoing branch edges from bb %i", bb->index); - err = 1; + err = true; } if (n_fallthru && any_uncondjump_p (BB_END (bb))) { error ("fallthru edge after unconditional jump in bb %i", bb->index); - err = 1; + err = true; } if (n_branch != 1 && any_uncondjump_p (BB_END (bb))) { error ("wrong number of branch edges after unconditional jump" " in bb %i", bb->index); - err = 1; + err = true; } if (n_branch != 1 && any_condjump_p (BB_END (bb)) && JUMP_LABEL (BB_END (bb)) != BB_HEAD (fallthru->dest)) { error ("wrong amount of branch edges after conditional jump" " in bb %i", bb->index); - err = 1; + err = true; } if (n_abnormal_call && !CALL_P (BB_END (bb))) { error ("abnormal call edges for non-call insn in bb %i", bb->index); - err = 1; + err = true; } if (n_sibcall && !CALL_P (BB_END (bb))) { error ("sibcall edges for non-call insn in bb %i", bb->index); - err = 1; + err = true; } if (n_abnormal > n_eh && !(CALL_P (BB_END (bb)) @@ -2709,7 +2708,7 @@ rtl_verify_edges (void) || any_uncondjump_p (BB_END (bb)))) { error ("abnormal edges for no purpose in bb %i", bb->index); - err = 1; + err = true; } int has_eh = -1; @@ -2721,7 +2720,7 @@ rtl_verify_edges (void) continue; error ("EH incoming edge mixed with non-EH incoming edges " "in bb %i", bb->index); - err = 1; + err = true; break; } } @@ -2743,11 +2742,11 @@ rtl_verify_edges (void) block starts with a basic block note, and that basic block notes and control flow jumps are not found in the middle of the block. */ -static int +static bool rtl_verify_bb_insns (void) { rtx_insn *x; - int err = 0; + bool err = false; basic_block bb; FOR_EACH_BB_REVERSE_FN (bb, cfun) @@ -2762,7 +2761,7 @@ rtl_verify_bb_insns (void) { error ("NOTE_INSN_BASIC_BLOCK is missing for block %d", bb->index); - err = 1; + err = true; } x = NEXT_INSN (x); @@ -2772,7 +2771,7 @@ rtl_verify_bb_insns (void) { error ("NOTE_INSN_BASIC_BLOCK is missing for block %d", bb->index); - err = 1; + err = true; } if (BB_END (bb) == x) @@ -2785,7 +2784,7 @@ rtl_verify_bb_insns (void) { error ("NOTE_INSN_BASIC_BLOCK %d in middle of basic block %d", INSN_UID (x), bb->index); - err = 1; + err = true; } if (x == BB_END (bb)) @@ -2806,10 +2805,10 @@ rtl_verify_bb_insns (void) /* Verify that block pointers for instructions in basic blocks, headers and footers are set appropriately. */ -static int +static bool rtl_verify_bb_pointers (void) { - int err = 0; + bool err = false; basic_block bb; /* Check the general integrity of the basic blocks. */ @@ -2820,7 +2819,7 @@ rtl_verify_bb_pointers (void) if (!(bb->flags & BB_RTL)) { error ("BB_RTL flag not set for block %d", bb->index); - err = 1; + err = true; } FOR_BB_INSNS (bb, insn) @@ -2830,7 +2829,7 @@ rtl_verify_bb_pointers (void) INSN_UID (insn), BLOCK_FOR_INSN (insn) ? BLOCK_FOR_INSN (insn)->index : 0, bb->index); - err = 1; + err = true; } for (insn = BB_HEADER (bb); insn; insn = NEXT_INSN (insn)) @@ -2839,7 +2838,7 @@ rtl_verify_bb_pointers (void) { error ("insn %d in header of bb %d has non-NULL basic block", INSN_UID (insn), bb->index); - err = 1; + err = true; } for (insn = BB_FOOTER (bb); insn; insn = NEXT_INSN (insn)) if (!BARRIER_P (insn) @@ -2847,7 +2846,7 @@ rtl_verify_bb_pointers (void) { error ("insn %d in footer of bb %d has non-NULL basic block", INSN_UID (insn), bb->index); - err = 1; + err = true; } } @@ -2873,16 +2872,19 @@ rtl_verify_bb_pointers (void) In future it can be extended check a lot of other stuff as well (reachability of basic blocks, life information, etc. etc.). */ -static int +static bool rtl_verify_flow_info_1 (void) { - int err = 0; + bool err = false; - err |= rtl_verify_bb_pointers (); + if (rtl_verify_bb_pointers ()) + err = true; - err |= rtl_verify_bb_insns (); + if (rtl_verify_bb_insns ()) + err = true; - err |= rtl_verify_edges (); + if (rtl_verify_edges ()) + err = true; return err; } @@ -2891,11 +2893,11 @@ rtl_verify_flow_info_1 (void) are correct, and that instructions are in exactly one bb and have correct block pointers. */ -static int +static bool rtl_verify_bb_insn_chain (void) { basic_block bb; - int err = 0; + bool err = false; rtx_insn *x; rtx_insn *last_head = get_last_insn (); basic_block *bb_info; @@ -2920,7 +2922,7 @@ rtl_verify_bb_insn_chain (void) { error ("insn %d outside of basic blocks has non-NULL bb field", INSN_UID (x)); - err = 1; + err = true; } } @@ -2928,7 +2930,7 @@ rtl_verify_bb_insn_chain (void) { error ("end insn %d for block %d not found in the insn stream", INSN_UID (end), bb->index); - err = 1; + err = true; } /* Work backwards from the end to the head of the basic block @@ -2941,7 +2943,7 @@ rtl_verify_bb_insn_chain (void) { error ("insn %d is in multiple basic blocks (%d and %d)", INSN_UID (x), bb->index, bb_info[INSN_UID (x)]->index); - err = 1; + err = true; } bb_info[INSN_UID (x)] = bb; @@ -2953,7 +2955,7 @@ rtl_verify_bb_insn_chain (void) { error ("head insn %d for block %d not found in the insn stream", INSN_UID (head), bb->index); - err = 1; + err = true; } last_head = PREV_INSN (x); @@ -2968,7 +2970,7 @@ rtl_verify_bb_insn_chain (void) { error ("insn %d outside of basic blocks has non-NULL bb field", INSN_UID (x)); - err = 1; + err = true; } } free (bb_info); @@ -2979,11 +2981,11 @@ rtl_verify_bb_insn_chain (void) /* Verify that fallthru edges point to adjacent blocks in layout order and that barriers exist after non-fallthru blocks. */ -static int +static bool rtl_verify_fallthru (void) { basic_block bb; - int err = 0; + bool err = false; FOR_EACH_BB_REVERSE_FN (bb, cfun) { @@ -3000,7 +3002,7 @@ rtl_verify_fallthru (void) if (!insn || NOTE_INSN_BASIC_BLOCK_P (insn)) { error ("missing barrier after block %i", bb->index); - err = 1; + err = true; break; } if (BARRIER_P (insn)) @@ -3017,7 +3019,7 @@ rtl_verify_fallthru (void) error ("verify_flow_info: Incorrect blocks for fallthru %i->%i", e->src->index, e->dest->index); - err = 1; + err = true; } else for (insn = NEXT_INSN (BB_END (e->src)); insn != BB_HEAD (e->dest); @@ -3028,7 +3030,7 @@ rtl_verify_fallthru (void) e->src->index, e->dest->index); error ("wrong insn in the fallthru edge"); debug_rtx (insn); - err = 1; + err = true; } } } @@ -3040,11 +3042,11 @@ rtl_verify_fallthru (void) instructions, verify that all expected instructions are inside the basic blocks, and that all returns are followed by barriers. */ -static int +static bool rtl_verify_bb_layout (void) { basic_block bb; - int err = 0; + bool err = false; rtx_insn *x, *y; int num_bb_notes; rtx_insn * const rtx_first = get_insns (); @@ -3118,20 +3120,25 @@ rtl_verify_bb_layout (void) - check that all fallthru edge points to the adjacent blocks - verify that there is a single hot/cold partition boundary after bbro */ -static int +static bool rtl_verify_flow_info (void) { - int err = 0; + bool err = false; - err |= rtl_verify_flow_info_1 (); + if (rtl_verify_flow_info_1 ()) + err = true; - err |= rtl_verify_bb_insn_chain (); + if (rtl_verify_bb_insn_chain ()) + err = true; - err |= rtl_verify_fallthru (); + if (rtl_verify_fallthru ()) + err = true; - err |= rtl_verify_bb_layout (); + if (rtl_verify_bb_layout ()) + err = true; - err |= verify_hot_cold_block_grouping (); + if (verify_hot_cold_block_grouping ()) + err = true; return err; } @@ -3310,7 +3317,7 @@ purge_dead_edges (basic_block bb) gcc_assert (single_succ_edge (bb)->flags == (EDGE_SIBCALL | EDGE_ABNORMAL)); - return 0; + return false; } /* If we don't see a jump insn, we don't know exactly why the block would @@ -3360,15 +3367,12 @@ purge_dead_edges (basic_block bb) bool purge_all_dead_edges (void) { - int purged = false; + bool purged = false; basic_block bb; FOR_EACH_BB_FN (bb, cfun) - { - bool purged_here = purge_dead_edges (bb); - - purged |= purged_here; - } + if (purge_dead_edges (bb)) + purged = true; return purged; } @@ -5018,8 +5022,8 @@ rtl_split_block_before_cond_jump (basic_block bb) return NULL; } -/* Return 1 if BB ends with a call, possibly followed by some - instructions that must stay with the call, 0 otherwise. */ +/* Return true if BB ends with a call, possibly followed by some + instructions that must stay with the call, false otherwise. */ static bool rtl_block_ends_with_call_p (basic_block bb) @@ -5035,7 +5039,7 @@ rtl_block_ends_with_call_p (basic_block bb) return (CALL_P (insn)); } -/* Return 1 if BB ends with a conditional branch, 0 otherwise. */ +/* Return true if BB ends with a conditional branch, false otherwise. */ static bool rtl_block_ends_with_condjump_p (const_basic_block bb) diff --git a/gcc/cfgrtl.h b/gcc/cfgrtl.h index e29513449fb..e175a28bee0 100644 --- a/gcc/cfgrtl.h +++ b/gcc/cfgrtl.h @@ -26,7 +26,7 @@ extern void delete_insn_chain (rtx, rtx_insn *, bool); extern basic_block create_basic_block_structure (rtx_insn *, rtx_insn *, rtx_note *, basic_block); extern void compute_bb_for_insn (void); -extern unsigned int free_bb_for_insn (void); +extern void free_bb_for_insn (void); extern rtx_insn *entry_of_function (void); extern void update_bb_for_insn (basic_block); extern bool contains_no_active_insn_p (const_basic_block); diff --git a/gcc/postreload-gcse.cc b/gcc/postreload-gcse.cc index 1f374eacff5..f4a560da131 100644 --- a/gcc/postreload-gcse.cc +++ b/gcc/postreload-gcse.cc @@ -141,7 +141,7 @@ expr_hasher::hash (const expr *exp) inline bool expr_hasher::equal (const expr *exp1, const expr *exp2) { - int equiv_p = exp_equiv_p (exp1->expr, exp2->expr, 0, true); + bool equiv_p = exp_equiv_p (exp1->expr, exp2->expr, 0, true); gcc_assert (!equiv_p || exp1->hash == exp2->hash); return equiv_p; @@ -244,7 +244,7 @@ static void record_last_set_info (rtx, const_rtx, void *); static void record_opr_changes (rtx_insn *); static void find_mem_conflicts (rtx, const_rtx, void *); -static int load_killed_in_block_p (int, rtx, bool); +static bool load_killed_in_block_p (int, rtx, bool); static void reset_opr_set_tables (void); /* Hash table support. */ @@ -529,7 +529,7 @@ oprs_unchanged_p (rtx x, rtx_insn *insn, bool after_insn) const char *fmt; if (x == 0) - return 1; + return true; code = GET_CODE (x); switch (code) @@ -544,7 +544,7 @@ oprs_unchanged_p (rtx x, rtx_insn *insn, bool after_insn) case MEM: if (load_killed_in_block_p (INSN_CUID (insn), x, after_insn)) - return 0; + return false; else return oprs_unchanged_p (XEXP (x, 0), insn, after_insn); @@ -555,7 +555,7 @@ oprs_unchanged_p (rtx x, rtx_insn *insn, bool after_insn) case LABEL_REF: case ADDR_VEC: case ADDR_DIFF_VEC: - return 1; + return true; case PRE_DEC: case PRE_INC: @@ -564,7 +564,7 @@ oprs_unchanged_p (rtx x, rtx_insn *insn, bool after_insn) case PRE_MODIFY: case POST_MODIFY: if (after_insn) - return 0; + return false; break; default: @@ -576,15 +576,15 @@ oprs_unchanged_p (rtx x, rtx_insn *insn, bool after_insn) if (fmt[i] == 'e') { if (! oprs_unchanged_p (XEXP (x, i), insn, after_insn)) - return 0; + return false; } else if (fmt[i] == 'E') for (j = 0; j < XVECLEN (x, i); j++) if (! oprs_unchanged_p (XVECEXP (x, i, j), insn, after_insn)) - return 0; + return false; } - return 1; + return true; } @@ -628,7 +628,7 @@ find_mem_conflicts (rtx dest, const_rtx setter ATTRIBUTE_UNUSED, the hash table construction or redundancy elimination phases start processing a new basic block. */ -static int +static bool load_killed_in_block_p (int uid_limit, rtx x, bool after_insn) { struct modifies_mem *list_entry = modifies_mem_list; @@ -651,7 +651,7 @@ load_killed_in_block_p (int uid_limit, rtx x, bool after_insn) to pure functions are never put on the list, so we need not worry about them. */ if (CALL_P (setter)) - return 1; + return true; /* SETTER must be an insn of some kind that sets memory. Call note_stores to examine each hunk of memory that is modified. @@ -660,11 +660,11 @@ load_killed_in_block_p (int uid_limit, rtx x, bool after_insn) mems_conflict_p = 0; note_stores (setter, find_mem_conflicts, x); if (mems_conflict_p) - return 1; + return true; list_entry = list_entry->next; } - return 0; + return false; } @@ -930,7 +930,7 @@ get_avail_load_store_reg (rtx_insn *insn) } } -/* Return nonzero if the predecessors of BB are "well behaved". */ +/* Return true if the predecessors of BB are "well behaved". */ static bool bb_has_well_behaved_predecessors (basic_block bb) @@ -1416,12 +1416,11 @@ gcse_after_reload_main (rtx f ATTRIBUTE_UNUSED) -static unsigned int +static void rest_of_handle_gcse2 (void) { gcse_after_reload_main (get_insns ()); rebuild_jump_labels (get_insns ()); - return 0; } namespace { @@ -1455,7 +1454,8 @@ public: unsigned int execute (function *) final override { - return rest_of_handle_gcse2 (); + rest_of_handle_gcse2 (); + return 0; } }; // class pass_gcse2 diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc index 4989906706c..938d0634290 100644 --- a/gcc/tree-cfg.cc +++ b/gcc/tree-cfg.cc @@ -165,7 +165,7 @@ static edge gimple_try_redirect_by_replacing_jump (edge, basic_block); /* Various helpers. */ static inline bool stmt_starts_bb_p (gimple *, gimple *); -static int gimple_verify_flow_info (void); +static bool gimple_verify_flow_info (void); static void gimple_make_forwarder_block (edge); static gimple *first_non_label_stmt (basic_block); static bool verify_gimple_transaction (gtransaction *); @@ -5654,10 +5654,10 @@ verify_gimple_in_cfg (struct function *fn, bool verify_nothrow, bool ice) /* Verifies that the flow information is OK. */ -static int +static bool gimple_verify_flow_info (void) { - int err = 0; + bool err = false; basic_block bb; gimple_stmt_iterator gsi; gimple *stmt; @@ -5668,21 +5668,21 @@ gimple_verify_flow_info (void) || ENTRY_BLOCK_PTR_FOR_FN (cfun)->il.gimple.phi_nodes) { error ("ENTRY_BLOCK has IL associated with it"); - err = 1; + err = true; } if (EXIT_BLOCK_PTR_FOR_FN (cfun)->il.gimple.seq || EXIT_BLOCK_PTR_FOR_FN (cfun)->il.gimple.phi_nodes) { error ("EXIT_BLOCK has IL associated with it"); - err = 1; + err = true; } FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR_FOR_FN (cfun)->preds) if (e->flags & EDGE_FALLTHRU) { error ("fallthru to exit from bb %d", e->src->index); - err = 1; + err = true; } FOR_EACH_BB_FN (bb, cfun) @@ -5707,28 +5707,28 @@ gimple_verify_flow_info (void) { error ("nonlocal label %qD is not first in a sequence " "of labels in bb %d", label, bb->index); - err = 1; + err = true; } if (prev_stmt && EH_LANDING_PAD_NR (label) != 0) { error ("EH landing pad label %qD is not first in a sequence " "of labels in bb %d", label, bb->index); - err = 1; + err = true; } if (label_to_block (cfun, label) != bb) { error ("label %qD to block does not match in bb %d", label, bb->index); - err = 1; + err = true; } if (decl_function_context (label) != current_function_decl) { error ("label %qD has incorrect context in bb %d", label, bb->index); - err = 1; + err = true; } } @@ -5742,7 +5742,7 @@ gimple_verify_flow_info (void) { error ("control flow in the middle of basic block %d", bb->index); - err = 1; + err = true; } if (stmt_ends_bb_p (stmt)) @@ -5752,7 +5752,7 @@ gimple_verify_flow_info (void) { error ("label %qD in the middle of basic block %d", gimple_label_label (label_stmt), bb->index); - err = 1; + err = true; } /* Check that no statements appear between a returns_twice call @@ -5781,7 +5781,7 @@ gimple_verify_flow_info (void) error ("returns_twice call is %s in basic block %d", misplaced, bb->index); print_gimple_stmt (stderr, stmt, 0, TDF_SLIM); - err = 1; + err = true; } } if (!is_gimple_debug (stmt)) @@ -5797,7 +5797,8 @@ gimple_verify_flow_info (void) if (gimple_code (stmt) == GIMPLE_LABEL) continue; - err |= verify_eh_edges (stmt); + if (verify_eh_edges (stmt)) + err = true; if (is_ctrl_stmt (stmt)) { @@ -5806,7 +5807,7 @@ gimple_verify_flow_info (void) { error ("fallthru edge after a control statement in bb %d", bb->index); - err = 1; + err = true; } } @@ -5819,7 +5820,7 @@ gimple_verify_flow_info (void) { error ("true/false edge after a non-GIMPLE_COND in bb %d", bb->index); - err = 1; + err = true; } } @@ -5842,7 +5843,7 @@ gimple_verify_flow_info (void) { error ("wrong outgoing edge flags at end of bb %d", bb->index); - err = 1; + err = true; } } break; @@ -5851,7 +5852,7 @@ gimple_verify_flow_info (void) if (simple_goto_p (stmt)) { error ("explicit goto at end of bb %d", bb->index); - err = 1; + err = true; } else { @@ -5864,7 +5865,7 @@ gimple_verify_flow_info (void) { error ("wrong outgoing edge flags at end of bb %d", bb->index); - err = 1; + err = true; } } break; @@ -5880,13 +5881,13 @@ gimple_verify_flow_info (void) | EDGE_TRUE_VALUE | EDGE_FALSE_VALUE))) { error ("wrong outgoing edge flags at end of bb %d", bb->index); - err = 1; + err = true; } if (single_succ (bb) != EXIT_BLOCK_PTR_FOR_FN (cfun)) { error ("return edge does not point to exit in bb %d", bb->index); - err = 1; + err = true; } break; @@ -5916,7 +5917,7 @@ gimple_verify_flow_info (void) { error ("found default case not at the start of " "case vector"); - err = 1; + err = true; continue; } if (CASE_LOW (prev) @@ -5927,7 +5928,7 @@ gimple_verify_flow_info (void) fprintf (stderr," is greater than "); print_generic_expr (stderr, c); fprintf (stderr," but comes before it.\n"); - err = 1; + err = true; } prev = c; } @@ -5941,7 +5942,7 @@ gimple_verify_flow_info (void) { error ("extra outgoing edge %d->%d", bb->index, e->dest->index); - err = 1; + err = true; } e->dest->aux = (void *)2; @@ -5950,7 +5951,7 @@ gimple_verify_flow_info (void) { error ("wrong outgoing edge flags at end of bb %d", bb->index); - err = 1; + err = true; } } @@ -5963,7 +5964,7 @@ gimple_verify_flow_info (void) if (label_bb->aux != (void *)2) { error ("missing edge %i->%i", bb->index, label_bb->index); - err = 1; + err = true; } } @@ -5973,7 +5974,8 @@ gimple_verify_flow_info (void) break; case GIMPLE_EH_DISPATCH: - err |= verify_eh_dispatch_edge (as_a (stmt)); + if (verify_eh_dispatch_edge (as_a (stmt))) + err = true; break; default: