summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-ssa.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-ir-ssa.cpp')
-rw-r--r--source/slang/slang-ir-ssa.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/source/slang/slang-ir-ssa.cpp b/source/slang/slang-ir-ssa.cpp
index 19f85eaa9..7c849e36a 100644
--- a/source/slang/slang-ir-ssa.cpp
+++ b/source/slang/slang-ir-ssa.cpp
@@ -776,6 +776,19 @@ IRInst* readVar(
return val;
}
+ if( blockInfo->block == var->parent )
+ {
+ // If this is the block that actually *introduces*
+ // the variable, then there is no reason to keep
+ // searching, because its value cannot have been
+ // established in a predecessor block.
+ //
+ auto type = var->getDataType()->getValueType();
+ val = blockInfo->builder.emitUndefined(type);
+ writeVar(context, blockInfo, var, val);
+ return val;
+ }
+
// Otherwise we need to try to non-trivial/recursive
// case of lookup.
return readVarRec(context, blockInfo, var);