cfgbuild.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. /* Control flow graph building code for GNU compiler.
  2. Copyright (C) 1987-2015 Free Software Foundation, Inc.
  3. This file is part of GCC.
  4. GCC is free software; you can redistribute it and/or modify it under
  5. the terms of the GNU General Public License as published by the Free
  6. Software Foundation; either version 3, or (at your option) any later
  7. version.
  8. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  9. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  11. for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GCC; see the file COPYING3. If not see
  14. <http://www.gnu.org/licenses/>. */
  15. #include "config.h"
  16. #include "system.h"
  17. #include "coretypes.h"
  18. #include "tm.h"
  19. #include "hash-set.h"
  20. #include "machmode.h"
  21. #include "vec.h"
  22. #include "double-int.h"
  23. #include "input.h"
  24. #include "alias.h"
  25. #include "symtab.h"
  26. #include "wide-int.h"
  27. #include "inchash.h"
  28. #include "tree.h"
  29. #include "rtl.h"
  30. #include "hard-reg-set.h"
  31. #include "predict.h"
  32. #include "hashtab.h"
  33. #include "function.h"
  34. #include "dominance.h"
  35. #include "cfg.h"
  36. #include "cfgrtl.h"
  37. #include "cfganal.h"
  38. #include "cfgbuild.h"
  39. #include "basic-block.h"
  40. #include "regs.h"
  41. #include "flags.h"
  42. #include "except.h"
  43. #include "statistics.h"
  44. #include "real.h"
  45. #include "fixed-value.h"
  46. #include "insn-config.h"
  47. #include "expmed.h"
  48. #include "dojump.h"
  49. #include "explow.h"
  50. #include "calls.h"
  51. #include "emit-rtl.h"
  52. #include "varasm.h"
  53. #include "stmt.h"
  54. #include "expr.h"
  55. #include "diagnostic-core.h"
  56. #include "timevar.h"
  57. #include "sbitmap.h"
  58. static void make_edges (basic_block, basic_block, int);
  59. static void make_label_edge (sbitmap, basic_block, rtx, int);
  60. static void find_bb_boundaries (basic_block);
  61. static void compute_outgoing_frequencies (basic_block);
  62. /* Return true if insn is something that should be contained inside basic
  63. block. */
  64. bool
  65. inside_basic_block_p (const rtx_insn *insn)
  66. {
  67. switch (GET_CODE (insn))
  68. {
  69. case CODE_LABEL:
  70. /* Avoid creating of basic block for jumptables. */
  71. return (NEXT_INSN (insn) == 0
  72. || ! JUMP_TABLE_DATA_P (NEXT_INSN (insn)));
  73. case JUMP_INSN:
  74. case CALL_INSN:
  75. case INSN:
  76. case DEBUG_INSN:
  77. return true;
  78. case JUMP_TABLE_DATA:
  79. case BARRIER:
  80. case NOTE:
  81. return false;
  82. default:
  83. gcc_unreachable ();
  84. }
  85. }
  86. /* Return true if INSN may cause control flow transfer, so it should be last in
  87. the basic block. */
  88. bool
  89. control_flow_insn_p (const rtx_insn *insn)
  90. {
  91. switch (GET_CODE (insn))
  92. {
  93. case NOTE:
  94. case CODE_LABEL:
  95. case DEBUG_INSN:
  96. return false;
  97. case JUMP_INSN:
  98. return true;
  99. case CALL_INSN:
  100. /* Noreturn and sibling call instructions terminate the basic blocks
  101. (but only if they happen unconditionally). */
  102. if ((SIBLING_CALL_P (insn)
  103. || find_reg_note (insn, REG_NORETURN, 0))
  104. && GET_CODE (PATTERN (insn)) != COND_EXEC)
  105. return true;
  106. /* Call insn may return to the nonlocal goto handler. */
  107. if (can_nonlocal_goto (insn))
  108. return true;
  109. break;
  110. case INSN:
  111. /* Treat trap instructions like noreturn calls (same provision). */
  112. if (GET_CODE (PATTERN (insn)) == TRAP_IF
  113. && XEXP (PATTERN (insn), 0) == const1_rtx)
  114. return true;
  115. if (!cfun->can_throw_non_call_exceptions)
  116. return false;
  117. break;
  118. case JUMP_TABLE_DATA:
  119. case BARRIER:
  120. /* It is nonsense to reach this when looking for the
  121. end of basic block, but before dead code is eliminated
  122. this may happen. */
  123. return false;
  124. default:
  125. gcc_unreachable ();
  126. }
  127. return can_throw_internal (insn);
  128. }
  129. /* Create an edge between two basic blocks. FLAGS are auxiliary information
  130. about the edge that is accumulated between calls. */
  131. /* Create an edge from a basic block to a label. */
  132. static void
  133. make_label_edge (sbitmap edge_cache, basic_block src, rtx label, int flags)
  134. {
  135. gcc_assert (LABEL_P (label));
  136. /* If the label was never emitted, this insn is junk, but avoid a
  137. crash trying to refer to BLOCK_FOR_INSN (label). This can happen
  138. as a result of a syntax error and a diagnostic has already been
  139. printed. */
  140. if (INSN_UID (label) == 0)
  141. return;
  142. cached_make_edge (edge_cache, src, BLOCK_FOR_INSN (label), flags);
  143. }
  144. /* Create the edges generated by INSN in REGION. */
  145. void
  146. rtl_make_eh_edge (sbitmap edge_cache, basic_block src, rtx insn)
  147. {
  148. eh_landing_pad lp = get_eh_landing_pad_from_rtx (insn);
  149. if (lp)
  150. {
  151. rtx label = lp->landing_pad;
  152. /* During initial rtl generation, use the post_landing_pad. */
  153. if (label == NULL)
  154. {
  155. gcc_assert (lp->post_landing_pad);
  156. label = label_rtx (lp->post_landing_pad);
  157. }
  158. make_label_edge (edge_cache, src, label,
  159. EDGE_ABNORMAL | EDGE_EH
  160. | (CALL_P (insn) ? EDGE_ABNORMAL_CALL : 0));
  161. }
  162. }
  163. /* States of basic block as seen by find_many_sub_basic_blocks. */
  164. enum state {
  165. /* Basic blocks created via split_block belong to this state.
  166. make_edges will examine these basic blocks to see if we need to
  167. create edges going out of them. */
  168. BLOCK_NEW = 0,
  169. /* Basic blocks that do not need examining belong to this state.
  170. These blocks will be left intact. In particular, make_edges will
  171. not create edges going out of these basic blocks. */
  172. BLOCK_ORIGINAL,
  173. /* Basic blocks that may need splitting (due to a label appearing in
  174. the middle, etc) belong to this state. After splitting them,
  175. make_edges will create edges going out of them as needed. */
  176. BLOCK_TO_SPLIT
  177. };
  178. #define STATE(BB) (enum state) ((size_t) (BB)->aux)
  179. #define SET_STATE(BB, STATE) ((BB)->aux = (void *) (size_t) (STATE))
  180. /* Used internally by purge_dead_tablejump_edges, ORed into state. */
  181. #define BLOCK_USED_BY_TABLEJUMP 32
  182. #define FULL_STATE(BB) ((size_t) (BB)->aux)
  183. /* Identify the edges going out of basic blocks between MIN and MAX,
  184. inclusive, that have their states set to BLOCK_NEW or
  185. BLOCK_TO_SPLIT.
  186. UPDATE_P should be nonzero if we are updating CFG and zero if we
  187. are building CFG from scratch. */
  188. static void
  189. make_edges (basic_block min, basic_block max, int update_p)
  190. {
  191. basic_block bb;
  192. sbitmap edge_cache = NULL;
  193. /* Heavy use of computed goto in machine-generated code can lead to
  194. nearly fully-connected CFGs. In that case we spend a significant
  195. amount of time searching the edge lists for duplicates. */
  196. if (forced_labels || cfun->cfg->max_jumptable_ents > 100)
  197. edge_cache = sbitmap_alloc (last_basic_block_for_fn (cfun));
  198. /* By nature of the way these get numbered, ENTRY_BLOCK_PTR->next_bb block
  199. is always the entry. */
  200. if (min == ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb)
  201. make_edge (ENTRY_BLOCK_PTR_FOR_FN (cfun), min, EDGE_FALLTHRU);
  202. FOR_BB_BETWEEN (bb, min, max->next_bb, next_bb)
  203. {
  204. rtx_insn *insn;
  205. enum rtx_code code;
  206. edge e;
  207. edge_iterator ei;
  208. if (STATE (bb) == BLOCK_ORIGINAL)
  209. continue;
  210. /* If we have an edge cache, cache edges going out of BB. */
  211. if (edge_cache)
  212. {
  213. bitmap_clear (edge_cache);
  214. if (update_p)
  215. {
  216. FOR_EACH_EDGE (e, ei, bb->succs)
  217. if (e->dest != EXIT_BLOCK_PTR_FOR_FN (cfun))
  218. bitmap_set_bit (edge_cache, e->dest->index);
  219. }
  220. }
  221. if (LABEL_P (BB_HEAD (bb))
  222. && LABEL_ALT_ENTRY_P (BB_HEAD (bb)))
  223. cached_make_edge (NULL, ENTRY_BLOCK_PTR_FOR_FN (cfun), bb, 0);
  224. /* Examine the last instruction of the block, and discover the
  225. ways we can leave the block. */
  226. insn = BB_END (bb);
  227. code = GET_CODE (insn);
  228. /* A branch. */
  229. if (code == JUMP_INSN)
  230. {
  231. rtx tmp;
  232. rtx_jump_table_data *table;
  233. /* Recognize a non-local goto as a branch outside the
  234. current function. */
  235. if (find_reg_note (insn, REG_NON_LOCAL_GOTO, NULL_RTX))
  236. ;
  237. /* Recognize a tablejump and do the right thing. */
  238. else if (tablejump_p (insn, NULL, &table))
  239. {
  240. rtvec vec = table->get_labels ();
  241. int j;
  242. for (j = GET_NUM_ELEM (vec) - 1; j >= 0; --j)
  243. make_label_edge (edge_cache, bb,
  244. XEXP (RTVEC_ELT (vec, j), 0), 0);
  245. /* Some targets (eg, ARM) emit a conditional jump that also
  246. contains the out-of-range target. Scan for these and
  247. add an edge if necessary. */
  248. if ((tmp = single_set (insn)) != NULL
  249. && SET_DEST (tmp) == pc_rtx
  250. && GET_CODE (SET_SRC (tmp)) == IF_THEN_ELSE
  251. && GET_CODE (XEXP (SET_SRC (tmp), 2)) == LABEL_REF)
  252. make_label_edge (edge_cache, bb,
  253. LABEL_REF_LABEL (XEXP (SET_SRC (tmp), 2)), 0);
  254. }
  255. /* If this is a computed jump, then mark it as reaching
  256. everything on the forced_labels list. */
  257. else if (computed_jump_p (insn))
  258. {
  259. for (rtx_insn_list *x = forced_labels; x; x = x->next ())
  260. make_label_edge (edge_cache, bb, x->insn (), EDGE_ABNORMAL);
  261. }
  262. /* Returns create an exit out. */
  263. else if (returnjump_p (insn))
  264. cached_make_edge (edge_cache, bb, EXIT_BLOCK_PTR_FOR_FN (cfun), 0);
  265. /* Recognize asm goto and do the right thing. */
  266. else if ((tmp = extract_asm_operands (PATTERN (insn))) != NULL)
  267. {
  268. int i, n = ASM_OPERANDS_LABEL_LENGTH (tmp);
  269. for (i = 0; i < n; ++i)
  270. make_label_edge (edge_cache, bb,
  271. XEXP (ASM_OPERANDS_LABEL (tmp, i), 0), 0);
  272. }
  273. /* Otherwise, we have a plain conditional or unconditional jump. */
  274. else
  275. {
  276. gcc_assert (JUMP_LABEL (insn));
  277. make_label_edge (edge_cache, bb, JUMP_LABEL (insn), 0);
  278. }
  279. }
  280. /* If this is a sibling call insn, then this is in effect a combined call
  281. and return, and so we need an edge to the exit block. No need to
  282. worry about EH edges, since we wouldn't have created the sibling call
  283. in the first place. */
  284. if (code == CALL_INSN && SIBLING_CALL_P (insn))
  285. cached_make_edge (edge_cache, bb, EXIT_BLOCK_PTR_FOR_FN (cfun),
  286. EDGE_SIBCALL | EDGE_ABNORMAL);
  287. /* If this is a CALL_INSN, then mark it as reaching the active EH
  288. handler for this CALL_INSN. If we're handling non-call
  289. exceptions then any insn can reach any of the active handlers.
  290. Also mark the CALL_INSN as reaching any nonlocal goto handler. */
  291. else if (code == CALL_INSN || cfun->can_throw_non_call_exceptions)
  292. {
  293. /* Add any appropriate EH edges. */
  294. rtl_make_eh_edge (edge_cache, bb, insn);
  295. if (code == CALL_INSN)
  296. {
  297. if (can_nonlocal_goto (insn))
  298. {
  299. /* ??? This could be made smarter: in some cases it's
  300. possible to tell that certain calls will not do a
  301. nonlocal goto. For example, if the nested functions
  302. that do the nonlocal gotos do not have their addresses
  303. taken, then only calls to those functions or to other
  304. nested functions that use them could possibly do
  305. nonlocal gotos. */
  306. for (rtx_insn_list *x = nonlocal_goto_handler_labels;
  307. x;
  308. x = x->next ())
  309. make_label_edge (edge_cache, bb, x->insn (),
  310. EDGE_ABNORMAL | EDGE_ABNORMAL_CALL);
  311. }
  312. if (flag_tm)
  313. {
  314. rtx note;
  315. for (note = REG_NOTES (insn); note; note = XEXP (note, 1))
  316. if (REG_NOTE_KIND (note) == REG_TM)
  317. make_label_edge (edge_cache, bb, XEXP (note, 0),
  318. EDGE_ABNORMAL | EDGE_ABNORMAL_CALL);
  319. }
  320. }
  321. }
  322. /* Find out if we can drop through to the next block. */
  323. insn = NEXT_INSN (insn);
  324. e = find_edge (bb, EXIT_BLOCK_PTR_FOR_FN (cfun));
  325. if (e && e->flags & EDGE_FALLTHRU)
  326. insn = NULL;
  327. while (insn
  328. && NOTE_P (insn)
  329. && NOTE_KIND (insn) != NOTE_INSN_BASIC_BLOCK)
  330. insn = NEXT_INSN (insn);
  331. if (!insn)
  332. cached_make_edge (edge_cache, bb, EXIT_BLOCK_PTR_FOR_FN (cfun),
  333. EDGE_FALLTHRU);
  334. else if (bb->next_bb != EXIT_BLOCK_PTR_FOR_FN (cfun))
  335. {
  336. if (insn == BB_HEAD (bb->next_bb))
  337. cached_make_edge (edge_cache, bb, bb->next_bb, EDGE_FALLTHRU);
  338. }
  339. }
  340. if (edge_cache)
  341. sbitmap_free (edge_cache);
  342. }
  343. static void
  344. mark_tablejump_edge (rtx label)
  345. {
  346. basic_block bb;
  347. gcc_assert (LABEL_P (label));
  348. /* See comment in make_label_edge. */
  349. if (INSN_UID (label) == 0)
  350. return;
  351. bb = BLOCK_FOR_INSN (label);
  352. SET_STATE (bb, FULL_STATE (bb) | BLOCK_USED_BY_TABLEJUMP);
  353. }
  354. static void
  355. purge_dead_tablejump_edges (basic_block bb, rtx_jump_table_data *table)
  356. {
  357. rtx_insn *insn = BB_END (bb);
  358. rtx tmp;
  359. rtvec vec;
  360. int j;
  361. edge_iterator ei;
  362. edge e;
  363. vec = table->get_labels ();
  364. for (j = GET_NUM_ELEM (vec) - 1; j >= 0; --j)
  365. mark_tablejump_edge (XEXP (RTVEC_ELT (vec, j), 0));
  366. /* Some targets (eg, ARM) emit a conditional jump that also
  367. contains the out-of-range target. Scan for these and
  368. add an edge if necessary. */
  369. if ((tmp = single_set (insn)) != NULL
  370. && SET_DEST (tmp) == pc_rtx
  371. && GET_CODE (SET_SRC (tmp)) == IF_THEN_ELSE
  372. && GET_CODE (XEXP (SET_SRC (tmp), 2)) == LABEL_REF)
  373. mark_tablejump_edge (LABEL_REF_LABEL (XEXP (SET_SRC (tmp), 2)));
  374. for (ei = ei_start (bb->succs); (e = ei_safe_edge (ei)); )
  375. {
  376. if (FULL_STATE (e->dest) & BLOCK_USED_BY_TABLEJUMP)
  377. SET_STATE (e->dest, FULL_STATE (e->dest)
  378. & ~(size_t) BLOCK_USED_BY_TABLEJUMP);
  379. else if (!(e->flags & (EDGE_ABNORMAL | EDGE_EH)))
  380. {
  381. remove_edge (e);
  382. continue;
  383. }
  384. ei_next (&ei);
  385. }
  386. }
  387. /* Scan basic block BB for possible BB boundaries inside the block
  388. and create new basic blocks in the progress. */
  389. static void
  390. find_bb_boundaries (basic_block bb)
  391. {
  392. basic_block orig_bb = bb;
  393. rtx_insn *insn = BB_HEAD (bb);
  394. rtx_insn *end = BB_END (bb), *x;
  395. rtx_jump_table_data *table;
  396. rtx_insn *flow_transfer_insn = NULL;
  397. edge fallthru = NULL;
  398. if (insn == BB_END (bb))
  399. return;
  400. if (LABEL_P (insn))
  401. insn = NEXT_INSN (insn);
  402. /* Scan insn chain and try to find new basic block boundaries. */
  403. while (1)
  404. {
  405. enum rtx_code code = GET_CODE (insn);
  406. /* In case we've previously seen an insn that effects a control
  407. flow transfer, split the block. */
  408. if ((flow_transfer_insn || code == CODE_LABEL)
  409. && inside_basic_block_p (insn))
  410. {
  411. fallthru = split_block (bb, PREV_INSN (insn));
  412. if (flow_transfer_insn)
  413. {
  414. BB_END (bb) = flow_transfer_insn;
  415. /* Clean up the bb field for the insns between the blocks. */
  416. for (x = NEXT_INSN (flow_transfer_insn);
  417. x != BB_HEAD (fallthru->dest);
  418. x = NEXT_INSN (x))
  419. if (!BARRIER_P (x))
  420. set_block_for_insn (x, NULL);
  421. }
  422. bb = fallthru->dest;
  423. remove_edge (fallthru);
  424. flow_transfer_insn = NULL;
  425. if (code == CODE_LABEL && LABEL_ALT_ENTRY_P (insn))
  426. make_edge (ENTRY_BLOCK_PTR_FOR_FN (cfun), bb, 0);
  427. }
  428. else if (code == BARRIER)
  429. {
  430. /* __builtin_unreachable () may cause a barrier to be emitted in
  431. the middle of a BB. We need to split it in the same manner as
  432. if the barrier were preceded by a control_flow_insn_p insn. */
  433. if (!flow_transfer_insn)
  434. flow_transfer_insn = prev_nonnote_insn_bb (insn);
  435. }
  436. if (control_flow_insn_p (insn))
  437. flow_transfer_insn = insn;
  438. if (insn == end)
  439. break;
  440. insn = NEXT_INSN (insn);
  441. }
  442. /* In case expander replaced normal insn by sequence terminating by
  443. return and barrier, or possibly other sequence not behaving like
  444. ordinary jump, we need to take care and move basic block boundary. */
  445. if (flow_transfer_insn)
  446. {
  447. BB_END (bb) = flow_transfer_insn;
  448. /* Clean up the bb field for the insns that do not belong to BB. */
  449. x = flow_transfer_insn;
  450. while (x != end)
  451. {
  452. x = NEXT_INSN (x);
  453. if (!BARRIER_P (x))
  454. set_block_for_insn (x, NULL);
  455. }
  456. }
  457. /* We've possibly replaced the conditional jump by conditional jump
  458. followed by cleanup at fallthru edge, so the outgoing edges may
  459. be dead. */
  460. purge_dead_edges (bb);
  461. /* purge_dead_edges doesn't handle tablejump's, but if we have split the
  462. basic block, we might need to kill some edges. */
  463. if (bb != orig_bb && tablejump_p (BB_END (bb), NULL, &table))
  464. purge_dead_tablejump_edges (bb, table);
  465. }
  466. /* Assume that frequency of basic block B is known. Compute frequencies
  467. and probabilities of outgoing edges. */
  468. static void
  469. compute_outgoing_frequencies (basic_block b)
  470. {
  471. edge e, f;
  472. edge_iterator ei;
  473. if (EDGE_COUNT (b->succs) == 2)
  474. {
  475. rtx note = find_reg_note (BB_END (b), REG_BR_PROB, NULL);
  476. int probability;
  477. if (note)
  478. {
  479. probability = XINT (note, 0);
  480. e = BRANCH_EDGE (b);
  481. e->probability = probability;
  482. e->count = apply_probability (b->count, probability);
  483. f = FALLTHRU_EDGE (b);
  484. f->probability = REG_BR_PROB_BASE - probability;
  485. f->count = b->count - e->count;
  486. return;
  487. }
  488. else
  489. {
  490. guess_outgoing_edge_probabilities (b);
  491. }
  492. }
  493. else if (single_succ_p (b))
  494. {
  495. e = single_succ_edge (b);
  496. e->probability = REG_BR_PROB_BASE;
  497. e->count = b->count;
  498. return;
  499. }
  500. else
  501. {
  502. /* We rely on BBs with more than two successors to have sane probabilities
  503. and do not guess them here. For BBs terminated by switch statements
  504. expanded to jump-table jump, we have done the right thing during
  505. expansion. For EH edges, we still guess the probabilities here. */
  506. bool complex_edge = false;
  507. FOR_EACH_EDGE (e, ei, b->succs)
  508. if (e->flags & EDGE_COMPLEX)
  509. {
  510. complex_edge = true;
  511. break;
  512. }
  513. if (complex_edge)
  514. guess_outgoing_edge_probabilities (b);
  515. }
  516. if (b->count)
  517. FOR_EACH_EDGE (e, ei, b->succs)
  518. e->count = apply_probability (b->count, e->probability);
  519. }
  520. /* Assume that some pass has inserted labels or control flow
  521. instructions within a basic block. Split basic blocks as needed
  522. and create edges. */
  523. void
  524. find_many_sub_basic_blocks (sbitmap blocks)
  525. {
  526. basic_block bb, min, max;
  527. FOR_EACH_BB_FN (bb, cfun)
  528. SET_STATE (bb,
  529. bitmap_bit_p (blocks, bb->index) ? BLOCK_TO_SPLIT : BLOCK_ORIGINAL);
  530. FOR_EACH_BB_FN (bb, cfun)
  531. if (STATE (bb) == BLOCK_TO_SPLIT)
  532. find_bb_boundaries (bb);
  533. FOR_EACH_BB_FN (bb, cfun)
  534. if (STATE (bb) != BLOCK_ORIGINAL)
  535. break;
  536. min = max = bb;
  537. for (; bb != EXIT_BLOCK_PTR_FOR_FN (cfun); bb = bb->next_bb)
  538. if (STATE (bb) != BLOCK_ORIGINAL)
  539. max = bb;
  540. /* Now re-scan and wire in all edges. This expect simple (conditional)
  541. jumps at the end of each new basic blocks. */
  542. make_edges (min, max, 1);
  543. /* Update branch probabilities. Expect only (un)conditional jumps
  544. to be created with only the forward edges. */
  545. if (profile_status_for_fn (cfun) != PROFILE_ABSENT)
  546. FOR_BB_BETWEEN (bb, min, max->next_bb, next_bb)
  547. {
  548. edge e;
  549. edge_iterator ei;
  550. if (STATE (bb) == BLOCK_ORIGINAL)
  551. continue;
  552. if (STATE (bb) == BLOCK_NEW)
  553. {
  554. bb->count = 0;
  555. bb->frequency = 0;
  556. FOR_EACH_EDGE (e, ei, bb->preds)
  557. {
  558. bb->count += e->count;
  559. bb->frequency += EDGE_FREQUENCY (e);
  560. }
  561. }
  562. compute_outgoing_frequencies (bb);
  563. }
  564. FOR_EACH_BB_FN (bb, cfun)
  565. SET_STATE (bb, 0);
  566. }