Skip to content
Snippets Groups Projects
Commit 96c39f73 authored by NAKAMURA Takumi's avatar NAKAMURA Takumi
Browse files

llvm/test/Transforms/SimplifyLibCalls: FileCheck-ize 3 tests.

llvm-svn: 168691
parent 62be5578
No related branches found
No related tags found
No related merge requests found
; Test that the FPrintFOptimizer works correctly ; Test that the FPrintFOptimizer works correctly
; RUN: opt < %s -simplify-libcalls -S | \ ; RUN: opt < %s -simplify-libcalls -S | FileCheck %s
; RUN: not grep "call.*fprintf"
; This transformation requires the pointer size, as it assumes that size_t is ; This transformation requires the pointer size, as it assumes that size_t is
; the size of a pointer. ; the size of a pointer.
...@@ -15,6 +14,7 @@ target datalayout = "p:64:64:64" ...@@ -15,6 +14,7 @@ target datalayout = "p:64:64:64"
declare i32 @fprintf(%struct._IO_FILE*, i8*, ...) declare i32 @fprintf(%struct._IO_FILE*, i8*, ...)
; CHECK: define i32 @foo() {
define i32 @foo() { define i32 @foo() {
entry: entry:
%tmp.1 = load %struct._IO_FILE** @stdout ; <%struct._IO_FILE*> [#uses=1] %tmp.1 = load %struct._IO_FILE** @stdout ; <%struct._IO_FILE*> [#uses=1]
...@@ -24,4 +24,6 @@ entry: ...@@ -24,4 +24,6 @@ entry:
%tmp.8 = load %struct._IO_FILE** @stdout ; <%struct._IO_FILE*> [#uses=1] %tmp.8 = load %struct._IO_FILE** @stdout ; <%struct._IO_FILE*> [#uses=1]
%tmp.7 = call i32 (%struct._IO_FILE*, i8*, ...)* @fprintf( %struct._IO_FILE* %tmp.8, i8* getelementptr ([3 x i8]* @chr, i32 0, i32 0), i32 33 ) ; <i32> [#uses=0] %tmp.7 = call i32 (%struct._IO_FILE*, i8*, ...)* @fprintf( %struct._IO_FILE* %tmp.8, i8* getelementptr ([3 x i8]* @chr, i32 0, i32 0), i32 33 ) ; <i32> [#uses=0]
ret i32 0 ret i32 0
; CHECK-NOT: @fprintf(
} }
; Test that the FPutsOptimizer works correctly ; Test that the FPutsOptimizer works correctly
; RUN: opt < %s -simplify-libcalls -S | \ ; RUN: opt < %s -simplify-libcalls -S | FileCheck %s
; RUN: not grep "call.*fputs"
; This transformation requires the pointer size, as it assumes that size_t is ; This transformation requires the pointer size, as it assumes that size_t is
; the size of a pointer. ; the size of a pointer.
...@@ -16,6 +15,7 @@ target datalayout = "p:64:64:64" ...@@ -16,6 +15,7 @@ target datalayout = "p:64:64:64"
declare i32 @fputs(i8*, %struct._IO_FILE*) declare i32 @fputs(i8*, %struct._IO_FILE*)
define i32 @main() { define i32 @main() {
; CHECK: define i32 @main() {
entry: entry:
%out = load %struct._IO_FILE** @stdout ; <%struct._IO_FILE*> [#uses=3] %out = load %struct._IO_FILE** @stdout ; <%struct._IO_FILE*> [#uses=3]
%s1 = getelementptr [1 x i8]* @empty, i32 0, i32 0 ; <i8*> [#uses=1] %s1 = getelementptr [1 x i8]* @empty, i32 0, i32 0 ; <i8*> [#uses=1]
...@@ -25,4 +25,6 @@ entry: ...@@ -25,4 +25,6 @@ entry:
%b = call i32 @fputs( i8* %s2, %struct._IO_FILE* %out ) ; <i32> [#uses=0] %b = call i32 @fputs( i8* %s2, %struct._IO_FILE* %out ) ; <i32> [#uses=0]
%c = call i32 @fputs( i8* %s3, %struct._IO_FILE* %out ) ; <i32> [#uses=0] %c = call i32 @fputs( i8* %s3, %struct._IO_FILE* %out ) ; <i32> [#uses=0]
ret i32 0 ret i32 0
; CHECK-NOT: @fputs(
} }
; Test that the SPrintFOptimizer works correctly ; Test that the SPrintFOptimizer works correctly
; RUN: opt < %s -instcombine -S | \ ; RUN: opt < %s -instcombine -S | FileCheck %s
; RUN: not grep "call.*sprintf"
; This transformation requires the pointer size, as it assumes that size_t is ; This transformation requires the pointer size, as it assumes that size_t is
; the size of a pointer. ; the size of a pointer.
...@@ -17,6 +16,7 @@ declare i32 @sprintf(i8*, i8*, ...) ...@@ -17,6 +16,7 @@ declare i32 @sprintf(i8*, i8*, ...)
declare i32 @puts(i8*) declare i32 @puts(i8*)
define i32 @foo(i8* %p) { define i32 @foo(i8* %p) {
; CHECK: define i32 @foo(i8* %p) {
%target = alloca [1024 x i8] ; <[1024 x i8]*> [#uses=1] %target = alloca [1024 x i8] ; <[1024 x i8]*> [#uses=1]
%target_p = getelementptr [1024 x i8]* %target, i32 0, i32 0 ; <i8*> [#uses=7] %target_p = getelementptr [1024 x i8]* %target, i32 0, i32 0 ; <i8*> [#uses=7]
%hello_p = getelementptr [6 x i8]* @hello, i32 0, i32 0 ; <i8*> [#uses=2] %hello_p = getelementptr [6 x i8]* @hello, i32 0, i32 0 ; <i8*> [#uses=2]
...@@ -37,4 +37,6 @@ define i32 @foo(i8* %p) { ...@@ -37,4 +37,6 @@ define i32 @foo(i8* %p) {
%r9 = add i32 %r8, %r4 ; <i32> [#uses=1] %r9 = add i32 %r8, %r4 ; <i32> [#uses=1]
%r10 = add i32 %r9, %r4.1 ; <i32> [#uses=1] %r10 = add i32 %r9, %r4.1 ; <i32> [#uses=1]
ret i32 %r10 ret i32 %r10
; CHECK-NOT: @sprintf(
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment