<div dir="ltr">Hi Zeke,<div><br></div><div>Thanks for pointing this out.</div><div><br></div><div>You're right: the issue is that ORCv2 doesn't support code removal (yet). To work around that we need to rename the anonymous expression each time (e.g. __anon_expr.1, __anon_expr.2, ...). Sounds like we're not doing that at the moment. I'll try to get it fixed up shortly.</div><div><br></div><div>Cheers,</div><div>Lang.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Aug 8, 2019 at 11:08 AM Zeke Medley via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></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">Hi Praveen,<br>
<br>
Thanks for pointing that out :) That's my mistake.<br>
<br>
I might have been misidentifying the issue with the assert statement.<br>
With those fixes made function calls seem to all call the first<br>
function called in the REPL. For example:<br>
<br>
ready> def fib(n) if (n < 2) then n else fib(n - 1) + fib(n - 2);<br>
...<br>
ready> fib(40);<br>
Evaluated to 102334155.000000<br>
ready> fib(10); # This should not have the same result as the earlier call.<br>
Evaluated to 102334155.000000<br>
<br>
Both of those calls evaluate fib(40) despite the second one being a<br>
call to fib(10). The same goes for further calls to functions. If I<br>
subsequently define another function in the same repl session and call<br>
it, it uses the results of the first function call in that repl<br>
session:<br>
<br>
ready> def bar(x) x + 1;<br>
...<br>
ready> bar(1);<br>
Evaluated to 102334155.000000<br>
<br>
I suspect that this has to do with the fact that in ORCv2 we can no<br>
longer remove modules meaning that the code in<br>
HandleTopLevelExpression can't wrap up by removing the most recent<br>
module it added. The tutorial does lookups by creating a function with<br>
no arguments names "__anon_expr", calling it, then removing it AFIK<br>
and because ORCv2 doesn't allow for the removal part as of yet, my<br>
hunch is that the issue is there.<br>
<br>
Any thoughts from anyone?<br>
<br>
If this does end up being an issue with how the tutorial looks right<br>
now and not me making a mistake I'll happily volunteer to update the<br>
tutorials as needed :)<br>
<br>
Zeke<br>
<br>
On Wed, Aug 7, 2019 at 8:38 PM Praveen Velliengiri<br>
<<a href="mailto:praveenvelliengiri@gmail.com" target="_blank">praveenvelliengiri@gmail.com</a>> wrote:<br>
><br>
> Hi Zeke,<br>
> Bool conversion of Error returns True for Failure States and False for Success States.<br>
><br>
> assert(add_q && "HandleDefinition: Error adding a module."); - You're essentially checking against success state to assert the condition. Plus, Error have many handling APIs dealing with success and failure states, you can use them instead of assert.<br>
> That will trigger a runtime error if Error is not handled correctly with the reason.<br>
><br>
> Try this:<br>
> +assert(!add_q && "Handle Definition : Error Adding a Module");<br>
><br>
> Please let me know, if you ran any more problems with ORCV2.<br>
><br>
> Cheers!<br>
><br>
><br>
> On Thu, 8 Aug 2019 at 05:12, Zeke Medley via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
>><br>
>> Hi folks,<br>
>><br>
>> I'm working on migrating a JIT compiler from the old ORCv1 JIT APIs to<br>
>> the newer ORCv2 ones and am having some trouble getting the code from<br>
>> chapter 1 of the "Building a JIT" [1] tutorial working properly. I<br>
>> have previously walked through the "My First Langauge" [2] tutorial<br>
>> and that went smoothly using the provided JIT class, but using the one<br>
>> from the JIT tutorial is giving me trouble.<br>
>><br>
>> Kaleidoscope builds fine using Clang and LLVM version 9, but fails on<br>
>> an expression like this:<br>
>><br>
>> ready> fun foo(c) c;<br>
>> Read function definition:<br>
>> define double @foo(double %c) {<br>
>> entry:<br>
>>   ret double %c<br>
>> }<br>
>><br>
>> kaleidoscope: kaleidoscope_baseline.cpp:980: void HandleDefinition():<br>
>> Assertion `add_q && "HandleDefinition: Error adding a module."'<br>
>> failed.<br>
>> Aborted<br>
>><br>
>> I'm using the exact source code from the tutorials to reproduce the<br>
>> problem with some tiny changes to the front end to deal with some<br>
>> slight API changes introduced in the JIT tutorial where some functions<br>
>> return Expected. For example, the specific place that this is failing:<br>
>><br>
>>             FnIR->print(errs());<br>
>>             fprintf(stderr, "\n");<br>
>> -           TheJIT->addModule(std::move(TheModule));<br>
>> +          auto add_q = TheJIT->addModule(std::move(TheModule));<br>
>> +          assert(add_q && "HandleDefinition: Error adding a module.");<br>
>>             InitializeModuleAndPassManager();<br>
>><br>
>><br>
>> I've looked at a previous thread discussing moving from ORCv1 to ORCv2<br>
>> [3] and watched the "Updating ORC JIT for Concurrency” talk by L.<br>
>> Hames & B. Loggins, but am still having a little trouble getting my<br>
>> head around everything without walking through a complete tutorial.<br>
>> I'd appreciate any guidance that you folks have on the migration as<br>
>> well as some help with this specific issue. I'm happy to share more<br>
>> about the source code and build settings if that is helpful.<br>
>><br>
>> Thanks in advance,<br>
>><br>
>> Zeke<br>
>><br>
>> [1] <a href="https://llvm.org/docs/tutorial/BuildingAJIT1.html" rel="noreferrer" target="_blank">https://llvm.org/docs/tutorial/BuildingAJIT1.html</a><br>
>> [2] <a href="https://llvm.org/docs/tutorial/MyFirstLanguageFrontend/index.html" rel="noreferrer" target="_blank">https://llvm.org/docs/tutorial/MyFirstLanguageFrontend/index.html</a><br>
>> [3] <a href="https://groups.google.com/forum/#!searchin/llvm-dev/orcv2%7Csort:date/llvm-dev/UNXf9EOw43g/w3qOKLYbAwAJ" rel="noreferrer" target="_blank">https://groups.google.com/forum/#!searchin/llvm-dev/orcv2%7Csort:date/llvm-dev/UNXf9EOw43g/w3qOKLYbAwAJ</a><br>
>> _______________________________________________<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="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
_______________________________________________<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="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>