<div dir="ltr">Hi Steve,<div><br></div><div>Several people told me that LLVM TOT bcreader can read odder version of bitcode without any problem. Do you know the oldest version of bitcode that the TOT bitcode reader supports?</div><div><br></div><div>Also, why do you generate bitcode instead of the textural representation, i.e. the "ll" file, for older version of LLVM? I guess generating "ll" code is simpler.</div><div><br></div><div>Another approach I am thinking is linking to two different version of LLVM at the same time, and use the old version of IRBuilder to build bitcode from new version of LLVM IR. How do you think about this?</div><div><br></div><div>At last, we also do not support<span style="font-size:12.8px"> </span><span style="font-size:12.8px">exception handling:)</span></div><div><br></div><div><br></div><div>Thanks.</div><div>Hongbin</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 2, 2016 at 7:26 PM, Stephen Hines <span dir="ltr"><<a href="mailto:srhines@google.com" target="_blank">srhines@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Hongbin,<br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Tue, Aug 2, 2016 at 5:42 PM, Jakub Kuderski <span dir="ltr"><<a href="mailto:kubakuderski+llvm@gmail.com" target="_blank">kubakuderski+llvm@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><span style="font-size:12.8px">I also have a look at the code, looks like it directly parse the bitcode and build in memory representation in a different LLVM version than the bitcode. Is this correct?</span> </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><span style="font-size:12.8px">According to your description, I guess the </span><span style="font-size:12.8px">BitCodeWriter should be the one to do the bitcode version downgrade, right?</span> </blockquote></span><div>I think so.<br><br>I don't know much about it and don't want to give you misleading information; I'm cc-ing Stephen. <br> </div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On 2 August 2016 at 16:53, Hongbin Zheng <span dir="ltr"><<a href="mailto:etherzhhb@gmail.com" target="_blank">etherzhhb@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Thanks Jakub. Looks Like I didn't rely all.<div><br></div><div>I also have a look at the code, looks like it directly parse the bitcode and build in memory representation in a different LLVM version than the bitcode. Is this correct?</div></div></blockquote></div></div></div></div></blockquote><div><br></div></span><div>Yes, it uses a TOT reader (which can support reading all 3.x Bitcode), and then lowers the in-memory representation back through a forked version of the 3.2 BitcodeWriter.</div><span class=""><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div><div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div><div>According to your description, I guess the <span style="font-size:12.8px">BitCodeWriter should be the one to do the bitcode version downgrade, right?</span></div></div></blockquote></div></div></div></div></blockquote><div><br></div></span><div>Yes, we use a separately-maintained LLVM 3.2 BticodeWriter to generate the downgraded form. We also have 2 other BitcodeWriters based on roughly LLVM 2.9 (but not exactly 2.9, so I would steer you away from those). <a href="https://android.googlesource.com/platform/frameworks/compile/slang/+/refs/heads/master/BitWriter_3_2/" target="_blank">https://android.googlesource.com/platform/frameworks/compile/slang/+/refs/heads/master/BitWriter_3_2/</a> is a link to the actual primary writer we use.</div><span class=""><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div><div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Does this took work on LLVM 3.9svn?</span></div></div></blockquote></div></div></div></div></blockquote><div><br></div></span><div>It currently only works up to LLVM r256229. We will most likely be updating it to closer to TOT LLVM in the next few months, but it isn't an extreme priority for us right now. Usually, maintenance requires us to fix up any internal API differences that might have changed for walking/manipulating the in-memory representation.</div><span class=""><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div><div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">And could you give some hints about how you test the bitcode translator?</span></div></div></blockquote></div></div></div></div></blockquote><div><br></div></span><div>We have very few tests for this, and mostly rely on older Android devices running applications that we build using the translated bitcode. If the older device (which only has LLVM 3.2) passes those tests, we consider it a success. I suppose that we could take a 3.2-era BitcodeReader and wash bitcode back and forth through it, but I don't work directly on RenderScript these days.</div><div><br></div><div>One word of caution about reusing our BitcodeWriter passes - we have only ever cared about C99, so we definitely removed some code that relates to exception handling (and possibly some other C++-specific features). We also only expect IR constructs that come about from normal C99 compilation/optimization, so if you have handwritten IR, there may be unsupported instructions that we don't know how to generate legacy bitcode for.</div><div><br></div><div>Thanks,</div><div>Steve</div><div><div class="h5"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div><div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Thanks</span></div><span><font color="#888888"><div><span style="font-size:12.8px">Hongbin</span></div><div><br><div><br></div><div><br></div></div></font></span></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 2, 2016 at 3:25 PM, Jakub Kuderski <span dir="ltr"><<a href="mailto:kubakuderski+llvm@gmail.com" target="_blank">kubakuderski+llvm@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">I'm not sure if it was intended, but I think that you responded only to me (not to the list).<br><br>Anyway, RenderScript currently uses llvm 3.2 IR as binary representation/exchangeable format, but the llvm version is higher internally. Essentially, there it reads old bitcode and operates on the newer one in memory. When it's done, it's also able to output bitcode in the old format. The corresponding classes should be something like BitCodeReader and BitCodeWriter.<br>The reader/writer is maintained to work with Android's llvm version, which follows upstream llvm version.<br><br>I haven't worked on it myself, but if you have some specific questions, I should be able to point you to appropriate people.<br><br>Regards<br></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On 2 August 2016 at 15:17, Hongbin Zheng <span dir="ltr"><<a href="mailto:etherzhhb@gmail.com" target="_blank">etherzhhb@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Jakub,<div><br></div><div>Thanks a lot. Do you have any document about this tool? or could you gave me a rough idea what it do?</div><div><br></div><div>Thanks</div><span><font color="#888888"><div>Hongbin</div></font></span></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 2, 2016 at 3:06 PM, Jakub Kuderski <span dir="ltr"><<a href="mailto:kubakuderski+llvm@gmail.com" target="_blank">kubakuderski+llvm@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Hongbin,<br><br>Android's RenderScript uses a tool like that. You can find the sources here: <a href="https://android.googlesource.com/platform/frameworks/compile/libbcc/+/master/bcinfo/" target="_blank">https://android.googlesource.com/platform/frameworks/compile/libbcc/+/master/bcinfo/</a> .<br><br>Best,<br>Jakub<br><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On 2 August 2016 at 11:10, Hongbin Zheng 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></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div><div><div dir="ltr">Hi mailing list,<div><br></div><div>I has been working on a large project that is based on LLVM 3.1. Recently we are thinking to introduce an LLVM bc converter from LLVM 3.9 to LLVM 3.1, such that we can introduce some of the newest LLVM analyses and optimizations to our  LLVM 3.1 based project.</div><div><br></div><div>Have you worked on similar things that converting LLVM bc downward and has anything to share?</div><div><br></div><div>Thanks</div><span><font color="#888888"><div>Hongbin</div></font></span></div>
<br></div></div>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div></div></div><br></div></div>
</blockquote></div><br></div></div>