transform/InlinePtrLets: Fix ICE for lets in for-loops

For loop initializers and continuing statements do not have a BlockStatement as their parent.
Handle removal of these statements with a new Transform::RemoveStatement() helper

Fixed: tint:990
Change-Id: I24e7b18dcf71d3ef0a4d3ee68b9f68518e0eb5e8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/58063
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
Ben Clayton
2021-07-15 22:20:29 +00:00
parent 96a6e7e95d
commit 8e38fad091
9 changed files with 95 additions and 3 deletions

4
test/bug/tint/990.wgsl Normal file
View File

@@ -0,0 +1,4 @@
fn f() {
var i : i32;
for (let p = &i;;) {}
}

View File

@@ -0,0 +1,12 @@
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
void f() {
int i = 0;
{
for(; ; ) {
}
}
}

View File

@@ -0,0 +1,9 @@
#include <metal_stdlib>
using namespace metal;
void f() {
int i = 0;
for(; ; ) {
}
}

View File

@@ -0,0 +1,35 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 15
; 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 %f "f"
OpName %i "i"
%void = OpTypeVoid
%1 = OpTypeFunction %void
%int = OpTypeInt 32 1
%_ptr_Function_int = OpTypePointer Function %int
%10 = OpConstantNull %int
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
OpReturn
OpFunctionEnd
%f = OpFunction %void None %1
%6 = OpLabel
%i = OpVariable %_ptr_Function_int Function %10
OpBranch %11
%11 = OpLabel
OpLoopMerge %12 %13 None
OpBranch %14
%14 = OpLabel
OpBranch %13
%13 = OpLabel
OpBranch %11
%12 = OpLabel
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,5 @@
fn f() {
var i : i32;
for(let p = &(i); ; ;) {
}
}