summaryrefslogtreecommitdiffstats
path: root/source/slang
diff options
context:
space:
mode:
authorGangzheng Tong <tonggangzheng@gmail.com>2025-09-10 00:14:05 -0700
committerGitHub <noreply@github.com>2025-09-10 07:14:05 +0000
commit2020a102e9e0ea2f39a0f2b2a75085c3607ce734 (patch)
tree2fb3782981a60c1151df06ad178c863d6f9c16a4 /source/slang
parent43dffcde78227113a0e62b02857eaf4ed6ea6e7e (diff)
Check if debugVar for is debuggable types in the legalization pass (#8326)
## Problem When generic functions with debug variables were specialized with concrete types containing non-debuggable fields (e.g., `StructuredBuffer`), the IR cloning process would create invalid `DebugVar` instructions without checking if the substituted types remained debuggable. ## Solution This fix adds a defensive check in the legalization pass that removes the debugVar created for the non-debuggable types. --------- Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'source/slang')
-rw-r--r--source/slang/slang-ir-legalize-types.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/source/slang/slang-ir-legalize-types.cpp b/source/slang/slang-ir-legalize-types.cpp
index 9363bc882..dd7107b18 100644
--- a/source/slang/slang-ir-legalize-types.cpp
+++ b/source/slang/slang-ir-legalize-types.cpp
@@ -13,6 +13,7 @@
#include "../compiler-core/slang-name.h"
#include "../core/slang-performance-profiler.h"
#include "slang-ir-clone.h"
+#include "slang-ir-insert-debug-value-store.h"
#include "slang-ir-insts.h"
#include "slang-ir-util.h"
#include "slang-ir.h"
@@ -842,8 +843,17 @@ static LegalVal legalizeDebugVar(
{
case LegalType::Flavor::simple:
{
+ auto pointedToType = tryGetPointedToType(context->builder, type.getSimple());
+
+ // Check if the type is debuggable before creating DebugVar
+ DebugValueStoreContext debugContext;
+ if (!debugContext.isDebuggableType(pointedToType))
+ {
+ return LegalVal();
+ }
+
auto legalVal = context->builder->emitDebugVar(
- tryGetPointedToType(context->builder, type.getSimple()),
+ pointedToType,
originalInst->getSource(),
originalInst->getLine(),
originalInst->getCol(),
@@ -881,6 +891,9 @@ static LegalVal legalizeDebugValue(
LegalVal debugValue,
IRDebugValue* originalInst)
{
+ if (debugVar.flavor == LegalVal::Flavor::none)
+ return LegalVal();
+
// For now we just discard any special part and keep the ordinary part.
switch (debugValue.flavor)
{
@@ -2114,6 +2127,10 @@ static LegalVal legalizeInst(
break;
case kIROp_DebugVar:
result = legalizeDebugVar(context, type, (IRDebugVar*)inst);
+ if (result.flavor == LegalVal::Flavor::none)
+ {
+ return result;
+ }
break;
case kIROp_DebugValue:
result = legalizeDebugValue(context, args[0], args[1], (IRDebugValue*)inst);