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

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 9 11:11:33 PDT 2018


lebedev.ri added inline comments.


================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:1697
+  if (ConstantInt *CInt = dyn_cast<ConstantInt>(CI->getArgOperand(2)))
+    return ConstantInt::get(CI->getType(), strtol(Str.str().c_str(), nullptr,
+                                                  CInt->getSExtValue()));
----------------
lebedev.ri wrote:
> `base` is `i32`, but `strtol` returns `long int` (`i64`?), so i don't think using `CI->getType()` is correct.
> 
Oh, `CI` is `CallInst`, not `ConstantInt`, never mind then.


================
Comment at: test/Transforms/InstCombine/str-int.ll:5
+ at .str = private unnamed_addr constant [3 x i8] c"12\00", align 1
+ at .str.1 = private unnamed_addr constant [2 x i8] c"0\00", align 1
+
----------------
lebedev.ri wrote:
> So i suppose this needs a test with larger-than-32bit-integer.
> 
The `STRTOL(3)` says that strtol returns `long int`, so it would still be good for the tests to represent that.
(i.e. please change this `strtol` to return `i64`, and add a test from ^ that comment.)


https://reviews.llvm.org/D45418





More information about the llvm-commits mailing list