From cf22eabc68bbe56ac9dafe4a27d02b9115324fe1 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Wed, 7 Oct 2020 14:35:21 +0100 Subject: [PATCH] aco: make validate_ir() output usable in tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rhys Perry Reviewed-by: Timur Kristóf Part-of: --- src/amd/compiler/aco_ir.h | 2 ++ src/amd/compiler/aco_validate.cpp | 15 +++++++++------ src/amd/compiler/tests/helpers.cpp | 5 +++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/amd/compiler/aco_ir.h b/src/amd/compiler/aco_ir.h index 824138f1148..997f523dd75 100644 --- a/src/amd/compiler/aco_ir.h +++ b/src/amd/compiler/aco_ir.h @@ -1922,6 +1922,8 @@ public: unsigned next_uniform_if_depth = 0; struct { + FILE *output = stderr; + bool shorten_messages = false; void (*func)(void *private_data, enum radv_compiler_debug_level level, const char *message); diff --git a/src/amd/compiler/aco_validate.cpp b/src/amd/compiler/aco_validate.cpp index 51ca2a35ae1..2e64a2358f2 100644 --- a/src/amd/compiler/aco_validate.cpp +++ b/src/amd/compiler/aco_validate.cpp @@ -37,16 +37,19 @@ static void aco_log(Program *program, enum radv_compiler_debug_level level, { char *msg; - msg = ralloc_strdup(NULL, prefix); - - ralloc_asprintf_append(&msg, " In file %s:%u\n", file, line); - ralloc_asprintf_append(&msg, " "); - ralloc_vasprintf_append(&msg, fmt, args); + if (program->debug.shorten_messages) { + msg = ralloc_vasprintf(NULL, fmt, args); + } else { + msg = ralloc_strdup(NULL, prefix); + ralloc_asprintf_append(&msg, " In file %s:%u\n", file, line); + ralloc_asprintf_append(&msg, " "); + ralloc_vasprintf_append(&msg, fmt, args); + } if (program->debug.func) program->debug.func(program->debug.private_data, level, msg); - fprintf(stderr, "%s\n", msg); + fprintf(program->debug.output, "%s\n", msg); ralloc_free(msg); } diff --git a/src/amd/compiler/tests/helpers.cpp b/src/amd/compiler/tests/helpers.cpp index d24e21e2c49..e826a3178e0 100644 --- a/src/amd/compiler/tests/helpers.cpp +++ b/src/amd/compiler/tests/helpers.cpp @@ -85,6 +85,11 @@ void create_program(enum chip_class chip_class, Stage stage, unsigned wave_size, program->debug.func = nullptr; program->debug.private_data = nullptr; + program->debug.output = output; + program->debug.shorten_messages = true; + program->debug.func = nullptr; + program->debug.private_data = nullptr; + Block *block = program->create_and_insert_block(); block->kind = block_kind_top_level;