diff options
author | Daniel Neilson <dneilson@azul.com> | 2017-06-29 14:21:28 +0000 |
---|---|---|
committer | Daniel Neilson <dneilson@azul.com> | 2017-06-29 14:21:28 +0000 |
commit | aad1a6f0a417ed8da71e2c5e8aed9e47c989fe26 (patch) | |
tree | f71a9ad186ed6ac65fc9a163068327aa63f97787 /llvm/test/Transforms/InstCombine/memset.ll | |
parent | 98d220e0a53a392963ce3c7336b0806e89bf49ae (diff) | |
download | bcm5719-llvm-aad1a6f0a417ed8da71e2c5e8aed9e47c989fe26.tar.gz bcm5719-llvm-aad1a6f0a417ed8da71e2c5e8aed9e47c989fe26.zip |
Restore original intent of memset instcombine test
Summary:
The original intent of test/Transforms/InstCombine/memset.ll was to test for lowering of llvm.memset into stores when the size of the memset is 1, 2, 4, or 8. Sometime between then and now the test has stopped testing for that, but remained passing due to testing for the absence of llvm.memset calls rather than the presence of store instructions. Right now this test ends up with an empty function body because the alloca is eliminated as safe-to-remove, which results in the llvm.memset calls's being eliminated due to their pointer args being undef; so it is not testing for conversion of llvm.memset into store instructions at all.
This change alters the test to verify that store instructions are created, and moves the target of the memset to an arg of the proc to avoid it being eliminated as unused.
Reviewers: anna, efriedma
Reviewed By: efriedma
Subscribers: efriedma, llvm-commits
Differential Revision: https://reviews.llvm.org/D34642
llvm-svn: 306681
Diffstat (limited to 'llvm/test/Transforms/InstCombine/memset.ll')
-rw-r--r-- | llvm/test/Transforms/InstCombine/memset.ll | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/llvm/test/Transforms/InstCombine/memset.ll b/llvm/test/Transforms/InstCombine/memset.ll index dfafcf948d1..08bbf8ba1ef 100644 --- a/llvm/test/Transforms/InstCombine/memset.ll +++ b/llvm/test/Transforms/InstCombine/memset.ll @@ -1,7 +1,16 @@ -; RUN: opt < %s -instcombine -S | not grep "call.*llvm.memset" +; RUN: opt < %s -instcombine -S | FileCheck %s -define i32 @main() { - %target = alloca [1024 x i8] +define i32 @test([1024 x i8]* %target) { + ;; CHECK-LABEL: test + ;; CHECK-NEXT: [[P1:%[^\s]+]] = getelementptr inbounds [1024 x i8], [1024 x i8]* %target, i64 0, i64 0 + ;; CHECK-NEXT: store i8 1, i8* [[P1]], align 1 + ;; CHECK-NEXT: [[P2:%[^\s]+]] = bitcast [1024 x i8]* %target to i16* + ;; CHECK-NEXT: store i16 257, i16* [[P2]], align 2 + ;; CHECK-NEXT: [[P3:%[^\s]+]] = bitcast [1024 x i8]* %target to i32* + ;; CHECK-NEXT: store i32 16843009, i32* [[P3]], align 4 + ;; CHECK-NEXT: [[P4:%[^\s]+]] = bitcast [1024 x i8]* %target to i64* + ;; CHECK-NEXT: store i64 72340172838076673, i64* [[P4]], align 8 + ;; CHECK-NEXT: ret i32 0 %target_p = getelementptr [1024 x i8], [1024 x i8]* %target, i32 0, i32 0 call void @llvm.memset.p0i8.i32(i8* %target_p, i8 1, i32 0, i32 1, i1 false) call void @llvm.memset.p0i8.i32(i8* %target_p, i8 1, i32 1, i32 1, i1 false) @@ -11,4 +20,4 @@ define i32 @main() { ret i32 0 } -declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i32, i1) nounwind +declare void @llvm.memset.p0i8.i32(i8* nocapture writeonly, i8, i32, i32, i1) argmemonly nounwind |