Code Monkey home page Code Monkey logo

Comments (6)

karolherbst avatar karolherbst commented on July 17, 2024

okay, I was able to track down the issue a bit more. The bug is inside LLVMToSPIRV::transType.

What happens is basically this:

  1. SPIRV::LLVMToSPIRV::transType called on "void (global struct Node* out, global struct Node* in)"
  2. SPIRV::LLVMToSPIRV::transType called on "global struct Node*"
  3. SPIRV::LLVMToSPIRV::transType called on "struct Node"
  4. SPIRV::LLVMToSPIRV::transType called on "global struct Node*"
  5. SPIRV::LLVMToSPIRV::transType called on "struct Node"

in 5. the call chain gets broken because "struct Node" already exists inside TypeMap, but the call chain has to be aborted in the 4th step already, otherwise we end up with two "global struct Node*" pointer types while parsing the a struct with members pointing to itself.

from spirv-llvm-translator.

karolherbst avatar karolherbst commented on July 17, 2024

some tests which also generated invalid SPIRV like this:

  • transcoding/RecursiveType.ll
  • transcoding/OpImageQuerySize.ll

from spirv-llvm-translator.

karolherbst avatar karolherbst commented on July 17, 2024

Now after reading the SPIRV specification more carefully, especially section 2.8, I came to the conclusion that this should be a bug within spirv-val.

Section 2.8:
[...] Pointer types are also allowed to have multiple ids for the same opcode and operands, to allow for differing decorations (e.g., Volatile) or different decoration values (e.g., different Array Stride values for the ArrayStride). [...]

from spirv-llvm-translator.

karolherbst avatar karolherbst commented on July 17, 2024

Filed bug against spirv-val: KhronosGroup/SPIRV-Tools#1577

from spirv-llvm-translator.

karolherbst avatar karolherbst commented on July 17, 2024

Okay, so for this to be valid SPIR-V code we either need the SPV_KHR_variable_pointers extension or have to use SPIR-V 1.3 whenever we end up with multiple OpTypePointer declarations being identical.

@AlexeySotkin Any suggestion what is the prefered thing to do here?

See KhronosGroup/SPIRV-Tools#1580 for the upstream fix in spirv-val

from spirv-llvm-translator.

MrSidims avatar MrSidims commented on July 17, 2024

It does look like following to patches are addressing this issue:

commit 8a0235a239f34a19136eafd88c7f515537bab40a
Author: Viktoria Maximova <[email protected]>
Date:   Tue Mar 22 12:37:49 2022 +0300

    Support complex recursive types that use an array of pointers (#1434)

    The use of pointer arrays inside the recursive type leads to the SPIR-V IR, where
    the TypePointer is declared after TypeArray. In turn, TypeArray can't handle the
    unknown element type, because the info from TypeForwardPointer is not used.

    Now the translator stores forward declared IDs to use them in backward
    translation. It actually means that the translator "knows" about the type but it
    would be handled later.

commit 5594d7c112edb21508526c6a3b0068df3a4201c6
Author: Alexey Sotkin <[email protected]>
Date:   Thu Mar 4 17:49:10 2021 +0300

    Redesign handling of forward pointers

    In some cases the current implementation doesn't create forward pointers
    when they are required. New approach is to create forward pointers
    during sorting of the type instructions.

    Signed-off-by: Alexey Sotkin <[email protected]>

and this patch proves, that the issue is fixed:

commit 1a800a0f65a231b1e0b5aedf0d99b0230563639b
Author: Sven van Haastregt <[email protected]>
Date:   Tue Jun 29 14:33:50 2021 +0100

    Run spirv-val for more tests

hence closing it

from spirv-llvm-translator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.