<div dir="ltr"><div>Hi Zeke,</div><div>Bool conversion of Error returns True for Failure States and False for Success States. </div><div><br></div><div>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.</div><div>That will trigger a runtime error if Error is not handled correctly with the reason. <br></div><div><br></div><div>Try this:<br></div><div>+assert(!add_q && "Handle Definition : Error Adding a Module"); <br></div><div><br></div><div>Please let me know, if you ran any more problems with ORCV2. <br></div><div><br></div><div>Cheers!<br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 8 Aug 2019 at 05:12, 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:1px solid rgb(204,204,204);padding-left:1ex">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>
</blockquote></div>