+ int i;
+ ir_node *endbb = get_irg_end_block(irg);
+ fix_env env;
+
+ set_current_ir_graph(irg);
+
+ /* generate a symbolic constant pointing to the count array */
+ sym.entity_p = bblock_counts;
+ wd.symconst = new_r_SymConst(irg, get_irg_start_block(irg), sym, symconst_addr_ent);
+
+ irg_block_walk_graph(irg, block_id_walker, NULL, &wd);
+ env.start_block = get_irg_start_block(irg);
+ env.end_block = get_irg_end_block(irg);
+ set_irn_link(env.start_block, get_irg_no_mem(irg));
+ irg_block_walk_graph(irg, fix_ssa, NULL, &env);
+ for (i = get_Block_n_cfgpreds(endbb) - 1; i >= 0; --i) {
+ ir_node *node = skip_Proj(get_Block_cfgpred(endbb, i));
+ ir_node *bb = get_Block_cfgpred_block(endbb, i);
+ ir_node *sync;
+ ir_node *ins[2];
+
+ switch (get_irn_opcode(node)) {
+ case iro_Return:
+ ins[0] = get_irn_link(bb);
+ ins[1] = get_Return_mem(node);
+ sync = new_r_Sync(irg, bb, 2, ins);
+ set_Return_mem(node, sync);
+ break;
+ case iro_Raise:
+ ins[0] = get_irn_link(bb);
+ ins[1] = get_Raise_mem(node);
+ sync = new_r_Sync(irg, bb, 2, ins);
+ set_Raise_mem(node, sync);
+ break;
+ default:
+ /* a fragile's op exception. There should be another path to End,
+ so ignore it */
+ assert(is_fragile_op(node) && "unexpected End control flow predecessor");
+ }
+ }
+ }
+ set_array_entity_values(bblock_id, tarval_array, n_blocks);
+
+ if (flags & profile_with_locations) {
+ /* build the initializer for the locations */
+ rem = current_ir_graph;
+ current_ir_graph = get_const_code_irg();
+ ent = get_array_element_entity(loc_type);
+ set_entity_variability(ent_locations, variability_constant);
+ for (i = 0; i < n_blocks; ++i) {
+ compound_graph_path *path;
+ tarval *tv;
+ ir_node *n;
+
+ /* lineno */
+ path = new_compound_graph_path(loc_type, 2);
+ set_compound_graph_path_array_index(path, 0, i);
+ set_compound_graph_path_node(path, 0, ent);
+ set_compound_graph_path_node(path, 1, loc_lineno);
+ tv = new_tarval_from_long(wd.locs[i].lineno, mode_Iu);
+ add_compound_ent_value_w_path(ent_locations, new_Const(mode_Iu, tv), path);
+
+ /* name */
+ path = new_compound_graph_path(loc_type, 2);
+ set_compound_graph_path_array_index(path, 0, i);
+ set_compound_graph_path_node(path, 0, ent);
+ set_compound_graph_path_node(path, 1, loc_name);
+ if (wd.locs[i].fname) {
+ sym.entity_p = wd.locs[i].fname;
+ n = new_SymConst(sym, symconst_addr_ent);
+ } else {
+ n = new_Const(mode_P_data, get_mode_null(mode_P_data));
+ }
+ add_compound_ent_value_w_path(ent_locations, n, path);
+ }
+ pmap_destroy(wd.fname_map);
+ }
+ return gen_initializer_irg(ent_filename, bblock_id, bblock_counts, n_blocks);
+}