[BasicAA] Be more careful with modulo ops on VariableGEPIndex.
authorFlorian Hahn <flo@fhahn.com>
Tue, 29 Jun 2021 07:56:50 +0000 (08:56 +0100)
committerFlorian Hahn <flo@fhahn.com>
Tue, 29 Jun 2021 08:22:36 +0000 (09:22 +0100)
commit91fa3565da16f77e07270e5323874abc22661cb0
treedde0621b0efe64bafc682964f3fa589cb290b58f
parent51d969dc27a80704038b653537fc12a31f4c31f0
[BasicAA] Be more careful with modulo ops on VariableGEPIndex.

(V * Scale) % X may not produce the same result for any possible value
of V, e.g. if the multiplication overflows. This means we currently
incorrectly determine NoAlias in some cases.

This patch updates LinearExpression to track whether the expression
has NSW and uses that to adjust the scale used for alias checks.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D99424
llvm/include/llvm/Analysis/BasicAliasAnalysis.h
llvm/lib/Analysis/BasicAliasAnalysis.cpp
llvm/test/Analysis/BasicAA/gep-modulo.ll