83 lines · plain
1; Test that the strto* library call simplifiers works correctly.2;3; RUN: opt < %s -passes='function(instcombine),inferattrs' -S | FileCheck %s4 5target 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"6 7declare i32 @strtol(ptr %s, ptr %endptr, i32 %base)8; CHECK: declare i32 @strtol(ptr readonly, ptr captures(none), i32)9 10declare double @strtod(ptr %s, ptr %endptr)11; CHECK: declare double @strtod(ptr readonly, ptr captures(none))12 13declare float @strtof(ptr %s, ptr %endptr)14; CHECK: declare float @strtof(ptr readonly, ptr captures(none))15 16declare i64 @strtoul(ptr %s, ptr %endptr, i32 %base)17; CHECK: declare i64 @strtoul(ptr readonly, ptr captures(none), i32)18 19declare i64 @strtoll(ptr %s, ptr %endptr, i32 %base)20; CHECK: declare i64 @strtoll(ptr readonly, ptr captures(none), i32)21 22declare double @strtold(ptr %s, ptr %endptr)23; CHECK: declare double @strtold(ptr readonly, ptr captures(none))24 25declare i64 @strtoull(ptr %s, ptr %endptr, i32 %base)26; CHECK: declare i64 @strtoull(ptr readonly, ptr captures(none), i32)27 28define void @test_simplify1(ptr %x, ptr %endptr) {29; CHECK-LABEL: @test_simplify1(30 call i32 @strtol(ptr %x, ptr null, i32 10)31; CHECK-NEXT: call i32 @strtol(ptr captures(none) %x, ptr null, i32 10)32 ret void33}34 35define void @test_simplify2(ptr %x, ptr %endptr) {36; CHECK-LABEL: @test_simplify2(37 call double @strtod(ptr %x, ptr null)38; CHECK-NEXT: call double @strtod(ptr captures(none) %x, ptr null)39 ret void40}41 42define void @test_simplify3(ptr %x, ptr %endptr) {43; CHECK-LABEL: @test_simplify3(44 call float @strtof(ptr %x, ptr null)45; CHECK-NEXT: call float @strtof(ptr captures(none) %x, ptr null)46 ret void47}48 49define void @test_simplify4(ptr %x, ptr %endptr) {50; CHECK-LABEL: @test_simplify4(51 call i64 @strtoul(ptr %x, ptr null, i32 10)52; CHECK-NEXT: call i64 @strtoul(ptr captures(none) %x, ptr null, i32 10)53 ret void54}55 56define void @test_simplify5(ptr %x, ptr %endptr) {57; CHECK-LABEL: @test_simplify5(58 call i64 @strtoll(ptr %x, ptr null, i32 10)59; CHECK-NEXT: call i64 @strtoll(ptr captures(none) %x, ptr null, i32 10)60 ret void61}62 63define void @test_simplify6(ptr %x, ptr %endptr) {64; CHECK-LABEL: @test_simplify6(65 call double @strtold(ptr %x, ptr null)66; CHECK-NEXT: call double @strtold(ptr captures(none) %x, ptr null)67 ret void68}69 70define void @test_simplify7(ptr %x, ptr %endptr) {71; CHECK-LABEL: @test_simplify7(72 call i64 @strtoull(ptr %x, ptr null, i32 10)73; CHECK-NEXT: call i64 @strtoull(ptr captures(none) %x, ptr null, i32 10)74 ret void75}76 77define void @test_no_simplify1(ptr %x, ptr %endptr) {78; CHECK-LABEL: @test_no_simplify1(79 call i32 @strtol(ptr %x, ptr %endptr, i32 10)80; CHECK-NEXT: call i32 @strtol(ptr %x, ptr %endptr, i32 10)81 ret void82}83