Mercurial > hg > CbC > CbC_gcc
comparison gcc/cfglayout.c @ 55:77e2b8dfacca gcc-4.4.5
update it from 4.4.3 to 4.5.0
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 12 Feb 2010 23:39:51 +0900 |
parents | a06113de4d67 |
children | b7f97abdc517 |
comparison
equal
deleted
inserted
replaced
52:c156f1bd5cd9 | 55:77e2b8dfacca |
---|---|
1 /* Basic block reordering routines for the GNU compiler. | 1 /* Basic block reordering routines for the GNU compiler. |
2 Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008 | 2 Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009 |
3 Free Software Foundation, Inc. | 3 Free Software Foundation, Inc. |
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 it under | 7 GCC is free software; you can redistribute it and/or modify it under |
110 } | 110 } |
111 break; | 111 break; |
112 | 112 |
113 case CODE_LABEL: | 113 case CODE_LABEL: |
114 if (NEXT_INSN (insn) | 114 if (NEXT_INSN (insn) |
115 && JUMP_P (NEXT_INSN (insn)) | 115 && JUMP_TABLE_DATA_P (NEXT_INSN (insn))) |
116 && (GET_CODE (PATTERN (NEXT_INSN (insn))) == ADDR_VEC | |
117 || GET_CODE (PATTERN (NEXT_INSN (insn))) == ADDR_DIFF_VEC)) | |
118 { | 116 { |
119 insn = NEXT_INSN (insn); | 117 insn = NEXT_INSN (insn); |
120 last_insn = insn; | 118 last_insn = insn; |
121 continue; | 119 continue; |
122 } | 120 } |
238 int epilogue_locator; | 236 int epilogue_locator; |
239 | 237 |
240 /* Hold current location information and last location information, so the | 238 /* Hold current location information and last location information, so the |
241 datastructures are built lazily only when some instructions in given | 239 datastructures are built lazily only when some instructions in given |
242 place are needed. */ | 240 place are needed. */ |
243 location_t curr_location, last_location; | 241 static location_t curr_location, last_location; |
244 static tree curr_block, last_block; | 242 static tree curr_block, last_block; |
245 static int curr_rtl_loc = -1; | 243 static int curr_rtl_loc = -1; |
246 | 244 |
247 /* Allocate insn locator datastructure. */ | 245 /* Allocate insn locator datastructure. */ |
248 void | 246 void |
290 { | 288 { |
291 /* IV opts calls into RTL expansion to compute costs of operations. At this | 289 /* IV opts calls into RTL expansion to compute costs of operations. At this |
292 time locators are not initialized. */ | 290 time locators are not initialized. */ |
293 if (curr_rtl_loc == -1) | 291 if (curr_rtl_loc == -1) |
294 return; | 292 return; |
295 if (location == last_location) | |
296 return; | |
297 curr_location = location; | 293 curr_location = location; |
298 } | 294 } |
299 | 295 |
300 /* Set current scope block. */ | 296 /* Get current location. */ |
297 location_t | |
298 get_curr_insn_source_location (void) | |
299 { | |
300 return curr_location; | |
301 } | |
302 | |
303 /* Set current scope block. */ | |
301 void | 304 void |
302 set_curr_insn_block (tree b) | 305 set_curr_insn_block (tree b) |
303 { | 306 { |
304 /* IV opts calls into RTL expansion to compute costs of operations. At this | 307 /* IV opts calls into RTL expansion to compute costs of operations. At this |
305 time locators are not initialized. */ | 308 time locators are not initialized. */ |
306 if (curr_rtl_loc == -1) | 309 if (curr_rtl_loc == -1) |
307 return; | 310 return; |
308 if (b) | 311 if (b) |
309 curr_block = b; | 312 curr_block = b; |
313 } | |
314 | |
315 /* Get current scope block. */ | |
316 tree | |
317 get_curr_insn_block (void) | |
318 { | |
319 return curr_block; | |
310 } | 320 } |
311 | 321 |
312 /* Return current insn locator. */ | 322 /* Return current insn locator. */ |
313 int | 323 int |
314 curr_insn_locator (void) | 324 curr_insn_locator (void) |
361 NULL, /* gate */ | 371 NULL, /* gate */ |
362 into_cfg_layout_mode, /* execute */ | 372 into_cfg_layout_mode, /* execute */ |
363 NULL, /* sub */ | 373 NULL, /* sub */ |
364 NULL, /* next */ | 374 NULL, /* next */ |
365 0, /* static_pass_number */ | 375 0, /* static_pass_number */ |
366 0, /* tv_id */ | 376 TV_NONE, /* tv_id */ |
367 0, /* properties_required */ | 377 0, /* properties_required */ |
368 0, /* properties_provided */ | 378 PROP_cfglayout, /* properties_provided */ |
369 0, /* properties_destroyed */ | 379 0, /* properties_destroyed */ |
370 0, /* todo_flags_start */ | 380 0, /* todo_flags_start */ |
371 TODO_dump_func, /* todo_flags_finish */ | 381 TODO_dump_func, /* todo_flags_finish */ |
372 } | 382 } |
373 }; | 383 }; |
380 NULL, /* gate */ | 390 NULL, /* gate */ |
381 outof_cfg_layout_mode, /* execute */ | 391 outof_cfg_layout_mode, /* execute */ |
382 NULL, /* sub */ | 392 NULL, /* sub */ |
383 NULL, /* next */ | 393 NULL, /* next */ |
384 0, /* static_pass_number */ | 394 0, /* static_pass_number */ |
385 0, /* tv_id */ | 395 TV_NONE, /* tv_id */ |
386 0, /* properties_required */ | 396 0, /* properties_required */ |
387 0, /* properties_provided */ | 397 0, /* properties_provided */ |
388 0, /* properties_destroyed */ | 398 PROP_cfglayout, /* properties_destroyed */ |
389 0, /* todo_flags_start */ | 399 0, /* todo_flags_start */ |
390 TODO_dump_func, /* todo_flags_finish */ | 400 TODO_dump_func, /* todo_flags_finish */ |
391 } | 401 } |
392 }; | 402 }; |
393 | 403 |
583 for (; insn; insn = next_active_insn (insn)) | 593 for (; insn; insn = next_active_insn (insn)) |
584 { | 594 { |
585 tree this_block; | 595 tree this_block; |
586 | 596 |
587 /* Avoid putting scope notes between jump table and its label. */ | 597 /* Avoid putting scope notes between jump table and its label. */ |
588 if (JUMP_P (insn) | 598 if (JUMP_TABLE_DATA_P (insn)) |
589 && (GET_CODE (PATTERN (insn)) == ADDR_VEC | |
590 || GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC)) | |
591 continue; | 599 continue; |
592 | 600 |
593 this_block = insn_scope (insn); | 601 this_block = insn_scope (insn); |
594 /* For sequences compute scope resulting from merging all scopes | 602 /* For sequences compute scope resulting from merging all scopes |
595 of instructions nested inside. */ | 603 of instructions nested inside. */ |
684 when we renumber the basic blocks in compact_blocks. If we are | 692 when we renumber the basic blocks in compact_blocks. If we are |
685 are going out of cfglayout mode, don't re-allocate the tables. */ | 693 are going out of cfglayout mode, don't re-allocate the tables. */ |
686 free_original_copy_tables (); | 694 free_original_copy_tables (); |
687 if (stay_in_cfglayout_mode) | 695 if (stay_in_cfglayout_mode) |
688 initialize_original_copy_tables (); | 696 initialize_original_copy_tables (); |
689 | 697 |
690 /* Finally, put basic_block_info in the new order. */ | 698 /* Finally, put basic_block_info in the new order. */ |
691 compact_blocks (); | 699 compact_blocks (); |
692 } | 700 } |
693 | 701 |
694 | 702 |
777 bb_end_insn = BB_END (bb); | 785 bb_end_insn = BB_END (bb); |
778 if (JUMP_P (bb_end_insn)) | 786 if (JUMP_P (bb_end_insn)) |
779 { | 787 { |
780 if (any_condjump_p (bb_end_insn)) | 788 if (any_condjump_p (bb_end_insn)) |
781 { | 789 { |
790 /* This might happen if the conditional jump has side | |
791 effects and could therefore not be optimized away. | |
792 Make the basic block to end with a barrier in order | |
793 to prevent rtl_verify_flow_info from complaining. */ | |
794 if (!e_fall) | |
795 { | |
796 gcc_assert (!onlyjump_p (bb_end_insn)); | |
797 bb->il.rtl->footer = emit_barrier_after (bb_end_insn); | |
798 continue; | |
799 } | |
800 | |
782 /* If the old fallthru is still next, nothing to do. */ | 801 /* If the old fallthru is still next, nothing to do. */ |
783 if (bb->aux == e_fall->dest | 802 if (bb->aux == e_fall->dest |
784 || e_fall->dest == EXIT_BLOCK_PTR) | 803 || e_fall->dest == EXIT_BLOCK_PTR) |
785 continue; | 804 continue; |
786 | 805 |
838 e_taken->flags |= EDGE_FALLTHRU; | 857 e_taken->flags |= EDGE_FALLTHRU; |
839 update_br_prob_note (bb); | 858 update_br_prob_note (bb); |
840 continue; | 859 continue; |
841 } | 860 } |
842 } | 861 } |
862 else if (extract_asm_operands (PATTERN (bb_end_insn)) != NULL) | |
863 { | |
864 /* If the old fallthru is still next, nothing to do. */ | |
865 if (bb->aux == e_fall->dest | |
866 || e_fall->dest == EXIT_BLOCK_PTR) | |
867 continue; | |
868 | |
869 /* Otherwise we'll have to use the fallthru fixup below. */ | |
870 } | |
843 else | 871 else |
844 { | 872 { |
845 /* Otherwise we have some return, switch or computed | 873 /* Otherwise we have some return, switch or computed |
846 jump. In the 99% case, there should not have been a | 874 jump. In the 99% case, there should not have been a |
847 fallthru edge. */ | 875 fallthru edge. */ |
898 edge_iterator ei; | 926 edge_iterator ei; |
899 | 927 |
900 FOR_EACH_EDGE (e, ei, bb->succs) | 928 FOR_EACH_EDGE (e, ei, bb->succs) |
901 if (e->flags & EDGE_FALLTHRU) | 929 if (e->flags & EDGE_FALLTHRU) |
902 break; | 930 break; |
903 | 931 |
904 if (e && !can_fallthru (e->src, e->dest)) | 932 if (e && !can_fallthru (e->src, e->dest)) |
905 force_nonfallthru (e); | 933 force_nonfallthru (e); |
906 } | 934 } |
907 | 935 |
908 /* Ensure goto_locus from edges has some instructions with that locus | 936 /* Ensure goto_locus from edges has some instructions with that locus |
1110 } | 1138 } |
1111 | 1139 |
1112 rtx | 1140 rtx |
1113 duplicate_insn_chain (rtx from, rtx to) | 1141 duplicate_insn_chain (rtx from, rtx to) |
1114 { | 1142 { |
1115 rtx insn, last; | 1143 rtx insn, last, copy; |
1116 | 1144 |
1117 /* Avoid updating of boundaries of previous basic block. The | 1145 /* Avoid updating of boundaries of previous basic block. The |
1118 note will get removed from insn stream in fixup. */ | 1146 note will get removed from insn stream in fixup. */ |
1119 last = emit_note (NOTE_INSN_DELETED); | 1147 last = emit_note (NOTE_INSN_DELETED); |
1120 | 1148 |
1122 be reordered later. */ | 1150 be reordered later. */ |
1123 for (insn = from; insn != NEXT_INSN (to); insn = NEXT_INSN (insn)) | 1151 for (insn = from; insn != NEXT_INSN (to); insn = NEXT_INSN (insn)) |
1124 { | 1152 { |
1125 switch (GET_CODE (insn)) | 1153 switch (GET_CODE (insn)) |
1126 { | 1154 { |
1155 case DEBUG_INSN: | |
1127 case INSN: | 1156 case INSN: |
1128 case CALL_INSN: | 1157 case CALL_INSN: |
1129 case JUMP_INSN: | 1158 case JUMP_INSN: |
1130 /* Avoid copying of dispatch tables. We never duplicate | 1159 /* Avoid copying of dispatch tables. We never duplicate |
1131 tablejumps, so this can hit only in case the table got | 1160 tablejumps, so this can hit only in case the table got |
1132 moved far from original jump. */ | 1161 moved far from original jump. */ |
1133 if (GET_CODE (PATTERN (insn)) == ADDR_VEC | 1162 if (GET_CODE (PATTERN (insn)) == ADDR_VEC |
1134 || GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC) | 1163 || GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC) |
1135 break; | 1164 break; |
1136 emit_copy_of_insn_after (insn, get_last_insn ()); | 1165 copy = emit_copy_of_insn_after (insn, get_last_insn ()); |
1166 maybe_copy_epilogue_insn (insn, copy); | |
1137 break; | 1167 break; |
1138 | 1168 |
1139 case CODE_LABEL: | 1169 case CODE_LABEL: |
1140 break; | 1170 break; |
1141 | 1171 |
1151 case NOTE_INSN_PROLOGUE_END: | 1181 case NOTE_INSN_PROLOGUE_END: |
1152 | 1182 |
1153 case NOTE_INSN_DELETED: | 1183 case NOTE_INSN_DELETED: |
1154 case NOTE_INSN_DELETED_LABEL: | 1184 case NOTE_INSN_DELETED_LABEL: |
1155 /* No problem to strip these. */ | 1185 /* No problem to strip these. */ |
1156 case NOTE_INSN_EPILOGUE_BEG: | |
1157 /* Debug code expect these notes to exist just once. | |
1158 Keep them in the master copy. | |
1159 ??? It probably makes more sense to duplicate them for each | |
1160 epilogue copy. */ | |
1161 case NOTE_INSN_FUNCTION_BEG: | 1186 case NOTE_INSN_FUNCTION_BEG: |
1162 /* There is always just single entry to function. */ | 1187 /* There is always just single entry to function. */ |
1163 case NOTE_INSN_BASIC_BLOCK: | 1188 case NOTE_INSN_BASIC_BLOCK: |
1164 break; | 1189 break; |
1165 | 1190 |
1191 case NOTE_INSN_EPILOGUE_BEG: | |
1166 case NOTE_INSN_SWITCH_TEXT_SECTIONS: | 1192 case NOTE_INSN_SWITCH_TEXT_SECTIONS: |
1167 emit_note_copy (insn); | 1193 emit_note_copy (insn); |
1168 break; | 1194 break; |
1169 | 1195 |
1170 default: | 1196 default: |
1171 /* All other notes should have already been eliminated. | 1197 /* All other notes should have already been eliminated. */ |
1172 */ | |
1173 gcc_unreachable (); | 1198 gcc_unreachable (); |
1174 } | 1199 } |
1175 break; | 1200 break; |
1176 default: | 1201 default: |
1177 gcc_unreachable (); | 1202 gcc_unreachable (); |