glsl2: Remove a couple FINISHME comments that have already been resolved
[mesa.git] / src / glsl / ir_dead_code_local.cpp
index e01877077c9b9b282364359e1d2852169c8d7b04..4bbedf0ff946e50c222c6aa1d69a228384c3e3e5 100644 (file)
@@ -111,9 +111,8 @@ public:
  * of a variable to a variable.
  */
 static bool
-process_assignment(ir_assignment *ir, exec_list *assignments)
+process_assignment(void *ctx, ir_assignment *ir, exec_list *assignments)
 {
-   void *ctx = talloc_parent(ir);
    ir_variable *var = NULL;
    bool progress = false;
    kill_for_derefs_visitor v(assignments);
@@ -138,7 +137,7 @@ process_assignment(ir_assignment *ir, exec_list *assignments)
    }
 
    /* Now, check if we did a whole-variable assignment. */
-   if (always_assign && (ir->lhs->whole_variable_referenced() != NULL)) {
+   if (always_assign && (ir->whole_variable_written() != NULL)) {
       /* We did a whole-variable assignment.  So, any instruction in
        * the assignment list with the same LHS is dead.
        */
@@ -157,7 +156,12 @@ process_assignment(ir_assignment *ir, exec_list *assignments)
       }
    }
 
-   /* Add this instruction to the assignment list. */
+   /* Add this instruction to the assignment list available to be removed.
+    * But not if the assignment has other side effects.
+    */
+   if (ir_has_call(ir))
+      return progress;
+
    assignment_entry *entry = new(ctx) assignment_entry(var, ir);
    assignments->push_tail(entry);
 
@@ -186,6 +190,7 @@ dead_code_local_basic_block(ir_instruction *first,
    bool *out_progress = (bool *)data;
    bool progress = false;
 
+   void *ctx = talloc_new(NULL);
    /* Safe looping, since process_assignment */
    for (ir = first, ir_next = (ir_instruction *)first->next;;
        ir = ir_next, ir_next = (ir_instruction *)ir->next) {
@@ -197,7 +202,7 @@ dead_code_local_basic_block(ir_instruction *first,
       }
 
       if (ir_assign) {
-        progress = process_assignment(ir_assign, &assignments) || progress;
+        progress = process_assignment(ctx, ir_assign, &assignments) || progress;
       } else {
         kill_for_derefs_visitor kill(&assignments);
         ir->accept(&kill);
@@ -207,6 +212,7 @@ dead_code_local_basic_block(ir_instruction *first,
         break;
    }
    *out_progress = progress;
+   talloc_free(ctx);
 }
 
 /**