[llvm-dev] Problem of getNumOperands() for CallInst

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[llvm-dev] Problem of getNumOperands() for CallInst

Reshabh Sharma via llvm-dev
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

_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Problem of getNumOperands() for CallInst

Reshabh Sharma via llvm-dev

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


_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Problem of getNumOperands() for CallInst

Reshabh Sharma via llvm-dev
There's a getNumArgOperands() that counts just arguments to the function and not the callee itself. 

~Craig


On Wed, May 29, 2019 at 3:53 AM Bevin Hansson via llvm-dev <[hidden email]> wrote:

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

_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Problem of getNumOperands() for CallInst

Reshabh Sharma via llvm-dev
Dear Craig and Bevin,

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

Best regards,
------------------------------------------
Tingyuan LIANG
MPhil Student
Department of Electronic and Computer Engineering
The Hong Kong University of Science and Technology

From: Craig Topper <[hidden email]>
Sent: Wednesday, May 29, 2019 10:21 PM
To: Bevin Hansson
Cc: [hidden email]; Tingyuan LIANG
Subject: Re: [llvm-dev] Problem of getNumOperands() for CallInst
 
There's a getNumArgOperands() that counts just arguments to the function and not the callee itself. 

~Craig


On Wed, May 29, 2019 at 3:53 AM Bevin Hansson via llvm-dev <[hidden email]> wrote:

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

_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev