From 9ea2fd245739fe7d8f49014f90d2311387bf7682 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 19 Oct 2023 10:21:21 +0200 Subject: [PATCH] [FunctionAttrs] Add additional tests for writeonly (NFC) Add tests with argmem variations. --- .../Transforms/FunctionAttrs/writeonly.ll | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/llvm/test/Transforms/FunctionAttrs/writeonly.ll b/llvm/test/Transforms/FunctionAttrs/writeonly.ll index 633068129eac69..01c2139dbadf64 100644 --- a/llvm/test/Transforms/FunctionAttrs/writeonly.ll +++ b/llvm/test/Transforms/FunctionAttrs/writeonly.ll @@ -317,3 +317,48 @@ define void @fptr_test3(ptr %p, ptr %f) { call void %f(ptr nocapture %p) writeonly ret void } + +define void @test_argmem_none_callee(ptr %p) { +; FNATTRS-LABEL: define {{[^@]+}}@test_argmem_none_callee +; FNATTRS-SAME: (ptr nocapture [[P:%.*]]) { +; FNATTRS-NEXT: call void @direct1_callee(ptr nocapture [[P]]) #[[ATTR9:[0-9]+]] +; FNATTRS-NEXT: ret void +; +; ATTRIBUTOR-LABEL: define {{[^@]+}}@test_argmem_none_callee +; ATTRIBUTOR-SAME: (ptr nocapture [[P:%.*]]) { +; ATTRIBUTOR-NEXT: call void @direct1_callee(ptr nocapture [[P]]) #[[ATTR8:[0-9]+]] +; ATTRIBUTOR-NEXT: ret void +; + call void @direct1_callee(ptr nocapture %p) memory(readwrite, argmem: none) + ret void +} + +define void @test_argmem_read_callee(ptr %p) { +; FNATTRS-LABEL: define {{[^@]+}}@test_argmem_read_callee +; FNATTRS-SAME: (ptr nocapture [[P:%.*]]) { +; FNATTRS-NEXT: call void @direct1_callee(ptr nocapture [[P]]) #[[ATTR10:[0-9]+]] +; FNATTRS-NEXT: ret void +; +; ATTRIBUTOR-LABEL: define {{[^@]+}}@test_argmem_read_callee +; ATTRIBUTOR-SAME: (ptr nocapture [[P:%.*]]) { +; ATTRIBUTOR-NEXT: call void @direct1_callee(ptr nocapture [[P]]) #[[ATTR9:[0-9]+]] +; ATTRIBUTOR-NEXT: ret void +; + call void @direct1_callee(ptr nocapture %p) memory(readwrite, argmem: read) + ret void +} + +define void @test_argmem_write_callee(ptr %p) { +; FNATTRS-LABEL: define {{[^@]+}}@test_argmem_write_callee +; FNATTRS-SAME: (ptr nocapture [[P:%.*]]) { +; FNATTRS-NEXT: call void @direct1_callee(ptr nocapture [[P]]) #[[ATTR11:[0-9]+]] +; FNATTRS-NEXT: ret void +; +; ATTRIBUTOR-LABEL: define {{[^@]+}}@test_argmem_write_callee +; ATTRIBUTOR-SAME: (ptr nocapture [[P:%.*]]) { +; ATTRIBUTOR-NEXT: call void @direct1_callee(ptr nocapture [[P]]) #[[ATTR10:[0-9]+]] +; ATTRIBUTOR-NEXT: ret void +; + call void @direct1_callee(ptr nocapture %p) memory(readwrite, argmem: write) + ret void +}