I wanted to check the LLVM IR for a vector addition from numba and noticed it generates a lot of IR just for a simple add. I was hoping a simple "add" IR but it generates 2000 lines of LLVM IR. Is there a way to get a minimal code?
from numba import jit
import numpy as np
@jit(nopython=True,nogil=True)
def mysum(a,b):
return a+b
a, b = 1.3 * np.ones(5), 2.2 * np.ones(5)
mysum(a, b)
# Get the llvm IR
llvm_ir =list(mysum.inspect_llvm().values())[0]
print(llvm_ir)
with open("llvm_ir.ll", "w") as file:
file.write(llvm_ir)
# Get the assembly code
asm = list(mysum.inspect_asm().values())[0]
print(asm)
with open("llvm_ir.asm", "w") as file:
file.write(asm)