[DSE][NFC] Need to be carefull mixing signed and unsigned types
authorEvgeniy Brevnov <ybrevnov@azul.com>
Fri, 4 Dec 2020 09:53:17 +0000 (16:53 +0700)
committerEvgeniy Brevnov <ybrevnov@azul.com>
Tue, 8 Dec 2020 09:53:37 +0000 (16:53 +0700)
commit2d1b024d06b2a81f1c35193a998a864be09e2ae8
treedbca66916e007e1515f50f375857d6a3047d45fa
parent80766ecc65096deeb4ff6f03562dcad94c54b862
[DSE][NFC] Need to be carefull mixing signed and unsigned types

Currently in some places we use signed type to represent size of an access and put explicit casts from unsigned to signed.
For example: int64_t EarlierSize = int64_t(Loc.Size.getValue());

Even though it doesn't loos bits (immidiatly) it may overflow and we end up with negative size. Potentially that cause later code to work incorrectly. A simple expample is a check that size is not negative.

I think it would be safer and clearer if we use unsigned type for the size and handle it appropriately.

Reviewed By: fhahn

Differential Revision: https://reviews.llvm.org/D92648
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp