[llvm-dev] Why getNumOperands() incorrectly returns 0?

Alberto Barbaro via llvm-dev llvm-dev at lists.llvm.org
Mon Mar 18 11:23:44 PDT 2019


Thanks Tim,
using arg_begin I solved my problem.

Thanks again

Il giorno sab 16 mar 2019 alle ore 08:45 Tim Northover <
t.p.northover at gmail.com> ha scritto:

> Hi Alberto,
>
> On Sat, 16 Mar 2019 at 07:25, Alberto Barbaro via llvm-dev
> <llvm-dev at lists.llvm.org> wrote:
> > The problem is that when I do F->getNumOperands() I have 0 as result.
> >
> > Can you explain me why please?
>
> You should think of a "Function *" like any other GlobalValue, in that
> what you've got during your visit is really just @png_set_mem_fn. That
> (pointer to a function) doesn't depend on any other LLVM values, so it
> doesn't have any operands. If and when you call it, the Function will
> continue to have no operands but the CallInst will have the operands
> you're expecting to see here.
>
> However, because it's a defined Function it does have other structure;
> and if you want to look at what arguments it might take if you called
> it, you need to use Function::arg_begin or related iterators. Because
> there aren't actually any values associated with those arguments
> outside the function body, you'll only be able to meaningfully use
> their type (and maybe their name).
>
> Cheers.
>
> Tim.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190318/d9dd9fd5/attachment.html>


More information about the llvm-dev mailing list