I’m working through the Kaleidoscope tutorial. The mini language has a JIT and it can call out to C functions by creating an llvm::Function
with the C function’s name. The JIT then looks up the implementation in the current process’s symbol table.
But I’ve added types to my mini-language, so I wanted to write some overloaded functions like:
func print(x: Int) { ... }
func print(s: String) { ... }
...
It’s simple to define those in C++, but then I don’t know the mangled name to give to the Function::Create(...)
constructor.
Is there a way to either:
- Create the
llvm::Function
with a function pointer, so it doesn’t use the name to look up the implementation. - Get the mangled name of a C++ function at runtime?
I know how to get a mangled name by running nm
and looking at the output. But that would be a bit weird - I’d have to compile once, then use nm to look at function names, then add them as strings in my code and compile again.
thanks,
Rob