<div dir="ltr"><div>Thanks for the clarification Lang! I didn't know about CodeGenOpt before. I'll give it a try to see if it fixes the issue.</div><div><br></div><div>Thanks again!</div><div>Haoran<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Lang Hames <<a href="mailto:lhames@gmail.com">lhames@gmail.com</a>> 于2020年9月6日周日 下午11:03写道:<br></div><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"><div dir="ltr"><div dir="ltr">Hi Haoran,<div><br></div><div>LLJIT uses CodeGenOpt::Default by default, whereas I suspect -O3 uses CodeGenOpt::Aggressive. You can configure this by setting/modifying the JITTargetMachineBuilder member of your LLJITBuilder before calling create.</div><div><br></div><div>You can also try attaching a DumpObjects instance to your JIT to dump the JIT'd objects to disk: sometimes comparing objects can offer useful insights. You can find an example of this in llvm/examples/OrcV2Examples/LLJITDumpObjects.</div><div><br></div><div>Regards,</div><div>Lang.</div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Sep 3, 2020 at 7:01 PM Haoran Xu via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">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"><div dir="ltr"><div>Hello,</div><div><br></div><div>I recently noticed a performance issue of JIT execution vs native code of the following simple logic which computes the Fibonacci sequence:</div><div><br></div><div>uint64_t fib(int n) {<br>     if (n <= 2) {<br>              return 1;<br>     } else {<br>              return fib(n-1) + fib(n-2);<br>   }<br>}<br></div><div><br></div><div>When compiled natively using clang++ with -O3, it took 0.17s to compute fib(40). However, when executing using LLJIT, fed with the IR output of "clang++ -emit-llvm -O3", it took 0.26s.</div><div><br></div><div>I don't know much about the internals of LLJIT, but my guess is since the IR is the same, maybe LLJIT used a cheaper but lower quality instruction selection pass, resulting in the slower runtime? Could someone working on LLJIT clarify the difference in lowering passes between LLJIT and clang++? And if I were to change this behavior, which APIs should I look at to begin with?<br></div><div><br></div><div>Thanks for your time!</div><div><br></div><div>Best regards,<br></div><div>Haoran</div><div><br></div><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="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>
</blockquote></div>