Problem of getNumOperands() for CallInst

Hi all,

I got a interesting problem when calling getNumOperands() of CallInst.
For example,
call void @_Z2f2PA100_i([100 x i32]* nonnull %arraydecay)

If I use getNumOperands(), it will return 2.
However, if I use getCalledFunction()->getNumParams(), it will return 1.
According to the IR, I think the number of operands of the call instruction should be 1.
I wonder what is going on for this situation.
Thanks in advance for your time and suggestion!

Best regards,

Tingyuan LIANG
MPhil Student
HKUST

Hi Tingyuan,

For example,
call void @_Z2f2PA100_i([100 x i32]* nonnull %arraydecay)

If I use getNumOperands(), it will return 2.
However, if I use getCalledFunction()->getNumParams(), it will return 1.
According to the IR, I think the number of operands of the call instruction should be 1.

I think you’ll find that the first operand of the ‘call’ instruction is the callee (the function being called) itself. So two operands makes sense in your case: one callee and one parameter.

/ Bevin

There’s a getNumArgOperands() that counts just arguments to the function and not the callee itself.

Dear Craig and Bevin,

THANKS for your information! I get it!
Sorry that I ignore the callee and thanks for your suggestion!!!
:slight_smile: