[Mesa-dev] [PATCH 15/26] glsl: Never put ir_var_temporary variables in the symbol table
Ian Romanick
idr at freedesktop.org
Mon Jul 14 15:48:47 PDT 2014
From: Ian Romanick <ian.d.romanick at intel.com>
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 at intel.com>
---
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 82ac29e..0a4b3a6 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)
@@ -4944,7 +4944,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 93f5e75..0555c57 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -1544,9 +1544,13 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
shader->symbols->add_function(decl);
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 2119943..842678f 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -969,7 +969,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);
}
}
}
@@ -2166,6 +2167,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 c72b80a..175f805 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. */
--
1.8.1.4
More information about the mesa-dev
mailing list