Search code examples
llvmllvm-clangllvm-irllvm-gccllvm-c++-api

llvm - Pass arguments to a pass


I need to tell the pass to look out for a specific function in the file. And I want to specify which function to look out for 'on the go' i.e when I run the pass. Any idea how I can do that? It's sort of like passing arguments to a function in theory.


Solution

  • Add a command line option using cl::opt<string> and set it when running your pass.

    Alternatively, if you are producing an IR from C or C++ using clang, you can utilize __attribute((__annotate__(("foo")))) to mark functions you are interested in.