Thank you a lot for your response. I will try to use your approach with chasing back along def-use chains to find instructions that define the registers used in the load. Can you tell me please what class/methods/existing path are good for this? I assume that I must have a method with arguments like the variable used into a Load instruction and a "stop instruction", like an Alloca. <br>
<br>However, if I have something like :<br><br>I1 :   %a = alloca i32, align 4<br>....<br>I2 :   %5 = load i32* %a, align 4<br>I3 :   %b = add i32 %a, %c<br>....<br>I4 :   %8 = load i32* %b, align 4<br><br>I4 is dependent on I1 since %8 is obtained using %a (indirectly)<br>
<br>I think it is better to check dependencies also between loads (for the case when a Load is not directly linked to an Alloca), so I can identify :<br><br>if (  ( I2 is dependent on I1 ) and ( I3 is dependent on I4 )  )   => I can check if I3 and I2 are dependent => indirectly I4 is dependent on I1<br>
<br><br><br><div class="gmail_quote">On Thu, Jan 24, 2013 at 6:03 PM, Preston Briggs <span dir="ltr"><<a href="mailto:preston.briggs@gmail.com" target="_blank">preston.briggs@gmail.com</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 class="im">> I tried methods related to point 1) suggested by you,<div>> but I still have problems of finding dependencies.</div><div>> What exactly I want to do:<br>><br>> I have a chain like : Alloca -> Load(1) -> ... -> Computation</div>

<div>> where the variable might be changed -> Store(new_var) -> ... -> Load(n)<br><br></div></div><div>Your example is not very clear.</div><div>I don't understand what's involved in the "chain".</div>
<div class="im">
<div><br></div><div>> Computation where the variable is changed = means that :</div><div>> I might have Alloca(a),  c=a+7000*b[32], Load(c)...ICMP(c, ...)<br>><br>> I want to get the corresponding Alloca from every Load</div>

<div>> (corresponding from the point of view of the variable used,</div></div><div><div class="im">> meaning that the Load is using a variables based/dependent on the Alloca or Allocas).<br><br></div>I don't know any magical LLVM way to get all the answers.</div>

<div>My approach would be to do some ordinary data-flow analysis,</div><div>chasing back along def-use chains to find instructions that define</div><div>the registers used in the load, recursively, to the beginning.</div>

<div>If you hit an alloca, stop. </div><div><div class="im"><br>> I tried to use methods from DependencyAnalysis class.<br><br></div>DependenceAnalysis. Seems like a bad start.</div><div>Dependence analysis is used to determine how two</div>

<div>array references may interact. Nothing to do with alloca.</div><div class="im"><div><br>> 1. if (DA.depends(loadInstrArray[i],loadInstrArray[j],false)) - no result</div><div><br></div></div><div>I can't say if this is correct or not without a more complete example.</div>

<div>For instance, in the code</div><div><br></div><div>    for (i = 0; i < n; i += 2) {</div><div>        loadInstr[i] = 0;</div><div>        j = i + 1;</div><div>        loadInstr[j] = 1;</div>
<div>    }</div><div><br></div><div>there is no dependence between the two stores to loadInstr.</div><div>The two stores write entirely disjoint areas of memory.</div><div>On the other hand, if we have</div>
<div><br></div><div><div>    for (i = 0; i < n; i++) {</div><div>        loadInstr[i] = 0;</div><div>        j = 2*i;</div><div>        loadInstr[j] = 1;</div><div>    }</div><div><br></div><div>we expect to find a more interesting pattern.</div>
<span class="HOEnZb"><font color="#888888">
<div><br></div><div>Preston</div><div><br></div></font></span></div></div>
</blockquote></div><br><br clear="all"><br>-- <br><font style="background-color:rgb(255,255,255);color:rgb(153,153,153)">Best regards,</font><br style="background-color:rgb(255,255,255);color:rgb(153,153,153)"><font style="background-color:rgb(255,255,255);color:rgb(153,153,153)">Alexandru Ionut Diaconescu</font><br>