-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[Lint][AMDGPU] No store to const addrspace #109181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| ; RUN: not opt --mtriple=amdgcn --passes=lint --lint-abort-on-error %s -disable-output 2>&1 | FileCheck %s | ||
| ; RUN: opt --mtriple=amdgcn --mcpu=gfx1030 --passes=lint %s -disable-output 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK0 | ||
| ; RUN: opt --mtriple=x86_64 --passes=lint --lint-abort-on-error %s -disable-output 2>&1 | FileCheck %s --allow-empty --check-prefix=NOERR | ||
| ; NOERR: {{^$}} | ||
|
|
||
jofrn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| define amdgpu_kernel void @store_const(ptr addrspace(4) %out, i32 %a, i32 %b) { | ||
| ; CHECK: Undefined behavior: Write to memory in const addrspace | ||
| ; CHECK-NEXT: store i32 %r, ptr addrspace(4) %out | ||
| %r = add i32 %a, %b | ||
| store i32 %r, ptr addrspace(4) %out | ||
| ret void | ||
| } | ||
|
|
||
| declare void @llvm.memset.p4.i64(ptr addrspace(4) noalias nocapture writeonly, i8, i64, i1) | ||
| define amdgpu_kernel void @memset_const(ptr addrspace(4) %dst) { | ||
| ; CHECK0: Undefined behavior: Write to memory in const addrspace | ||
| ; CHECK0-NEXT: call void @llvm.memset.p4.i64(ptr addrspace(4) %dst, i8 0, i64 256, i1 false) | ||
| call void @llvm.memset.p4.i64(ptr addrspace(4) %dst, i8 0, i64 256, i1 false) | ||
| ret void | ||
| } | ||
|
|
||
| declare void @llvm.memcpy.p6.p0.i32(ptr addrspace(6) noalias nocapture writeonly, ptr noalias nocapture readonly, i32, i1) | ||
| define amdgpu_kernel void @memcpy_to_const(ptr addrspace(6) %dst, ptr %src) { | ||
| ; CHECK0: Undefined behavior: Write to memory in const addrspace | ||
| ; CHECK0-NEXT: call void @llvm.memcpy.p6.p0.i32(ptr addrspace(6) %dst, ptr %src, i32 256, i1 false) | ||
| call void @llvm.memcpy.p6.p0.i32(ptr addrspace(6) %dst, ptr %src, i32 256, i1 false) | ||
| ret void | ||
| } | ||
|
|
||
| define amdgpu_kernel void @cmpxchg_to_const(ptr addrspace(4) %dst, i32 %src) { | ||
| ; CHECK0: Undefined behavior: Write to memory in const addrspace | ||
| ; CHECK0-NEXT: %void = cmpxchg ptr addrspace(4) %dst, i32 0, i32 %src seq_cst monotonic | ||
| %void = cmpxchg ptr addrspace(4) %dst, i32 0, i32 %src seq_cst monotonic | ||
| ret void | ||
| } | ||
|
|
||
| define amdgpu_kernel void @atomicrmw_to_const(ptr addrspace(4) %dst, i32 %src) { | ||
| ; CHECK0: Undefined behavior: Write to memory in const addrspace | ||
| ; CHECK0-NEXT: %void = atomicrmw add ptr addrspace(4) %dst, i32 %src acquire | ||
| %void = atomicrmw add ptr addrspace(4) %dst, i32 %src acquire | ||
| ret void | ||
| } | ||
|
||
|
|
||
| declare void @const_param(ptr addrspace(6)) | ||
| define amdgpu_kernel void @call_with_const(ptr addrspace(6) %dst) { | ||
| ; CHECK0-NOT: call void @const_param(ptr addrspace(6) %dst) | ||
| call void @const_param(ptr addrspace(6) %dst) | ||
| ret void | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.