From 9a926058f45c7adfa569946b4f6b15a8772ac035 Mon Sep 17 00:00:00 2001 From: Sai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com> Date: Mon, 13 Jan 2025 15:50:40 -0500 Subject: Don't initialize temp var for out parameters. (#6076) --- source/slang/slang-ir-autodiff-rev.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source') diff --git a/source/slang/slang-ir-autodiff-rev.cpp b/source/slang/slang-ir-autodiff-rev.cpp index 65ce69877..3237ba3b2 100644 --- a/source/slang/slang-ir-autodiff-rev.cpp +++ b/source/slang/slang-ir-autodiff-rev.cpp @@ -528,10 +528,12 @@ InstPair BackwardDiffTranscriber::transcribeFuncHeader(IRBuilder* inBuilder, IRF // If primal parameter is mutable, we need to pass in a temp var. auto tempVar = builder.emitVar(primalParamPtrType->getValueType()); - // We also need to setup the initial value of the temp var, otherwise - // the temp var will be uninitialized which could cause undefined behavior - // in the primal function. - builder.emitStore(tempVar, primalArg); + // If the parameter is not a pure 'out' param, we also need to setup the initial + // value of the temp var, otherwise the temp var will be uninitialized which could + // cause undefined behavior in the primal function. + // + if (!as(primalParamType)) + builder.emitStore(tempVar, primalArg); primalArgs.add(tempVar); } -- cgit v1.2.3