From: Caroline Tice <ctice@apple.com>
To: "gcc-patches@gcc.gnu.org Patches" <gcc-patches@gcc.gnu.org>
Cc: Caroline Tice <ctice@apple.com>
Subject: Ping! [PATCH, revised]: Track uninitialized variables
Date: Fri, 18 May 2007 19:48:00 -0000 [thread overview]
Message-ID: <7F2DCB28-8330-49E5-BD9D-403F446371A5@apple.com> (raw)
In-Reply-To: <738B4C94-E6B1-4C3C-AEA6-42BD0C40C4CA@apple.com>
As a point of interest: The GDB side of this patch has been accepted
and
committed to FSF GDB.
-- Caroline
On May 11, 2007, at 12:13 PM, Caroline Tice wrote:
> Here is a revised version of my patch for tracking uninitialized
> variables (see description in original posting copied below). I added
> the comments Ian asked for, and I changed the way it is turned on/off.
> Instead of the macro in my previous patch, it is now controlled by a
> command line option, -fvar-tracking-uninit, which turns on
> var-tracking, just like -fvar-tracking, but also turns on the
> uninitialized variable tracking. I added the same feasibility
> checks to
> it that are used for -fvar-tracking. I also turned it on by default
> on darwin systems running 10.5 or later (when var-tracking is on).
>
> I tested this patch by bootstrapping it and running the dejagnu
> testsuite without any regressions, on a ppc running apple-darwin, an
> x86 running apple-darwin, and an x86 64 running 64-bit linux. I also
> ran it on a small test case containing uninitialized variables, to
> verify that it turns on when the command line option is passed, or
> when running on the correct version of darwin, and is off at all other
> times.
>
> Is this patch okay to commit to mainline?
>
> --Caroline Tice
> ctice@apple.com
>
>
> On May 1, 2007, at 5:02 PM, Caroline Tice wrote:
>
>>
>> As part of some work I've been doing on improving debugging of
>> optimized code, I have developed the following patch which, while
>> tracking the locations of variables, also keeps track of whether the
>> variables are initialized or not (it makes conservative assumptions
>> where it can't be sure). For those places where it is sure the
>> variables are unintialized, it adds an annotation to the
>> var_location_note, which the dwarf writer later translates to a new
>> DW_OP (an extension) that indicates a variable is uninitialized
>> (DW_OP_GNU_uninit).
>
>> Since this work requires that GDB be able to read and do something
>> reasonable with the new DW_OP, I have also created a GDB patch to
>> deal
>> with the new op, and to inform the user that a particular value is
>> unintialized when the user asks to see it. As the two patches really
>> go together, I am attaching both of them to this message. (I will
>> also be sending the GDB patch to the gdb patches list).
>
>> Because using the new DW_OP is sensitive to whether or not the user
>> has a version of GDB that can handle it, I have added a macro,
>> TARGET_DWARF_UNINIT_VARS, which defaults to 0, and which controls
>> whether the uninitialized variable tracking is done.
>
>> I have bootstrapped and run the dejagnu testsuite on this patch, with
>> no regressions, on a ppc running apple-darwin, an x86 running
>> apple-darwin, and an x86 64 running 64-bit linux.
>
>> Is this patch okay to commit to mainline?
>> -- Caroline Tice
>> ctice@apple.com
>>
>
> 2007-05-11 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.
>
>
> <fsf-gcc-patch.v2.txt>
next prev parent reply other threads:[~2007-05-18 19:48 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-02 0:03 [PATCH]: " Caroline Tice
2007-05-08 16:25 ` Ping! " Caroline Tice
2007-05-09 0:28 ` Ian Lance Taylor
2007-05-09 16:48 ` Caroline Tice
2007-05-09 17:40 ` Caroline Tice
2007-05-09 18:08 ` Ian Lance Taylor
2007-05-09 18:16 ` Daniel Jacobowitz
2007-05-10 3:29 ` Mark Mitchell
2007-05-11 19:13 ` [PATCH, revised]: " Caroline Tice
2007-05-18 19:48 ` Caroline Tice [this message]
2007-05-25 21:26 ` Ping2! " Caroline Tice
2007-06-01 16:59 ` Ping3! " Caroline Tice
2007-06-01 17:13 ` Manuel López-Ibáñez
2007-06-01 17:24 ` Caroline Tice
2007-06-08 17:52 ` Ping 4! " Caroline Tice
2007-06-21 17:02 ` Ping 5! " Caroline Tice
2007-06-23 18:54 ` Mark Mitchell
2007-07-12 17:24 ` Ping 6! " Caroline Tice
2007-07-12 20:11 ` Eric Christopher
2007-07-12 21:04 ` Caroline Tice
2007-07-11 14:45 ` Ian Lance Taylor
2007-07-16 13:37 ` Richard Guenther
2007-07-16 16:40 ` Caroline Tice
2007-07-16 17:19 ` Caroline Tice
2007-07-16 17:33 ` H.J. Lu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7F2DCB28-8330-49E5-BD9D-403F446371A5@apple.com \
--to=ctice@apple.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).