1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 04:02:41 +01:00

[BasicAA] Avoid duplicate query for GEPs with identical offsets (NFCI)

For two GEPs with identical offsets, we currently first perform
a base address query without size information, and then if it is
MayAlias, perform another with size information. This is pointless,
as the latter query should produce strictly better results.

This was not quite true historically due to the way that NoAlias
assumptions were handled, but that issue has since been resolved.
This commit is contained in:
Nikita Popov 2021-02-13 23:43:57 +01:00
parent 8bf924114e
commit 304d2b10bb

View File

@ -1116,22 +1116,18 @@ AliasResult BasicAAResult::aliasGEP(
DecompGEP1.Offset -= DecompGEP2.Offset;
GetIndexDifference(DecompGEP1.VarIndices, DecompGEP2.VarIndices);
// For GEPs with identical offsets, we can preserve the size and AAInfo
// when performing the alias check on the underlying objects.
if (DecompGEP1.Offset == 0 && DecompGEP1.VarIndices.empty())
return getBestAAResults().alias(
MemoryLocation(UnderlyingV1, V1Size, V1AAInfo),
MemoryLocation(UnderlyingV2, V2Size, V2AAInfo), AAQI);
// Do the base pointers alias?
AliasResult BaseAlias = getBestAAResults().alias(
MemoryLocation::getBeforeOrAfter(UnderlyingV1),
MemoryLocation::getBeforeOrAfter(UnderlyingV2), AAQI);
// For GEPs with identical offsets, we can preserve the size and AAInfo
// when performing the alias check on the underlying objects.
if (BaseAlias == MayAlias && DecompGEP1.Offset == 0 &&
DecompGEP1.VarIndices.empty()) {
AliasResult PreciseBaseAlias = getBestAAResults().alias(
MemoryLocation(UnderlyingV1, V1Size, V1AAInfo),
MemoryLocation(UnderlyingV2, V2Size, V2AAInfo), AAQI);
if (PreciseBaseAlias == NoAlias)
return NoAlias;
}
// If we get a No or May, then return it immediately, no amount of analysis
// will improve this situation.
if (BaseAlias != MustAlias) {