Mohammad Norouzi via llvm-dev
2017-Mar-10 15:12 UTC
[llvm-dev] get function parameters (not arguments)
Hi Everyone, Does anyone know to get function parameters? For example, I want to get e and f in the call to function foo in the following code: foo(inr a , int b){ .... } main() { int e,f; e=10; f=22; *foo(e,f);* } I use the following code: for (auto& A : (cast<CallInst>(BI))->arg_operands ()) errs() << A.dump(); but I get a and b instead. Thank you and best -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170310/f0d2da9c/attachment.html>
Tim Northover via llvm-dev
2017-Mar-10 15:25 UTC
[llvm-dev] get function parameters (not arguments)
On 10 March 2017 at 15:12, Mohammad Norouzi via llvm-dev <llvm-dev at lists.llvm.org> wrote:> for (auto& A : (cast<CallInst>(BI))->arg_operands ()) errs() << A.dump(); > > but I get a and b instead.This sounds really weird. If you're analyzing a CallInst in main, %a and %b shouldn't even be available. Can you show us your actual IR and output? Cheers. Tim.
Mohammad Norouzi via llvm-dev
2017-Mar-10 15:41 UTC
[llvm-dev] get function parameters (not arguments)
Sorry i'm using the following code: F = (cast<CallInst>(BI))->getCalledFunction(); for (auto& A : F->getArgumentList()) { errs() << "------- " << A.getName() << " " << "11" << "\n"; } But how can I get the parameters (as e and f in the example)? Thank you and best, Mo On Fri, Mar 10, 2017 at 4:25 PM, Tim Northover <t.p.northover at gmail.com> wrote:> On 10 March 2017 at 15:12, Mohammad Norouzi via llvm-dev > <llvm-dev at lists.llvm.org> wrote: > > for (auto& A : (cast<CallInst>(BI))->arg_operands ()) errs() << > A.dump(); > > > > but I get a and b instead. > > This sounds really weird. If you're analyzing a CallInst in main, %a > and %b shouldn't even be available. Can you show us your actual IR and > output? > > Cheers. > > Tim. >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170310/9069b2e4/attachment.html>