[Mesa-dev] [PATCH 14/26] glsl: Add the possibility for ir_variable to have a non-ralloced name
Ian Romanick
idr at freedesktop.org
Mon Jul 14 15:48:46 PDT 2014
From: Ian Romanick <ian.d.romanick at intel.com>
Specifically, ir_var_temporary variables constructed with a NULL name
will all have the name "compiler_temp" in static storage.
No change Valgrind massif results for a trimmed apitrace of dota2.
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
src/glsl/ir.cpp | 20 +++++++++++++++++++-
src/glsl/ir.h | 10 ++++++++++
src/glsl/ir_validate.cpp | 2 +-
3 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
index 40dbb6b..0045c2d 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -1533,12 +1533,30 @@ ir_swizzle::variable_referenced() const
}
+const char ir_variable::tmp_name[] = "compiler_temp";
+
ir_variable::ir_variable(const struct glsl_type *type, const char *name,
ir_variable_mode mode)
: ir_instruction(ir_type_variable)
{
this->type = type;
- this->name = ralloc_strdup(this, name);
+
+ /* The ir_variable clone method may call this constructor with name set to
+ * tmp_name.
+ */
+ assert(name != NULL
+ || mode == ir_var_temporary
+ || mode == ir_var_function_in
+ || mode == ir_var_function_out
+ || mode == ir_var_function_inout);
+ assert(name != ir_variable::tmp_name
+ || mode == ir_var_temporary);
+ if (mode == ir_var_temporary
+ && (name == NULL || name == ir_variable::tmp_name)) {
+ this->name = ir_variable::tmp_name;
+ } else {
+ this->name = ralloc_strdup(this, name);
+ }
this->u.max_ifc_array_access = NULL;
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index 1071858..1aeb1ff 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -575,6 +575,11 @@ public:
return this->u.state_slots;
}
+ inline bool is_name_ralloced() const
+ {
+ return this->name != ir_variable::tmp_name;
+ }
+
/**
* Enable emitting extension warnings for this variable
*/
@@ -881,6 +886,11 @@ private:
* \sa ir_variable::location
*/
const glsl_type *interface_type;
+
+ /**
+ * Name used for anonymous compiler temporaries
+ */
+ static const char tmp_name[];
};
/**
diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp
index 12b8874..23f55fc 100644
--- a/src/glsl/ir_validate.cpp
+++ b/src/glsl/ir_validate.cpp
@@ -650,7 +650,7 @@ ir_validate::visit(ir_variable *ir)
* in the ir_dereference_variable handler to ensure that a variable is
* declared before it is dereferenced.
*/
- if (ir->name)
+ if (ir->name && ir->is_name_ralloced())
assert(ralloc_parent(ir->name) == ir);
hash_table_insert(ht, ir, ir);
--
1.8.1.4
More information about the mesa-dev
mailing list