mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 13:38:00 +00:00
Fixes for bugs around unreachable code
Remove the ICE check for expression behaviors always being either `{Next}` or `{Next, Discard}`. Unreachable code may be result in something else.
Add the RemoveUnreachableStatements transform to the SPIR-V writer sanitizer transform list. The writer cannot correctly handle unreachable statements.
Bug: tint:1369
Bug: chromium:1285622
Change-Id: I9fa54c6d2096b1ee633dd551b628c7dd3ba64fb5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76300
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Tint LUCI CQ
parent
d6e962b437
commit
51e37c6f91
10
test/bug/tint/1369.wgsl
Normal file
10
test/bug/tint/1369.wgsl
Normal file
@@ -0,0 +1,10 @@
|
||||
fn call_discard() -> bool {
|
||||
discard;
|
||||
return true;
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn f() {
|
||||
var v = call_discard();
|
||||
var also_unreachable : bool;
|
||||
}
|
||||
22
test/bug/tint/1369.wgsl.expected.hlsl
Normal file
22
test/bug/tint/1369.wgsl.expected.hlsl
Normal file
@@ -0,0 +1,22 @@
|
||||
bug/tint/1369.wgsl:3:3 warning: code is unreachable
|
||||
return true;
|
||||
^^^^^^
|
||||
|
||||
bug/tint/1369.wgsl:9:9 warning: code is unreachable
|
||||
var also_unreachable : bool;
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
bool call_discard() {
|
||||
if (true) {
|
||||
discard;
|
||||
return true;
|
||||
}
|
||||
bool unused;
|
||||
return unused;
|
||||
}
|
||||
|
||||
void f() {
|
||||
bool v = call_discard();
|
||||
bool also_unreachable = false;
|
||||
return;
|
||||
}
|
||||
22
test/bug/tint/1369.wgsl.expected.msl
Normal file
22
test/bug/tint/1369.wgsl.expected.msl
Normal file
@@ -0,0 +1,22 @@
|
||||
bug/tint/1369.wgsl:3:3 warning: code is unreachable
|
||||
return true;
|
||||
^^^^^^
|
||||
|
||||
bug/tint/1369.wgsl:9:9 warning: code is unreachable
|
||||
var also_unreachable : bool;
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
bool call_discard() {
|
||||
discard_fragment();
|
||||
return true;
|
||||
}
|
||||
|
||||
fragment void f() {
|
||||
bool v = call_discard();
|
||||
bool also_unreachable = false;
|
||||
return;
|
||||
}
|
||||
|
||||
37
test/bug/tint/1369.wgsl.expected.spvasm
Normal file
37
test/bug/tint/1369.wgsl.expected.spvasm
Normal file
@@ -0,0 +1,37 @@
|
||||
bug/tint/1369.wgsl:3:3 warning: code is unreachable
|
||||
return true;
|
||||
^^^^^^
|
||||
|
||||
bug/tint/1369.wgsl:9:9 warning: code is unreachable
|
||||
var also_unreachable : bool;
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 13
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Fragment %f "f"
|
||||
OpExecutionMode %f OriginUpperLeft
|
||||
OpName %call_discard "call_discard"
|
||||
OpName %f "f"
|
||||
OpName %v "v"
|
||||
%bool = OpTypeBool
|
||||
%1 = OpTypeFunction %bool
|
||||
%void = OpTypeVoid
|
||||
%5 = OpTypeFunction %void
|
||||
%_ptr_Function_bool = OpTypePointer Function %bool
|
||||
%12 = OpConstantNull %bool
|
||||
%call_discard = OpFunction %bool None %1
|
||||
%4 = OpLabel
|
||||
OpKill
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %5
|
||||
%8 = OpLabel
|
||||
%v = OpVariable %_ptr_Function_bool Function %12
|
||||
%9 = OpFunctionCall %bool %call_discard
|
||||
OpStore %v %9
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
18
test/bug/tint/1369.wgsl.expected.wgsl
Normal file
18
test/bug/tint/1369.wgsl.expected.wgsl
Normal file
@@ -0,0 +1,18 @@
|
||||
bug/tint/1369.wgsl:3:3 warning: code is unreachable
|
||||
return true;
|
||||
^^^^^^
|
||||
|
||||
bug/tint/1369.wgsl:9:9 warning: code is unreachable
|
||||
var also_unreachable : bool;
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
fn call_discard() -> bool {
|
||||
discard;
|
||||
return true;
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn f() {
|
||||
var v = call_discard();
|
||||
var also_unreachable : bool;
|
||||
}
|
||||
Reference in New Issue
Block a user