-
Notifications
You must be signed in to change notification settings - Fork 664
Linker does not deduplicate equivalent array types #2442
Copy link
Copy link
Closed
Description
The linker does not deduplicate equivalent array types between modules, which causes type mismatch errors when sharing an array type (or types based on an array) between modules. Can verify fails for variables and for functions (when used as an argument, directly and pointer to).
Example, causes a type mismatch on symbol "x":
; a.spv
OpCapability Linkage
OpCapability Shader
OpMemoryModel Logical Simple
OpDecorate %1 LinkageAttributes "x" Import
%void = OpTypeVoid
%uint = OpTypeInt 32 0
%uint_7 = OpConstant %uint 7
%_arr_uint_uint_7 = OpTypeArray %uint %uint_7
%_ptr_Workgroup__arr_uint_uint_7 = OpTypePointer Workgroup %_arr_uint_uint_7
%1 = OpVariable %_ptr_Workgroup__arr_uint_uint_7 Workgroup
; b.spv, differs from a.spv only in changing Import -> Export
OpCapability Linkage
OpCapability Shader
OpMemoryModel Logical Simple
OpDecorate %1 LinkageAttributes "x" Export
%void = OpTypeVoid
%uint = OpTypeInt 32 0
%uint_7 = OpConstant %uint 7
%_arr_uint_uint_7 = OpTypeArray %uint %uint_7
%_ptr_Workgroup__arr_uint_uint_7 = OpTypePointer Workgroup %_arr_uint_uint_7
%1 = OpVariable %_ptr_Workgroup__arr_uint_uint_7 Workgroup
Removing the OpDecorate instructions produces duplicates of both the constant and types:
OpCapability Shader
OpMemoryModel Logical Simple
OpModuleProcessed "Linked by SPIR-V Tools Linker"
%void = OpTypeVoid
%uint = OpTypeInt 32 0
%uint_7 = OpConstant %uint 7
%_arr_uint_uint_7 = OpTypeArray %uint %uint_7
%_ptr_Workgroup__arr_uint_uint_7 = OpTypePointer Workgroup %_arr_uint_uint_7
%6 = OpVariable %_ptr_Workgroup__arr_uint_uint_7 Workgroup
%uint_7_0 = OpConstant %uint 7
%_arr_uint_uint_7_0 = OpTypeArray %uint %uint_7_0
%_ptr_Workgroup__arr_uint_uint_7_0 = OpTypePointer Workgroup %_arr_uint_uint_7_0
%10 = OpVariable %_ptr_Workgroup__arr_uint_uint_7_0 Workgroup
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels