From 0a81d11bc06e55089f7061225b9553329f697828 Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 3 Sep 2021 01:57:31 -0700 Subject: Fix crash: dynamic dispatch of generic interface method. (#1929) * Fix crash: dynamic dispatch of generic interface method. * Fix memory error. Co-authored-by: Yong He --- source/slang/slang-ir-lower-generic-call.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source/slang/slang-ir-lower-generic-call.cpp') diff --git a/source/slang/slang-ir-lower-generic-call.cpp b/source/slang/slang-ir-lower-generic-call.cpp index 3571b7a27..7669593c6 100644 --- a/source/slang/slang-ir-lower-generic-call.cpp +++ b/source/slang/slang-ir-lower-generic-call.cpp @@ -218,9 +218,6 @@ namespace Slang auto newCall = builder->emitCallInst(calleeRetType, newCallee, args); auto callInstType = callInst->getDataType(); auto unpackInst = maybeUnpackValue(builder, callInstType, calleeRetType, newCall); - callInst->replaceUsesWith(unpackInst); - callInst->removeAndDeallocate(); - // Unpack other `out` arguments. for (auto& item : argsToUnpack) { @@ -229,6 +226,8 @@ namespace Slang auto unpackedVal = builder->emitUnpackAnyValue(originalValType, packedVal); builder->emitStore(item.dstArg, unpackedVal); } + callInst->replaceUsesWith(unpackInst); + callInst->removeAndDeallocate(); } IRInst* findInnerMostSpecializingBase(IRSpecialize* inst) -- cgit v1.2.3