From 2e3688af574738650c2753680ce9f417fb22e5e7 Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 14 Sep 2020 10:28:22 -0700 Subject: Dynamic dispatch bug fixes. (#1541) Co-authored-by: Yong He --- source/slang/slang-ir-deduplicate.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source/slang/slang-ir-deduplicate.cpp') diff --git a/source/slang/slang-ir-deduplicate.cpp b/source/slang/slang-ir-deduplicate.cpp index 83090e5ff..bbcb8cf03 100644 --- a/source/slang/slang-ir-deduplicate.cpp +++ b/source/slang/slang-ir-deduplicate.cpp @@ -17,6 +17,7 @@ namespace Slang IRInst* addConstantValue(IRConstant* value) { IRConstantKey key = { value }; + value->setFullType((IRType*)addValue(value->getFullType())); if (auto newValue = builder->constantMap.TryGetValue(key)) return *newValue; builder->constantMap[key] = value; @@ -34,15 +35,14 @@ namespace Slang break; } - IRInstKey key = { value }; - if (auto newValue = builder->globalValueNumberingMap.TryGetValue(key)) - return *newValue; - for (UInt i = 0; i < value->getOperandCount(); i++) { value->setOperand(i, addValue(value->getOperand(i))); } value->setFullType((IRType*)addValue(value->getFullType())); + IRInstKey key = { value }; + if (auto newValue = builder->globalValueNumberingMap.TryGetValue(key)) + return *newValue; builder->globalValueNumberingMap[key] = value; return value; } @@ -53,6 +53,7 @@ namespace Slang context.builder = this; bool changed = true; constantMap.Clear(); + globalValueNumberingMap.Clear(); for (auto inst : module->getGlobalInsts()) { if (auto constVal = as(inst)) @@ -60,7 +61,6 @@ namespace Slang context.addConstantValue(constVal); } } - globalValueNumberingMap.Clear(); List instToRemove; for (auto inst : module->getGlobalInsts()) { -- cgit v1.2.3