summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-ir-clone.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2022-12-19 11:47:19 -0800
committerGitHub <noreply@github.com>2022-12-19 11:47:19 -0800
commit216dfba0af66210a46ef0df18beb73d975fdf727 (patch)
treef397ea5bf8d47d7a5d90dc95edfb472f2e49d762 /source/slang/slang-ir-clone.cpp
parent36220da1e29c891972fef32c8575c15f868b9959 (diff)
Separate primal computations from unzipped function into an explicit function. (#2569)
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-clone.cpp')
-rw-r--r--source/slang/slang-ir-clone.cpp18
1 files changed, 13 insertions, 5 deletions
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);
}