[PATCH] Vectorizing Global Structures - Take 2

Arnold Schwaighofer aschwaighofer at apple.com
Thu Feb 14 12:13:08 PST 2013


On Feb 14, 2013, at 1:55 PM, Daniel Berlin <dberlin at dberlin.org> wrote:

> 
> 
> On Thu, Feb 14, 2013 at 2:49 PM, Arnold Schwaighofer <aschwaighofer at apple.com> wrote:
> 
> On Feb 14, 2013, at 12:34 PM, Renato Golin <renato.golin at linaro.org> wrote:
> 
>> On 14 February 2013 17:46, Arnold Schwaighofer <aschwaighofer at apple.com> wrote:
>> The existing implementation already relies on runtime checks (it has to make sure that an unknown object and a known object do not overlap). Yes, AA will conservatively return MayAlias/PartialAlias if it does not know two objects. You just have to make sure that you actually query it with that unknown object.
>> 
>> I was expecting this, and I'm planning to be extra conservative to begin with. So, for now, MayAlias and PartialAlias are reasons to stop trying. Once we can get the code to understand basic independent objects inside a structure, we can specialize for the other cases.
>> 
> 
> Okay. But understand that LLVM IR semantics does not give you much leeway in "understanding independent objects inside a structure". That is what you need TBAA for.
> 
> TBAA is not a good answer to this general problem.  It falls down pretty quickly when you start to ask it about fields inside structures.
> Proper structure aliasing (IE aliasing on pieces of structs), including pointer analysis, in languages where things can point to fields inside structures (like GEP does) is not only possible to do on LLVM IR, it's actually been done before :)
> 
> See, e.g, http://www.cs.ucsb.edu/~benh/research/downloads.html (The field sensitive version, and the flow sensitive/field sensitive versions).
> Both were done on earlier versions of LLVM, but could be made to work today.
> 
> 



What I meant by saying "understanding independent objects inside a structure" to is that just by looking at an llvm type say for example struct { int A[100]; int B[100]} you and seeing two gep accesses that index into the first and second field of the type you can not necessarily say that the access is not overlapping without fully evaluating the address computation:

struct { int A[100]; int B[100]} S;

ptr1 = getelementpr S, 0, 1, x
ptr2  = getelementpr S, 0, 0, y

ptr1 and ptr2 mayalias for some x and y (for example x = 0 and y = 100, the ir makes no guarantee that you cannot run over the length of an array within a struct as long as you are within the struct, http://llvm.org/docs/GetElementPtr.html#what-happens-if-an-array-index-is-out-of-bounds)

If you can symbolically reason about x and y - the full address computation then yes you can make more concise statements.

Correct me if I am wrong but this is how it understand the semantics of a gep. I would love to be able to treat a type like a tree :).

I have not had a look at what ben hardekopf is doing. Does he handle the case I mention above correctly?

I know that the existing TBAA can not handle cases with struct fields, but an improved one might. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130214/677be064/attachment.html>


More information about the llvm-commits mailing list