Debian Codegraph @

test/opt/private_to_local_test.cpp

raw
1 // Copyright (c) 2017 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include <string>
16
17 #include "gmock/gmock.h"
18 #include "source/opt/value_number_table.h"
19 #include "test/opt/assembly_builder.h"
20 #include "test/opt/pass_fixture.h"
21 #include "test/opt/pass_utils.h"
22
23 namespace spvtools {
24 namespace opt {
25 namespace {
26
27 using ::testing::HasSubstr;
28 using ::testing::MatchesRegex;
29 using PrivateToLocalTest = PassTest<::testing::Test>;
30
31 TEST_F(PrivateToLocalTest, ChangeToLocal) {
32 // Change the private variable to a local, and change the types accordingly.
33 const std::string text = R"(
34 OpCapability Shader
35 %1 = OpExtInstImport "GLSL.std.450"
36 OpMemoryModel Logical GLSL450
37 OpEntryPoint Fragment %2 "main"
38 OpExecutionMode %2 OriginUpperLeft
39 OpSource GLSL 430
40 %3 = OpTypeVoid
41 %4 = OpTypeFunction %3
42 ; CHECK: [[float:%[a-zA-Z_\d]+]] = OpTypeFloat 32
43 %5 = OpTypeFloat 32
44 ; CHECK: [[newtype:%[a-zA-Z_\d]+]] = OpTypePointer Function [[float]]
45 %6 = OpTypePointer Private %5
46 ; CHECK-NOT: OpVariable [[.+]] Private
47 %8 = OpVariable %6 Private
48 ; CHECK: OpFunction
49 %2 = OpFunction %3 None %4
50 ; CHECK: OpLabel
51 %7 = OpLabel
52 ; CHECK-NEXT: [[newvar:%[a-zA-Z_\d]+]] = OpVariable [[newtype]] Function
53 ; CHECK: OpLoad [[float]] [[newvar]]
54 %9 = OpLoad %5 %8
55 OpReturn
56 OpFunctionEnd
57 )";
58 SinglePassRunAndMatch<PrivateToLocalPass>(text, false);
59 }
60
61 TEST_F(PrivateToLocalTest, ReuseExistingType) {
62 // Change the private variable to a local, and change the types accordingly.
63 const std::string text = R"(
64 OpCapability Shader
65 %1 = OpExtInstImport "GLSL.std.450"
66 OpMemoryModel Logical GLSL450
67 OpEntryPoint Fragment %2 "main"
68 OpExecutionMode %2 OriginUpperLeft
69 OpSource GLSL 430
70 %3 = OpTypeVoid
71 %4 = OpTypeFunction %3
72 ; CHECK: [[float:%[a-zA-Z_\d]+]] = OpTypeFloat 32
73 %5 = OpTypeFloat 32
74 %func_ptr = OpTypePointer Function %5
75 ; CHECK: [[newtype:%[a-zA-Z_\d]+]] = OpTypePointer Function [[float]]
76 ; CHECK-NOT: [[%[a-zA-Z_\d]+]] = OpTypePointer Function [[float]]
77 %6 = OpTypePointer Private %5
78 ; CHECK-NOT: OpVariable [[.+]] Private
79 %8 = OpVariable %6 Private
80 ; CHECK: OpFunction
81 %2 = OpFunction %3 None %4
82 ; CHECK: OpLabel
83 %7 = OpLabel
84 ; CHECK-NEXT: [[newvar:%[a-zA-Z_\d]+]] = OpVariable [[newtype]] Function
85 ; CHECK: OpLoad [[float]] [[newvar]]
86 %9 = OpLoad %5 %8
87 OpReturn
88 OpFunctionEnd
89 )";
90 SinglePassRunAndMatch<PrivateToLocalPass>(text, false);
91 }
92
93 TEST_F(PrivateToLocalTest, UpdateAccessChain) {
94 // Change the private variable to a local, and change the AccessChain.
95 const std::string text = R"(
96 OpCapability Shader
97 %1 = OpExtInstImport "GLSL.std.450"
98 OpMemoryModel Logical GLSL450
99 OpEntryPoint Fragment %2 "main"
100 OpExecutionMode %2 OriginUpperLeft
101 OpSource GLSL 430
102 %uint = OpTypeInt 32 0
103 %uint_0 = OpConstant %uint 0
104 %void = OpTypeVoid
105 %6 = OpTypeFunction %void
106 ; CHECK: [[float:%[a-zA-Z_\d]+]] = OpTypeFloat
107 %float = OpTypeFloat 32
108 ; CHECK: [[struct:%[a-zA-Z_\d]+]] = OpTypeStruct
109 %_struct_8 = OpTypeStruct %float
110 %_ptr_Private_float = OpTypePointer Private %float
111 ; CHECK: [[new_struct_type:%[a-zA-Z_\d]+]] = OpTypePointer Function [[struct]]
112 ; CHECK: [[new_float_type:%[a-zA-Z_\d]+]] = OpTypePointer Function [[float]]
113 %_ptr_Private__struct_8 = OpTypePointer Private %_struct_8
114 ; CHECK-NOT: OpVariable [[.+]] Private
115 %11 = OpVariable %_ptr_Private__struct_8 Private
116 ; CHECK: OpFunction
117 %2 = OpFunction %void None %6
118 ; CHECK: OpLabel
119 %12 = OpLabel
120 ; CHECK-NEXT: [[newvar:%[a-zA-Z_\d]+]] = OpVariable [[new_struct_type]] Function
121 ; CHECK: [[member:%[a-zA-Z_\d]+]] = OpAccessChain [[new_float_type]] [[newvar]]
122 %13 = OpAccessChain %_ptr_Private_float %11 %uint_0
123 ; CHECK: OpLoad [[float]] [[member]]
124 %14 = OpLoad %float %13
125 OpReturn
126 OpFunctionEnd
127 )";
128 SinglePassRunAndMatch<PrivateToLocalPass>(text, false);
129 }
130
131 TEST_F(PrivateToLocalTest, UseTexelPointer) {
132 // Change the private variable to a local, and change the OpImageTexelPointer.
133 const std::string text = R"(
134 OpCapability SampledBuffer
135 OpCapability StorageImageExtendedFormats
136 OpCapability ImageBuffer
137 OpCapability Shader
138 %1 = OpExtInstImport "GLSL.std.450"
139 OpMemoryModel Logical GLSL450
140 OpEntryPoint GLCompute %2 "min" %gl_GlobalInvocationID
141 OpExecutionMode %2 LocalSize 64 1 1
142 OpSource HLSL 600
143 OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId
144 OpDecorate %4 DescriptorSet 4
145 OpDecorate %4 Binding 70
146 %uint = OpTypeInt 32 0
147 %6 = OpTypeImage %uint Buffer 0 0 0 2 R32ui
148 %_ptr_UniformConstant_6 = OpTypePointer UniformConstant %6
149 %_ptr_Private_6 = OpTypePointer Private %6
150 %void = OpTypeVoid
151 %10 = OpTypeFunction %void
152 %uint_0 = OpConstant %uint 0
153 %uint_1 = OpConstant %uint 1
154 %v3uint = OpTypeVector %uint 3
155 %_ptr_Input_v3uint = OpTypePointer Input %v3uint
156 %_ptr_Image_uint = OpTypePointer Image %uint
157 %4 = OpVariable %_ptr_UniformConstant_6 UniformConstant
158 %16 = OpVariable %_ptr_Private_6 Private
159 %gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input
160 %2 = OpFunction %void None %10
161 %17 = OpLabel
162 ; Make sure the variable was moved.
163 ; CHECK: OpFunction
164 ; CHECK-NEXT: OpLabel
165 ; CHECK-NEXT: OpVariable %_ptr_Function_6 Function
166 %18 = OpLoad %6 %4
167 OpStore %16 %18
168 %19 = OpImageTexelPointer %_ptr_Image_uint %16 %uint_0 %uint_0
169 %20 = OpAtomicIAdd %uint %19 %uint_1 %uint_0 %uint_1
170 OpReturn
171 OpFunctionEnd
172 )";
173 SinglePassRunAndMatch<PrivateToLocalPass>(text, false);
174 }
175
176 TEST_F(PrivateToLocalTest, IgnorePointerToPrivateVariable) {
177 // Should not change because the pointer to the private variable
178 // has been stored inside a function variable.
179 const std::string text = R"(
180 OpCapability Shader
181 OpCapability VariablePointersStorageBuffer
182 OpCapability VariablePointers
183 %1 = OpExtInstImport "GLSL.std.450"
184 OpMemoryModel Logical GLSL450
185 OpEntryPoint GLCompute %load_thread_local "load_thread_local" %v
186 OpExecutionMode %load_thread_local LocalSize 8 8 1
187 %uint = OpTypeInt 32 0
188 %uint_0 = OpConstant %uint 0
189 %void = OpTypeVoid
190 %function_type__1561_ = OpTypeFunction %void
191 %_ptr_Private_uint = OpTypePointer Private %uint
192 %_ptr_Function__ptr_Private_uint = OpTypePointer Function %_ptr_Private_uint
193 %_ptr_Function_uint = OpTypePointer Function %uint
194 %v = OpVariable %_ptr_Private_uint Private %uint_0
195 %load_thread_local = OpFunction %void None %function_type__1561_
196 %37 = OpLabel
197 %31 = OpVariable %_ptr_Function__ptr_Private_uint Function
198 %32 = OpVariable %_ptr_Function_uint Function
199 %33 = OpVariable %_ptr_Function_uint Function
200 OpStore %31 %v
201 %35 = OpLoad %uint %v
202 OpStore %32 %35
203 %36 = OpLoad %uint %v
204 OpStore %33 %36
205 OpReturn
206 OpFunctionEnd
207 )";
208 auto result = SinglePassRunAndDisassemble<PrivateToLocalPass>(
209 text, /* skip_nop = */ true, /* do_validation = */ false);
210 EXPECT_EQ(Pass::Status::SuccessWithoutChange, std::get<1>(result));
211 }
212
213 TEST_F(PrivateToLocalTest, UsedInTwoFunctions) {
214 // Should not change because it is used in multiple functions.
215 const std::string text = R"(
216 OpCapability Shader
217 %1 = OpExtInstImport "GLSL.std.450"
218 OpMemoryModel Logical GLSL450
219 OpEntryPoint Fragment %2 "main"
220 OpExecutionMode %2 OriginUpperLeft
221 OpSource GLSL 430
222 %3 = OpTypeVoid
223 %4 = OpTypeFunction %3
224 %5 = OpTypeFloat 32
225 %6 = OpTypePointer Private %5
226 %8 = OpVariable %6 Private
227 %2 = OpFunction %3 None %4
228 %7 = OpLabel
229 %9 = OpLoad %5 %8
230 OpReturn
231 OpFunctionEnd
232 %10 = OpFunction %3 None %4
233 %11 = OpLabel
234 %12 = OpLoad %5 %8
235 OpReturn
236 OpFunctionEnd
237 )";
238 auto result = SinglePassRunAndDisassemble<StrengthReductionPass>(
239 text, /* skip_nop = */ true, /* do_validation = */ false);
240 EXPECT_EQ(Pass::Status::SuccessWithoutChange, std::get<1>(result));
241 }
242
243 TEST_F(PrivateToLocalTest, UsedInFunctionCall) {
244 // Should not change because it is used in a function call. Changing the
245 // signature of the function would require cloning the function, which is not
246 // worth it.
247 const std::string text = R"(
248 OpCapability Shader
249 %1 = OpExtInstImport "GLSL.std.450"
250 OpMemoryModel Logical GLSL450
251 OpEntryPoint Fragment %2 "main"
252 OpExecutionMode %2 OriginUpperLeft
253 OpSource GLSL 430
254 %void = OpTypeVoid
255 %4 = OpTypeFunction %void
256 %float = OpTypeFloat 32
257 %_ptr_Private_float = OpTypePointer Private %float
258 %7 = OpTypeFunction %void %_ptr_Private_float
259 %8 = OpVariable %_ptr_Private_float Private
260 %2 = OpFunction %void None %4
261 %9 = OpLabel
262 %10 = OpFunctionCall %void %11 %8
263 OpReturn
264 OpFunctionEnd
265 %11 = OpFunction %void None %7
266 %12 = OpFunctionParameter %_ptr_Private_float
267 %13 = OpLabel
268 %14 = OpLoad %float %12
269 OpReturn
270 OpFunctionEnd
271 )";
272 auto result = SinglePassRunAndDisassemble<StrengthReductionPass>(
273 text, /* skip_nop = */ true, /* do_validation = */ false);
274 EXPECT_EQ(Pass::Status::SuccessWithoutChange, std::get<1>(result));
275 }
276
277 TEST_F(PrivateToLocalTest, CreatePointerToAmbiguousStruct1) {
278 // Test that the correct pointer type is picked up.
279 const std::string text = R"(
280 ; CHECK: [[struct1:%[a-zA-Z_\d]+]] = OpTypeStruct
281 ; CHECK: [[struct2:%[a-zA-Z_\d]+]] = OpTypeStruct
282 ; CHECK: [[priv_ptr:%[\w]+]] = OpTypePointer Private [[struct1]]
283 ; CHECK: [[fuct_ptr2:%[\w]+]] = OpTypePointer Function [[struct2]]
284 ; CHECK: [[fuct_ptr1:%[\w]+]] = OpTypePointer Function [[struct1]]
285 ; CHECK: OpFunction
286 ; CHECK: OpLabel
287 ; CHECK-NEXT: [[newvar:%[a-zA-Z_\d]+]] = OpVariable [[fuct_ptr1]] Function
288 ; CHECK: OpLoad [[struct1]] [[newvar]]
289 OpCapability Shader
290 %1 = OpExtInstImport "GLSL.std.450"
291 OpMemoryModel Logical GLSL450
292 OpEntryPoint Fragment %2 "main"
293 OpExecutionMode %2 OriginUpperLeft
294 OpSource GLSL 430
295 %3 = OpTypeVoid
296 %4 = OpTypeFunction %3
297 %5 = OpTypeFloat 32
298 %struct1 = OpTypeStruct %5
299 %struct2 = OpTypeStruct %5
300 %6 = OpTypePointer Private %struct1
301 %func_ptr2 = OpTypePointer Function %struct2
302 %8 = OpVariable %6 Private
303 %2 = OpFunction %3 None %4
304 %7 = OpLabel
305 %9 = OpLoad %struct1 %8
306 OpReturn
307 OpFunctionEnd
308 )";
309 SinglePassRunAndMatch<PrivateToLocalPass>(text, false);
310 }
311
312 TEST_F(PrivateToLocalTest, CreatePointerToAmbiguousStruct2) {
313 // Test that the correct pointer type is picked up.
314 const std::string text = R"(
315 ; CHECK: [[struct1:%[a-zA-Z_\d]+]] = OpTypeStruct
316 ; CHECK: [[struct2:%[a-zA-Z_\d]+]] = OpTypeStruct
317 ; CHECK: [[priv_ptr:%[\w]+]] = OpTypePointer Private [[struct2]]
318 ; CHECK: [[fuct_ptr1:%[\w]+]] = OpTypePointer Function [[struct1]]
319 ; CHECK: [[fuct_ptr2:%[\w]+]] = OpTypePointer Function [[struct2]]
320 ; CHECK: OpFunction
321 ; CHECK: OpLabel
322 ; CHECK-NEXT: [[newvar:%[a-zA-Z_\d]+]] = OpVariable [[fuct_ptr2]] Function
323 ; CHECK: OpLoad [[struct2]] [[newvar]]
324 OpCapability Shader
325 %1 = OpExtInstImport "GLSL.std.450"
326 OpMemoryModel Logical GLSL450
327 OpEntryPoint Fragment %2 "main"
328 OpExecutionMode %2 OriginUpperLeft
329 OpSource GLSL 430
330 %3 = OpTypeVoid
331 %4 = OpTypeFunction %3
332 %5 = OpTypeFloat 32
333 %struct1 = OpTypeStruct %5
334 %struct2 = OpTypeStruct %5
335 %6 = OpTypePointer Private %struct2
336 %func_ptr2 = OpTypePointer Function %struct1
337 %8 = OpVariable %6 Private
338 %2 = OpFunction %3 None %4
339 %7 = OpLabel
340 %9 = OpLoad %struct2 %8
341 OpReturn
342 OpFunctionEnd
343 )";
344 SinglePassRunAndMatch<PrivateToLocalPass>(text, false);
345 }
346
347 TEST_F(PrivateToLocalTest, SPV14RemoveFromInterface) {
348 const std::string text = R"(
349 ; CHECK-NOT: OpEntryPoint GLCompute %foo "foo" %in %priv
350 ; CHECK: OpEntryPoint GLCompute %foo "foo" %in
351 ; CHECK: %priv = OpVariable {{%\w+}} Function
352 OpCapability Shader
353 OpMemoryModel Logical GLSL450
354 OpEntryPoint GLCompute %foo "foo" %in %priv
355 OpExecutionMode %foo LocalSize 1 1 1
356 OpName %foo "foo"
357 OpName %in "in"
358 OpName %priv "priv"
359 %void = OpTypeVoid
360 %int = OpTypeInt 32 0
361 %ptr_ssbo_int = OpTypePointer StorageBuffer %int
362 %ptr_private_int = OpTypePointer Private %int
363 %in = OpVariable %ptr_ssbo_int StorageBuffer
364 %priv = OpVariable %ptr_private_int Private
365 %void_fn = OpTypeFunction %void
366 %foo = OpFunction %void None %void_fn
367 %entry = OpLabel
368 %ld = OpLoad %int %in
369 OpStore %priv %ld
370 OpReturn
371 OpFunctionEnd
372 )";
373
374 SetTargetEnv(SPV_ENV_UNIVERSAL_1_4);
375 SinglePassRunAndMatch<PrivateToLocalPass>(text, true);
376 }
377
378 TEST_F(PrivateToLocalTest, SPV14RemoveFromInterfaceMultipleEntryPoints) {
379 const std::string text = R"(
380 ; CHECK-NOT: OpEntryPoint GLCompute %foo "foo" %in %priv
381 ; CHECK-NOT: OpEntryPoint GLCompute %foo "bar" %in %priv
382 ; CHECK: OpEntryPoint GLCompute %foo "foo" %in
383 ; CHECK: OpEntryPoint GLCompute %foo "bar" %in
384 ; CHECK: %priv = OpVariable {{%\w+}} Function
385 OpCapability Shader
386 OpMemoryModel Logical GLSL450
387 OpEntryPoint GLCompute %foo "foo" %in %priv
388 OpEntryPoint GLCompute %foo "bar" %in %priv
389 OpExecutionMode %foo LocalSize 1 1 1
390 OpName %foo "foo"
391 OpName %in "in"
392 OpName %priv "priv"
393 %void = OpTypeVoid
394 %int = OpTypeInt 32 0
395 %ptr_ssbo_int = OpTypePointer StorageBuffer %int
396 %ptr_private_int = OpTypePointer Private %int
397 %in = OpVariable %ptr_ssbo_int StorageBuffer
398 %priv = OpVariable %ptr_private_int Private
399 %void_fn = OpTypeFunction %void
400 %foo = OpFunction %void None %void_fn
401 %entry = OpLabel
402 %ld = OpLoad %int %in
403 OpStore %priv %ld
404 OpReturn
405 OpFunctionEnd
406 )";
407
408 SetTargetEnv(SPV_ENV_UNIVERSAL_1_4);
409 SinglePassRunAndMatch<PrivateToLocalPass>(text, true);
410 }
411
412 TEST_F(PrivateToLocalTest, SPV14RemoveFromInterfaceMultipleVariables) {
413 const std::string text = R"(
414 ; CHECK-NOT: OpEntryPoint GLCompute %foo "foo" %in %priv1 %priv2
415 ; CHECK: OpEntryPoint GLCompute %foo "foo" %in
416 ; CHECK: %priv1 = OpVariable {{%\w+}} Function
417 ; CHECK: %priv2 = OpVariable {{%\w+}} Function
418 OpCapability Shader
419 OpMemoryModel Logical GLSL450
420 OpEntryPoint GLCompute %foo "foo" %in %priv1 %priv2
421 OpExecutionMode %foo LocalSize 1 1 1
422 OpName %foo "foo"
423 OpName %in "in"
424 OpName %priv1 "priv1"
425 OpName %priv2 "priv2"
426 %void = OpTypeVoid
427 %int = OpTypeInt 32 0
428 %ptr_ssbo_int = OpTypePointer StorageBuffer %int
429 %ptr_private_int = OpTypePointer Private %int
430 %in = OpVariable %ptr_ssbo_int StorageBuffer
431 %priv1 = OpVariable %ptr_private_int Private
432 %priv2 = OpVariable %ptr_private_int Private
433 %void_fn = OpTypeFunction %void
434 %foo = OpFunction %void None %void_fn
435 %entry = OpLabel
436 %1 = OpFunctionCall %void %bar1
437 %2 = OpFunctionCall %void %bar2
438 OpReturn
439 OpFunctionEnd
440 %bar1 = OpFunction %void None %void_fn
441 %3 = OpLabel
442 %ld1 = OpLoad %int %in
443 OpStore %priv1 %ld1
444 OpReturn
445 OpFunctionEnd
446 %bar2 = OpFunction %void None %void_fn
447 %4 = OpLabel
448 %ld2 = OpLoad %int %in
449 OpStore %priv2 %ld2
450 OpReturn
451 OpFunctionEnd
452 )";
453
454 SetTargetEnv(SPV_ENV_UNIVERSAL_1_4);
455 SinglePassRunAndMatch<PrivateToLocalPass>(text, true);
456 }
457
458 TEST_F(PrivateToLocalTest, IdBoundOverflow1) {
459 const std::string text = R"(
460 OpCapability Shader
461 OpMemoryModel Logical GLSL450
462 OpEntryPoint Fragment %4 "main"
463 OpExecutionMode %4 OriginLowerLeft
464 OpSource HLSL 84
465 %2 = OpTypeVoid
466 %3 = OpTypeFunction %2
467 %6 = OpTypeFloat 32
468 %7 = OpTypeVector %6 4
469 %8 = OpTypeStruct %7
470 %4194302 = OpTypeStruct %8 %8
471 %9 = OpTypeStruct %8 %8
472 %11 = OpTypePointer Private %7
473 %18 = OpTypeStruct %6 %9
474 %12 = OpVariable %11 Private
475 %4 = OpFunction %2 None %3
476 %5 = OpLabel
477 %13 = OpLoad %7 %12
478 OpReturn
479 OpFunctionEnd
480 )";
481
482 SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
483
484 std::vector<Message> messages = {
485 {SPV_MSG_ERROR, "", 0, 0, "ID overflow. Try running compact-ids."}};
486 SetMessageConsumer(GetTestMessageConsumer(messages));
487 auto result = SinglePassRunToBinary<PrivateToLocalPass>(text, true);
488 EXPECT_EQ(Pass::Status::Failure, std::get<1>(result));
489 }
490
491 TEST_F(PrivateToLocalTest, DebugPrivateToLocal) {
492 // Debug instructions must not have any impact on changing the private
493 // variable to a local.
494 const std::string text = R"(
495 OpCapability Shader
496 %1 = OpExtInstImport "GLSL.std.450"
497 %10 = OpExtInstImport "OpenCL.DebugInfo.100"
498 OpMemoryModel Logical GLSL450
499 OpEntryPoint Fragment %2 "main"
500 OpExecutionMode %2 OriginUpperLeft
501 %11 = OpString "test"
502 OpSource GLSL 430
503 %13 = OpTypeInt 32 0
504 %14 = OpConstant %13 32
505 %3 = OpTypeVoid
506 %4 = OpTypeFunction %3
507 ; CHECK: [[float:%[a-zA-Z_\d]+]] = OpTypeFloat 32
508 %5 = OpTypeFloat 32
509 ; CHECK: [[newtype:%[a-zA-Z_\d]+]] = OpTypePointer Function [[float]]
510 %6 = OpTypePointer Private %5
511 ; CHECK-NOT: OpVariable [[.+]] Private
512 %8 = OpVariable %6 Private
513
514 %12 = OpExtInst %3 %10 DebugTypeBasic %11 %14 Float
515 %15 = OpExtInst %3 %10 DebugSource %11
516 %16 = OpExtInst %3 %10 DebugCompilationUnit 1 4 %15 GLSL
517 ; CHECK-NOT: DebugGlobalVariable
518 ; CHECK: [[dbg_newvar:%[a-zA-Z_\d]+]] = OpExtInst {{%\w+}} {{%\w+}} DebugLocalVariable
519 %17 = OpExtInst %3 %10 DebugGlobalVariable %11 %12 %15 0 0 %16 %11 %8 FlagIsDefinition
520
521 ; CHECK: OpFunction
522 %2 = OpFunction %3 None %4
523 ; CHECK: OpLabel
524 %7 = OpLabel
525 ; CHECK-NEXT: [[newvar:%[a-zA-Z_\d]+]] = OpVariable [[newtype]] Function
526 ; CHECK-NEXT: DebugDeclare [[dbg_newvar]] [[newvar]]
527 ; CHECK: OpLoad [[float]] [[newvar]]
528 %9 = OpLoad %5 %8
529 OpReturn
530 OpFunctionEnd
531 )";
532 SinglePassRunAndMatch<PrivateToLocalPass>(text, true);
533 }
534
535 } // namespace
536 } // namespace opt
537 } // namespace spvtools