-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[SPIRV] Handle aggregate arguments to spv_store
#172348
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
Open
AlexVlx
wants to merge
10
commits into
llvm:main
Choose a base branch
from
AlexVlx:spirv_be_staging_12
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c0933bf
i128 is legal in IR / MIR, even though it might yield a module which …
AlexVlx 82dbfe9
Fix formatting.
AlexVlx 18c2124
Merge branch 'main' of https://github.com/llvm/llvm-project into spir…
AlexVlx 2eb946a
Merge branch 'main' of https://github.com/llvm/llvm-project into spir…
AlexVlx 40de8fd
Merge branch 'main' of https://github.com/llvm/llvm-project into spir…
AlexVlx 97d5cc2
Handle storing of aggregates via `spv_store`.
AlexVlx 46745f4
Merge branch 'main' of https://github.com/llvm/llvm-project into spir…
AlexVlx f837bb6
Fix formatting.
AlexVlx b72197d
Merge branch 'main' of https://github.com/llvm/llvm-project into spir…
AlexVlx f70786d
Merge branch 'main' of https://github.com/llvm/llvm-project into spir…
AlexVlx 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 |
|---|---|---|
| @@ -1,13 +1,19 @@ | ||
| ; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s | ||
| ; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s | ||
| ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %} | ||
| ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %} | ||
|
|
||
| ; CHECK-DAG: OpName [[FOOBAR:%.+]] "foobar" | ||
| ; CHECK-DAG: OpName [[PRODUCER:%.+]] "producer" | ||
| ; CHECK-DAG: OpName [[CONSUMER:%.+]] "consumer" | ||
| ; CHECK-DAG: OpName [[SNEAKY:%.+]] "sneaky" | ||
| ; CHECK-DAG: OpName [[ARR_RET:%.+]] "arr_ret" | ||
|
|
||
| ; CHECK-NOT: DAG-FENCE | ||
|
|
||
| %ty1 = type {i16, i32} | ||
| %ty2 = type {%ty1, i64} | ||
| %ty3 = type {ptr addrspace(4), ptr addrspace(4), [8 x i8]} | ||
|
|
||
| ; CHECK-DAG: [[I16:%.+]] = OpTypeInt 16 | ||
| ; CHECK-DAG: [[I32:%.+]] = OpTypeInt 32 | ||
|
|
@@ -18,6 +24,12 @@ | |
| ; CHECK-DAG: [[UNDEF_I64:%.+]] = OpUndef [[I64]] | ||
| ; CHECK-DAG: [[UNDEF_TY2:%.+]] = OpUndef [[TY2]] | ||
| ; CHECK-DAG: [[CST_42:%.+]] = OpConstant [[I32]] 42 | ||
| ; CHECK-DAG: [[I8:%.+]] = OpTypeInt 8 0 | ||
| ; CHECK-DAG: [[PTR:%.+]] = OpTypePointer Generic [[I8]] | ||
| ; CHECK-DAG: [[CST_8:%.+]] = OpConstant [[I32]] 8 | ||
| ; CHECK-DAG: [[ARR:%.+]] = OpTypeArray [[I8]] [[CST_8]] | ||
| ; CHECK-DAG: [[TY3:%.+]] = OpTypeStruct [[PTR]] [[PTR]] [[ARR]] | ||
| ; CHECK-DAG: [[PTR_ARR:%.+]] = OpTypePointer Generic [[ARR]] | ||
|
|
||
| ; CHECK-NOT: DAG-FENCE | ||
|
|
||
|
|
@@ -62,3 +74,21 @@ define i32 @consumer(%ty2 %agg) { | |
| ; CHECK: [[RET:%.+]] = OpCompositeExtract [[I32]] [[AGG]] 0 1 | ||
| ; CHECK: OpReturnValue [[RET]] | ||
| ; CHECK: OpFunctionEnd | ||
|
|
||
| declare %ty3 @arr_ret() | ||
|
|
||
| define void @sneaky(ptr addrspace(4) %p, [8 x i8] %a) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is |
||
| %1 = call spir_func %ty3 @arr_ret() | ||
| %2 = getelementptr inbounds nuw %ty3, ptr addrspace(4) %p, i32 0, i32 2 | ||
| %3 = extractvalue %ty3 %1, 2 | ||
| store [8 x i8] %3, ptr addrspace(4) %2, align 8 | ||
| ret void | ||
| } | ||
|
|
||
| ; CHECK: [[SNEAKY]] = OpFunction | ||
| ; CHECK: [[PTR_AGG:%.+]] = OpFunctionParameter | ||
| ; CHECK: [[A:%.+]] = OpFunctionParameter [[ARR]] | ||
| ; CHECK: [[AGG_RET:%.+]] = OpFunctionCall [[TY3]] | ||
| ; CHECK: [[GEP:%.+]] = OpInBoundsPtrAccessChain [[PTR_ARR]] [[PTR_AGG]] | ||
| ; CHECK: [[EXTRACTV:%.+]] = OpCompositeExtract [[ARR]] [[AGG_RET]] 2 | ||
| ; CHECK: OpStore [[GEP]] [[EXTRACTV]] | ||
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.
I'm not sure this change generates valid llvm-ir since we update the call return type but not the called function type.
The generated LLVM-IR for the test is:
With expensive checks enabled the test is passing still, even though I don't think this is valid IR, since we have:
Can we replace the call to
llvm.spv.extractv.a8i8with a call tollvm.spv.extractv.i32and then mutate the type ?