Mesa (master): glsl: use the linear allocator in opt_dead_code_local

Marek Olšák mareko at kemper.freedesktop.org
Mon Oct 31 11:26:38 UTC 2016


Module: Mesa
Branch: master
Commit: 9c19dedff033a7cfb43d32d035fe9b26d6eb7636
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9c19dedff033a7cfb43d32d035fe9b26d6eb7636

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Fri Oct  7 20:57:04 2016 +0200

glsl: use the linear allocator in opt_dead_code_local

Tested-by: Edmondo Tommasina <edmondo.tommasina at gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>

---

 src/compiler/glsl/opt_dead_code_local.cpp | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/compiler/glsl/opt_dead_code_local.cpp b/src/compiler/glsl/opt_dead_code_local.cpp
index d38fd2b..fc979af 100644
--- a/src/compiler/glsl/opt_dead_code_local.cpp
+++ b/src/compiler/glsl/opt_dead_code_local.cpp
@@ -45,6 +45,9 @@ namespace {
 class assignment_entry : public exec_node
 {
 public:
+   /* override operator new from exec_node */
+   DECLARE_LINEAR_ZALLOC_CXX_OPERATORS(assignment_entry)
+
    assignment_entry(ir_variable *lhs, ir_assignment *ir)
    {
       assert(lhs);
@@ -161,7 +164,7 @@ public:
  * of a variable to a variable.
  */
 static bool
-process_assignment(void *ctx, ir_assignment *ir, exec_list *assignments)
+process_assignment(void *lin_ctx, ir_assignment *ir, exec_list *assignments)
 {
    ir_variable *var = NULL;
    bool progress = false;
@@ -271,7 +274,7 @@ process_assignment(void *ctx, ir_assignment *ir, exec_list *assignments)
    }
 
    /* Add this instruction to the assignment list available to be removed. */
-   assignment_entry *entry = new(ctx) assignment_entry(var, ir);
+   assignment_entry *entry = new(lin_ctx) assignment_entry(var, ir);
    assignments->push_tail(entry);
 
    if (debug) {
@@ -298,6 +301,8 @@ dead_code_local_basic_block(ir_instruction *first,
    bool progress = false;
 
    void *ctx = ralloc_context(NULL);
+   void *lin_ctx = linear_alloc_parent(ctx, 0);
+
    /* Safe looping, since process_assignment */
    for (ir = first, ir_next = (ir_instruction *)first->next;;
 	ir = ir_next, ir_next = (ir_instruction *)ir->next) {
@@ -309,7 +314,8 @@ dead_code_local_basic_block(ir_instruction *first,
       }
 
       if (ir_assign) {
-	 progress = process_assignment(ctx, ir_assign, &assignments) || progress;
+	 progress = process_assignment(lin_ctx, ir_assign, &assignments) ||
+                    progress;
       } else {
 	 kill_for_derefs_visitor kill(&assignments);
 	 ir->accept(&kill);




More information about the mesa-commit mailing list