summaryrefslogtreecommitdiff
path: root/source/slang/slang-emit-c-like.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2020-07-23 13:47:12 -0700
committerGitHub <noreply@github.com>2020-07-23 13:47:12 -0700
commitfed4292a581364b611a82a0f6c1c1c95f82dfeb2 (patch)
treef4e50a0d448f2710313a05b5def07a1c0a3b67b3 /source/slang/slang-emit-c-like.cpp
parente93d3a443934b50fb983f77306a72e9c695bd5b9 (diff)
Run SSA pass to clean up temporary variables during generics lowering. (#1447)
* Run SSA pass to clean up generic temporary variables during lowering. * Fix `undefined` emitting logic. * revert dumpir control flag * Defer fold decision of `undefined` values after special case logic for GLSL and HLSL. * Update expected test result. * Manually update raygen.slang.glsl to minimize change. * fix formatting Co-authored-by: Tim Foley <tfoleyNV@users.noreply.github.com>
Diffstat (limited to 'source/slang/slang-emit-c-like.cpp')
-rw-r--r--source/slang/slang-emit-c-like.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/source/slang/slang-emit-c-like.cpp b/source/slang/slang-emit-c-like.cpp
index 733811183..a3b11a908 100644
--- a/source/slang/slang-emit-c-like.cpp
+++ b/source/slang/slang-emit-c-like.cpp
@@ -1074,6 +1074,15 @@ bool CLikeSourceEmitter::shouldFoldInstIntoUseSites(IRInst* inst)
if(inst->findDecoration<IRPreciseDecoration>())
return false;
+ // In general, undefined value should be emitted as an uninitialized
+ // variable, so we shouldn't fold it.
+ // However, we cannot emit all undefined values a separate variable
+ // definition for certain types on certain targets (e.g. `out TriangleStream<T>`
+ // for GLSL), so we check this only after all those special cases are
+ // considered.
+ if (inst->op == kIROp_undefined)
+ return false;
+
// Okay, at this point we know our instruction must have a single use.
auto use = inst->firstUse;
SLANG_ASSERT(use);