X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=test%2FTransforms%2FSimplifyLibCalls%2FStrChr.ll;h=eaabeb2feb8f99058c4f2fb171778851cf66a67d;hb=0f0c411079cd21bb3a81a1b70bf8c67539a16c22;hp=802639f723208e690132aa5c64489fc9ca653bc9;hpb=fddaa3193cd1bb2ef1f561efc5b7b6dbefeec7ee;p=oota-llvm.git diff --git a/test/Transforms/SimplifyLibCalls/StrChr.ll b/test/Transforms/SimplifyLibCalls/StrChr.ll index 802639f7232..eaabeb2feb8 100644 --- a/test/Transforms/SimplifyLibCalls/StrChr.ll +++ b/test/Transforms/SimplifyLibCalls/StrChr.ll @@ -1,22 +1,26 @@ ; Test that the StrChrOptimizer works correctly -; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | \ -; RUN: not grep {call.*@strchr} +; RUN: opt < %s -simplify-libcalls -S | FileCheck %s -@hello = constant [14 x i8] c"hello world\5Cn\00" ; <[14 x i8]*> [#uses=1] -@null = constant [1 x i8] zeroinitializer ; <[1 x i8]*> [#uses=1] +; This transformation requires the pointer size, as it assumes that size_t is +; the size of a pointer. +target datalayout = "-p:64:64:64" -declare i8* @strchr(i8*, i32) +@hello = constant [14 x i8] c"hello world\5Cn\00" +@null = constant [1 x i8] zeroinitializer -declare i32 @puts(i8*) +declare i8* @strchr(i8*, i32) -define i32 @main() { - %hello_p = getelementptr [14 x i8]* @hello, i32 0, i32 0 ; [#uses=2] - %null_p = getelementptr [1 x i8]* @null, i32 0, i32 0 ; [#uses=1] - %world = call i8* @strchr( i8* %hello_p, i32 119 ) ; [#uses=1] - %ignore = call i8* @strchr( i8* %null_p, i32 119 ) ; [#uses=0] - %len = call i32 @puts( i8* %world ) ; [#uses=1] - %index = add i32 %len, 112 ; [#uses=2] - %result = call i8* @strchr( i8* %hello_p, i32 %index ) ; [#uses=0] +define i32 @foo(i32 %index) { + %hello_p = getelementptr [14 x i8]* @hello, i32 0, i32 0 + %null_p = getelementptr [1 x i8]* @null, i32 0, i32 0 + %world = call i8* @strchr(i8* %hello_p, i32 119) +; CHECK: getelementptr i8* %hello_p, i64 6 + %ignore = call i8* @strchr(i8* %null_p, i32 119) +; CHECK-NOT: call i8* strchr + %null = call i8* @strchr(i8* %hello_p, i32 0) +; CHECK: getelementptr i8* %hello_p, i64 13 + %result = call i8* @strchr(i8* %hello_p, i32 %index) +; CHECK: call i8* @memchr(i8* %hello_p, i32 %index, i64 14) ret i32 %index }