Skip to content

[SPIR-V] Mark array reference to aliased var as unaliased#6232

Merged
s-perron merged 3 commits into
microsoft:mainfrom
s-perron:i6110
Feb 6, 2024
Merged

[SPIR-V] Mark array reference to aliased var as unaliased#6232
s-perron merged 3 commits into
microsoft:mainfrom
s-perron:i6110

Conversation

@s-perron
Copy link
Copy Markdown
Collaborator

An "aliased" variable is on where the compiler has implicitly added an
extra level indirection. So when we access one of these variable, we
have to do an extra load.

When we do an array access on an aliased variable, we do the extra load
before doing the access chain, but we still treat the result of the
access chain as if it is an aliased value. This causes an extra load and
generates invalid spir-v.

The fix is to change isReferencingNonAliasStructuredOrByteBuffer so
that we do not distinguish between externally and internally visible
variable if we see an array subscript.

Fixes #6110

An "aliased" variable is on where the compiler has implicitly added an
extra level indirection. So when we access one of these variable, we
have to do an extra load.

When we do an array access on an aliased variable, we do the extra load
before doing the access chain, but we still treat the result of the
access chain as if it is an aliased value. This causes an extra load and
generates invalid spir-v.

The fix is to change `isReferencingNonAliasStructuredOrByteBuffer` so
that we do not distinguish between externally and internally visible
variable if we see an array subscript.

Fixes microsoft#6110
Comment thread tools/clang/test/CodeGenSPIRV/type.byte-address-buffer.hlsl Outdated
Comment thread tools/clang/test/CodeGenSPIRV/type.byte-address-buffer.hlsl Outdated
Comment thread tools/clang/test/CodeGenSPIRV/type.byte-address-buffer.hlsl Outdated
Comment thread tools/clang/test/CodeGenSPIRV/type.byte-address-buffer.hlsl Outdated
Comment thread tools/clang/test/CodeGenSPIRV/type.byte-address-buffer.hlsl Outdated
Comment thread tools/clang/test/CodeGenSPIRV/type.byte-address-buffer.hlsl Outdated
s-perron and others added 2 commits February 5, 2024 09:23
Co-authored-by: Nathan Gauër <github@keenuts.net>
@s-perron s-perron merged commit 93db806 into microsoft:main Feb 6, 2024
@s-perron s-perron deleted the i6110 branch February 6, 2024 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[SPIR-V] Crash when accessing buffer from array of buffers

3 participants