This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Emit DW_OP_stack_value more often, don't emit DW_OP_piece after it
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Alexandre Oliva <aoliva at redhat dot com>, Roland McGrath <roland at redhat dot com>, Tom Tromey <tromey at redhat dot com>
- Date: Wed, 23 Sep 2009 09:33:46 +0200
- Subject: [PATCH] Emit DW_OP_stack_value more often, don't emit DW_OP_piece after it
- References: <m3vdmsrwvy.fsf@fleche.redhat.com> <4cf39eea0906212112l1429bbdfx2fb0001fddf358df@mail.gmail.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
The initial code to emit DW_OP_stack_value was written before seeing this:
On Sun, Jun 21, 2009 at 09:12:54PM -0700, Cary Coutant wrote:
> > About DW_OP_stack_value, the text says:
> >
> > ?This operation may only be followed by DW_OP_piece or DW_OP_bit_piece.
> >
> > However, later there is an example showing DW_OP_stack_value without a
> > following piece operator.
> >
> > We had some disagreement about the proper interpretation of this
> > sentence: should it mean that DW_OP_stack_value *must* be followed by
> > a piece operator, or should it mean that DW_OP_stack_value should
> > follow the DW_OP_reg* rules and either be followed by a piece operator
> > or occur at the end of an expression?
>
> The latter. IF it's followed by anything at all, those are the only
> two operators that can follow it. (In other words, DW_OP_stack_value
> terminates an expression, and those are the only two operators that
> can apply to a terminated expression.)
and apparently I forgot about it completely. So, this patch adjusts
dwarf2out to not emit DW_OP_piece unless necessary.
Ok for trunk if it passes bootstrap/regtest?
2009-09-23 Jakub Jelinek <jakub@redhat.com>
PR debug/41439
* dwarf2out.c (address_of_int_loc_descriptor): Don't emit
DW_OP_piece after DW_OP_stack_value, adjust size calculations
for it, when DW_OP_stack_value and DW_OP_implicit_value has
the same size, prefer DW_OP_stack_value.
(loc_descriptor, loc_list_for_address_of_addr_expr_of_indirect_ref,
loc_list_from_tree): Don't emit DW_OP_piece after DW_OP_stack_value.
--- gcc/dwarf2out.c.jj 2009-09-23 09:05:34.000000000 +0200
+++ gcc/dwarf2out.c 2009-09-23 09:20:22.000000000 +0200
@@ -10941,17 +10941,14 @@ address_of_int_loc_descriptor (int size,
}
/* Determine if DW_OP_stack_value or DW_OP_implicit_value
is more compact. For DW_OP_stack_value we need:
- litsize + 1 (DW_OP_stack_value) + 1 (DW_OP_bit_size)
- + 1 (mode size)
+ litsize + 1 (DW_OP_stack_value)
and for DW_OP_implicit_value:
- 1 (DW_OP_implicit_value) + 1 (length) + mode_size. */
- if ((int) DWARF2_ADDR_SIZE >= size
- && litsize + 1 + 1 + 1 < 1 + 1 + size)
+ 1 (DW_OP_implicit_value) + 1 (length) + size. */
+ if ((int) DWARF2_ADDR_SIZE >= size && litsize + 1 <= 1 + 1 + size)
{
loc_result = int_loc_descriptor (i);
add_loc_descr (&loc_result,
new_loc_descr (DW_OP_stack_value, 0, 0));
- add_loc_descr_op_piece (&loc_result, size);
return loc_result;
}
@@ -11997,11 +11994,8 @@ loc_descriptor (rtx rtl, enum machine_mo
/* Value expression. */
loc_result = mem_loc_descriptor (rtl, VOIDmode, initialized);
if (loc_result)
- {
- add_loc_descr (&loc_result,
- new_loc_descr (DW_OP_stack_value, 0, 0));
- add_loc_descr_op_piece (&loc_result, GET_MODE_SIZE (mode));
- }
+ add_loc_descr (&loc_result,
+ new_loc_descr (DW_OP_stack_value, 0, 0));
}
break;
}
@@ -12391,11 +12385,6 @@ loc_list_for_address_of_addr_expr_of_ind
loc_list_plus_const (list_ret, bytepos);
add_loc_descr_to_each (list_ret,
new_loc_descr (DW_OP_stack_value, 0, 0));
- add_loc_descr_to_each (list_ret,
- new_loc_descr (DW_OP_piece,
- int_size_in_bytes (TREE_TYPE
- (loc)),
- 0));
}
return list_ret;
}
@@ -12916,11 +12905,6 @@ loc_list_from_tree (tree loc, int want_a
}
add_loc_descr_to_each (list_ret,
new_loc_descr (DW_OP_stack_value, 0, 0));
- add_loc_descr_to_each (list_ret,
- new_loc_descr (DW_OP_piece,
- int_size_in_bytes (TREE_TYPE
- (loc)),
- 0));
have_address = 1;
}
/* Show if we can't fill the request for an address. */
Jakub