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

Author: Ian Romanick <[email protected]>
Date:   Tue Jul  8 18:53:09 2014 -0700

glsl: Never put ir_var_temporary variables in the symbol table

Later patches will give every ir_var_temporary the same name in release
builds.  Adding a bunch of variables named "compiler_temp" to the symbol
table can only cause problems.

No change Valgrind massif results for a trimmed apitrace of dota2.

Signed-off-by: Ian Romanick <[email protected]>
Reviewed-by: Matt Turner <[email protected]>

---

 src/glsl/ast_to_hir.cpp            |    4 ++--
 src/glsl/glsl_parser_extras.cpp    |    8 ++++++--
 src/glsl/glsl_symbol_table.cpp     |    2 ++
 src/glsl/linker.cpp                |    4 +++-
 src/glsl/lower_packed_varyings.cpp |    1 +
 5 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 5ec1614..068af29 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -912,7 +912,6 @@ get_lvalue_copy(exec_list *instructions, ir_rvalue *lvalue)
    var = new(ctx) ir_variable(lvalue->type, "_post_incdec_tmp",
                              ir_var_temporary);
    instructions->push_tail(var);
-   var->data.mode = ir_var_auto;
 
    instructions->push_tail(new(ctx) ir_assignment(new(ctx) 
ir_dereference_variable(var),
                                                  lvalue));
@@ -2499,6 +2498,7 @@ apply_type_qualifier_to_variable(const struct 
ast_type_qualifier *qual,
    /* If there is no qualifier that changes the mode of the variable, leave
     * the setting alone.
     */
+   assert(var->data.mode != ir_var_temporary);
    if (qual->flags.q.in && qual->flags.q.out)
       var->data.mode = ir_var_function_inout;
    else if (qual->flags.q.in)
@@ -5031,7 +5031,7 @@ ast_type_specifier::hir(exec_list *instructions,
           */
          ir_variable *const junk =
             new(state) ir_variable(type, "#default precision",
-                                   ir_var_temporary);
+                                   ir_var_auto);
 
          state->symbols->add_variable(junk);
       }
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 2da6d5a..5005cff 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -1536,9 +1536,13 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct 
gl_shader *shader,
       case ir_type_function:
          shader->symbols->add_function((ir_function *) ir);
          break;
-      case ir_type_variable:
-         shader->symbols->add_variable((ir_variable *) ir);
+      case ir_type_variable: {
+         ir_variable *const var = (ir_variable *) ir;
+
+         if (var->data.mode != ir_var_temporary)
+            shader->symbols->add_variable(var);
          break;
+      }
       default:
          break;
       }
diff --git a/src/glsl/glsl_symbol_table.cpp b/src/glsl/glsl_symbol_table.cpp
index a052362..2294dda 100644
--- a/src/glsl/glsl_symbol_table.cpp
+++ b/src/glsl/glsl_symbol_table.cpp
@@ -124,6 +124,8 @@ bool glsl_symbol_table::name_declared_this_scope(const char 
*name)
 
 bool glsl_symbol_table::add_variable(ir_variable *v)
 {
+   assert(v->data.mode != ir_var_temporary);
+
    if (this->separate_function_namespace) {
       /* In 1.10, functions and variables have separate namespaces. */
       symbol_table_entry *existing = get_entry(v->name);
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index dbcc5b4..47a722d 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -976,7 +976,8 @@ populate_symbol_table(gl_shader *sh)
       if ((func = inst->as_function()) != NULL) {
         sh->symbols->add_function(func);
       } else if ((var = inst->as_variable()) != NULL) {
-        sh->symbols->add_variable(var);
+         if (var->data.mode != ir_var_temporary)
+            sh->symbols->add_variable(var);
       }
    }
 }
@@ -2185,6 +2186,7 @@ demote_shader_inputs_and_outputs(gl_shader *sh, enum 
ir_variable_mode mode)
        * to have a location assigned.
        */
       if (var->data.is_unmatched_generic_inout) {
+         assert(var->data.mode != ir_var_temporary);
         var->data.mode = ir_var_auto;
       }
    }
diff --git a/src/glsl/lower_packed_varyings.cpp 
b/src/glsl/lower_packed_varyings.cpp
index 7801483..5e844c7 100644
--- a/src/glsl/lower_packed_varyings.cpp
+++ b/src/glsl/lower_packed_varyings.cpp
@@ -261,6 +261,7 @@ lower_packed_varyings_visitor::run(exec_list *instructions)
              !var->type->contains_integer());
 
       /* Change the old varying into an ordinary global. */
+      assert(var->data.mode != ir_var_temporary);
       var->data.mode = ir_var_auto;
 
       /* Create a reference to the old varying. */

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to