[PATCH] D45418: [SimplifyLibcalls] Atoi, strtol replacements

Dávid Bolvanský via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 12 12:53:48 PDT 2018


xbolva00 marked an inline comment as done.
xbolva00 added inline comments.


================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:1716
+  if (DL.getTypeAllocSize(CI->getType()) != sizeof(long int))
+    return nullptr;
+
----------------
efriedma wrote:
> `DL.getTypeAllocSize(CI->getType()) != sizeof(long int)` will cause your testcase to fail on 32-bit hosts (because we'll refuse the fold the call).
> 
> Can you use strtoll plus a range check, instead?
 But problem is ..

errs() << std::numeric_limits<long int>::max() << "\n";
errs() << std::numeric_limits<long long int>::max() << "\n";

9223372036854775807
9223372036854775807

So we need to rely on errno, I think


https://reviews.llvm.org/D45418





More information about the llvm-commits mailing list