aboutsummaryrefslogtreecommitdiff
path: root/gcc/toplev.c
diff options
context:
space:
mode:
authorJosef Zlomek <zlomekj@suse.cz>2004-02-06 21:03:45 +0100
committerJosef Zlomek <zlomek@gcc.gnu.org>2004-02-06 20:03:45 +0000
commit014a1138d6ff79eff9aea704d5e8ae3f58fef5d1 (patch)
treef57616e19dba86e71b7eabf273b9af5e97701906 /gcc/toplev.c
parent298c28a8f4e43c22d3ad390699192f2dfa8fca70 (diff)
downloadgcc-014a1138d6ff79eff9aea704d5e8ae3f58fef5d1.zip
gcc-014a1138d6ff79eff9aea704d5e8ae3f58fef5d1.tar.gz
gcc-014a1138d6ff79eff9aea704d5e8ae3f58fef5d1.tar.bz2
Josef Zlomek <zlomekj@suse.cz>
Josef Zlomek <zlomekj@suse.cz> * Makefile.in (var-tracking.o): New. * common.opt (fvar-tracking): New. * flags.h (flag_var_tracking): New. * gengtype.c (adjust_field_rtx_def): NOTE_INSN_VAR_LOCATION was added. * opts.c (common_handle_option): Add OPT_fvar_tracking. * print-rtl.c (print_rtx): NOTE_INSN_VAR_LOCATION was added. * rtl.c (note_insn_name): Likewise. * rtl.def (VAR_LOCATION): New. * rtl.h (NOTE_VAR_LOCATION): New. (NOTE_VAR_LOCATION_DECL): New. (NOTE_VAR_LOCATION_LOC): New. (enum insn_note): NOTE_INSN_VAR_LOCATION was added. (variable_tracking_main): New exported function. * timevar.def (TV_VAR_TRACKING): New. * toplev.c (enum dump_file_index): Added DFI_vartrack. (dump_file): "vartrack" was added (-dV). (flag_var_tracking): New. (f_options): "var-tracking" was added. (rest_of_handle_variable_tracking): New function. (rest_of_compilation): Run variable tracking. (process_options): If user has not specified flag_var_tracking set it according to optimize, debug_info_level and debug_hooks. * tree.h (frame_base_decl): New. * var-tracking.c: New file. * config/ia64/ia64.c (ia64_flag_var_tracking): New variable. (ia64_override_options): Set flags to run variable tracking in machine dependent reorg instead of toplev.c. (ia64_reorg): Run variable tracking if wanted. * doc/invoke.texi: Mention variable tracking in -dV, add and -fvar-tracking. * doc/passes.texi: Added variable tracking pass. Daniel Berlin <dberlin@dberlin.org> * debug.h (struct gcc_debug_hooks): Added var_location debug hook. * dbxout.c (dbx_debug_hooks): Likewise. (xcoff_debug): Likewise. * debug.c (do_nothing_debug_hooks): Likewise. * dwarf2out.c (dwarf2_debug_hooks): Likewise. * dwarfout.c (dwarf_debug_hooks): Likewise. * sdbout.c (sdb_debug_hooks): Likewise. * vmsdbgout.c (vmsdbg_debug_hooks): Likewise. * final.c (final_scan_insn): Call var_location debug hook for each NOTE_INSN_VAR_LOCATION. Co-Authored-By: Daniel Berlin <dberlin@dberlin.org> From-SVN: r77418
Diffstat (limited to 'gcc/toplev.c')
-rw-r--r--gcc/toplev.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 369ba5c..8330c89 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -158,6 +158,7 @@ static void rest_of_handle_reorder_blocks (tree, rtx);
#ifdef STACK_REGS
static void rest_of_handle_stack_regs (tree, rtx);
#endif
+static void rest_of_handle_variable_tracking (tree, rtx);
static void rest_of_handle_machine_reorg (tree, rtx);
#ifdef DELAY_SLOTS
static void rest_of_handle_delay_slots (tree, rtx);
@@ -289,6 +290,7 @@ enum dump_file_index
DFI_branch_target_load,
DFI_sched2,
DFI_stack,
+ DFI_vartrack,
DFI_mach,
DFI_dbr,
DFI_MAX
@@ -340,6 +342,7 @@ static struct dump_file_info dump_file[DFI_MAX] =
{ "btl", 'd', 1, 0, 0 }, /* Yes, duplicate enable switch. */
{ "sched2", 'R', 1, 0, 0 },
{ "stack", 'k', 1, 0, 0 },
+ { "vartrack", 'V', 1, 0, 0 }, /* Yes, duplicate enable switch. */
{ "mach", 'M', 1, 0, 0 },
{ "dbr", 'd', 0, 0, 0 },
};
@@ -965,6 +968,13 @@ int flag_tracer = 0;
int flag_unit_at_a_time = 0;
+/* Nonzero if we should track variables. When
+ flag_var_tracking == AUTODETECT_FLAG_VAR_TRACKING it will be set according
+ to optimize, debug_info_level and debug_hooks in process_options (). */
+
+#define AUTODETECT_FLAG_VAR_TRACKING 2
+int flag_var_tracking = AUTODETECT_FLAG_VAR_TRACKING;
+
/* Values of the -falign-* flags: how much to align labels in code.
0 means `use default', 1 means `don't align'.
For each variable, there is an _log variant which is the power
@@ -1145,7 +1155,8 @@ static const lang_independent_options f_options[] =
{"mem-report", &mem_report, 1 },
{ "trapv", &flag_trapv, 1 },
{ "wrapv", &flag_wrapv, 1 },
- { "new-ra", &flag_new_regalloc, 1 }
+ { "new-ra", &flag_new_regalloc, 1 },
+ { "var-tracking", &flag_var_tracking, 1}
};
/* Here is a table, controlled by the tm.h file, listing each -m switch
@@ -2148,6 +2159,18 @@ rest_of_handle_stack_regs (tree decl, rtx insns)
}
#endif
+/* Track the variables, ie. compute where the variable is stored at each position in function. */
+static void
+rest_of_handle_variable_tracking (tree decl, rtx insns)
+{
+ timevar_push (TV_VAR_TRACKING);
+ open_dump_file (DFI_vartrack, decl);
+
+ variable_tracking_main ();
+
+ close_dump_file (DFI_vartrack, print_rtl_with_bb, insns);
+ timevar_pop (TV_VAR_TRACKING);
+}
/* Machine independent reorg pass. */
static void
@@ -3562,6 +3585,9 @@ rest_of_compilation (tree decl)
compute_alignments ();
+ if (flag_var_tracking)
+ rest_of_handle_variable_tracking (decl, insns);
+
/* CFG is no longer maintained up-to-date. */
free_bb_for_insn ();
@@ -4414,6 +4440,16 @@ process_options (void)
error ("target system does not support the \"%s\" debug format",
debug_type_names[write_symbols]);
+ /* Now we know which debug output will be used so we can set
+ flag_var_tracking if user has not specified it. */
+ if (flag_var_tracking == AUTODETECT_FLAG_VAR_TRACKING)
+ {
+ /* User has not specified -f(no-)var-tracking so autodetect it. */
+ flag_var_tracking
+ = (optimize >= 1 && debug_info_level >= DINFO_LEVEL_NORMAL
+ && debug_hooks->var_location != do_nothing_debug_hooks.var_location);
+ }
+
/* If auxiliary info generation is desired, open the output file.
This goes in the same directory as the source file--unlike
all the other output files. */