How to identify a library function call in IR?

Hi all,

Recently I’ve been working on LLVM IR. I need to identify function calls to a dynamic library, like glibc. I found isDeclaration() of Function class might be useful. So could it identify external function calls? Is there a more graceful way of identifying such calls?

Moreover, when used in a link-time optimization pass, will it give out different results from those when used in a normal optimization pass?

Thanks.

Hi,

I need to identify function calls to a dynamic library, like glibc. I found isDeclaration() of Function class might be useful. So could it identify external function calls? Is there a more graceful way of identifying such calls?

I guess the library_call field in Linalg Dialect would be helpful. And currently I have finished the path with: a pytorch code → torch-mlir → mlir → llvm → objective file. Here’s what we discussed before.

Hope this could be helpful. :slight_smile:

Btw, I’m committing some code about it. Wish to be merged soon.

Thank you for your notification. However, I was working on the traditional IR instead of MLIR when I posted this topic. I was trying to pick out calls to library functions in a traditional C/C++ program, so Linalg Dialect offers little help for this problem. But thanks for the information anyway. Hope you are doing well in your project.

Thank you