[Mesa-dev] [PATCH 11/15] glsl: use the linear allocator in opt_dead_code_local
Marek Olšák
maraeo at gmail.com
Sat Oct 8 10:58:35 UTC 2016
From: Marek Olšák <marek.olsak 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
@@ -38,20 +38,23 @@
#include "ir_optimization.h"
#include "compiler/glsl_types.h"
static bool debug = false;
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);
assert(ir);
this->lhs = lhs;
this->ir = ir;
this->unused = ir->write_mask;
}
ir_variable *lhs;
@@ -154,21 +157,21 @@ public:
ir_hierarchical_visitor *visitor;
};
} /* unnamed namespace */
/**
* Adds an entry to the available copy list if it's a plain assignment
* 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;
kill_for_derefs_visitor v(assignments);
/* Kill assignment entries for things used to produce this assignment. */
ir->rhs->accept(&v);
if (ir->condition) {
ir->condition->accept(&v);
}
@@ -264,21 +267,21 @@ process_assignment(void *ctx, ir_assignment *ir, exec_list *assignments)
printf("removing %s\n", var->name);
entry->ir->remove();
entry->remove();
progress = true;
}
}
}
}
/* 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) {
printf("add %s\n", var->name);
printf("current entries\n");
foreach_in_list(assignment_entry, entry, assignments) {
printf(" %s (0x%01x)\n", entry->lhs->name, entry->unused);
}
}
@@ -291,32 +294,35 @@ dead_code_local_basic_block(ir_instruction *first,
ir_instruction *last,
void *data)
{
ir_instruction *ir, *ir_next;
/* List of avaialble_copy */
exec_list assignments;
bool *out_progress = (bool *)data;
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) {
ir_assignment *ir_assign = ir->as_assignment();
if (debug) {
ir->print();
printf("\n");
}
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);
}
if (ir == last)
break;
}
*out_progress = progress;
ralloc_free(ctx);
--
2.7.4
More information about the mesa-dev
mailing list