Fixed r22124:
[libfirm] / ir / opt / funccall.c
index 1b44fa4..7992636 100644 (file)
@@ -171,8 +171,8 @@ static void fix_const_call_list(ir_graph *irg, ir_node *call_list, ir_node *proj
 
        current_ir_graph = irg;
 
-       /* First step: fix all calls by removing it's memory input.
-          It's original memory input is preserved in their link fields. */
+       /* First step: fix all calls by removing their memory input.
+        * The original memory input is preserved in their link fields. */
        for (call = call_list; call; call = next) {
                next = get_irn_link(call);
                mem  = get_Call_mem(call);
@@ -181,7 +181,7 @@ static void fix_const_call_list(ir_graph *irg, ir_node *call_list, ir_node *proj
                set_Call_mem(call, get_irg_no_mem(irg));
 
                /*
-                * Sorrily we cannot simply set the node to 'float'.
+                * Unfortunately we cannot simply set the node to 'float'.
                 * There is a reason for that:
                 *
                 * - The call might be inside a loop/if that is NOT entered
@@ -576,12 +576,17 @@ static unsigned check_const_or_pure_function(ir_graph *irg, int top) {
        if (prop != mtp_no_property) {
                /* check, if a keep-alive exists */
                for (j = get_End_n_keepalives(end) - 1; j >= 0; --j) {
-                       ir_node *mem = get_End_keepalive(end, j);
+                       ir_node *kept = get_End_keepalive(end, j);
 
-                       if (mode_M != get_irn_mode(mem))
+                       if (is_Block(kept)) {
+                               prop = mtp_no_property;
+                               break;
+                       }
+
+                       if (mode_M != get_irn_mode(kept))
                                continue;
 
-                       prop = max_property(prop, follow_mem(mem, prop));
+                       prop = max_property(prop, follow_mem(kept, prop));
                        if (prop == mtp_no_property)
                                break;
                }