Defining user definition function through llvm pass

In any case, I can determine if the function is called by the user by the user or not? For instance:

void foo() { printf("hello world again"); } int main() { printf("hello world\n"); foo(); } 

As in this case, foo () is the defining user, while printf () is the library function.

The method I'm currently using is to iterate over all the modules and check if its size is greater than 0 or not. i.e:

 for(Module::iterator F = M.begin(); F != M.end(); ++F) { Function &Func = *F; if(F->size()>0) errs() << "User Define"; } 

But I'm not sure of its accuracy?

+6
source share
1 answer

You can use the isDeclaration method to check if a function is defined or just declared in a module. This will allow you to distinguish between functions whose implementation is in the module and functions that are expected to be found outside it.

+7
source

Source: https://habr.com/ru/post/970030/


All Articles