Fixed r22124:
[libfirm] / ir / opt / funccall.c
index 9ec4615..7992636 100644 (file)
@@ -90,8 +90,8 @@ static void collect_const_and_pure_calls(ir_node *node, void *env) {
                /* set the link to NULL for all non-const/pure calls */
                set_irn_link(call, NULL);
                ptr = get_Call_ptr(call);
-               if (is_SymConst_addr_ent(ptr)) {
-                       ent = get_SymConst_entity(ptr);
+               if (is_Global(ptr)) {
+                       ent = get_Global_entity(ptr);
 
                        prop = get_entity_additional_properties(ent);
                        if ((prop & (mtp_property_const|mtp_property_pure)) == 0)
@@ -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
@@ -207,7 +207,7 @@ static void fix_const_call_list(ir_graph *irg, ir_node *call_list, ir_node *proj
                mem  = get_irn_link(call);
 
                /* beware of calls in the pure call list */
-               if (! mem || get_irn_op(mem) == op_Call)
+               if (!mem || is_Call(mem))
                        continue;
                assert(get_irn_mode(mem) == mode_M);
 
@@ -261,8 +261,8 @@ static void collect_nothrow_calls(ir_node *node, void *env) {
                /* set the link to NULL for all non-const/pure calls */
                set_irn_link(call, NULL);
                ptr = get_Call_ptr(call);
-               if (is_SymConst_addr_ent(ptr)) {
-                       ent = get_SymConst_entity(ptr);
+               if (is_Global(ptr)) {
+                       ent = get_Global_entity(ptr);
 
                        prop = get_entity_additional_properties(ent);
                        if ((prop & mtp_property_nothrow) == 0)
@@ -463,8 +463,7 @@ static unsigned _follow_mem(ir_node *node) {
                case iro_Call:
                        /* A call is only tolerable if its either constant or pure. */
                        ptr = get_Call_ptr(node);
-                       if (get_irn_op(ptr) == op_SymConst &&
-                               get_SymConst_kind(ptr) == symconst_addr_ent) {
+                       if (is_SymConst(ptr) && get_SymConst_kind(ptr) == symconst_addr_ent) {
                                ir_entity *ent = get_SymConst_entity(ptr);
                                ir_graph  *irg = get_entity_irg(ent);
 
@@ -577,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;
                }
@@ -677,8 +681,8 @@ static int is_malloc_call_result(const ir_node *node) {
        if (is_alloc_entity != NULL && is_Call(node)) {
                ir_node *ptr = get_Call_ptr(node);
 
-               if (is_SymConst_addr_ent(ptr)) {
-                       ir_entity *ent = get_SymConst_entity(ptr);
+               if (is_Global(ptr)) {
+                       ir_entity *ent = get_Global_entity(ptr);
                        return is_alloc_entity(ent);
                }
        }
@@ -723,8 +727,8 @@ static int is_stored(const ir_node *n) {
                        break;
                case iro_Call:
                        ptr = get_Call_ptr(succ);
-                       if (is_SymConst_addr_ent(ptr)) {
-                               ir_entity *ent = get_SymConst_entity(ptr);
+                       if (is_Global(ptr)) {
+                               ir_entity *ent = get_Global_entity(ptr);
                                int       i;
 
                                /* we know the called entity */
@@ -831,9 +835,9 @@ static unsigned check_nothrow_or_malloc(ir_graph *irg, int top) {
                                        } else if (is_Call(res)) {
                                                ir_node *ptr = get_Call_ptr(res);
 
-                                               if (is_SymConst_addr_ent(ptr)) {
+                                               if (is_Global(ptr)) {
                                                        /* a direct call */
-                                                       ir_entity *ent    = get_SymConst_entity(ptr);
+                                                       ir_entity *ent    = get_Global_entity(ptr);
                                                        ir_graph  *callee = get_entity_irg(ent);
 
                                                        if (callee == irg) {
@@ -887,9 +891,9 @@ static unsigned check_nothrow_or_malloc(ir_graph *irg, int top) {
                        if (is_Call(pred)) {
                                ir_node *ptr = get_Call_ptr(pred);
 
-                               if (is_SymConst_addr_ent(ptr)) {
+                               if (is_Global(ptr)) {
                                        /* a direct call */
-                                       ir_entity *ent    = get_SymConst_entity(ptr);
+                                       ir_entity *ent    = get_Global_entity(ptr);
                                        ir_graph  *callee = get_entity_irg(ent);
 
                                        if (callee == irg) {