On Thu, May 05, 2011 at 10:25:53AM -0400, Jason Merrill wrote:
> >+          && (mode != Pmode
> >+              || GET_MODE_SIZE (ptr_mode) != DWARF2_ADDR_SIZE
> 
> This test seems overly cautious; it seems implausible to have
> DWARF2_ADDR_SIZE smaller than GET_MODE_SIZE (ptr_mode), and having
> it be larger doesn't seem like a problem.

Ok, I guess I can leave those ptr_mode GET_MODE_SIZE tests out.

> >+              || mem_mode == VOIDmode)
> 
> We can't handle Pmode void* like other pointers?

mem_mode == VOIDmode doesn't mean a void* pointer, mem_mode != VOIDmode
means mem_loc_descriptor is called on some MEM's address and gives the
mode of the MEM, while VOIDmode mem_mode means it isn't a memory address,
but just a random rtl that we wish to translate into DWARF location
expression.

If it is not a MEM address (i.e. mem_mode is VOIDmode) and
Pmode is wider than DWARF2_ADDR_SIZE, then how do you otherwise find out
if it is a pointer and you leave it up to the debug info consumer to do
some zero/sign/something else extension from DWARF2_ADDR_SIZE to
Pmode size, or if it is any other DImode quantity, which needs to be
represented using DW_OP_GNU_*_type?
Say for i?86 -m32
unsigned long long x = (uintptr_t) &y + 0x123456789abcULL;
(plus:DI (zero_extend:DI (symbol_ref:SI "y")) (const_double 0x123456789abc))
using untyped ops would be incorrect.

We could have some flag/global var whether mem_loc_descriptor is called
from unwind info code or not, and just assume untyped (ptr_mode) arithmetics
is always fine in that case, and just use always DW_OP_GNU_*_type
on POINTERS_EXTEND_UNSIGNED targets for Pmode elsewhere, the problem with
that is that the generated debug info for -gdwarf-strict would be very bad
and debug info would be unnecessarily large.
And we'd still need to represent Pmode SYMBOL_REF/CONST/LABEL_REF somehow
with the zero/sign extension being explicit (like
DW_OP_addr <foo + 6> DW_OP_GNU_convert <unsigned int> DW_OP_GNU_convert <long 
long>
for zero-extension, s/unsigned int/int/ for sign extension).  Unfortunately
POINTERS_EXTEND_UNSIGNED can be also -1 which means target has special
instruction to do the extension, but nothing says what that insn actually
performs.  So I think it is better to use untyped ops for memory addresses
and typed ops outside of memory addresses when the mode is larger than
DWARF2_ADDR_SIZE.

        Jakub

Reply via email to