diff options
author | Davide Italiano <davide@freebsd.org> | 2018-01-15 01:40:18 +0000 |
---|---|---|
committer | Davide Italiano <davide@freebsd.org> | 2018-01-15 01:40:18 +0000 |
commit | 7ccd4619e487780be9ed365e68e7836276c1305e (patch) | |
tree | 489a32243fd858b43b6ae469fccf9c0c9df9b27e /llvm/lib/Analysis/BasicAliasAnalysis.cpp | |
parent | 5eccf52e12c79f7d2d3d77393d59e27a5705c69e (diff) | |
download | bcm5719-llvm-7ccd4619e487780be9ed365e68e7836276c1305e.tar.gz bcm5719-llvm-7ccd4619e487780be9ed365e68e7836276c1305e.zip |
[BasicAA] Stop crashing when dealing with pointers > 64 bits.
An alternative (and probably better) fix would be that of
making `Scale` an APInt, and there's a patch floating around
to do this. As we're still discussing it, at least stop crashing
in the meanwhile (added bonus, we now have a regression test for
this situation).
Fixes PR35843.
Thanks to Eli for suggesting the fix and Simon for reporting and
reducing the bug.
llvm-svn: 322467
Diffstat (limited to 'llvm/lib/Analysis/BasicAliasAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/BasicAliasAnalysis.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp index 5a2401f8d8a..dab551049cb 100644 --- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp +++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp @@ -503,6 +503,13 @@ bool BasicAAResult::DecomposeGEPExpression(const Value *V, Index = GetLinearExpression(Index, IndexScale, IndexOffset, ZExtBits, SExtBits, DL, 0, AC, DT, NSW, NUW); + // All GEP math happens in the width of the pointer type, + // so we can truncate the value to 64-bits as we don't handle + // currently pointers larger than 64 bits and we would crash + // later. TODO: Make `Scale` an APInt to avoid this problem. + if (IndexScale.getBitWidth() > 64) + IndexScale = IndexScale.sextOrTrunc(64); + // The GEP index scale ("Scale") scales C1*V+C2, yielding (C1*V+C2)*Scale. // This gives us an aggregate computation of (C1*Scale)*V + C2*Scale. Decomposed.OtherOffset += IndexOffset.getSExtValue() * Scale; |