1 // GENERATED FILE - DO NOT EDIT. 2 // Generated by generate_tests.py 3 // 4 // Copyright (c) 2022 Google LLC. 5 // 6 // Licensed under the Apache License, Version 2.0 (the "License"); 7 // you may not use this file except in compliance with the License. 8 // You may obtain a copy of the License at 9 // 10 // http://www.apache.org/licenses/LICENSE-2.0 11 // 12 // Unless required by applicable law or agreed to in writing, software 13 // distributed under the License is distributed on an "AS IS" BASIS, 14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 // See the License for the specific language governing permissions and 16 // limitations under the License. 17 18 #include "../diff_test_utils.h" 19 20 #include "gtest/gtest.h" 21 22 namespace spvtools { 23 namespace diff { 24 namespace { 25 26 // Test where src and dst have a function with different parameter count. 27 constexpr char kSrc[] = R"(; SPIR-V 28 ; Version: 1.0 29 ; Generator: Khronos Glslang Reference Front End; 10 30 ; Bound: 25 31 ; Schema: 0 32 OpCapability Shader 33 %1 = OpExtInstImport "GLSL.std.450" 34 OpMemoryModel Logical GLSL450 35 OpEntryPoint Fragment %4 "main" %20 36 OpExecutionMode %4 OriginUpperLeft 37 OpSource ESSL 320 38 OpName %4 "main" 39 OpName %11 "f(vf2;" 40 OpName %10 "v" 41 OpName %20 "o" 42 OpName %23 "param" 43 OpDecorate %20 RelaxedPrecision 44 OpDecorate %20 Location 0 45 %2 = OpTypeVoid 46 %3 = OpTypeFunction %2 47 %6 = OpTypeFloat 32 48 %7 = OpTypeVector %6 2 49 %8 = OpTypePointer Function %7 50 %9 = OpTypeFunction %7 %8 51 %14 = OpConstant %6 0.5 52 %15 = OpConstantComposite %7 %14 %14 53 %19 = OpTypePointer Output %7 54 %20 = OpVariable %19 Output 55 %21 = OpConstant %6 0 56 %22 = OpConstantComposite %7 %21 %21 57 %4 = OpFunction %2 None %3 58 %5 = OpLabel 59 %23 = OpVariable %8 Function 60 OpStore %23 %22 61 %24 = OpFunctionCall %7 %11 %23 62 OpStore %20 %24 63 OpReturn 64 OpFunctionEnd 65 %11 = OpFunction %7 None %9 66 %10 = OpFunctionParameter %8 67 %12 = OpLabel 68 %13 = OpLoad %7 %10 69 %16 = OpFAdd %7 %13 %15 70 OpReturnValue %16 71 OpFunctionEnd)"; 72 constexpr char kDst[] = R"(; SPIR-V 73 ; Version: 1.0 74 ; Generator: Khronos Glslang Reference Front End; 10 75 ; Bound: 28 76 ; Schema: 0 77 OpCapability Shader 78 %1 = OpExtInstImport "GLSL.std.450" 79 OpMemoryModel Logical GLSL450 80 OpEntryPoint Fragment %4 "main" %20 81 OpExecutionMode %4 OriginUpperLeft 82 OpSource ESSL 320 83 OpName %4 "main" 84 OpName %12 "f(vf2;vf2;" 85 OpName %10 "v" 86 OpName %11 "v2" 87 OpName %20 "o" 88 OpName %25 "param" 89 OpName %26 "param" 90 OpDecorate %20 RelaxedPrecision 91 OpDecorate %20 Location 0 92 %2 = OpTypeVoid 93 %3 = OpTypeFunction %2 94 %6 = OpTypeFloat 32 95 %7 = OpTypeVector %6 2 96 %8 = OpTypePointer Function %7 97 %9 = OpTypeFunction %7 %8 %8 98 %19 = OpTypePointer Output %7 99 %20 = OpVariable %19 Output 100 %21 = OpConstant %6 0 101 %22 = OpConstantComposite %7 %21 %21 102 %23 = OpConstant %6 0.5 103 %24 = OpConstantComposite %7 %23 %23 104 %4 = OpFunction %2 None %3 105 %5 = OpLabel 106 %25 = OpVariable %8 Function 107 %26 = OpVariable %8 Function 108 OpStore %25 %22 109 OpStore %26 %24 110 %27 = OpFunctionCall %7 %12 %25 %26 111 OpStore %20 %27 112 OpReturn 113 OpFunctionEnd 114 %12 = OpFunction %7 None %9 115 %10 = OpFunctionParameter %8 116 %11 = OpFunctionParameter %8 117 %13 = OpLabel 118 %14 = OpLoad %7 %10 119 %15 = OpLoad %7 %11 120 %16 = OpFAdd %7 %14 %15 121 OpReturnValue %16 122 OpFunctionEnd 123 124 )"; 125 126 TEST(DiffTest, DifferentFunctionParameterCount) { 127 constexpr char kDiff[] = R"( ; SPIR-V 128 ; Version: 1.6 129 ; Generator: Khronos SPIR-V Tools Assembler; 0 130 -; Bound: 25 131 +; Bound: 31 132 ; Schema: 0 133 OpCapability Shader 134 %1 = OpExtInstImport "GLSL.std.450" 135 OpMemoryModel Logical GLSL450 136 OpEntryPoint Fragment %4 "main" %20 137 OpExecutionMode %4 OriginUpperLeft 138 OpSource ESSL 320 139 OpName %4 "main" 140 -OpName %11 "f(vf2;" 141 +OpName %11 "f(vf2;vf2;" 142 OpName %10 "v" 143 +OpName %26 "v2" 144 OpName %20 "o" 145 OpName %23 "param" 146 +OpName %29 "param" 147 OpDecorate %20 RelaxedPrecision 148 OpDecorate %20 Location 0 149 %2 = OpTypeVoid 150 %3 = OpTypeFunction %2 151 %6 = OpTypeFloat 32 152 %7 = OpTypeVector %6 2 153 %8 = OpTypePointer Function %7 154 -%9 = OpTypeFunction %7 %8 155 +%25 = OpTypeFunction %7 %8 %8 156 %14 = OpConstant %6 0.5 157 %15 = OpConstantComposite %7 %14 %14 158 %19 = OpTypePointer Output %7 159 %20 = OpVariable %19 Output 160 %21 = OpConstant %6 0 161 %22 = OpConstantComposite %7 %21 %21 162 %4 = OpFunction %2 None %3 163 %5 = OpLabel 164 %23 = OpVariable %8 Function 165 +%29 = OpVariable %8 Function 166 OpStore %23 %22 167 -%24 = OpFunctionCall %7 %11 %23 168 +OpStore %29 %15 169 +%30 = OpFunctionCall %7 %11 %23 %29 170 -OpStore %20 %24 171 +OpStore %20 %30 172 OpReturn 173 OpFunctionEnd 174 -%11 = OpFunction %7 None %9 175 +%11 = OpFunction %7 None %25 176 %10 = OpFunctionParameter %8 177 +%26 = OpFunctionParameter %8 178 %12 = OpLabel 179 %13 = OpLoad %7 %10 180 -%16 = OpFAdd %7 %13 %15 181 +%27 = OpLoad %7 %26 182 +%28 = OpFAdd %7 %13 %27 183 -OpReturnValue %16 184 +OpReturnValue %28 185 OpFunctionEnd 186 )"; 187 Options options; 188 DoStringDiffTest(kSrc, kDst, kDiff, options); 189 } 190 191 TEST(DiffTest, DifferentFunctionParameterCountNoDebug) { 192 constexpr char kSrcNoDebug[] = R"(; SPIR-V 193 ; Version: 1.0 194 ; Generator: Khronos Glslang Reference Front End; 10 195 ; Bound: 25 196 ; Schema: 0 197 OpCapability Shader 198 %1 = OpExtInstImport "GLSL.std.450" 199 OpMemoryModel Logical GLSL450 200 OpEntryPoint Fragment %4 "main" %20 201 OpExecutionMode %4 OriginUpperLeft 202 OpSource ESSL 320 203 OpDecorate %20 RelaxedPrecision 204 OpDecorate %20 Location 0 205 %2 = OpTypeVoid 206 %3 = OpTypeFunction %2 207 %6 = OpTypeFloat 32 208 %7 = OpTypeVector %6 2 209 %8 = OpTypePointer Function %7 210 %9 = OpTypeFunction %7 %8 211 %14 = OpConstant %6 0.5 212 %15 = OpConstantComposite %7 %14 %14 213 %19 = OpTypePointer Output %7 214 %20 = OpVariable %19 Output 215 %21 = OpConstant %6 0 216 %22 = OpConstantComposite %7 %21 %21 217 %4 = OpFunction %2 None %3 218 %5 = OpLabel 219 %23 = OpVariable %8 Function 220 OpStore %23 %22 221 %24 = OpFunctionCall %7 %11 %23 222 OpStore %20 %24 223 OpReturn 224 OpFunctionEnd 225 %11 = OpFunction %7 None %9 226 %10 = OpFunctionParameter %8 227 %12 = OpLabel 228 %13 = OpLoad %7 %10 229 %16 = OpFAdd %7 %13 %15 230 OpReturnValue %16 231 OpFunctionEnd 232 )"; 233 constexpr char kDstNoDebug[] = R"(; SPIR-V 234 ; Version: 1.0 235 ; Generator: Khronos Glslang Reference Front End; 10 236 ; Bound: 28 237 ; Schema: 0 238 OpCapability Shader 239 %1 = OpExtInstImport "GLSL.std.450" 240 OpMemoryModel Logical GLSL450 241 OpEntryPoint Fragment %4 "main" %20 242 OpExecutionMode %4 OriginUpperLeft 243 OpSource ESSL 320 244 OpDecorate %20 RelaxedPrecision 245 OpDecorate %20 Location 0 246 %2 = OpTypeVoid 247 %3 = OpTypeFunction %2 248 %6 = OpTypeFloat 32 249 %7 = OpTypeVector %6 2 250 %8 = OpTypePointer Function %7 251 %9 = OpTypeFunction %7 %8 %8 252 %19 = OpTypePointer Output %7 253 %20 = OpVariable %19 Output 254 %21 = OpConstant %6 0 255 %22 = OpConstantComposite %7 %21 %21 256 %23 = OpConstant %6 0.5 257 %24 = OpConstantComposite %7 %23 %23 258 %4 = OpFunction %2 None %3 259 %5 = OpLabel 260 %25 = OpVariable %8 Function 261 %26 = OpVariable %8 Function 262 OpStore %25 %22 263 OpStore %26 %24 264 %27 = OpFunctionCall %7 %12 %25 %26 265 OpStore %20 %27 266 OpReturn 267 OpFunctionEnd 268 %12 = OpFunction %7 None %9 269 %10 = OpFunctionParameter %8 270 %11 = OpFunctionParameter %8 271 %13 = OpLabel 272 %14 = OpLoad %7 %10 273 %15 = OpLoad %7 %11 274 %16 = OpFAdd %7 %14 %15 275 OpReturnValue %16 276 OpFunctionEnd 277 278 )"; 279 constexpr char kDiff[] = R"( ; SPIR-V 280 ; Version: 1.6 281 ; Generator: Khronos SPIR-V Tools Assembler; 0 282 -; Bound: 25 283 +; Bound: 31 284 ; Schema: 0 285 OpCapability Shader 286 %1 = OpExtInstImport "GLSL.std.450" 287 OpMemoryModel Logical GLSL450 288 OpEntryPoint Fragment %4 "main" %20 289 OpExecutionMode %4 OriginUpperLeft 290 OpSource ESSL 320 291 OpDecorate %20 RelaxedPrecision 292 OpDecorate %20 Location 0 293 %2 = OpTypeVoid 294 %3 = OpTypeFunction %2 295 %6 = OpTypeFloat 32 296 %7 = OpTypeVector %6 2 297 %8 = OpTypePointer Function %7 298 -%9 = OpTypeFunction %7 %8 299 +%25 = OpTypeFunction %7 %8 %8 300 %14 = OpConstant %6 0.5 301 %15 = OpConstantComposite %7 %14 %14 302 %19 = OpTypePointer Output %7 303 %20 = OpVariable %19 Output 304 %21 = OpConstant %6 0 305 %22 = OpConstantComposite %7 %21 %21 306 %4 = OpFunction %2 None %3 307 %5 = OpLabel 308 %23 = OpVariable %8 Function 309 +%29 = OpVariable %8 Function 310 OpStore %23 %22 311 -%24 = OpFunctionCall %7 %11 %23 312 +OpStore %29 %15 313 +%30 = OpFunctionCall %7 %11 %23 %29 314 -OpStore %20 %24 315 +OpStore %20 %30 316 OpReturn 317 OpFunctionEnd 318 -%11 = OpFunction %7 None %9 319 +%11 = OpFunction %7 None %25 320 %10 = OpFunctionParameter %8 321 +%26 = OpFunctionParameter %8 322 %12 = OpLabel 323 %13 = OpLoad %7 %10 324 -%16 = OpFAdd %7 %13 %15 325 +%27 = OpLoad %7 %26 326 +%28 = OpFAdd %7 %13 %27 327 -OpReturnValue %16 328 +OpReturnValue %28 329 OpFunctionEnd 330 )"; 331 Options options; 332 DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); 333 } 334 335 } // namespace 336 } // namespace diff 337 } // namespace spvtools 338