@@ -2008,6 +2008,111 @@ OpFunctionEnd
20082008 SinglePassRunAndCheck<CanonicalizeIdsPass>(before, after, false , false );
20092009}
20102010
2011+ TEST_F (CanonicalizeIdsTest, NonSemanticDebugInfo) {
2012+ std::string before = R"(
2013+ OpCapability Shader
2014+ OpExtension "SPV_KHR_non_semantic_info"
2015+ OpExtension "SPV_KHR_storage_buffer_storage_class"
2016+ %1 = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
2017+ OpMemoryModel Logical GLSL450
2018+ OpEntryPoint GLCompute %2 "main"
2019+ OpExecutionMode %2 LocalSize 1 1 1
2020+ %4 = OpString ""
2021+ OpDecorate %6 ArrayStride 4
2022+ OpDecorate %7 Block
2023+ OpMemberDecorate %7 0 Offset 0
2024+ OpDecorate %3 Binding 0
2025+ OpDecorate %3 DescriptorSet 0
2026+ %8 = OpTypeVoid
2027+ %9 = OpTypeInt 32 0
2028+ %10 = OpConstant %9 100
2029+ %11 = OpTypeFunction %8
2030+ %12 = OpTypeInt 32 1
2031+ %13 = OpConstant %12 0
2032+ %14 = OpTypeFloat 32
2033+ %5 = OpTypePointer StorageBuffer %14
2034+ %6 = OpTypeRuntimeArray %14
2035+ %7 = OpTypeStruct %6
2036+ %15 = OpTypePointer StorageBuffer %7
2037+ %16 = OpConstant %14 0
2038+ %3 = OpVariable %15 StorageBuffer
2039+ %17 = OpExtInst %8 %1 DebugInfoNone
2040+ %18 = OpExtInst %8 %1 DebugSource %4 %4
2041+ %19 = OpExtInst %8 %1 DebugCompilationUnit %10 %10 %18 %10
2042+ %20 = OpExtInst %8 %1 DebugTypeFunction %10 %8
2043+ %21 = OpExtInst %8 %1 DebugFunction %4 %20 %18 %10 %10 %19 %4 %10 %10
2044+ %22 = OpExtInst %8 %1 DebugEntryPoint %21 %19 %4 %4
2045+ %23 = OpExtInst %8 %1 DebugTypeBasic %4 %10 %10 %10
2046+ %24 = OpExtInst %8 %1 DebugTypeArray %23 %10
2047+ %25 = OpExtInst %8 %1 DebugTypeMember %4 %24 %18 %10 %10 %10 %10 %10
2048+ %26 = OpExtInst %8 %1 DebugTypeComposite %4 %10 %18 %10 %10 %19 %4 %10 %10 %25
2049+ %27 = OpExtInst %8 %1 DebugGlobalVariable %4 %26 %18 %10 %10 %19 %4 %3 %10
2050+ %2 = OpFunction %8 None %11
2051+ %28 = OpLabel
2052+ %29 = OpExtInst %8 %1 DebugFunctionDefinition %21 %2
2053+ %30 = OpExtInst %8 %1 DebugScope %21
2054+ %31 = OpExtInst %8 %1 DebugLine %18 %10 %10 %10 %10
2055+ %32 = OpAccessChain %5 %3 %13 %13
2056+ OpStore %32 %16
2057+ OpReturn
2058+ %33 = OpExtInst %8 %1 DebugNoScope
2059+ OpFunctionEnd
2060+ )" ;
2061+
2062+ std::string after = R"( OpCapability Shader
2063+ OpExtension "SPV_KHR_non_semantic_info"
2064+ OpExtension "SPV_KHR_storage_buffer_storage_class"
2065+ %1 = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
2066+ OpMemoryModel Logical GLSL450
2067+ OpEntryPoint GLCompute %10742 "main"
2068+ OpExecutionMode %10742 LocalSize 1 1 1
2069+ %3 = OpString ""
2070+ OpDecorate %2002 ArrayStride 4
2071+ OpDecorate %1952 Block
2072+ OpMemberDecorate %1952 0 Offset 0
2073+ OpDecorate %2 Binding 0
2074+ OpDecorate %2 DescriptorSet 0
2075+ %8 = OpTypeVoid
2076+ %11 = OpTypeInt 32 0
2077+ %2870 = OpConstant %11 100
2078+ %1282 = OpTypeFunction %8
2079+ %12 = OpTypeInt 32 1
2080+ %2571 = OpConstant %12 0
2081+ %13 = OpTypeFloat 32
2082+ %650 = OpTypePointer StorageBuffer %13
2083+ %2002 = OpTypeRuntimeArray %13
2084+ %1952 = OpTypeStruct %2002
2085+ %2589 = OpTypePointer StorageBuffer %1952
2086+ %2572 = OpConstant %13 0
2087+ %2 = OpVariable %2589 StorageBuffer
2088+ %4 = OpExtInst %8 %1 DebugInfoNone
2089+ %5 = OpExtInst %8 %1 DebugSource %3 %3
2090+ %6 = OpExtInst %8 %1 DebugCompilationUnit %2870 %2870 %5 %2870
2091+ %7 = OpExtInst %8 %1 DebugTypeFunction %2870 %8
2092+ %9 = OpExtInst %8 %1 DebugFunction %3 %7 %5 %2870 %2870 %6 %3 %2870 %2870
2093+ %10 = OpExtInst %8 %1 DebugEntryPoint %9 %6 %3 %3
2094+ %14 = OpExtInst %8 %1 DebugTypeBasic %3 %2870 %2870 %2870
2095+ %15 = OpExtInst %8 %1 DebugTypeArray %14 %2870
2096+ %16 = OpExtInst %8 %1 DebugTypeMember %3 %15 %5 %2870 %2870 %2870 %2870 %2870
2097+ %17 = OpExtInst %8 %1 DebugTypeComposite %3 %2870 %5 %2870 %2870 %6 %3 %2870 %2870 %16
2098+ %18 = OpExtInst %8 %1 DebugGlobalVariable %3 %17 %5 %2870 %2870 %6 %3 %2 %2870
2099+ %10742 = OpFunction %8 None %1282
2100+ %9442 = OpLabel
2101+ %15450 = OpExtInst %8 %1 DebugFunctionDefinition %9 %10742
2102+ %20275 = OpExtInst %8 %1 DebugScope %9
2103+ %19 = OpExtInst %8 %1 DebugLine %5 %2870 %2870 %2870 %2870
2104+ %20274 = OpAccessChain %650 %2 %2571 %2571
2105+ OpStore %20274 %2572
2106+ OpReturn
2107+ %20276 = OpExtInst %8 %1 DebugNoScope
2108+ OpFunctionEnd
2109+ )" ;
2110+
2111+ SetAssembleOptions (SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
2112+ SetDisassembleOptions (SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
2113+ SinglePassRunAndCheck<CanonicalizeIdsPass>(before, after, false , true );
2114+ }
2115+
20112116} // namespace
20122117} // namespace opt
20132118} // namespace spvtools
0 commit comments