<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 19 April 2017 at 17:22, Anshuman Dhuliya 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="ltr"><div>Is it the case that for each C stack variable there will always be and 'alloca' statement. If so, we can identify all such variables.<br></div></div></blockquote><div><br></div><div>That would only hold true before the mem2reg pass, which makes the alloca into registers whenever possible.<br><br></div><div>And conversely, the compiler may well introduce temporary allocas that aren't referring to any variable in the source code.<br><br></div><div>I'd be surprised if there is a trivial way to tell this - more likely, you need source-code information (e.g. AST-level) to perform such analysis. Possibly debug info would be helpful too.<br><br>--<br></div><div>Mats<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div>And globals can be identified separately, I guess...<br></div><div class="gmail_extra"><br clear="all"><div><div class="m_8451706966627305711gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Thanks & Regards<br>Anshuman Dhuliya<br>
</div>PhD Scholar<div>CSE Department<br><div>IIT Bombay</div><div>Mumbai, India<br><div><br><br></div></div></div></div></div></div><div><div class="h5">
<br><div class="gmail_quote">On Wed, Apr 19, 2017 at 9:20 PM, Pushpinder Singh <span dir="ltr"><<a href="mailto:pushpinderdhaliwal00@gmail.com" target="_blank">pushpinderdhaliwal00@gmail.<wbr>com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello everyone,<br>
<br>
We are working on a particular points-to analysis. The final output of<br>
that analysis should not have the LLVM SSA temporaries (like, %0, %1).<br>
My doubt is that whether we can extract the normal C variables from<br>
LLVM IR or is there any way to differentiate between SSA temporary and<br>
local C variable?<br>
<br>
For e.g. in GCC I can check whether a particular variable is an SSA<br>
temporary like,<br>
<br>
if(TREE_CODE(t) == SSA_NAME)<br>
return true;<br>
<br>
Basically, I want to skip all those %0, %1 temporaries. But keep all<br>
those which refer to C variables. One way to do this would be to check<br>
whether a Value has been given a name by using hasName function. But<br>
it does not work every time. For e.g. in case of getelementptr<br>
instruction, this name refers to a member name of a structure (which<br>
is in SSA form).<br>
E.g.,<br>
<br>
define void @f() {<br>
entry:<br>
%s = alloca %struct.A, align 8<br>
%a = alloca i32, align 4 ; I can know that<br>
this is a C variable<br>
store i32 10, i32* %a, align 4<br>
%b = getelementptr inbounds %struct.A, %struct.A* %s, i32 0, i32 1<br>
; but this is not<br>
store i32* %a, i32** %b, align 8<br>
<br>
; and this is not a C variable, so hasName logic can not work here.<br>
%a1 = getelementptr inbounds %struct.A, %struct.A* %s, i32 0, i32 0<br>
store i32 30, i32* %a1, align 8<br>
ret void<br>
}<br>
<br>
Thanks,<br>
Pushpinder Singh<br>
</blockquote></div><br></div></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></div>