intel/compiler: Don't store stage name and abbrev
authorCaio Oliveira <caio.oliveira@intel.com>
Mon, 25 Sep 2023 04:38:47 +0000 (21:38 -0700)
committerCaio Oliveira <caio.oliveira@intel.com>
Wed, 27 Sep 2023 01:12:53 +0000 (18:12 -0700)
Those are used in the failure paths and are easily retriavable from the
stage itself, so no need to store them.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Sagar Ghuge <sagar.ghuge@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25367>

src/intel/compiler/brw_fs.cpp
src/intel/compiler/brw_fs_validate.cpp
src/intel/compiler/brw_shader.cpp
src/intel/compiler/brw_shader.h
src/intel/compiler/brw_vec4.cpp
src/intel/compiler/brw_vec4_visitor.cpp

index c67f904..9716383 100644 (file)
@@ -36,6 +36,7 @@
 #include "brw_cfg.h"
 #include "brw_dead_control_flow.h"
 #include "brw_private.h"
+#include "shader_enums.h"
 #include "dev/intel_debug.h"
 #include "dev/intel_wa.h"
 #include "compiler/glsl_types.h"
@@ -591,7 +592,7 @@ fs_visitor::vfail(const char *format, va_list va)
 
    msg = ralloc_vasprintf(mem_ctx, format, va);
    msg = ralloc_asprintf(mem_ctx, "SIMD%d %s compile failed: %s\n",
-         dispatch_width, stage_abbrev, msg);
+         dispatch_width, _mesa_shader_stage_to_abbrev(stage), msg);
 
    this->fail_msg = msg;
 
@@ -6259,7 +6260,7 @@ fs_visitor::debug_optimizer(const nir_shader *nir,
    char *filename;
    int ret = asprintf(&filename, "%s/%s%d-%s-%02d-%02d-%s",
                       debug_get_option("INTEL_SHADER_OPTIMIZER_PATH", "./"),
-                      stage_abbrev, dispatch_width, nir->info.name,
+                      _mesa_shader_stage_to_abbrev(stage), dispatch_width, nir->info.name,
                       iteration, pass_num, pass_name);
    if (ret == -1)
       return;
@@ -6922,7 +6923,7 @@ fs_visitor::allocate_registers(bool allow_spilling)
                           "%s shader triggered register spilling.  "
                           "Try reducing the number of live scalar "
                           "values to improve performance.\n",
-                          stage_name);
+                          _mesa_shader_stage_to_string(stage));
    }
 
    /* This must come after all optimization and register allocation, since
index 98d149e..56ce471 100644 (file)
@@ -33,7 +33,8 @@
 #define fsv_assert(assertion)                                           \
    {                                                                    \
       if (!(assertion)) {                                               \
-         fprintf(stderr, "ASSERT: Scalar %s validation failed!\n", stage_abbrev); \
+         fprintf(stderr, "ASSERT: Scalar %s validation failed!\n",      \
+                 _mesa_shader_stage_to_abbrev(stage));                  \
          dump_instruction(inst, stderr);                                \
          fprintf(stderr, "%s:%d: '%s' failed\n", __FILE__, __LINE__, #assertion);  \
          abort();                                                       \
@@ -45,7 +46,8 @@
       unsigned f = (first);                                             \
       unsigned s = (second);                                            \
       if (f != s) {                                                     \
-         fprintf(stderr, "ASSERT: Scalar %s validation failed!\n", stage_abbrev); \
+         fprintf(stderr, "ASSERT: Scalar %s validation failed!\n",      \
+                 _mesa_shader_stage_to_abbrev(stage));                  \
          dump_instruction(inst, stderr);                                \
          fprintf(stderr, "%s:%d: A == B failed\n", __FILE__, __LINE__); \
          fprintf(stderr, "  A = %s = %u\n", #first, f);                 \
@@ -59,7 +61,8 @@
       unsigned f = (first);                                             \
       unsigned s = (second);                                            \
       if (f == s) {                                                     \
-         fprintf(stderr, "ASSERT: Scalar %s validation failed!\n", stage_abbrev); \
+         fprintf(stderr, "ASSERT: Scalar %s validation failed!\n",      \
+                 _mesa_shader_stage_to_abbrev(stage));                  \
          dump_instruction(inst, stderr);                                \
          fprintf(stderr, "%s:%d: A != B failed\n", __FILE__, __LINE__); \
          fprintf(stderr, "  A = %s = %u\n", #first, f);                 \
@@ -73,7 +76,8 @@
       unsigned f = (first);                                             \
       unsigned s = (second);                                            \
       if (f > s) {                                                      \
-         fprintf(stderr, "ASSERT: Scalar %s validation failed!\n", stage_abbrev); \
+         fprintf(stderr, "ASSERT: Scalar %s validation failed!\n",      \
+                 _mesa_shader_stage_to_abbrev(stage));                  \
          dump_instruction(inst, stderr);                                \
          fprintf(stderr, "%s:%d: A <= B failed\n", __FILE__, __LINE__); \
          fprintf(stderr, "  A = %s = %u\n", #first, f);                 \
index e924135..88beeb5 100644 (file)
@@ -697,8 +697,6 @@ backend_shader::backend_shader(const struct brw_compiler *compiler,
      stage(shader->info.stage),
      debug_enabled(debug_enabled)
 {
-   stage_name = _mesa_shader_stage_to_string(stage);
-   stage_abbrev = _mesa_shader_stage_to_abbrev(stage);
 }
 
 backend_shader::~backend_shader()
index b4a6c18..6fd8500 100644 (file)
@@ -76,8 +76,6 @@ public:
 
    gl_shader_stage stage;
    bool debug_enabled;
-   const char *stage_name;
-   const char *stage_abbrev;
 
    brw::simple_allocator alloc;
 
index 83718f0..57449a6 100644 (file)
@@ -2398,7 +2398,8 @@ vec4_visitor::run()
       if (INTEL_DEBUG(DEBUG_OPTIMIZER) && this_progress) {             \
          char filename[64];                                            \
          snprintf(filename, 64, "%s-%s-%02d-%02d-" #pass,              \
-                  stage_abbrev, nir->info.name, iteration, pass_num); \
+                  _mesa_shader_stage_to_abbrev(stage),                 \
+                  nir->info.name, iteration, pass_num);                \
                                                                        \
          backend_shader::dump_instructions(filename);                  \
       }                                                                \
@@ -2411,7 +2412,7 @@ vec4_visitor::run()
    if (INTEL_DEBUG(DEBUG_OPTIMIZER)) {
       char filename[64];
       snprintf(filename, 64, "%s-%s-00-00-start",
-               stage_abbrev, nir->info.name);
+               _mesa_shader_stage_to_abbrev(stage), nir->info.name);
 
       backend_shader::dump_instructions(filename);
    }
@@ -2499,7 +2500,7 @@ vec4_visitor::run()
                           "%s shader triggered register spilling.  "
                           "Try reducing the number of live vec4 values "
                           "to improve performance.\n",
-                          stage_name);
+                          _mesa_shader_stage_to_string(stage));
 
       while (!reg_allocate()) {
          if (failed)
index d20d8ff..9a56f1e 100644 (file)
@@ -1415,7 +1415,8 @@ vec4_visitor::fail(const char *format, ...)
    va_start(va, format);
    msg = ralloc_vasprintf(mem_ctx, format, va);
    va_end(va);
-   msg = ralloc_asprintf(mem_ctx, "%s compile failed: %s\n", stage_abbrev, msg);
+   msg = ralloc_asprintf(mem_ctx, "%s compile failed: %s\n",
+                         _mesa_shader_stage_to_abbrev(stage), msg);
 
    this->fail_msg = msg;