From 216dfba0af66210a46ef0df18beb73d975fdf727 Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 19 Dec 2022 11:47:19 -0800 Subject: Separate primal computations from unzipped function into an explicit function. (#2569) Co-authored-by: Yong He --- source/slang/slang-ir-clone.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'source/slang/slang-ir-clone.cpp') diff --git a/source/slang/slang-ir-clone.cpp b/source/slang/slang-ir-clone.cpp index 634aff75d..5b5ace64b 100644 --- a/source/slang/slang-ir-clone.cpp +++ b/source/slang/slang-ir-clone.cpp @@ -208,8 +208,9 @@ static void _cloneInstDecorationsAndChildren( // The public version of `cloneInstDecorationsAndChildren` is then // just a wrapper over the internal one that sets up a temporary -// environment to use for the cloning process, so that we do -// not leave any lasting changes in the user-provided `env`. +// environment to use for the cloning process when `env->squashChildrenMapping` is false (default), +// so that we do not leave any lasting changes in the user-provided `env` unless the caller +// explicitly asks for it. // void cloneInstDecorationsAndChildren( IRCloneEnv* env, @@ -221,10 +222,17 @@ void cloneInstDecorationsAndChildren( SLANG_ASSERT(oldInst); SLANG_ASSERT(newInst); + IRCloneEnv* subEnv = nullptr; IRCloneEnv subEnvStorage; - auto subEnv = &subEnvStorage; - subEnv->parent = env; - + if (env->squashChildrenMapping) + { + subEnv = env; + } + else + { + subEnv = &subEnvStorage; + subEnv->parent = env; + } _cloneInstDecorationsAndChildren(subEnv, sharedBuilder, oldInst, newInst); } -- cgit v1.2.3