Mesa (main): aco: make validate_ir() output usable in tests

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 8 09:19:35 UTC 2021


Module: Mesa
Branch: main
Commit: cf22eabc68bbe56ac9dafe4a27d02b9115324fe1
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=cf22eabc68bbe56ac9dafe4a27d02b9115324fe1

Author: Rhys Perry <pendingchaos02 at gmail.com>
Date:   Wed Oct  7 14:35:21 2020 +0100

aco: make validate_ir() output usable in tests

Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3151>

---

 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;
 



More information about the mesa-commit mailing list