[Dwarf-discuss] Re: Dwarf2 Beginner's Question: Pointer variable...
Wed Jun 15 08:20:58 GMT 2005
>>>>Ron 603-884-2088 said:
> > The lack of a DW_AT_location attribute on the DIE for p_int
> > indicates that it has no address. That is, it was "optimized
> > away". In this example, value propagation might well move the
> > address of bbb directly into the point of use without ever
> > allocating a place specifically for p_int.
>Does this mean these two lines
> p_int = &bbb;
> printf(..., p_int);
>can be optimized into the following one line?
> printf(..., &bbb )
Absolutely possible, even likely if that is the only use of p_int.
>In this case, is it possible to determine the register of '&bbb'
>from the DWARF output?
>I was hoping that the DW_AT_location of 'p_int' would still be the register of
>the '&bbb' even after this 'optimized away' step.
It is almost surely impossible to determine the register holding
'&bbb' from the DWARF info. That location would likely be a parameter
passing location, in this example, and unrelated to an user variable.
This is just like
print(..., x+5 )
where the result of evaluating the expression 'x+5' will end up in
that same parameter passing location, which is not related to whatever
location might hold the value of x.
More information about the Dwarf-discuss