glsl: Never put ir_var_temporary variables in the symbol table
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 9 Jul 2014 01:53:09 +0000 (18:53 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Tue, 30 Sep 2014 20:34:42 +0000 (13:34 -0700)
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 <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/glsl/ast_to_hir.cpp
src/glsl/glsl_parser_extras.cpp
src/glsl/glsl_symbol_table.cpp
src/glsl/linker.cpp
src/glsl/lower_packed_varyings.cpp

index 5ec1614be34b9703583809e357b0e8e72f57e488..068af295aa1b9b4d189b5fdbdaf9ed78ad693ef9 100644 (file)
@@ -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);
       }
index 2da6d5ab9d58eeaea6d97fc3d573596ed098ba8f..5005cff9d67af388d3b8885ee84bd53a3ed04458 100644 (file)
@@ -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;
       }
index a052362035bec65a11b523de394c1c1f9824a84d..2294dda42c8f25d4eefe427035deea835cc15e92 100644 (file)
@@ -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);
index dbcc5b4578f634dc57478b2ffdd03602a7cc6b33..47a722d9d1e0bc67479cb92fa64afbebb5d61f1a 100644 (file)
@@ -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;
       }
    }
index 78014831566c5d7ae47d91e04b91f0109cb749d5..5e844c792e8df2b1e8293bd05e9207d7677630d7 100644 (file)
@@ -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. */