diff options
| author | Roman Divacky <rdivacky@FreeBSD.org> | 2010-04-02 08:54:30 +0000 |
|---|---|---|
| committer | Roman Divacky <rdivacky@FreeBSD.org> | 2010-04-02 08:54:30 +0000 |
| commit | 104bd8179fb5f6551c65c94ebcd0a4918b060189 (patch) | |
| tree | cf5763d092b81cecc168fa28032247ee495d06e2 /test/Transforms | |
| parent | 2f12f10af369d468b14617276446166383d692ed (diff) | |
Notes
Diffstat (limited to 'test/Transforms')
| -rw-r--r-- | test/Transforms/GVN/2010-03-31-RedundantPHIs.ll | 46 | ||||
| -rw-r--r-- | test/Transforms/GVN/rle.ll | 12 | ||||
| -rw-r--r-- | test/Transforms/Inline/noinline.ll | 18 | ||||
| -rw-r--r-- | test/Transforms/InstCombine/objsize.ll | 15 | ||||
| -rw-r--r-- | test/Transforms/SimplifyCFG/2010-03-30-InvokeCrash.ll | 18 | ||||
| -rw-r--r-- | test/Transforms/SimplifyLibCalls/StrCpy.ll | 45 |
6 files changed, 134 insertions, 20 deletions
diff --git a/test/Transforms/GVN/2010-03-31-RedundantPHIs.ll b/test/Transforms/GVN/2010-03-31-RedundantPHIs.ll new file mode 100644 index 000000000000..066e3038b087 --- /dev/null +++ b/test/Transforms/GVN/2010-03-31-RedundantPHIs.ll @@ -0,0 +1,46 @@ +; RUN: opt < %s -gvn -enable-full-load-pre -S | FileCheck %s + +define i8* @cat(i8* %s1, ...) nounwind { +entry: + br i1 undef, label %bb, label %bb3 + +bb: ; preds = %entry + unreachable + +bb3: ; preds = %entry + store i8* undef, i8** undef, align 4 + br i1 undef, label %bb5, label %bb6 + +bb5: ; preds = %bb3 + unreachable + +bb6: ; preds = %bb3 + br label %bb12 + +bb8: ; preds = %bb12 + br i1 undef, label %bb9, label %bb10 + +bb9: ; preds = %bb8 + %0 = load i8** undef, align 4 ; <i8*> [#uses=0] + %1 = load i8** undef, align 4 ; <i8*> [#uses=0] + br label %bb11 + +bb10: ; preds = %bb8 + br label %bb11 + +bb11: ; preds = %bb10, %bb9 +; CHECK: bb11: +; CHECK: phi +; CHECK-NOT: phi + br label %bb12 + +bb12: ; preds = %bb11, %bb6 +; CHECK: bb12: +; CHECK: phi +; CHECK-NOT: phi + br i1 undef, label %bb8, label %bb13 + +bb13: ; preds = %bb12 +; CHECK: bb13: + ret i8* undef +} diff --git a/test/Transforms/GVN/rle.ll b/test/Transforms/GVN/rle.ll index d419fd24240c..d656c1a5fcc7 100644 --- a/test/Transforms/GVN/rle.ll +++ b/test/Transforms/GVN/rle.ll @@ -531,4 +531,16 @@ out: } +; PR6642 +define i32 @memset_to_load() nounwind readnone { +entry: + %x = alloca [256 x i32], align 4 ; <[256 x i32]*> [#uses=2] + %tmp = bitcast [256 x i32]* %x to i8* ; <i8*> [#uses=1] + call void @llvm.memset.i64(i8* %tmp, i8 0, i64 1024, i32 4) + %arraydecay = getelementptr inbounds [256 x i32]* %x, i32 0, i32 0 ; <i32*> + %tmp1 = load i32* %arraydecay ; <i32> [#uses=1] + ret i32 %tmp1 +; CHECK: @memset_to_load +; CHECK: ret i32 0 +} diff --git a/test/Transforms/Inline/noinline.ll b/test/Transforms/Inline/noinline.ll new file mode 100644 index 000000000000..dc3f6e003094 --- /dev/null +++ b/test/Transforms/Inline/noinline.ll @@ -0,0 +1,18 @@ +; RUN: opt %s -inline -S | FileCheck %s +; PR6682 +declare void @foo() nounwind + +define void @bar() nounwind { +entry: + tail call void @foo() nounwind + ret void +} + +define void @bazz() nounwind { +entry: + tail call void @bar() nounwind noinline + ret void +} + +; CHECK: define void @bazz() +; CHECK: call void @bar() diff --git a/test/Transforms/InstCombine/objsize.ll b/test/Transforms/InstCombine/objsize.ll index cd7b7c80679b..f8b2ffca01ed 100644 --- a/test/Transforms/InstCombine/objsize.ll +++ b/test/Transforms/InstCombine/objsize.ll @@ -118,6 +118,7 @@ entry: ret i32 0 } +; rdar://7782496 @s = external global i8* define void @test5(i32 %n) nounwind ssp { @@ -127,11 +128,23 @@ entry: %1 = tail call i32 @llvm.objectsize.i32(i8* %0, i1 false) %2 = load i8** @s, align 8 ; CHECK-NOT: @llvm.objectsize -; CHECK: @__memcpy_chk(i8* %0, i8* %1, i32 10, i32 20) +; CHECK: @llvm.memcpy.i32(i8* %0, i8* %1, i32 10, i32 1) %3 = tail call i8* @__memcpy_chk(i8* %0, i8* %2, i32 10, i32 %1) nounwind ret void } +define void @test6(i32 %n) nounwind ssp { +; CHECK: @test6 +entry: + %0 = tail call noalias i8* @malloc(i32 20) nounwind + %1 = tail call i32 @llvm.objectsize.i32(i8* %0, i1 false) + %2 = load i8** @s, align 8 +; CHECK-NOT: @llvm.objectsize +; CHECK: @__memcpy_chk(i8* %0, i8* %1, i32 30, i32 20) + %3 = tail call i8* @__memcpy_chk(i8* %0, i8* %2, i32 30, i32 %1) nounwind + ret void +} + declare i8* @__memset_chk(i8*, i32, i64, i64) nounwind declare noalias i8* @malloc(i32) nounwind diff --git a/test/Transforms/SimplifyCFG/2010-03-30-InvokeCrash.ll b/test/Transforms/SimplifyCFG/2010-03-30-InvokeCrash.ll new file mode 100644 index 000000000000..ced89cf4c2b3 --- /dev/null +++ b/test/Transforms/SimplifyCFG/2010-03-30-InvokeCrash.ll @@ -0,0 +1,18 @@ +; RUN: opt %s -simplifycfg -disable-output +; END. +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" + +declare void @bar(i32) + +define void @foo() { +entry: + invoke void @bar(i32 undef) + to label %r unwind label %u + +r: ; preds = %entry + ret void + +u: ; preds = %entry + unwind +} diff --git a/test/Transforms/SimplifyLibCalls/StrCpy.ll b/test/Transforms/SimplifyLibCalls/StrCpy.ll index 75429842cd21..c3cc58ce3806 100644 --- a/test/Transforms/SimplifyLibCalls/StrCpy.ll +++ b/test/Transforms/SimplifyLibCalls/StrCpy.ll @@ -1,30 +1,37 @@ ; Test that the StrCpyOptimizer works correctly -; RUN: opt < %s -simplify-libcalls -S | \ -; RUN: not grep {call.*strcpy} +; RUN: opt < %s -simplify-libcalls -S | FileCheck %s ; This transformation requires the pointer size, as it assumes that size_t is ; the size of a pointer. -target datalayout = "-p:64:64:64" +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" -@hello = constant [6 x i8] c"hello\00" ; <[6 x i8]*> [#uses=1] -@null = constant [1 x i8] zeroinitializer ; <[1 x i8]*> [#uses=1] -@null_hello = constant [7 x i8] c"\00hello\00" ; <[7 x i8]*> [#uses=1] +@hello = constant [6 x i8] c"hello\00" declare i8* @strcpy(i8*, i8*) -declare i32 @puts(i8*) +declare i8* @__strcpy_chk(i8*, i8*, i32) nounwind -define i32 @main() { - %target = alloca [1024 x i8] ; <[1024 x i8]*> [#uses=1] - %arg1 = getelementptr [1024 x i8]* %target, i32 0, i32 0 ; <i8*> [#uses=2] - store i8 0, i8* %arg1 - %arg2 = getelementptr [6 x i8]* @hello, i32 0, i32 0 ; <i8*> [#uses=1] - %rslt1 = call i8* @strcpy( i8* %arg1, i8* %arg2 ) ; <i8*> [#uses=1] - %arg3 = getelementptr [1 x i8]* @null, i32 0, i32 0 ; <i8*> [#uses=1] - %rslt2 = call i8* @strcpy( i8* %rslt1, i8* %arg3 ) ; <i8*> [#uses=1] - %arg4 = getelementptr [7 x i8]* @null_hello, i32 0, i32 0 ; <i8*> [#uses=1] - %rslt3 = call i8* @strcpy( i8* %rslt2, i8* %arg4 ) ; <i8*> [#uses=1] - call i32 @puts( i8* %rslt3 ) ; <i32>:1 [#uses=0] - ret i32 0 +declare i32 @llvm.objectsize.i32(i8*, i1) nounwind readonly + +; rdar://6839935 + +define i32 @t1() { +; CHECK: @t1 + %target = alloca [1024 x i8] + %arg1 = getelementptr [1024 x i8]* %target, i32 0, i32 0 + %arg2 = getelementptr [6 x i8]* @hello, i32 0, i32 0 + %rslt1 = call i8* @strcpy( i8* %arg1, i8* %arg2 ) +; CHECK: @llvm.memcpy.i32 + ret i32 0 } +define i32 @t2() { +; CHECK: @t2 + %target = alloca [1024 x i8] + %arg1 = getelementptr [1024 x i8]* %target, i32 0, i32 0 + %arg2 = getelementptr [6 x i8]* @hello, i32 0, i32 0 + %tmp1 = call i32 @llvm.objectsize.i32(i8* %arg1, i1 false) + %rslt1 = call i8* @__strcpy_chk(i8* %arg1, i8* %arg2, i32 %tmp1) +; CHECK: @__memcpy_chk + ret i32 0 +} |
