From: Michael Beck Date: Tue, 5 Aug 2008 16:46:01 +0000 (+0000) Subject: BugFix: map all anchored nodes of the called graph to nodes of the callers graph X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=4038a6839a47c63d5723b3fb400daaae52b075dc;p=libfirm BugFix: map all anchored nodes of the called graph to nodes of the callers graph [r20998] --- diff --git a/ir/opt/opt_inline.c b/ir/opt/opt_inline.c index dcf73e30b..d145dd38b 100644 --- a/ir/opt/opt_inline.c +++ b/ir/opt/opt_inline.c @@ -852,6 +852,7 @@ int inline_method(ir_node *call, ir_graph *called_graph) { ir_entity *ent; ir_graph *rem, *irg; irg_inline_property prop = get_irg_inline_property(called_graph); + unsigned long visited; if (prop == irg_inline_forbidden) return 0; @@ -995,17 +996,30 @@ int inline_method(ir_node *call, ir_graph *called_graph) { set_irg_visited(irg, get_irg_visited(called_graph) + 1); if (get_irg_block_visited(irg) < get_irg_block_visited(called_graph)) set_irg_block_visited(irg, get_irg_block_visited(called_graph)); + visited = get_irg_visited(irg); + /* Set pre_call as new Start node in link field of the start node of calling graph and pre_calls block as new block for the start block of calling graph. Further mark these nodes so that they are not visited by the copying. */ set_irn_link(get_irg_start(called_graph), pre_call); - set_irn_visited(get_irg_start(called_graph), get_irg_visited(irg)); + set_irn_visited(get_irg_start(called_graph), visited); set_irn_link(get_irg_start_block(called_graph), get_nodes_block(pre_call)); - set_irn_visited(get_irg_start_block(called_graph), get_irg_visited(irg)); - set_irn_link(get_irg_bad(called_graph), get_irg_bad(irg)); - set_irn_visited(get_irg_bad(called_graph), get_irg_visited(irg)); + set_irn_visited(get_irg_start_block(called_graph), visited); + + assert(get_irg_n_anchors(called_graph) == get_irg_n_anchors(irg)); + + for (i = get_irg_n_anchors(called_graph) - 1; i >= 0; --i) { + ir_node *anchor = get_irg_anchor(called_graph, i); + + if (get_irn_visited(anchor) >= visited) { + /* already set above */ + continue; + } + set_irn_link(anchor, get_irg_anchor(irg, i)); + set_irn_visited(anchor, visited); + } /* Initialize for compaction of in arrays */ inc_irg_block_visited(irg);