From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31535 invoked by alias); 5 Nov 2002 23:58:00 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 31514 invoked from network); 5 Nov 2002 23:57:58 -0000 Received: from unknown (HELO tornado.toronto.redhat.com) (216.138.202.10) by sources.redhat.com with SMTP; 5 Nov 2002 23:57:58 -0000 Received: from tornado.toronto.redhat.com (localhost [127.0.0.1]) by tornado.toronto.redhat.com (8.12.5/8.12.5) with ESMTP id gA5Nvvmi017074 for ; Tue, 5 Nov 2002 18:57:58 -0500 Received: (from dnovillo@localhost) by tornado.toronto.redhat.com (8.12.5/8.12.5/Submit) id gA5NvvXB017072 for gcc-patches@gcc.gnu.org; Tue, 5 Nov 2002 18:57:57 -0500 Date: Tue, 05 Nov 2002 15:58:00 -0000 From: Diego Novillo To: gcc-patches@gcc.gnu.org Subject: [tree-ssa] Changes to -fdump-tree-all-ssa and GC fixes [patch] Message-ID: <20021105235757.GA16970@tornado.toronto.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline User-Agent: Mutt/1.4i Organization: Red Hat Canada X-SW-Source: 2002-11/txt/msg00246.txt.bz2 - Renames -fdump-tree-all-ssa to -fdump-tree-all and parses the switch in dump_switch_p. This allows the user to set global flags for all the tree dumping options. - Adds a new tree dump option -block, to display basic block information on block boundaries. - Makes the tree CFG builder use the memory allocation routines used in the RTL flowgraph. Since basic_block is still not marked for garbage collection, we can't use ggc_alloc to allocate basic blocks. Long term we should mark basic_block for GC. Bootstrapped and tested on x86. Diego. * tree-cfg.c (create_block_annotations): New local function. (create_bb_ann): Remove. Update all users. (parent_array): New local variable. (build_tree_cfg): Initialize it. Call create_block_annotations. (create_bb): Call alloc_block instead of ggc_alloc to allocate memory for basic blocks. Don't call set_parent_block. Grow array parent_array. (dump_tree_cfg): Change meaning of second argument. Make it accept any of the TDF_* flags defined in tree.h. (delete_tree_cfg): Call free_aux_for_blocks. Free array parent_array. * tree-flow-inline.h (get_filename): New function. (is_exec_stmt): return false if T is error_mark_node. * tree-flow.h (struct var_ref_d): Mark alias_imm_rdefs field for garbage collection. (get_filename): Declare. (struct bb_ann_d): Rename from bb_ann_def. Remove garbage collection markers. (referenced_vars): Mark for garbage collection. (global_var): Likewise. (create_bb_ann): Remove. * tree-optimize.c (optimize_function_tree): Remove CFG and SSA after debugging dumps. * diagnostic.h (print_generic_stmt): Rename from print_generic_tree. Update all users. (print_generic_expr): Rename from print_generic_node. Update all users. (PPF_BRIEF): Remove. Update all users. (PPF_BLOCK): Remove. Update all users. (PPF_LINENO): Remove. Update all users. (PPF_IS_STMT): Remove. Update all users. * flags.h (flag_dump_tree_all_ssa): Remove. Update all users. * toplev.c (f_options): Remove entry for -fdump-tree-all-ssa. Update all users. * tree-dump.c (dump_enable_all): Rename from dump_enable_all_ssa. Update all users. (dump_files): Add entry for -fdump-tree-all. (dump_option_value_info): Remove entries for TDF_REFS and TDF_RDEFS. Add entry for TDF_BLOCK. (dump_switch_p): If -fdump-tree-all was given, call dump_enable_all. * tree-pretty-print.c (PPF_BRIEF): Remove. Update all users. (PPF_BLOCK): Remove. Update all users. (PPF_LINENO): Remove. Update all users. (PPF_IS_STMT): Remove. Update all users. (dumping_stmts): New local variable. (print_generic_stmt): Rename from print_generic_tree. Update all users. Set dumping_stmts to true. (print_generic_expr): Rename from print_generic_node. Update all users. Set dumping_stmts to false. (maybe_init_pretty_print): Set last_bb to -1. (dump_block_info): If available, dump file and line number information for the first statement in the basic block. * tree-ssa.c (build_tree_ssa): Dump referenced variables and reaching definition information if -details is given. * tree.h (enum tree_dump_index): Rename TDI_all to TDI_tu. Update all users. Add new index TDI_all. (TDF_DETAILS): Change value. (TDF_REFS): Remove. Update all users. (TDF_RDEFS): Remove. Update all users. (TDF_BLOCK): Define. * doc/invoke.texi: Update documentation for -fdump-tree-... flags. Index: c-call-graph.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/Attic/c-call-graph.c,v retrieving revision 1.1.4.6 diff -d -u -p -r1.1.4.6 c-call-graph.c --- c-call-graph.c 18 Oct 2002 03:36:38 -0000 1.1.4.6 +++ c-call-graph.c 5 Nov 2002 22:16:54 -0000 @@ -118,7 +118,7 @@ construct_call_graph (buffer, t, spc) /* Statements based statistics. */ INDENT (spc+1); - output_printf (buffer, "next_bb = EXIT_BLOCK_PTR; EXIT_BLOCK_PTR->prev_bb = ENTRY_BLOCK_PTR; @@ -138,6 +140,9 @@ build_tree_cfg (fnbody) /* Adjust the size of the array. */ VARRAY_GROW (basic_block_info, n_basic_blocks); + /* Create block annotations. */ + create_block_annotations (); + /* Create the edges of the flowgraph. */ make_edges (); @@ -153,7 +158,7 @@ build_tree_cfg (fnbody) dump_file = dump_begin (TDI_cfg, &dump_flags); if (dump_file) { - dump_tree_cfg (dump_file, dump_flags & TDF_DETAILS); + dump_tree_cfg (dump_file, dump_flags); dump_end (TDI_cfg, dump_file); } } @@ -339,17 +344,13 @@ create_bb (head_p, parent_block) basic_block bb; /* Create and initialize a new basic block. */ - bb = (basic_block) ggc_alloc (sizeof (*bb)); + bb = alloc_block (); memset (bb, 0, sizeof (*bb)); bb->head_tree_p = bb->end_tree_p = head_p; bb->index = last_basic_block; bb->flags = BB_NEW; - /* Create annotations for the block. */ - create_bb_ann (bb); - set_parent_block (bb, parent_block); - /* Add the new block to the linked list of blocks. */ if (n_basic_blocks > 0) link_block (bb, BASIC_BLOCK (n_basic_blocks - 1)); @@ -358,10 +359,14 @@ create_bb (head_p, parent_block) /* Grow the basic block array if needed. */ if ((size_t) n_basic_blocks == VARRAY_SIZE (basic_block_info)) - VARRAY_GROW (basic_block_info, n_basic_blocks + (n_basic_blocks + 3) / 4); + { + VARRAY_GROW (basic_block_info, n_basic_blocks + (n_basic_blocks + 3) / 4); + VARRAY_GROW (parent_array, n_basic_blocks + (n_basic_blocks + 3) / 4); + } /* Add the newly created block to the array. */ BASIC_BLOCK (n_basic_blocks) = bb; + VARRAY_BB (parent_array, n_basic_blocks) = parent_block; n_basic_blocks++; last_basic_block++; @@ -400,18 +405,25 @@ set_bb_for_stmt (t, bb) } -/* Create a new annotation for basic block BB. */ +/* Create annotations for all the blocks in the flowgraph. */ -bb_ann -create_bb_ann (bb) - basic_block bb; +static void +create_block_annotations () { - bb_ann ann = (bb_ann) ggc_alloc (sizeof (*ann)); - memset ((void *) ann, 0, sizeof (*ann)); - ann->refs = create_ref_list (); - bb->aux = (void *) ann; + basic_block bb; + int i; - return ann; + alloc_aux_for_blocks (sizeof (struct bb_ann_d)); + + /* Set parent block information for each block. */ + i = 0; + FOR_EACH_BB (bb) + { + bb_ann ann = (bb_ann)bb->aux; + ann->refs = create_ref_list (); + ann->parent_block = VARRAY_BB (parent_array, i); + i++; + } } @@ -767,19 +779,16 @@ remove_tree_bb (bb, remove_stmts) for (i = gsi_start_bb (bb); !gsi_after_end (i); gsi_step_bb (&i)) { tree stmt = gsi_stmt (i); - STRIP_WFL (stmt); - STRIP_NOPS (stmt); - - if (remove_stmts) - gsi_remove (i); - else - set_bb_for_stmt (stmt, NULL); if (dump_file && is_exec_stmt (gsi_stmt (i))) { fprintf (dump_file, "WARNING: Removing executable statement: "); - print_generic_node (dump_file, gsi_stmt (i), PPF_BRIEF); + print_generic_stmt (dump_file, gsi_stmt (i), dump_flags|TDF_SLIM); } + + set_bb_for_stmt (stmt, NULL); + if (remove_stmts) + gsi_remove (i); } /* Remove the edges into and out of this block. */ @@ -1305,7 +1314,7 @@ dump_tree_bb (outf, prefix, bb, indent) if (head) { lineno = get_lineno (head); - print_generic_node (outf, head, PPF_BRIEF|PPF_IS_STMT); + print_generic_stmt (outf, head, TDF_SLIM); fprintf (outf, " (line: %d)\n", lineno); } else @@ -1315,7 +1324,7 @@ dump_tree_bb (outf, prefix, bb, indent) if (end) { lineno = get_lineno (end); - print_generic_node (outf, end, PPF_BRIEF|PPF_IS_STMT); + print_generic_stmt (outf, end, TDF_SLIM); fprintf (outf, " (line: %d)\n", lineno); } else @@ -1353,29 +1362,29 @@ debug_tree_bb (bb) } -/* Dump the CFG on stderr. If DETAILS is nonzero, a textual representation - of each basic block is also produced. */ +/* Dump the CFG on stderr. FLAGS are the same used by the tree dumping + functions (see TDF_* in tree.h). */ void -debug_tree_cfg (details) - int details; +debug_tree_cfg (flags) + int flags; { - dump_tree_cfg (stderr, details); + dump_tree_cfg (stderr, flags); } -/* Dump the program showing basic block boundaries on the given FILE. If - DETAILS is set, a textual representation of every basic block will also - be dumped. */ +/* Dump the program showing basic block boundaries on the given FILE. + FLAGS are the same used by the tree dumping functions (see TDF_* in + tree.h). */ void -dump_tree_cfg (file, details) +dump_tree_cfg (file, flags) FILE *file; - int details; + int flags; { basic_block bb; - if (details) + if (flags & TDF_DETAILS) { fputc ('\n', file); fprintf (file, "Function %s\n\n", get_name (current_function_decl)); @@ -1390,7 +1399,8 @@ dump_tree_cfg (file, details) } fprintf (file, "%s()\n", get_name (current_function_decl)); - print_generic_tree (file, DECL_SAVED_TREE (current_function_decl), PPF_BLOCK); + print_generic_stmt (file, DECL_SAVED_TREE (current_function_decl), + flags|TDF_BLOCK); fprintf (file, "\n"); } @@ -1614,18 +1624,17 @@ stmt_starts_bb_p (t) void delete_tree_cfg () { - basic_block bb; - if (basic_block_info == NULL) return; - FOR_EACH_BB (bb) - bb->aux = NULL; + if (n_basic_blocks > 0) + { + free_aux_for_blocks (); + clear_edges (); + } - ENTRY_BLOCK_PTR->aux = NULL; - EXIT_BLOCK_PTR->aux = NULL; - clear_edges (); VARRAY_FREE (basic_block_info); + VARRAY_FREE (parent_array); } Index: tree-dfa.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/Attic/tree-dfa.c,v retrieving revision 1.1.4.39 diff -d -u -p -r1.1.4.39 tree-dfa.c --- tree-dfa.c 2 Nov 2002 04:30:54 -0000 1.1.4.39 +++ tree-dfa.c 5 Nov 2002 22:16:56 -0000 @@ -1135,14 +1135,14 @@ dump_ref (outf, prefix, ref, indent, det fprintf (outf, "%s%s%s(", s_indent, prefix, type); if (ref_var (ref)) - print_generic_node (outf, ref_var (ref), 0); + print_generic_expr (outf, ref_var (ref), 0); else fprintf (outf, "nil"); fprintf (outf, "): line %d, bb %d, id %lu, ", lineno, bbix, ref_id (ref)); if (ref_expr (ref)) - print_generic_node (outf, ref_expr (ref), 0); + print_generic_expr (outf, ref_expr (ref), 0); else fprintf (outf, ""); @@ -1319,7 +1319,7 @@ dump_variable (file, var) size_t num; fprintf (file, "Variable: "); - print_generic_node (file, var, 0); + print_generic_expr (file, var, 0); num = num_may_alias (var); if (num > 0) @@ -1330,7 +1330,7 @@ dump_variable (file, var) for (i = 0; i < num; i++) { - print_generic_node (file, may_alias (var, i), 0); + print_generic_expr (file, may_alias (var, i), 0); if (i < num - 1) fprintf (file, ", "); } Index: tree-dump.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/tree-dump.c,v retrieving revision 1.6.2.13 diff -d -u -p -r1.6.2.13 tree-dump.c --- tree-dump.c 11 Oct 2002 23:55:00 -0000 1.6.2.13 +++ tree-dump.c 5 Nov 2002 22:16:56 -0000 @@ -34,6 +34,7 @@ static void dequeue_and_dump PARAMS ((du static void dump_new_line PARAMS ((dump_info_p)); static void dump_maybe_newline PARAMS ((dump_info_p)); static void dump_string_field PARAMS ((dump_info_p, const char *, const char *)); +static void dump_enable_all PARAMS ((int)); /* Add T to the end of the queue of nodes to dump. Returns the index assigned to T. */ @@ -669,6 +670,7 @@ static struct dump_file_info dump_files[ {".dce", "dump-tree-dce", 0, 0}, {".optimized", "dump-tree-optimized", 0, 0}, {".xml", "dump-call-graph", 0, 0}, + {NULL, "dump-tree-all", 0, 0}, }; /* Define a name->number mapping for a dump flag value. */ @@ -686,9 +688,8 @@ static const struct dump_option_value_in {"slim", TDF_SLIM}, {"raw", TDF_RAW}, {"details", TDF_DETAILS}, - {"refs", TDF_REFS}, - {"rdefs", TDF_RDEFS}, {"stats", TDF_STATS}, + {"block", TDF_BLOCK}, {"all", ~0}, {NULL, 0} }; @@ -755,20 +756,23 @@ dump_end (phase, stream) fclose (stream); } -/* Enable all SSA-related tree dumps. */ +/* Enable all tree dumps. */ -void -dump_enable_all_ssa () +static void +dump_enable_all (flags) + int flags; { - dump_files[TDI_original].state = -1; - dump_files[TDI_optimized].state = -1; - dump_files[TDI_cfg].state = -1; - dump_files[TDI_dot].state = -1; - dump_files[TDI_pre].state = -1; - dump_files[TDI_ccp].state = -1; - dump_files[TDI_dce].state = -1; - dump_files[TDI_ssa].state = -1; - dump_files[TDI_simple].state = -1; + enum tree_dump_index i; + + for (i = TDI_tu; i < TDI_end; i++) + { + dump_files[i].state = -1; + dump_files[i].flags = flags; + } + + /* FIXME -fdump-call-graph is broken. */ + dump_files[TDI_xml].state = 0; + dump_files[TDI_xml].flags = 0; } /* Parse ARG as a dump switch. Return nonzero if it is, and store the @@ -793,6 +797,7 @@ dump_switch_p (arg) best = ix; bestlen = strlen (option_value); } + if (best >= 0) { if ((option_value = skip_leading_substring (arg, dump_files[best].swtch))) @@ -829,9 +834,14 @@ dump_switch_p (arg) dump_files[best].state = -1; dump_files[best].flags = flags; + + /* Process -fdump-tree-all by enabling all the known dumps. */ + if (dump_files[best].suffix == NULL) + dump_enable_all (dump_files[best].flags); return 1; } } + return 0; } Index: tree-flow-inline.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/Attic/tree-flow-inline.h,v retrieving revision 1.1.2.9 diff -d -u -p -r1.1.2.9 tree-flow-inline.h --- tree-flow-inline.h 26 Oct 2002 20:37:07 -0000 1.1.2.9 +++ tree-flow-inline.h 5 Nov 2002 22:16:56 -0000 @@ -284,6 +284,22 @@ get_lineno (expr) return -1; } +static inline const char * +get_filename (expr) + tree expr; +{ + if (expr == NULL_TREE) + return "???"; + + if (TREE_CODE (expr) == COMPOUND_EXPR) + expr = TREE_OPERAND (expr, 0); + + if (TREE_CODE (expr) == EXPR_WITH_FILE_LOCATION) + return EXPR_WFL_FILENAME (expr); + else + return "???"; +} + static inline tree_ref output_ref (t) tree t; @@ -649,7 +665,7 @@ static inline bool is_exec_stmt (t) tree t; { - return (t && t != empty_stmt_node); + return (t && t != empty_stmt_node && t != error_mark_node); } static inline bool Index: tree-flow.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/Attic/tree-flow.h,v retrieving revision 1.1.4.31 diff -d -u -p -r1.1.4.31 tree-flow.h --- tree-flow.h 2 Nov 2002 04:30:54 -0000 1.1.4.31 +++ tree-flow.h 5 Nov 2002 22:16:56 -0000 @@ -192,7 +192,7 @@ struct var_ref_d GTY(()) reference. This array is setup so that the Ith entry corresponds to the Ith alias of the variable associated to this reference (i.e., this is the Ith entry of the array MAY_ALIASES in struct tree_ann_d). */ - union tree_ref_d ** GTY((skip (""))) alias_imm_rdefs; + union tree_ref_d ** GTY((length ("VARRAY_SIZE (%h.common.var->common.ann->may_aliases)"))) alias_imm_rdefs; }; /* Variable definitions. */ @@ -534,23 +534,24 @@ static inline void set_indirect_var PARA static inline tree may_alias PARAMS ((tree, size_t)); static inline size_t num_may_alias PARAMS ((tree)); static inline int get_lineno PARAMS ((tree)); +static inline const char *get_filename PARAMS ((tree)); static inline bool is_exec_stmt PARAMS ((tree)); /*--------------------------------------------------------------------------- Block annotations stored in basic_block.aux ---------------------------------------------------------------------------*/ -struct bb_ann_def GTY(()) +struct bb_ann_d { /* Control flow parent. This is the entry block to the control structure to which this block belongs to. */ - basic_block GTY((skip (""))) parent_block; + basic_block parent_block; /* List of references made in this block. */ ref_list refs; }; -typedef struct bb_ann_def *bb_ann; +typedef struct bb_ann_d *bb_ann; /* Accessors for basic block annotations. */ static inline bb_ann bb_annotation PARAMS ((basic_block)); @@ -615,13 +616,13 @@ extern void rli_delete PARAMS ((ref_li extern int tree_warn_uninitialized; /* Array of all variables referenced in the function. */ -extern varray_type referenced_vars; +extern GTY(()) varray_type referenced_vars; /* Next unique reference ID to be assigned by create_ref(). */ extern unsigned long next_tree_ref_id; /* Artificial variable used to model the effects of function calls. */ -extern tree global_var; +extern GTY(()) tree global_var; /* Accessors for the referenced_vars array. */ extern unsigned long num_referenced_vars; @@ -645,7 +646,6 @@ extern bool is_computed_goto PARAMS ((t extern tree loop_body PARAMS ((tree)); extern void set_loop_body PARAMS ((tree, tree)); extern bool stmt_starts_bb_p PARAMS ((tree)); -extern bb_ann create_bb_ann PARAMS ((basic_block)); extern void dump_tree_bb PARAMS ((FILE *, const char *, basic_block, int)); extern void debug_tree_bb PARAMS ((basic_block)); Index: tree-mudflap.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/Attic/tree-mudflap.c,v retrieving revision 1.1.2.20 diff -d -u -p -r1.1.2.20 tree-mudflap.c --- tree-mudflap.c 26 Oct 2002 20:37:07 -0000 1.1.2.20 +++ tree-mudflap.c 5 Nov 2002 22:16:56 -0000 @@ -84,13 +84,13 @@ mudflap_c_function (t) if (getenv ("UNPARSE")) /* XXX */ { - print_generic_tree (stderr, DECL_RESULT (t), 0); + print_generic_expr (stderr, DECL_RESULT (t), 0); fprintf (stderr, " "); - print_generic_tree (stderr, DECL_NAME (t), 0); + print_generic_expr (stderr, DECL_NAME (t), 0); fprintf (stderr, " ("); - print_generic_tree (stderr, DECL_ARGUMENTS (t), 0); + print_generic_expr (stderr, DECL_ARGUMENTS (t), 0); fprintf (stderr, " )\n"); - print_generic_tree (stderr, DECL_SAVED_TREE (t), 0); + print_generic_stmt (stderr, DECL_SAVED_TREE (t), 0); } mf_init_extern_trees (); @@ -101,7 +101,7 @@ mudflap_c_function (t) if (getenv ("UNPARSE")) /* XXX */ { fprintf (stderr, "/* after -fmudflap: */\n"); - print_generic_tree (stderr, DECL_SAVED_TREE (t), 0); + print_generic_stmt (stderr, DECL_SAVED_TREE (t), 0); } } @@ -137,7 +137,7 @@ mudflap_enqueue_decl (obj, label) /* fprintf (stderr, "enqueue_decl obj=`"); - print_generic_tree (stderr, obj, 0); + print_generic_expr (stderr, obj, 0); fprintf (stderr, "' label=`%s'\n", label); */ @@ -733,7 +733,7 @@ mx_xfn_indirect_ref (t, continue_p, data #if 0 fprintf (stderr, "expr=%s: ", tree_code_name [TREE_CODE (*t)]); - print_generic_tree (stderr, *t, 0); + print_generic_expr (stderr, *t, 0); fprintf (stderr, "\n"); #endif @@ -830,7 +830,7 @@ mx_xfn_indirect_ref (t, continue_p, data #if 0 warning ("mudflap is omitting array bounds checks"); fprintf (stderr, " for expression: "); - print_generic_tree (stderr, *t, 0); + print_generic_expr (stderr, *t, 0); fprintf (stderr, " array-size=%u", int_size_in_bytes (TREE_TYPE (base_array))); fprintf (stderr, " check-size=%u", TREE_INT_CST_LOW (check_size)); fprintf (stderr, "\n"); @@ -1164,9 +1164,9 @@ mx_xfn_find_addrof (t, continue_p, data) if (gotit != NULL) { fprintf (stderr, "matched decl="); - print_generic_tree (stderr, decl, 0); + print_generic_expr (stderr, decl, 0); fprintf (stderr, " in tree="); - print_generic_tree (stderr, gotit, 0); + print_generic_expr (stderr, gotit, 0); fprintf (stderr, "\n"); } #endif Index: tree-optimize.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/Attic/tree-optimize.c,v retrieving revision 1.1.4.19 diff -d -u -p -r1.1.4.19 tree-optimize.c --- tree-optimize.c 26 Oct 2002 20:37:07 -0000 1.1.4.19 +++ tree-optimize.c 5 Nov 2002 22:16:56 -0000 @@ -99,10 +99,6 @@ optimize_function_tree (fndecl) double_chain_free (fnbody); #endif - /* Flush out flow graph and SSA data. */ - delete_tree_ssa (fnbody); - delete_tree_cfg (); - /* Debugging dump after optimization. */ dump_file = dump_begin (TDI_optimized, &dump_flags); if (dump_file) @@ -114,9 +110,13 @@ optimize_function_tree (fndecl) if (dump_flags & TDF_RAW) dump_node (fnbody, TDF_SLIM | dump_flags, dump_file); else - print_generic_tree (dump_file, fnbody, 0); + print_generic_stmt (dump_file, fnbody, dump_flags); fprintf (dump_file, "\n"); dump_end (TDI_optimized, dump_file); } + + /* Flush out flow graph and SSA data. */ + delete_tree_ssa (fnbody); + delete_tree_cfg (); } Index: tree-pretty-print.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/Attic/tree-pretty-print.c,v retrieving revision 1.1.2.3 diff -d -u -p -r1.1.2.3 tree-pretty-print.c --- tree-pretty-print.c 26 Oct 2002 20:37:07 -0000 1.1.2.3 +++ tree-pretty-print.c 5 Nov 2002 22:16:56 -0000 @@ -28,14 +28,6 @@ Software Foundation, 59 Temple Place - S #include "hashtab.h" #include "tree-flow.h" -/* Modifier flags for print_generic_* functions. See diagnostic.h for - documentation. */ -const int PPF_BRIEF = 1 << 0; -const int PPF_BLOCK = 1 << 1; -const int PPF_LINENO = 1 << 2; -const int PPF_IS_STMT = 1 << 3; - - /* Local functions, macros and variables. */ static int op_prio PARAMS ((tree)); static const char *op_symbol PARAMS ((tree)); @@ -67,44 +59,46 @@ static void dump_block_info PARAMS ((o static output_buffer buffer; static int initialized = 0; -static int last_bb = -1; +static int last_bb; +static bool dumping_stmts; -/* Print the tree T, and its successors, on file FILE. FLAGS specifies details - to show in the dump. See PPF_* in diagnostic.h. */ +/* Print tree T, and its successors, on file FILE. FLAGS specifies details + to show in the dump. See TDF_* in tree.h. */ void -print_generic_tree (file, t, flags) +print_generic_stmt (file, t, flags) FILE *file; tree t; int flags; { maybe_init_pretty_print (); - last_bb = -1; - dump_generic_node (&buffer, t, 0, flags | PPF_IS_STMT); + dumping_stmts = true; + dump_generic_node (&buffer, t, 0, flags); fprintf (file, "%s", output_finalize_message (&buffer)); output_clear_message_text (&buffer); } -/* Print a single node T on file FILE. FLAGS specifies details to show in the - dump. See PPF_* in diagnostic.h. */ +/* Print a single expression T on file FILE. FLAGS specifies details to show + in the dump. See TDF_* in tree.h. */ void -print_generic_node (file, t, flags) +print_generic_expr (file, t, flags) FILE *file; tree t; int flags; { maybe_init_pretty_print (); - last_bb = -1; + dumping_stmts = false; dump_generic_node (&buffer, t, 0, flags); fprintf (file, "%s", output_finalize_message (&buffer)); output_clear_message_text (&buffer); } -/* Dump the node NODE on the output_buffer BUFFER, SPC spaces of indent. */ +/* Dump the node NODE on the output_buffer BUFFER, SPC spaces of indent. + FLAGS specifies details to show in the dump (see TDF_* in tree.h). */ int dump_generic_node (buffer, node, spc, flags) @@ -120,7 +114,7 @@ dump_generic_node (buffer, node, spc, fl if (node == NULL_TREE) return spc; - if ((flags & PPF_BLOCK) + if ((flags & TDF_BLOCK) && node != empty_stmt_node && node != error_mark_node) dump_block_info (buffer, bb_for_stmt (node), spc); @@ -575,10 +569,10 @@ dump_generic_node (buffer, node, spc, fl break; case COMPOUND_EXPR: - if (flags & PPF_IS_STMT) + if (dumping_stmts) { dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags); - if (!(flags & PPF_BRIEF)) + if (!(flags & TDF_SLIM)) { output_add_character (buffer, ';'); newline_and_indent (buffer, spc); @@ -616,7 +610,7 @@ dump_generic_node (buffer, node, spc, fl output_add_string (buffer, "if ("); dump_generic_node (buffer, COND_EXPR_COND (node), spc, flags); output_add_character (buffer, ')'); - if (!(flags & PPF_BRIEF)) + if (!(flags & TDF_SLIM)) { if (COND_EXPR_THEN (node) == empty_stmt_node) { @@ -662,7 +656,7 @@ dump_generic_node (buffer, node, spc, fl case BIND_EXPR: output_add_character (buffer, '{'); - if (!(flags & PPF_BRIEF)) + if (!(flags & TDF_SLIM)) { if (BIND_EXPR_VARS (node)) { @@ -1009,7 +1003,7 @@ dump_generic_node (buffer, node, spc, fl } dump_generic_node (buffer, LABELED_BLOCK_LABEL (node), spc, flags); output_add_string (buffer, ": {"); - if (!(flags & PPF_BRIEF)) + if (!(flags & TDF_SLIM)) newline_and_indent (buffer, spc+2); dump_generic_node (buffer, LABELED_BLOCK_BODY (node), spc+2, flags); if (!flags) @@ -1045,7 +1039,7 @@ dump_generic_node (buffer, node, spc, fl case LOOP_EXPR: output_add_string (buffer, "while (1)"); - if (!(flags & PPF_BRIEF)) + if (!(flags & TDF_SLIM)) { newline_and_indent (buffer, spc+2); output_add_character (buffer, '{'); @@ -1059,7 +1053,7 @@ dump_generic_node (buffer, node, spc, fl flowgraph information, we should show them to avoid confusing the user. This perhaps should be fixed by actually inserting an empty statement at the end of LOOP_EXPRs. */ - if ((flags & PPF_BLOCK) && bb_for_stmt (node)) + if ((flags & TDF_BLOCK) && bb_for_stmt (node)) { newline_and_indent (buffer, spc); dump_block_info (buffer, latch_block (bb_for_stmt (node)), spc); @@ -1091,7 +1085,7 @@ dump_generic_node (buffer, node, spc, fl output_add_string (buffer, "switch ("); dump_generic_node (buffer, SWITCH_COND (node), spc, flags); output_add_character (buffer, ')'); - if (!(flags & PPF_BRIEF)) + if (!(flags & TDF_SLIM)) { newline_and_indent (buffer, spc+2); output_add_character (buffer, '{'); @@ -1136,7 +1130,7 @@ dump_generic_node (buffer, node, spc, fl dump_generic_node (buffer, ASM_CLOBBERS (node), spc, flags); } output_add_string (buffer, ");"); - if (!(flags & PPF_BRIEF)) + if (!(flags & TDF_SLIM)) output_add_newline (buffer); break; @@ -1246,7 +1240,7 @@ print_declaration (buffer, t, spc, flags } output_add_character (buffer, ';'); - if (!(flags & PPF_BRIEF)) + if (!(flags & TDF_SLIM)) output_add_newline (buffer); } @@ -1733,6 +1727,8 @@ pretty_print_string (buffer, str) static void maybe_init_pretty_print () { + last_bb = -1; + if (!initialized) { init_output_buffer (&buffer, /* prefix */NULL, /* line-width */0); @@ -1759,8 +1755,20 @@ dump_block_info (buffer, bb, spc) if (bb && bb->index != last_bb) { edge e; + tree *stmt_p = bb->head_tree_p; + int lineno; output_formatted_scalar (buffer, "# BLOCK %d", bb->index); + + if (stmt_p + && is_exec_stmt (*stmt_p) + && (lineno = get_lineno (*stmt_p)) > 0) + { + output_add_string (buffer, " ("); + output_add_string (buffer, get_filename (*stmt_p)); + output_formatted_scalar (buffer, ":%d", lineno); + output_add_string (buffer, ")"); + } output_add_string (buffer, ". PRED:"); for (e = bb->pred; e; e = e->pred_next) Index: tree-ssa-ccp.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-ccp.c,v retrieving revision 1.1.2.28 diff -d -u -p -r1.1.2.28 tree-ssa-ccp.c --- tree-ssa-ccp.c 2 Nov 2002 04:30:54 -0000 1.1.2.28 +++ tree-ssa-ccp.c 5 Nov 2002 22:16:56 -0000 @@ -167,7 +167,7 @@ tree_ssa_ccp (fndecl) if (dump_flags & TDF_RAW) dump_node (fnbody, TDF_SLIM | dump_flags, dump_file); else - print_generic_tree (dump_file, fnbody, PPF_BLOCK); + print_generic_stmt (dump_file, fnbody, dump_flags); fprintf (dump_file, "\n"); dump_end (TDI_ccp, dump_file); @@ -309,7 +309,7 @@ substitute_and_fold () if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, "Line %d: replaced ", get_lineno (expr)); - print_generic_node (dump_file, expr, 0); + print_generic_stmt (dump_file, expr, TDF_SLIM); } replace_uses_in (expr); @@ -320,7 +320,7 @@ substitute_and_fold () if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, " with "); - print_generic_node (dump_file, new_expr, 0); + print_generic_stmt (dump_file, new_expr, TDF_SLIM); fprintf (dump_file, "\n"); } } @@ -480,7 +480,7 @@ visit_expression_for (ref) if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, "\nVisiting expression: "); - print_generic_node (dump_file, expr, 0); + print_generic_expr (dump_file, expr, 0); dump_ref (dump_file, "\nfor reference: ", ref, 0, 0); } @@ -669,12 +669,12 @@ evaluate_expr (expr) if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, "Expression evaluates to "); - print_generic_node (dump_file, expr, 0); + print_generic_expr (dump_file, expr, 0); fprintf (dump_file, " which is "); if (val.lattice_val == CONSTANT) { fprintf (dump_file, "constant "); - print_generic_node (dump_file, simplified, 0); + print_generic_expr (dump_file, simplified, 0); } else if (val.lattice_val == VARYING) fprintf (dump_file, "not a constant"); @@ -705,7 +705,7 @@ dump_lattice_value (outf, prefix, val) else { fprintf (outf, "%sCONSTANT ", prefix); - print_generic_node (outf, val.const_value, 0); + print_generic_expr (outf, val.const_value, 0); } } @@ -917,7 +917,7 @@ set_lattice_value (def, val) if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, "Lattice value changed to "); - print_generic_node (dump_file, val.const_value, 0); + print_generic_expr (dump_file, val.const_value, 0); fprintf (dump_file, ". Adding definition to SSA edges.\n"); } Index: tree-ssa-dce.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-dce.c,v retrieving revision 1.1.2.10 diff -d -u -p -r1.1.2.10 tree-ssa-dce.c --- tree-ssa-dce.c 26 Oct 2002 20:37:07 -0000 1.1.2.10 +++ tree-ssa-dce.c 5 Nov 2002 22:16:56 -0000 @@ -152,7 +152,7 @@ tree_ssa_eliminate_dead_code (fndecl) if (dump_flags & TDF_RAW) dump_node (fnbody, TDF_SLIM | dump_flags, dump_file); else - print_generic_tree (dump_file, fnbody, 0); + print_generic_stmt (dump_file, fnbody, dump_flags); fprintf (dump_file, "Finding obviously useful instructions:\n"); } @@ -282,7 +282,7 @@ tree_ssa_eliminate_dead_code (fndecl) if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, "Warning: removing "); - print_generic_node (dump_file, t, PPF_IS_STMT); + print_generic_stmt (dump_file, t, TDF_SLIM); } stats.removed++; @@ -312,7 +312,7 @@ tree_ssa_eliminate_dead_code (fndecl) if (dump_flags & TDF_RAW) dump_node (fnbody, TDF_SLIM | dump_flags, dump_file); else - print_generic_tree (dump_file, fnbody, 0); + print_generic_stmt (dump_file, fnbody, dump_flags); print_stats (); Index: tree-ssa-pre.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-pre.c,v retrieving revision 1.1.4.30 diff -d -u -p -r1.1.4.30 tree-ssa-pre.c --- tree-ssa-pre.c 26 Oct 2002 20:37:07 -0000 1.1.4.30 +++ tree-ssa-pre.c 5 Nov 2002 22:16:57 -0000 @@ -1490,12 +1490,12 @@ finalize_1 (ei, temp) { fprintf (dump_file, "In BB %d, insert save of ", ref_bb (X)->index); - print_generic_tree (dump_file, ei->expr, 0); + print_generic_expr (dump_file, ei->expr, 0); fprintf (dump_file, " to "); - print_generic_tree (dump_file, temp, 0); + print_generic_expr (dump_file, temp, 0); fprintf (dump_file, " after "); - print_generic_node (dump_file, last_stmt (ref_bb (X)), - PPF_IS_STMT); + print_generic_stmt (dump_file, last_stmt (ref_bb (X)), + dump_flags); fprintf (dump_file, " (at end of BB), because of ExprPhi"); fprintf (dump_file, " in BB %d\n", @@ -1953,7 +1953,7 @@ calculate_increment (ei, expr) if (dump_file) { fprintf (dump_file, "Increment calculated to be: "); - print_generic_tree (dump_file, incr, 0); + print_generic_expr (dump_file, incr, 0); fprintf (dump_file, "\n"); } #endif @@ -2022,7 +2022,7 @@ repair_injury (ei, use, temp, orig_euse) if (dump_file) { fprintf (dump_file, "Injuring def to repair is: "); - print_generic_tree (dump_file, ref_expr (v), 0); + print_generic_expr (dump_file, ref_expr (v), 0); fprintf (dump_file, "\n"); } #endif @@ -2389,11 +2389,11 @@ code_motion (ei, temp) { fprintf (dump_file, "In BB %d, insert save of ", use_bb->index); - print_generic_tree (dump_file, ei->expr, 0); + print_generic_expr (dump_file, ei->expr, 0); fprintf (dump_file, " to "); - print_generic_tree (dump_file, temp, 0); + print_generic_expr (dump_file, temp, 0); fprintf (dump_file, " before statement "); - print_generic_tree (dump_file,TREE_OPERAND (use_stmt, 0), 0); + print_generic_expr (dump_file,TREE_OPERAND (use_stmt, 0), 0); fprintf (dump_file, " on line %d\n", EXPR_WFL_LINENO (use_expr)); } @@ -2467,11 +2467,11 @@ code_motion (ei, temp) { fprintf (dump_file, "In BB %d, insert reload of ", use_bb->index); - print_generic_tree (dump_file, ei->expr, 0); + print_generic_expr (dump_file, ei->expr, 0); fprintf (dump_file, " from "); - print_generic_tree (dump_file, temp, 0); + print_generic_expr (dump_file, temp, 0); fprintf (dump_file, " in statement "); - print_generic_tree (dump_file, TREE_OPERAND (use_stmt, 0), 0); + print_generic_expr (dump_file, TREE_OPERAND (use_stmt, 0), 0); fprintf (dump_file, " on line %d\n", EXPR_WFL_LINENO (use_stmt)); } @@ -2648,7 +2648,7 @@ pre_part_1_trav (slot, data) if (dump_file) { fprintf (dump_file, "Occurrences for expression "); - print_generic_tree (dump_file, ei->expr, 0); + print_generic_expr (dump_file, ei->expr, 0); fprintf (dump_file, "\n"); dump_ref_array (dump_file, "", ei->refs, 0, 1); } @@ -2657,7 +2657,7 @@ pre_part_1_trav (slot, data) if (dump_file) { fprintf (dump_file, "ExprPhi's for expression "); - print_generic_tree (dump_file, ei->expr, 0); + print_generic_expr (dump_file, ei->expr, 0); fprintf (dump_file, "\n"); dump_ref_array (dump_file, "", ei->phis, 0, 1); } @@ -2865,7 +2865,7 @@ tree_perform_ssapre () if (dump_flags & TDF_RAW) dump_node (fn, TDF_SLIM | dump_flags, dump_file); else - print_generic_tree (dump_file, fn, 0); + print_generic_stmt (dump_file, fn, dump_flags); dump_end (TDI_pre, dump_file); } Index: tree-ssa.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa.c,v retrieving revision 1.1.4.27 diff -d -u -p -r1.1.4.27 tree-ssa.c --- tree-ssa.c 31 Oct 2002 19:47:04 -0000 1.1.4.27 +++ tree-ssa.c 5 Nov 2002 22:16:57 -0000 @@ -221,16 +221,14 @@ build_tree_ssa (fndecl) /* FIXME Default dump should be the pretty-printed function with SSA indices. */ if (tree_ssa_dump_flags & (TDF_DETAILS)) - dump_tree_ssa (tree_ssa_dump_file); + { + dump_referenced_vars (tree_ssa_dump_file); + dump_tree_ssa (tree_ssa_dump_file); + dump_reaching_defs (tree_ssa_dump_file); + } if (tree_ssa_dump_flags & TDF_STATS) dump_dfa_stats (tree_ssa_dump_file); - - if (tree_ssa_dump_flags & TDF_REFS) - dump_referenced_vars (tree_ssa_dump_file); - - if (tree_ssa_dump_flags & TDF_RDEFS) - dump_reaching_defs (tree_ssa_dump_file); dump_end (TDI_ssa, tree_ssa_dump_file); } Index: tree.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/tree.h,v retrieving revision 1.342.2.24 diff -d -u -p -r1.342.2.24 tree.h --- tree.h 1 Nov 2002 18:40:17 -0000 1.342.2.24 +++ tree.h 5 Nov 2002 22:16:57 -0000 @@ -3201,8 +3201,8 @@ typedef tree (*walk_tree_fn) PARAMS ((t extend the DUMP_FILES array in tree-dump.c */ enum tree_dump_index { - TDI_all, /* dump the whole translation unit */ - TDI_class, /* dump class hierarchy */ + TDI_tu, /* dump the whole translation unit. */ + TDI_class, /* dump class hierarchy. */ TDI_inlined, /* dump each function after inlining within it. */ TDI_original, /* dump each function before optimizing it */ @@ -3218,8 +3218,9 @@ enum tree_dump_index function. */ TDI_dce, /* dump SSA DCE information for each function. */ - TDI_optimized, /* dump each function after optimizing it */ - TDI_xml, /* dump function call graph. */ + TDI_optimized, /* dump each function after optimizing it. */ + TDI_xml, /* dump function call graph. */ + TDI_all, /* enable all the dumps above. */ TDI_end }; @@ -3229,12 +3230,12 @@ enum tree_dump_index #define TDF_ADDRESS (1 << 0) /* dump node addresses */ #define TDF_SLIM (1 << 1) /* don't go wild following links */ #define TDF_RAW (1 << 2) /* unparse the function */ -#define TDF_DETAILS (1 << 3) /* show how each statement is - simplified */ +#define TDF_DETAILS (1 << 3) /* show more detailed info about + each pass */ #define TDF_STATS (1 << 4) /* dump various statistics about each pass */ -#define TDF_REFS (1 << 0) /* dump ssa variable refs */ -#define TDF_RDEFS (1 << 1) /* dump reaching definitions */ +#define TDF_BLOCK (1 << 5) /* display basic block boundaries */ + typedef struct dump_info *dump_info_p; @@ -3244,11 +3245,10 @@ extern FILE *dump_begin PARAMS ((enum extern void dump_end PARAMS ((enum tree_dump_index, FILE *)); extern void dump_node PARAMS ((tree, int, FILE *)); extern int dump_switch_p PARAMS ((const char *)); -extern void dump_enable_all_ssa PARAMS ((void)); -const char *dump_flag_name PARAMS ((enum tree_dump_index)); +const char *dump_flag_name PARAMS ((enum tree_dump_index)); -extern int simplify_function_tree PARAMS ((tree)); -extern const char *get_name PARAMS ((tree)); +extern int simplify_function_tree PARAMS ((tree)); +extern const char *get_name PARAMS ((tree)); /* Redefine abort to report an internal error w/o coredump, and reporting the location of the error in the source file. This logic Index: doc/invoke.texi =================================================================== RCS file: /cvs/gcc/gcc/gcc/doc/invoke.texi,v retrieving revision 1.152.2.21 diff -d -u -p -r1.152.2.21 invoke.texi --- doc/invoke.texi 22 Oct 2002 18:28:51 -0000 1.152.2.21 +++ doc/invoke.texi 5 Nov 2002 22:16:59 -0000 @@ -3232,19 +3232,19 @@ changes according to the environment and is for tying up a dump file with a debug environment. @item slim Inhibit dumping of members of a scope or body of a function merely -because that scope has been reached. Only dump such items when they -are directly reachable by some other path. -@item refs -Print the list of references made to each variable in the program. -@item rdefs -Print the list of reaching definitions for each variable used in the program. +because that scope has been reached. Only dump such items when they +are directly reachable by some other path. When dumping pretty-printed +trees, this option inhibits dumping the bodies of control structures. @item raw -Print a raw representation of the tree. +Print a raw representation of the tree. By default, trees are +pretty-printed into a C-like representation. @item details Enable more detailed dumps (not honored by every dump option). @item stats Enable dumping various statistics about the pass (not honored by every dump option). +@item block +Enable showing basic block boundaries (disabled in raw dumps). @item all Turn on all options. @end table @@ -3295,11 +3295,11 @@ by appending @file{.pre} to the source f @opindex fdump-tree-dce Dump each function before and after DCE. The file name is made by appending @file{.dce} to the source file name. -@end table -@item -fdump-tree-all-ssa @r{(C and C++ only)} -@opindex fdump-tree-all-ssa @r{(C and C++ only)} -Enable all SSA-related dumps described above. +@item all +@opindex fdump-tree-all +Enable all the available tree dumps with the flags provided in this option. +@end table @item -fsched-verbose=@var{n} @opindex fsched-verbose