mirror of
				https://github.com/encounter/dawn-cmake.git
				synced 2025-10-25 19:20:30 +00:00 
			
		
		
		
	Prevents UB for divide-by-zero and integer overflow when dividing Fixed: tint:1349 Change-Id: Ieef66d27d7aec3011628ced076b2bccc7770a8af Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108925 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com>
		
			
				
	
	
		
			73 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			73 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| ; SPIR-V
 | |
| ; Version: 1.3
 | |
| ; Generator: Google Tint Compiler; 0
 | |
| ; Bound: 47
 | |
| ; Schema: 0
 | |
|                OpCapability Shader
 | |
|                OpMemoryModel Logical GLSL450
 | |
|                OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
 | |
|                OpExecutionMode %unused_entry_point LocalSize 1 1 1
 | |
|                OpName %unused_entry_point "unused_entry_point"
 | |
|                OpName %tint_div "tint_div"
 | |
|                OpName %lhs "lhs"
 | |
|                OpName %rhs "rhs"
 | |
|                OpName %foo "foo"
 | |
|                OpName %a "a"
 | |
|                OpName %b "b"
 | |
|                OpName %c "c"
 | |
|        %void = OpTypeVoid
 | |
|           %1 = OpTypeFunction %void
 | |
|         %int = OpTypeInt 32 1
 | |
|           %5 = OpTypeFunction %int %int %int
 | |
|          %12 = OpConstantNull %int
 | |
|        %bool = OpTypeBool
 | |
| %int_n2147483648 = OpConstant %int -2147483648
 | |
|      %int_n1 = OpConstant %int -1
 | |
|       %int_1 = OpConstant %int 1
 | |
| %_ptr_Function_int = OpTypePointer Function %int
 | |
|       %float = OpTypeFloat 32
 | |
|     %v4float = OpTypeVector %float 4
 | |
| %_ptr_Function_v4float = OpTypePointer Function %v4float
 | |
|          %31 = OpConstantNull %v4float
 | |
|     %v2float = OpTypeVector %float 2
 | |
| %mat2v2float = OpTypeMatrix %v2float 2
 | |
| %_ptr_Function_mat2v2float = OpTypePointer Function %mat2v2float
 | |
|          %36 = OpConstantNull %mat2v2float
 | |
|       %int_2 = OpConstant %int 2
 | |
| %mat4v4float = OpTypeMatrix %v4float 4
 | |
|          %42 = OpConstantNull %mat4v4float
 | |
|     %float_2 = OpConstant %float 2
 | |
| %unused_entry_point = OpFunction %void None %1
 | |
|           %4 = OpLabel
 | |
|                OpReturn
 | |
|                OpFunctionEnd
 | |
|    %tint_div = OpFunction %int None %5
 | |
|         %lhs = OpFunctionParameter %int
 | |
|         %rhs = OpFunctionParameter %int
 | |
|          %10 = OpLabel
 | |
|          %13 = OpIEqual %bool %rhs %12
 | |
|          %16 = OpIEqual %bool %lhs %int_n2147483648
 | |
|          %18 = OpIEqual %bool %rhs %int_n1
 | |
|          %19 = OpLogicalAnd %bool %16 %18
 | |
|          %20 = OpLogicalOr %bool %13 %19
 | |
|          %11 = OpSelect %int %20 %int_1 %rhs
 | |
|          %22 = OpSDiv %int %lhs %11
 | |
|                OpReturnValue %22
 | |
|                OpFunctionEnd
 | |
|         %foo = OpFunction %void None %1
 | |
|          %24 = OpLabel
 | |
|           %a = OpVariable %_ptr_Function_int Function %12
 | |
|           %b = OpVariable %_ptr_Function_v4float Function %31
 | |
|           %c = OpVariable %_ptr_Function_mat2v2float Function %36
 | |
|          %38 = OpLoad %int %a
 | |
|          %37 = OpFunctionCall %int %tint_div %38 %int_2
 | |
|                OpStore %a %37
 | |
|          %40 = OpLoad %v4float %b
 | |
|          %43 = OpVectorTimesMatrix %v4float %40 %42
 | |
|                OpStore %b %43
 | |
|          %44 = OpLoad %mat2v2float %c
 | |
|          %46 = OpMatrixTimesScalar %mat2v2float %44 %float_2
 | |
|                OpStore %c %46
 | |
|                OpReturn
 | |
|                OpFunctionEnd
 |