<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 6, 2016 at 2:14 PM, Peter Collingbourne <span dir="ltr"><<a href="mailto:peter@pcc.me.uk" target="_blank">peter@pcc.me.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Fri, May 6, 2016 at 2:10 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span>On Fri, May 6, 2016 at 2:09 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span>On Fri, May 6, 2016 at 1:55 PM, Peter Collingbourne via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span>On Fri, May 6, 2016 at 1:21 PM, Duncan P. N. Exon Smith <span dir="ltr"><<a href="mailto:dexonsmith@apple.com" target="_blank">dexonsmith@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><br>
> On 2016-May-06, at 13:17, Peter Collingbourne <<a href="mailto:peter@pcc.me.uk" target="_blank">peter@pcc.me.uk</a>> wrote:<br>
><br>
> Hi all,<br>
><br>
> I'd like to add support for metadata attachments for global variables in the same way as we did for functions.<br>
><br>
> Syntax would be pretty simple:<br>
> @foo = global i32 0, !foo !0, !bar !1<br>
> (the extra commas are required to disambiguate from a named metadata on the next line)<br>
<br>
</span>SGTM.<br>
<span><br>
> Benefits:<br>
> 1) Lets us reverse the DIGlobalVariable -> GlobalVariable edge, which should hopefully clear the way for removing the <a href="http://llvm.dbg.cu" rel="noreferrer" target="_blank">llvm.dbg.cu</a> named metadata node.<br>
<br>
</span>A little harder than it sounds (need to somehow support a GlobalVariable that is RAUW'ed with a ConstantInt), but I think this is important to do.<br></blockquote><div><br></div></span><div>How can a GlobalVariable be replaced with a ConstantInt? Wouldn't that just be an absolute address?</div></div></div></div></blockquote><div><br></div></span><div>If the global variable has a known constant value & the address is never needed, then we might optimize away the storage and still want debug info describing the constant. </div></div></div></div></blockquote><div><br></div></span><div>I'm not sure under what conditions, if any, that currently works - so this may be more of a "nice to have" or "be good to think about how any future design wouldn't preclude fixing this gap" sort of thing.</div></div></div></div></blockquote><div><br></div></span><div>I see. This does seem a lot like something like macro expansions where the entity doesn't have a direct correspondent in the IR. </div></div></div></div></blockquote><div><br></div><div>Ish - macros disappear in the frontend, so, yes, when we're preserving them we just attach them to the CU.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>So perhaps any pass that would want to preserve debug info in such a case could call some utility function that would move the DIGlobalVariable to (I suppose it would have to be) some named metadata node to which we'd attach things like macro expansions.</div></div></div></div></blockquote><div><br></div><div>Yep, something like that. But many passes might just blindly RAUW loads of the pointer to the global with the constant & then the global just quietly disappears due to lack of use (probably some cleanup path). But this seems to already be happening today - Duncan, do you know any cases where we do successfully describe a global via a constant value that would be the value of the global, not its address? My simple cases just seemed to lose the location entirely if the constant's storage was optimized away.<br><br>- David</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>Thanks,</div></div><span class="HOEnZb"><font color="#888888">-- <br><div><div dir="ltr">-- <div>Peter</div></div></div>
</font></span></div></div>
</blockquote></div><br></div></div>