This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [rtlopt] do not emit unnecessary labels for variable locationlists
- From: Daniel Berlin <dberlin at dberlin dot org>
- To: Josef Zlomek <zlomj9am at artax dot karlin dot mff dot cuni dot cz>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 20 Feb 2003 18:23:24 -0500 (EST)
- Subject: Re: [rtlopt] do not emit unnecessary labels for variable locationlists
- References: <20030220201852.GA3265@artax.karlin.mff.cuni.cz>
On Thu, 20 Feb 2003, Josef Zlomek wrote:
> Hi,
>
> this patch protects from emitting a new label fro location lists if one
> has been already emitted to the same place.
Why bother?
gas will eliminate the useless ones.
>
> Bootstrapped x86-64.
>
> Joe
>
> 2003-02-20 Josef Zlomek <zlomekj at suse dot cz>
>
> * dwarf2out.c (dwarf2out_var_location): Do not emit unnecessary labels.
>
> Index: dwarf2out.c
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/dwarf2out.c,v
> retrieving revision 1.382.2.11
> diff -c -3 -p -r1.382.2.11 dwarf2out.c
> *** dwarf2out.c 20 Feb 2003 16:47:12 -0000 1.382.2.11
> --- dwarf2out.c 20 Feb 2003 20:13:22 -0000
> *************** dwarf2out_var_location (loc_note)
> *** 12615,12631 ****
> {
> char loclabel[MAX_ARTIFICIAL_LABEL_BYTES];
> struct var_loc_node *newloc;
>
> if (!DECL_P (NOTE_VAR_LOCATION_DECL (loc_note)))
> return;
>
> newloc = ggc_alloc_cleared (sizeof (struct var_loc_node));
> ! ASM_GENERATE_INTERNAL_LABEL (loclabel, "LVL", loclabel_num++);
> ! ASM_OUTPUT_LABEL (asm_out_file, loclabel);
> ! newloc->label = ggc_strdup (loclabel);
> newloc->var_loc_note = loc_note;
> newloc->next = NULL;
>
> add_var_loc_to_decl (NOTE_VAR_LOCATION_DECL (loc_note), newloc);
> }
>
> --- 12615,12651 ----
> {
> char loclabel[MAX_ARTIFICIAL_LABEL_BYTES];
> struct var_loc_node *newloc;
> + rtx prev_insn;
> + static rtx last_insn;
> + static const char *last_label;
>
> if (!DECL_P (NOTE_VAR_LOCATION_DECL (loc_note)))
> return;
> + prev_insn = PREV_INSN (loc_note);
>
> newloc = ggc_alloc_cleared (sizeof (struct var_loc_node));
> ! /* If the insn we processed last time is the previous insn
> ! and it is also a var location note, use the label we emitted
> ! last time. */
> ! if (last_insn != NULL_RTX
> ! && last_insn == prev_insn
> ! && GET_CODE (prev_insn) == NOTE
> ! && NOTE_LINE_NUMBER (prev_insn) == NOTE_INSN_VAR_LOCATION)
> ! {
> ! newloc->label = last_label;
> ! }
> ! else
> ! {
> ! ASM_GENERATE_INTERNAL_LABEL (loclabel, "LVL", loclabel_num++);
> ! ASM_OUTPUT_LABEL (asm_out_file, loclabel);
> ! newloc->label = ggc_strdup (loclabel);
> ! }
> newloc->var_loc_note = loc_note;
> newloc->next = NULL;
>
> + last_insn = loc_note;
> + last_label = newloc->label;
> +
> add_var_loc_to_decl (NOTE_VAR_LOCATION_DECL (loc_note), newloc);
> }
>
>