[llvm-dev] Using bytecode version of std::sort for JIT generated data type

Rajesh S R via llvm-dev llvm-dev at lists.llvm.org
Wed Jul 3 15:43:01 PDT 2019


Hi LLVM devs,
The performance of C++ std::sort comes from being able to inline the
comparator. For a JIT generated data type, using the comparator as a
function call from std::sort may not be ideal. So, i was wondering how can
we make a JIT-sort which is as good as statically compiled std::sort with
comparator inlined.

What is the recommended way to pass a an existing function like std::sort
into JIT so that it can optimize the whole program? For example, how do we
generate the bytecode for existing function (say some external tools) and
give to JIT runtime. Is there some code sample?

The alternative is to rollout my own Sort function inside JIT, but i don't
want to do that and want to take this as an opportunity to learn the
general approach of passing existing function definitions into JIT to do
whole program optimization like inlining.

I found this stackoverflow question
<https://stackoverflow.com/questions/10587250/fast-to-compile-efficient-sort-algorithm-for-jit-compilation>which
is related to what I am asking for, but I don't see any final conclusion on
this beyond incurring a function call for each comparison.

Thanks!

Rajesh S R
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190703/23c44b64/attachment.html>


More information about the llvm-dev mailing list