diff --git a/src/ir_opt/verification_pass.cpp b/src/ir_opt/verification_pass.cpp index 8668a619..2de47a5a 100644 --- a/src/ir_opt/verification_pass.cpp +++ b/src/ir_opt/verification_pass.cpp @@ -4,6 +4,8 @@ * General Public License version 2 or any later version. */ +#include + #include "common/assert.h" #include "frontend/ir/ir.h" #include "ir_opt/passes.h" @@ -12,11 +14,26 @@ namespace Dynarmic { namespace Optimization { void VerificationPass(const IR::Block& block) { -#if 0 for (const auto& inst : block.instructions) { - inst->AssertValid(); + for (size_t i = 0; i < inst.NumArgs(); i++) { + IR::Type t1 = inst.GetArg(i).GetType(); + IR::Type t2 = IR::GetArgTypeOf(inst.GetOpcode(), i); + ASSERT(t1 == t2 || t1 == IR::Type::Opaque || t2 == IR::Type::Opaque); + } + } + + std::map actual_uses; + for (const auto& inst : block.instructions) { + for (size_t i = 0; i < inst.NumArgs(); i++) { + if (!inst.GetArg(i).IsImmediate()) { + actual_uses[inst.GetArg(i).GetInst()]++; + } + } + } + + for (const auto& pair : actual_uses) { + ASSERT(pair.first->use_count == pair.second); } -#endif } } // namespace Optimization