aco: move cfg validation to its own function

Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23507>
This commit is contained in:
Georg Lehmann 2023-06-09 13:58:18 +02:00 committed by Marge Bot
parent e5df6ee605
commit b9854a9097
3 changed files with 23 additions and 9 deletions

View file

@ -119,6 +119,9 @@ aco_postprocess_shader(const struct aco_compiler_options* options,
if (options->dump_preoptir)
aco_print_program(program.get(), stderr);
ASSERTED bool is_valid = aco::validate_cfg(program.get());
assert(is_valid);
aco::live live_vars;
if (!info->is_trap_handler_shader) {
aco::dominator_tree(program.get());

View file

@ -2266,6 +2266,7 @@ unsigned emit_program(Program* program, std::vector<uint32_t>& code,
bool check_print_asm_support(Program* program);
bool print_asm(Program* program, std::vector<uint32_t>& binary, unsigned exec_size, FILE* output);
bool validate_ir(Program* program);
bool validate_cfg(Program* program);
bool validate_ra(Program* program);
#ifndef NDEBUG
void perfwarn(Program* program, bool cond, const char* msg, Instruction* instr = NULL);

View file

@ -102,15 +102,6 @@ validate_ir(Program* program)
}
};
auto check_block = [&program, &is_valid](bool success, const char* msg,
aco::Block* block) -> void
{
if (!success) {
aco_err(program, "%s: BB%u", msg, block->index);
is_valid = false;
}
};
for (Block& block : program->blocks) {
for (aco_ptr<Instruction>& instr : block.instructions) {
@ -783,6 +774,25 @@ validate_ir(Program* program)
}
}
return is_valid;
}
bool
validate_cfg(Program* program)
{
if (!(debug_flags & DEBUG_VALIDATE_IR))
return true;
bool is_valid = true;
auto check_block = [&program, &is_valid](bool success, const char* msg,
aco::Block* block) -> void
{
if (!success) {
aco_err(program, "%s: BB%u", msg, block->index);
is_valid = false;
}
};
/* validate CFG */
for (unsigned i = 0; i < program->blocks.size(); i++) {
Block& block = program->blocks[i];