-static bool ir_block_life_propagate(ir_block *b, ir_block *prev, bool *changed);
-bool ir_function_calculate_liferanges(ir_function *self)
-{
- size_t i;
- bool changed;
-
- /* parameters live at 0 */
- for (i = 0; i < vec_size(self->params); ++i)
- ir_value_life_merge(self->locals[i], 0);
-
- do {
- self->run_id++;
- changed = false;
- for (i = 0; i != vec_size(self->blocks); ++i)
- {
- if (self->blocks[i]->is_return)
- {
- vec_free(self->blocks[i]->living);
- if (!ir_block_life_propagate(self->blocks[i], NULL, &changed))
- return false;
- }
- }
- } while (changed);
- if (vec_size(self->blocks)) {
- ir_block *block = self->blocks[0];
- for (i = 0; i < vec_size(block->living); ++i) {
- ir_value *v = block->living[i];
- if (v->store != store_local)
- continue;
- if ((v->members[0] && v->members[1] && v->members[2])) {
- /* all vector members have been accessed - only treat this as uninitialized
- * if any of them is also uninitialized.
- */
- if (!vec_ir_value_find(block->living, v->members[0], NULL) &&
- !vec_ir_value_find(block->living, v->members[1], NULL) &&
- !vec_ir_value_find(block->living, v->members[2], NULL))
- {
- continue;
- }
- }
- if (v->memberof) {
- /* A member is only uninitialized if the whole vector is also uninitialized */
- if (!vec_ir_value_find(block->living, v->memberof, NULL))
- continue;
- }
- self->flags |= IR_FLAG_HAS_UNINITIALIZED;
- if (irwarning(v->context, WARN_USED_UNINITIALIZED,
- "variable `%s` may be used uninitialized in this function", v->name))
- {
- return false;
- }
- }
- }
- return true;
-}
-