[llvm] 0334fa0 - [Tests] Added tests for D88328

Dávid Bolvanský via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 17 17:06:56 PDT 2020


Author: Dávid Bolvanský
Date: 2020-10-18T02:06:39+02:00
New Revision: 0334fa091a910778c0148918f19ba2da2d986534

URL: https://github.com/llvm/llvm-project/commit/0334fa091a910778c0148918f19ba2da2d986534
DIFF: https://github.com/llvm/llvm-project/commit/0334fa091a910778c0148918f19ba2da2d986534.diff

LOG: [Tests] Added tests for D88328

Added: 
    

Modified: 
    llvm/test/Transforms/DeadStoreElimination/MSSA/libcalls.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/DeadStoreElimination/MSSA/libcalls.ll b/llvm/test/Transforms/DeadStoreElimination/MSSA/libcalls.ll
index 1c85d0db6ced7..4376154502826 100644
--- a/llvm/test/Transforms/DeadStoreElimination/MSSA/libcalls.ll
+++ b/llvm/test/Transforms/DeadStoreElimination/MSSA/libcalls.ll
@@ -1,5 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -S -inferattrs -basic-aa -dse < %s | FileCheck %s
+; RUN: opt -S -inferattrs -basic-aa -dse < %s | FileCheck %s --check-prefixes=CHECK,LPM
+; RUN: opt -S -aa-pipeline=basic-aa -passes=inferattrs,dse < %s | FileCheck %s --check-prefixes=CHECK,NPM
 
 target triple = "x86_64-unknown-linux-gnu"
 
@@ -302,3 +303,74 @@ entry:
   %res = call i8* @memccpy(i8* %foo, i8* %stack.ptr, i32 42, i64 %n)
   ret i8* %res
 }
+
+define void @dse_strcpy(i8* nocapture readonly %src) {
+; CHECK-LABEL: @dse_strcpy(
+; CHECK-NEXT:    [[A:%.*]] = alloca [256 x i8], align 16
+; CHECK-NEXT:    [[BUF:%.*]] = getelementptr inbounds [256 x i8], [256 x i8]* [[A]], i64 0, i64 0
+; CHECK-NEXT:    call void @llvm.lifetime.start.p0i8(i64 256, i8* nonnull [[BUF]])
+; CHECK-NEXT:    [[TMP1:%.*]] = call i8* @strcpy(i8* nonnull [[BUF]], i8* nonnull dereferenceable(1) [[SRC:%.*]])
+; CHECK-NEXT:    call void @llvm.lifetime.end.p0i8(i64 256, i8* nonnull [[BUF]])
+; CHECK-NEXT:    ret void
+;
+  %a = alloca [256 x i8], align 16
+  %buf = getelementptr inbounds [256 x i8], [256 x i8]* %a, i64 0, i64 0
+  call void @llvm.lifetime.start.p0i8(i64 256, i8* nonnull %buf)
+  call i8* @strcpy(i8* nonnull %buf, i8* nonnull dereferenceable(1) %src)
+  call void @llvm.lifetime.end.p0i8(i64 256, i8* nonnull %buf)
+  ret void
+}
+
+define void @dse_strncpy(i8* nocapture readonly %src) {
+; CHECK-LABEL: @dse_strncpy(
+; CHECK-NEXT:    [[A:%.*]] = alloca [256 x i8], align 16
+; CHECK-NEXT:    [[BUF:%.*]] = getelementptr inbounds [256 x i8], [256 x i8]* [[A]], i64 0, i64 0
+; CHECK-NEXT:    call void @llvm.lifetime.start.p0i8(i64 256, i8* nonnull [[BUF]])
+; CHECK-NEXT:    [[TMP1:%.*]] = call i8* @strncpy(i8* nonnull [[BUF]], i8* nonnull dereferenceable(1) [[SRC:%.*]], i64 6)
+; CHECK-NEXT:    call void @llvm.lifetime.end.p0i8(i64 256, i8* nonnull [[BUF]])
+; CHECK-NEXT:    ret void
+;
+  %a = alloca [256 x i8], align 16
+  %buf = getelementptr inbounds [256 x i8], [256 x i8]* %a, i64 0, i64 0
+  call void @llvm.lifetime.start.p0i8(i64 256, i8* nonnull %buf)
+  call i8* @strncpy(i8* nonnull %buf, i8* nonnull dereferenceable(1) %src, i64 6)
+  call void @llvm.lifetime.end.p0i8(i64 256, i8* nonnull %buf)
+  ret void
+}
+
+define void @dse_strcat(i8* nocapture readonly %src) {
+; CHECK-LABEL: @dse_strcat(
+; CHECK-NEXT:    [[A:%.*]] = alloca [256 x i8], align 16
+; CHECK-NEXT:    [[BUF:%.*]] = getelementptr inbounds [256 x i8], [256 x i8]* [[A]], i64 0, i64 0
+; CHECK-NEXT:    call void @llvm.lifetime.start.p0i8(i64 256, i8* nonnull [[BUF]])
+; CHECK-NEXT:    [[TMP1:%.*]] = call i8* @strcat(i8* nonnull [[BUF]], i8* nonnull dereferenceable(1) [[SRC:%.*]])
+; CHECK-NEXT:    call void @llvm.lifetime.end.p0i8(i64 256, i8* nonnull [[BUF]])
+; CHECK-NEXT:    ret void
+;
+  %a = alloca [256 x i8], align 16
+  %buf = getelementptr inbounds [256 x i8], [256 x i8]* %a, i64 0, i64 0
+  call void @llvm.lifetime.start.p0i8(i64 256, i8* nonnull %buf)
+  call i8* @strcat(i8* nonnull %buf, i8* nonnull dereferenceable(1) %src)
+  call void @llvm.lifetime.end.p0i8(i64 256, i8* nonnull %buf)
+  ret void
+}
+
+define void @dse_strncat(i8* nocapture readonly %src) {
+; CHECK-LABEL: @dse_strncat(
+; CHECK-NEXT:    [[A:%.*]] = alloca [256 x i8], align 16
+; CHECK-NEXT:    [[BUF:%.*]] = getelementptr inbounds [256 x i8], [256 x i8]* [[A]], i64 0, i64 0
+; CHECK-NEXT:    call void @llvm.lifetime.start.p0i8(i64 256, i8* nonnull [[BUF]])
+; CHECK-NEXT:    [[TMP1:%.*]] = call i8* @strncat(i8* nonnull [[BUF]], i8* nonnull dereferenceable(1) [[SRC:%.*]], i64 6)
+; CHECK-NEXT:    call void @llvm.lifetime.end.p0i8(i64 256, i8* nonnull [[BUF]])
+; CHECK-NEXT:    ret void
+;
+  %a = alloca [256 x i8], align 16
+  %buf = getelementptr inbounds [256 x i8], [256 x i8]* %a, i64 0, i64 0
+  call void @llvm.lifetime.start.p0i8(i64 256, i8* nonnull %buf)
+  call i8* @strncat(i8* nonnull %buf, i8* nonnull dereferenceable(1) %src, i64 6)
+  call void @llvm.lifetime.end.p0i8(i64 256, i8* nonnull %buf)
+  ret void
+}
+
+declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture)
+declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture)


        


More information about the llvm-commits mailing list