[llvm-dev] How to pass the current function name at runtime without additional Global variables?

Alberto Barbaro via llvm-dev llvm-dev at lists.llvm.org
Sun Jan 9 00:42:23 PST 2022


Hi all,
I'm working on a little LLVM pass that should add a call to an external
function ( C++ project ) and pass as a parameter the name of the function
that is about to be called. I have a problem finding a nice way to pass the
current function name. In fact, so far,  Unfortunately the only solution
that I have found for passing the name is to create a global for each
function, store the name there and pass it as a parameter. I don't really
like this solution because the size of the final binary increases and the
overall approach feels not  optimal.

Assuming that I have a variable `I` which is the CallInst instruction, is
it possible to pass the function name at runtime to my external library in
a nice way? I thought about passing the address of the instruction and
casting it back to the CallInst instruction but I don't know how to do it.

Any suggestions?

Thanks
Alberto
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20220109/d5ee6908/attachment.html>


More information about the llvm-dev mailing list