Typed DWARF stack and convert to untyped

Jakub Jelinek jakub@redhat.com
Thu Jun 9 15:47:00 GMT 2011


Hi!

On Fri, Mar 25, 2011 at 12:32:37PM +0100, Jakub Jelinek wrote:
> This patch on top of
> http://gcc.gnu.org/ml/gcc-patches/2011-03/msg01224.html
> and
> http://gcc.gnu.org/ml/gcc-patches/2011-03/msg01723.html
> implements parts of Cary's typed DWARF stack proposal:
> http://www.dwarfstd.org/doc/040408.1.html

GCC currently doesn't fully adhere to the above SPEC (even with the
agreed on slight changes for some binary ops), in particular to the
binary ops operand need to have the same type.

Currently once a value on the stack is typed, the typedness
propagates forever through unary/binary ops (the only exception
are comparisons that push untyped result even for typed operands).

I'd like to propose convert to untyped operation, e.g.
DW_OP_GNU_convert <0> could do it (and maybe DW_OP_GNU_reinterpret <0>),
these would convert to an integral value of the same size as DWARF
address and make it untyped.  As DW_OP_GNU_convert operand is
uleb128 DIE offset within current CU, offset 0 certainly won't
contain any DIEs, because it is the first byte of the CU header.

Without this, currently GCC will sometimes end up with one
operand typed, another untyped.  While it is solvable even just on
the GCC side (mem_loc_descriptor would need to track whether the
TOS of the expression it returned is typed, untyped (or uncertain,
e.g. for DW_OP_GNU_parameter_ref), as that would be determined
by the matching DW_AT_GNU_call_site_value, and when e.g. for binary
operation one argument is determined as typed, the other argument
would need to be converted to typed as well if untyped, and any
uncertain operand of a binary op or unary that cares about the
sign would need to be converted to typed), I think it would
generate unnecessarily bloated code, as e.g. after a float is
converted to int or other small integer suddenly all further
additions etc. would need to convert constants etc. to typed values
(or use DW_OP_const_type).  With an convert to untyped operation,
mem_loc_descriptor could just ensure that for integral modes <=
DWARF_ADDR_SIZE the result is untyped (current gcc code sort of
assumes that) and only when a larger mode is needed or non-integral,
it would be typed, and when sign matters for operation of integral small
modes, it could just temporarily convert to typed and back.

Does this sound reasonable, or is it too ugly?

	Jakub



More information about the Gcc-patches mailing list