<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 16, 2015 at 10:52 AM, Adrian Prantl <span dir="ltr"><<a href="mailto:aprantl@apple.com" target="_blank">aprantl@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">In <a href="http://reviews.llvm.org/D6986#109826" target="_blank">http://reviews.llvm.org/D6986#109826</a>, @dblaikie wrote:<br>
<br>
> (might be easier to review/commit by adding the expression handling then just removing the flag as dead code afterwards, but I'm not sure - it's not bad the way you've got it either)<br>
<br>
<br>
</span>Oh that would be great, but it's complicated:<br>
After having read this patch, look at this gem from SelectionDAGBuilder:<br>
<br>
  uint64_t Offset = DI->getOffset();<br>
    // A dbg.value for an alloca is always indirect.<br>
    bool IsIndirect = isa<AllocaInst>(V) || Offset != 0;<br>
    SDDbgValue *SDV;<br>
    if (Val.getNode()) {<br>
      if (!EmitFuncArgumentDbgValue(V, Variable, Expr, Offset, IsIndirect,<br>
                                    Val)) {<br>
        SDV = DAG.getDbgValue(Variable, Expr, Val.getNode(), Val.getResNo(),<br>
                              IsIndirect, Offset, dl, DbgSDNodeOrder);<br>
        DAG.AddDbgValue(SDV, Val.getNode(), false);<br>
      }<br>
    } else<br>
<br>
It is rematerializing the OP_deref that this patch removes in the form a of an indirect MachineLocation.<br>
<br>
Horrible, right?<br></blockquote><div><br>OK, so the indirect flag on MachineLocation is separate/in addition to the indirect flag on DIVariable that gets passed around through a few other layers/side channels.<br><br>So you could still remove the DIVariable related indirection and keep the MachineLocation indirection for now, maybe? Not sure. Maybe they end up together eventually.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">We //could// get rid of the indirect field in MachineLocation, if we were to redefine alloca's to be treated as addresses rather than values in dbg.value/dbg.declare.<br>
Let me give an example. Currently, the following code:<br>
<br>
  %x = alloca i64<br>
  call void @llvm.dbg.declare(metadata %i64* %b, [var=x], [expr=[]])<br>
  store i64 42, %x<br>
<br>
is lowered into<br>
<br>
  %x = i64 42<br>
  call void @llvm.dbg.value(metadata %i64* %b, [var=x], [expr=[]])<br>
<br>
Observe that the alloca, although it is treated like an address in IR, is treated like it was the value as far as the debug info is concerned.<br>
If we want to fix this we'd have to change the frontend to emit<br>
<br>
  %x = alloca i64<br>
  call void @llvm.dbg.declare(metadata %i64* %b, [var=x], [expr=[DW_OP_deref]])<br>
  store i64 42, %x<br>
<br>
which could then be lowered into the same code as above. After separating out DIExpression from DIVariable this is really easy to do; before it was pretty much impossible.<br>
<br>
I think I'd love to do that instead. Should we go break stuff? ;-)<br></blockquote><div><br>I believe this is the right direction to go sooner or later (Eric - can you confirm/deny?). This would get us pretty close to just removing dbg.declare entirely, wouldn't it? Or am I misremembering/misunderstanding the distinction. It'd just be a matter of whether we are indirecting through a register that doesn't change or not. (modulo lifetime intrinsics that make this harder - but they shouldn't shrink variable lifetime beyond the lexical scope anyway... maybe? so perhaps they don't matter)<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class=""><br>
<br>
REPOSITORY<br>
  rL LLVM<br>
<br>
<a href="http://reviews.llvm.org/D6986" target="_blank">http://reviews.llvm.org/D6986</a><br>
<br>
</span>EMAIL PREFERENCES<br>
  <a href="http://reviews.llvm.org/settings/panel/emailpreferences/" target="_blank">http://reviews.llvm.org/settings/panel/emailpreferences/</a><br>
<br>
<br>
</blockquote></div><br></div></div>