From 083eecee3f56b90c7011895f53aaafa9db15856e Mon Sep 17 00:00:00 2001 From: Mukund Keshava Date: Sun, 11 May 2025 02:29:37 +0530 Subject: Add debug information for slang inling (#6621) --- source/slang/slang-lower-to-ir.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'source/slang/slang-lower-to-ir.cpp') diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index 2271e750e..c58eed1c1 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -11011,6 +11011,31 @@ struct DeclLoweringVisitor : DeclVisitor } } + // Add debugfunction decoration and emit debug function. This + // is needed for emitting debug information + auto nameHint = irFunc->findDecoration(); + IRStringLit* nameOperand = nameHint ? as(nameHint->getNameOperand()) : nullptr; + if (nameOperand) + { + getBuilder()->setInsertInto(getBuilder()->getModule()->getModuleInst()); + + auto locationDecor = irFunc->findDecoration(); + IRInst* debugType = irFunc->getDataType(); + + if (locationDecor && debugType) + { + auto debugFuncCallee = getBuilder()->emitDebugFunction( + nameOperand, + locationDecor->getLine(), + locationDecor->getCol(), + locationDecor->getSource(), + debugType); + + // Add a decoration to link the function to its debug function + getBuilder()->addDecoration(irFunc, kIROp_DebugFunctionDecoration, debugFuncCallee); + } + } + // For convenience, ensure that any additional global // values that were emitted while outputting the function // body appear before the function itself in the list -- cgit v1.2.3