Commit 014a1138 by Josef Zlomek Committed by Josef Zlomek

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
parent 298c28a8
2004-02-06 Josef Zlomek <zlomekj@suse.cz>
Daniel Berlin <dberlin@dberlin.org>
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.
2004-02-06 Jan Hubicka <jh@suse.cz>
* flow.c (update_life_info): Allocate reg_deaths when called from
......
......@@ -852,7 +852,7 @@ OBJS-common = \
insn-extract.o insn-opinit.o insn-output.o insn-peep.o insn-recog.o \
integrate.o intl.o jump.o langhooks.o lcm.o lists.o local-alloc.o \
loop.o optabs.o options.o opts.o params.o postreload.o predict.o \
print-rtl.o print-tree.o value-prof.o \
print-rtl.o print-tree.o value-prof.o var-tracking.o \
profile.o ra.o ra-build.o ra-colorize.o ra-debug.o ra-rewrite.o \
real.o recog.o reg-stack.o regclass.o regmove.o regrename.o \
reload.o reload1.o reorg.o resource.o rtl.o rtlanal.o rtl-error.o \
......@@ -1669,6 +1669,9 @@ lcm.o : lcm.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(REGS_H) \
df.o : df.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
insn-config.h $(RECOG_H) function.h $(REGS_H) alloc-pool.h hard-reg-set.h \
$(BASIC_BLOCK_H) df.h $(FIBHEAP_H)
var-tracking.o : var-tracking.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(RTL_H) $(TREE_H) hard-reg-set.h insn-config.h reload.h flags.h \
$(BASIC_BLOCK_H) output.h sbitmap.h alloc-pool.h $(FIBHEAP_H) $(HASHTAB_H)
conflict.o : conflict.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(OBSTACK_H) \
$(HASHTAB_H) $(RTL_H) hard-reg-set.h $(BASIC_BLOCK_H)
profile.o : profile.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
......
......@@ -715,6 +715,10 @@ funwind-tables
Common
Just generate unwind tables for exception handling
fvar-tracking
Common
Perform variable tracking
fverbose-asm
Common
Add extra commentary to assembler output
......
......@@ -117,6 +117,10 @@ const char *ia64_tune_string;
avoid the normal second scheduling pass. */
static int ia64_flag_schedule_insns2;
/* Determines whether we run variable tracking in machine dependent
reorganization. */
static int ia64_flag_var_tracking;
/* Variables which are this size or smaller are put in the sdata/sbss
sections. */
......@@ -4785,6 +4789,11 @@ ia64_override_options (void)
ia64_flag_schedule_insns2 = flag_schedule_insns_after_reload;
flag_schedule_insns_after_reload = 0;
/* Variable tracking should be run after all optimizations which change order
of insns. It also needs a valid CFG. */
ia64_flag_var_tracking = flag_var_tracking;
flag_var_tracking = 0;
ia64_section_threshold = g_switch_set ? g_switch_value : IA64_DEFAULT_GVALUE;
init_machine_status = ia64_init_machine_status;
......@@ -7630,6 +7639,13 @@ ia64_reorg (void)
fixup_errata ();
emit_predicate_relation_info ();
if (ia64_flag_var_tracking)
{
timevar_push (TV_VAR_TRACKING);
variable_tracking_main ();
timevar_pop (TV_VAR_TRACKING);
}
}
/* Return true if REGNO is used by the epilogue. */
......
......@@ -400,7 +400,8 @@ const struct gcc_debug_hooks dbx_debug_hooks =
debug_nothing_tree, /* deferred_inline_function */
debug_nothing_tree, /* outlining_inline_function */
debug_nothing_rtx, /* label */
dbxout_handle_pch /* handle_pch */
dbxout_handle_pch, /* handle_pch */
debug_nothing_rtx /* var_location */
};
#endif /* DBX_DEBUGGING_INFO */
......@@ -428,7 +429,8 @@ const struct gcc_debug_hooks xcoff_debug_hooks =
debug_nothing_tree, /* deferred_inline_function */
debug_nothing_tree, /* outlining_inline_function */
debug_nothing_rtx, /* label */
dbxout_handle_pch /* handle_pch */
dbxout_handle_pch, /* handle_pch */
debug_nothing_rtx /* var_location */
};
#endif /* XCOFF_DEBUGGING_INFO */
......
......@@ -45,7 +45,8 @@ const struct gcc_debug_hooks do_nothing_debug_hooks =
debug_nothing_tree, /* deferred_inline_function */
debug_nothing_tree, /* outlining_inline_function */
debug_nothing_rtx, /* label */
debug_nothing_int /* handle_pch */
debug_nothing_int, /* handle_pch */
debug_nothing_rtx /* var_location */
};
/* This file contains implementations of each debug hook that do
......
......@@ -108,6 +108,9 @@ struct gcc_debug_hooks
/* Called after the start and before the end of writing a PCH file.
The parameter is 0 if after the start, 1 if before the end. */
void (* handle_pch) (unsigned int);
/* Called from final_scan_insn for any NOTE_INSN_VAR_LOCATION note. */
void (* var_location) (rtx);
};
extern const struct gcc_debug_hooks *debug_hooks;
......
......@@ -251,7 +251,7 @@ in the following sections.
-feliminate-dwarf2-dups -feliminate-unused-debug-types @gol
-feliminate-unused-debug-symbols -fmem-report -fprofile-arcs @gol
-frandom-seed=@var{string} -fsched-verbose=@var{n} @gol
-ftest-coverage -ftime-report @gol
-ftest-coverage -ftime-report -fvar-tracking @gol
-g -g@var{level} -gcoff -gdwarf-2 @gol
-ggdb -gstabs -gstabs+ -gvms -gxcoff -gxcoff+ @gol
-p -pg -print-file-name=@var{library} -print-libgcc-file-name @gol
......@@ -3313,6 +3313,7 @@ Dump callgraph and unit-at-a-time optimization @file{@var{file}.00.unit}.
@item V
@opindex dV
Dump after the value profile transformations, to @file{@var{file}.13.vpt}.
Also dump after variable tracking, to @file{@var{file}.35.vartrack}.
@item w
@opindex dw
Dump after the second flow pass, to @file{@var{file}.27.flow2}.
......@@ -3467,6 +3468,16 @@ executing the program itself. The second number is ``system time,''
time spent executing operating system routines on behalf of the program.
Both numbers are in seconds.
@item -fvar-tracking
@opindex fvar-tracking
Run variable tracking pass. It computes where variables are stored at each
position in code. Better debugging information is then generated
(if the debugging information format supports this information).
It is enabled by default when compiling with optimization (@option{-Os},
@option{-O}, @option{-O2}, ...), debugging information (@option{-g}) and
the debug info format supports it.
@item -print-file-name=@var{library}
@opindex print-file-name
Print the full absolute name of the library file @var{library} that
......
......@@ -507,6 +507,19 @@ The option @option{-dB} causes a debugging dump of the RTL code after
this pass. This dump file's name is made by appending @samp{.bbro} to
the input file name.
@cindex variable tracking
@item
Variable tracking. This pass computes where the variables are stored at each
position in code and generates notes describing the variable locations
to RTL code. The location lists are then generated according to these
notes to debug information if the debugging information format supports
location lists.
@opindex dV
The option @option{-dV} causes a debugging dump of the RTL code after
this pass. This dump file's name is made by appending @samp{.vartrack}
to the input file name.
@cindex delayed branch scheduling
@cindex scheduling, delayed branch
@item
......
......@@ -3280,7 +3280,8 @@ const struct gcc_debug_hooks dwarf2_debug_hooks =
something tries to reference them. */
dwarf2out_abstract_function, /* outlining_inline_function */
debug_nothing_rtx, /* label */
debug_nothing_int /* handle_pch */
debug_nothing_int, /* handle_pch */
debug_nothing_rtx /* var_location */
};
#endif
......
......@@ -1782,6 +1782,10 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED,
ASM_OUTPUT_DEBUG_LABEL (file, "L", CODE_LABEL_NUMBER (insn));
break;
case NOTE_INSN_VAR_LOCATION:
(*debug_hooks->var_location) (insn);
break;
case 0:
break;
......
......@@ -723,6 +723,9 @@ extern int flag_web;
used. */
extern int flag_remove_unreachable_functions;
/* Nonzero if we should track variables. */
extern int flag_var_tracking;
/* A string that's used when a random name is required. NULL means
to make it really random. */
......
......@@ -450,6 +450,7 @@ adjust_field_rtx_def (type_p t, options_p opt ATTRIBUTE_UNUSED)
break;
case NOTE_INSN_EXPECTED_VALUE:
case NOTE_INSN_VAR_LOCATION:
note_flds->name = "rtx";
note_flds->type = rtx_tp;
break;
......
......@@ -1436,6 +1436,10 @@ common_handle_option (size_t scode, const char *arg,
flag_unwind_tables = value;
break;
case OPT_fvar_tracking:
flag_var_tracking = value;
break;
case OPT_fverbose_asm:
flag_verbose_asm = value;
break;
......
......@@ -291,6 +291,14 @@ print_rtx (rtx in_rtx)
fprintf (outfile, " [ ERROR ]");
break;
case NOTE_INSN_VAR_LOCATION:
fprintf (outfile, " (");
print_mem_expr (outfile, NOTE_VAR_LOCATION_DECL (in_rtx));
fprintf (outfile, " ");
print_rtx (NOTE_VAR_LOCATION_LOC (in_rtx));
fprintf (outfile, ")");
break;
default:
{
const char * const str = X0STR (in_rtx, i);
......
......@@ -122,7 +122,7 @@ const char * const note_insn_name[NOTE_INSN_MAX - NOTE_INSN_BIAS] =
"NOTE_INSN_EH_REGION_BEG", "NOTE_INSN_EH_REGION_END",
"NOTE_INSN_REPEATED_LINE_NUMBER",
"NOTE_INSN_BASIC_BLOCK", "NOTE_INSN_EXPECTED_VALUE",
"NOTE_INSN_PREDICTION"
"NOTE_INSN_PREDICTION", "NOTE_INSN_VAR_LOCATION"
};
const char * const reg_note_name[] =
......
......@@ -1215,6 +1215,8 @@ DEF_RTL_EXPR(SS_TRUNCATE, "ss_truncate", "e", '1')
/* Unsigned saturating truncate. */
DEF_RTL_EXPR(US_TRUNCATE, "us_truncate", "e", '1')
/* Information about the variable and its location. */
DEF_RTL_EXPR(VAR_LOCATION, "var_location", "te", 'x')
/*
Local variables:
......
......@@ -819,6 +819,7 @@ extern const char * const reg_note_name[];
#define NOTE_EXPECTED_VALUE(INSN) XCEXP (INSN, 4, NOTE)
#define NOTE_PREDICTION(INSN) XCINT (INSN, 4, NOTE)
#define NOTE_PRECONDITIONED(INSN) XCINT (INSN, 4, NOTE)
#define NOTE_VAR_LOCATION(INSN) XCEXP (INSN, 4, NOTE)
/* In a NOTE that is a line number, this is the line number.
Other kinds of NOTEs are identified by negative numbers here. */
......@@ -834,6 +835,12 @@ extern const char * const reg_note_name[];
#define NOTE_PREDICTION_FLAGS(INSN) (XCINT(INSN, 4, NOTE)&0xff)
#define NOTE_PREDICT(ALG,FLAGS) ((ALG<<8)+(FLAGS))
/* Variable declaration and the location of a variable. */
#define NOTE_VAR_LOCATION_DECL(INSN) (XCTREE (XCEXP (INSN, 4, NOTE), \
0, VAR_LOCATION))
#define NOTE_VAR_LOCATION_LOC(INSN) (XCEXP (XCEXP (INSN, 4, NOTE), \
1, VAR_LOCATION))
/* Codes that appear in the NOTE_LINE_NUMBER field
for kinds of notes that are not line numbers.
......@@ -917,6 +924,9 @@ enum insn_note
/* Record a prediction. Uses NOTE_PREDICTION. */
NOTE_INSN_PREDICTION,
/* The location of a variable. */
NOTE_INSN_VAR_LOCATION,
NOTE_INSN_MAX
};
......@@ -2343,4 +2353,7 @@ extern bool expensive_function_p (int);
/* In tracer.c */
extern void tracer (void);
/* In var-tracking.c */
extern void variable_tracking_main (void);
#endif /* ! GCC_RTL_H */
......@@ -335,7 +335,8 @@ const struct gcc_debug_hooks sdb_debug_hooks =
debug_nothing_tree, /* deferred_inline_function */
debug_nothing_tree, /* outlining_inline_function */
sdbout_label, /* label */
debug_nothing_int /* handle_pch */
debug_nothing_int, /* handle_pch */
debug_nothing_rtx /* var_location */
};
/* Return a unique string to name an anonymous type. */
......
......@@ -95,6 +95,7 @@ DEFTIMEVAR (TV_SHORTEN_BRANCH , "shorten branches")
DEFTIMEVAR (TV_REG_STACK , "reg stack")
DEFTIMEVAR (TV_FINAL , "final")
DEFTIMEVAR (TV_SYMOUT , "symout")
DEFTIMEVAR (TV_VAR_TRACKING , "variable tracking")
/* Everything else in rest_of_compilation not included above. */
DEFTIMEVAR (TV_REST_OF_COMPILATION , "rest of compilation")
......@@ -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. */
......
......@@ -2060,6 +2060,7 @@ enum ptrmemfunc_vbit_where_t
#define NULL_TREE (tree) NULL
extern tree frame_base_decl;
extern tree decl_assembler_name (tree);
/* Compute the number of bytes occupied by 'node'. This routine only
......
......@@ -190,7 +190,8 @@ const struct gcc_debug_hooks vmsdbg_debug_hooks
debug_nothing_tree, /* deferred_inline_function */
vmsdbgout_abstract_function,
debug_nothing_rtx, /* label */
debug_nothing_int /* handle_pch */
debug_nothing_int, /* handle_pch */
debug_nothing_rtx /* var_location */
};
/* Definitions of defaults for assembler-dependent names of various
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment