Turn on LLVM optimization pass

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?

Hi @COOLIRON2311

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?

No problem.

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 llvmlite’s ir.IRBuilder IR builders — llvmlite 0+untagged.g42db9b7 documentation, the easiest way to access this from Numba is via the extension API’s @intrinsic decorator High-level extension API — Numba 0+untagged.4124.gd4460fe.dirty documentation. Hope this helps?

1 Like