Tracing global variables use in llvm

I am trying to write a custom analysis pass. Below is a llvm-ir snippet from my module.

1 @my_string = common global i8* null, align 8
2 %tmp1 = load i8*, i8** @my_string, align 8
3 call void @copy_string(i8* %tmp1, i8* %tmp2, i8* %tmp3)

I wish to make a check, if one of the function parameters passed is a global variable or not? For instance in above example code, I wish to check if %tmp1 is a global variable or not?

Could you suggest the best way to achieve this?

Thanks in advance.

Hi Arun,

You can do it by iterating over arguments to function call and dyn_cast each of them to check if it is a global variable.

Regards,
Suyog