From: Rhys Perry Date: Thu, 30 Jan 2020 11:49:20 +0000 (+0000) Subject: aco: make validate() usable in tests X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bf4b377b9b9fa7152431f1efd6bcd15018bbd8f8;p=mesa.git aco: make validate() usable in tests Signed-off-by: Rhys Perry Reviewed-by: Samuel Pitoiset Part-of: --- diff --git a/src/amd/compiler/aco_interface.cpp b/src/amd/compiler/aco_interface.cpp index 95e2bd1ac1a..a05df1e7959 100644 --- a/src/amd/compiler/aco_interface.cpp +++ b/src/amd/compiler/aco_interface.cpp @@ -45,6 +45,15 @@ static radv_compiler_statistic_info statistic_infos[] = { [aco::statistic_vgpr_presched] = {"Pre-Sched VGPRs", "VGPR usage before scheduling"}, }; +static void validate(aco::Program *program) +{ + if (!(aco::debug_flags & aco::DEBUG_VALIDATE)) + return; + + bool is_valid = aco::validate(program, stderr); + assert(is_valid); +} + void aco_compile_shader(unsigned shader_count, struct nir_shader *const *shaders, struct radv_shader_binary **binary, @@ -72,7 +81,7 @@ void aco_compile_shader(unsigned shader_count, /* Phi lowering */ aco::lower_phis(program.get()); aco::dominator_tree(program.get()); - aco::validate(program.get(), stderr); + validate(program.get()); /* Optimization */ aco::value_numbering(program.get()); @@ -81,7 +90,7 @@ void aco_compile_shader(unsigned shader_count, /* cleanup and exec mask handling */ aco::setup_reduce_temp(program.get()); aco::insert_exec_mask(program.get()); - aco::validate(program.get(), stderr); + validate(program.get()); /* spilling and scheduling */ aco::live live_vars = aco::live_var_analysis(program.get(), args->options); @@ -89,7 +98,7 @@ void aco_compile_shader(unsigned shader_count, if (program->collect_statistics) aco::collect_presched_stats(program.get()); aco::schedule_program(program.get(), live_vars); - aco::validate(program.get(), stderr); + validate(program.get()); std::string llvm_ir; if (args->options->record_ir) { @@ -119,7 +128,7 @@ void aco_compile_shader(unsigned shader_count, abort(); } - aco::validate(program.get(), stderr); + validate(program.get()); /* Lower to HW Instructions */ aco::ssa_elimination(program.get()); diff --git a/src/amd/compiler/aco_ir.h b/src/amd/compiler/aco_ir.h index 7cf5ab19911..6f2a4a46b91 100644 --- a/src/amd/compiler/aco_ir.h +++ b/src/amd/compiler/aco_ir.h @@ -1607,7 +1607,7 @@ void insert_NOPs(Program* program); unsigned emit_program(Program* program, std::vector& code); void print_asm(Program *program, std::vector& binary, unsigned exec_size, std::ostream& out); -void validate(Program* program, FILE *output); +bool validate(Program* program, FILE *output); bool validate_ra(Program* program, const struct radv_nir_compiler_options *options, FILE *output); #ifndef NDEBUG void perfwarn(bool cond, const char *msg, Instruction *instr=NULL); diff --git a/src/amd/compiler/aco_validate.cpp b/src/amd/compiler/aco_validate.cpp index 83457e54fdf..e532cdf241f 100644 --- a/src/amd/compiler/aco_validate.cpp +++ b/src/amd/compiler/aco_validate.cpp @@ -46,11 +46,8 @@ void perfwarn(bool cond, const char *msg, Instruction *instr) } #endif -void validate(Program* program, FILE * output) +bool validate(Program* program, FILE *output) { - if (!(debug_flags & DEBUG_VALIDATE)) - return; - bool is_valid = true; auto check = [&output, &is_valid](bool check, const char * msg, aco::Instruction * instr) -> void { if (!check) { @@ -439,7 +436,7 @@ void validate(Program* program, FILE * output) } } - assert(is_valid); + return is_valid; } /* RA validation */