- turn while into do-while
[libfirm] / ir / be / beabi.c
index e3fb804..9fd9753 100644 (file)
@@ -1110,7 +1110,9 @@ static int cmp_call_dependency(const void *c1, const void *c2)
        if (dependent_on(n2, n1))
                return 1;
 
-       return 0;
+       /* The nodes have no depth order, but we need a total order because qsort()
+        * is not stable. */
+       return get_irn_idx(n1) - get_irn_idx(n2);
 }
 
 /**
@@ -1567,8 +1569,11 @@ static void lower_frame_sels_walker(ir_node *irn, void *data)
                        ir_node      *bl  = get_nodes_block(irn);
                        ir_node      *nw;
                        int          pos = 0;
+                       int          is_value_param = 0;
 
                        if (get_entity_owner(ent) == ctx->value_tp) {
+                               is_value_param = 1;
+
                                /* replace by its copy from the argument type */
                                pos = get_struct_member_index(ctx->value_tp, ent);
                                ent = get_argument_entity(ent, ctx);
@@ -1577,8 +1582,8 @@ static void lower_frame_sels_walker(ir_node *irn, void *data)
                        nw = be_new_FrameAddr(ctx->sp_class, current_ir_graph, bl, ctx->frame, ent);
                        exchange(irn, nw);
 
-                       /* check, if it's a param sel and if have not seen this entity before */
-                       if (get_entity_owner(ent) == ctx->value_tp && get_entity_link(ent) == NULL) {
+                       /* check, if it's a param Sel and if have not seen this entity before */
+                       if (is_value_param && get_entity_link(ent) == NULL) {
                                ent_pos_pair pair;
 
                                pair.ent  = ent;
@@ -1782,10 +1787,12 @@ static void update_outer_frame_sels(ir_node *irn, void *env) {
 /**
  * Fix access to outer local variables.
  */
-static void fix_outer_variable_access(be_abi_irg_t *env, lower_frame_sels_env_t *ctx)
+static void fix_outer_variable_access(be_abi_irg_t *env,
+                                      lower_frame_sels_env_t *ctx)
 {
        int      i;
        ir_graph *irg;
+       (void) env;
 
        for (i = get_class_n_members(ctx->frame_tp) - 1; i >= 0; --i) {
                ir_entity *ent = get_class_member(ctx->frame_tp, i);
@@ -2194,7 +2201,7 @@ static ir_entity *get_pic_symbol(be_main_env_t *env, ir_entity *entity)
 static int can_address_relative(ir_entity *entity)
 {
        return get_entity_variability(entity) == variability_initialized
-               || get_entity_visibility(entity) == visibility_local;
+               && get_entity_visibility(entity) != visibility_external_allocated;
 }
 
 /** patches SymConsts to work in position independent code */