[Mesa-dev] [PATCH 20/21] glsl: Use short names for function return value variables

Ian Romanick idr at freedesktop.org
Tue May 27 19:49:15 PDT 2014


From: Ian Romanick <ian.d.romanick at intel.com>

Reduces the peak ir_variable memory usage in a trimmed apitrace of dota2
by 181KiB on 64-bit.

Before: IR MEM: variable usage / name / total: 5327760 1121441 6449201
After:  IR MEM: variable usage / name / total: 5327760 935234 6262994

Reduces the peak ir_variable memory usage in a trimmed apitrace of dota2
by 114KiB on 32-bit.

Before: IR MEM: variable usage / name / total: 4118280 787727 4906007
After:  IR MEM: variable usage / name / total: 4118280 670980 4789260

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/glsl/ast_function.cpp | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp
index bad410b..24bbd90 100644
--- a/src/glsl/ast_function.cpp
+++ b/src/glsl/ast_function.cpp
@@ -394,12 +394,9 @@ 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. */
-      ir_variable *var;
+      ir_variable *var =
+         new(ctx) ir_variable(sig->return_type, "$r", ir_var_temporary);
 
-      var = new(ctx) ir_variable(sig->return_type,
-				 ralloc_asprintf(ctx, "%s_retval",
-						 sig->function_name()),
-				 ir_var_temporary);
       instructions->push_tail(var);
 
       deref = new(ctx) ir_dereference_variable(var);
-- 
1.8.1.4



More information about the mesa-dev mailing list