# Suggest example of using LLVM IR function as @intrinsic

**URL:** <https://numba.discourse.group/t/suggest-example-of-using-llvm-ir-function-as-intrinsic/911>\
**Category:** Numba\
**Created:** [September 14, 2021, 3:46pm UTC](https://numba.discourse.group/t/suggest-example-of-using-llvm-ir-function-as-intrinsic/911 "2021-09-14T15:46:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![moytrage](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/moytrage/32/405_2.png) [@moytrage](https://numba.discourse.group/u/moytrage)\
**Post date:** [September 14, 2021, 3:46pm UTC](https://numba.discourse.group/t/suggest-example-of-using-llvm-ir-function-as-intrinsic/911/1 "2021-09-14T15:46:52Z")

</div>

Hi! For example I have C/C++ function

`extern "C" double Add(double a, double b) { return a + b; }`

which can be compiled to LLVM IR text assembly using command

`clang a.cpp -c -O3 -m64 -emit-llvm -S`

which produces a.ll having this function

```auto
define dso_local double @Add(double %a, double %b) local_unnamed_addr #0 {
entry:
  %add = fadd double %a, %b
  ret double %add
}

```

Can I use this function assembly inside Numba’s `@intrinsic`? My main goal to make this function’s body being inlined and optimized into njit function’s code. So that if I use my LLVM IR function from above in njit-ed function then whole code of njit-ed function and my IR function above is mixed and optimized together as a whole.

I see there is example of compiling LLVM IR into CFUNC here [Example—compiling a simple function — llvmlite 0.37.0-dirty documentation](https://llvmlite.readthedocs.io/en/stable/user-guide/binding/examples.html)

But this CFUNC solution will have an overhead of CALL instruction if I use it from njit. In other words it is not optimized and not inlined together with njit-ed function were it is called from.

I need some minimal but fully working example of how to embed (wrap) LLVM IR text assembly into intrinsic function and then use this intrinsic inside njit-ed function.

---

<div class="post-metadata">

**Author:** ![moytrage](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/moytrage/32/405_2.png) [@moytrage](https://numba.discourse.group/u/moytrage)\
**Post date:** [September 29, 2021, 4:56am UTC](https://numba.discourse.group/t/suggest-example-of-using-llvm-ir-function-as-intrinsic/911/2 "2021-09-29T04:56:53Z")

</div>

I already got two replies to topic’s question on GitHub here [https://github.com/numba/numba/issues/7371#issuecomment-929027456](https://github.com/numba/numba/issues/7371#issuecomment-929027456) and here [https://github.com/numba/numba/issues/2795#issuecomment-472013539](https://github.com/numba/numba/issues/2795#issuecomment-472013539)
