summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-ir.cpp')
-rw-r--r--source/slang/slang-ir.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp
index ba8864684..7b7d5ec17 100644
--- a/source/slang/slang-ir.cpp
+++ b/source/slang/slang-ir.cpp
@@ -815,6 +815,37 @@ IRType* IRFunc::getParamType(UInt index)
return getDataType()->getParamType(index);
}
+void fixUpDebugFuncType(IRFunc* func)
+{
+ SLANG_ASSERT(func);
+
+ if (auto debugFuncDecor = func->findDecoration<IRDebugFuncDecoration>())
+ {
+ auto funcType = func->getDataType();
+ auto oldDebugFunc = cast<IRDebugFunction>(debugFuncDecor->getDebugFunc());
+
+ // If the existing debug func type is already the same, there's no need
+ // to do anything.
+ if (isTypeEqual(funcType, as<IRType>(oldDebugFunc->getDebugType())))
+ return;
+
+ auto irModule = func->getModule();
+ SLANG_ASSERT(irModule);
+
+ IRBuilder builder(irModule);
+ builder.setInsertInto(irModule->getModuleInst());
+
+ auto newDebugFunc = builder.emitDebugFunction(
+ oldDebugFunc->getName(),
+ oldDebugFunc->getLine(),
+ oldDebugFunc->getCol(),
+ oldDebugFunc->getFile(),
+ funcType);
+ debugFuncDecor->removeAndDeallocate();
+ builder.addDecoration(funcType, kIROp_DebugFuncDecoration, newDebugFunc);
+ }
+}
+
void fixUpFuncType(IRFunc* func, IRType* resultType)
{
SLANG_ASSERT(func);