<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 15, 2016 at 1:55 PM, Jonathan Roelofs <span dir="ltr"><<a href="mailto:jonathan@codesourcery.com" target="_blank">jonathan@codesourcery.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=""><br>
<br>
On 1/15/16 2:42 PM, Adrian Prantl wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
On Jan 15, 2016, at 1:29 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a><br></span><span class="">
<mailto:<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>>> wrote:<br>
<br>
<br>
<br>
On Fri, Jan 15, 2016 at 6:54 AM, Jonathan Roelofs via llvm-commits<br></span><span class="">
<<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a> <mailto:<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>>> wrote:<br>
<br>
    jroelofs added a comment.<br>
<br>
    @Dblaikie Not sure if my explanation was clear: I'm trying to<br>
    convert the DI metadata from the kind that references a global, to<br>
    the kind that references a local.<br>
<br>
<br>
Right<br>
<br>
    To do that, I /think/ I need to add the dbg.declare/value to the<br>
    alloca that gets's created, and delete the one that references the<br>
    soon-to-be-dead global. Does /that/ seem to you to be something<br>
    out of the range of things that the DI metadata scheme can cope with?<br>
<br>
<br>
The problem I'm getting at is that I think you'll end up with DWARF<br>
that doesn't make sense. You'll end up with a local variable instead<br>
of a global. Not just a global described by a local location.<br>
<br>
Does that make sense?<br>
</span></blockquote></blockquote>
<br>
Ahh, I see. Thanks for the explanation.<span class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
DWARF:<br>
<br>
  DW_TAG_compile_unit<br>
    DW_TAG_global_variable "foo"<br>
    DW_TAG_subprogram<br>
      DW_TAG_variable "bar"<br>
      ...<br>
<br>
-><br>
<br>
  DW_TAG_compile_unit<br>
    DW_TAG_subprogram<br>
      DW_TAG_variable "foo"<br>
      DW_TAG_variable "bar"<br>
<br>
Which isn't correct. "foo" should still be a DW_TAG_global_variable in<br>
the CU scope, its location should be a local location.<br>
<br>
I don't think the metadata can describe this currently... - but I<br>
could be wrong.<br>
</blockquote>
<br>
I don’t think it can, which is why I suggested this hack with the local<br>
variable on IRC yesterday. But, of course, it would be better to fix<br>
LLVM to support the latter.<br>
</blockquote>
<br></span>
Am I understanding correctly that this is a limitation of the IR's representation of it, and not of DWARF?<br></blockquote><div><br></div><div>That's my understanding, yes. I'd check GCC's DWARF representation for situations like this, but I imagine it's plausible.<br><br>I don't have /great/ ideas about how to do this in LLVM's IR representation or IRGen, especially if the global is sunk into more than one function (eg: int i; void f1() {  i = 3; ... } void f2() { i = 7; ... })... won't be pretty.<br><br>- Dave</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
Jon<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
-- adrian<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
<br>
    If not, do you know how to delete the DIGlobalVariable here? I<br>
    started down this rabbit hole because I've got a bug where the<br>
    debug info emitted into the asm references the global... which no<br>
    longer exists, causing the assembler to barf on it.<br>
<br>
<br>
    <a href="http://reviews.llvm.org/D16209" rel="noreferrer" target="_blank">http://reviews.llvm.org/D16209</a><br>
<br>
<br>
<br>
    _______________________________________________<br>
    llvm-commits mailing list<br></span>
    <a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a> <mailto:<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>><br>
    <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
<br>
<br>
</blockquote>
<br><span class="HOEnZb"><font color="#888888">
</font></span></blockquote><span class="HOEnZb"><font color="#888888">
<br>
-- <br>
Jon Roelofs<br>
<a href="mailto:jonathan@codesourcery.com" target="_blank">jonathan@codesourcery.com</a><br>
CodeSourcery / Mentor Embedded<br>
</font></span></blockquote></div><br></div></div>