diff options
| author | Igor Laevsky <igmyrj@gmail.com> | 2015-09-23 11:38:44 +0000 |
|---|---|---|
| committer | Igor Laevsky <igmyrj@gmail.com> | 2015-09-23 11:38:44 +0000 |
| commit | 029bd93c5dba80145a04d7c7ac56ded6cd8d1d8e (patch) | |
| tree | 25e79a56debebd39766cdd74fa8973365d2836ea /llvm/test | |
| parent | edf1465a561ecab73be2238a90b77fda6d8fabb1 (diff) | |
| download | bcm5719-llvm-029bd93c5dba80145a04d7c7ac56ded6cd8d1d8e.tar.gz bcm5719-llvm-029bd93c5dba80145a04d7c7ac56ded6cd8d1d8e.zip | |
[DeadStoreElimination] Remove dead zero store to calloc initialized memory
This change allows dead store elimination to remove zero and null stores into memory freshly allocated with calloc-like function.
Differential Revision: http://reviews.llvm.org/D13021
llvm-svn: 248374
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/Transforms/DeadStoreElimination/calloc-store.ll | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/llvm/test/Transforms/DeadStoreElimination/calloc-store.ll b/llvm/test/Transforms/DeadStoreElimination/calloc-store.ll new file mode 100644 index 00000000000..daba6133206 --- /dev/null +++ b/llvm/test/Transforms/DeadStoreElimination/calloc-store.ll @@ -0,0 +1,65 @@ +; RUN: opt < %s -basicaa -dse -S | FileCheck %s + +declare noalias i8* @calloc(i64, i64) + +define i32* @test1() { +; CHECK-LABEL: test1 + %1 = tail call noalias i8* @calloc(i64 1, i64 4) + %2 = bitcast i8* %1 to i32* + ; This store is dead and should be removed + store i32 0, i32* %2, align 4 +; CHECK-NOT: store i32 0, i32* %2, align 4 + ret i32* %2 +} + +define i32* @test2() { +; CHECK-LABEL: test2 + %1 = tail call noalias i8* @calloc(i64 1, i64 4) + %2 = bitcast i8* %1 to i32* + %3 = getelementptr i32, i32* %2, i32 5 + store i32 0, i32* %3, align 4 +; CHECK-NOT: store i32 0, i32* %2, align 4 + ret i32* %2 +} + +define i32* @test3(i32 *%arg) { +; CHECK-LABEL: test3 + store i32 0, i32* %arg, align 4 +; CHECK: store i32 0, i32* %arg, align 4 + ret i32* %arg +} + +declare void @clobber_memory(i8*) +define i8* @test4() { +; CHECK-LABEL: test4 + %1 = tail call noalias i8* @calloc(i64 1, i64 4) + call void @clobber_memory(i8* %1) + store i8 0, i8* %1, align 4 +; CHECK: store i8 0, i8* %1, align 4 + ret i8* %1 +} + +define i32* @test5() { +; CHECK-LABEL: test5 + %1 = tail call noalias i8* @calloc(i64 1, i64 4) + %2 = bitcast i8* %1 to i32* + store volatile i32 0, i32* %2, align 4 +; CHECK: store volatile i32 0, i32* %2, align 4 + ret i32* %2 +} + +define i8* @test6() { +; CHECK-LABEL: test6 + %1 = tail call noalias i8* @calloc(i64 1, i64 4) + store i8 5, i8* %1, align 4 +; CHECK: store i8 5, i8* %1, align 4 + ret i8* %1 +} + +define i8* @test7(i8 %arg) { +; CHECK-LABEL: test7 + %1 = tail call noalias i8* @calloc(i64 1, i64 4) + store i8 %arg, i8* %1, align 4 +; CHECK: store i8 %arg, i8* %1, align 4 + ret i8* %1 +} |

