Alberto Barbaro via llvm-dev
2018-Dec-29 09:27 UTC
[llvm-dev] How to get the function's parameters value at runtime?
Hi all, I'm still experimenting with the Interpreter class and in this case I would like to know a couple of things if possible. Suppose that "instruction" is a StoreInst & that is part of a function called sum with the following prototype: int sum(int a, int b);. During the execution sum is called passing two integer (e.g. 1,2). When the "instruction" is about to be interpreted how can I get the value of a and b? I access to the first argument using Argument *argument = I.getFunction()->arg_begin(), is it the proper way? The relevant IR is: %2 = call i32 @sum(i32 1, i32 2) %3 = alloca i32, align 4 %4 = alloca i32, align 4 %5 = alloca i32, align 4 store i32 %0, i32* %3, align 4 In addition, if I call instruction.getValueOperand() and on the result I call ->dump() I can see i32 %0 as expected but what kind of instruction is returned by getValueOperand()? In the end I would like to understand how to identify if the %0 is a parameter or not. Thanks a lot Alberto -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181229/87f8920a/attachment.html>