From: Per Bothner Date: Wed, 30 Jun 2004 18:21:54 +0000 (-0700) Subject: Conditionally compile support for --enable-mapped_location. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9506ac2be5e52ce7e184be3c52d31421355b7ab4;p=gcc.git Conditionally compile support for --enable-mapped_location. * gengtype-lex.l: Temporary kludge to avoid duplicate typedef. * gengtype.c: Update for now typdefs in input.h. More kludges. * modulo-sched.c (sms_schedule): Use NOTE_EXPANDED_LOCATION macro. * ra-debug.c (ra_print_rtl): Likewise. * sched-rgn.c: Likewise. * sched-vis.c: Likewise. * rtl.h (gen_rtx_ASM_OPERANDS): Redefine if USE_MAPPED_LOCATION. * stmt.c (expand_asm_operands): Adjust calls to gen_rtx_ASM_OPERANDS. * tree-cfg.c: Use new macros and typedefs. * tree-flow-inline.h: Likewise. From-SVN: r83922 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b217e27ee79..2e424d7c14a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -79,6 +79,16 @@ * rtl-error.c: Likewise. * stmt.c (check_seenlabel): Likewise. * tree-pretty-print.c: Likewise. + * gengtype-lex.l: Temporary kludge to avoid duplicate typedef. + * gengtype.c: Update for now typdefs in input.h. More kludges. + * modulo-sched.c (sms_schedule): Use NOTE_EXPANDED_LOCATION macro. + * ra-debug.c (ra_print_rtl): Likewise. + * sched-rgn.c: Likewise. + * sched-vis.c: Likewise. + * rtl.h (gen_rtx_ASM_OPERANDS): Redefine if USE_MAPPED_LOCATION. + * stmt.c (expand_asm_operands): Adjust calls to gen_rtx_ASM_OPERANDS. + * tree-cfg.c: Use new macros and typedefs. + * tree-flow-inline.h: Likewise. 2004-06-30 Richard Sandiford Eric Christopher diff --git a/gcc/gengtype-lex.l b/gcc/gengtype-lex.l index ed9100829ee..22a5cd8ee0f 100644 --- a/gcc/gengtype-lex.l +++ b/gcc/gengtype-lex.l @@ -88,7 +88,12 @@ ITYPE {IWORD}({WS}{IWORD})* t = find_structure (xmemdup (tagstart, taglen, taglen+1), union_p); if (is_pointer) t = create_pointer (t); - do_typedef (xmemdup (namestart, namelen, namelen+1), t, &lexer_line); + namestart = xmemdup (namestart, namelen, namelen+1); +#ifdef USE_MAPPED_LOCATION + /* temporary kludge - gentype doesn't handle cpp conditionals */ + if (strcmp (namestart, "location_t") != 0) +#endif + do_typedef (namestart, t, &lexer_line); update_lineno (yytext, yyleng); } diff --git a/gcc/gengtype.c b/gcc/gengtype.c index 85e856f89fd..6c19725f868 100644 --- a/gcc/gengtype.c +++ b/gcc/gengtype.c @@ -1104,7 +1104,7 @@ open_base_files (void) /* The order of files here matters very much. */ static const char *const ifiles [] = { "config.h", "system.h", "coretypes.h", "tm.h", "varray.h", - "hashtab.h", "splay-tree.h", "bitmap.h", "tree.h", "rtl.h", + "hashtab.h", "splay-tree.h", "bitmap.h", "input.h", "tree.h", "rtl.h", "function.h", "insn-config.h", "expr.h", "hard-reg-set.h", "basic-block.h", "cselib.h", "insn-addr.h", "optabs.h", "libfuncs.h", "debug.h", "ggc.h", "cgraph.h", @@ -2988,6 +2988,10 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) do_scalar_typedef ("uint8", &pos); do_scalar_typedef ("jword", &pos); do_scalar_typedef ("JCF_u2", &pos); +#ifdef USE_MAPPED_LOCATION + do_scalar_typedef ("location_t", &pos); + do_scalar_typedef ("source_locus", &pos); +#endif do_scalar_typedef ("void", &pos); do_typedef ("PTR", create_pointer (resolve_typedef ("void", &pos)), &pos); @@ -3010,6 +3014,12 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) } if (!dupflag) parse_file (all_files[i]); +#ifndef USE_MAPPED_LOCATION + /* temporary kludge - gengtype doesn't handle conditionals. + Manually add source_locus *after* we've processed input.h. */ + if (i == 0) + do_typedef ("source_locus", create_pointer (resolve_typedef ("location_t", &pos)), &pos); +#endif } if (hit_error != 0) diff --git a/gcc/modulo-sched.c b/gcc/modulo-sched.c index 68eeb364e9f..c14b58f8699 100644 --- a/gcc/modulo-sched.c +++ b/gcc/modulo-sched.c @@ -900,8 +900,12 @@ sms_schedule (FILE *dump_file) rtx line_note = find_line_note (tail); if (line_note) - fprintf (stats_file, "SMS bb %s %d (file, line)\n", - NOTE_SOURCE_FILE (line_note), NOTE_LINE_NUMBER (line_note)); + { + expanded_location xloc; + NOTE_EXPANDED_LOCATION (xloc, line_note); + fprintf (stats_file, "SMS bb %s %d (file, line)\n", + xloc.file, xloc.line); + } fprintf (stats_file, "SMS single-bb-loop\n"); if (profile_info && flag_branch_probabilities) { @@ -996,8 +1000,12 @@ sms_schedule (FILE *dump_file) rtx line_note = find_line_note (tail); if (line_note) - fprintf (stats_file, "SMS bb %s %d (file, line)\n", - NOTE_SOURCE_FILE (line_note), NOTE_LINE_NUMBER (line_note)); + { + expanded_location xloc; + NOTE_EXPANDED_LOCATION (xloc, line_note); + fprintf (stats_file, "SMS bb %s %d (file, line)\n", + xloc.file, xloc.line); + } fprintf (stats_file, "SMS single-bb-loop\n"); if (profile_info && flag_branch_probabilities) { diff --git a/gcc/ra-debug.c b/gcc/ra-debug.c index a5c4f0983f4..9bbfeb7fdb8 100644 --- a/gcc/ra-debug.c +++ b/gcc/ra-debug.c @@ -389,9 +389,11 @@ ra_print_rtx (FILE *file, rtx x, int with_pn) fprintf (file, " %s", GET_NOTE_INSN_NAME (ln)); else { - fprintf (file, " line %d", ln); - if (NOTE_SOURCE_FILE (x)) - fprintf (file, ":%s", NOTE_SOURCE_FILE (x)); + expanded_location s; + NOTE_EXPANDED_LOCATION (s, x); + fprintf (file, " line %d", s.line); + if (s.file != NULL) + fprintf (file, ":%s", s.file); } } else diff --git a/gcc/sched-rgn.c b/gcc/sched-rgn.c index 14175776a4a..1630a3d297a 100644 --- a/gcc/sched-rgn.c +++ b/gcc/sched-rgn.c @@ -2321,8 +2321,12 @@ debug_dependencies (void) if (n < 0) fprintf (sched_dump, "%s\n", GET_NOTE_INSN_NAME (n)); else - fprintf (sched_dump, "line %d, file %s\n", n, - NOTE_SOURCE_FILE (insn)); + { + expanded_location xloc; + NOTE_EXPANDED_LOCATION (xloc, insn); + fprintf (sched_dump, "line %d, file %s\n", + xloc.line, xloc.file); + } } else fprintf (sched_dump, " {%s}\n", GET_RTX_NAME (GET_CODE (insn))); diff --git a/gcc/sched-vis.c b/gcc/sched-vis.c index b7544d2ef8e..856830693e6 100644 --- a/gcc/sched-vis.c +++ b/gcc/sched-vis.c @@ -787,8 +787,12 @@ print_insn (char *buf, rtx x, int verbose) break; case NOTE: if (NOTE_LINE_NUMBER (x) > 0) - sprintf (buf, "%4d note \"%s\" %d", INSN_UID (x), - NOTE_SOURCE_FILE (x), NOTE_LINE_NUMBER (x)); + { + expanded_location xloc; + NOTE_EXPANDED_LOCATION (xloc, x); + sprintf (buf, "%4d note \"%s\" %d", INSN_UID (x), + xloc.file, xloc.line); + } else sprintf (buf, "%4d %s", INSN_UID (x), GET_NOTE_INSN_NAME (NOTE_LINE_NUMBER (x))); diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 88e66f7badc..509803cee99 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -666,7 +666,11 @@ make_goto_expr_edges (basic_block bb) if (simple_goto_p (goto_t)) { edge e = make_edge (bb, label_to_block (dest), EDGE_FALLTHRU); +#ifdef USE_MAPPED_LOCATION + e->goto_locus = EXPR_LOCATION (goto_t); +#else e->goto_locus = EXPR_LOCUS (goto_t); +#endif bsi_remove (&last); return; } @@ -1115,9 +1119,10 @@ static void remove_useless_stmts_1 (tree *, struct rus_data *); static bool remove_useless_stmts_warn_notreached (tree stmt) { - if (EXPR_LOCUS (stmt)) + if (EXPR_HAS_LOCATION (stmt)) { - warning ("%Hwill never be executed", EXPR_LOCUS (stmt)); + location_t loc = EXPR_LOCATION (stmt); + warning ("%Hwill never be executed", &loc); return true; } @@ -1776,7 +1781,7 @@ static void remove_bb (basic_block bb) { block_stmt_iterator i; - location_t *loc = NULL; + source_locus loc = 0; if (dump_file) { @@ -1799,8 +1804,12 @@ remove_bb (basic_block bb) jump threading, thus resulting in bogus warnings. Not great, since this way we lose warnings for gotos in the original program that are indeed unreachable. */ - if (TREE_CODE (stmt) != GOTO_EXPR && EXPR_LOCUS (stmt) && !loc) + if (TREE_CODE (stmt) != GOTO_EXPR && EXPR_HAS_LOCATION (stmt) && !loc) +#ifdef USE_MAPPED_LOCATION + loc = EXPR_LOCATION (stmt); +#else loc = EXPR_LOCUS (stmt); +#endif } /* If requested, give a warning that the first statement in the @@ -1808,7 +1817,11 @@ remove_bb (basic_block bb) loop above, so the last statement we process is the first statement in the block. */ if (warn_notreached && loc) +#ifdef USE_MAPPED_LOCATION + warning ("%Hwill never be executed", &loc); +#else warning ("%Hwill never be executed", loc); +#endif remove_phi_nodes_and_edges_for_unreachable_block (bb); } @@ -2641,7 +2654,11 @@ disband_implicit_edges (void) label = tree_block_label (e->dest); stmt = build1 (GOTO_EXPR, void_type_node, label); +#ifdef USE_MAPPED_LOCATION + SET_EXPR_LOCATION (stmt, e->goto_locus); +#else SET_EXPR_LOCUS (stmt, e->goto_locus); +#endif bsi_insert_after (&last, stmt, BSI_NEW_STMT); e->flags &= ~EDGE_FALLTHRU; } @@ -4759,7 +4776,11 @@ struct tree_opt_pass pass_split_crit_edges = static void execute_warn_function_return (void) { +#ifdef USE_MAPPED_LOCATION + source_location location; +#else location_t *locus; +#endif tree last; edge e; @@ -4774,17 +4795,31 @@ execute_warn_function_return (void) if (TREE_THIS_VOLATILE (cfun->decl) && EXIT_BLOCK_PTR->pred != NULL) { +#ifdef USE_MAPPED_LOCATION + location = UNKNOWN_LOCATION; +#else locus = NULL; +#endif for (e = EXIT_BLOCK_PTR->pred; e ; e = e->pred_next) { last = last_stmt (e->src); if (TREE_CODE (last) == RETURN_EXPR +#ifdef USE_MAPPED_LOCATION + && (location = EXPR_LOCATION (last)) != UNKNOWN_LOCATION) +#else && (locus = EXPR_LOCUS (last)) != NULL) +#endif break; } +#ifdef USE_MAPPED_LOCATION + if (location == UNKNOWN_LOCATION) + location = cfun->function_end_locus; + warning ("%H`noreturn' function does return", &location); +#else if (!locus) locus = &cfun->function_end_locus; warning ("%H`noreturn' function does return", locus); +#endif } /* If we see "return;" in some basic block, then we do reach the end @@ -4799,10 +4834,17 @@ execute_warn_function_return (void) if (TREE_CODE (last) == RETURN_EXPR && TREE_OPERAND (last, 0) == NULL) { +#ifdef USE_MAPPED_LOCATION + location = EXPR_LOCATION (last); + if (location == UNKNOWN_LOCATION) + location = cfun->function_end_locus; + warning ("%Hcontrol reaches end of non-void function", &location); +#else locus = EXPR_LOCUS (last); if (!locus) locus = &cfun->function_end_locus; warning ("%Hcontrol reaches end of non-void function", locus); +#endif break; } } diff --git a/gcc/tree-flow-inline.h b/gcc/tree-flow-inline.h index 48d8b34bfaa..bda65ca7f5c 100644 --- a/gcc/tree-flow-inline.h +++ b/gcc/tree-flow-inline.h @@ -126,7 +126,7 @@ get_lineno (tree expr) if (TREE_CODE (expr) == COMPOUND_EXPR) expr = TREE_OPERAND (expr, 0); - if (! EXPR_LOCUS (expr)) + if (! EXPR_HAS_LOCATION (expr)) return -1; return EXPR_LINENO (expr); @@ -137,14 +137,15 @@ get_lineno (tree expr) static inline const char * get_filename (tree expr) { + const char *filename; if (expr == NULL_TREE) return "???"; if (TREE_CODE (expr) == COMPOUND_EXPR) expr = TREE_OPERAND (expr, 0); - if (EXPR_LOCUS (expr) && EXPR_FILENAME (expr)) - return EXPR_FILENAME (expr); + if (EXPR_HAS_LOCATION (expr) && (filename = EXPR_FILENAME (expr))) + return filename; else return "???"; }