<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 Feb 8, 2017, at 11:05 PM, Nemanja Ivanovic <<a href="mailto:nemanja.i.ibm@gmail.com" class="">nemanja.i.ibm@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">So the general consensus then is that it only makes sense to provide the string API? This would allow the user to determine that two versions of LLVM are identical/different. </div></div></div></blockquote><div><br class=""></div><div>That was only the answer I had to give for the caching use-case, you can see my answer to this as orthogonal to asking if we should or not add the proposed API here.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="">However no API should be provided that would allow the user to query whether the version is "at least/at most" some version or "between" two versions?<br class=""><br class=""></div><div class="">I hope I am not out of line by asking how providing these major/minor/patch versions in an API is fundamentally different to providing them as macros. I imagine users of these macros guard their code with these macros so they don't use something known to be missing or buggy. So I don't see how doing something similar at runtime in a JIT context is so fundamentally flawed. As a concrete example that motivated the RFC:<br class="">- there was a bug in our back end that we fixed for the 3.9 release<br class=""></div><div class="">- a package that uses LLVM as a JIT has a workaround for that bug that hurts performance<br class=""></div><div class="">- the package decides to use the workaround or not based on the version macros<br class=""></div><div class="">- the package maintainers would prefer to be able to do this check at run-time so if a more recent version is loaded, the workaround is not used<br class=""></div></div></div></blockquote><div><br class=""></div><div><br class=""></div><div>I agree with mats that any of what you’re describing above would be broken by linking to a non-vanilla release.</div><div>There are many people that branch LLVM at different point, the upstream release number are not meaningful there.</div><div><br class=""></div><div>That said, I sympathize for the use-case, and in the absence of a better solution I wouldn’t be against adding this.</div><div><br class=""></div><div>— </div><div>Mehdi</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Feb 8, 2017 at 5:02 PM, mats petersson <span dir="ltr" class=""><<a href="mailto:mats@planetcatfish.com" target="_blank" class="">mats@planetcatfish.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote"><span class="">On 8 February 2017 at 15:43, Nemanja Ivanovic via llvm-dev <span dir="ltr" class=""><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="">Would it make sense to:<br class=""><ol class=""><li class="">Provide the integer Major/Minor/Patch API's for use cases where the user wants to check that the loaded version is at least some version that contains a fix they're after</li><li class="">Provide a string API for the caching use case you outlined</li></ol></div></blockquote><div class=""><br class=""></div></span><div class="">The major, minor and patch level only works for "released" versions. If, for some reason, you then update to a version of LLVM that isn't a true release, what are those values? The "next" one, the "previous" one, something else? And what happens if you then pick up the next 583 commits that came in over night - which just so happens "breaks" the compatibility, or make some local changes to implement an intrinsic function, fix a linker bug, or whatever it is that you need to do to improve/fix your product?<br class=""><br class="">Nobody knows when and how these numbers reflect the details of your current release.<br class=""><br class="">Providing a string, which is not just some integer values and can change to "anything", based on for example a sha1 in git or a revision number in svn, is a much more reliable choice to know EXACTLY if it's the same source-code (and thus a compatible or incompatible "version"). It either matches, or it doesn't. There's no two versions that have the same identification, regardless of whether some distribution updated LLVM with their own fixes, whether the vendor that have their own backend uses a new version of their backend code [assuming it's part of the LLVM repo, at least - if it's not, perhaps they should reconsider that], etc, etc.<br class=""><br class="">--<br class=""></div><div class="">Mats<br class=""></div><div class=""><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="m_8354703690301694559HOEnZb"><div class="m_8354703690301694559h5"><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Feb 8, 2017 at 3:56 PM, Mehdi Amini <span dir="ltr" class=""><<a href="mailto:mehdi.amini@apple.com" target="_blank" class="">mehdi.amini@apple.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><br class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">On Feb 8, 2017, at 7:51 AM, Nemanja Ivanovic <<a href="mailto:nemanja.i.ibm@gmail.com" target="_blank" class="">nemanja.i.ibm@gmail.com</a>> wrote:</div><br class="m_8354703690301694559m_4605393106784991678m_6859429729845591090Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">So Mehdi,<br class=""></div>you're not in favour of providing this functionality then? </div></div></blockquote><div class=""><br class=""></div></span><div class="">I’m not against the functionality, but I’m not sure the API is the right one for the use-case.</div><span class=""><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class="">Or just not in favour of that use case?<br class=""></div></div></blockquote><div class=""><br class=""></div></span><div class="">The use-case (object cache) makes perfect sense, but I wouldn’t use this API.</div><div class="">I’d like use a `const char *getLLVMVersion()` API that would be documented as returning an opaque string representing the LLVM version.</div><div class="">The reason to return an opaque string is to prevent (not encourage…) users to parse it. It could return something like “LLVM 4.0.0svn(r12345)”.</div><div class="">Using this as part of your cache key makes it more robust to switching a given version of the compiler.</div><div class=""><br class=""></div><div class="">But ultimately, if I had to build such a caching system*, I’d likely do it upstream in LLVM and design the API to such that it would “just work” for my shader driver and could be maintained/improved by the community and reused by other users.</div><div class=""><br class=""></div><div class="">* <a href="https://github.com/llvm-mirror/llvm/blob/master/lib/LTO/Caching.cpp" target="_blank" class="">https://github.com/llvm-mirr<wbr class="">or/llvm/blob/master/lib/LTO/Ca<wbr class="">ching.cpp</a> <a href="https://github.com/llvm-mirror/llvm/blob/master/include/llvm/Support/CachePruning.h" target="_blank" class="">https://github.com/llvm-mirror<wbr class="">/llvm/blob/master/include/llvm<wbr class="">/Support/CachePruning.h</a> </div><div class=""><br class=""></div><div class="">— </div><span class="m_8354703690301694559m_4605393106784991678HOEnZb"><font color="#888888" class=""><div class="">Mehdi</div></font></span><div class=""><div class="m_8354703690301694559m_4605393106784991678h5"><div class=""><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Feb 8, 2017 at 10:18 AM, Mehdi Amini <span dir="ltr" class=""><<a href="mailto:mehdi.amini@apple.com" target="_blank" class="">mehdi.amini@apple.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br class="">
> On Feb 7, 2017, at 5:44 PM, Timothy Arceri via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>> wrote:<br class="">
><br class="">
> On Wed, 2017-02-08 at 00:12 +0100, Nemanja Ivanovic wrote:<br class="">
>> I am certainly willing to write up a patch to do this. I was hoping<br class="">
>> to get a few more responses/buy-in from the community.<br class="">
>> And honestly, I'd be interested to know if this can be back-ported to<br class="">
>> at least 4.0 if it gets accepted.<br class="">
><br class="">
> My *possible* use case is for identifying the version of llvm used to<br class="">
> compile shaders for AMD gpus. This information would be used with an<br class="">
> on-disk cache of compiled shaders allowing old cache items to be<br class="">
> ignored if llvm is upgraded.<br class="">
><br class="">
> One downside of this is there is no way to know if distros backport<br class="">
> fixes to llvm. If the version is not bumped then the a buggy cached<br class="">
> shader would continue to be used even after the distro makes the fix.<br class="">
<br class="">
</span>This is exactly why we don’t use this kind of versioning: it is fragile/unreliable.<br class="">
<br class="">
—<br class="">
<span class="m_8354703690301694559m_4605393106784991678m_6859429729845591090HOEnZb"><font color="#888888" class="">Mehdi<br class="">
</font></span><div class="m_8354703690301694559m_4605393106784991678m_6859429729845591090HOEnZb"><div class="m_8354703690301694559m_4605393106784991678m_6859429729845591090h5"><br class="">
<br class="">
><br class="">
><br class="">
>><br class="">
>> Now that I see that there's more interest in this than just my own,<br class="">
>> I'll put up a patch on Phabricator.<br class="">
><br class="">
> Cool, thanks!<br class="">
><br class="">
>><br class="">
>> On Wed, Feb 8, 2017 at 12:04 AM, Timothy Arceri via llvm-dev <llvm-de<br class="">
>> <a href="mailto:v@lists.llvm.org" target="_blank" class="">v@lists.llvm.org</a>> wrote:<br class="">
>>> On 01/26/2017 12:45 AM, Nemanja Ivanovic via llvm-dev wrote:<br class="">
>>>> This has actually come up in the context of a JIT, but I think<br class="">
>>> that<br class="">
>>>> having the functionality in general could be useful.<br class="">
>>>><br class="">
>>>> Currently, there does not appear to be an API in LLVM to query<br class="">
>>> for<br class="">
>>>> LLVM version information. In the particular context where this<br class="">
>>> came<br class="">
>>>> up, LLVM is used as a shared library and various functionality<br class="">
>>> (and<br class="">
>>>> bug fixes) used by the JIT is available in various LLVM versions.<br class="">
>>> So<br class="">
>>>> it would be quite convenient to be able to dynamically determine<br class="">
>>> the<br class="">
>>>> version that happens to be loaded.<br class="">
>>>><br class="">
>>>> Honestly, I am not completely clear on what the best place for<br class="">
>>>> something like this would be, but it appears that the following<br class="">
>>> seems<br class="">
>>>> like a natural choice:<br class="">
>>>><br class="">
>>>> llvm::VersionPrinter in lib/Support/CommandLine.cpp already<br class="">
>>> queries<br class="">
>>>> this data so it might make sense for it to expose the following<br class="">
>>> API's<br class="">
>>>> (as part of VersionPrinter, accessed through the instance):<br class="">
>>>> llvm::cl::getVersionMajor()<br class="">
>>>> llvm::cl::getVersionMinor()<br class="">
>>>> llvm::cl::getVersionPatch()<br class="">
>>><br class="">
>>> Hi,<br class="">
>>><br class="">
>>> I'm also interested in querying this at runtime. Has there been any<br class="">
>>> patches submitted for this yet?<br class="">
>>><br class="">
>>> Thanks,<br class="">
>>> Tim<br class="">
>>> ______________________________<wbr class="">_________________<br class="">
>>> LLVM Developers mailing list<br class="">
>>> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a><br class="">
>>> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/<wbr class="">mailman/listinfo/llvm-dev</a><br class="">
>>><br class="">
>><br class="">
>><br class="">
> ______________________________<wbr class="">_________________<br class="">
> LLVM Developers mailing list<br class="">
> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a><br class="">
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/<wbr class="">mailman/listinfo/llvm-dev</a><br class="">
<br class="">
</div></div></blockquote></div><br class=""></div>
</div></blockquote></div></div></div><br class=""></div></blockquote></div><br class=""></div>
</div></div><br class="">______________________________<wbr class="">_________________<br class="">
LLVM Developers mailing list<br class="">
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/<wbr class="">mailman/listinfo/llvm-dev</a><br class="">
<br class=""></blockquote></div></div></div><br class=""></div></div>
</blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></body></html>