[llvm] 3dfa76b - [tests] Precommit tests for writeonly argument attribute inference

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 1 19:48:38 PST 2021


Author: Philip Reames
Date: 2021-12-01T19:48:29-08:00
New Revision: 3dfa76b695f8812e70b2b46bb12dfc2a76ab296a

URL: https://github.com/llvm/llvm-project/commit/3dfa76b695f8812e70b2b46bb12dfc2a76ab296a
DIFF: https://github.com/llvm/llvm-project/commit/3dfa76b695f8812e70b2b46bb12dfc2a76ab296a.diff

LOG: [tests] Precommit tests for writeonly argument attribute inference

Added: 
    

Modified: 
    llvm/test/Transforms/FunctionAttrs/writeonly.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/FunctionAttrs/writeonly.ll b/llvm/test/Transforms/FunctionAttrs/writeonly.ll
index db9f49bc9e4c5..f3431ae42cb4c 100644
--- a/llvm/test/Transforms/FunctionAttrs/writeonly.ll
+++ b/llvm/test/Transforms/FunctionAttrs/writeonly.ll
@@ -25,6 +25,82 @@ nouses-argworn-funwo_entry:
   ret void
 }
 
+; CHECK: define void @test_store(i8* nocapture %p)
+define void @test_store(i8* %p) {
+  store i8 0, i8* %p
+  ret void
+}
+
+; CHECK: define void @test_addressing(i8* nocapture %p)
+define void @test_addressing(i8* %p) {
+  %gep = getelementptr i8, i8* %p, i64 8
+  %bitcast = bitcast i8* %gep to i32*
+  store i32 0, i32* %bitcast
+  ret void
+}
+
+; CHECK: define void @test_readwrite(i8* nocapture %p)
+define void @test_readwrite(i8* %p) {
+  %v = load i8, i8* %p
+  store i8 %v, i8* %p
+  ret void
+}
+
+; CHECK: define void @test_volatile(i8* %p)
+define void @test_volatile(i8* %p) {
+  store volatile i8 0, i8* %p
+  ret void
+}
+
+; CHECK: define void @test_atomicrmw(i8* nocapture %p)
+define void @test_atomicrmw(i8* %p) {
+  atomicrmw add i8* %p, i8 0  seq_cst
+  ret void
+}
+
+
+declare void @direct1_callee(i8* %p)
+
+; CHECK: define void @direct1(i8* %p)
+define void @direct1(i8* %p) {
+  call void @direct1_callee(i8* %p)
+  ret void
+}
+
+declare void @direct2_callee(i8* %p) writeonly
+
+; CHECK: define void @direct2(i8* %p)
+define void @direct2(i8* %p) {
+  call void @direct2_callee(i8* %p)
+  ret void
+}
+
+declare void @direct3_callee(i8* writeonly %p)
+
+; CHECK: define void @direct3(i8* %p)
+define void @direct3(i8* %p) {
+  call void @direct3_callee(i8* %p)
+  ret void
+}
+
+; CHECK: define void @fptr_test1(i8* %p, void (i8*)* nocapture %f)
+define void @fptr_test1(i8* %p, void (i8*)* %f) {
+  call void %f(i8* %p)
+  ret void
+}
+
+; CHECK: define void @fptr_test2(i8* %p, void (i8*)* nocapture %f)
+define void @fptr_test2(i8* %p, void (i8*)* %f) {
+  call void %f(i8* writeonly %p)
+  ret void
+}
+
+; CHECK: define void @fptr_test3(i8* %p, void (i8*)* nocapture %f)
+define void @fptr_test3(i8* %p, void (i8*)* %f) {
+  call void %f(i8* %p) writeonly
+  ret void
+}
+
 ; CHECK: attributes #0 = { {{.*}}readnone{{.*}} }
 ; CHECK: attributes #1 = { {{.*}}readonly{{.*}} }
 ; CHECK: attributes #2 = { {{.*}}writeonly{{.*}} }


        


More information about the llvm-commits mailing list