Skip to content

mlir deserialize spirv: "Cannot destroy a value that still has uses!" #163099

@alex-s168

Description

@alex-s168

On LLVM d81ffd4ebb45 (latest main at time of writing)

mlir-translate --deserialize-spirv on the input below causes an error error:

; SPIR-V
; Version: 1.0
; Generator: Khronos SPIR-V Tools Assembler; 0
; Bound: 14
; Schema: 0
               OpCapability Shader
          %1 = OpExtInstImport "GLSL.std.450"
               OpMemoryModel Logical GLSL450
               OpEntryPoint Fragment %2 "main"
               OpExecutionMode %2 OriginLowerLeft
       %void = OpTypeVoid
          %4 = OpTypeFunction %void
       %bool = OpTypeBool
      %false = OpConstantFalse %bool
          %2 = OpFunction %void None %4
          %7 = OpLabel
               OpBranch %8
          %9 = OpLabel
               OpSelectionMerge %10 None
               OpBranchConditional %false %11 %11
         %11 = OpLabel
               OpBranch %12
         %12 = OpLabel
               OpBranch %10
         %13 = OpLabel
               OpBranch %12
         %10 = OpLabel
               OpBranch %8
          %8 = OpLabel
               OpReturn
               OpFunctionEnd

(this was produced by using spirv-reduce on an glslang compiled glsl fragment shader)

error (minimized):

mlir-translate: mlir/include/mlir/IR/UseDefLists.h:198: mlir::IRObjectWithUseList<mlir::BlockOperand>::~IRObjectWithUseList() [OperandType = mlir::BlockOperand]: Assertion `use_empty() && "Cannot destroy a value that still has uses!"' failed.
Stack dump:
...
#12  mlir::Block::erase() Block.cpp:0:0
#13  mlir::spirv::Deserializer::structurizeControlFlow() Deserializer.cpp:0:0
#14  mlir::spirv::Deserializer::processFunctionEnd(llvm::ArrayRef<unsigned int>) Deserializer.cpp:0:0
#15  mlir::spirv::Deserializer::processFunction(llvm::ArrayRef<unsigned int>) Deserializer.cpp:0:0
#16  mlir::spirv::Deserializer::deserialize() Deserializer.cpp:0:0
#17  mlir::spirv::deserialize(llvm::ArrayRef<unsigned int>, mlir::MLIRContext*, mlir::spirv::DeserializationOptions const&) Deserialization.cpp:0:0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions