+static void fix_start_block(ir_graph *irg)
+{
+ ir_node *initial_X = get_irg_initial_exec(irg);
+ ir_node *start_block = get_irg_start_block(irg);
+ const ir_edge_t *edge;
+
+ assert(is_Proj(initial_X));
+
+ foreach_out_edge(initial_X, edge) {
+ ir_node *block = get_edge_src_irn(edge);
+
+ if (is_Anchor(block))
+ continue;
+ if (block != start_block) {
+ ir_node *jmp = new_r_Jmp(start_block);
+
+ set_Block_cfgpred(block, get_edge_src_pos(edge), jmp);
+ return;
+ }
+ }
+ panic("Initial exec has no follow block in %+F", irg);
+}
+
+/**
+ * Update the entity of Sels to the outer value parameters.
+ */
+static void update_outer_frame_sels(ir_node *irn, void *env) {
+ lower_frame_sels_env_t *ctx = env;
+ ir_node *ptr;
+ ir_entity *ent;
+ int pos = 0;
+
+ if (! is_Sel(irn))
+ return;
+ ptr = get_Sel_ptr(irn);
+ if (! is_arg_Proj(ptr))
+ return;
+ if (get_Proj_proj(ptr) != ctx->static_link_pos)
+ return;
+ ent = get_Sel_entity(irn);
+
+ if (get_entity_owner(ent) == ctx->value_tp) {
+ /* replace by its copy from the argument type */
+ pos = get_struct_member_index(ctx->value_tp, ent);
+ ent = get_argument_entity(ent, ctx);
+ set_Sel_entity(irn, ent);
+
+ /* check, if we have not seen this entity before */
+ if (get_entity_link(ent) == NULL) {
+ ent_pos_pair pair;
+
+ pair.ent = ent;
+ pair.pos = pos;
+ pair.next = NULL;
+ ARR_APP1(ent_pos_pair, ctx->value_param_list, pair);
+ /* just a mark */
+ set_entity_link(ent, ctx->value_param_list);
+ }
+ }
+}
+
+/**
+ * Fix access to outer local variables.
+ */
+static void fix_outer_variable_access(be_abi_irg_t *env,
+ lower_frame_sels_env_t *ctx)
+{