[llvm-dev] Get arguments of a function (bitcast)
John Criswell via llvm-dev
llvm-dev at lists.llvm.org
Wed Jan 13 06:44:00 PST 2016
Dear Mohammad,
Are you trying to get the formal arguments or the actual arguments?
If you're trying to get the actual arguments, you can use the CallSite
class (http://llvm.org/doxygen/classllvm_1_1CallSite.html). Create a
local CallSite variable constructed from the Instruction * (in this
case, a CallInst). You can then use the getArgument() method to get the
various operands to the call site. The CallSite class is nice because
it abstracts away details of the CallInst and InvokeInst instructions.
If you want the formal arguments, you need to find the function that the
CallInst calls. You can do that as Manual suggests. However, keep in
mind that the CallInst may be an indirect call and, therefore, you may
not see a Function constant. In that case, you'll need to use a call
graph analysis pass (like DSA) to determine which set of functions the
CallInst can call.
Regards,
John Criswell
On 1/12/16 10:43 AM, Mohammad Norouzi via llvm-dev wrote:
> Hi All,
>
> I need to get the list of arguments of a function which is bitcasted.
>
> Here is the C code excerpt:
>
> main()
> {
> .....
>
> /* Get input samples */
> input_dsp(input, N, 1);
>
> .....
> }
>
> and here is llvm ir for the code section:
>
> %call = call i32 (i32*, i32, i32, ...)* bitcast (i32 (...)* @input_dsp
> to i32 (i32*, i32, i32, ...)*)(i32* getelementptr inbounds ([256 x
> i32]* @input, i32 0, i32 0), i32 256, i32 1)
>
>
> When I use the ordinary method for getting arguments,
>
> for (Function::ArgumentListType::iterator it =
> f->getArgumentList().begin(); it != f->getArgumentList().end(); it++)
> {...}
>
> i get a segmentation fault which i think i valid. But how can i get
> arguments of /input_dsp/ which are /input/, /N/ and /1/ in this case.
>
> Best,
> Mo
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
--
John Criswell
Assistant Professor
Department of Computer Science, University of Rochester
http://www.cs.rochester.edu/u/criswell
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160113/0260a21c/attachment.html>
More information about the llvm-dev
mailing list