From 24f56d0d0e00853709f9a51da593928eb3460f60 Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 27 Sep 2024 19:28:58 -0700 Subject: Fix target switch lowering bug. (#5182) --- source/slang/slang-lower-to-ir.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index d8dbaa812..e677c24dd 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -6622,8 +6622,13 @@ struct StmtLoweringVisitor : StmtVisitor } context->shared->breakLabels.remove(stmt); builder->setInsertInto(initialBlock); + + auto parentFunc = initialBlock->getParent(); + parentFunc->addBlock(breakLabel); + builder->emitIntrinsicInst(nullptr, kIROp_TargetSwitch, (UInt)args.getCount(), args.getBuffer()); - insertBlock(breakLabel); + + builder->setInsertInto(breakLabel); } void visitTargetCaseStmt(TargetCaseStmt*) -- cgit v1.2.3