Identify which LLVM function is currently being invoked ?

Hi All
Is there any way to identify which LLVM function is currently executing in the program. It would be nice to know or print what is the corresponding LLVM function is executing/



There’s no general way to do this, but if you control the IR, it’s pretty easy to insert a call to a trace function at the beginning and end of each function. You could also write a pass to do the same thing.

basic steps:

  • add a function declaration to the module for your trace function (i.e. “puts”)
  • insert calls to that function using constant strings as arguments (so the address is fixed)
  • provide a definition for your trace function (i.e. linking)