[LLVMdev] PROPOSAL: struct-access-path aware TBAA

Manman Ren mren at apple.com
Wed Mar 13 11:58:54 PDT 2013


On Mar 12, 2013, at 7:59 PM, Krzysztof Parzyszek wrote:

> On 3/12/2013 9:56 PM, Shuxin Yang wrote:
>> Based on my understanding of her design, following is one obtuse
>> motivating example:
>> 
>> --------------------------
>> class A;
>> class B;
>> 
>> int foo(A* p, B* q) {
>> 
>>    p->a_int_field = 2;
>>    q->another_int_field = 3;
>>    return p->a_int_field; // !!!!!
>> }
>> ----------------------------------
>> 
>> the *-statement can be optimized into "return 2" if optimizer can prove
>> type-A does not include type-B,
>> and type-B does not include type-A either.
>> 
> 
> And my example shows that they can alias regardless of that.  Granted, it's somewhat contrived and I'm not 100% sure if it's legal.  Once there are pointers, there is little that can be done without knowing at least something about what they point to.
Your example should return alias with llvm's alias analysis framework.
llvm's alias analysis are chained together, basic alias analysis should return alias for your example.
We call TBAA when basicAA says mayalias.

We let basicAA try its best to do point chasing (there is no inter procedural analysis).
For Shuxin's example, if the input parameters can alias, TBAA may still return noalias.
This issue exists with the current TBAA where we only annotate scalar accesses with the scalar types.

-Manman
> 
> -Krzysztof
> 
> -- 
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation




More information about the llvm-dev mailing list