Skip to content

Commit

Permalink
Add negative test
Browse files Browse the repository at this point in the history
  • Loading branch information
jofrn committed Sep 21, 2024
1 parent 4553484 commit 2c640e5
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions llvm/test/Analysis/Lint/const-store.ll
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
; RUN: not opt --mtriple=amdgcn --passes=lint --lint-abort-on-error %s -o - |& FileCheck %s
; RUN: not opt --mtriple=amdgcn --mcpu=gfx1030 --passes=lint --lint-abort-on-error %s -o - |& FileCheck %s
; RUN: not opt --mtriple=amdgcn --passes=lint --lint-abort-on-error %s -o /dev/null |& FileCheck %s
; RUN: opt --mtriple=amdgcn --mcpu=gfx1030 --passes=lint %s -o /dev/null |& FileCheck %s --check-prefixes=CHECK,CHECK0
; RUN: opt --mtriple=x86_64 --passes=lint --lint-abort-on-error %s -o /dev/null |& FileCheck %s --allow-empty --check-prefix=NOERR
; NOERR: {{^$}}

define amdgpu_kernel void @store_const(ptr addrspace(4) %out, i32 %a, i32 %b) {
; CHECK: Undefined behavior: Write to const memory
Expand All @@ -8,3 +10,12 @@ define amdgpu_kernel void @store_const(ptr addrspace(4) %out, i32 %a, i32 %b) {
store i32 %r, ptr addrspace(4) %out
ret void
}

define amdgpu_kernel void @memcpy_to_const(ptr addrspace(6) %dst, ptr %src) {
; CHECK0: Undefined behavior: Write to const memory
; CHECK0-NEXT: call void @llvm.memcpy.p6.p0.i32(ptr addrspace(6) %dst, ptr %src, i32 256, i1 false)
call void @llvm.memcpy.px.py.i32(ptr addrspace(6) %dst, ptr %src, i32 256, i1 false)
ret void
}

declare void @llvm.memcpy.px.py.i32(ptr addrspace(6) noalias nocapture writeonly, ptr noalias nocapture readonly, i32, i1 immarg)

0 comments on commit 2c640e5

Please sign in to comment.