[PATCH] D47059: [InstCombine] Calloc-ed strings optimizations

Benjamin Kramer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 21 03:04:43 PDT 2018


bkramer added inline comments.


================
Comment at: include/llvm/Analysis/ValueTracking.h:277
   /// pointer, return 'len+1'.  If we can't, return 0.
-  uint64_t GetStringLength(const Value *V, unsigned CharSize = 8);
+  uint64_t GetStringLength(Value *V, const TargetLibraryInfo *TLI, unsigned CharSize = 8);
 
----------------
xbolva00 wrote:
> Or should I leave const here and then const_cast for dyn_cast in isStringFromCalloc?
Leave the const here and make the variables in isStringFromCalloc const too. There should be no need for const_cast, dyn_cast will preserve const input types.


================
Comment at: lib/Analysis/ValueTracking.cpp:3392
+
+  if (N->getZExtValue() == 0 || Size->getZExtValue() == 0)
+    return false;
----------------
APInt::isNullValue() is preferable over getZExtValue()==0 because it also handles integer widths > 64


https://reviews.llvm.org/D47059





More information about the llvm-commits mailing list