[PATCH] D21690: Fix size computation of array allocation in inline cost analysis

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 24 17:19:18 PDT 2016


eli.friedman added inline comments.

================
Comment at: lib/Analysis/InlineCost.cpp:347
@@ -345,1 +346,3 @@
+      ArraySize *= ElementSize;
+      AllocatedSize += ArraySize.getLimitedValue();
       return Base::visitAlloca(I);
----------------
The addition can overflow as well.

Maybe use SaturatingMultiplyAdd from MathExtras.h instead of APInt?


http://reviews.llvm.org/D21690





More information about the llvm-commits mailing list