Avoid use of aux field inside the cfglayout
Jan Hubicka
jh@suse.cz
Mon Jun 16 13:47:00 GMT 2003
Hi,
This patch avoid use of ->aux field in cfg_layout code and replaces it by
specialized pointer. It is needed in order to move other passes that do use
aux fields (like cfgcleanup) to this scheme. I hope that in not-so-distant
future I will be able to actually elliminate most of the fields of rbi
structure.
Honza
Mon Jun 16 17:28:27 CEST 2003 Jan Hubicka <jh@suse.cz>
* basic-block.h (basic_block_def): Add field 'rbi'.
* bb-reorder.c (find_traces, rotate_loop, mark_bb_visited,
find_traces_1_round, copy_bb, connect_traces): Update use of rbi.
* cfg.c (entry_exit_blocks): Add new field.
* cfglayout.c: Include alloc-pool.h;
(cfg_layout_pool): New.
(record_effective_endpoints, fixup_reorder_chain,
fixup_fallthru_exit_predecessor, cfg_layout_duplicate_bb): Update use of rbi.
(cfg_layout_initialize_rbi): New function.
(cfg_layout_initialize): Use it.
(cfg_layout_finalize): Clear rbi fields.
* cfglayout.h (RBI): Kill.
(cfg_layout_initialize_rbi): Declare.
* cfgloopmanip.c (copy_bbs): Use rbi.
(record_exit_edges): Likewise.
(duplicate_loop_to_header_edge): Likewise.
* cfgrtl.c (cfg_layout_create_basic_block): Use cfg_layout_initialize_rbi.
(cfg_layout_split_block): Use rbi.
(cfg_layout_delete_block): Likewise.
* loop-init.c (loop_optimizer_finalize): Likewise.
* loop-unswitch.c (unswitch_loop): Likewise.
* tracer.c (seen, tail_duplicate, layout_superblocks): Likewise.
*** basic-block.h.old2 Mon Jun 16 16:12:38 2003
--- basic-block.h Mon Jun 16 16:13:18 2003
*************** typedef struct basic_block_def {
*** 241,246 ****
--- 241,249 ----
/* Various flags. See BB_* below. */
int flags;
+
+ /* Additional data maintained by cfg_layout routines. */
+ struct reorder_block_def *rbi;
} *basic_block;
#define BB_FREQ_MAX 10000
*** bb-reorder.c.old2 Mon Jun 16 16:19:38 2003
--- bb-reorder.c Mon Jun 16 16:19:53 2003
*************** find_traces (n_traces, traces)
*** 210,216 ****
basic_block bb;
fprintf (rtl_dump_file, "Trace %d (round %d): ", i + 1,
traces[i].round + 1);
! for (bb = traces[i].first; bb != traces[i].last; bb = RBI (bb)->next)
fprintf (rtl_dump_file, "%d [%d] ", bb->index, bb->frequency);
fprintf (rtl_dump_file, "%d [%d]\n", bb->index, bb->frequency);
}
--- 210,216 ----
basic_block bb;
fprintf (rtl_dump_file, "Trace %d (round %d): ", i + 1,
traces[i].round + 1);
! for (bb = traces[i].first; bb != traces[i].last; bb = bb->rbi->next)
fprintf (rtl_dump_file, "%d [%d] ", bb->index, bb->frequency);
fprintf (rtl_dump_file, "%d [%d]\n", bb->index, bb->frequency);
}
*************** rotate_loop (back_edge, trace, trace_n)
*** 245,258 ****
edge e;
for (e = bb->succ; e; e = e->succ_next)
if (e->dest != EXIT_BLOCK_PTR
! && RBI (e->dest)->visited != trace_n
&& (e->flags & EDGE_CAN_FALLTHRU)
&& !(e->flags & EDGE_COMPLEX))
{
if (is_preferred)
{
/* The best edge is preferred. */
! if (!RBI (e->dest)->visited
|| bbd[e->dest->index].start_of_trace >= 0)
{
/* The current edge E is also preferred. */
--- 245,258 ----
edge e;
for (e = bb->succ; e; e = e->succ_next)
if (e->dest != EXIT_BLOCK_PTR
! && e->dest->rbi->visited != trace_n
&& (e->flags & EDGE_CAN_FALLTHRU)
&& !(e->flags & EDGE_COMPLEX))
{
if (is_preferred)
{
/* The best edge is preferred. */
! if (!e->dest->rbi->visited
|| bbd[e->dest->index].start_of_trace >= 0)
{
/* The current edge E is also preferred. */
*************** rotate_loop (back_edge, trace, trace_n)
*** 268,274 ****
}
else
{
! if (!RBI (e->dest)->visited
|| bbd[e->dest->index].start_of_trace >= 0)
{
/* The current edge E is preferred. */
--- 268,274 ----
}
else
{
! if (!e->dest->rbi->visited
|| bbd[e->dest->index].start_of_trace >= 0)
{
/* The current edge E is preferred. */
*************** rotate_loop (back_edge, trace, trace_n)
*** 291,297 ****
}
}
}
! bb = RBI (bb)->next;
}
while (bb != back_edge->dest);
--- 291,297 ----
}
}
}
! bb = bb->rbi->next;
}
while (bb != back_edge->dest);
*************** rotate_loop (back_edge, trace, trace_n)
*** 301,317 ****
the trace. */
if (back_edge->dest == trace->first)
{
! trace->first = RBI (best_bb)->next;
}
else
{
basic_block prev_bb;
for (prev_bb = trace->first;
! RBI (prev_bb)->next != back_edge->dest;
! prev_bb = RBI (prev_bb)->next)
;
! RBI (prev_bb)->next = RBI (best_bb)->next;
/* Try to get rid of uncond jump to cond jump. */
if (prev_bb->succ && !prev_bb->succ->succ_next)
--- 301,317 ----
the trace. */
if (back_edge->dest == trace->first)
{
! trace->first = best_bb->rbi->next;
}
else
{
basic_block prev_bb;
for (prev_bb = trace->first;
! prev_bb->rbi->next != back_edge->dest;
! prev_bb = prev_bb->rbi->next)
;
! prev_bb->rbi->next = best_bb->rbi->next;
/* Try to get rid of uncond jump to cond jump. */
if (prev_bb->succ && !prev_bb->succ->succ_next)
*************** rotate_loop (back_edge, trace, trace_n)
*** 332,338 ****
/* We have not found suitable loop tail so do no rotation. */
best_bb = back_edge->src;
}
! RBI (best_bb)->next = NULL;
return best_bb;
}
--- 332,338 ----
/* We have not found suitable loop tail so do no rotation. */
best_bb = back_edge->src;
}
! best_bb->rbi->next = NULL;
return best_bb;
}
*************** mark_bb_visited (bb, trace)
*** 343,349 ****
basic_block bb;
int trace;
{
! RBI (bb)->visited = trace;
if (bbd[bb->index].heap)
{
fibheap_delete_node (bbd[bb->index].heap, bbd[bb->index].node);
--- 343,349 ----
basic_block bb;
int trace;
{
! bb->rbi->visited = trace;
if (bbd[bb->index].heap)
{
fibheap_delete_node (bbd[bb->index].heap, bbd[bb->index].node);
*************** find_traces_1_round (branch_th, exec_th,
*** 435,442 ****
if (e->dest == EXIT_BLOCK_PTR)
continue;
! if (RBI (e->dest)->visited
! && RBI (e->dest)->visited != *n_traces)
continue;
prob = e->probability;
--- 435,442 ----
if (e->dest == EXIT_BLOCK_PTR)
continue;
! if (e->dest->rbi->visited
! && e->dest->rbi->visited != *n_traces)
continue;
prob = e->probability;
*************** find_traces_1_round (branch_th, exec_th,
*** 468,474 ****
{
if (e == best_edge
|| e->dest == EXIT_BLOCK_PTR
! || RBI (e->dest)->visited)
continue;
key = bb_to_key (e->dest);
--- 468,474 ----
{
if (e == best_edge
|| e->dest == EXIT_BLOCK_PTR
! || e->dest->rbi->visited)
continue;
key = bb_to_key (e->dest);
*************** find_traces_1_round (branch_th, exec_th,
*** 523,529 ****
if (best_edge) /* Suitable successor was found. */
{
! if (RBI (best_edge->dest)->visited == *n_traces)
{
/* We do nothing with one basic block loops. */
if (best_edge->dest != bb)
--- 523,529 ----
if (best_edge) /* Suitable successor was found. */
{
! if (best_edge->dest->rbi->visited == *n_traces)
{
/* We do nothing with one basic block loops. */
if (best_edge->dest != bb)
*************** find_traces_1_round (branch_th, exec_th,
*** 543,549 ****
"Rotating loop %d - %d\n",
best_edge->dest->index, bb->index);
}
! RBI (bb)->next = best_edge->dest;
bb = rotate_loop (best_edge, trace, *n_traces);
}
}
--- 543,549 ----
"Rotating loop %d - %d\n",
best_edge->dest->index, bb->index);
}
! bb->rbi->next = best_edge->dest;
bb = rotate_loop (best_edge, trace, *n_traces);
}
}
*************** find_traces_1_round (branch_th, exec_th,
*** 598,604 ****
if (e != best_edge
&& (e->flags & EDGE_CAN_FALLTHRU)
&& !(e->flags & EDGE_COMPLEX)
! && !RBI (e->dest)->visited
&& !e->dest->pred->pred_next
&& e->dest->succ
&& (e->dest->succ->flags & EDGE_CAN_FALLTHRU)
--- 598,604 ----
if (e != best_edge
&& (e->flags & EDGE_CAN_FALLTHRU)
&& !(e->flags & EDGE_COMPLEX)
! && !e->dest->rbi->visited
&& !e->dest->pred->pred_next
&& e->dest->succ
&& (e->dest->succ->flags & EDGE_CAN_FALLTHRU)
*************** find_traces_1_round (branch_th, exec_th,
*** 614,620 ****
break;
}
! RBI (bb)->next = best_edge->dest;
bb = best_edge->dest;
}
}
--- 614,620 ----
break;
}
! bb->rbi->next = best_edge->dest;
bb = best_edge->dest;
}
}
*************** find_traces_1_round (branch_th, exec_th,
*** 630,636 ****
for (e = bb->succ; e; e = e->succ_next)
{
if (e->dest == EXIT_BLOCK_PTR
! || RBI (e->dest)->visited)
continue;
if (bbd[e->dest->index].heap)
--- 630,636 ----
for (e = bb->succ; e; e = e->succ_next)
{
if (e->dest == EXIT_BLOCK_PTR
! || e->dest->rbi->visited)
continue;
if (bbd[e->dest->index].heap)
*************** copy_bb (old_bb, e, bb, trace)
*** 675,689 ****
new_bb = cfg_layout_duplicate_bb (old_bb, e);
if (e->dest != new_bb)
abort ();
! if (RBI (e->dest)->visited)
abort ();
if (rtl_dump_file)
fprintf (rtl_dump_file,
"Duplicated bb %d (created bb %d)\n",
old_bb->index, new_bb->index);
! RBI (new_bb)->visited = trace;
! RBI (new_bb)->next = RBI (bb)->next;
! RBI (bb)->next = new_bb;
if (new_bb->index >= array_size || last_basic_block > array_size)
{
--- 675,689 ----
new_bb = cfg_layout_duplicate_bb (old_bb, e);
if (e->dest != new_bb)
abort ();
! if (e->dest->rbi->visited)
abort ();
if (rtl_dump_file)
fprintf (rtl_dump_file,
"Duplicated bb %d (created bb %d)\n",
old_bb->index, new_bb->index);
! new_bb->rbi->visited = trace;
! new_bb->rbi->next = bb->rbi->next;
! bb->rbi->next = new_bb;
if (new_bb->index >= array_size || last_basic_block > array_size)
{
*************** connect_traces (n_traces, traces)
*** 853,859 ****
}
if (best)
{
! RBI (best->src)->next = best->dest;
t2 = bbd[best->src->index].end_of_trace;
connected[t2] = true;
if (rtl_dump_file)
--- 853,859 ----
}
if (best)
{
! best->src->rbi->next = best->dest;
t2 = bbd[best->src->index].end_of_trace;
connected[t2] = true;
if (rtl_dump_file)
*************** connect_traces (n_traces, traces)
*** 867,873 ****
}
if (last_trace >= 0)
! RBI (traces[last_trace].last)->next = traces[t2].first;
last_trace = t;
/* Find the successor traces. */
--- 867,873 ----
}
if (last_trace >= 0)
! traces[last_trace].last->rbi->next = traces[t2].first;
last_trace = t;
/* Find the successor traces. */
*************** connect_traces (n_traces, traces)
*** 903,909 ****
best->src->index, best->dest->index);
}
t = bbd[best->dest->index].start_of_trace;
! RBI (traces[last_trace].last)->next = traces[t].first;
connected[t] = true;
last_trace = t;
}
--- 903,909 ----
best->src->index, best->dest->index);
}
t = bbd[best->dest->index].start_of_trace;
! traces[last_trace].last->rbi->next = traces[t].first;
connected[t] = true;
last_trace = t;
}
*************** connect_traces (n_traces, traces)
*** 991,997 ****
if (next_bb && next_bb != EXIT_BLOCK_PTR)
{
t = bbd[next_bb->index].start_of_trace;
! RBI (traces[last_trace].last)->next = traces[t].first;
connected[t] = true;
last_trace = t;
}
--- 991,997 ----
if (next_bb && next_bb != EXIT_BLOCK_PTR)
{
t = bbd[next_bb->index].start_of_trace;
! traces[last_trace].last->rbi->next = traces[t].first;
connected[t] = true;
last_trace = t;
}
*************** connect_traces (n_traces, traces)
*** 1009,1015 ****
basic_block bb;
fprintf (rtl_dump_file, "Final order:\n");
! for (bb = traces[0].first; bb; bb = RBI (bb)->next)
fprintf (rtl_dump_file, "%d ", bb->index);
fprintf (rtl_dump_file, "\n");
fflush (rtl_dump_file);
--- 1009,1015 ----
basic_block bb;
fprintf (rtl_dump_file, "Final order:\n");
! for (bb = traces[0].first; bb; bb = bb->rbi->next)
fprintf (rtl_dump_file, "%d ", bb->index);
fprintf (rtl_dump_file, "\n");
fflush (rtl_dump_file);
*** cfg.c.old2 Mon Jun 16 16:33:17 2003
--- cfg.c Mon Jun 16 16:36:09 2003
*************** struct basic_block_def entry_exit_blocks
*** 113,119 ****
NULL, /* loop_father */
0, /* count */
0, /* frequency */
! 0 /* flags */
},
{
NULL, /* head */
--- 113,120 ----
NULL, /* loop_father */
0, /* count */
0, /* frequency */
! 0, /* flags */
! NULL /* rbi */
},
{
NULL, /* head */
*************** struct basic_block_def entry_exit_blocks
*** 134,140 ****
NULL, /* loop_father */
0, /* count */
0, /* frequency */
! 0 /* flags */
}
};
--- 135,142 ----
NULL, /* loop_father */
0, /* count */
0, /* frequency */
! 0, /* flags */
! NULL /* rbi */
}
};
*** cfglayout.c.old2 Mon Jun 16 16:06:56 2003
--- cfglayout.c Mon Jun 16 16:28:24 2003
*************** Software Foundation, 59 Temple Place - S
*** 34,44 ****
--- 34,47 ----
#include "cfgloop.h"
#include "target.h"
#include "ggc.h"
+ #include "alloc-pool.h"
/* The contents of the current function definition are allocated
in this obstack, and all are freed at the end of the function. */
extern struct obstack flow_obstack;
+ alloc_pool cfg_layout_pool;
+
/* Holds the interesting trailing notes for the function. */
rtx cfg_layout_function_footer;
*************** record_effective_endpoints ()
*** 201,211 ****
rtx end;
if (PREV_INSN (bb->head) && next_insn != bb->head)
! RBI (bb)->header = unlink_insn_chain (next_insn,
PREV_INSN (bb->head));
end = skip_insns_after_block (bb);
if (NEXT_INSN (bb->end) && bb->end != end)
! RBI (bb)->footer = unlink_insn_chain (NEXT_INSN (bb->end), end);
next_insn = NEXT_INSN (bb->end);
}
--- 204,214 ----
rtx end;
if (PREV_INSN (bb->head) && next_insn != bb->head)
! bb->rbi->header = unlink_insn_chain (next_insn,
PREV_INSN (bb->head));
end = skip_insns_after_block (bb);
if (NEXT_INSN (bb->end) && bb->end != end)
! bb->rbi->footer = unlink_insn_chain (NEXT_INSN (bb->end), end);
next_insn = NEXT_INSN (bb->end);
}
*************** fixup_reorder_chain ()
*** 546,561 ****
for (bb = ENTRY_BLOCK_PTR->next_bb, index = 0;
bb != 0;
! bb = RBI (bb)->next, index++)
{
! if (RBI (bb)->header)
{
if (insn)
! NEXT_INSN (insn) = RBI (bb)->header;
else
! set_first_insn (RBI (bb)->header);
! PREV_INSN (RBI (bb)->header) = insn;
! insn = RBI (bb)->header;
while (NEXT_INSN (insn))
insn = NEXT_INSN (insn);
}
--- 549,564 ----
for (bb = ENTRY_BLOCK_PTR->next_bb, index = 0;
bb != 0;
! bb = bb->rbi->next, index++)
{
! if (bb->rbi->header)
{
if (insn)
! NEXT_INSN (insn) = bb->rbi->header;
else
! set_first_insn (bb->rbi->header);
! PREV_INSN (bb->rbi->header) = insn;
! insn = bb->rbi->header;
while (NEXT_INSN (insn))
insn = NEXT_INSN (insn);
}
*************** fixup_reorder_chain ()
*** 565,574 ****
set_first_insn (bb->head);
PREV_INSN (bb->head) = insn;
insn = bb->end;
! if (RBI (bb)->footer)
{
! NEXT_INSN (insn) = RBI (bb)->footer;
! PREV_INSN (RBI (bb)->footer) = insn;
while (NEXT_INSN (insn))
insn = NEXT_INSN (insn);
}
--- 568,577 ----
set_first_insn (bb->head);
PREV_INSN (bb->head) = insn;
insn = bb->end;
! if (bb->rbi->footer)
{
! NEXT_INSN (insn) = bb->rbi->footer;
! PREV_INSN (bb->rbi->footer) = insn;
while (NEXT_INSN (insn))
insn = NEXT_INSN (insn);
}
*************** fixup_reorder_chain ()
*** 592,598 ****
/* Now add jumps and labels as needed to match the blocks new
outgoing edges. */
! for (bb = ENTRY_BLOCK_PTR->next_bb; bb ; bb = RBI (bb)->next)
{
edge e_fall, e_taken, e;
rtx bb_end_insn;
--- 595,601 ----
/* Now add jumps and labels as needed to match the blocks new
outgoing edges. */
! for (bb = ENTRY_BLOCK_PTR->next_bb; bb ; bb = bb->rbi->next)
{
edge e_fall, e_taken, e;
rtx bb_end_insn;
*************** fixup_reorder_chain ()
*** 616,623 ****
if (any_condjump_p (bb_end_insn))
{
/* If the old fallthru is still next, nothing to do. */
! if (RBI (bb)->next == e_fall->dest
! || (!RBI (bb)->next
&& e_fall->dest == EXIT_BLOCK_PTR))
continue;
--- 619,626 ----
if (any_condjump_p (bb_end_insn))
{
/* If the old fallthru is still next, nothing to do. */
! if (bb->rbi->next == e_fall->dest
! || (!bb->rbi->next
&& e_fall->dest == EXIT_BLOCK_PTR))
continue;
*************** fixup_reorder_chain ()
*** 657,663 ****
such as happens at the very end of a function, then we'll
need to add a new unconditional jump. Choose the taken
edge based on known or assumed probability. */
! else if (RBI (bb)->next != e_taken->dest)
{
rtx note = find_reg_note (bb_end_insn, REG_BR_PROB, 0);
--- 660,666 ----
such as happens at the very end of a function, then we'll
need to add a new unconditional jump. Choose the taken
edge based on known or assumed probability. */
! else if (bb->rbi->next != e_taken->dest)
{
rtx note = find_reg_note (bb_end_insn, REG_BR_PROB, 0);
*************** fixup_reorder_chain ()
*** 696,702 ****
#ifdef CASE_DROPS_THROUGH
/* Except for VAX. Since we didn't have predication for the
tablejump, the fallthru block should not have moved. */
! if (RBI (bb)->next == e_fall->dest)
continue;
bb_end_insn = skip_insns_after_block (bb);
#else
--- 699,705 ----
#ifdef CASE_DROPS_THROUGH
/* Except for VAX. Since we didn't have predication for the
tablejump, the fallthru block should not have moved. */
! if (bb->rbi->next == e_fall->dest)
continue;
bb_end_insn = skip_insns_after_block (bb);
#else
*************** fixup_reorder_chain ()
*** 713,723 ****
continue;
/* If the fallthru block is still next, nothing to do. */
! if (RBI (bb)->next == e_fall->dest)
continue;
/* A fallthru to exit block. */
! if (!RBI (bb)->next && e_fall->dest == EXIT_BLOCK_PTR)
continue;
}
--- 716,726 ----
continue;
/* If the fallthru block is still next, nothing to do. */
! if (bb->rbi->next == e_fall->dest)
continue;
/* A fallthru to exit block. */
! if (!bb->rbi->next && e_fall->dest == EXIT_BLOCK_PTR)
continue;
}
*************** fixup_reorder_chain ()
*** 725,734 ****
nb = force_nonfallthru (e_fall);
if (nb)
{
! alloc_aux_for_block (nb, sizeof (struct reorder_block_def));
! RBI (nb)->visited = 1;
! RBI (nb)->next = RBI (bb)->next;
! RBI (bb)->next = nb;
/* Don't process this new block. */
bb = nb;
}
--- 728,737 ----
nb = force_nonfallthru (e_fall);
if (nb)
{
! cfg_layout_initialize_rbi (nb);
! nb->rbi->visited = 1;
! nb->rbi->next = bb->rbi->next;
! bb->rbi->next = nb;
/* Don't process this new block. */
bb = nb;
}
*************** fixup_reorder_chain ()
*** 739,750 ****
if (rtl_dump_file)
{
fprintf (rtl_dump_file, "Reordered sequence:\n");
! for (bb = ENTRY_BLOCK_PTR->next_bb, index = 0; bb; bb = RBI (bb)->next, index ++)
{
fprintf (rtl_dump_file, " %i ", index);
! if (RBI (bb)->original)
fprintf (rtl_dump_file, "duplicate of %i ",
! RBI (bb)->original->index);
else if (forwarder_block_p (bb) && GET_CODE (bb->head) != CODE_LABEL)
fprintf (rtl_dump_file, "compensation ");
else
--- 742,753 ----
if (rtl_dump_file)
{
fprintf (rtl_dump_file, "Reordered sequence:\n");
! for (bb = ENTRY_BLOCK_PTR->next_bb, index = 0; bb; bb = bb->rbi->next, index ++)
{
fprintf (rtl_dump_file, " %i ", index);
! if (bb->rbi->original)
fprintf (rtl_dump_file, "duplicate of %i ",
! bb->rbi->original->index);
else if (forwarder_block_p (bb) && GET_CODE (bb->head) != CODE_LABEL)
fprintf (rtl_dump_file, "compensation ");
else
*************** fixup_reorder_chain ()
*** 757,763 ****
bb = ENTRY_BLOCK_PTR->next_bb;
index = 0;
! for (; bb; prev_bb = bb, bb = RBI (bb)->next, index ++)
{
bb->index = index;
BASIC_BLOCK (index) = bb;
--- 760,766 ----
bb = ENTRY_BLOCK_PTR->next_bb;
index = 0;
! for (; bb; prev_bb = bb, bb = bb->rbi->next, index ++)
{
bb->index = index;
BASIC_BLOCK (index) = bb;
*************** fixup_fallthru_exit_predecessor ()
*** 894,912 ****
if (e->flags & EDGE_FALLTHRU)
bb = e->src;
! if (bb && RBI (bb)->next)
{
basic_block c = ENTRY_BLOCK_PTR->next_bb;
! while (RBI (c)->next != bb)
! c = RBI (c)->next;
! RBI (c)->next = RBI (bb)->next;
! while (RBI (c)->next)
! c = RBI (c)->next;
! RBI (c)->next = bb;
! RBI (bb)->next = NULL;
}
}
--- 897,915 ----
if (e->flags & EDGE_FALLTHRU)
bb = e->src;
! if (bb && bb->rbi->next)
{
basic_block c = ENTRY_BLOCK_PTR->next_bb;
! while (c->rbi->next != bb)
! c = c->rbi->next;
! c->rbi->next = bb->rbi->next;
! while (c->rbi->next)
! c = c->rbi->next;
! c->rbi->next = bb;
! bb->rbi->next = NULL;
}
}
*************** cfg_layout_duplicate_bb (bb, e)
*** 1068,1091 ****
insn ? get_last_insn () : NULL,
EXIT_BLOCK_PTR->prev_bb);
! if (RBI (bb)->header)
{
! insn = RBI (bb)->header;
while (NEXT_INSN (insn))
insn = NEXT_INSN (insn);
! insn = duplicate_insn_chain (RBI (bb)->header, insn);
if (insn)
! RBI (new_bb)->header = unlink_insn_chain (insn, get_last_insn ());
}
! if (RBI (bb)->footer)
{
! insn = RBI (bb)->footer;
while (NEXT_INSN (insn))
insn = NEXT_INSN (insn);
! insn = duplicate_insn_chain (RBI (bb)->footer, insn);
if (insn)
! RBI (new_bb)->footer = unlink_insn_chain (insn, get_last_insn ());
}
if (bb->global_live_at_start)
--- 1071,1094 ----
insn ? get_last_insn () : NULL,
EXIT_BLOCK_PTR->prev_bb);
! if (bb->rbi->header)
{
! insn = bb->rbi->header;
while (NEXT_INSN (insn))
insn = NEXT_INSN (insn);
! insn = duplicate_insn_chain (bb->rbi->header, insn);
if (insn)
! new_bb->rbi->header = unlink_insn_chain (insn, get_last_insn ());
}
! if (bb->rbi->footer)
{
! insn = bb->rbi->footer;
while (NEXT_INSN (insn))
insn = NEXT_INSN (insn);
! insn = duplicate_insn_chain (bb->rbi->footer, insn);
if (insn)
! new_bb->rbi->footer = unlink_insn_chain (insn, get_last_insn ());
}
if (bb->global_live_at_start)
*************** cfg_layout_duplicate_bb (bb, e)
*** 1129,1139 ****
if (bb->frequency < 0)
bb->frequency = 0;
! RBI (new_bb)->original = bb;
! RBI (bb)->copy = new_bb;
return new_bb;
}
/* Main entry point to this module - initialize the datastructures for
CFG layout changes. It keeps LOOPS up-to-date if not null. */
--- 1132,1152 ----
if (bb->frequency < 0)
bb->frequency = 0;
! new_bb->rbi->original = bb;
! bb->rbi->copy = new_bb;
return new_bb;
}
+ void
+ cfg_layout_initialize_rbi (bb)
+ basic_block bb;
+ {
+ if (bb->rbi)
+ abort ();
+ bb->rbi = pool_alloc (cfg_layout_pool);
+ memset (bb->rbi, 0, sizeof (struct reorder_block_def));
+ }
+
/* Main entry point to this module - initialize the datastructures for
CFG layout changes. It keeps LOOPS up-to-date if not null. */
*************** void
*** 1141,1149 ****
cfg_layout_initialize (loops)
struct loops *loops;
{
/* Our algorithm depends on fact that there are now dead jumptables
around the code. */
! alloc_aux_for_blocks (sizeof (struct reorder_block_def));
cfg_layout_rtl_register_cfg_hooks ();
cleanup_unconditional_jumps (loops);
--- 1154,1169 ----
cfg_layout_initialize (loops)
struct loops *loops;
{
+ basic_block bb;
+
/* Our algorithm depends on fact that there are now dead jumptables
around the code. */
! cfg_layout_pool =
! create_alloc_pool ("cfg layout pool", sizeof (struct reorder_block_def),
! n_basic_blocks + 2);
! FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
! cfg_layout_initialize_rbi (bb);
!
cfg_layout_rtl_register_cfg_hooks ();
cleanup_unconditional_jumps (loops);
*************** break_superblocks ()
*** 1186,1191 ****
--- 1206,1213 ----
void
cfg_layout_finalize ()
{
+ basic_block bb;
+
#ifdef ENABLE_CHECKING
verify_flow_info ();
#endif
*************** cfg_layout_finalize ()
*** 1197,1203 ****
verify_insn_chain ();
#endif
! free_aux_for_blocks ();
break_superblocks ();
--- 1219,1227 ----
verify_insn_chain ();
#endif
! free_alloc_pool (cfg_layout_pool);
! FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
! bb->rbi = NULL;
break_superblocks ();
*** cfglayout.h.old2 Mon Jun 16 16:11:52 2003
--- cfglayout.h Mon Jun 16 16:18:58 2003
*************** typedef struct reorder_block_def
*** 33,40 ****
int visited;
} *reorder_block_def;
- #define RBI(BB) ((reorder_block_def) (BB)->aux)
-
extern rtx cfg_layout_function_footer;
extern void cfg_layout_initialize PARAMS ((struct loops *));
--- 33,38 ----
*************** extern bool cfg_layout_can_duplicate_bb_
*** 43,45 ****
--- 41,44 ----
extern basic_block cfg_layout_duplicate_bb PARAMS ((basic_block, edge));
extern void insn_locators_initialize PARAMS ((void));
extern void reemit_insn_block_notes PARAMS ((void));
+ extern void cfg_layout_initialize_rbi PARAMS ((basic_block));
*** cfgloopmanip.c.old2 Mon Jun 16 16:21:08 2003
--- cfgloopmanip.c Mon Jun 16 16:21:53 2003
*************** copy_bbs (bbs, n, entry, latch_edge, new
*** 926,932 ****
/* Duplicate. */
bb = bbs[i];
new_bb = (*new_bbs)[i] = cfg_layout_duplicate_bb (bb, NULL);
! RBI (new_bb)->duplicated = 1;
/* Add to loop. */
add_bb_to_loop (new_bb, bb->loop_father->copy);
add_to_dominance_info (loops->cfg.dom, new_bb);
--- 926,932 ----
/* Duplicate. */
bb = bbs[i];
new_bb = (*new_bbs)[i] = cfg_layout_duplicate_bb (bb, NULL);
! new_bb->rbi->duplicated = 1;
/* Add to loop. */
add_bb_to_loop (new_bb, bb->loop_father->copy);
add_to_dominance_info (loops->cfg.dom, new_bb);
*************** copy_bbs (bbs, n, entry, latch_edge, new
*** 952,958 ****
{
/* For anything else than loop header, just copy it. */
dom_bb = get_immediate_dominator (loops->cfg.dom, bb);
! dom_bb = RBI (dom_bb)->copy;
}
else
{
--- 952,958 ----
{
/* For anything else than loop header, just copy it. */
dom_bb = get_immediate_dominator (loops->cfg.dom, bb);
! dom_bb = dom_bb->rbi->copy;
}
else
{
*************** copy_bbs (bbs, n, entry, latch_edge, new
*** 976,982 ****
e_pred = e->pred_next;
! if (!RBI (src)->duplicated)
continue;
/* Leads to copied loop and it is not latch edge, redirect it. */
--- 976,982 ----
e_pred = e->pred_next;
! if (!src->rbi->duplicated)
continue;
/* Leads to copied loop and it is not latch edge, redirect it. */
*************** copy_bbs (bbs, n, entry, latch_edge, new
*** 985,1008 ****
if (add_irreducible_flag
&& (bb->loop_father == header->loop_father
! || RBI (src)->original->loop_father == header->loop_father))
e->flags |= EDGE_IRREDUCIBLE_LOOP;
}
}
/* Redirect header edge. */
! bb = RBI (latch_edge->src)->copy;
for (e = bb->succ; e->dest != latch_edge->dest; e = e->succ_next);
*header_edge = e;
loop_redirect_edge (*header_edge, header);
/* Redirect entry to copy of header. */
! loop_redirect_edge (entry, RBI (header)->copy);
*copy_header_edge = entry;
/* Clear information about duplicates. */
for (i = 0; i < n; i++)
! RBI ((*new_bbs)[i])->duplicated = 0;
}
/* Check whether LOOP's body can be duplicated. */
--- 985,1008 ----
if (add_irreducible_flag
&& (bb->loop_father == header->loop_father
! || src->rbi->original->loop_father == header->loop_father))
e->flags |= EDGE_IRREDUCIBLE_LOOP;
}
}
/* Redirect header edge. */
! bb = latch_edge->src->rbi->copy;
for (e = bb->succ; e->dest != latch_edge->dest; e = e->succ_next);
*header_edge = e;
loop_redirect_edge (*header_edge, header);
/* Redirect entry to copy of header. */
! loop_redirect_edge (entry, header->rbi->copy);
*copy_header_edge = entry;
/* Clear information about duplicates. */
for (i = 0; i < n; i++)
! (*new_bbs)[i]->rbi->duplicated = 0;
}
/* Check whether LOOP's body can be duplicated. */
*************** record_exit_edges (orig, bbs, nbbs, to_r
*** 1067,1073 ****
return;
}
! for (e = RBI (orig->src)->copy->succ; e; e = e->succ_next)
if (e->dest == orig->dest)
break;
if (!e)
--- 1067,1073 ----
return;
}
! for (e = orig->src->rbi->copy->succ; e; e = e->succ_next)
if (e->dest == orig->dest)
break;
if (!e)
*************** duplicate_loop_to_header_edge (loop, e,
*** 1254,1260 ****
copy_bbs (bbs, n, e, latch_edge, &new_bbs, loops,
&e, &he, add_irreducible_flag);
if (is_latch)
! loop->latch = RBI (latch)->copy;
/* Record exit edges in this copy. */
if (TEST_BIT (wont_exit, j + 1))
--- 1254,1260 ----
copy_bbs (bbs, n, e, latch_edge, &new_bbs, loops,
&e, &he, add_irreducible_flag);
if (is_latch)
! loop->latch = latch->rbi->copy;
/* Record exit edges in this copy. */
if (TEST_BIT (wont_exit, j + 1))
*************** duplicate_loop_to_header_edge (loop, e,
*** 1288,1294 ****
if (!first_active_latch)
{
memcpy (first_active, new_bbs, n * sizeof (basic_block));
! first_active_latch = RBI (latch)->copy;
}
free (new_bbs);
--- 1288,1294 ----
if (!first_active_latch)
{
memcpy (first_active, new_bbs, n * sizeof (basic_block));
! first_active_latch = latch->rbi->copy;
}
free (new_bbs);
*************** duplicate_loop_to_header_edge (loop, e,
*** 1296,1306 ****
/* Original loop header is dominated by latch copy
if we duplicated on its only entry edge. */
if (!is_latch && !header->pred->pred_next->pred_next)
! set_immediate_dominator (loops->cfg.dom, header, RBI (latch)->copy);
if (is_latch && j == 0)
{
/* Update edge from latch. */
! for (latch_edge = RBI (header)->copy->pred;
latch_edge->src != latch;
latch_edge = latch_edge->pred_next);
}
--- 1296,1306 ----
/* Original loop header is dominated by latch copy
if we duplicated on its only entry edge. */
if (!is_latch && !header->pred->pred_next->pred_next)
! set_immediate_dominator (loops->cfg.dom, header, latch->rbi->copy);
if (is_latch && j == 0)
{
/* Update edge from latch. */
! for (latch_edge = header->rbi->copy->pred;
latch_edge->src != latch;
latch_edge = latch_edge->pred_next);
}
*** cfgrtl.c.old2 Mon Jun 16 16:19:14 2003
--- cfgrtl.c Mon Jun 16 16:23:13 2003
*************** cfg_layout_create_basic_block (head, end
*** 361,367 ****
{
basic_block newbb = rtl_create_basic_block (head, end, after);
! alloc_aux_for_block (newbb, sizeof (struct reorder_block_def));
return newbb;
}
--- 361,367 ----
{
basic_block newbb = rtl_create_basic_block (head, end, after);
! cfg_layout_initialize_rbi (newbb);
return newbb;
}
*************** cfg_layout_split_block (bb, insnp)
*** 2311,2318 ****
edge fallthru = rtl_split_block (bb, insn);
! RBI (fallthru->dest)->footer = RBI (fallthru->src)->footer;
! RBI (fallthru->src)->footer = NULL;
return fallthru;
}
--- 2311,2318 ----
edge fallthru = rtl_split_block (bb, insn);
! fallthru->dest->rbi->footer = fallthru->src->rbi->footer;
! fallthru->src->rbi->footer = NULL;
return fallthru;
}
*************** cfg_layout_delete_block (bb)
*** 2389,2414 ****
{
rtx insn, next, prev = PREV_INSN (bb->head), *to, remaints;
! if (RBI (bb)->header)
{
next = bb->head;
if (prev)
! NEXT_INSN (prev) = RBI (bb)->header;
else
! set_first_insn (RBI (bb)->header);
! PREV_INSN (RBI (bb)->header) = prev;
! insn = RBI (bb)->header;
while (NEXT_INSN (insn))
insn = NEXT_INSN (insn);
NEXT_INSN (insn) = next;
PREV_INSN (next) = insn;
}
next = NEXT_INSN (bb->end);
! if (RBI (bb)->footer)
{
insn = bb->end;
! NEXT_INSN (insn) = RBI (bb)->footer;
! PREV_INSN (RBI (bb)->footer) = insn;
while (NEXT_INSN (insn))
insn = NEXT_INSN (insn);
NEXT_INSN (insn) = next;
--- 2389,2414 ----
{
rtx insn, next, prev = PREV_INSN (bb->head), *to, remaints;
! if (bb->rbi->header)
{
next = bb->head;
if (prev)
! NEXT_INSN (prev) = bb->rbi->header;
else
! set_first_insn (bb->rbi->header);
! PREV_INSN (bb->rbi->header) = prev;
! insn = bb->rbi->header;
while (NEXT_INSN (insn))
insn = NEXT_INSN (insn);
NEXT_INSN (insn) = next;
PREV_INSN (next) = insn;
}
next = NEXT_INSN (bb->end);
! if (bb->rbi->footer)
{
insn = bb->end;
! NEXT_INSN (insn) = bb->rbi->footer;
! PREV_INSN (bb->rbi->footer) = insn;
while (NEXT_INSN (insn))
insn = NEXT_INSN (insn);
NEXT_INSN (insn) = next;
*************** cfg_layout_delete_block (bb)
*** 2418,2424 ****
set_last_insn (insn);
}
if (bb->next_bb != EXIT_BLOCK_PTR)
! to = &RBI(bb->next_bb)->header;
else
to = &cfg_layout_function_footer;
rtl_delete_block (bb);
--- 2418,2424 ----
set_last_insn (insn);
}
if (bb->next_bb != EXIT_BLOCK_PTR)
! to = &bb->next_bb->rbi->header;
else
to = &cfg_layout_function_footer;
rtl_delete_block (bb);
*** loop-init.c.old2 Mon Jun 16 16:22:29 2003
--- loop-init.c Mon Jun 16 16:22:30 2003
*************** loop_optimizer_finalize (loops, dumpfile
*** 94,100 ****
/* Make chain. */
FOR_EACH_BB (bb)
if (bb->next_bb != EXIT_BLOCK_PTR)
! RBI (bb)->next = bb->next_bb;
/* Another dump. */
flow_loops_dump (loops, dumpfile, NULL, 1);
--- 94,100 ----
/* Make chain. */
FOR_EACH_BB (bb)
if (bb->next_bb != EXIT_BLOCK_PTR)
! bb->rbi->next = bb->next_bb;
/* Another dump. */
flow_loops_dump (loops, dumpfile, NULL, 1);
*** loop-unswitch.c.old2 Mon Jun 16 16:22:39 2003
--- loop-unswitch.c Mon Jun 16 16:22:45 2003
*************** unswitch_loop (loops, loop, unswitch_on)
*** 377,383 ****
entry->flags |= irred_flag;
/* Record the block with condition we unswitch on. */
! unswitch_on_alt = RBI (unswitch_on)->copy;
/* Make a copy of the block containing the condition; we will use
it as switch to decide which loop we want to use. */
--- 377,383 ----
entry->flags |= irred_flag;
/* Record the block with condition we unswitch on. */
! unswitch_on_alt = unswitch_on->rbi->copy;
/* Make a copy of the block containing the condition; we will use
it as switch to decide which loop we want to use. */
*************** unswitch_loop (loops, loop, unswitch_on)
*** 395,408 ****
switch_bb->succ->succ_next->flags &= ~EDGE_IRREDUCIBLE_LOOP;
}
add_to_dominance_info (loops->cfg.dom, switch_bb);
! RBI (unswitch_on)->copy = unswitch_on_alt;
/* Loopify from the copy of LOOP body, constructing the new loop. */
! for (latch_edge = RBI (loop->latch)->copy->succ;
latch_edge->dest != loop->header;
latch_edge = latch_edge->succ_next);
nloop = loopify (loops, latch_edge,
! RBI (loop->header)->copy->pred, switch_bb);
/* Remove branches that are now unreachable in new loops. We rely on the
fact that cfg_layout_duplicate_bb reverses list of edges. */
--- 395,408 ----
switch_bb->succ->succ_next->flags &= ~EDGE_IRREDUCIBLE_LOOP;
}
add_to_dominance_info (loops->cfg.dom, switch_bb);
! unswitch_on->rbi->copy = unswitch_on_alt;
/* Loopify from the copy of LOOP body, constructing the new loop. */
! for (latch_edge = loop->latch->rbi->copy->succ;
latch_edge->dest != loop->header;
latch_edge = latch_edge->succ_next);
nloop = loopify (loops, latch_edge,
! loop->header->rbi->copy->pred, switch_bb);
/* Remove branches that are now unreachable in new loops. We rely on the
fact that cfg_layout_duplicate_bb reverses list of edges. */
*** tracer.c.old2 Mon Jun 16 16:20:54 2003
--- tracer.c Mon Jun 16 16:20:57 2003
*************** static int branch_ratio_cutoff;
*** 65,71 ****
/* Return true if BB has been seen - it is connected to some trace
already. */
! #define seen(bb) (RBI (bb)->visited || RBI (bb)->next)
/* Return true if we should ignore the basic block for purposes of tracing. */
static bool
--- 65,71 ----
/* Return true if BB has been seen - it is connected to some trace
already. */
! #define seen(bb) (bb->rbi->visited || bb->rbi->next)
/* Return true if we should ignore the basic block for purposes of tracing. */
static bool
*************** tail_duplicate ()
*** 296,303 ****
fprintf (rtl_dump_file, "Duplicated %i as %i [%i]\n",
old->index, bb2->index, bb2->frequency);
}
! RBI (bb)->next = bb2;
! RBI (bb2)->visited = 1;
bb = bb2;
/* In case the trace became infrequent, stop duplicating. */
if (ignore_bb_p (bb))
--- 296,303 ----
fprintf (rtl_dump_file, "Duplicated %i as %i [%i]\n",
old->index, bb2->index, bb2->frequency);
}
! bb->rbi->next = bb2;
! bb2->rbi->visited = 1;
bb = bb2;
/* In case the trace became infrequent, stop duplicating. */
if (ignore_bb_p (bb))
*************** layout_superblocks ()
*** 331,358 ****
while (bb != EXIT_BLOCK_PTR)
{
edge e, best = NULL;
! while (RBI (end)->next)
! end = RBI (end)->next;
for (e = end->succ; e; e = e->succ_next)
if (e->dest != EXIT_BLOCK_PTR
&& e->dest != ENTRY_BLOCK_PTR->succ->dest
! && !RBI (e->dest)->visited
&& (!best || EDGE_FREQUENCY (e) > EDGE_FREQUENCY (best)))
best = e;
if (best)
{
! RBI (end)->next = best->dest;
! RBI (best->dest)->visited = 1;
}
else
for (; bb != EXIT_BLOCK_PTR; bb = bb->next_bb)
{
! if (!RBI (bb)->visited)
{
! RBI (end)->next = bb;
! RBI (bb)->visited = 1;
break;
}
}
--- 331,358 ----
while (bb != EXIT_BLOCK_PTR)
{
edge e, best = NULL;
! while (end->rbi->next)
! end = end->rbi->next;
for (e = end->succ; e; e = e->succ_next)
if (e->dest != EXIT_BLOCK_PTR
&& e->dest != ENTRY_BLOCK_PTR->succ->dest
! && !e->dest->rbi->visited
&& (!best || EDGE_FREQUENCY (e) > EDGE_FREQUENCY (best)))
best = e;
if (best)
{
! end->rbi->next = best->dest;
! best->dest->rbi->visited = 1;
}
else
for (; bb != EXIT_BLOCK_PTR; bb = bb->next_bb)
{
! if (!bb->rbi->visited)
{
! end->rbi->next = bb;
! bb->rbi->visited = 1;
break;
}
}
More information about the Gcc-patches
mailing list