<div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div>Hi Rasha,<br><br></div><div>What are you actually trying to do?<br></div><div><br></div>This is not something that can be done trivially. Obviously for this particular code-sequence:<br><br>   {<br></div>     int a = 0;<br></div>     a++;<br></div>     printf("a=%d", a);<br>   }<br><br></div>the compiler may well optimize it to `printf("a=%d\n", 1)` - and you could get the value from the constant integer that is in the IR after optimisations. <br><br></div>If we ignore such trivial cases, and look at REAL code, that actually does things:<br><br>    {<br></div>        int a;<br></div>        a = rand() % 11;<br></div>        if (a < 5)<br></div>            a++;<br></div>        else<br></div>            a--;<br>        printf("a=%d", a);<br>    }<br><br></div>This can't be understood by the compiler, and it's impossible to get the value of `a`, other than by storing the value with a store instruction [you need a defined place to store it, however, which makes life a bit difficult].<br><br></div>If you have a specific use-case that you want this for, perhaps there is something "better", so perhaps if you can explain what you are actually trying to do, maybe someone can give you a better suggestion - no promises tho'. (For example, debuggers are able to figure out, through information stored in the debug info, how to get to a particular variable's value - not 100% of cases, even after optimizations - but some opts some do crazy things like invert loop counts to save an instruction, which will make this break tho')<br><br>--<br></div>Mats<br><div><div><div>       <div><div><div><div><div><div><div><div><div><br></div></div></div></div></div></div></div></div></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 6 July 2017 at 21:29, Rasha Omar via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div><div style="direction:rtl"><p style="direction:ltr;box-sizing:border-box;margin:0px 0px 0.8em;padding:0px;border:0px;line-height:inherit;vertical-align:baseline"><br></p></div></div><div><p style="box-sizing:border-box;margin:0px 0px 0.8em;padding:0px;border:0px;line-height:inherit;vertical-align:baseline"><span style="background-color:rgba(255,255,255,0)">If I have this example:</span></p><pre style="box-sizing:border-box;margin-top:0px;margin-bottom:0.8em;padding:10px;border:0px;line-height:inherit;vertical-align:baseline;word-wrap:normal;max-height:300px;overflow:auto"><code style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant-caps:inherit;line-height:inherit;vertical-align:baseline;max-height:300px;overflow:auto;white-space:normal;background-color:rgba(255,255,255,0)"><font face="UICTFontTextStyleBody">int a=0, b=0;
</font></code></pre><p style="box-sizing:border-box;margin:0px 0px 0.8em;padding:0px;border:0px;line-height:inherit;vertical-align:baseline"><span style="background-color:rgba(255,255,255,0)">a and b are local variables and make any modifications in their values, such as:</span></p><pre style="box-sizing:border-box;margin-top:0px;margin-bottom:0.8em;padding:10px;border:0px;line-height:inherit;vertical-align:baseline;word-wrap:normal;max-height:300px;overflow:auto"><code style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant-caps:inherit;line-height:inherit;vertical-align:baseline;max-height:300px;overflow:auto;white-space:normal;background-color:rgba(255,255,255,0)"><font face="UICTFontTextStyleBody">a++;
b++;
</font></code></pre><p style="box-sizing:border-box;margin:0px 0px 0.8em;padding:0px;border:0px;line-height:inherit;vertical-align:baseline"><span style="background-color:rgba(255,255,255,0)">I need to get the value in this line code during running MCJIT. </span></p><p style="box-sizing:border-box;margin:0px;padding:0px;border:0px;line-height:inherit;vertical-align:baseline"><span style="background-color:rgba(255,255,255,0)">I mean by value not <code style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant-caps:inherit;line-height:inherit;vertical-align:baseline;max-height:300px;overflow:auto">Value</code> class, but the actual integer or any type value.</span></p><br><br></div><div><br><br>Sent from my iPhone</div></div><br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>