This is an archive of the discontinued LLVM Phabricator instance.

[PR16236] Be conservative when doing TypeBasedAlias Analysis of members of Struct
AbandonedPublic

Authored by karthikthecool on Apr 8 2014, 5:04 AM.

Details

Summary

Hi All,
This patches fixes PR16236 aproblem with TypeBasedAlias Analysis. Below is my understanding please help me review this patch and if i'm thinking in the right direction.
The problem in this case seems to be that in case we have an union like -

union
{
  short f0;
  int f1;
} u, *up = &u;

f0 and f1 may alias each other. But while constructing AliasSet for these in TypeBasedAlias Analysis during PathAliases we see that both the MDNodes corresponding to (f0 and f1) are not ancestor of each other and have a common root and thus conclude that they will Not alias each other. But in case of union this may not be correct f1 anf f0 may alias each other as thye operate on same underlining memory location.

In this patch we check that if both correspond to StructTyID type we evaluate it conservatively so that we do not incorrectly conclude that these two types are NoAlias.

But doing this will also prevent promotion in case of structs were the 2 types will not alias each other but i'm not sure if we can differentiate between union and struct in llvm AliasAnalysis.

Could someone please review the same and let me know if this approach is correct?

Thanks and Regards
Karthik Bhat

Diff Detail

Event Timeline

karthikthecool abandoned this revision.Apr 20 2014, 8:06 PM