[PATCH] D55538: [InterleavedAccessAnalysis] Fix integer overflow in insertMember.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 5 18:38:14 PST 2019


fhahn added inline comments.


================
Comment at: llvm/include/llvm/Analysis/VectorUtils.h:284
+    if (KeyLong > std::numeric_limits<int32_t>::max() - 2 ||
+        KeyLong < std::numeric_limits<int32_t>::min() + 2)
+      return false;
----------------
efriedma wrote:
> Not sure I understand the "-2" and "+2" here; is the issue that it collides with the default DenseMap tombstone otherwise?  Can we use some map that doesn't randomly reserve certain integers?  Otherwise, please add an explicit note, and check for the tombstone/empty keys separately from the overflow check.
> 
> Do we have some overflow-checked addition helper we could use instead of writing out the overflow check here?
Yep it's a tombstone check. I guess we could use std::unordered_map, will that have a perf impact?

I'll check again if there are some overflow helpers anywhere, but if not then it might be worth adding some.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55538/new/

https://reviews.llvm.org/D55538





More information about the llvm-commits mailing list