forked from OSchip/llvm-project
4f2381440d
Motivated by the discussion in D38499, this patch updates BasicAA to support arbitrary pointer sizes by switching most remaining non-APInt calculations to use APInt. The size of these APInts is set to the maximum pointer size (maximum over all address spaces described by the data layout string). Most of this translation is straightforward, but this patch contains a fix for a bug that revealed itself during this translation process. In order for test/Analysis/BasicAA/gep-and-alias.ll to pass, which is run with 32-bit pointers, the intermediate calculations must be performed using 64-bit integers. This is because, as noted in the patch, when GetLinearExpression decomposes an expression into C1*V+C2, and we then multiply this by Scale, and distribute, to get (C1*Scale)*V + C2*Scale, it can be the case that, even through C1*V+C2 does not overflow for relevant values of V, (C2*Scale) can overflow. If this happens, later logic will draw invalid conclusions from the (base) offset value. Thus, when initially applying the APInt conversion, because the maximum pointer size in this test is 32 bits, it started failing. Suspicious, I created a 64-bit version of this test (included here), and that failed (miscompiled) on trunk for a similar reason (the multiplication can overflow). After fixing this overflow bug, the first test case (at least) in Analysis/BasicAA/q.bad.ll started failing. This is also a 32-bit test, and was relying on having 64-bit intermediate values to have BasicAA return an accurate result. In order to fix this problem, and because I believe that it is not uncommon to use i64 indexing expressions in 32-bit code (especially portable code using int64_t), it seems reasonable to always use at least 64-bit integers. In this way, we won't regress our analysis capabilities (and there's a command-line option added, so experimenting with this should be easy). As pointed out by Eli during the review, there are other potential overflow conditions that this patch does not address. Fixing those is left to follow-up work. Patch by me with contributions from Michael Ferguson (mferguson@cray.com). Differential Revision: https://reviews.llvm.org/D38662 llvm-svn: 350220 |
||
---|---|---|
.. | ||
128-bit-ptr.ll | ||
2003-02-26-AccessSizeTest.ll | ||
2003-03-04-GEPCrash.ll | ||
2003-04-22-GEPProblem.ll | ||
2003-04-25-GEPCrash.ll | ||
2003-05-21-GEP-Problem.ll | ||
2003-06-01-AliasCrash.ll | ||
2003-07-03-BasicAACrash.ll | ||
2003-09-19-LocalArgument.ll | ||
2003-11-04-SimpleCases.ll | ||
2003-12-11-ConstExprGEP.ll | ||
2004-07-28-MustAliasbug.ll | ||
2006-03-03-BadArraySubscript.ll | ||
2006-11-03-BasicAAVectorCrash.ll | ||
2007-01-13-BasePointerBadNoAlias.ll | ||
2007-08-01-NoAliasAndCalls.ll | ||
2007-08-01-NoAliasAndGEP.ll | ||
2007-08-05-GetOverloadedModRef.ll | ||
2007-10-24-ArgumentsGlobals.ll | ||
2007-11-05-SizeCrash.ll | ||
2007-12-08-OutOfBoundsCrash.ll | ||
2008-04-15-Byval.ll | ||
2008-06-02-GEPTailCrash.ll | ||
2008-11-23-NoaliasRet.ll | ||
2009-03-04-GEPNoalias.ll | ||
2009-10-13-AtomicModRef.ll | ||
2009-10-13-GEP-BaseNoAlias.ll | ||
2010-09-15-GEP-SignedArithmetic.ll | ||
2014-03-18-Maxlookup-reached.ll | ||
aligned-overread.ll | ||
args-rets-allocas-loads.ll | ||
assume.ll | ||
bug.23540.ll | ||
bug.23626.ll | ||
byval.ll | ||
call-attrs.ll | ||
cas.ll | ||
constant-over-index.ll | ||
cs-cs-arm.ll | ||
cs-cs.ll | ||
dag.ll | ||
empty.ll | ||
fallback-mayalias.ll | ||
featuretest.ll | ||
full-store-partial-alias.ll | ||
gcsetest.ll | ||
gep-alias.ll | ||
gep-and-alias-64.ll | ||
gep-and-alias.ll | ||
getmodrefinfo-cs-cs.ll | ||
global-size.ll | ||
guards.ll | ||
intrinsics-arm.ll | ||
intrinsics.ll | ||
invalidation.ll | ||
invariant_group.ll | ||
invariant_load.ll | ||
memset_pattern.ll | ||
modref.ll | ||
must-and-partial.ll | ||
negoffset.ll | ||
no-escape-call.ll | ||
noalias-bugs.ll | ||
noalias-geps.ll | ||
noalias-param.ll | ||
noalias-wraparound-bug.ll | ||
nocapture.ll | ||
phi-aa.ll | ||
phi-and-select.ll | ||
phi-loop.ll | ||
phi-spec-order.ll | ||
phi-speculation.ll | ||
phi-values-usage.ll | ||
pr18573.ll | ||
pr31761.ll | ||
pr35821.ll | ||
pr35843.ll | ||
pure-const-dce.ll | ||
q.bad.ll | ||
returned.ll | ||
sequential-gep.ll | ||
store-promote.ll | ||
struct-geps.ll | ||
tail-byval.ll | ||
tailcall-modref.ll | ||
underlying-value.ll | ||
unreachable-block.ll | ||
zext.ll |