glsl: Don't make a name for the function return variable
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 9 Jul 2014 02:04:52 +0000 (19:04 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Tue, 30 Sep 2014 20:34:43 +0000 (13:34 -0700)
If the name is just going to get dropped, don't bother making it.  If
the name is made, release it sooner (rather than later).

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_function.cpp

index 7130d6162824a6f02469d6f0c931147d3e71f9fe..cbff9d8b452ba9fab7afda1f8cc6ab12fe03af3b 100644 (file)
@@ -408,14 +408,17 @@ generate_call(exec_list *instructions, ir_function_signature *sig,
    ir_dereference_variable *deref = NULL;
    if (!sig->return_type->is_void()) {
       /* Create a new temporary to hold the return value. */
+      char *const name = ir_variable::temporaries_allocate_names
+         ? ralloc_asprintf(ctx, "%s_retval", sig->function_name())
+         : NULL;
+
       ir_variable *var;
 
-      var = new(ctx) ir_variable(sig->return_type,
-                                ralloc_asprintf(ctx, "%s_retval",
-                                                sig->function_name()),
-                                ir_var_temporary);
+      var = new(ctx) ir_variable(sig->return_type, name, ir_var_temporary);
       instructions->push_tail(var);
 
+      ralloc_free(name);
+
       deref = new(ctx) ir_dereference_variable(var);
    }
    ir_call *call = new(ctx) ir_call(sig, deref, actual_parameters);