<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Mon, Aug 28, 2017 at 9:21 AM Nikola Prica via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">NikolaPrica marked an inline comment as done.<br>
NikolaPrica added a comment.<br>
<br>
>><br>
>><br>
>>   val * (ValOther - ValInit) + ValInit:<br>
><br>
> If we are doing this expression, there should be an assertion in the code that `ValInit < ValOther`.<br>
<br>
I have tested this for edge cases such as both negative values, LONG_MAX, LONG_INT etc and there was no problem for this values. Only flaw for this is ugly long DW_AT_location expression for long values.<br>
<br>
>>    DW_OP_deref DW_OP_constu <ValMinus><br>
>>   DW_OP_mul DW_OP_constu <ValInit> DW_OP_plus DW_OP_stack_value<br>
><br>
> Why does `Val` need to be dereferenced?<br>
<br>
DW_OP_deref needs to be used because we have address of new variable on stack, not its value.<br>
<br>
> Apart from the DW_OP_deref, this seems very good, I'm slightly worried about the assumption that the init value will always be the smaller one.<br>
>  What happens if any of the two values is negative (because of the typeless DWARF <5 expression stack — not sure if this will be a problem).<br>
<br>
For dwarf versions lower than 4 gdb reads value of DW_AT_location expression as address giving message "Cannot access memory at address 0x1e". This may be a problem but it is still better than optimized-out?<br></blockquote><div><br>I'm a bit curious about this - are the DW_OPs we're using defined in DWARF lower than 4? If not, what do we want to do about that? I know we've historically supported older DWARF versions on a sort of ad-hoc as-needed basis, so breaking this might not be out of character there... <br><br>But I'm kind of OK saying "optimized out" if there's no way to express the location in the DWARF version the user asked for... (so perhaps when emitting the expression in the backend, we could check the supported version for the ops being used, and drop the whole location if any of the ops aren't supported by the version being emitted)<br><br>- Dave<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
<a href="https://reviews.llvm.org/D35994" rel="noreferrer" target="_blank">https://reviews.llvm.org/D35994</a><br>
<br>
<br>
<br>
</blockquote></div></div>