Commit 62760ffd by Caroline Tice Committed by Caroline Tice

Add ability to track uninitialized variables, and mark uninitialized variables…

Add ability to track uninitialized variables, and mark uninitialized variables in the Dwarf debug info.

Add ability to track uninitialized variables, and mark uninitialized
variables in the Dwarf debug info.  Controlled by compile option
-fvar-tracking-uninit

From-SVN: r126630
parent f861f54d
2007-07-13 Caroline Tice <ctice@apple.com>
* toplev.c (process_options): Turn flag_var_tracking_uninit off when
flag_var_tracking is explicitly turned off (i.e. when variable
tracking is not feasible); otherwise, turn flag_var_tracking on when
flag_var_tracking_uninit is on.
* rtl.def (VAR_LOCATION): Add a new integer subfield to VAR_LOCATION
note definitions, to allow recording of initialization status in the
notes.
* dwarf2out.c (dwarf_stack_op_name): Add case for DW_OP_GNU_uninit.
(add_var_loc_to_decl): Add comparison of NOTE_VAR_LOCATION_STATUS to
determine if two note locations are equal.
(output_loc_list): Don't output list entries whose start & end labels
are the same.
(reg_loc_descriptor): Add parameter for initialization status; pass it
to other loc descriptor functions.
(one_reg_loc_descriptor): Add parameter for initialization status;
check its value and add DW_OP_GNU_uninit to returned loc descr if
appropriate.
(multiple_reg_loc_descriptor): Add parameter for initialization
status;
pass init status argument to other loc descriptor functions; check
value of intialization parameter and add DW_OP_GNU_uninit to returned
loc descr if appropriate.
(based_loc_descr): Add parameter for initialization status; add new
variable for return value; check value of initialization parameter and
add DW_OP_GNU_uninit to returned loc descr if appropriate.
(concatn_mem_loc_descriptor): Add parameter for initialization status;
pass init status argument to other loc descriptor functions; check
value of intialization parameter and add DW_OP_GNU_uninit to returned
loc descr if appropriate.
(mem_loc_descriptor): Likewise.
(concat_loc_descriptor): Likewise.
(concatn_loc_descriptor): Likewise.
(loc_descriptor): Add parameter for initialization status; pass it as
argument to other loc descriptor function calls.
(loc_descriptor_from_tree_1): Add appropriate initialization status
to loc descriptor function calls.
(add_location_or_const_value_attribute): Get initialization status
from VAR_LOCATION note; add initialization status to loc descriptor
function calls.
* dwarf2.h (enum dwarf_location_atom): New op, DW_OP_GNU_uninit.
* print-rtl.c (print_rtx): When printing a VAR_LOCATION note, if
status is uninitialized, add "[uninint]" to output.
* common.opt (fvar-tracking-uninit): New option, similar to
fvar-tracking, to turn on tracking of uninitialized variables; creates
a new global flag, flag_var_tracking_uninit.
* rtl.h (NOTE_VAR_LOCATION_STATUS): New macro for accessing new field.
(enum var_init_status): New type, for var initialization status field.
* var-tracking.c (struct location_chain_def): Two new fields, init,
for initialization status, and set_src for the assignment value expr.
(unshare_variable): New parameter for initialization status;
initialize new init and set_src fields.
(var_reg_set): New parameters for initialization status and value;
pass them to set_variable_part.
(var_mem_set): Likewise.
(get_init_value): New function.
(var_reg_delete_and_set): New initialization status & value
parameters; add call to get_init_value if status is unknown; pass new
parameters to clobber_variable_part and var_reg_set.
(var_mem_delete_and_set): Likewise.
(var_reg_delete): Pass null set_src value to clobber_variable_part.
(var_mem_delete): Likewise.
(variable_union): Pass status to unshare_variable; initialize new init
and set_src fields. If flag_var_tracking_uninit is not set, force
status to initialized.
(add_stores): Store insn, rather than NEXT_INSN(insn), so it can be
used later to get the set_src value.
(find_src_status): New function.
(find_src_set_src): New function.
(compute_bb_dataflow): Pass init status to calls to var_reg_set,
var_mem_set, var_reg_delete_and_set and var_mem_delete_and_set; for
MO_SET, get set_src value and pass it to var_reg_delete_and_set
and var_mem_delete_and_set.
(dump_variable): Print out "[uninit]" if appropriate.
(set_variable_part): Add new initialization and set_src parameters;
pass status to unshare_variable; set node->init and node- >set_src
fields and modify slot in hash table appropriately; save the init and
set_src values if appropriate and assign to the new node.
(clobber_variable_part): New set_src parameter; if two nodes have
same variable and same location but different set_src (assignment)
values, clobber old node.
(delete_variable_part): Pass init status to unshare_variable.
(emit_note_insn_var_location): Add initialized var; assign var's init
status to new 'initialized'; pass new init status field to calls to
gen_rtx_VAR_LOCATION. If flag_var_tracking_uninit is not set, force
status to initialized.
(emit_notes_in_bb): Pass initialization status to calls to
var_reg_set, var_mem_set, var_reg_delete_and_set and
var_mem_delete_and_set; for MO_SET, get set_src value and pass it to
var_reg_delete_and_set and var_mem_delete_and_set; call
emit_notes_for_changes on NEXT_INSN(insn) rather than on insn, to
make up for change in add_stores.
(vt_add_function_parameters): Add status to calls to
set_variable_part.
* config/darwin.c (darwin_override_options): Turn on uninitialized
tracking automatically, if var_tracking is on and the system is
10.5 or higher.
2007-07-13 Sa Liu <saliu@de.ibm.com> 2007-07-13 Sa Liu <saliu@de.ibm.com>
* config.gcc: Add options for arch and tune on SPU. * config.gcc: Add options for arch and tune on SPU.
......
...@@ -1130,6 +1130,10 @@ fvar-tracking ...@@ -1130,6 +1130,10 @@ fvar-tracking
Common Report Var(flag_var_tracking) VarExists Optimization Common Report Var(flag_var_tracking) VarExists Optimization
Perform variable tracking Perform variable tracking
fvar-tracking-uninit
Common Report Var(flag_var_tracking_uninit) Optimization
Perform variable tracking and also tag variables that are uninitialized
ftree-vectorize ftree-vectorize
Common Report Var(flag_tree_vectorize) Optimization Common Report Var(flag_tree_vectorize) Optimization
Enable loop vectorization on trees Enable loop vectorization on trees
......
...@@ -1728,6 +1728,9 @@ darwin_override_options (void) ...@@ -1728,6 +1728,9 @@ darwin_override_options (void)
/* No -fnon-call-exceptions data in kexts. */ /* No -fnon-call-exceptions data in kexts. */
flag_non_call_exceptions = 0; flag_non_call_exceptions = 0;
} }
if (flag_var_tracking
&& strverscmp (darwin_macosx_version_min, "10.5") >= 0)
flag_var_tracking_uninit = 1;
} }
#include "gt-darwin.h" #include "gt-darwin.h"
...@@ -540,6 +540,8 @@ enum dwarf_location_atom ...@@ -540,6 +540,8 @@ enum dwarf_location_atom
DW_OP_bit_piece = 0x9d, DW_OP_bit_piece = 0x9d,
/* GNU extensions. */ /* GNU extensions. */
DW_OP_GNU_push_tls_address = 0xe0, DW_OP_GNU_push_tls_address = 0xe0,
/* The following is for marking variables that are uninitialized. */
DW_OP_GNU_uninit = 0xf0,
/* HP extensions. */ /* HP extensions. */
DW_OP_HP_unknown = 0xe0, /* Ouch, the same as GNU_push_tls_address. */ DW_OP_HP_unknown = 0xe0, /* Ouch, the same as GNU_push_tls_address. */
DW_OP_HP_is_value = 0xe1, DW_OP_HP_is_value = 0xe1,
......
...@@ -325,6 +325,9 @@ print_rtx (rtx in_rtx) ...@@ -325,6 +325,9 @@ print_rtx (rtx in_rtx)
print_mem_expr (outfile, NOTE_VAR_LOCATION_DECL (in_rtx)); print_mem_expr (outfile, NOTE_VAR_LOCATION_DECL (in_rtx));
fprintf (outfile, " "); fprintf (outfile, " ");
print_rtx (NOTE_VAR_LOCATION_LOC (in_rtx)); print_rtx (NOTE_VAR_LOCATION_LOC (in_rtx));
if (NOTE_VAR_LOCATION_STATUS (in_rtx) ==
VAR_INIT_STATUS_UNINITIALIZED)
fprintf (outfile, " [uninit]");
fprintf (outfile, ")"); fprintf (outfile, ")");
#endif #endif
break; break;
......
...@@ -680,7 +680,9 @@ DEF_RTL_EXPR(SS_TRUNCATE, "ss_truncate", "e", RTX_UNARY) ...@@ -680,7 +680,9 @@ DEF_RTL_EXPR(SS_TRUNCATE, "ss_truncate", "e", RTX_UNARY)
DEF_RTL_EXPR(US_TRUNCATE, "us_truncate", "e", RTX_UNARY) DEF_RTL_EXPR(US_TRUNCATE, "us_truncate", "e", RTX_UNARY)
/* Information about the variable and its location. */ /* Information about the variable and its location. */
DEF_RTL_EXPR(VAR_LOCATION, "var_location", "te", RTX_EXTRA) /* Changed 'te' to 'tei'; the 'i' field is for recording
initialization status of variables. */
DEF_RTL_EXPR(VAR_LOCATION, "var_location", "tei", RTX_EXTRA)
/* All expressions from this point forward appear only in machine /* All expressions from this point forward appear only in machine
descriptions. */ descriptions. */
......
...@@ -847,6 +847,22 @@ extern const char * const reg_note_name[]; ...@@ -847,6 +847,22 @@ extern const char * const reg_note_name[];
#define NOTE_VAR_LOCATION_LOC(INSN) (XCEXP (XCEXP (INSN, 4, NOTE), \ #define NOTE_VAR_LOCATION_LOC(INSN) (XCEXP (XCEXP (INSN, 4, NOTE), \
1, VAR_LOCATION)) 1, VAR_LOCATION))
/* Initialization status of the variable in the location. Status
can be unknown, uninitialized or initialized. See enumeration
type below. */
#define NOTE_VAR_LOCATION_STATUS(INSN) (XCINT (XCEXP (INSN, 4, NOTE), \
2, VAR_LOCATION))
/* Possible initialization status of a variable. When requested
by the user, this information is tracked and recorded in the DWARF
debug information, along with the variable's location. */
enum var_init_status
{
VAR_INIT_STATUS_UNKNOWN,
VAR_INIT_STATUS_UNINITIALIZED,
VAR_INIT_STATUS_INITIALIZED
};
/* Codes that appear in the NOTE_KIND field for kinds of notes /* Codes that appear in the NOTE_KIND field for kinds of notes
that are not line numbers. These codes are all negative. that are not line numbers. These codes are all negative.
......
...@@ -1874,7 +1874,8 @@ process_options (void) ...@@ -1874,7 +1874,8 @@ process_options (void)
if (debug_info_level < DINFO_LEVEL_NORMAL if (debug_info_level < DINFO_LEVEL_NORMAL
|| debug_hooks->var_location == do_nothing_debug_hooks.var_location) || debug_hooks->var_location == do_nothing_debug_hooks.var_location)
{ {
if (flag_var_tracking == 1) if (flag_var_tracking == 1
|| flag_var_tracking_uninit == 1)
{ {
if (debug_info_level < DINFO_LEVEL_NORMAL) if (debug_info_level < DINFO_LEVEL_NORMAL)
warning (0, "variable tracking requested, but useless unless " warning (0, "variable tracking requested, but useless unless "
...@@ -1884,6 +1885,7 @@ process_options (void) ...@@ -1884,6 +1885,7 @@ process_options (void)
"by this debug format"); "by this debug format");
} }
flag_var_tracking = 0; flag_var_tracking = 0;
flag_var_tracking_uninit = 0;
} }
if (flag_rename_registers == AUTODETECT_VALUE) if (flag_rename_registers == AUTODETECT_VALUE)
...@@ -1893,6 +1895,12 @@ process_options (void) ...@@ -1893,6 +1895,12 @@ process_options (void)
if (flag_var_tracking == AUTODETECT_VALUE) if (flag_var_tracking == AUTODETECT_VALUE)
flag_var_tracking = optimize >= 1; flag_var_tracking = optimize >= 1;
/* If the user specifically requested variable tracking with tagging
uninitialized variables, we need to turn on variable tracking.
(We already determined above that variable tracking is feasible.) */
if (flag_var_tracking_uninit)
flag_var_tracking = 1;
/* If auxiliary info generation is desired, open the output file. /* If auxiliary info generation is desired, open the output file.
This goes in the same directory as the source file--unlike This goes in the same directory as the source file--unlike
all the other output files. */ all the other output files. */
......
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