summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2011-02-12 18:19:57 +0000
committerDaniel Dunbar <daniel@zuster.org>2011-02-12 18:19:57 +0000
commit210ce0feb50becca2f2ef619175b2e905c435598 (patch)
tree1533d98feac56b122b12f56d3b05168e7c998a1f /llvm/test
parent76c95562bc34c2819642e9756b31e508f838b052 (diff)
downloadbcm5719-llvm-210ce0feb50becca2f2ef619175b2e905c435598.tar.gz
bcm5719-llvm-210ce0feb50becca2f2ef619175b2e905c435598.zip
SimplifyLibCalls: Add missing legalize check on various printf to puts and
putchar transforms, their return values are not compatible. llvm-svn: 125442
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Transforms/SimplifyLibCalls/Printf.ll27
1 files changed, 20 insertions, 7 deletions
diff --git a/llvm/test/Transforms/SimplifyLibCalls/Printf.ll b/llvm/test/Transforms/SimplifyLibCalls/Printf.ll
index d68928ee6b5..caea311ba14 100644
--- a/llvm/test/Transforms/SimplifyLibCalls/Printf.ll
+++ b/llvm/test/Transforms/SimplifyLibCalls/Printf.ll
@@ -1,23 +1,36 @@
; RUN: opt < %s -simplify-libcalls -S -o %t
; RUN: FileCheck < %t %s
-; CHECK-NOT: call{{.*}}printf
-; CHECK: putchar
-
@str = internal constant [13 x i8] c"hello world\0A\00" ; <[13 x i8]*> [#uses=1]
@str1 = internal constant [2 x i8] c"h\00" ; <[2 x i8]*> [#uses=1]
-define void @foo() {
+declare i32 @printf(i8*, ...)
+
+; CHECK: define void @f0
+; CHECK-NOT: printf
+; CHECK: }
+define void @f0() {
entry:
%tmp1 = tail call i32 (i8*, ...)* @printf( i8* getelementptr ([13 x i8]* @str, i32 0, i32 0) ) ; <i32> [#uses=0]
ret void
}
-declare i32 @printf(i8*, ...)
-
-define void @bar() {
+; CHECK: define void @f1
+; CHECK-NOT: printf
+; CHECK: }
+define void @f1() {
entry:
%tmp1 = tail call i32 (i8*, ...)* @printf( i8* getelementptr ([2 x i8]* @str1, i32 0, i32 0) ) ; <i32> [#uses=0]
ret void
}
+; Verify that we don't turn this into a putchar call (thus changing the return
+; value).
+;
+; CHECK: define i32 @f2
+; CHECK: printf
+; CHECK: }
+define i32 @f2() {
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([2 x i8]* @str1, i32 0, i32 0))
+ ret i32 %call
+}
OpenPOWER on IntegriCloud