Hello All, I was wondering how I could determine the values of function arguments using the iterators defined in Function.cpp. Any advice or hints would be great..! Basically, what I am trying out is: Function foo has the following function body: int foo(int a, int b) { } Function * f = module->getFunction("foo"); Function::arg_iterator start = f->arg_begin(); Function::arg_iterator end = f->arg_end(); while(start != end) { Argument * value = (Argument *)start; cout << "\n Argument: << value->getNameStr(); start++; } This piece of code works if 'module' contains the definition of function foo. Otherwise, I just get blanks even though the number returned by arg_size() is two. If foo is just a function being called from 'module', then how do I determine the arguments. -- Thanks, Hemanth -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100722/6851e67d/attachment.html>
Hi Hemanth,> I was wondering how I could determine the values of function arguments > using the iterators defined in Function.cpp.are you sure you aren't confusing values and names? In something like this int foo(int a, int b) there are names "a" and "b". To make it easier for humans to read LLVM IR, most front-ends will use the same names for the function arguments in the LLVM IR. But names are entirely optional, and everything works fine if all function arguments are nameless. So in general you can't hope to extract "a" and "b" from the LLVM IR. What do you want the names for? They aren't needed to use and manipulate arguments.> This piece of code works if 'module' contains the definition of function > foo. Otherwise, I just get blanks even though the number returned by > arg_size() is two.No names :) Ciao, Duncan.
Hi Duncan, Thanks for the clarification. My doubt is to know how I can extract the values contained in the arguments from LLVM IR. Thanks, Hemanth On Thu, Jul 22, 2010 at 2:28 AM, Duncan Sands <baldrick at free.fr> wrote:> Hi Hemanth, > > > I was wondering how I could determine the values of function arguments > > using the iterators defined in Function.cpp. > > are you sure you aren't confusing values and names? In something like > this > int foo(int a, int b) > there are names "a" and "b". To make it easier for humans to read LLVM > IR, most front-ends will use the same names for the function arguments > in the LLVM IR. But names are entirely optional, and everything works > fine if all function arguments are nameless. So in general you can't hope > to extract "a" and "b" from the LLVM IR. > > What do you want the names for? They aren't needed to use and manipulate > arguments. > > > This piece of code works if 'module' contains the definition of function > > foo. Otherwise, I just get blanks even though the number returned by > > arg_size() is two. > > No names :) > > Ciao, > > Duncan. > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- Cheers, Hemanth -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100722/7c0554e1/attachment.html>