Skip to content

Commit 01fdbb8

Browse files
authored
Fix incorrect debug function type (#9012)
IRDebugFunction is supposed to have all information needed to emit SPIRV code for DebugFunction. However, there was a case where a wrong DebugType information was inserted to IRDebugFunction. This commit fix up the problem in the first place and removes the need of handling cases where IRDebugFunction doesn't have a right type during the emit stage. Fixes #8992
1 parent a3afdc6 commit 01fdbb8

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

source/slang/slang-emit-spirv.cpp

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2409,8 +2409,7 @@ struct SPIRVEmitContext : public SourceEmitterBase, public SPIRVEmitSharedContex
24092409
getSection(SpvLogicalSectionID::ConstantsAndTypes),
24102410
nullptr,
24112411
nullptr,
2412-
as<IRDebugFunction>(inst),
2413-
nullptr);
2412+
as<IRDebugFunction>(inst));
24142413
case kIROp_DebugInlinedAt:
24152414
return emitDebugInlinedAt(
24162415
getSection(SpvLogicalSectionID::ConstantsAndTypes),
@@ -3587,7 +3586,6 @@ struct SPIRVEmitContext : public SourceEmitterBase, public SPIRVEmitSharedContex
35873586
spvBlock,
35883587
spvFunc,
35893588
irDebugFunc,
3590-
irFunc->getDataType(),
35913589
irFunc);
35923590
}
35933591
if (funcDebugScope)
@@ -4792,8 +4790,7 @@ struct SPIRVEmitContext : public SourceEmitterBase, public SPIRVEmitSharedContex
47924790
getSection(SpvLogicalSectionID::ConstantsAndTypes),
47934791
nullptr,
47944792
nullptr,
4795-
as<IRDebugFunction>(inst),
4796-
nullptr);
4793+
as<IRDebugFunction>(inst));
47974794
case kIROp_DebugInlinedAt:
47984795
return emitDebugInlinedAt(
47994796
getSection(SpvLogicalSectionID::ConstantsAndTypes),
@@ -8559,7 +8556,6 @@ struct SPIRVEmitContext : public SourceEmitterBase, public SPIRVEmitSharedContex
85598556
SpvInst* firstBlock,
85608557
SpvInst* spvFunc,
85618558
IRDebugFunction* debugFunc,
8562-
IRFuncType* debugType,
85638559
IRFunc* irFunc = nullptr)
85648560
{
85658561
SpvInst* debugFuncInfo = nullptr;
@@ -8572,15 +8568,8 @@ struct SPIRVEmitContext : public SourceEmitterBase, public SPIRVEmitSharedContex
85728568
if (!scope)
85738569
return nullptr;
85748570

8575-
SpvInst* neededDebugType = nullptr;
8576-
if (debugType)
8577-
{
8578-
neededDebugType = emitDebugType(debugType);
8579-
}
8580-
else
8581-
{
8582-
neededDebugType = emitDebugType(as<IRFuncType>(debugFunc->getDebugType()));
8583-
}
8571+
SpvInst* neededDebugType = emitDebugType(as<IRFuncType>(debugFunc->getDebugType()));
8572+
SLANG_ASSERT(neededDebugType);
85848573

85858574
IRBuilder builder(debugFunc);
85868575
debugFuncInfo = emitOpDebugFunction(

source/slang/slang-ir-lower-generic-function.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ struct GenericFunctionLoweringContext
122122
}
123123
}
124124
cloneInstDecorationsAndChildren(&cloneEnv, sharedContext->module, func, loweredFunc);
125+
fixUpDebugFuncType(loweredFunc);
125126

126127
auto block = as<IRBlock>(loweredFunc->getFirstChild());
127128
for (auto param : clonedParams)

0 commit comments

Comments
 (0)