diff options
Diffstat (limited to 'test/Transforms/SimplifyLibCalls')
-rw-r--r-- | test/Transforms/SimplifyLibCalls/2010-05-30-memcpy-Struct.ll | 20 | ||||
-rw-r--r-- | test/Transforms/SimplifyLibCalls/PR7357.ll | 16 | ||||
-rw-r--r-- | test/Transforms/SimplifyLibCalls/StrNCmp.ll | 7 | ||||
-rw-r--r-- | test/Transforms/SimplifyLibCalls/StrStr.ll | 12 |
4 files changed, 55 insertions, 0 deletions
diff --git a/test/Transforms/SimplifyLibCalls/2010-05-30-memcpy-Struct.ll b/test/Transforms/SimplifyLibCalls/2010-05-30-memcpy-Struct.ll new file mode 100644 index 0000000..f67bae7 --- /dev/null +++ b/test/Transforms/SimplifyLibCalls/2010-05-30-memcpy-Struct.ll @@ -0,0 +1,20 @@ +; RUN: opt -simplify-libcalls %s -S -o - | FileCheck %s +; PR7265 + +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" +target triple = "x86_64-unknown-linux-gnu" + +%union.anon = type { i32, [4 x i8] } + +@.str = private constant [3 x i8] c"%s\00" ; <[3 x i8]*> [#uses=2] + +define void @CopyEventArg(%union.anon* %ev) nounwind { +entry: + %call = call i32 (i8*, i8*, ...)* @sprintf(i8* undef, i8* getelementptr inbounds ([3 x i8]* @.str, i64 0, i64 0), %union.anon* %ev) nounwind ; <i32> [#uses=0] +; CHECK: bitcast %union.anon* %ev to i8* +; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64 + ret void +} + +declare i32 @sprintf(i8*, i8*, ...) + diff --git a/test/Transforms/SimplifyLibCalls/PR7357.ll b/test/Transforms/SimplifyLibCalls/PR7357.ll new file mode 100644 index 0000000..6d5c1d5 --- /dev/null +++ b/test/Transforms/SimplifyLibCalls/PR7357.ll @@ -0,0 +1,16 @@ +; RUN: opt < %s -default-data-layout="e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-n32" -simplify-libcalls -S | FileCheck %s +@.str1 = private constant [11 x i8] c"(){};[]&|:\00", align 4 + +; check that simplify libcalls will not replace a call with one calling +; convention with a new call with a different calling convention. + +; CHECK: define arm_aapcscc i32 @foo(i32 %argc) +; CHECK: call arm_aapcscc i8* @strchr +define arm_aapcscc i32 @foo(i32 %argc) nounwind { +bb.nph: + call arm_aapcscc i8* @strchr(i8* getelementptr ([11 x i8]* @.str1, i32 0, +i32 0), i32 %argc) nounwind readonly + ret i32 0 +} + +declare arm_aapcscc i8* @strchr(i8*, i32) nounwind readonly diff --git a/test/Transforms/SimplifyLibCalls/StrNCmp.ll b/test/Transforms/SimplifyLibCalls/StrNCmp.ll index ba77385..8b536a5 100644 --- a/test/Transforms/SimplifyLibCalls/StrNCmp.ll +++ b/test/Transforms/SimplifyLibCalls/StrNCmp.ll @@ -2,6 +2,9 @@ ; RUN: opt < %s -simplify-libcalls -S | \ ; RUN: not grep {call.*strncmp} +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-n8:16:32" +target triple = "i386-apple-darwin9.0" + @hello = constant [6 x i8] c"hello\00" ; <[6 x i8]*> [#uses=1] @hell = constant [5 x i8] c"hell\00" ; <[5 x i8]*> [#uses=1] @null = constant [1 x i8] zeroinitializer ; <[1 x i8]*> [#uses=1] @@ -26,3 +29,7 @@ define i32 @main() { ret i32 %rslt4 } +define i32 @test1(i8* %P, i8* %Q) { + %cmp = call i32 @strncmp(i8* %P, i8* %Q, i32 1) + ret i32 %cmp +} diff --git a/test/Transforms/SimplifyLibCalls/StrStr.ll b/test/Transforms/SimplifyLibCalls/StrStr.ll index 2cac2d4..eefd2e8 100644 --- a/test/Transforms/SimplifyLibCalls/StrStr.ll +++ b/test/Transforms/SimplifyLibCalls/StrStr.ll @@ -46,3 +46,15 @@ entry: ; CHECK: @test4 ; CHECK: ret i8* %P } + +define i1 @test5(i8* %P, i8* %Q) nounwind readonly { +entry: + %call = tail call i8* @strstr(i8* %P, i8* %Q) nounwind ; <i8*> [#uses=1] + %cmp = icmp eq i8* %call, %P + ret i1 %cmp +; CHECK: @test5 +; CHECK: [[LEN:%[a-z]+]] = call {{i[0-9]+}} @strlen(i8* %Q) +; CHECK: [[NCMP:%[a-z]+]] = call {{i[0-9]+}} @strncmp(i8* %P, i8* %Q, {{i[0-9]+}} [[LEN]]) +; CHECK: icmp eq {{i[0-9]+}} [[NCMP]], 0 +; CHECK: ret i1 +} |