@@ -2584,6 +2584,82 @@ TEST_F(TrimCapabilitiesPassTest, UInt16_RemainsWhenUsed) {
2584
2584
EXPECT_EQ (std::get<1 >(result), Pass::Status::SuccessWithoutChange);
2585
2585
}
2586
2586
2587
+ TEST_F (TrimCapabilitiesPassTest,
2588
+ VulkanMemoryModelDeviceScope_RemovedWhenUnused) {
2589
+ const std::string kTest = R"(
2590
+ OpCapability VulkanMemoryModelDeviceScope
2591
+ ; CHECK-NOT: OpCapability VulkanMemoryModelDeviceScope
2592
+ OpCapability Shader
2593
+ OpMemoryModel Logical GLSL450
2594
+ OpEntryPoint GLCompute %1 "main"
2595
+ %void = OpTypeVoid
2596
+ %3 = OpTypeFunction %void
2597
+ %1 = OpFunction %void None %3
2598
+ %6 = OpLabel
2599
+ OpReturn
2600
+ OpFunctionEnd;
2601
+ )" ;
2602
+ const auto result =
2603
+ SinglePassRunAndMatch<TrimCapabilitiesPass>(kTest , /* skip_nop= */ false );
2604
+ EXPECT_EQ (std::get<1 >(result), Pass::Status::SuccessWithChange);
2605
+ }
2606
+
2607
+ TEST_F (TrimCapabilitiesPassTest,
2608
+ VulkanMemoryModelDeviceScope_RemovedWhenUsedWithGLSL450) {
2609
+ const std::string kTest = R"(
2610
+ OpCapability VulkanMemoryModelDeviceScope
2611
+ ; CHECK-NOT: OpCapability VulkanMemoryModelDeviceScope
2612
+ OpCapability Shader
2613
+ OpCapability ShaderClockKHR
2614
+ OpCapability Int64
2615
+ OpExtension "SPV_KHR_shader_clock"
2616
+ OpMemoryModel Logical GLSL450
2617
+ OpEntryPoint GLCompute %main "main"
2618
+ OpExecutionMode %main LocalSize 1 2 4
2619
+ %void = OpTypeVoid
2620
+ %uint = OpTypeInt 32 0
2621
+ %ulong = OpTypeInt 64 0
2622
+ %uint_1 = OpConstant %uint 1
2623
+ %3 = OpTypeFunction %void
2624
+ %main = OpFunction %void None %3
2625
+ %6 = OpLabel
2626
+ %22 = OpReadClockKHR %ulong %uint_1 ; Device Scope
2627
+ OpReturn
2628
+ OpFunctionEnd
2629
+ )" ;
2630
+ const auto result =
2631
+ SinglePassRunAndMatch<TrimCapabilitiesPass>(kTest , /* skip_nop= */ false );
2632
+ EXPECT_EQ (std::get<1 >(result), Pass::Status::SuccessWithChange);
2633
+ }
2634
+
2635
+ TEST_F (TrimCapabilitiesPassTest,
2636
+ VulkanMemoryModelDeviceScope_RemainsWhenUsedWithVulkan) {
2637
+ const std::string kTest = R"(
2638
+ OpCapability VulkanMemoryModelDeviceScope
2639
+ ; CHECK: OpCapability VulkanMemoryModelDeviceScope
2640
+ OpCapability Shader
2641
+ OpCapability ShaderClockKHR
2642
+ OpCapability Int64
2643
+ OpExtension "SPV_KHR_shader_clock"
2644
+ OpMemoryModel Logical Vulkan
2645
+ OpEntryPoint GLCompute %main "main"
2646
+ OpExecutionMode %main LocalSize 1 2 4
2647
+ %void = OpTypeVoid
2648
+ %uint = OpTypeInt 32 0
2649
+ %ulong = OpTypeInt 64 0
2650
+ %uint_1 = OpConstant %uint 1
2651
+ %3 = OpTypeFunction %void
2652
+ %main = OpFunction %void None %3
2653
+ %6 = OpLabel
2654
+ %22 = OpReadClockKHR %ulong %uint_1 ; Device Scope
2655
+ OpReturn
2656
+ OpFunctionEnd
2657
+ )" ;
2658
+ const auto result =
2659
+ SinglePassRunAndMatch<TrimCapabilitiesPass>(kTest , /* skip_nop= */ false );
2660
+ EXPECT_EQ (std::get<1 >(result), Pass::Status::SuccessWithoutChange);
2661
+ }
2662
+
2587
2663
} // namespace
2588
2664
} // namespace opt
2589
2665
} // namespace spvtools
0 commit comments