[PATCH] D46750: [SROA] pr37267: fix assertion failure while integer widening

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 16 11:31:03 PDT 2018


efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM with one minor comment



================
Comment at: lib/Transforms/Scalar/SROA.cpp:1953
 
-  uint64_t RelBegin = S.beginOffset() - AllocBeginOffset;
+  int64_t RelBegin = S.beginOffset() - AllocBeginOffset;
   uint64_t RelEnd = S.endOffset() - AllocBeginOffset;
----------------
Instead of doing this implicit signed-unsigned conversion, could you explicitly check "S.beginOffset() < AllocBeginOffset"?  It's confusing to have to worry about overflow.  (Granted, I don't think the overflowing case is likely to show up in practice, but there isn't anything preventing it.)


https://reviews.llvm.org/D46750





More information about the llvm-commits mailing list