<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 15, 2016, at 1:51 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><br class="Apple-interchange-newline"><br style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_quote" style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">On Fri, Jan 15, 2016 at 1:42 PM, Adrian Prantl<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:aprantl@apple.com" target="_blank" class="">aprantl@apple.com</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><br class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">On Jan 15, 2016, at 1:29 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank" class="">dblaikie@gmail.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Fri, Jan 15, 2016 at 6:54 AM, Jonathan Roelofs via llvm-commits<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">jroelofs added a comment.<br class=""><br class="">@Dblaikie Not sure if my explanation was clear: I'm trying to convert the DI metadata from the kind that references a global, to the kind that references a local.<span class="Apple-converted-space"> </span></blockquote><div class=""><br class=""></div><div class="">Right</div><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">To do that, I /think/ I need to add the dbg.declare/value to the alloca that gets's created, and delete the one that references the soon-to-be-dead global. Does /that/ seem to you to be something out of the range of things that the DI metadata scheme can cope with?<br class=""></blockquote><div class=""><br class=""></div><div class="">The problem I'm getting at is that I think you'll end up with DWARF that doesn't make sense. You'll end up with a local variable instead of a global. Not just a global described by a local location.<br class=""><br class="">Does that make sense?<br class=""><br class="">DWARF:<br class=""><br class=""> <span class="Apple-converted-space"> </span>DW_TAG_compile_unit<br class="">   <span class="Apple-converted-space"> </span>DW_TAG_global_variable "foo"<br class="">   <span class="Apple-converted-space"> </span>DW_TAG_subprogram<br class="">     <span class="Apple-converted-space"> </span>DW_TAG_variable "bar"<br class="">     <span class="Apple-converted-space"> </span>...<br class=""><br class="">-><br class=""><br class=""> <span class="Apple-converted-space"> </span>DW_TAG_compile_unit<br class="">   <span class="Apple-converted-space"> </span>DW_TAG_subprogram<br class="">     <span class="Apple-converted-space"> </span>DW_TAG_variable "foo"<br class="">     <span class="Apple-converted-space"> </span>DW_TAG_variable "bar"<br class=""><br class="">Which isn't correct. "foo" should still be a DW_TAG_global_variable in the CU scope, its location should be a local location.<br class=""><br class="">I don't think the metadata can describe this currently... - but I could be wrong.</div></div></div></div></div></blockquote><div class=""><br class=""></div></span><div class="">I don’t think it can, which is why I suggested this hack with the local variable on IRC yesterday. But, of course, it would be better to fix LLVM to support the latter.</div></div></div></blockquote><div class=""><br class=""></div><div class="">Ah, yeah - if we're going to implement this, I'm not sure turning a global into a local is a sufficiently good user experience to make it an intermediate step towards the end goal, rather than doing the work up front. I'm open to discussing it, though - I can see how it'd be an option, but just seems like a bad user experience..<br class=""></div></div></div></blockquote><div><br class=""></div>No I totally agree. This is similar to the imported_entity thing we discussed yesterday. Even if the global variable isn’t available everywhere it may affect name resolution etc. so we should attempt to correctly represent it in DWARF.<br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_quote" style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class=""><br class="">- Dave</div><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><div class=""><span class="HOEnZb"><font color="#888888" class=""><div class=""><br class=""></div><div class="">-- adrian</div></font></span><span class=""><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><br class="">If not, do you know how to delete the DIGlobalVariable here? I started down this rabbit hole because I've got a bug where the debug info emitted into the asm references the global... which no longer exists, causing the assembler to barf on it.<br class=""><br class=""><br class=""><a href="http://reviews.llvm.org/D16209" rel="noreferrer" target="_blank" class="">http://reviews.llvm.org/D16209</a><br class=""><div class=""><div class=""><br class=""><br class=""><br class="">_______________________________________________<br class="">llvm-commits mailing list<br class=""><a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a><br class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a></div></div></blockquote></div></div></div></div></blockquote></span></div></div></blockquote></div></div></blockquote></div><br class=""></body></html>