Debian Codegraph @

test/fuzz/transformation_load_test.cpp

raw
1 // Copyright (c) 2019 Google LLC
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 "source/fuzz/transformation_load.h"
16
17 #include "gtest/gtest.h"
18 #include "source/fuzz/fuzzer_util.h"
19 #include "source/fuzz/instruction_descriptor.h"
20 #include "test/fuzz/fuzz_test_util.h"
21
22 namespace spvtools {
23 namespace fuzz {
24 namespace {
25
26 TEST(TransformationLoadTest, BasicTest) {
27 std::string shader = R"(
28 OpCapability Shader
29 OpCapability VariablePointers
30 %1 = OpExtInstImport "GLSL.std.450"
31 OpMemoryModel Logical GLSL450
32 OpEntryPoint Fragment %4 "main"
33 OpExecutionMode %4 OriginUpperLeft
34 OpSource ESSL 310
35 %2 = OpTypeVoid
36 %3 = OpTypeFunction %2
37 %6 = OpTypeInt 32 1
38 %7 = OpTypeFloat 32
39 %8 = OpTypeStruct %6 %7
40 %9 = OpTypePointer Function %8
41 %10 = OpTypeFunction %6 %9
42 %14 = OpConstant %6 0
43 %15 = OpTypePointer Function %6
44 %51 = OpTypePointer Private %6
45 %21 = OpConstant %6 2
46 %23 = OpConstant %6 1
47 %24 = OpConstant %7 1
48 %25 = OpTypePointer Function %7
49 %50 = OpTypePointer Private %7
50 %34 = OpTypeBool
51 %35 = OpConstantFalse %34
52 %60 = OpConstantNull %50
53 %52 = OpVariable %50 Private
54 %53 = OpVariable %51 Private
55 %4 = OpFunction %2 None %3
56 %5 = OpLabel
57 %20 = OpVariable %9 Function
58 %27 = OpVariable %9 Function ; irrelevant
59 %22 = OpAccessChain %15 %20 %14
60 %44 = OpCopyObject %9 %20
61 %26 = OpAccessChain %25 %20 %23
62 %29 = OpFunctionCall %6 %12 %27
63 %30 = OpAccessChain %15 %20 %14
64 %45 = OpCopyObject %15 %30
65 %33 = OpAccessChain %15 %20 %14
66 OpSelectionMerge %37 None
67 OpBranchConditional %35 %36 %37
68 %36 = OpLabel
69 %38 = OpAccessChain %15 %20 %14
70 %40 = OpAccessChain %15 %20 %14
71 %43 = OpAccessChain %15 %20 %14
72 OpBranch %37
73 %37 = OpLabel
74 OpReturn
75 OpFunctionEnd
76 %12 = OpFunction %6 None %10
77 %11 = OpFunctionParameter %9 ; irrelevant
78 %13 = OpLabel
79 %46 = OpCopyObject %9 %11 ; irrelevant
80 %16 = OpAccessChain %15 %11 %14 ; irrelevant
81 OpReturnValue %21
82 OpFunctionEnd
83 )";
84
85 const auto env = SPV_ENV_UNIVERSAL_1_4;
86 const auto consumer = nullptr;
87 const auto context = BuildModule(env, consumer, shader, kFuzzAssembleOption);
88 spvtools::ValidatorOptions validator_options;
89 validator_options.SetRelaxLogicalPointer(true);
90 ASSERT_TRUE(fuzzerutil::IsValidAndWellFormed(context.get(), validator_options,
91 kConsoleMessageConsumer));
92 TransformationContext transformation_context(
93 MakeUnique<FactManager>(context.get()), validator_options);
94 transformation_context.GetFactManager()->AddFactValueOfPointeeIsIrrelevant(
95 27);
96 transformation_context.GetFactManager()->AddFactValueOfPointeeIsIrrelevant(
97 11);
98 transformation_context.GetFactManager()->AddFactValueOfPointeeIsIrrelevant(
99 46);
100 transformation_context.GetFactManager()->AddFactValueOfPointeeIsIrrelevant(
101 16);
102 transformation_context.GetFactManager()->AddFactValueOfPointeeIsIrrelevant(
103 52);
104
105 transformation_context.GetFactManager()->AddFactBlockIsDead(36);
106
107 // Variables with pointee types:
108 // 52 - ptr_to(7)
109 // 53 - ptr_to(6)
110 // 20 - ptr_to(8)
111 // 27 - ptr_to(8) - irrelevant
112
113 // Access chains with pointee type:
114 // 22 - ptr_to(6)
115 // 26 - ptr_to(6)
116 // 30 - ptr_to(6)
117 // 33 - ptr_to(6)
118 // 38 - ptr_to(6)
119 // 40 - ptr_to(6)
120 // 43 - ptr_to(6)
121 // 16 - ptr_to(6) - irrelevant
122
123 // Copied object with pointee type:
124 // 44 - ptr_to(8)
125 // 45 - ptr_to(6)
126 // 46 - ptr_to(8) - irrelevant
127
128 // Function parameters with pointee type:
129 // 11 - ptr_to(8) - irrelevant
130
131 // Pointers that cannot be used:
132 // 60 - null
133
134 // Bad: id is not fresh
135 ASSERT_FALSE(TransformationLoad(
136 33, 33, false, 0, 0,
137 MakeInstructionDescriptor(38, spv::Op::OpAccessChain, 0))
138 .IsApplicable(context.get(), transformation_context));
139 // Bad: attempt to load from 11 from outside its function
140 ASSERT_FALSE(TransformationLoad(
141 100, 11, false, 0, 0,
142 MakeInstructionDescriptor(38, spv::Op::OpAccessChain, 0))
143 .IsApplicable(context.get(), transformation_context));
144
145 // Bad: pointer is not available
146 ASSERT_FALSE(TransformationLoad(
147 100, 33, false, 0, 0,
148 MakeInstructionDescriptor(45, spv::Op::OpCopyObject, 0))
149 .IsApplicable(context.get(), transformation_context));
150
151 // Bad: attempt to insert before OpVariable
152 ASSERT_FALSE(
153 TransformationLoad(100, 27, false, 0, 0,
154 MakeInstructionDescriptor(27, spv::Op::OpVariable, 0))
155 .IsApplicable(context.get(), transformation_context));
156
157 // Bad: pointer id does not exist
158 ASSERT_FALSE(TransformationLoad(
159 100, 1000, false, 0, 0,
160 MakeInstructionDescriptor(38, spv::Op::OpAccessChain, 0))
161 .IsApplicable(context.get(), transformation_context));
162
163 // Bad: pointer id exists but does not have a type
164 ASSERT_FALSE(TransformationLoad(
165 100, 5, false, 0, 0,
166 MakeInstructionDescriptor(38, spv::Op::OpAccessChain, 0))
167 .IsApplicable(context.get(), transformation_context));
168
169 // Bad: pointer id exists and has a type, but is not a pointer
170 ASSERT_FALSE(TransformationLoad(
171 100, 24, false, 0, 0,
172 MakeInstructionDescriptor(38, spv::Op::OpAccessChain, 0))
173 .IsApplicable(context.get(), transformation_context));
174
175 // Bad: attempt to load from null pointer
176 ASSERT_FALSE(TransformationLoad(
177 100, 60, false, 0, 0,
178 MakeInstructionDescriptor(38, spv::Op::OpAccessChain, 0))
179 .IsApplicable(context.get(), transformation_context));
180
181 // Bad: %40 is not available at the program point
182 ASSERT_FALSE(
183 TransformationLoad(100, 40, false, 0, 0,
184 MakeInstructionDescriptor(37, spv::Op::OpReturn, 0))
185 .IsApplicable(context.get(), transformation_context));
186
187 // Bad: The described instruction does not exist
188 ASSERT_FALSE(
189 TransformationLoad(100, 33, false, 0, 0,
190 MakeInstructionDescriptor(1000, spv::Op::OpReturn, 0))
191 .IsApplicable(context.get(), transformation_context));
192
193 {
194 TransformationLoad transformation(
195 100, 33, false, 0, 0,
196 MakeInstructionDescriptor(38, spv::Op::OpAccessChain, 0));
197 ASSERT_TRUE(
198 transformation.IsApplicable(context.get(), transformation_context));
199 ApplyAndCheckFreshIds(transformation, context.get(),
200 &transformation_context);
201 ASSERT_TRUE(fuzzerutil::IsValidAndWellFormed(
202 context.get(), validator_options, kConsoleMessageConsumer));
203 }
204
205 {
206 TransformationLoad transformation(
207 101, 46, false, 0, 0,
208 MakeInstructionDescriptor(16, spv::Op::OpReturnValue, 0));
209 ASSERT_TRUE(
210 transformation.IsApplicable(context.get(), transformation_context));
211 ApplyAndCheckFreshIds(transformation, context.get(),
212 &transformation_context);
213 ASSERT_TRUE(fuzzerutil::IsValidAndWellFormed(
214 context.get(), validator_options, kConsoleMessageConsumer));
215 }
216
217 {
218 TransformationLoad transformation(
219 102, 16, false, 0, 0,
220 MakeInstructionDescriptor(16, spv::Op::OpReturnValue, 0));
221 ASSERT_TRUE(
222 transformation.IsApplicable(context.get(), transformation_context));
223 ApplyAndCheckFreshIds(transformation, context.get(),
224 &transformation_context);
225 ASSERT_TRUE(fuzzerutil::IsValidAndWellFormed(
226 context.get(), validator_options, kConsoleMessageConsumer));
227 }
228
229 {
230 TransformationLoad transformation(
231 103, 40, false, 0, 0,
232 MakeInstructionDescriptor(43, spv::Op::OpAccessChain, 0));
233 ASSERT_TRUE(
234 transformation.IsApplicable(context.get(), transformation_context));
235 ApplyAndCheckFreshIds(transformation, context.get(),
236 &transformation_context);
237 ASSERT_TRUE(fuzzerutil::IsValidAndWellFormed(
238 context.get(), validator_options, kConsoleMessageConsumer));
239 }
240
241 std::string after_transformation = R"(
242 OpCapability Shader
243 OpCapability VariablePointers
244 %1 = OpExtInstImport "GLSL.std.450"
245 OpMemoryModel Logical GLSL450
246 OpEntryPoint Fragment %4 "main"
247 OpExecutionMode %4 OriginUpperLeft
248 OpSource ESSL 310
249 %2 = OpTypeVoid
250 %3 = OpTypeFunction %2
251 %6 = OpTypeInt 32 1
252 %7 = OpTypeFloat 32
253 %8 = OpTypeStruct %6 %7
254 %9 = OpTypePointer Function %8
255 %10 = OpTypeFunction %6 %9
256 %14 = OpConstant %6 0
257 %15 = OpTypePointer Function %6
258 %51 = OpTypePointer Private %6
259 %21 = OpConstant %6 2
260 %23 = OpConstant %6 1
261 %24 = OpConstant %7 1
262 %25 = OpTypePointer Function %7
263 %50 = OpTypePointer Private %7
264 %34 = OpTypeBool
265 %35 = OpConstantFalse %34
266 %60 = OpConstantNull %50
267 %52 = OpVariable %50 Private
268 %53 = OpVariable %51 Private
269 %4 = OpFunction %2 None %3
270 %5 = OpLabel
271 %20 = OpVariable %9 Function
272 %27 = OpVariable %9 Function ; irrelevant
273 %22 = OpAccessChain %15 %20 %14
274 %44 = OpCopyObject %9 %20
275 %26 = OpAccessChain %25 %20 %23
276 %29 = OpFunctionCall %6 %12 %27
277 %30 = OpAccessChain %15 %20 %14
278 %45 = OpCopyObject %15 %30
279 %33 = OpAccessChain %15 %20 %14
280 OpSelectionMerge %37 None
281 OpBranchConditional %35 %36 %37
282 %36 = OpLabel
283 %100 = OpLoad %6 %33
284 %38 = OpAccessChain %15 %20 %14
285 %40 = OpAccessChain %15 %20 %14
286 %103 = OpLoad %6 %40
287 %43 = OpAccessChain %15 %20 %14
288 OpBranch %37
289 %37 = OpLabel
290 OpReturn
291 OpFunctionEnd
292 %12 = OpFunction %6 None %10
293 %11 = OpFunctionParameter %9 ; irrelevant
294 %13 = OpLabel
295 %46 = OpCopyObject %9 %11 ; irrelevant
296 %16 = OpAccessChain %15 %11 %14 ; irrelevant
297 %101 = OpLoad %8 %46
298 %102 = OpLoad %6 %16
299 OpReturnValue %21
300 OpFunctionEnd
301 )";
302 ASSERT_TRUE(IsEqual(env, after_transformation, context.get()));
303 }
304
305 TEST(TransformationLoadTest, AtomicLoadTestCase) {
306 const std::string shader = R"(
307 OpCapability Shader
308 OpCapability Int8
309 %1 = OpExtInstImport "GLSL.std.450"
310 OpMemoryModel Logical GLSL450
311 OpEntryPoint Fragment %4 "main"
312 OpExecutionMode %4 OriginUpperLeft
313 OpSource ESSL 320
314 %2 = OpTypeVoid
315 %3 = OpTypeFunction %2
316 %6 = OpTypeInt 32 1
317 %7 = OpTypeInt 8 1
318 %9 = OpTypeInt 32 0
319 %26 = OpTypeFloat 32
320 %8 = OpTypeStruct %6
321 %10 = OpTypePointer StorageBuffer %8
322 %11 = OpVariable %10 StorageBuffer
323 %19 = OpConstant %26 0
324 %18 = OpConstant %9 1
325 %12 = OpConstant %6 0
326 %13 = OpTypePointer StorageBuffer %6
327 %15 = OpConstant %6 4
328 %16 = OpConstant %6 7
329 %17 = OpConstant %7 4
330 %20 = OpConstant %9 64
331 %4 = OpFunction %2 None %3
332 %5 = OpLabel
333 %14 = OpAccessChain %13 %11 %12
334 %24 = OpAccessChain %13 %11 %12
335 OpReturn
336 OpFunctionEnd
337 )";
338
339 const auto env = SPV_ENV_UNIVERSAL_1_3;
340 const auto consumer = nullptr;
341 const auto context = BuildModule(env, consumer, shader, kFuzzAssembleOption);
342 spvtools::ValidatorOptions validator_options;
343 ASSERT_TRUE(fuzzerutil::IsValidAndWellFormed(context.get(), validator_options,
344 kConsoleMessageConsumer));
345 TransformationContext transformation_context(
346 MakeUnique<FactManager>(context.get()), validator_options);
347
348 // Bad: id is not fresh.
349 ASSERT_FALSE(TransformationLoad(
350 14, 14, true, 15, 20,
351 MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
352 .IsApplicable(context.get(), transformation_context));
353
354 // Bad: id 100 of memory scope instruction does not exist.
355 ASSERT_FALSE(TransformationLoad(
356 21, 14, true, 100, 20,
357 MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
358 .IsApplicable(context.get(), transformation_context));
359 // Bad: id 100 of memory semantics instruction does not exist.
360 ASSERT_FALSE(TransformationLoad(
361 21, 14, true, 15, 100,
362 MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
363 .IsApplicable(context.get(), transformation_context));
364 // Bad: memory scope should be |OpConstant| opcode.
365 ASSERT_FALSE(TransformationLoad(
366 21, 14, true, 5, 20,
367 MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
368 .IsApplicable(context.get(), transformation_context));
369 // Bad: memory semantics should be |OpConstant| opcode.
370 ASSERT_FALSE(TransformationLoad(
371 21, 14, true, 15, 5,
372 MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
373 .IsApplicable(context.get(), transformation_context));
374
375 // Bad: The memory scope instruction must have an Integer operand.
376 ASSERT_FALSE(TransformationLoad(
377 21, 14, true, 15, 19,
378 MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
379 .IsApplicable(context.get(), transformation_context));
380 // Bad: The memory memory semantics instruction must have an Integer operand.
381 ASSERT_FALSE(TransformationLoad(
382 21, 14, true, 19, 20,
383 MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
384 .IsApplicable(context.get(), transformation_context));
385
386 // Bad: Integer size of the memory scope must be equal to 32 bits.
387 ASSERT_FALSE(TransformationLoad(
388 21, 14, true, 17, 20,
389 MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
390 .IsApplicable(context.get(), transformation_context));
391
392 // Bad: Integer size of memory semantics must be equal to 32 bits.
393 ASSERT_FALSE(TransformationLoad(
394 21, 14, true, 15, 17,
395 MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
396 .IsApplicable(context.get(), transformation_context));
397
398 // Bad: memory scope value must be 4 (spv::Scope::Invocation).
399 ASSERT_FALSE(TransformationLoad(
400 21, 14, true, 16, 20,
401 MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
402 .IsApplicable(context.get(), transformation_context));
403
404 // Bad: memory semantics value must be either:
405 // 64 (SpvMemorySemanticsUniformMemoryMask)
406 // 256 (SpvMemorySemanticsWorkgroupMemoryMask)
407 ASSERT_FALSE(TransformationLoad(
408 21, 14, true, 15, 16,
409 MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
410 .IsApplicable(context.get(), transformation_context));
411
412 // Bad: The described instruction does not exist
413 ASSERT_FALSE(TransformationLoad(
414 21, 14, false, 15, 20,
415 MakeInstructionDescriptor(150, spv::Op::OpAccessChain, 0))
416 .IsApplicable(context.get(), transformation_context));
417
418 // Successful transformations.
419 {
420 TransformationLoad transformation(
421 21, 14, true, 15, 20,
422 MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0));
423 ASSERT_TRUE(
424 transformation.IsApplicable(context.get(), transformation_context));
425 ApplyAndCheckFreshIds(transformation, context.get(),
426 &transformation_context);
427 ASSERT_TRUE(fuzzerutil::IsValidAndWellFormed(
428 context.get(), validator_options, kConsoleMessageConsumer));
429 }
430
431 const std::string after_transformation = R"(
432 OpCapability Shader
433 OpCapability Int8
434 %1 = OpExtInstImport "GLSL.std.450"
435 OpMemoryModel Logical GLSL450
436 OpEntryPoint Fragment %4 "main"
437 OpExecutionMode %4 OriginUpperLeft
438 OpSource ESSL 320
439 %2 = OpTypeVoid
440 %3 = OpTypeFunction %2
441 %6 = OpTypeInt 32 1
442 %7 = OpTypeInt 8 1
443 %9 = OpTypeInt 32 0
444 %26 = OpTypeFloat 32
445 %8 = OpTypeStruct %6
446 %10 = OpTypePointer StorageBuffer %8
447 %11 = OpVariable %10 StorageBuffer
448 %19 = OpConstant %26 0
449 %18 = OpConstant %9 1
450 %12 = OpConstant %6 0
451 %13 = OpTypePointer StorageBuffer %6
452 %15 = OpConstant %6 4
453 %16 = OpConstant %6 7
454 %17 = OpConstant %7 4
455 %20 = OpConstant %9 64
456 %4 = OpFunction %2 None %3
457 %5 = OpLabel
458 %14 = OpAccessChain %13 %11 %12
459 %21 = OpAtomicLoad %6 %14 %15 %20
460 %24 = OpAccessChain %13 %11 %12
461 OpReturn
462 OpFunctionEnd
463 )";
464
465 ASSERT_TRUE(IsEqual(env, after_transformation, context.get()));
466 }
467
468 TEST(TransformationLoadTest, AtomicLoadTestCaseForWorkgroupMemory) {
469 std::string shader = R"(
470 OpCapability Shader
471 OpCapability Int8
472 %1 = OpExtInstImport "GLSL.std.450"
473 OpMemoryModel Logical GLSL450
474 OpEntryPoint Fragment %4 "main"
475 OpExecutionMode %4 OriginUpperLeft
476 OpSource ESSL 310
477 %2 = OpTypeVoid
478 %3 = OpTypeFunction %2
479 %6 = OpTypeInt 32 1
480 %26 = OpTypeFloat 32
481 %27 = OpTypeInt 8 1
482 %7 = OpTypeInt 32 0 ; 0 means unsigned
483 %8 = OpConstant %7 0
484 %17 = OpConstant %27 4
485 %19 = OpConstant %26 0
486 %9 = OpTypePointer Function %6
487 %13 = OpTypeStruct %6
488 %12 = OpTypePointer Workgroup %13
489 %11 = OpVariable %12 Workgroup
490 %14 = OpConstant %6 0
491 %15 = OpTypePointer Function %6
492 %51 = OpTypePointer Private %6
493 %21 = OpConstant %6 4
494 %23 = OpConstant %6 256
495 %25 = OpTypePointer Function %7
496 %50 = OpTypePointer Workgroup %6
497 %34 = OpTypeBool
498 %35 = OpConstantFalse %34
499 %53 = OpVariable %51 Private
500 %4 = OpFunction %2 None %3
501 %5 = OpLabel
502 OpSelectionMerge %37 None
503 OpBranchConditional %35 %36 %37
504 %36 = OpLabel
505 %38 = OpAccessChain %50 %11 %14
506 %40 = OpAccessChain %50 %11 %14
507 OpBranch %37
508 %37 = OpLabel
509 OpReturn
510 OpFunctionEnd
511 )";
512
513 const auto env = SPV_ENV_UNIVERSAL_1_3;
514 const auto consumer = nullptr;
515 const auto context = BuildModule(env, consumer, shader, kFuzzAssembleOption);
516 spvtools::ValidatorOptions validator_options;
517 ASSERT_TRUE(fuzzerutil::IsValidAndWellFormed(context.get(), validator_options,
518 kConsoleMessageConsumer));
519 TransformationContext transformation_context(
520 MakeUnique<FactManager>(context.get()), validator_options);
521
522 // Bad: Can't insert OpAccessChain before the id 23 of memory scope.
523 ASSERT_FALSE(TransformationLoad(
524 60, 38, true, 21, 23,
525 MakeInstructionDescriptor(23, spv::Op::OpAccessChain, 0))
526 .IsApplicable(context.get(), transformation_context));
527
528 // Bad: Can't insert OpAccessChain before the id 23 of memory semantics.
529 ASSERT_FALSE(TransformationLoad(
530 60, 38, true, 21, 23,
531 MakeInstructionDescriptor(21, spv::Op::OpAccessChain, 0))
532 .IsApplicable(context.get(), transformation_context));
533
534 // Successful transformations.
535 {
536 TransformationLoad transformation(
537 60, 38, true, 21, 23,
538 MakeInstructionDescriptor(40, spv::Op::OpAccessChain, 0));
539 ASSERT_TRUE(
540 transformation.IsApplicable(context.get(), transformation_context));
541 ApplyAndCheckFreshIds(transformation, context.get(),
542 &transformation_context);
543 ASSERT_TRUE(fuzzerutil::IsValidAndWellFormed(
544 context.get(), validator_options, kConsoleMessageConsumer));
545 }
546
547 std::string after_transformation = R"(
548 OpCapability Shader
549 OpCapability Int8
550 %1 = OpExtInstImport "GLSL.std.450"
551 OpMemoryModel Logical GLSL450
552 OpEntryPoint Fragment %4 "main"
553 OpExecutionMode %4 OriginUpperLeft
554 OpSource ESSL 310
555 %2 = OpTypeVoid
556 %3 = OpTypeFunction %2
557 %6 = OpTypeInt 32 1
558 %26 = OpTypeFloat 32
559 %27 = OpTypeInt 8 1
560 %7 = OpTypeInt 32 0 ; 0 means unsigned
561 %8 = OpConstant %7 0
562 %17 = OpConstant %27 4
563 %19 = OpConstant %26 0
564 %9 = OpTypePointer Function %6
565 %13 = OpTypeStruct %6
566 %12 = OpTypePointer Workgroup %13
567 %11 = OpVariable %12 Workgroup
568 %14 = OpConstant %6 0
569 %15 = OpTypePointer Function %6
570 %51 = OpTypePointer Private %6
571 %21 = OpConstant %6 4
572 %23 = OpConstant %6 256
573 %25 = OpTypePointer Function %7
574 %50 = OpTypePointer Workgroup %6
575 %34 = OpTypeBool
576 %35 = OpConstantFalse %34
577 %53 = OpVariable %51 Private
578 %4 = OpFunction %2 None %3
579 %5 = OpLabel
580 OpSelectionMerge %37 None
581 OpBranchConditional %35 %36 %37
582 %36 = OpLabel
583 %38 = OpAccessChain %50 %11 %14
584 %60 = OpAtomicLoad %6 %38 %21 %23
585 %40 = OpAccessChain %50 %11 %14
586 OpBranch %37
587 %37 = OpLabel
588 OpReturn
589 OpFunctionEnd
590 )";
591
592 ASSERT_TRUE(IsEqual(env, after_transformation, context.get()));
593 }
594
595 } // namespace
596 } // namespace fuzz
597 } // namespace spvtools