From b7d318f48db2cb83a41d665f1727ae93fc555124 Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 28 Sep 2023 18:07:40 -0700 Subject: Support `constref` parameters passing. (#3249) * Support `constref` parameters passing. * Fix. * Fix. * Add test and diagnostic on mix use of __constref and no_diff. * check for [constref] on differentiable member method. --------- Co-authored-by: Yong He --- source/slang/slang-ir-addr-inst-elimination.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source/slang/slang-ir-addr-inst-elimination.cpp') diff --git a/source/slang/slang-ir-addr-inst-elimination.cpp b/source/slang/slang-ir-addr-inst-elimination.cpp index 4d44aac1f..6fb21e1ef 100644 --- a/source/slang/slang-ir-addr-inst-elimination.cpp +++ b/source/slang/slang-ir-addr-inst-elimination.cpp @@ -97,6 +97,12 @@ struct AddressInstEliminationContext auto addr = use->get(); auto call = as(use->getUser()); + // Don't change the use if addr is a non mutable address. + if (auto refType = as(getRootAddr(addr)->getDataType())) + { + return; + } + IRBuilder builder(module); builder.setInsertBefore(call); auto tempVar = builder.emitVar(cast(addr->getFullType())->getValueType()); @@ -123,6 +129,8 @@ struct AddressInstEliminationContext { for (auto inst : block->getChildren()) { + if (as(getRootAddr(inst)->getDataType())) + continue; if (auto ptrType = as(inst->getDataType())) { auto valType = unwrapAttributedType(ptrType->getValueType()); -- cgit v1.2.3