mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-28 14:10:41 +00:00
d97964253e
a standalone pass. There is no call graph or even interesting analysis for this part of function attributes -- it is literally inferring attributes based on the target library identification. As such, we can do it using a much simpler module pass that just walks the declarations. This can also happen much earlier in the pass pipeline which has benefits for any number of other passes. In the process, I've cleaned up one particular aspect of the logic which was necessary in order to separate the two passes cleanly. It now counts inferred attributes independently rather than just counting all the inferred attributes as one, and the counts are more clearly explained. The two test cases we had for this code path are both ... woefully inadequate and copies of each other. I've kept the superset test and updated it. We need more testing here, but I had to pick somewhere to stop fixing everything broken I saw here. Differential Revision: http://reviews.llvm.org/D15676 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256466 91177308-0d34-0410-b5e6-96231b3b80d8
83 lines
2.7 KiB
LLVM
83 lines
2.7 KiB
LLVM
; Test that the strto* library call simplifiers works correctly.
|
|
;
|
|
; RUN: opt < %s -instcombine -inferattrs -S | FileCheck %s
|
|
|
|
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"
|
|
|
|
declare i64 @strtol(i8* %s, i8** %endptr, i32 %base)
|
|
; CHECK: declare i64 @strtol(i8* readonly, i8** nocapture, i32)
|
|
|
|
declare double @strtod(i8* %s, i8** %endptr, i32 %base)
|
|
; CHECK: declare double @strtod(i8* readonly, i8** nocapture, i32)
|
|
|
|
declare float @strtof(i8* %s, i8** %endptr, i32 %base)
|
|
; CHECK: declare float @strtof(i8* readonly, i8** nocapture, i32)
|
|
|
|
declare i64 @strtoul(i8* %s, i8** %endptr, i32 %base)
|
|
; CHECK: declare i64 @strtoul(i8* readonly, i8** nocapture, i32)
|
|
|
|
declare i64 @strtoll(i8* %s, i8** %endptr, i32 %base)
|
|
; CHECK: declare i64 @strtoll(i8* readonly, i8** nocapture, i32)
|
|
|
|
declare double @strtold(i8* %s, i8** %endptr)
|
|
; CHECK: declare double @strtold(i8* readonly, i8** nocapture)
|
|
|
|
declare i64 @strtoull(i8* %s, i8** %endptr, i32 %base)
|
|
; CHECK: declare i64 @strtoull(i8* readonly, i8** nocapture, i32)
|
|
|
|
define void @test_simplify1(i8* %x, i8** %endptr) {
|
|
; CHECK-LABEL: @test_simplify1(
|
|
call i64 @strtol(i8* %x, i8** null, i32 10)
|
|
; CHECK-NEXT: call i64 @strtol(i8* nocapture %x, i8** null, i32 10)
|
|
ret void
|
|
}
|
|
|
|
define void @test_simplify2(i8* %x, i8** %endptr) {
|
|
; CHECK-LABEL: @test_simplify2(
|
|
call double @strtod(i8* %x, i8** null, i32 10)
|
|
; CHECK-NEXT: call double @strtod(i8* nocapture %x, i8** null, i32 10)
|
|
ret void
|
|
}
|
|
|
|
define void @test_simplify3(i8* %x, i8** %endptr) {
|
|
; CHECK-LABEL: @test_simplify3(
|
|
call float @strtof(i8* %x, i8** null, i32 10)
|
|
; CHECK-NEXT: call float @strtof(i8* nocapture %x, i8** null, i32 10)
|
|
ret void
|
|
}
|
|
|
|
define void @test_simplify4(i8* %x, i8** %endptr) {
|
|
; CHECK-LABEL: @test_simplify4(
|
|
call i64 @strtoul(i8* %x, i8** null, i32 10)
|
|
; CHECK-NEXT: call i64 @strtoul(i8* nocapture %x, i8** null, i32 10)
|
|
ret void
|
|
}
|
|
|
|
define void @test_simplify5(i8* %x, i8** %endptr) {
|
|
; CHECK-LABEL: @test_simplify5(
|
|
call i64 @strtoll(i8* %x, i8** null, i32 10)
|
|
; CHECK-NEXT: call i64 @strtoll(i8* nocapture %x, i8** null, i32 10)
|
|
ret void
|
|
}
|
|
|
|
define void @test_simplify6(i8* %x, i8** %endptr) {
|
|
; CHECK-LABEL: @test_simplify6(
|
|
call double @strtold(i8* %x, i8** null)
|
|
; CHECK-NEXT: call double @strtold(i8* nocapture %x, i8** null)
|
|
ret void
|
|
}
|
|
|
|
define void @test_simplify7(i8* %x, i8** %endptr) {
|
|
; CHECK-LABEL: @test_simplify7(
|
|
call i64 @strtoull(i8* %x, i8** null, i32 10)
|
|
; CHECK-NEXT: call i64 @strtoull(i8* nocapture %x, i8** null, i32 10)
|
|
ret void
|
|
}
|
|
|
|
define void @test_no_simplify1(i8* %x, i8** %endptr) {
|
|
; CHECK-LABEL: @test_no_simplify1(
|
|
call i64 @strtol(i8* %x, i8** %endptr, i32 10)
|
|
; CHECK-NEXT: call i64 @strtol(i8* %x, i8** %endptr, i32 10)
|
|
ret void
|
|
}
|