[spirv-reader] Log error for infinite loop.
When attempting to propagate through a loop, if we find no exits then
the loop is infinite. Emit a nicer error message and terminate.
Fixed: 42251941
Change-Id: If911378497444f8bb61530393dd9d514de3f68e4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/267854
Commit-Queue: James Price <jrprice@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
diff --git a/src/tint/lang/spirv/reader/parser/parser.cc b/src/tint/lang/spirv/reader/parser/parser.cc
index 91e6cfe..1fbfd8e 100644
--- a/src/tint/lang/spirv/reader/parser/parser.cc
+++ b/src/tint/lang/spirv/reader/parser/parser.cc
@@ -1218,6 +1218,12 @@
// control as we're jumping over the control to its parent control. (This is an
// `if` inside a `loop` where the `if` is doing a `break`).
if (ctrl->Exits().IsEmpty()) {
+ if (ctrl->Is<core::ir::Loop>()) {
+ TINT_UNREACHABLE()
+ << "loop detected with no exits which means it's an infinite loop. "
+ "Infinite loops are not supported in WGSL";
+ }
+
TINT_ASSERT(ctrl->Is<core::ir::If>());
blk = ctrl->Block();
continue;