[PATCH] D45418: [SimplifyLibcalls] Atoi, strtol replacements
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 12 12:59:07 PDT 2018
efriedma added inline comments.
================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:1716
+ if (DL.getTypeAllocSize(CI->getType()) != sizeof(long int))
+ return nullptr;
+
----------------
xbolva00 wrote:
> 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
By "range check", I mean in addition to the errno check, if CI->getType() is a 32-bit integer, check that the result of strtoll fits into a 32-bit integer.
https://reviews.llvm.org/D45418
More information about the llvm-commits
mailing list