strto-1.ll 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. ; Test that the strto* library call simplifiers works correctly.
  2. ;
  3. ; RUN: opt < %s -instcombine -functionattrs -S | FileCheck %s
  4. target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
  5. declare i64 @strtol(i8* %s, i8** %endptr, i32 %base)
  6. ; CHECK: declare i64 @strtol(i8* readonly, i8** nocapture, i32)
  7. declare double @strtod(i8* %s, i8** %endptr, i32 %base)
  8. ; CHECK: declare double @strtod(i8* readonly, i8** nocapture, i32)
  9. declare float @strtof(i8* %s, i8** %endptr, i32 %base)
  10. ; CHECK: declare float @strtof(i8* readonly, i8** nocapture, i32)
  11. declare i64 @strtoul(i8* %s, i8** %endptr, i32 %base)
  12. ; CHECK: declare i64 @strtoul(i8* readonly, i8** nocapture, i32)
  13. declare i64 @strtoll(i8* %s, i8** %endptr, i32 %base)
  14. ; CHECK: declare i64 @strtoll(i8* readonly, i8** nocapture, i32)
  15. declare double @strtold(i8* %s, i8** %endptr)
  16. ; CHECK: declare double @strtold(i8* readonly, i8** nocapture)
  17. declare i64 @strtoull(i8* %s, i8** %endptr, i32 %base)
  18. ; CHECK: declare i64 @strtoull(i8* readonly, i8** nocapture, i32)
  19. define void @test_simplify1(i8* %x, i8** %endptr) {
  20. ; CHECK-LABEL: @test_simplify1(
  21. call i64 @strtol(i8* %x, i8** null, i32 10)
  22. ; CHECK-NEXT: call i64 @strtol(i8* nocapture %x, i8** null, i32 10)
  23. ret void
  24. }
  25. define void @test_simplify2(i8* %x, i8** %endptr) {
  26. ; CHECK-LABEL: @test_simplify2(
  27. call double @strtod(i8* %x, i8** null, i32 10)
  28. ; CHECK-NEXT: call double @strtod(i8* nocapture %x, i8** null, i32 10)
  29. ret void
  30. }
  31. define void @test_simplify3(i8* %x, i8** %endptr) {
  32. ; CHECK-LABEL: @test_simplify3(
  33. call float @strtof(i8* %x, i8** null, i32 10)
  34. ; CHECK-NEXT: call float @strtof(i8* nocapture %x, i8** null, i32 10)
  35. ret void
  36. }
  37. define void @test_simplify4(i8* %x, i8** %endptr) {
  38. ; CHECK-LABEL: @test_simplify4(
  39. call i64 @strtoul(i8* %x, i8** null, i32 10)
  40. ; CHECK-NEXT: call i64 @strtoul(i8* nocapture %x, i8** null, i32 10)
  41. ret void
  42. }
  43. define void @test_simplify5(i8* %x, i8** %endptr) {
  44. ; CHECK-LABEL: @test_simplify5(
  45. call i64 @strtoll(i8* %x, i8** null, i32 10)
  46. ; CHECK-NEXT: call i64 @strtoll(i8* nocapture %x, i8** null, i32 10)
  47. ret void
  48. }
  49. define void @test_simplify6(i8* %x, i8** %endptr) {
  50. ; CHECK-LABEL: @test_simplify6(
  51. call double @strtold(i8* %x, i8** null)
  52. ; CHECK-NEXT: call double @strtold(i8* nocapture %x, i8** null)
  53. ret void
  54. }
  55. define void @test_simplify7(i8* %x, i8** %endptr) {
  56. ; CHECK-LABEL: @test_simplify7(
  57. call i64 @strtoull(i8* %x, i8** null, i32 10)
  58. ; CHECK-NEXT: call i64 @strtoull(i8* nocapture %x, i8** null, i32 10)
  59. ret void
  60. }
  61. define void @test_no_simplify1(i8* %x, i8** %endptr) {
  62. ; CHECK-LABEL: @test_no_simplify1(
  63. call i64 @strtol(i8* %x, i8** %endptr, i32 10)
  64. ; CHECK-NEXT: call i64 @strtol(i8* %x, i8** %endptr, i32 10)
  65. ret void
  66. }