Mercurial > hg > CbC > CbC_gcc
comparison gcc/cfghooks.c @ 132:d34655255c78
update gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 10:21:07 +0900 |
parents | 84e7813d76e9 |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
130:e108057fa461 | 132:d34655255c78 |
---|---|
1 /* Hooks for cfg representation specific functions. | 1 /* Hooks for cfg representation specific functions. |
2 Copyright (C) 2003-2017 Free Software Foundation, Inc. | 2 Copyright (C) 2003-2018 Free Software Foundation, Inc. |
3 Contributed by Sebastian Pop <s.pop@laposte.net> | 3 Contributed by Sebastian Pop <s.pop@laposte.net> |
4 | 4 |
5 This file is part of GCC. | 5 This file is part of GCC. |
6 | 6 |
7 GCC is free software; you can redistribute it and/or modify | 7 GCC is free software; you can redistribute it and/or modify |
144 if (!bb->count.verify ()) | 144 if (!bb->count.verify ()) |
145 { | 145 { |
146 error ("verify_flow_info: Wrong count of block %i", bb->index); | 146 error ("verify_flow_info: Wrong count of block %i", bb->index); |
147 err = 1; | 147 err = 1; |
148 } | 148 } |
149 if (bb->frequency < 0) | 149 /* FIXME: Graphite and SLJL and target code still tends to produce |
150 { | 150 edges with no probablity. */ |
151 error ("verify_flow_info: Wrong frequency of block %i %i", | 151 if (profile_status_for_fn (cfun) >= PROFILE_GUESSED |
152 bb->index, bb->frequency); | 152 && !bb->count.initialized_p () && !flag_graphite && 0) |
153 { | |
154 error ("verify_flow_info: Missing count of block %i", bb->index); | |
153 err = 1; | 155 err = 1; |
154 } | 156 } |
155 | 157 |
156 FOR_EACH_EDGE (e, ei, bb->succs) | 158 FOR_EACH_EDGE (e, ei, bb->succs) |
157 { | 159 { |
162 err = 1; | 164 err = 1; |
163 } | 165 } |
164 /* FIXME: Graphite and SLJL and target code still tends to produce | 166 /* FIXME: Graphite and SLJL and target code still tends to produce |
165 edges with no probablity. */ | 167 edges with no probablity. */ |
166 if (profile_status_for_fn (cfun) >= PROFILE_GUESSED | 168 if (profile_status_for_fn (cfun) >= PROFILE_GUESSED |
167 && !e->probability.initialized_p () && 0) | 169 && !e->probability.initialized_p () && !flag_graphite && 0) |
168 { | 170 { |
169 error ("Uninitialized probability of edge %i->%i", e->src->index, | 171 error ("Uninitialized probability of edge %i->%i", e->src->index, |
170 e->dest->index); | 172 e->dest->index); |
171 err = 1; | 173 err = 1; |
172 } | 174 } |
284 } | 286 } |
285 | 287 |
286 DEBUG_FUNCTION void | 288 DEBUG_FUNCTION void |
287 debug (basic_block_def &ref) | 289 debug (basic_block_def &ref) |
288 { | 290 { |
289 dump_bb (stderr, &ref, 0, 0); | 291 dump_bb (stderr, &ref, 0, TDF_NONE); |
290 } | 292 } |
291 | 293 |
292 DEBUG_FUNCTION void | 294 DEBUG_FUNCTION void |
293 debug (basic_block_def *ptr) | 295 debug (basic_block_def *ptr) |
294 { | 296 { |
296 debug (*ptr); | 298 debug (*ptr); |
297 else | 299 else |
298 fprintf (stderr, "<nil>\n"); | 300 fprintf (stderr, "<nil>\n"); |
299 } | 301 } |
300 | 302 |
303 static void | |
304 debug_slim (basic_block ptr) | |
305 { | |
306 fprintf (stderr, "<basic_block %p (%d)>", (void *) ptr, ptr->index); | |
307 } | |
308 | |
309 DEFINE_DEBUG_VEC (basic_block_def *) | |
310 DEFINE_DEBUG_HASH_SET (basic_block_def *) | |
301 | 311 |
302 /* Dumps basic block BB to pretty-printer PP, for use as a label of | 312 /* Dumps basic block BB to pretty-printer PP, for use as a label of |
303 a DOT graph record-node. The implementation of this hook is | 313 a DOT graph record-node. The implementation of this hook is |
304 expected to write the label to the stream that is attached to PP. | 314 expected to write the label to the stream that is attached to PP. |
305 Field separators between instructions are pipe characters printed | 315 Field separators between instructions are pipe characters printed |
313 internal_error ("%s does not support dump_bb_for_graph", | 323 internal_error ("%s does not support dump_bb_for_graph", |
314 cfg_hooks->name); | 324 cfg_hooks->name); |
315 /* TODO: Add pretty printer for counter. */ | 325 /* TODO: Add pretty printer for counter. */ |
316 if (bb->count.initialized_p ()) | 326 if (bb->count.initialized_p ()) |
317 pp_printf (pp, "COUNT:" "%" PRId64, bb->count.to_gcov_type ()); | 327 pp_printf (pp, "COUNT:" "%" PRId64, bb->count.to_gcov_type ()); |
318 pp_printf (pp, " FREQ:%i |", bb->frequency); | |
319 pp_write_text_to_stream (pp); | 328 pp_write_text_to_stream (pp); |
320 if (!(dump_flags & TDF_SLIM)) | 329 if (!(dump_flags & TDF_SLIM)) |
321 cfg_hooks->dump_bb_for_graph (pp, bb); | 330 cfg_hooks->dump_bb_for_graph (pp, bb); |
322 } | 331 } |
323 | 332 |
511 new_bb = cfg_hooks->split_block (bb, i); | 520 new_bb = cfg_hooks->split_block (bb, i); |
512 if (!new_bb) | 521 if (!new_bb) |
513 return NULL; | 522 return NULL; |
514 | 523 |
515 new_bb->count = bb->count; | 524 new_bb->count = bb->count; |
516 new_bb->frequency = bb->frequency; | |
517 new_bb->discriminator = bb->discriminator; | 525 new_bb->discriminator = bb->discriminator; |
518 | 526 |
519 if (dom_info_available_p (CDI_DOMINATORS)) | 527 if (dom_info_available_p (CDI_DOMINATORS)) |
520 { | 528 { |
521 redirect_immediate_dominators (CDI_DOMINATORS, bb, new_bb); | 529 redirect_immediate_dominators (CDI_DOMINATORS, bb, new_bb); |
624 basic_block | 632 basic_block |
625 split_edge (edge e) | 633 split_edge (edge e) |
626 { | 634 { |
627 basic_block ret; | 635 basic_block ret; |
628 profile_count count = e->count (); | 636 profile_count count = e->count (); |
629 int freq = EDGE_FREQUENCY (e); | |
630 edge f; | 637 edge f; |
631 bool irr = (e->flags & EDGE_IRREDUCIBLE_LOOP) != 0; | 638 bool irr = (e->flags & EDGE_IRREDUCIBLE_LOOP) != 0; |
632 struct loop *loop; | 639 struct loop *loop; |
633 basic_block src = e->src, dest = e->dest; | 640 basic_block src = e->src, dest = e->dest; |
634 | 641 |
638 if (current_loops != NULL) | 645 if (current_loops != NULL) |
639 rescan_loop_exit (e, false, true); | 646 rescan_loop_exit (e, false, true); |
640 | 647 |
641 ret = cfg_hooks->split_edge (e); | 648 ret = cfg_hooks->split_edge (e); |
642 ret->count = count; | 649 ret->count = count; |
643 ret->frequency = freq; | |
644 single_succ_edge (ret)->probability = profile_probability::always (); | 650 single_succ_edge (ret)->probability = profile_probability::always (); |
645 | 651 |
646 if (irr) | 652 if (irr) |
647 { | 653 { |
648 ret->flags |= BB_IRREDUCIBLE_LOOP; | 654 ret->flags |= BB_IRREDUCIBLE_LOOP; |
867 cfg_hooks->name); | 873 cfg_hooks->name); |
868 | 874 |
869 fallthru = split_block_after_labels (bb); | 875 fallthru = split_block_after_labels (bb); |
870 dummy = fallthru->src; | 876 dummy = fallthru->src; |
871 dummy->count = profile_count::zero (); | 877 dummy->count = profile_count::zero (); |
872 dummy->frequency = 0; | |
873 bb = fallthru->dest; | 878 bb = fallthru->dest; |
874 | 879 |
875 /* Redirect back edges we want to keep. */ | 880 /* Redirect back edges we want to keep. */ |
876 for (ei = ei_start (dummy->preds); (e = ei_safe_edge (ei)); ) | 881 for (ei = ei_start (dummy->preds); (e = ei_safe_edge (ei)); ) |
877 { | 882 { |
878 basic_block e_src; | 883 basic_block e_src; |
879 | 884 |
880 if (redirect_edge_p (e)) | 885 if (redirect_edge_p (e)) |
881 { | 886 { |
882 dummy->frequency += EDGE_FREQUENCY (e); | |
883 if (dummy->frequency > BB_FREQ_MAX) | |
884 dummy->frequency = BB_FREQ_MAX; | |
885 | |
886 dummy->count += e->count (); | 887 dummy->count += e->count (); |
887 ei_next (&ei); | 888 ei_next (&ei); |
888 continue; | 889 continue; |
889 } | 890 } |
890 | 891 |
1099 if (e) | 1100 if (e) |
1100 { | 1101 { |
1101 new_bb->count = new_count; | 1102 new_bb->count = new_count; |
1102 bb->count -= new_count; | 1103 bb->count -= new_count; |
1103 | 1104 |
1104 new_bb->frequency = EDGE_FREQUENCY (e); | |
1105 bb->frequency -= EDGE_FREQUENCY (e); | |
1106 | |
1107 redirect_edge_and_branch_force (e, new_bb); | 1105 redirect_edge_and_branch_force (e, new_bb); |
1108 | |
1109 if (bb->frequency < 0) | |
1110 bb->frequency = 0; | |
1111 } | 1106 } |
1112 else | 1107 else |
1113 { | 1108 new_bb->count = bb->count; |
1114 new_bb->count = bb->count; | |
1115 new_bb->frequency = bb->frequency; | |
1116 } | |
1117 | 1109 |
1118 set_bb_original (new_bb, bb); | 1110 set_bb_original (new_bb, bb); |
1119 set_bb_copy (bb, new_bb); | 1111 set_bb_copy (bb, new_bb); |
1120 | 1112 |
1121 /* Add the new block to the copy of the loop of BB, or directly to the loop | 1113 /* Add the new block to the copy of the loop of BB, or directly to the loop |
1461 record->num_mismatched_count_out[after_pass]++; | 1453 record->num_mismatched_count_out[after_pass]++; |
1462 } | 1454 } |
1463 if (bb != ENTRY_BLOCK_PTR_FOR_FN (cfun) | 1455 if (bb != ENTRY_BLOCK_PTR_FOR_FN (cfun) |
1464 && profile_status_for_fn (cfun) != PROFILE_ABSENT) | 1456 && profile_status_for_fn (cfun) != PROFILE_ABSENT) |
1465 { | 1457 { |
1466 int sum = 0; | |
1467 FOR_EACH_EDGE (e, ei, bb->preds) | |
1468 sum += EDGE_FREQUENCY (e); | |
1469 if (abs (sum - bb->frequency) > 100 | |
1470 || (MAX (sum, bb->frequency) > 10 | |
1471 && abs ((sum - bb->frequency) * 100 / (MAX (sum, bb->frequency) + 1)) > 10)) | |
1472 record->num_mismatched_freq_in[after_pass]++; | |
1473 profile_count lsum = profile_count::zero (); | 1458 profile_count lsum = profile_count::zero (); |
1474 FOR_EACH_EDGE (e, ei, bb->preds) | 1459 FOR_EACH_EDGE (e, ei, bb->preds) |
1475 lsum += e->count (); | 1460 lsum += e->count (); |
1476 if (lsum.differs_from_p (bb->count)) | 1461 if (lsum.differs_from_p (bb->count)) |
1477 record->num_mismatched_count_in[after_pass]++; | 1462 record->num_mismatched_count_in[after_pass]++; |