summaryrefslogtreecommitdiffstats
path: root/source/slang/ir.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/ir.cpp')
-rw-r--r--source/slang/ir.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/source/slang/ir.cpp b/source/slang/ir.cpp
index 3a8aabd85..d35ffe2d1 100644
--- a/source/slang/ir.cpp
+++ b/source/slang/ir.cpp
@@ -3764,6 +3764,14 @@ namespace Slang
String const& mangledName,
IRGlobalValue* originalVal)
{
+ // Check if we've already cloned this value, for the case where
+ // an original value has already been established.
+ IRValue* clonedVal = nullptr;
+ if( originalVal && context->getClonedValues().TryGetValue(originalVal, clonedVal) )
+ {
+ return (IRGlobalValue*) clonedVal;
+ }
+
if(mangledName.Length() == 0)
{
// If there is no mangled name, then we assume this is a local symbol,
@@ -3779,6 +3787,9 @@ namespace Slang
RefPtr<IRSpecSymbol> sym;
if( !context->getSymbols().TryGetValue(mangledName, sym) )
{
+ if(!originalVal)
+ return nullptr;
+
// This shouldn't happen!
SLANG_UNEXPECTED("no matching values registered");
UNREACHABLE_RETURN(cloneGlobalValueImpl(context, originalVal, nullptr));
@@ -3798,6 +3809,14 @@ namespace Slang
bestVal = newVal;
}
+ // Check if we've already cloned this value, for the case where
+ // we didn't have an original value (just a name), but we've
+ // now found a representative value.
+ if( !originalVal && context->getClonedValues().TryGetValue(bestVal, clonedVal) )
+ {
+ return (IRGlobalValue*) clonedVal;
+ }
+
return cloneGlobalValueImpl(context, bestVal, sym);
}