nir: Allocate nir_phi_src values out of the nir_phi_instr.
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 2 Apr 2015 23:15:11 +0000 (16:15 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 7 Apr 2015 21:34:13 +0000 (14:34 -0700)
Phi sources are part of the phi instruction and should have the same
lifetime.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
src/glsl/nir/nir_lower_phis_to_scalar.c
src/glsl/nir/nir_lower_vars_to_ssa.c
src/glsl/nir/nir_to_ssa.c

index 7cd93ea0a538fb5e45444f44e53d92d0967d7ab6..4bdb80072ab5ecdea514d706ab05b71195aaad29 100644 (file)
@@ -223,7 +223,7 @@ lower_phis_to_scalar_block(nir_block *block, void *void_state)
             else
                nir_instr_insert_after_block(src->pred, &mov->instr);
 
-            nir_phi_src *new_src = ralloc(state->mem_ctx, nir_phi_src);
+            nir_phi_src *new_src = ralloc(new_phi, nir_phi_src);
             new_src->pred = src->pred;
             new_src->src = nir_src_for_ssa(&mov->dest.dest.ssa);
 
index 86e6ab416015a678d5f497017ee482e6b2f56018..2ca74d71bc252cab59d2e4fb7f02a5942e02edb7 100644 (file)
@@ -642,7 +642,7 @@ add_phi_sources(nir_block *block, nir_block *pred,
 
       struct deref_node *node = entry->data;
 
-      nir_phi_src *src = ralloc(state->mem_ctx, nir_phi_src);
+      nir_phi_src *src = ralloc(phi, nir_phi_src);
       src->pred = pred;
       src->src.is_ssa = true;
       src->src.ssa = get_ssa_def_for_block(node, pred, state);
index 47cf45393e09ba9856aa3bdda0146ad00fa8ba58..53ff547669d054e7a5f5fccc1398df284704d2d7 100644 (file)
@@ -47,7 +47,7 @@ insert_trivial_phi(nir_register *reg, nir_block *block, void *mem_ctx)
    set_foreach(block->predecessors, entry) {
       nir_block *pred = (nir_block *) entry->key;
 
-      nir_phi_src *src = ralloc(mem_ctx, nir_phi_src);
+      nir_phi_src *src = ralloc(instr, nir_phi_src);
       src->pred = pred;
       src->src.is_ssa = false;
       src->src.reg.base_offset = 0;