<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><br></div>And globals can be identified separately, I guess...<br></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_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>
<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.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>