(no subject)

I am interested in getting llvm IR only for a subset of the input source code - basically starting from a specified top level function, including all its callee functions (recursively).

For example, in the following code, I am interested in a command like “extract -top_function blah()” that will create an llvm IR with just blah() and foo().

int foo() {


int blah() {

int junk() {

int main() {

I can imagine writing some kind of FunctionPass that filters for specified function etc. But is there already some pass/command/tool that already does something similar?

Thanks in advance for helping a newbie!


fixing missing subject line in original email.

Hi Ananth,

I’m not sure about a tool that already does it, but there is code to construct a callgraph that you could use to write a pass to do this.

Have you looked at llvm-extract tool ?