glsl: Add assert to check variable_entry referenced_count after construction.
[mesa.git] / src / glsl / ir_dead_code_local.cpp
index 7a44ec8a4a45ef999455ea8ea34d2dc1f335c684..4bbedf0ff946e50c222c6aa1d69a228384c3e3e5 100644 (file)
@@ -137,7 +137,7 @@ process_assignment(void *ctx, 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.
        */
@@ -156,7 +156,12 @@ process_assignment(void *ctx, 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);