From patchwork Wed Sep 26 04:29:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dehao Chen X-Patchwork-Id: 186946 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id AD01A2C0085 for ; Wed, 26 Sep 2012 14:29:31 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1349238573; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: MIME-Version:Received:Received:Date:Message-ID:Subject:From:To: Cc:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=Tr1i8Ep v8i1L+4Rl7pihl1aJTUk=; b=UJb+skTixZGMwZMFes97UT/zHyh2i5VBI2Va6QH I8q8zIoJhjQVn25E0Sx/nzxsMNrN416Aw94Fj4XenRArgmZMzR+eofv6xRLcR+zX fpKH48I3tRrKvH+z+KILs2MCUJEXgPlhDoSPWIJ2oW4S+kgfqVm4vDG/sKqDk9KW rpqo= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-Google-DKIM-Signature:Received:MIME-Version:Received:Received:Date:Message-ID:Subject:From:To:Cc:Content-Type:X-System-Of-Record:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=Slq0BC1GO5KeJBNqW7G0XsL0VfmZn1IHEEYPakbGzGf6intELdMoK/kvKkE/39 PEspx66d8KVUBDhGufOUS3C+gvFl2L2YE7VwyjstwnfUHMDtJ1EwgJvrt8cBMfID CaD47nOqmckggR/Jo6wa8G9AoLofyPOIMwA8jr3zTqtFw=; Received: (qmail 14805 invoked by alias); 26 Sep 2012 04:29:25 -0000 Received: (qmail 14795 invoked by uid 22791); 26 Sep 2012 04:29:22 -0000 X-SWARE-Spam-Status: No, hits=-5.3 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, TW_TM X-Spam-Check-By: sourceware.org Received: from mail-pa0-f47.google.com (HELO mail-pa0-f47.google.com) (209.85.220.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 26 Sep 2012 04:29:07 +0000 Received: by padfa11 with SMTP id fa11so138677pad.20 for ; Tue, 25 Sep 2012 21:29:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type :x-system-of-record:x-gm-message-state; bh=hT78QINK0zyeM4e9DBAVmO0qUBcj3oeCXRScyPAiJW4=; b=CFA8iwwl8SoAktxQ2UeJ9LE3MEICO3AFwmOCfCPkWMPcN24PFXVLc6pOCBvtlbVkqb N224ILW9cAOejZKtTzRLSDqjWo/qOLT4qYF1nOoAHfFvM9/ZGyKYJYDcd5yhGBSK8K5E 2xmjwBbvXALKd3bUCayTyf/fQS/8yH1N+SVI14GgxGvwamN5ddF6bd2uovb8suntksUT RxulLWCcRFf6Dh1i6fEeqQouvjroHdJtA0OKNBurxlVjE/PFwZoRO/KnuwQeG3gUR9O9 8+3dg3/ya1mGBmVtyBFxWBx/+p/er2pd4HEUwD1r/CgUhVlLBK0i9NcqF84uclNdmOxu Ldcg== Received: by 10.68.189.164 with SMTP id gj4mr51329086pbc.48.1348633747117; Tue, 25 Sep 2012 21:29:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.189.164 with SMTP id gj4mr51329066pbc.48.1348633747009; Tue, 25 Sep 2012 21:29:07 -0700 (PDT) Received: by 10.68.49.232 with HTTP; Tue, 25 Sep 2012 21:29:06 -0700 (PDT) Date: Tue, 25 Sep 2012 21:29:06 -0700 Message-ID: Subject: [PATCH] Refactor the code to remove IS_UNKNOWN_LOCATION From: Dehao Chen To: GCC Patches Cc: Richard Guenther X-System-Of-Record: true X-Gm-Message-State: ALoCoQma58nslrjl9cmsK8Z02qlt0W1vVyD3xldQBPtldoMEp0CPNuiKWc8Odfpnz9Q4YTpdcgF3jyYN5+IcK9Puj4PK1593cvzvHEI7re/KHcvSpoAxH4yMOgb+hPSuzlMpuOJ+xgLR0bY8WhnnEyhH7Ienp71ooPYJQfNsP/CdiTnmiwVYNT+saEv9r7wwRhURAHc4Qp07 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org IS_UNKNOWN_LOCATION is very misleading. This patch removes this macro from input.h. For sites when checking LOCUS is intended, we explicit use LOCATION_LOCUS and compare it to UNKNOWN_LOCATION. Bootstrapped and passed all gcc regression tests. Ok for trunk? Thanks, Dehao gcc/ChangeLog: 2012-09-25 Dehao Chen * gcc/tree.h (tree_constructor): Remove IS_UNKNOWN_LOCATION. (extern void protected_set_expr_location): Likewise. (function_args_iter_next): Likewise. (inlined_function_outer_scope_p): Likewise. * gcc/input.h (IS_UNKNOWN_LOCATION): Likewise. * gcc/fold-const.c (expr_location_or): Likewise. * gcc/lto-cgraph.c (output_node_opt_summary): Likewise. * gcc/dwarf2out.c (add_src_coords_attributes): Likewise. * gcc/tree-eh.c (lower_try_finally_dup_block): Likewise. * gcc/profile.c (branch_prob): * gcc/cfgexpand.c (expand_gimple_cond): Likewise. (expand_gimple_basic_block): Likewise. (construct_exit_block): Likewise. (gimple_expand_cfg): Likewise. * gcc/cfgcleanup.c (try_forward_edges): Likewise. * gcc/tree-ssa-live.c (remove_unused_scope_block_p): Likewise. (dump_scope_block): Likewise. * gcc/ipa-prop.c (ipa_write_jump_function): Likewise. * gcc/rtl.h (extern void rtl_check_failed_flag): Likewise. * gcc/gimple.h (gimple_set_location): Likewise. (gimple_has_location): Likewise. * gcc/cfgrtl.c (unique_locus_on_edge_between_p): Likewise. (force_nonfallthru_and_redirect): Likewise. (fixup_reorder_chain): Likewise. (cfg_layout_merge_blocks): Likewise. Index: gcc/tree.h =================================================================== --- gcc/tree.h (revision 191746) +++ gcc/tree.h (working copy) @@ -1612,7 +1612,8 @@ struct GTY(()) tree_constructor { #define EXPR_LOCATION(NODE) \ (CAN_HAVE_LOCATION_P ((NODE)) ? (NODE)->exp.locus : UNKNOWN_LOCATION) #define SET_EXPR_LOCATION(NODE, LOCUS) EXPR_CHECK ((NODE))->exp.locus = (LOCUS) -#define EXPR_HAS_LOCATION(NODE) (!IS_UNKNOWN_LOCATION (EXPR_LOCATION (NODE))) +#define EXPR_HAS_LOCATION(NODE) (LOCATION_LOCUS (EXPR_LOCATION (NODE)) \ + != UNKNOWN_LOCATION) /* The location to be used in a diagnostic about this expression. Do not use this macro if the location will be assigned to other expressions. */ #define EXPR_LOC_OR_HERE(NODE) (EXPR_HAS_LOCATION (NODE) ? (NODE)->exp.locus : input_location) @@ -1791,7 +1792,8 @@ extern void protected_set_expr_location (tree, loc OMP_CLAUSE_PRIVATE, \ OMP_CLAUSE_COPYPRIVATE), 0) #define OMP_CLAUSE_HAS_LOCATION(NODE) \ - (!IS_UNKNOWN_LOCATION ((OMP_CLAUSE_CHECK (NODE))->omp_clause.locus)) + (LOCATION_LOCUS ((OMP_CLAUSE_CHECK (NODE))->omp_clause.locus) \ + != UNKNOWN_LOCATION) #define OMP_CLAUSE_LOCATION(NODE) (OMP_CLAUSE_CHECK (NODE))->omp_clause.locus /* True on an OMP_SECTION statement that was the last lexical member. @@ -5535,7 +5537,7 @@ function_args_iter_next (function_args_iterator *i static inline bool inlined_function_outer_scope_p (const_tree block) { - return !IS_UNKNOWN_LOCATION (BLOCK_SOURCE_LOCATION (block)); + return LOCATION_LOCUS (BLOCK_SOURCE_LOCATION (block)) != UNKNOWN_LOCATION; } /* Loop over all function arguments of FNTYPE. In each iteration, PTR is set Index: gcc/input.h =================================================================== --- gcc/input.h (revision 191746) +++ gcc/input.h (working copy) @@ -56,9 +56,6 @@ extern location_t input_location; #define LOCATION_BLOCK(LOC) \ ((tree) ((IS_ADHOC_LOC (LOC)) ? get_data_from_adhoc_loc (line_table, (LOC)) \ : NULL)) -#define IS_UNKNOWN_LOCATION(LOC) \ - ((IS_ADHOC_LOC (LOC)) ? get_location_from_adhoc_loc (line_table, LOC) == 0 \ - : (LOC) == 0) #define input_line LOCATION_LINE (input_location) #define input_filename LOCATION_FILE (input_location) Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c (revision 191746) +++ gcc/fold-const.c (working copy) @@ -145,7 +145,7 @@ static location_t expr_location_or (tree t, location_t loc) { location_t tloc = EXPR_LOCATION (t); - return IS_UNKNOWN_LOCATION (tloc) ? loc : tloc; + return tloc == UNKNOWN_LOCATION ? loc : tloc; } /* Similar to protected_set_expr_location, but never modify x in place, Index: gcc/lto-cgraph.c =================================================================== --- gcc/lto-cgraph.c (revision 191746) +++ gcc/lto-cgraph.c (working copy) @@ -1412,7 +1412,7 @@ output_node_opt_summary (struct output_block *ob, mechanism to store function local declarations into summaries. */ gcc_assert (parm); streamer_write_uhwi (ob, parm_num); - gcc_assert (IS_UNKNOWN_LOCATION (EXPR_LOCATION (map->new_tree))); + gcc_assert (EXPR_LOCATION (map->new_tree) == UNKNOWN_LOCATION); stream_write_tree (ob, map->new_tree, true); bp = bitpack_create (ob->main_stream); bp_pack_value (&bp, map->replace_p, 1); Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c (revision 191746) +++ gcc/dwarf2out.c (working copy) @@ -15552,7 +15552,7 @@ add_src_coords_attributes (dw_die_ref die, tree de { expanded_location s; - if (IS_UNKNOWN_LOCATION (DECL_SOURCE_LOCATION (decl))) + if (LOCATION_LOCUS (DECL_SOURCE_LOCATION (decl)) == UNKNOWN_LOCATION) return; s = expand_location (DECL_SOURCE_LOCATION (decl)); add_AT_file (die, DW_AT_decl_file, lookup_filename (s.file)); Index: gcc/tree-eh.c =================================================================== --- gcc/tree-eh.c (revision 191746) +++ gcc/tree-eh.c (working copy) @@ -885,7 +885,7 @@ lower_try_finally_dup_block (gimple_seq seq, struc for (gsi = gsi_start (new_seq); !gsi_end_p (gsi); gsi_next (&gsi)) { gimple stmt = gsi_stmt (gsi); - if (IS_UNKNOWN_LOCATION (gimple_location (stmt))) + if (LOCATION_LOCUS (gimple_location (stmt)) == UNKNOWN_LOCATION) { tree block = gimple_block (stmt); gimple_set_location (stmt, loc); Index: gcc/profile.c =================================================================== --- gcc/profile.c (revision 191746) +++ gcc/profile.c (working copy) @@ -1123,7 +1123,7 @@ branch_prob (void) is not computed twice. */ if (last && gimple_has_location (last) - && !IS_UNKNOWN_LOCATION (e->goto_locus) + && LOCATION_LOCUS (e->goto_locus) != UNKNOWN_LOCATION && !single_succ_p (bb) && (LOCATION_FILE (e->goto_locus) != LOCATION_FILE (gimple_location (last)) @@ -1344,7 +1344,8 @@ branch_prob (void) /* Notice GOTO expressions eliminated while constructing the CFG. */ if (single_succ_p (bb) - && !IS_UNKNOWN_LOCATION (single_succ_edge (bb)->goto_locus)) + && LOCATION_LOCUS (single_succ_edge (bb)->goto_locus) + != UNKNOWN_LOCATION) { expanded_location curr_location = expand_location (single_succ_edge (bb)->goto_locus); Index: gcc/cfgexpand.c =================================================================== --- gcc/cfgexpand.c (revision 191746) +++ gcc/cfgexpand.c (working copy) @@ -1838,7 +1838,7 @@ expand_gimple_cond (basic_block bb, gimple stmt) jumpif_1 (code, op0, op1, label_rtx_for_bb (true_edge->dest), true_edge->probability); maybe_dump_rtl_for_gimple_stmt (stmt, last); - if (!IS_UNKNOWN_LOCATION (true_edge->goto_locus)) + if (true_edge->goto_locus != UNKNOWN_LOCATION) set_curr_insn_location (true_edge->goto_locus); false_edge->flags |= EDGE_FALLTHRU; maybe_cleanup_end_of_block (false_edge, last); @@ -1849,7 +1849,7 @@ expand_gimple_cond (basic_block bb, gimple stmt) jumpifnot_1 (code, op0, op1, label_rtx_for_bb (false_edge->dest), false_edge->probability); maybe_dump_rtl_for_gimple_stmt (stmt, last); - if (!IS_UNKNOWN_LOCATION (false_edge->goto_locus)) + if (false_edge->goto_locus != UNKNOWN_LOCATION) set_curr_insn_location (false_edge->goto_locus); true_edge->flags |= EDGE_FALLTHRU; maybe_cleanup_end_of_block (true_edge, last); @@ -1859,7 +1859,7 @@ expand_gimple_cond (basic_block bb, gimple stmt) jumpif_1 (code, op0, op1, label_rtx_for_bb (true_edge->dest), true_edge->probability); last = get_last_insn (); - if (!IS_UNKNOWN_LOCATION (false_edge->goto_locus)) + if (false_edge->goto_locus != UNKNOWN_LOCATION) set_curr_insn_location (false_edge->goto_locus); emit_jump (label_rtx_for_bb (false_edge->dest)); @@ -1885,7 +1885,7 @@ expand_gimple_cond (basic_block bb, gimple stmt) maybe_dump_rtl_for_gimple_stmt (stmt, last2); - if (!IS_UNKNOWN_LOCATION (true_edge->goto_locus)) + if (true_edge->goto_locus != UNKNOWN_LOCATION) { set_curr_insn_location (true_edge->goto_locus); true_edge->goto_locus = curr_insn_location (); @@ -3973,7 +3973,7 @@ expand_gimple_basic_block (basic_block bb) /* Expand implicit goto and convert goto_locus. */ FOR_EACH_EDGE (e, ei, bb->succs) { - if (!IS_UNKNOWN_LOCATION (e->goto_locus)) + if (e->goto_locus != UNKNOWN_LOCATION) set_curr_insn_location (e->goto_locus); if ((e->flags & EDGE_FALLTHRU) && e->dest != bb->next_bb) { @@ -4094,7 +4094,7 @@ construct_exit_block (void) /* Make sure the locus is set to the end of the function, so that epilogue line numbers and warnings are set properly. */ - if (!IS_UNKNOWN_LOCATION (cfun->function_end_locus)) + if (LOCATION_LOCUS (cfun->function_end_locus) != UNKNOWN_LOCATION) input_location = cfun->function_end_locus; /* Generate rtl for function exit. */ @@ -4318,7 +4318,7 @@ gimple_expand_cfg (void) if (!DECL_IS_BUILTIN (current_function_decl)) { /* Eventually, all FEs should explicitly set function_start_locus. */ - if (IS_UNKNOWN_LOCATION (cfun->function_start_locus)) + if (LOCATION_LOCUS (cfun->function_start_locus) == UNKNOWN_LOCATION) set_curr_insn_location (DECL_SOURCE_LOCATION (current_function_decl)); else Index: gcc/cfgcleanup.c =================================================================== --- gcc/cfgcleanup.c (revision 191746) +++ gcc/cfgcleanup.c (working copy) @@ -481,15 +481,15 @@ try_forward_edges (int mode, basic_block b) int new_locus = single_succ_edge (target)->goto_locus; int locus = goto_locus; - if (!IS_UNKNOWN_LOCATION (new_locus) - && !IS_UNKNOWN_LOCATION (locus) + if (new_locus != UNKNOWN_LOCATION + && locus != UNKNOWN_LOCATION && new_locus != locus) new_target = NULL; else { rtx last; - if (!IS_UNKNOWN_LOCATION (new_locus)) + if (new_locus != UNKNOWN_LOCATION) locus = new_locus; last = BB_END (target); @@ -499,13 +499,13 @@ try_forward_edges (int mode, basic_block b) new_locus = last && INSN_P (last) ? INSN_LOCATION (last) : 0; - if (!IS_UNKNOWN_LOCATION (new_locus) - && !IS_UNKNOWN_LOCATION (locus) + if (new_locus != UNKNOWN_LOCATION + && locus != UNKNOWN_LOCATION && new_locus != locus) new_target = NULL; else { - if (!IS_UNKNOWN_LOCATION (new_locus)) + if (new_locus != UNKNOWN_LOCATION) locus = new_locus; goto_locus = locus; Index: gcc/tree-ssa-live.c =================================================================== --- gcc/tree-ssa-live.c (revision 191746) +++ gcc/tree-ssa-live.c (working copy) @@ -597,7 +597,8 @@ remove_unused_scope_block_p (tree scope) else /* Verfify that only blocks with source location set are entry points to the inlined functions. */ - gcc_assert (IS_UNKNOWN_LOCATION (BLOCK_SOURCE_LOCATION (scope))); + gcc_assert (LOCATION_LOCUS (BLOCK_SOURCE_LOCATION (scope)) + == UNKNOWN_LOCATION); TREE_USED (scope) = !unused; return unused; @@ -671,7 +672,7 @@ dump_scope_block (FILE *file, int indent, tree sco fprintf (file, "\n%*s{ Scope block #%i%s%s",indent, "" , BLOCK_NUMBER (scope), TREE_USED (scope) ? "" : " (unused)", BLOCK_ABSTRACT (scope) ? " (abstract)": ""); - if (!IS_UNKNOWN_LOCATION (BLOCK_SOURCE_LOCATION (scope))) + if (LOCATION_LOCUS (BLOCK_SOURCE_LOCATION (scope)) != UNKNOWN_LOCATION) { expanded_location s = expand_location (BLOCK_SOURCE_LOCATION (scope)); fprintf (file, " %s:%i", s.file, s.line); Index: gcc/ipa-prop.c =================================================================== --- gcc/ipa-prop.c (revision 191746) +++ gcc/ipa-prop.c (working copy) @@ -3165,7 +3165,7 @@ ipa_write_jump_function (struct output_block *ob, break; case IPA_JF_CONST: gcc_assert ( - IS_UNKNOWN_LOCATION (EXPR_LOCATION (jump_func->value.constant))); + EXPR_LOCATION (jump_func->value.constant) == UNKNOWN_LOCATION); stream_write_tree (ob, jump_func->value.constant, true); break; case IPA_JF_PASS_THROUGH: Index: gcc/rtl.h =================================================================== --- gcc/rtl.h (revision 191746) +++ gcc/rtl.h (working copy) @@ -829,7 +829,8 @@ extern void rtl_check_failed_flag (const char *, c #define INSN_LOCATION(INSN) XUINT (INSN, 5) -#define INSN_HAS_LOCATION(INSN) (!IS_UNKNOWN_LOCATION (INSN_LOCATION (INSN))) +#define INSN_HAS_LOCATION(INSN) ((LOCATION_LOCUS (INSN_LOCATION (INSN)))\ + != UNKNOWN_LOCATION) /* LOCATION of an RTX if relevant. */ #define RTL_LOCATION(X) (INSN_P (X) ? \ Index: gcc/gimple.h =================================================================== --- gcc/gimple.h (revision 191746) +++ gcc/gimple.h (working copy) @@ -1240,7 +1240,7 @@ gimple_set_location (gimple g, location_t location static inline bool gimple_has_location (const_gimple g) { - return !IS_UNKNOWN_LOCATION (gimple_location (g)); + return LOCATION_LOCUS (gimple_location (g)) != UNKNOWN_LOCATION; } Index: gcc/cfgrtl.c =================================================================== --- gcc/cfgrtl.c (revision 191746) +++ gcc/cfgrtl.c (working copy) @@ -723,7 +723,7 @@ unique_locus_on_edge_between_p (basic_block a, bas const location_t goto_locus = EDGE_SUCC (a, 0)->goto_locus; rtx insn, end; - if (IS_UNKNOWN_LOCATION (goto_locus)) + if (LOCATION_LOCUS (goto_locus) == UNKNOWN_LOCATION) return false; /* First scan block A backward. */ @@ -1477,10 +1477,7 @@ force_nonfallthru_and_redirect (edge e, basic_bloc else jump_block = e->src; - if (!IS_UNKNOWN_LOCATION (e->goto_locus)) - loc = e->goto_locus; - else - loc = 0; + loc = e->goto_locus; e->flags &= ~EDGE_FALLTHRU; if (target == EXIT_BLOCK_PTR) { @@ -3335,7 +3332,7 @@ fixup_reorder_chain (void) edge_iterator ei; FOR_EACH_EDGE (e, ei, bb->succs) - if (!IS_UNKNOWN_LOCATION (e->goto_locus) + if (LOCATION_LOCUS (e->goto_locus) != UNKNOWN_LOCATION && !(e->flags & EDGE_ABNORMAL)) { edge e2; @@ -3385,7 +3382,7 @@ fixup_reorder_chain (void) well, this can prevent other such blocks from being created in subsequent iterations of the loop. */ for (ei2 = ei_start (dest->preds); (e2 = ei_safe_edge (ei2)); ) - if (!IS_UNKNOWN_LOCATION (e2->goto_locus) + if (LOCATION_LOCUS (e2->goto_locus) != UNKNOWN_LOCATION && !(e2->flags & (EDGE_ABNORMAL | EDGE_FALLTHRU)) && e->goto_locus == e2->goto_locus) redirect_edge_and_branch (e2, nb); @@ -4087,7 +4084,8 @@ cfg_layout_merge_blocks (basic_block a, basic_bloc } /* If B was a forwarder block, propagate the locus on the edge. */ - if (forwarder_p && IS_UNKNOWN_LOCATION (EDGE_SUCC (b, 0)->goto_locus)) + if (forwarder_p + && LOCATION_LOCUS (EDGE_SUCC (b, 0)->goto_locus) != UNKNOWN_LOCATION) EDGE_SUCC (b, 0)->goto_locus = EDGE_SUCC (a, 0)->goto_locus; if (dump_file)