@@ -2226,6 +2226,93 @@ TEST_F(CopyPropArrayPassTest, PropCopyLogical) {
2226
2226
SinglePassRunAndMatch<CopyPropagateArrays>(before, true );
2227
2227
}
2228
2228
2229
+ // Ensure that the use of the global variable in a debug instruction does not
2230
+ // stop copy propagation. We expect the image operand to OpImageTexelPointer to
2231
+ // be replaced.
2232
+ TEST_F (CopyPropArrayPassTest, DebugInstNotStore) {
2233
+ const std::string before = R"(
2234
+ OpCapability Shader
2235
+ OpCapability SampledBuffer
2236
+ OpExtension "SPV_KHR_non_semantic_info"
2237
+ OpExtension "SPV_EXT_descriptor_indexing"
2238
+ %1 = OpExtInstImport "GLSL.std.450"
2239
+ %2 = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
2240
+ OpMemoryModel Logical GLSL450
2241
+ OpEntryPoint GLCompute %3 "maincomp"
2242
+ OpExecutionMode %3 LocalSize 16 16 1
2243
+ %4 = OpString ""
2244
+ %uint = OpTypeInt 32 0
2245
+ %uint_0 = OpConstant %uint 0
2246
+ %uint_1 = OpConstant %uint 1
2247
+ %uint_6 = OpConstant %uint 6
2248
+ %uint_8 = OpConstant %uint 8
2249
+ %uint_2 = OpConstant %uint 2
2250
+ %uint_7 = OpConstant %uint 7
2251
+ %uint_3 = OpConstant %uint 3
2252
+ %uint_32 = OpConstant %uint 32
2253
+ %uint_16 = OpConstant %uint 16
2254
+ %uint_4 = OpConstant %uint 4
2255
+ %16 = OpTypeImage %uint Buffer 2 0 0 2 R32ui
2256
+ %_ptr_UniformConstant_16 = OpTypePointer UniformConstant %16
2257
+ %void = OpTypeVoid
2258
+ %uint_5 = OpConstant %uint 5
2259
+ %uint_70 = OpConstant %uint 70
2260
+ %uint_71 = OpConstant %uint 71
2261
+ %uint_72 = OpConstant %uint 72
2262
+ %uint_17 = OpConstant %uint 17
2263
+ %uint_9 = OpConstant %uint 9
2264
+ %uint_25 = OpConstant %uint 25
2265
+ %uint_14 = OpConstant %uint 14
2266
+ %uint_24 = OpConstant %uint 24
2267
+ %uint_13 = OpConstant %uint 13
2268
+ %29 = OpTypeFunction %void
2269
+ %_ptr_Function_16 = OpTypePointer Function %16
2270
+ %_ptr_Image_uint = OpTypePointer Image %uint
2271
+ ; CHECK: [[GV:%\w+]] = OpVariable {{%\w+}} UniformConstant
2272
+ %32 = OpVariable %_ptr_UniformConstant_16 UniformConstant
2273
+ %33 = OpExtInst %void %2 DebugInfoNone
2274
+ %34 = OpExtInst %void %2 DebugExpression
2275
+ %35 = OpExtInst %void %2 DebugTypeBasic %4 %uint_32 %uint_3 %uint_0
2276
+ %36 = OpExtInst %void %2 DebugTypeVector %35 %uint_3
2277
+ %37 = OpExtInst %void %2 DebugSource %4 %4
2278
+ %38 = OpExtInst %void %2 DebugCompilationUnit %uint_1 %uint_4 %37 %uint_5
2279
+ %39 = OpExtInst %void %2 DebugTypeTemplateParameter %4 %36 %33 %37 %uint_0 %uint_0
2280
+ %40 = OpExtInst %void %2 DebugTypeBasic %4 %uint_32 %uint_6 %uint_0
2281
+ %41 = OpExtInst %void %2 DebugSource %4 %4
2282
+ %42 = OpExtInst %void %2 DebugCompilationUnit %uint_1 %uint_4 %41 %uint_5
2283
+ %43 = OpExtInst %void %2 DebugTypeComposite %4 %uint_0 %37 %uint_0 %uint_0 %38 %4 %33 %uint_3
2284
+ %44 = OpExtInst %void %2 DebugTypeTemplateParameter %4 %40 %33 %37 %uint_0 %uint_0
2285
+ %45 = OpExtInst %void %2 DebugTypeTemplate %43 %44
2286
+ %46 = OpExtInst %void %2 DebugTypeFunction %uint_3 %void %40
2287
+ %47 = OpExtInst %void %2 DebugFunction %4 %46 %37 %uint_70 %uint_1 %38 %4 %uint_3 %uint_71
2288
+ %48 = OpExtInst %void %2 DebugLexicalBlock %37 %uint_71 %uint_1 %47
2289
+ %49 = OpExtInst %void %2 DebugLocalVariable %4 %45 %37 %uint_72 %uint_17 %48 %uint_4
2290
+ %50 = OpExtInst %void %2 DebugTypeFunction %uint_3 %void
2291
+ %51 = OpExtInst %void %2 DebugSource %4 %4
2292
+ %52 = OpExtInst %void %2 DebugCompilationUnit %uint_1 %uint_4 %51 %uint_5
2293
+ %53 = OpExtInst %void %2 DebugFunction %4 %50 %51 %uint_24 %uint_1 %52 %4 %uint_3 %uint_25
2294
+ %54 = OpExtInst %void %2 DebugGlobalVariable %4 %45 %37 %uint_17 %uint_16 %38 %4 %32 %uint_8
2295
+ %55 = OpExtInst %void %2 DebugTypeMember %4 %40 %37 %uint_14 %uint_7 %uint_0 %uint_32 %uint_3
2296
+ %56 = OpExtInst %void %2 DebugTypeComposite %4 %uint_1 %37 %uint_13 %uint_9 %38 %4 %uint_32 %uint_3 %55
2297
+ %57 = OpExtInst %void %2 DebugEntryPoint %53 %42 %4 %4
2298
+ %3 = OpFunction %void None %29
2299
+ %58 = OpLabel
2300
+ %59 = OpVariable %_ptr_Function_16 Function
2301
+ %60 = OpLoad %16 %32
2302
+ OpStore %59 %60
2303
+ %61 = OpExtInst %void %2 DebugDeclare %49 %59 %34
2304
+ %62 = OpExtInst %void %2 DebugLine %37 %uint_0 %uint_0 %uint_2 %uint_2
2305
+ ; CHECK: OpImageTexelPointer %_ptr_Image_uint [[GV]] %uint_0 %uint_0
2306
+ %63 = OpImageTexelPointer %_ptr_Image_uint %59 %uint_0 %uint_0
2307
+ %64 = OpAtomicIAdd %uint %63 %uint_1 %uint_0 %uint_1
2308
+ OpReturn
2309
+ OpFunctionEnd
2310
+ )" ;
2311
+
2312
+ SetTargetEnv (SPV_ENV_VULKAN_1_1);
2313
+ SinglePassRunAndMatch<CopyPropagateArrays>(before, false );
2314
+ }
2315
+
2229
2316
} // namespace
2230
2317
} // namespace opt
2231
2318
} // namespace spvtools
0 commit comments