X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Finstrument.c;h=9c569eeec01892223d706741ed741af4385ea949;hb=8940e28146a93b189ad4e6a6ed409ebf5631eacf;hp=019fbf2d5d9fb9708e9fcf22bb5744aeb41d39d1;hpb=f8cc15664f571aa7ef89d6f6bc8d5bd2b8ca7d53;p=libfirm diff --git a/ir/ir/instrument.c b/ir/ir/instrument.c index 019fbf2d5..9c569eeec 100644 --- a/ir/ir/instrument.c +++ b/ir/ir/instrument.c @@ -1,20 +1,6 @@ /* - * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. - * * This file is part of libFirm. - * - * This file may be distributed and/or modified under the terms of the - * GNU General Public License version 2 as published by the Free Software - * Foundation and appearing in the file LICENSE.GPL included in the - * packaging of this file. - * - * Licensees holding valid libFirm Professional Edition licenses may use - * this file in accordance with the libFirm Commercial License. - * Agreement provided with the Software. - * - * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. + * Copyright (C) 2012 University of Karlsruhe. */ /** @@ -31,30 +17,22 @@ #include "ircons.h" #include "instrument.h" -/** - * Adds a Call at the beginning of the given irg. - */ void instrument_initcall(ir_graph *irg, ir_entity *ent) { - const ir_edge_t *edge; - ir_node *initial_exec; - ir_node *initial_mem; - ir_node *start_block; - ir_node *adr, *call, *new_mem; - ir_node *first_block = NULL; + ir_node *initial_exec; + ir_node *first_block = NULL; int i, idx, need_new_block; symconst_symbol sym; - edges_assure(irg); + assure_edges(irg); /* find the first block */ initial_exec = get_irg_initial_exec(irg); - start_block = get_irg_start_block(irg); foreach_out_edge(initial_exec, edge) { ir_node *succ = get_edge_src_irn(edge); - if (succ != start_block && is_Block(succ)) { + if (is_Block(succ)) { /* found the first block */ first_block = succ; break; @@ -86,14 +64,12 @@ void instrument_initcall(ir_graph *irg, ir_entity *ent) /* place the call */ sym.entity_p = ent; - adr = new_r_SymConst(irg, mode_P_code, sym, symconst_addr_ent); - - call = new_r_Call(first_block, get_irg_no_mem(irg), adr, 0, NULL, get_entity_type(ent)); - new_mem = new_r_Proj(call, mode_M, pn_Call_M); + ir_node *const adr = new_r_SymConst(irg, mode_P_code, sym, symconst_addr_ent); + ir_node *const initial_mem = get_irg_initial_mem(irg); + ir_node *const call = new_r_Call(first_block, initial_mem, adr, 0, NULL, get_entity_type(ent)); + ir_node *const new_mem = new_r_Proj(call, mode_M, pn_Call_M); - initial_mem = get_irg_initial_mem(irg); - edges_reroute(initial_mem, new_mem); + edges_reroute_except(initial_mem, new_mem, call); /* beware: reroute routes anchor edges also, revert this */ set_irg_initial_mem(irg, initial_mem); - set_Call_mem(call, initial_mem); }