[BasicAA] Use index difference to detect GEPs with identical indexes
authorNikita Popov <nikita.ppv@gmail.com>
Sun, 14 Feb 2021 14:55:53 +0000 (15:55 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Sun, 14 Feb 2021 16:11:03 +0000 (17:11 +0100)
commit728803ed74e26b370600002dcffe4994ce3ec37a
treeffa54ef4aa5366155fb9b97f9dd67f94ba9ff926
parent428bc6feed088accf549296b77ecf544d54ff1c9
[BasicAA] Use index difference to detect GEPs with identical indexes

We currently detect GEPs that have exactly the same indexes by
comparing the Offsets and VarIndices. However, the latter implicitly
performs equality comparisons between two values, which is not
generally legal inside BasicAA, due to the possibility of comparisons
across phi cycles.

I believe that in this particular instance this actually ends up being
unproblematic, at least I wasn't able to come up with any cases that
could result in an incorrect root query result.

In the interest of being defensive, compute GetIndexDifference earlier
(which knows how to handle phi cycles properly) and use the result of
that to determine whether the offsets are identical.
llvm/include/llvm/Analysis/BasicAliasAnalysis.h
llvm/lib/Analysis/BasicAliasAnalysis.cpp