diff options
| author | Yong He <yonghe@outlook.com> | 2023-03-16 23:46:14 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-16 23:46:14 -0700 |
| commit | 9476d4543f4336a66308e55f722b0b0b2bd69dd2 (patch) | |
| tree | ff3a0514249f5c3975177bf053c5cb038e37acc8 /source/slang/slang-ir-validate.cpp | |
| parent | 77d3630eef4ea1c4b0424a46526a6be476a89230 (diff) | |
Fix Phi simplification bug. (#2710)
* Fix Phi simplification bug.
* Fix up.
* Fix.
* Fix.
* Fix.
* Fix.
* Fix.
* Fix test.
* Fix test.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-validate.cpp')
| -rw-r--r-- | source/slang/slang-ir-validate.cpp | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/source/slang/slang-ir-validate.cpp b/source/slang/slang-ir-validate.cpp index 55e0f0168..3c720e929 100644 --- a/source/slang/slang-ir-validate.cpp +++ b/source/slang/slang-ir-validate.cpp @@ -3,6 +3,7 @@ #include "slang-ir.h" #include "slang-ir-insts.h" +#include "slang-ir-dominators.h" namespace Slang { @@ -11,6 +12,8 @@ namespace Slang // The IR module we are validating. IRModule* module; + RefPtr<IRDominatorTree> domTree; + // A diagnostic sink to send errors to if anything is invalid. DiagnosticSink* sink; @@ -165,9 +168,14 @@ namespace Slang // the same function (or another value with code). We need // to validate that `operandParentBlock` dominates `instParentBlock`. // - // TODO: implement this validation once we compute dominator trees. - // - // validate(context, operandParentBlock->dominates(instParentBlock), inst, "def must dominate use"); + if (context && context->domTree) + { + validate( + context, + context->domTree->dominates(operandParentBlock, instParentBlock), + inst, + "def must dominate use"); + } return; } } @@ -327,10 +335,24 @@ namespace Slang if (auto code = as<IRGlobalValueWithCode>(inst)) { + context->domTree = computeDominatorTree(code); validateCodeBody(context, code); + context->domTree = nullptr; } } + void validateIRInst(IRInst* inst) + { + IRValidateContext contextStorage; + IRValidateContext* context = &contextStorage; + DiagnosticSink sink; + context->module = inst->getModule(); + context->sink = &sink; + if (auto func = as<IRFunc>(inst)) + context->domTree = computeDominatorTree(func); + validateIRInst(context, inst); + } + void validateIRModule(IRModule* module, DiagnosticSink* sink) { IRValidateContext contextStorage; |
