-
Notifications
You must be signed in to change notification settings - Fork 622
Open
Description
This appears to be a regression from
The optimization is inserting unexpected OpUndef
between OpVariable
and OpLabel
. It causes VVL errors.
I am attaching two spirv-asm:
- one is without spirv-opt, "o0.spirv-asm.txt", and
- another is with spirv-opt, "o1.spirv-asm.txt"
As a quick reference, I am attaching the important parts here.
The original SPIRV code is following, which is valid, "o0.spirv-asm"
; Function Val_set
%Val_set = OpFunction %void None %77
%this = OpFunctionParameter %_ptr_Function_Val
%v = OpFunctionParameter %bool
%80 = OpLabel
%82 = OpVariable %_ptr_Function_bool Function ; <=== VALID
%83 = OpVariable %_ptr_Function_Val Function
%88 = OpExtInst %void %2 DebugFunctionDefinition %85 %Val_set
%89 = OpExtInst %void %2 DebugScope %85
%95 = OpExtInst %void %2 DebugDeclare %v_0 %82 %43
OpStore %82 %v
%103 = OpExtInst %void %2 DebugDeclare %this_0 %83 %43
%104 = OpLoad %Val %this
OpStore %83 %104
%106 = OpExtInst %void %2 DebugLine %4 %uint_8 %uint_8 %uint_9 %uint_10
And the following is generated from spirv-opt, "o1.spirv-asm"
; Function computeMain
%computeMain = OpFunction %void None %12
%13 = OpLabel
%160 = OpExtInst %void %2 DebugNoScope
%156 = OpUndef %_ptr_Function_int ; <=== Unexpected OpUndef
%138 = OpVariable %_ptr_Function_bool Function ; <=== VVL error
%161 = OpExtInst %void %2 DebugNoScope
Note that an unexpected instruction of OpUndef
is inserted between OpLabel
and OpVariable
.
And it causes Vulkan Validation Layer error.
The VVL error message is following,
error: -1520283006 - VUID-VkShaderModuleCreateInfo-pCode-08737:
vkCreateShaderModule(): pCreateInfo->pCode (spirv-val produced an error):
All OpVariable instructions in a function must be the first instructions in the first block.
%286 = OpVariable %_ptr_Function_bool Function
The Vulkan spec states: If pCode is a pointer to SPIR-V code, pCode must adhere to the validation rules described by the Validation Rules within a Module section of the SPIR-V Environment appendix (https://vulkan.lunarg.com/doc/view/1.4.321.1/windows/antora/spec/latest/chapters/shaders.html#VUID-VkShaderModuleCreateInfo-pCode-08737)
Metadata
Metadata
Assignees
Labels
No labels