[llvm-dev] What is TBAA's advantage over BasicAA?

Bekket McClane via llvm-dev llvm-dev at lists.llvm.org
Sun Jul 8 11:55:18 PDT 2018


Hi all,

I’m currently studying TBAA. I understand that it provide a “struct-path” analysis, which should do well on analyzing struct-like type in high level language.
However, I got one simple question - Why don’t we just trace back the GEP chains from a given pointer, evaluate the pointer as some sort of BasePtr + Offset form, then compare if two pointers have same forms - just exactly what BasicAA do in its aliasGEP function ?
What is TBAA’s advantage over BasicAA, and its necessity of providing a decent type system, which actually looks like another form of Base + Offset?

Currently I only come up with one example: addresses of A[i].firstField and A[j].secondField, where A is SomeStruct* type. 
As the two pointers is accessing different fields of a struct, they would never alias regardless of offsets i and j against A. 
BasicAA would try to evaluate them into (A + sizeof(A) * i + Offset1) and (A + sizeof(A) * j + Offset2), and probably fail to continue since i and j are not constants.
But I don’t think this is the only reason TBAA is invented. Could someone give me examples showing TBAA performs over BasicAA in some domains?

Thank you

Bekket McClane


More information about the llvm-dev mailing list