Is there a way to turn on tail call elimination pass of LLVM in Numba? If not, how in general can a custom pass be implemented for this task?
I’m afraid there’s no way to do this yet, you’d have to subclass quite a bit of the compilation stack to eventually override parts of this:
which runs the optimisers. This is something we’re hoping to create a better abstraction for in the future.
Thanks for the information, @stuartarchibald !
It’s just that I’m thinking about doing a course work on this topic (tail call elimination). So, any info regarding the topic would be valuable for me.
For example, any documentation on manipulating generated llvm ir and assembly from numba.
And in conclusion, in your opinion, can at least a subset of the desired functionality be achieved by writing a custom pass on numba’s own ir as described here?
I’m not sure that Numba IR is the right level for performing such an optimisation, it’s too high level. When Numba lowers its IR it emits LLVM IR via
builder classes based on
ir.IRBuilder IR builders — llvmlite 0.37.0-dirty documentation, the easiest way to access this from Numba is via the extension API’s
@intrinsic decorator High-level extension API — Numba 0.54.1+0.g39aef3deb.dirty-py3.7-linux-x86_64.egg documentation. Hope this helps?