Skip to content
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

OpSource parsing does not account for optional parameters #2188

Open
Snektron opened this issue Oct 15, 2023 · 0 comments
Open

OpSource parsing does not account for optional parameters #2188

Snektron opened this issue Oct 15, 2023 · 0 comments

Comments

@Snektron
Copy link

%1 = OpString "test"
     OpSource Unknown 0 %1
%2 = OpString "test"

Running llvm-spirv -r ./test.spv --spirv-debug prints:

addCapability: Kernel
Read word: W = 119734787 V = 119734787
Read word: W = 66560 V = 66560
Read word: W = 458752 V = 458752
Read word: W = 3 V = 3
Read word: W = 0 V = 0
Read word: W = 262151 V = 262151
[SPIRVDecoder] getWordCountAndOpCode 4 String
Read word: W = 1 V = 1
Read string: "test"
Read word: W = 262147 V = 262147
[SPIRVDecoder] getWordCountAndOpCode 4 Source
Read word: W = 0 V = 0
Read word: W = 0 V = 0
Read word: W = 1 V = 1
[SPIRVDecoder] getWordCountAndOpCode 0 Undef
Read word: W = 262151 V = 262151
[SPIRVDecoder] getWordCountAndOpCode 4 String
Read word: W = 2 V = 2
Read string: "test"
Read word: W = 32664 V = 32664
[SPIRVDecoder] getWordCountAndOpCode FAIL 0 0

It fails to consider that OpSource accepts optional operands, and then tries to parse the optional parameter as an instruction.

Snektron added a commit to Snektron/zig that referenced this issue Oct 15, 2023
The Khronos SPIRV-LLVM translator does not parse OpSource correctly. This
was causing tests to fail and other mysterious issues.

These are resolved by only generating a single OpSource instruction for now,
which does not have the source file locations also.

See KhronosGroup/SPIRV-LLVM-Translator#2188
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant