[LLVMdev] Passing Arguments to External Function Call in llvm pass

Abhinash Jain
Fri, 20 Sep 2013 20:08:12 -0000

I have a external function which is like this :-
void foo(int num, ...)
{
       va_list arguments;
       va_start(arguments,num);
       for(int x=0;x<num;x++)
       {
		long long *oprnd=va_arg ( arguments, long long* );
        }
	va_end ( arguments );
}

And on llvm pass i have one vector of Value* (i.e. vector&lt;Value*>
vect).
which basically contains getoperand(0) of all Load instruction present on
some test program.
eg.

  load i32* %a, align 4
  vect.push_back(getoperand(0))
  load i32* %b, align 4
  vect.push_back(getoperand(0))     . So on.

Now How can I pass this vector to the external foo(int, ...) function???

What should I use to declare the foo function in my pass (so that it works
fine on both 32-bit and 64-bit system)-
Type::getInt32Ty(*Context) or
Type::getInt64Ty(*Context) or
Type::getIntPtr32Ty(*Context) or
Type::getInt64Ty(*Context). etc.




--
View this message in context:
http://llvm.1065342.n5.nabble.com/Passing-Arguments-to-External-Function-Call-in-llvm-pass-tp61367.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.