Help with creating a pass to insert a call to library function

Ajay Kumar nitk.ajay@gmail.com
Wed Mar 24 12:13:00 GMT 2010


Hi,

I am writing a pass in which I need to insert a call to a library
function. Specifically I need to call the function
"pthread_mutex_lock" from the library "pthread".

Looking around the documentation, what I found is I will have to use
the function gimple_build_call. My question is how do I build the tree
fn, and the arguments which have to be provided to gimple_build_call.

I also found a function which does something similar,
"build_libfunc_function", but I'm not sure which one can be used for
this purpose.

Do I have to use build_function_type_list and build_fn_decl for
building tree fn? The original function call "pthread_mutex_lock"
requires an "pthread_mutex_t" type variable as an argument, how can I
declare that in the pass, and use it as an argument in
gimple_build_call?

Thanks,
Ajay.



More information about the Gcc-help mailing list