From b937207dccd05f700855e9aeb3f7c375b595b827 Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 12 Apr 2024 14:40:30 -0700 Subject: Fix IR lowering bug of do-while loops. (#3941) --- source/slang/slang-ir-validate.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source/slang/slang-ir-validate.cpp') diff --git a/source/slang/slang-ir-validate.cpp b/source/slang/slang-ir-validate.cpp index 2868c9929..a4a2921fe 100644 --- a/source/slang/slang-ir-validate.cpp +++ b/source/slang/slang-ir-validate.cpp @@ -66,6 +66,7 @@ namespace Slang State state = kState_Initial; IRInst* prevChild = nullptr; + bool hasSeenTerminatorInst = false; for(auto child : parent->getDecorationsAndChildren() ) { // We need to check the integrity of the parent/next/prev links of @@ -105,7 +106,11 @@ namespace Slang validate(context, !as(child), child, "terminator must be last instruction in a block"); } - + if (as(child)) + { + validate(context, !hasSeenTerminatorInst, child, "block must not contain more than one terminator"); + hasSeenTerminatorInst = true; + } prevChild = child; } } -- cgit v1.2.3