* 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);
}
/* 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.
*/
}
}
- /* 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);
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) {
}
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);
break;
}
*out_progress = progress;
+ talloc_free(ctx);
}
/**