<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></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 Oct 24, 2016, at 1:07 PM, Peter Collingbourne <<a href="mailto:peter@pcc.me.uk" class="">peter@pcc.me.uk</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote">On Mon, Oct 10, 2016 at 8:12 PM, Peter Collingbourne <span dir="ltr" class=""><<a href="mailto:peter@pcc.me.uk" target="_blank" class="">peter@pcc.me.uk</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr" class=""><div class="">The specific change I have in mind is to allow !range metadata on GlobalObjects. This would<br class=""></div><div class=""><div class="">be similar to existing !range metadata, but it would apply to the "address" of the attached GlobalObject, rather than any value loaded from it. Its presence on a GlobalObject would also imply that the address of the GlobalObject is "fixed" at link time.</div></div></div></blockquote><div class=""> </div><div class="">Going back to IR-level representation: here is an alternative representation based on a suggestion from Eli.</div><div class=""><br class=""></div><div class="">Introduce a new type of GlobalValue called GlobalConstant. GlobalConstant would fit into the GlobalValue hierarchy like this:</div><div class=""><ul class=""><li class="">GlobalValue<br class=""></li><ul class=""><li class="">GlobalConstant</li><li class="">GlobalPointer</li><ul class=""><li class="">GlobalIndirectSymbol</li><ul class=""><li class="">GlobalAlias</li><li class="">GlobalIFunc</li></ul><li class="">GlobalObject</li><ul class=""><li class="">Function</li><li class="">GlobalVariable</li></ul></ul></ul></ul><div class="">GlobalValue would no longer be assumed to be of pointer type. The getType() overload that takes a PointerType, as well as getValueType() would be moved down to GlobalPointer. (A nice side benefit of this is that it would help flush out cases where we are unnecessarily depending on global pointee types.)</div></div></div></div></div></div></blockquote><br class=""></div><div>Hi Peter,</div><div><br class=""></div><div>I agree that it makes sense to introduce a new GlobalConstant IR node for this sort of thing.  That said, have you considered a design where GlobalConstant is still required to be a pointer type?  If you did this, you would end up with a simpler and less invasive design of:</div><div><ul class=""><li class="">GlobalValue<br class=""></li><ul class=""><li class="">GlobalConstant</li><li class="">GlobalIndirectSymbol</li><ul class=""><li class="">GlobalAlias</li><li class="">GlobalIFunc</li></ul><li class="">GlobalObject</li><ul class=""><li class="">Function</li><li class="">GlobalVariable</li></ul></ul></ul><div class="">I think that this would be better for (e.g.) the X86 backend anyway, since global objects can be assigned to specific addresses with linker maps, and thus have small addresses (and this is expressible with the range metadata).  This means that GlobalConstant and other GlobalValues should all be usable in the same places in principle.</div><div class=""><br class=""></div><div class="">-Chris</div></div></body></html>