From 4c4826d47eeef4675daae4ae53ff76f4d5ebd84a Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 16 Feb 2023 13:55:32 -0800 Subject: Overhaul global inst deduplication and cpp/cuda backend. (#2654) * Overhaul global inst deduplication and cpp/cuda backend. * Update IR documentation. --------- Co-authored-by: Yong He --- source/slang/slang-ir-validate.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'source/slang/slang-ir-validate.cpp') diff --git a/source/slang/slang-ir-validate.cpp b/source/slang/slang-ir-validate.cpp index 03db96ac5..d5c0aa432 100644 --- a/source/slang/slang-ir-validate.cpp +++ b/source/slang/slang-ir-validate.cpp @@ -186,6 +186,28 @@ namespace Slang if (pp == operandParent) return; } + + // We allow out-of-order def-use in global scope. + bool allInGlobalScope = inst->getParent() && inst->getParent()->getOp() == kIROp_Module; + if (allInGlobalScope) + { + for (UInt i = 0; i < inst->getOperandCount(); i++) + { + auto op = inst->getOperand(i); + if (!op) + continue; + if (!op->getParent()) + continue; + if (op->getParent()->getOp() != kIROp_Module) + { + allInGlobalScope = false; + break; + } + } + } + if (allInGlobalScope) + return; + // // We failed to find `operandParent` while walking the ancestors of `inst`, // so something had gone wrong. -- cgit v1.2.3