[BasicAA] Merge aliasGEP code paths
authorNikita Popov <nikita.ppv@gmail.com>
Sun, 14 Feb 2021 17:51:45 +0000 (18:51 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Sun, 14 Feb 2021 18:35:36 +0000 (19:35 +0100)
commitf197cf2126be3b224cadfe8b1cde9c05f638a0ea
treeb2036b20134f2b44b90550efa4284acc68339a90
parentda46a2a87bca044fe1577bb0ca674296848453b8
[BasicAA] Merge aliasGEP code paths

At this point, we can treat the case of GEP/GEP aliasing and
GEP/non-GEP aliasing in essentially the same way. The only
differences are that we need to do an additional negative GEP base
check, and that we perform a bailout on unknown sizes for the
GEP/non-GEP case (the latter exists only to limit compile-time).

This change is not quite NFC due to the peculiar effect that
the DecomposedGEP for V2 can actually be non-trivial even if V2
is not a GEP. The reason for this is that getUnderlyingObject()
can look through LCSSA phi nodes, while stripPointerCasts() doesn't.
This can lead to slightly better results if single-entry phi nodes
occur inside a loop, where looking through the phi node via aliasPhi()
would subject it to phi cycle equivalence restrictions. It would
probably make sense to adjust pointer cast stripping (for AA) to
handle this case, and ensure consistent results.
llvm/lib/Analysis/BasicAliasAnalysis.cpp
llvm/test/Analysis/BasicAA/phi-aa.ll