-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[SPIRV][SPIRVPrepareGlobals] Map AMD's dynamic LDS 0-element globals to arrays with UINT32_MAX elements #166952
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
5 commits
Select commit
Hold shift + click to select a range
89f8cc5
[SPIRV][SPIRVPrepareGlobals] Map AMD's dynamic LDS 0-element globals …
jmmartinez 4bccb7f
[Review] Rename Magic->UInt32Max
jmmartinez b14f1e5
[Review] use storageClassToAddressSpace(SPIRV::StorageClass::Workgroup);
jmmartinez c4b2b8b
[Review] Add comment
jmmartinez ab31a73
Merge branch 'main' into users/jmmartinez/spirv/hip_dyn_lds
jmmartinez 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| ; RUN: llc -verify-machineinstrs -mtriple=spirv64-amd-amdhsa %s -o - | FileCheck %s | ||
| ; RUN: %if spirv-tools %{ llc -mtriple=spirv64-amd-amdhsa %s -o - -filetype=obj | spirv-val %} | ||
|
|
||
| ; CHECK: OpName %[[#LDS:]] "lds" | ||
| ; CHECK: OpDecorate %[[#LDS]] LinkageAttributes "lds" Import | ||
| ; CHECK: %[[#UINT:]] = OpTypeInt 32 0 | ||
| ; CHECK: %[[#UINT_MAX:]] = OpConstant %[[#UINT]] 4294967295 | ||
| ; CHECK: %[[#LDS_ARR_TY:]] = OpTypeArray %[[#UINT]] %[[#UINT_MAX]] | ||
| ; CHECK: %[[#LDS_ARR_PTR_WG:]] = OpTypePointer Workgroup %[[#LDS_ARR_TY]] | ||
| ; CHECK: %[[#LDS]] = OpVariable %[[#LDS_ARR_PTR_WG]] Workgroup | ||
|
|
||
| @lds = external addrspace(3) global [0 x i32] | ||
|
|
||
| define spir_kernel void @foo(ptr addrspace(4) %in, ptr addrspace(4) %out) { | ||
| entry: | ||
| %val = load i32, ptr addrspace(4) %in | ||
| %add = add i32 %val, 1 | ||
| store i32 %add, ptr addrspace(4) %out | ||
| ret void | ||
| } |
Oops, something went wrong.
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.
What do you want to do with 0-sized arrays that are not the type of the global value? Is even possible to do that? Comments explaining why you limit this to just the type of the GV would be useful.
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.
Sorry I'm not sure I understood the question.
This condition is matching globals that have an array type with 0 elements. If the global does not have an array type or if it is an array type with a size different from 0 this function returns false.
Maybe there is a mix from using
getValueTypevsgetType. The first gives the type of the initializer of the global (the value stored in the global), the second returns the type of the global when used as a value in the llvm-ir (a pointer type).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.
Sorry, I did not write that properly.
Could you have, say, a global whose type is a struct containing a 0-sized array? What do you want to do in case?
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.
I don't think it's possible. These cases get rejected by the frontend normally: https://godbolt.org/z/8PdqqrYMT