Skip to content

Commit

Permalink
[FunctionAttrs] Add additional tests for writeonly (NFC)
Browse files Browse the repository at this point in the history
Add tests with argmem variations.
  • Loading branch information
nikic committed Oct 19, 2023
1 parent 5316d19 commit 9ea2fd2
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions llvm/test/Transforms/FunctionAttrs/writeonly.ll
Expand Up @@ -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
}

0 comments on commit 9ea2fd2

Please sign in to comment.