if (is_Bad(cfgpred)) {
value = new_r_Bad(irg);
} else {
+ inc_irg_visited(irg);
+
value = get_r_value_internal(cfgpred, pos, mode);
}
in[i] = value;
*/
static ir_node *get_r_value_internal(ir_node *block, int pos, ir_mode *mode)
{
- ir_node *res = block->attr.block.graph_arr[pos];
+ ir_node *res = block->attr.block.graph_arr[pos];
+ ir_graph *irg = get_irn_irg(block);
if (res != NULL)
return res;
+ /* We ran into a cycle. This may happen in unreachable loops. */
+ if (irn_visited(block)) {
+ /* Since the loop is unreachable, return a Bad. */
+ return new_r_Bad(irg);
+ }
+
+ mark_irn_visited(block);
+
/* in a matured block we can immediately determine the phi arguments */
if (get_Block_matured(block)) {
int arity = get_irn_arity(block);
{
assert(get_irg_phase_state(irg) == phase_building);
assert(pos >= 0);
+ inc_irg_visited(irg);
return get_r_value_internal(irg->current_block, pos + 1, mode);
}
ir_node *get_r_store(ir_graph *irg)
{
assert(get_irg_phase_state(irg) == phase_building);
+ inc_irg_visited(irg);
return get_r_value_internal(irg->current_block, 0, mode_M);
}