From: Martin Liska Date: Tue, 18 Nov 2014 16:15:52 +0000 (+0100) Subject: tracer ported to new fibonacci_heap data structure. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=dd7bda5eb2998b92beb0c821ccb9b76cf54d24b5;p=gcc.git tracer ported to new fibonacci_heap data structure. * tracer.c (tail_duplicate): New fibonacci_heap class is used. From-SVN: r217722 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3f285a57a61..6d2d5f7a72e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2014-11-18 Martin Liska + + * tracer.c (tail_duplicate): New fibonacci_heap class is used. + 2014-11-18 Martin Liska * bb-reorder.c (mark_bb_visited): New fibonacci_heap is used. diff --git a/gcc/tracer.c b/gcc/tracer.c index b3a412cec49..cecefdcd8c4 100644 --- a/gcc/tracer.c +++ b/gcc/tracer.c @@ -52,7 +52,6 @@ #include "cfg.h" #include "cfganal.h" #include "basic-block.h" -#include "fibheap.h" #include "flags.h" #include "params.h" #include "coverage.h" @@ -67,6 +66,7 @@ #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); @@ -241,12 +241,14 @@ find_trace (basic_block bb, basic_block *trace) static bool tail_duplicate (void) { - fibnode_t *blocks = XCNEWVEC (fibnode_t, last_basic_block_for_fn (cfun)); + auto_vec*> 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 heap (LONG_MIN); gcov_type cover_insns; int max_dup_insns; basic_block bb; @@ -271,8 +273,7 @@ tail_duplicate (void) { 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; @@ -287,9 +288,9 @@ tail_duplicate (void) 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) @@ -307,7 +308,7 @@ tail_duplicate (void) 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; } @@ -317,7 +318,7 @@ tail_duplicate (void) 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]; @@ -344,8 +345,7 @@ tail_duplicate (void) /* 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", @@ -370,10 +370,8 @@ tail_duplicate (void) free_original_copy_tables (); sbitmap_free (bb_seen); - free (blocks); free (trace); free (counts); - fibheap_delete (heap); return changed; }