#include "cfg.h"
#include "cfganal.h"
#include "basic-block.h"
-#include "fibheap.h"
#include "flags.h"
#include "params.h"
#include "coverage.h"
#include "tree-ssa.h"
#include "tree-inline.h"
#include "cfgloop.h"
+#include "fibonacci_heap.h"
static int count_insns (basic_block);
static bool ignore_bb_p (const_basic_block);
static bool
tail_duplicate (void)
{
- fibnode_t *blocks = XCNEWVEC (fibnode_t, last_basic_block_for_fn (cfun));
+ auto_vec<fibonacci_node<long, basic_block_def>*> blocks;
+ blocks.safe_grow_cleared (last_basic_block_for_fn (cfun));
+
basic_block *trace = XNEWVEC (basic_block, n_basic_blocks_for_fn (cfun));
int *counts = XNEWVEC (int, last_basic_block_for_fn (cfun));
int ninsns = 0, nduplicated = 0;
gcov_type weighted_insns = 0, traced_insns = 0;
- fibheap_t heap = fibheap_new ();
+ fibonacci_heap<long, basic_block_def> heap (LONG_MIN);
gcov_type cover_insns;
int max_dup_insns;
basic_block bb;
{
int n = count_insns (bb);
if (!ignore_bb_p (bb))
- blocks[bb->index] = fibheap_insert (heap, -bb->frequency,
- bb);
+ blocks[bb->index] = heap.insert (-bb->frequency, bb);
counts [bb->index] = n;
ninsns += n;
max_dup_insns = (ninsns * PARAM_VALUE (TRACER_MAX_CODE_GROWTH) + 50) / 100;
while (traced_insns < cover_insns && nduplicated < max_dup_insns
- && !fibheap_empty (heap))
+ && !heap.empty ())
{
- basic_block bb = (basic_block) fibheap_extract_min (heap);
+ basic_block bb = heap.extract_min ();
int n, pos;
if (!bb)
traced_insns += bb->frequency * counts [bb->index];
if (blocks[bb->index])
{
- fibheap_delete_node (heap, blocks[bb->index]);
+ heap.delete_node (blocks[bb->index]);
blocks[bb->index] = NULL;
}
if (blocks[bb2->index])
{
- fibheap_delete_node (heap, blocks[bb2->index]);
+ heap.delete_node (blocks[bb2->index]);
blocks[bb2->index] = NULL;
}
traced_insns += bb2->frequency * counts [bb2->index];
/* Reconsider the original copy of block we've duplicated.
Removing the most common predecessor may make it to be
head. */
- blocks[bb2->index] =
- fibheap_insert (heap, -bb2->frequency, bb2);
+ blocks[bb2->index] = heap.insert (-bb2->frequency, bb2);
if (dump_file)
fprintf (dump_file, "Duplicated %i as %i [%i]\n",
free_original_copy_tables ();
sbitmap_free (bb_seen);
- free (blocks);
free (trace);
free (counts);
- fibheap_delete (heap);
return changed;
}