[BasicAA] Fix order in which we pass MemoryLocations to alias()
authorArthur Eubanks <aeubanks@google.com>
Tue, 10 May 2022 02:32:14 +0000 (19:32 -0700)
committerArthur Eubanks <aeubanks@google.com>
Tue, 10 May 2022 19:05:38 +0000 (12:05 -0700)
commit7e0802aeb5b9059c580479049e6074f6b97ba5d6
tree64012258aae9f7be20e4eba4d8b222f088ef5406
parent17a73992dd8ba831e47b29b41d5c20292992a810
[BasicAA] Fix order in which we pass MemoryLocations to alias()

D98718 caused the order of Values/MemoryLocations we pass to alias() to
be significant due to storing the offset in the PartialAlias case. But
some callers weren't audited and were still passing swapped arguments,
causing the returned PartialAlias offset to be negative in some
cases. For example, the newly added unittests would return -1
instead of 1.

Fixes #55343, a miscompile.

Reviewed By: asbirlea, nikic

Differential Revision: https://reviews.llvm.org/D125328
llvm/include/llvm/IR/IRBuilder.h
llvm/lib/Analysis/BasicAliasAnalysis.cpp
llvm/unittests/Analysis/BasicAliasAnalysisTest.cpp