From 3d435f7321c3f9241d33a0f7521573f21b548186 Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 4 Jan 2018 13:41:09 -0800 Subject: Bug fixes for Slang integration (#356) * fix #353 * move validateEntryPoint to after all entrypoints has been checked * bug fix: DeclRefType::SubstituteImpl should change ioDiff * bug fix: generic resource usage should have count of 1 instead of 0. * update test case --- source/slang/ir.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'source/slang/ir.cpp') diff --git a/source/slang/ir.cpp b/source/slang/ir.cpp index e0f703cbd..088139953 100644 --- a/source/slang/ir.cpp +++ b/source/slang/ir.cpp @@ -3095,6 +3095,12 @@ namespace Slang { return declRef; } + + // A callback used to clone (or not) a Val + virtual RefPtr maybeCloneVal(Val* val) + { + return val; + } }; void registerClonedValue( @@ -3203,6 +3209,7 @@ namespace Slang virtual DeclRef maybeCloneDeclRef(DeclRef const& declRef) override; virtual RefPtr maybeCloneType(Type* originalType) override; + virtual RefPtr maybeCloneVal(Val* val) override; }; @@ -3216,6 +3223,11 @@ namespace Slang return originalType->Substitute(subst).As(); } + RefPtr IRSpecContext::maybeCloneVal(Val * val) + { + return val->Substitute(subst); + } + IRValue* IRSpecContext::maybeCloneValue(IRValue* originalValue) { switch (originalValue->op) @@ -3316,7 +3328,7 @@ namespace Slang } else { - return val; + return context->maybeCloneVal(val); } } @@ -3439,7 +3451,7 @@ namespace Slang IRGlobalVar* originalVar, IROriginalValuesForClone const& originalValues) { - auto clonedVar = context->builder->createGlobalVar(context->maybeCloneType(originalVar->getType()->getValueType())); + auto clonedVar = context->builder->createGlobalVar(context->maybeCloneType(originalVar->getType()->getValueType())); registerClonedValue(context, clonedVar, originalValues); auto mangledName = originalVar->mangledName; @@ -4229,6 +4241,7 @@ namespace Slang virtual IRValue* maybeCloneValue(IRValue* originalVal) override; virtual RefPtr maybeCloneType(Type* originalType) override; + virtual RefPtr maybeCloneVal(Val* val) override; }; // Convert a type-level value into an IR-level equivalent. @@ -4352,6 +4365,11 @@ namespace Slang return originalType->Substitute(subst).As(); } + RefPtr IRGenericSpecContext::maybeCloneVal(Val * val) + { + return val->Substitute(subst); + } + // Given a list of substitutions, return the inner-most // generic substitution in the list, or NULL if there // are no generic substitutions. -- cgit v1.2.3