[LLVMdev] llvm alloca dependencies

Alexandru Ionut Diaconescu alexandruionutdiaconescu at gmail.com
Fri Jan 25 01:23:31 PST 2013


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.

However, if I have something like :

I1 :   %a = alloca i32, align 4
....
I2 :   %5 = load i32* %a, align 4
I3 :   %b = add i32 %a, %c
....
I4 :   %8 = load i32* %b, align 4

I4 is dependent on I1 since %8 is obtained using %a (indirectly)

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 :

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



On Thu, Jan 24, 2013 at 6:03 PM, Preston Briggs <preston.briggs at gmail.com>wrote:

> > I tried methods related to point 1) suggested by you,
> > but I still have problems of finding dependencies.
> > What exactly I want to do:
> >
> > I have a chain like : Alloca -> Load(1) -> ... -> Computation
> > where the variable might be changed -> Store(new_var) -> ... -> Load(n)
>
> Your example is not very clear.
> I don't understand what's involved in the "chain".
>
> > Computation where the variable is changed = means that :
> > I might have Alloca(a),  c=a+7000*b[32], Load(c)...ICMP(c, ...)
> >
> > I want to get the corresponding Alloca from every Load
> > (corresponding from the point of view of the variable used,
> > meaning that the Load is using a variables based/dependent on the Alloca
> or Allocas).
>
> I don't know any magical LLVM way to get all the answers.
> My approach would be to do some ordinary data-flow analysis,
> chasing back along def-use chains to find instructions that define
> the registers used in the load, recursively, to the beginning.
> If you hit an alloca, stop.
>
> > I tried to use methods from DependencyAnalysis class.
>
> DependenceAnalysis. Seems like a bad start.
> Dependence analysis is used to determine how two
> array references may interact. Nothing to do with alloca.
>
> > 1. if (DA.depends(loadInstrArray[i],loadInstrArray[j],false)) - no result
>
> I can't say if this is correct or not without a more complete example.
> For instance, in the code
>
>     for (i = 0; i < n; i += 2) {
>         loadInstr[i] = 0;
>         j = i + 1;
>         loadInstr[j] = 1;
>     }
>
> there is no dependence between the two stores to loadInstr.
> The two stores write entirely disjoint areas of memory.
> On the other hand, if we have
>
>     for (i = 0; i < n; i++) {
>         loadInstr[i] = 0;
>         j = 2*i;
>         loadInstr[j] = 1;
>     }
>
> we expect to find a more interesting pattern.
>
> Preston
>
>


-- 
Best regards,
Alexandru Ionut Diaconescu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130125/5eccdc6a/attachment.html>


More information about the llvm-dev mailing list