Or else poor programmers might mistakenly use the temporary mem_ctx,
instead of the fs_visitor's mem_ctx and wonder why their code is
crashing.

Also remove the parenting. These contexts are local to the optimization
passes they're in and are freed at the end.
---
 src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp | 14 +++++++-------
 src/mesa/drivers/dri/i965/brw_fs_cse.cpp              |  6 +++---
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
index 2816d3c..a148c54 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
@@ -483,7 +483,7 @@ fs_visitor::try_constant_propagate(fs_inst *inst, acp_entry 
*entry)
  * list.
  */
 bool
-fs_visitor::opt_copy_propagate_local(void *mem_ctx, bblock_t *block,
+fs_visitor::opt_copy_propagate_local(void *copy_prop_ctx, bblock_t *block,
                                      exec_list *acp)
 {
    bool progress = false;
@@ -543,7 +543,7 @@ fs_visitor::opt_copy_propagate_local(void *mem_ctx, 
bblock_t *block,
          inst->src[0].type == inst->dst.type &&
          !inst->saturate &&
          !inst->is_partial_write()) {
-        acp_entry *entry = ralloc(mem_ctx, acp_entry);
+        acp_entry *entry = ralloc(copy_prop_ctx, acp_entry);
         entry->dst = inst->dst;
         entry->src = inst->src[0];
         acp[entry->dst.reg % ACP_HASH_SIZE].push_tail(entry);
@@ -557,7 +557,7 @@ bool
 fs_visitor::opt_copy_propagate()
 {
    bool progress = false;
-   void *mem_ctx = ralloc_context(this->mem_ctx);
+   void *copy_prop_ctx = ralloc_context(NULL);
    cfg_t cfg(&instructions);
    exec_list *out_acp[cfg.num_blocks];
    for (int i = 0; i < cfg.num_blocks; i++)
@@ -569,12 +569,12 @@ fs_visitor::opt_copy_propagate()
    for (int b = 0; b < cfg.num_blocks; b++) {
       bblock_t *block = cfg.blocks[b];
 
-      progress = opt_copy_propagate_local(mem_ctx, block,
+      progress = opt_copy_propagate_local(copy_prop_ctx, block,
                                           out_acp[b]) || progress;
    }
 
    /* Do dataflow analysis for those available copies. */
-   fs_copy_prop_dataflow dataflow(mem_ctx, &cfg, out_acp);
+   fs_copy_prop_dataflow dataflow(copy_prop_ctx, &cfg, out_acp);
 
    /* Next, re-run local copy propagation, this time with the set of copies
     * provided by the dataflow analysis available at the start of a block.
@@ -590,12 +590,12 @@ fs_visitor::opt_copy_propagate()
          }
       }
 
-      progress = opt_copy_propagate_local(mem_ctx, block, in_acp) || progress;
+      progress = opt_copy_propagate_local(copy_prop_ctx, block, in_acp) || 
progress;
    }
 
    for (int i = 0; i < cfg.num_blocks; i++)
       delete [] out_acp[i];
-   ralloc_free(mem_ctx);
+   ralloc_free(copy_prop_ctx);
 
    if (progress)
       invalidate_live_intervals();
diff --git a/src/mesa/drivers/dri/i965/brw_fs_cse.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
index d8a5434..ea610bd 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
@@ -121,7 +121,7 @@ fs_visitor::opt_cse_local(bblock_t *block, exec_list *aeb)
 {
    bool progress = false;
 
-   void *mem_ctx = ralloc_context(this->mem_ctx);
+   void *cse_ctx = ralloc_context(NULL);
 
    int ip = block->start_ip;
    for (fs_inst *inst = (fs_inst *)block->start;
@@ -148,7 +148,7 @@ fs_visitor::opt_cse_local(bblock_t *block, exec_list *aeb)
 
         if (!found) {
            /* Our first sighting of this expression.  Create an entry. */
-           aeb_entry *entry = ralloc(mem_ctx, aeb_entry);
+           aeb_entry *entry = ralloc(cse_ctx, aeb_entry);
            entry->tmp = reg_undef;
            entry->generator = inst;
            aeb->push_tail(entry);
@@ -254,7 +254,7 @@ fs_visitor::opt_cse_local(bblock_t *block, exec_list *aeb)
       ip++;
    }
 
-   ralloc_free(mem_ctx);
+   ralloc_free(cse_ctx);
 
    if (progress)
       invalidate_live_intervals();
-- 
1.8.3.2

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to