[llvm] 222442e - [BasicAA] Add tests for strcat/strncat/strcpy.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 2 09:38:26 PST 2021


Author: Florian Hahn
Date: 2021-12-02T17:38:07Z
New Revision: 222442ec2d7172faedf20291f5d14f4883b5fa1b

URL: https://github.com/llvm/llvm-project/commit/222442ec2d7172faedf20291f5d14f4883b5fa1b
DIFF: https://github.com/llvm/llvm-project/commit/222442ec2d7172faedf20291f5d14f4883b5fa1b.diff

LOG: [BasicAA] Add tests for strcat/strncat/strcpy.

Added: 
    

Modified: 
    llvm/test/Analysis/BasicAA/libfuncs.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Analysis/BasicAA/libfuncs.ll b/llvm/test/Analysis/BasicAA/libfuncs.ll
index 253a154de501f..c9c457c7a4cfa 100644
--- a/llvm/test/Analysis/BasicAA/libfuncs.ll
+++ b/llvm/test/Analysis/BasicAA/libfuncs.ll
@@ -128,6 +128,81 @@ entry:
   ret i8* %res
 }
 
+declare i8* @strcat(i8*, i8*)
+
+define i8* @test_strcat_read_write_after(i8* noalias %a, i8* noalias %b) {
+; CHECK-LABEL: Function: test_strcat_read_write_after
+; CHECK:       Both ModRef:  Ptr: i8* %a	<->  %res = tail call i8* @strcat(i8* %a.gep.1, i8* %b.gep.1)
+; CHECK-NEXT:  Just Ref:  Ptr: i8* %b	<->  %res = tail call i8* @strcat(i8* %a.gep.1, i8* %b.gep.1)
+; CHECK-NEXT:  Both ModRef:  Ptr: i8* %a.gep.1	<->  %res = tail call i8* @strcat(i8* %a.gep.1, i8* %b.gep.1)
+; CHECK-NEXT:  Just Ref:  Ptr: i8* %b.gep.1	<->  %res = tail call i8* @strcat(i8* %a.gep.1, i8* %b.gep.1)
+; CHECK-NEXT:  Both ModRef:  Ptr: i8* %res	<->  %res = tail call i8* @strcat(i8* %a.gep.1, i8* %b.gep.1)
+; CHECK-NEXT:  Both ModRef:  Ptr: i8* %a.gep.5	<->  %res = tail call i8* @strcat(i8* %a.gep.1, i8* %b.gep.1)
+; CHECK-NEXT:  Just Ref:  Ptr: i8* %b.gep.5	<->  %res = tail call i8* @strcat(i8* %a.gep.1, i8* %b.gep.1)
+;
+entry:
+  store i8 0, i8* %a
+  store i8 2, i8* %b
+  %a.gep.1 = getelementptr i8, i8* %a, i32 1
+  %b.gep.1 = getelementptr i8, i8* %b, i32 1
+  %res = tail call i8* @strcat(i8* %a.gep.1, i8* %b.gep.1)
+  %a.gep.5 = getelementptr i8, i8* %a, i32 5
+  store i8 1, i8* %a.gep.5
+  %b.gep.5 = getelementptr i8, i8* %b, i32 5
+  store i8 3, i8* %b.gep.5
+  ret i8* %res
+}
+
+declare i8* @strncat(i8*, i8*, i64)
+
+define i8* @test_strncat_read_write_after(i8* noalias %a, i8* noalias %b, i64 %n) {
+; CHECK-LABEL: Function: test_strncat_read_write_after
+; CHECK:       Both ModRef:  Ptr: i8* %a	<->  %res = tail call i8* @strncat(i8* %a.gep.1, i8* %b.gep.1, i64 %n)
+; CHECK-NEXT:  Just Ref:  Ptr: i8* %b	<->  %res = tail call i8* @strncat(i8* %a.gep.1, i8* %b.gep.1, i64 %n)
+; CHECK-NEXT:  Both ModRef:  Ptr: i8* %a.gep.1	<->  %res = tail call i8* @strncat(i8* %a.gep.1, i8* %b.gep.1, i64 %n)
+; CHECK-NEXT:  Just Ref:  Ptr: i8* %b.gep.1	<->  %res = tail call i8* @strncat(i8* %a.gep.1, i8* %b.gep.1, i64 %n)
+; CHECK-NEXT:  Both ModRef:  Ptr: i8* %res	<->  %res = tail call i8* @strncat(i8* %a.gep.1, i8* %b.gep.1, i64 %n)
+; CHECK-NEXT:  Both ModRef:  Ptr: i8* %a.gep.5	<->  %res = tail call i8* @strncat(i8* %a.gep.1, i8* %b.gep.1, i64 %n)
+; CHECK-NEXT:  Just Ref:  Ptr: i8* %b.gep.5	<->  %res = tail call i8* @strncat(i8* %a.gep.1, i8* %b.gep.1, i64 %n)
+;
+entry:
+  store i8 0, i8* %a
+  store i8 2, i8* %b
+  %a.gep.1 = getelementptr i8, i8* %a, i32 1
+  %b.gep.1 = getelementptr i8, i8* %b, i32 1
+  %res = tail call i8* @strncat(i8* %a.gep.1, i8* %b.gep.1, i64 %n)
+  %a.gep.5 = getelementptr i8, i8* %a, i32 5
+  store i8 1, i8* %a.gep.5
+  %b.gep.5 = getelementptr i8, i8* %b, i32 5
+  store i8 3, i8* %b.gep.5
+  ret i8* %res
+}
+
+declare i8* @strcpy(i8*, i8*)
+
+define i8* @test_strcpy_read_write_after(i8* noalias %a, i8* noalias %b) {
+; CHECK-LABEL: Function: test_strcpy_read_write_after
+; CHECK:       Just Mod:  Ptr: i8* %a	<->  %res = tail call i8* @strcpy(i8* %a.gep.1, i8* %b.gep.1)
+; CHECK-NEXT:  Just Ref:  Ptr: i8* %b	<->  %res = tail call i8* @strcpy(i8* %a.gep.1, i8* %b.gep.1)
+; CHECK-NEXT:  Just Mod:  Ptr: i8* %a.gep.1	<->  %res = tail call i8* @strcpy(i8* %a.gep.1, i8* %b.gep.1)
+; CHECK-NEXT:  Just Ref:  Ptr: i8* %b.gep.1	<->  %res = tail call i8* @strcpy(i8* %a.gep.1, i8* %b.gep.1)
+; CHECK-NEXT:  Just Mod:  Ptr: i8* %res	<->  %res = tail call i8* @strcpy(i8* %a.gep.1, i8* %b.gep.1)
+; CHECK-NEXT:  Just Mod:  Ptr: i8* %a.gep.5	<->  %res = tail call i8* @strcpy(i8* %a.gep.1, i8* %b.gep.1)
+; CHECK-NEXT:  Just Ref:  Ptr: i8* %b.gep.5	<->  %res = tail call i8* @strcpy(i8* %a.gep.1, i8* %b.gep.1)
+;
+entry:
+  store i8 0, i8* %a
+  store i8 2, i8* %b
+  %a.gep.1 = getelementptr i8, i8* %a, i32 1
+  %b.gep.1 = getelementptr i8, i8* %b, i32 1
+  %res = tail call i8* @strcpy(i8* %a.gep.1, i8* %b.gep.1)
+  %a.gep.5 = getelementptr i8, i8* %a, i32 5
+  store i8 1, i8* %a.gep.5
+  %b.gep.5 = getelementptr i8, i8* %b, i32 5
+  store i8 3, i8* %b.gep.5
+  ret i8* %res
+}
+
 declare i8* @strncpy(i8*, i8*, i64)
 
 define i8* @test_strncpy_const_size(i8* noalias %a, i8* noalias %b) {


        


More information about the llvm-commits mailing list