/* Funcionality for inlining */
/**********************************************************************/
-/* Copy node for inlineing. Copies the node by calling copy_node and
- then updates the entity if it's a local one. env must be a pointer
- to the frame type of the procedure. The new entities must be in
- the link field of the entities. */
+/* Copy node for inlineing. Updates attributes that change when
+ * inlineing but not for dead node elimination.
+ *
+ * Copies the node by calling copy_node and then updates the entity if
+ * it's a local one. env must be a pointer of the frame type of the
+ * inlined procedure. The new entities must be in the link field of
+ * the entities. */
static INLINE void
copy_node_inline (ir_node *n, void *env) {
ir_node *new;
if (get_entity_owner(get_Sel_entity(n)) == frame_tp) {
set_Sel_entity(new, get_entity_link(get_Sel_entity(n)));
}
+ } else if (get_irn_op(n) == op_Block) {
+ new = get_new_node (n);
+ new->attr.block.irg = current_ir_graph;
}
}
+
void inline_method(ir_node *call, ir_graph *called_graph) {
ir_node *pre_call;
ir_node *post_call, *post_bl;
cf_op = get_Block_cfgpred(end_bl, i);
if (get_irn_op(cf_op) == op_Proj) {
cf_op = get_Proj_pred(cf_op);
- if (get_irn_op(cf_op) == op_Tuple) {
- cf_op = get_Tuple_pred(cf_op, 1);
+ if ((get_irn_op(cf_op) == op_Tuple) && (cf_op == call)) {
+ // There are unoptimized tuples from inlineing before when no exc
+ assert(get_Proj_proj(get_Block_cfgpred(end_bl, i)) == pn_Call_X_except);
+ cf_op = get_Tuple_pred(cf_op, pn_Call_X_except);
assert(get_irn_op(cf_op) == op_Jmp);
break;
}
cf_pred[j] = get_Block_cfgpred(end_bl, j-get_Block_n_cfgpreds(bl) +1);
set_irn_in(end_bl, arity, cf_pred);
free(cf_pred);
+ // Remove the exception pred from post-call Tuple.
+ set_Tuple_pred(call, pn_Call_X_except, new_Bad());
}
}
if ((get_irn_op(n) == op_Const) ||
(get_irn_op(n) == op_SymConst) ||
- (is_Bad(n))) {
+ (is_Bad(n)) ||
+ (get_irn_op(n) == op_Unknown)) {
/* These nodes will not be placed by the loop below. */
b = get_irg_start_block(current_ir_graph);
depth = 1;
while (irn_not_visited(b) && (!is_Bad(new)) && (new != b)) {
/* We would have to run gigo if new is bad, so we
promote it directly below. */
- assert(((b == new) || get_opt_control_flow_straightening() || get_opt_control_flow_weak_simplification()) &&
+ assert(((b == new) ||
+ get_opt_control_flow_straightening() ||
+ get_opt_control_flow_weak_simplification()) &&
("strange flag setting"));
exchange (b, new);
b = new;
(get_irn_arity(n) > 1)) {
arity = get_irn_arity(n);
+ if (n == get_irg_end_block(current_ir_graph))
+ return; // No use to add a block here.
+
for (i=0; i<arity; i++) {
pre = get_irn_n(n, i);
/* Predecessor has multiple sucessors. Insert new flow edge */
- if ((NULL != pre) && (op_Proj == get_irn_op(pre))) {
+ if ((NULL != pre) &&
+ (op_Proj == get_irn_op(pre)) &&
+ op_Raise != get_irn_op(skip_Proj(pre))) {
/* set predecessor array for new block */
in = NEW_ARR_D (ir_node *, current_ir_graph->obst, 1);