import_prototypes(const exec_list *source, exec_list *dest,
class glsl_symbol_table *symbols, void *mem_ctx);
+extern bool
+ir_has_call(ir_instruction *ir);
+
#endif /* IR_H */
bool has_call;
};
+bool
+ir_has_call(ir_instruction *ir)
+{
+ ir_has_call_visitor v;
+ ir->accept(&v);
+ return v.has_call;
+}
+
/**
* Calls a user function for every basic block in the instruction stream.
*
call_for_basic_blocks(&ir_sig->body, callback, data);
}
} else if (ir->as_assignment()) {
- ir_has_call_visitor v;
-
/* If there's a call in the expression tree being assigned,
* then that ends the BB too.
*
* expression flattener may be useful before using the basic
* block finder to get more maximal basic blocks out.
*/
- ir->accept(&v);
- if (v.has_call) {
+ if (ir_has_call(ir)) {
callback(leader, ir, data);
leader = NULL;
}
* Don't do so if it's a shader output, though.
*/
if (entry->var->mode != ir_var_out &&
- entry->var->mode != ir_var_inout) {
+ entry->var->mode != ir_var_inout &&
+ !ir_has_call(entry->assign)) {
entry->assign->remove();
progress = true;
}
}
- /* 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);