libgomp: Use pthread mutexes in the nvptx plugin.
[official-gcc.git] / gcc / lra-lives.c
blobbd7e15998fd6c21edc409ff35bdf64fa38a96c11
1 /* Build live ranges for pseudos.
2 Copyright (C) 2010-2015 Free Software Foundation, Inc.
3 Contributed by Vladimir Makarov <vmakarov@redhat.com>.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
22 /* This file contains code to build pseudo live-ranges (analogous
23 structures used in IRA, so read comments about the live-ranges
24 there) and other info necessary for other passes to assign
25 hard-registers to pseudos, coalesce the spilled pseudos, and assign
26 stack memory slots to spilled pseudos. */
28 #include "config.h"
29 #include "system.h"
30 #include "coretypes.h"
31 #include "tm.h"
32 #include "hard-reg-set.h"
33 #include "rtl.h"
34 #include "tm_p.h"
35 #include "insn-config.h"
36 #include "recog.h"
37 #include "output.h"
38 #include "regs.h"
39 #include "hashtab.h"
40 #include "hash-set.h"
41 #include "vec.h"
42 #include "machmode.h"
43 #include "input.h"
44 #include "function.h"
45 #include "symtab.h"
46 #include "expr.h"
47 #include "predict.h"
48 #include "dominance.h"
49 #include "cfg.h"
50 #include "cfganal.h"
51 #include "basic-block.h"
52 #include "except.h"
53 #include "df.h"
54 #include "ira.h"
55 #include "sparseset.h"
56 #include "lra-int.h"
58 /* Program points are enumerated by numbers from range
59 0..LRA_LIVE_MAX_POINT-1. There are approximately two times more
60 program points than insns. Program points are places in the
61 program where liveness info can be changed. In most general case
62 (there are more complicated cases too) some program points
63 correspond to places where input operand dies and other ones
64 correspond to places where output operands are born. */
65 int lra_live_max_point;
67 /* Accumulated execution frequency of all references for each hard
68 register. */
69 int lra_hard_reg_usage[FIRST_PSEUDO_REGISTER];
71 /* A global flag whose true value says to build live ranges for all
72 pseudos, otherwise the live ranges only for pseudos got memory is
73 build. True value means also building copies and setting up hard
74 register preferences. The complete info is necessary only for the
75 assignment pass. The complete info is not needed for the
76 coalescing and spill passes. */
77 static bool complete_info_p;
79 /* Pseudos live at current point in the RTL scan. */
80 static sparseset pseudos_live;
82 /* Pseudos probably living through calls and setjumps. As setjump is
83 a call too, if a bit in PSEUDOS_LIVE_THROUGH_SETJUMPS is set up
84 then the corresponding bit in PSEUDOS_LIVE_THROUGH_CALLS is set up
85 too. These data are necessary for cases when only one subreg of a
86 multi-reg pseudo is set up after a call. So we decide it is
87 probably live when traversing bb backward. We are sure about
88 living when we see its usage or definition of the pseudo. */
89 static sparseset pseudos_live_through_calls;
90 static sparseset pseudos_live_through_setjumps;
92 /* Set of hard regs (except eliminable ones) currently live. */
93 static HARD_REG_SET hard_regs_live;
95 /* Set of pseudos and hard registers start living/dying in the current
96 insn. These sets are used to update REG_DEAD and REG_UNUSED notes
97 in the insn. */
98 static sparseset start_living, start_dying;
100 /* Set of pseudos and hard regs dead and unused in the current
101 insn. */
102 static sparseset unused_set, dead_set;
104 /* Bitmap used for holding intermediate bitmap operation results. */
105 static bitmap_head temp_bitmap;
107 /* Pool for pseudo live ranges. */
108 static alloc_pool live_range_pool;
110 /* Free live range LR. */
111 static void
112 free_live_range (lra_live_range_t lr)
114 pool_free (live_range_pool, lr);
117 /* Free live range list LR. */
118 static void
119 free_live_range_list (lra_live_range_t lr)
121 lra_live_range_t next;
123 while (lr != NULL)
125 next = lr->next;
126 free_live_range (lr);
127 lr = next;
131 /* Create and return pseudo live range with given attributes. */
132 static lra_live_range_t
133 create_live_range (int regno, int start, int finish, lra_live_range_t next)
135 lra_live_range_t p;
137 p = (lra_live_range_t) pool_alloc (live_range_pool);
138 p->regno = regno;
139 p->start = start;
140 p->finish = finish;
141 p->next = next;
142 return p;
145 /* Copy live range R and return the result. */
146 static lra_live_range_t
147 copy_live_range (lra_live_range_t r)
149 lra_live_range_t p;
151 p = (lra_live_range_t) pool_alloc (live_range_pool);
152 *p = *r;
153 return p;
156 /* Copy live range list given by its head R and return the result. */
157 lra_live_range_t
158 lra_copy_live_range_list (lra_live_range_t r)
160 lra_live_range_t p, first, *chain;
162 first = NULL;
163 for (chain = &first; r != NULL; r = r->next)
165 p = copy_live_range (r);
166 *chain = p;
167 chain = &p->next;
169 return first;
172 /* Merge *non-intersected* ranges R1 and R2 and returns the result.
173 The function maintains the order of ranges and tries to minimize
174 size of the result range list. Ranges R1 and R2 may not be used
175 after the call. */
176 lra_live_range_t
177 lra_merge_live_ranges (lra_live_range_t r1, lra_live_range_t r2)
179 lra_live_range_t first, last, temp;
181 if (r1 == NULL)
182 return r2;
183 if (r2 == NULL)
184 return r1;
185 for (first = last = NULL; r1 != NULL && r2 != NULL;)
187 if (r1->start < r2->start)
189 temp = r1;
190 r1 = r2;
191 r2 = temp;
193 if (r1->start == r2->finish + 1)
195 /* Joint ranges: merge r1 and r2 into r1. */
196 r1->start = r2->start;
197 temp = r2;
198 r2 = r2->next;
199 pool_free (live_range_pool, temp);
201 else
203 gcc_assert (r2->finish + 1 < r1->start);
204 /* Add r1 to the result. */
205 if (first == NULL)
206 first = last = r1;
207 else
209 last->next = r1;
210 last = r1;
212 r1 = r1->next;
215 if (r1 != NULL)
217 if (first == NULL)
218 first = r1;
219 else
220 last->next = r1;
222 else
224 lra_assert (r2 != NULL);
225 if (first == NULL)
226 first = r2;
227 else
228 last->next = r2;
230 return first;
233 /* Return TRUE if live ranges R1 and R2 intersect. */
234 bool
235 lra_intersected_live_ranges_p (lra_live_range_t r1, lra_live_range_t r2)
237 /* Remember the live ranges are always kept ordered. */
238 while (r1 != NULL && r2 != NULL)
240 if (r1->start > r2->finish)
241 r1 = r1->next;
242 else if (r2->start > r1->finish)
243 r2 = r2->next;
244 else
245 return true;
247 return false;
250 /* The function processing birth of hard register REGNO. It updates
251 living hard regs, conflict hard regs for living pseudos, and
252 START_LIVING. */
253 static void
254 make_hard_regno_born (int regno)
256 unsigned int i;
258 lra_assert (regno < FIRST_PSEUDO_REGISTER);
259 if (TEST_HARD_REG_BIT (hard_regs_live, regno))
260 return;
261 SET_HARD_REG_BIT (hard_regs_live, regno);
262 sparseset_set_bit (start_living, regno);
263 EXECUTE_IF_SET_IN_SPARSESET (pseudos_live, i)
264 SET_HARD_REG_BIT (lra_reg_info[i].conflict_hard_regs, regno);
267 /* Process the death of hard register REGNO. This updates
268 hard_regs_live and START_DYING. */
269 static void
270 make_hard_regno_dead (int regno)
272 lra_assert (regno < FIRST_PSEUDO_REGISTER);
273 if (! TEST_HARD_REG_BIT (hard_regs_live, regno))
274 return;
275 sparseset_set_bit (start_dying, regno);
276 CLEAR_HARD_REG_BIT (hard_regs_live, regno);
279 /* Mark pseudo REGNO as living at program point POINT, update conflicting
280 hard registers of the pseudo and START_LIVING, and start a new live
281 range for the pseudo corresponding to REGNO if it is necessary. */
282 static void
283 mark_pseudo_live (int regno, int point)
285 lra_live_range_t p;
287 lra_assert (regno >= FIRST_PSEUDO_REGISTER);
288 lra_assert (! sparseset_bit_p (pseudos_live, regno));
289 sparseset_set_bit (pseudos_live, regno);
290 IOR_HARD_REG_SET (lra_reg_info[regno].conflict_hard_regs, hard_regs_live);
292 if ((complete_info_p || lra_get_regno_hard_regno (regno) < 0)
293 && ((p = lra_reg_info[regno].live_ranges) == NULL
294 || (p->finish != point && p->finish + 1 != point)))
295 lra_reg_info[regno].live_ranges
296 = create_live_range (regno, point, -1, p);
297 sparseset_set_bit (start_living, regno);
300 /* Mark pseudo REGNO as not living at program point POINT and update
301 START_DYING.
302 This finishes the current live range for the pseudo corresponding
303 to REGNO. */
304 static void
305 mark_pseudo_dead (int regno, int point)
307 lra_live_range_t p;
309 lra_assert (regno >= FIRST_PSEUDO_REGISTER);
310 lra_assert (sparseset_bit_p (pseudos_live, regno));
311 sparseset_clear_bit (pseudos_live, regno);
312 sparseset_set_bit (start_dying, regno);
313 if (complete_info_p || lra_get_regno_hard_regno (regno) < 0)
315 p = lra_reg_info[regno].live_ranges;
316 lra_assert (p != NULL);
317 p->finish = point;
321 /* The corresponding bitmaps of BB currently being processed. */
322 static bitmap bb_killed_pseudos, bb_gen_pseudos;
324 /* Mark register REGNO (pseudo or hard register) in MODE as live at
325 program point POINT. Update BB_GEN_PSEUDOS.
326 Return TRUE if the liveness tracking sets were modified, or FALSE
327 if nothing changed. */
328 static bool
329 mark_regno_live (int regno, machine_mode mode, int point)
331 int last;
332 bool changed = false;
334 if (regno < FIRST_PSEUDO_REGISTER)
336 for (last = regno + hard_regno_nregs[regno][mode];
337 regno < last;
338 regno++)
339 make_hard_regno_born (regno);
341 else
343 if (! sparseset_bit_p (pseudos_live, regno))
345 mark_pseudo_live (regno, point);
346 changed = true;
348 bitmap_set_bit (bb_gen_pseudos, regno);
350 return changed;
354 /* Mark register REGNO in MODE as dead at program point POINT. Update
355 BB_GEN_PSEUDOS and BB_KILLED_PSEUDOS. Return TRUE if the liveness
356 tracking sets were modified, or FALSE if nothing changed. */
357 static bool
358 mark_regno_dead (int regno, machine_mode mode, int point)
360 int last;
361 bool changed = false;
363 if (regno < FIRST_PSEUDO_REGISTER)
365 for (last = regno + hard_regno_nregs[regno][mode];
366 regno < last;
367 regno++)
368 make_hard_regno_dead (regno);
370 else
372 if (sparseset_bit_p (pseudos_live, regno))
374 mark_pseudo_dead (regno, point);
375 changed = true;
377 bitmap_clear_bit (bb_gen_pseudos, regno);
378 bitmap_set_bit (bb_killed_pseudos, regno);
380 return changed;
385 /* This page contains code for making global live analysis of pseudos.
386 The code works only when pseudo live info is changed on a BB
387 border. That might be a consequence of some global transformations
388 in LRA, e.g. PIC pseudo reuse or rematerialization. */
390 /* Structure describing local BB data used for pseudo
391 live-analysis. */
392 struct bb_data_pseudos
394 /* Basic block about which the below data are. */
395 basic_block bb;
396 bitmap_head killed_pseudos; /* pseudos killed in the BB. */
397 bitmap_head gen_pseudos; /* pseudos generated in the BB. */
400 /* Array for all BB data. Indexed by the corresponding BB index. */
401 typedef struct bb_data_pseudos *bb_data_t;
403 /* All basic block data are referred through the following array. */
404 static bb_data_t bb_data;
406 /* Two small functions for access to the bb data. */
407 static inline bb_data_t
408 get_bb_data (basic_block bb)
410 return &bb_data[(bb)->index];
413 static inline bb_data_t
414 get_bb_data_by_index (int index)
416 return &bb_data[index];
419 /* Bitmap with all hard regs. */
420 static bitmap_head all_hard_regs_bitmap;
422 /* The transfer function used by the DF equation solver to propagate
423 live info through block with BB_INDEX according to the following
424 equation:
426 bb.livein = (bb.liveout - bb.kill) OR bb.gen
428 static bool
429 live_trans_fun (int bb_index)
431 basic_block bb = get_bb_data_by_index (bb_index)->bb;
432 bitmap bb_liveout = df_get_live_out (bb);
433 bitmap bb_livein = df_get_live_in (bb);
434 bb_data_t bb_info = get_bb_data (bb);
436 bitmap_and_compl (&temp_bitmap, bb_liveout, &all_hard_regs_bitmap);
437 return bitmap_ior_and_compl (bb_livein, &bb_info->gen_pseudos,
438 &temp_bitmap, &bb_info->killed_pseudos);
441 /* The confluence function used by the DF equation solver to set up
442 live info for a block BB without predecessor. */
443 static void
444 live_con_fun_0 (basic_block bb)
446 bitmap_and_into (df_get_live_out (bb), &all_hard_regs_bitmap);
449 /* The confluence function used by the DF equation solver to propagate
450 live info from successor to predecessor on edge E according to the
451 following equation:
453 bb.liveout = 0 for entry block | OR (livein of successors)
455 static bool
456 live_con_fun_n (edge e)
458 basic_block bb = e->src;
459 basic_block dest = e->dest;
460 bitmap bb_liveout = df_get_live_out (bb);
461 bitmap dest_livein = df_get_live_in (dest);
463 return bitmap_ior_and_compl_into (bb_liveout,
464 dest_livein, &all_hard_regs_bitmap);
467 /* Indexes of all function blocks. */
468 static bitmap_head all_blocks;
470 /* Allocate and initialize data needed for global pseudo live
471 analysis. */
472 static void
473 initiate_live_solver (void)
475 bitmap_initialize (&all_hard_regs_bitmap, &reg_obstack);
476 bitmap_set_range (&all_hard_regs_bitmap, 0, FIRST_PSEUDO_REGISTER);
477 bb_data = XNEWVEC (struct bb_data_pseudos, last_basic_block_for_fn (cfun));
478 bitmap_initialize (&all_blocks, &reg_obstack);
480 basic_block bb;
481 FOR_ALL_BB_FN (bb, cfun)
483 bb_data_t bb_info = get_bb_data (bb);
484 bb_info->bb = bb;
485 bitmap_initialize (&bb_info->killed_pseudos, &reg_obstack);
486 bitmap_initialize (&bb_info->gen_pseudos, &reg_obstack);
487 bitmap_set_bit (&all_blocks, bb->index);
491 /* Free all data needed for global pseudo live analysis. */
492 static void
493 finish_live_solver (void)
495 basic_block bb;
497 bitmap_clear (&all_blocks);
498 FOR_ALL_BB_FN (bb, cfun)
500 bb_data_t bb_info = get_bb_data (bb);
501 bitmap_clear (&bb_info->killed_pseudos);
502 bitmap_clear (&bb_info->gen_pseudos);
504 free (bb_data);
505 bitmap_clear (&all_hard_regs_bitmap);
510 /* Insn currently scanned. */
511 static rtx_insn *curr_insn;
512 /* The insn data. */
513 static lra_insn_recog_data_t curr_id;
514 /* The insn static data. */
515 static struct lra_static_insn_data *curr_static_id;
517 /* Return true when one of the predecessor edges of BB is marked with
518 EDGE_ABNORMAL_CALL or EDGE_EH. */
519 static bool
520 bb_has_abnormal_call_pred (basic_block bb)
522 edge e;
523 edge_iterator ei;
525 FOR_EACH_EDGE (e, ei, bb->preds)
527 if (e->flags & (EDGE_ABNORMAL_CALL | EDGE_EH))
528 return true;
530 return false;
533 /* Vec containing execution frequencies of program points. */
534 static vec<int> point_freq_vec;
536 /* The start of the above vector elements. */
537 int *lra_point_freq;
539 /* Increment the current program point POINT to the next point which has
540 execution frequency FREQ. */
541 static void
542 next_program_point (int &point, int freq)
544 point_freq_vec.safe_push (freq);
545 lra_point_freq = point_freq_vec.address ();
546 point++;
549 /* Update the preference of HARD_REGNO for pseudo REGNO by PROFIT. */
550 void
551 lra_setup_reload_pseudo_preferenced_hard_reg (int regno,
552 int hard_regno, int profit)
554 lra_assert (regno >= lra_constraint_new_regno_start);
555 if (lra_reg_info[regno].preferred_hard_regno1 == hard_regno)
556 lra_reg_info[regno].preferred_hard_regno_profit1 += profit;
557 else if (lra_reg_info[regno].preferred_hard_regno2 == hard_regno)
558 lra_reg_info[regno].preferred_hard_regno_profit2 += profit;
559 else if (lra_reg_info[regno].preferred_hard_regno1 < 0)
561 lra_reg_info[regno].preferred_hard_regno1 = hard_regno;
562 lra_reg_info[regno].preferred_hard_regno_profit1 = profit;
564 else if (lra_reg_info[regno].preferred_hard_regno2 < 0
565 || profit > lra_reg_info[regno].preferred_hard_regno_profit2)
567 lra_reg_info[regno].preferred_hard_regno2 = hard_regno;
568 lra_reg_info[regno].preferred_hard_regno_profit2 = profit;
570 else
571 return;
572 /* Keep the 1st hard regno as more profitable. */
573 if (lra_reg_info[regno].preferred_hard_regno1 >= 0
574 && lra_reg_info[regno].preferred_hard_regno2 >= 0
575 && (lra_reg_info[regno].preferred_hard_regno_profit2
576 > lra_reg_info[regno].preferred_hard_regno_profit1))
578 int temp;
580 temp = lra_reg_info[regno].preferred_hard_regno1;
581 lra_reg_info[regno].preferred_hard_regno1
582 = lra_reg_info[regno].preferred_hard_regno2;
583 lra_reg_info[regno].preferred_hard_regno2 = temp;
584 temp = lra_reg_info[regno].preferred_hard_regno_profit1;
585 lra_reg_info[regno].preferred_hard_regno_profit1
586 = lra_reg_info[regno].preferred_hard_regno_profit2;
587 lra_reg_info[regno].preferred_hard_regno_profit2 = temp;
589 if (lra_dump_file != NULL)
591 if ((hard_regno = lra_reg_info[regno].preferred_hard_regno1) >= 0)
592 fprintf (lra_dump_file,
593 " Hard reg %d is preferable by r%d with profit %d\n",
594 hard_regno, regno,
595 lra_reg_info[regno].preferred_hard_regno_profit1);
596 if ((hard_regno = lra_reg_info[regno].preferred_hard_regno2) >= 0)
597 fprintf (lra_dump_file,
598 " Hard reg %d is preferable by r%d with profit %d\n",
599 hard_regno, regno,
600 lra_reg_info[regno].preferred_hard_regno_profit2);
604 /* Check that REGNO living through calls and setjumps, set up conflict
605 regs, and clear corresponding bits in PSEUDOS_LIVE_THROUGH_CALLS and
606 PSEUDOS_LIVE_THROUGH_SETJUMPS. */
607 static inline void
608 check_pseudos_live_through_calls (int regno)
610 int hr;
612 if (! sparseset_bit_p (pseudos_live_through_calls, regno))
613 return;
614 sparseset_clear_bit (pseudos_live_through_calls, regno);
615 IOR_HARD_REG_SET (lra_reg_info[regno].conflict_hard_regs,
616 call_used_reg_set);
618 for (hr = 0; hr < FIRST_PSEUDO_REGISTER; hr++)
619 if (HARD_REGNO_CALL_PART_CLOBBERED (hr, PSEUDO_REGNO_MODE (regno)))
620 SET_HARD_REG_BIT (lra_reg_info[regno].conflict_hard_regs, hr);
621 #ifdef ENABLE_CHECKING
622 lra_reg_info[regno].call_p = true;
623 #endif
624 if (! sparseset_bit_p (pseudos_live_through_setjumps, regno))
625 return;
626 sparseset_clear_bit (pseudos_live_through_setjumps, regno);
627 /* Don't allocate pseudos that cross setjmps or any call, if this
628 function receives a nonlocal goto. */
629 SET_HARD_REG_SET (lra_reg_info[regno].conflict_hard_regs);
632 /* Process insns of the basic block BB to update pseudo live ranges,
633 pseudo hard register conflicts, and insn notes. We do it on
634 backward scan of BB insns. CURR_POINT is the program point where
635 BB ends. The function updates this counter and returns in
636 CURR_POINT the program point where BB starts. The function also
637 does local live info updates and can delete the dead insns if
638 DEAD_INSN_P. It returns true if pseudo live info was
639 changed at the BB start. */
640 static bool
641 process_bb_lives (basic_block bb, int &curr_point, bool dead_insn_p)
643 int i, regno, freq;
644 unsigned int j;
645 bitmap_iterator bi;
646 bitmap reg_live_out;
647 unsigned int px;
648 rtx_insn *next;
649 rtx link, *link_loc;
650 bool need_curr_point_incr;
652 reg_live_out = df_get_live_out (bb);
653 sparseset_clear (pseudos_live);
654 sparseset_clear (pseudos_live_through_calls);
655 sparseset_clear (pseudos_live_through_setjumps);
656 REG_SET_TO_HARD_REG_SET (hard_regs_live, reg_live_out);
657 AND_COMPL_HARD_REG_SET (hard_regs_live, eliminable_regset);
658 EXECUTE_IF_SET_IN_BITMAP (reg_live_out, FIRST_PSEUDO_REGISTER, j, bi)
659 mark_pseudo_live (j, curr_point);
661 bb_gen_pseudos = &get_bb_data (bb)->gen_pseudos;
662 bb_killed_pseudos = &get_bb_data (bb)->killed_pseudos;
663 bitmap_clear (bb_gen_pseudos);
664 bitmap_clear (bb_killed_pseudos);
665 freq = REG_FREQ_FROM_BB (bb);
667 if (lra_dump_file != NULL)
668 fprintf (lra_dump_file, " BB %d\n", bb->index);
670 /* Scan the code of this basic block, noting which pseudos and hard
671 regs are born or die.
673 Note that this loop treats uninitialized values as live until the
674 beginning of the block. For example, if an instruction uses
675 (reg:DI foo), and only (subreg:SI (reg:DI foo) 0) is ever set,
676 FOO will remain live until the beginning of the block. Likewise
677 if FOO is not set at all. This is unnecessarily pessimistic, but
678 it probably doesn't matter much in practice. */
679 FOR_BB_INSNS_REVERSE_SAFE (bb, curr_insn, next)
681 bool call_p;
682 int dst_regno, src_regno;
683 rtx set;
684 struct lra_insn_reg *reg;
686 if (!NONDEBUG_INSN_P (curr_insn))
687 continue;
689 curr_id = lra_get_insn_recog_data (curr_insn);
690 curr_static_id = curr_id->insn_static_data;
691 if (lra_dump_file != NULL)
692 fprintf (lra_dump_file, " Insn %u: point = %d\n",
693 INSN_UID (curr_insn), curr_point);
695 set = single_set (curr_insn);
697 if (dead_insn_p && set != NULL_RTX
698 && REG_P (SET_DEST (set)) && REGNO (SET_DEST (set)) >= FIRST_PSEUDO_REGISTER
699 && find_reg_note (curr_insn, REG_EH_REGION, NULL_RTX) == NULL_RTX
700 && ! may_trap_p (PATTERN (curr_insn))
701 /* Don't do premature remove of pic offset pseudo as we can
702 start to use it after some reload generation. */
703 && (pic_offset_table_rtx == NULL_RTX
704 || pic_offset_table_rtx != SET_DEST (set)))
706 bool remove_p = true;
708 for (reg = curr_id->regs; reg != NULL; reg = reg->next)
709 if (reg->type != OP_IN && sparseset_bit_p (pseudos_live, reg->regno))
711 remove_p = false;
712 break;
714 for (reg = curr_static_id->hard_regs; reg != NULL; reg = reg->next)
715 if (reg->type != OP_IN)
717 remove_p = false;
718 break;
720 if (remove_p && ! volatile_refs_p (PATTERN (curr_insn)))
722 dst_regno = REGNO (SET_DEST (set));
723 if (lra_dump_file != NULL)
724 fprintf (lra_dump_file, " Deleting dead insn %u\n",
725 INSN_UID (curr_insn));
726 lra_set_insn_deleted (curr_insn);
727 if (lra_reg_info[dst_regno].nrefs == 0)
729 /* There might be some debug insns with the pseudo. */
730 unsigned int uid;
731 rtx_insn *insn;
733 bitmap_copy (&temp_bitmap, &lra_reg_info[dst_regno].insn_bitmap);
734 EXECUTE_IF_SET_IN_BITMAP (&temp_bitmap, 0, uid, bi)
736 insn = lra_insn_recog_data[uid]->insn;
737 lra_substitute_pseudo_within_insn (insn, dst_regno,
738 SET_SRC (set));
739 lra_update_insn_regno_info (insn);
742 continue;
746 /* Update max ref width and hard reg usage. */
747 for (reg = curr_id->regs; reg != NULL; reg = reg->next)
748 if (reg->regno >= FIRST_PSEUDO_REGISTER
749 && (GET_MODE_SIZE (reg->biggest_mode)
750 > GET_MODE_SIZE (lra_reg_info[reg->regno].biggest_mode)))
751 lra_reg_info[reg->regno].biggest_mode = reg->biggest_mode;
752 else if (reg->regno < FIRST_PSEUDO_REGISTER)
753 lra_hard_reg_usage[reg->regno] += freq;
755 call_p = CALL_P (curr_insn);
756 if (complete_info_p
757 && set != NULL_RTX
758 && REG_P (SET_DEST (set)) && REG_P (SET_SRC (set))
759 /* Check that source regno does not conflict with
760 destination regno to exclude most impossible
761 preferences. */
762 && ((((src_regno = REGNO (SET_SRC (set))) >= FIRST_PSEUDO_REGISTER
763 && ! sparseset_bit_p (pseudos_live, src_regno))
764 || (src_regno < FIRST_PSEUDO_REGISTER
765 && ! TEST_HARD_REG_BIT (hard_regs_live, src_regno)))
766 /* It might be 'inheritance pseudo <- reload pseudo'. */
767 || (src_regno >= lra_constraint_new_regno_start
768 && ((int) REGNO (SET_DEST (set))
769 >= lra_constraint_new_regno_start)
770 /* Remember to skip special cases where src/dest regnos are
771 the same, e.g. insn SET pattern has matching constraints
772 like =r,0. */
773 && src_regno != (int) REGNO (SET_DEST (set)))))
775 int hard_regno = -1, regno = -1;
777 dst_regno = REGNO (SET_DEST (set));
778 if (dst_regno >= lra_constraint_new_regno_start
779 && src_regno >= lra_constraint_new_regno_start)
780 lra_create_copy (dst_regno, src_regno, freq);
781 else if (dst_regno >= lra_constraint_new_regno_start)
783 if ((hard_regno = src_regno) >= FIRST_PSEUDO_REGISTER)
784 hard_regno = reg_renumber[src_regno];
785 regno = dst_regno;
787 else if (src_regno >= lra_constraint_new_regno_start)
789 if ((hard_regno = dst_regno) >= FIRST_PSEUDO_REGISTER)
790 hard_regno = reg_renumber[dst_regno];
791 regno = src_regno;
793 if (regno >= 0 && hard_regno >= 0)
794 lra_setup_reload_pseudo_preferenced_hard_reg
795 (regno, hard_regno, freq);
798 sparseset_clear (start_living);
800 /* Try to avoid unnecessary program point increments, this saves
801 a lot of time in remove_some_program_points_and_update_live_ranges.
802 We only need an increment if something becomes live or dies at this
803 program point. */
804 need_curr_point_incr = false;
806 /* Mark each defined value as live. We need to do this for
807 unused values because they still conflict with quantities
808 that are live at the time of the definition. */
809 for (reg = curr_id->regs; reg != NULL; reg = reg->next)
810 if (reg->type != OP_IN)
812 need_curr_point_incr
813 |= mark_regno_live (reg->regno, reg->biggest_mode,
814 curr_point);
815 check_pseudos_live_through_calls (reg->regno);
818 for (reg = curr_static_id->hard_regs; reg != NULL; reg = reg->next)
819 if (reg->type != OP_IN)
820 make_hard_regno_born (reg->regno);
822 sparseset_copy (unused_set, start_living);
824 sparseset_clear (start_dying);
826 /* See which defined values die here. */
827 for (reg = curr_id->regs; reg != NULL; reg = reg->next)
828 if (reg->type == OP_OUT && ! reg->early_clobber && ! reg->subreg_p)
829 need_curr_point_incr
830 |= mark_regno_dead (reg->regno, reg->biggest_mode,
831 curr_point);
833 for (reg = curr_static_id->hard_regs; reg != NULL; reg = reg->next)
834 if (reg->type == OP_OUT && ! reg->early_clobber && ! reg->subreg_p)
835 make_hard_regno_dead (reg->regno);
837 if (call_p)
839 if (flag_ipa_ra)
841 HARD_REG_SET this_call_used_reg_set;
842 get_call_reg_set_usage (curr_insn, &this_call_used_reg_set,
843 call_used_reg_set);
845 EXECUTE_IF_SET_IN_SPARSESET (pseudos_live, j)
846 IOR_HARD_REG_SET (lra_reg_info[j].actual_call_used_reg_set,
847 this_call_used_reg_set);
850 sparseset_ior (pseudos_live_through_calls,
851 pseudos_live_through_calls, pseudos_live);
852 if (cfun->has_nonlocal_label
853 || find_reg_note (curr_insn, REG_SETJMP,
854 NULL_RTX) != NULL_RTX)
855 sparseset_ior (pseudos_live_through_setjumps,
856 pseudos_live_through_setjumps, pseudos_live);
859 /* Increment the current program point if we must. */
860 if (need_curr_point_incr)
861 next_program_point (curr_point, freq);
863 sparseset_clear (start_living);
865 need_curr_point_incr = false;
867 /* Mark each used value as live. */
868 for (reg = curr_id->regs; reg != NULL; reg = reg->next)
869 if (reg->type == OP_IN)
871 need_curr_point_incr
872 |= mark_regno_live (reg->regno, reg->biggest_mode,
873 curr_point);
874 check_pseudos_live_through_calls (reg->regno);
877 for (reg = curr_static_id->hard_regs; reg != NULL; reg = reg->next)
878 if (reg->type == OP_IN)
879 make_hard_regno_born (reg->regno);
881 if (curr_id->arg_hard_regs != NULL)
882 /* Make argument hard registers live. */
883 for (i = 0; (regno = curr_id->arg_hard_regs[i]) >= 0; i++)
884 make_hard_regno_born (regno);
886 sparseset_and_compl (dead_set, start_living, start_dying);
888 /* Mark early clobber outputs dead. */
889 for (reg = curr_id->regs; reg != NULL; reg = reg->next)
890 if (reg->type == OP_OUT && reg->early_clobber && ! reg->subreg_p)
891 need_curr_point_incr
892 |= mark_regno_dead (reg->regno, reg->biggest_mode,
893 curr_point);
895 for (reg = curr_static_id->hard_regs; reg != NULL; reg = reg->next)
896 if (reg->type == OP_OUT && reg->early_clobber && ! reg->subreg_p)
897 make_hard_regno_dead (reg->regno);
899 if (need_curr_point_incr)
900 next_program_point (curr_point, freq);
902 /* Update notes. */
903 for (link_loc = &REG_NOTES (curr_insn); (link = *link_loc) != NULL_RTX;)
905 if (REG_NOTE_KIND (link) != REG_DEAD
906 && REG_NOTE_KIND (link) != REG_UNUSED)
908 else if (REG_P (XEXP (link, 0)))
910 regno = REGNO (XEXP (link, 0));
911 if ((REG_NOTE_KIND (link) == REG_DEAD
912 && ! sparseset_bit_p (dead_set, regno))
913 || (REG_NOTE_KIND (link) == REG_UNUSED
914 && ! sparseset_bit_p (unused_set, regno)))
916 *link_loc = XEXP (link, 1);
917 continue;
919 if (REG_NOTE_KIND (link) == REG_DEAD)
920 sparseset_clear_bit (dead_set, regno);
921 else if (REG_NOTE_KIND (link) == REG_UNUSED)
922 sparseset_clear_bit (unused_set, regno);
924 link_loc = &XEXP (link, 1);
926 EXECUTE_IF_SET_IN_SPARSESET (dead_set, j)
927 add_reg_note (curr_insn, REG_DEAD, regno_reg_rtx[j]);
928 EXECUTE_IF_SET_IN_SPARSESET (unused_set, j)
929 add_reg_note (curr_insn, REG_UNUSED, regno_reg_rtx[j]);
932 #ifdef EH_RETURN_DATA_REGNO
933 if (bb_has_eh_pred (bb))
934 for (j = 0; ; ++j)
936 unsigned int regno = EH_RETURN_DATA_REGNO (j);
938 if (regno == INVALID_REGNUM)
939 break;
940 make_hard_regno_born (regno);
942 #endif
944 /* Pseudos can't go in stack regs at the start of a basic block that
945 is reached by an abnormal edge. Likewise for call clobbered regs,
946 because caller-save, fixup_abnormal_edges and possibly the table
947 driven EH machinery are not quite ready to handle such pseudos
948 live across such edges. */
949 if (bb_has_abnormal_pred (bb))
951 #ifdef STACK_REGS
952 EXECUTE_IF_SET_IN_SPARSESET (pseudos_live, px)
953 lra_reg_info[px].no_stack_p = true;
954 for (px = FIRST_STACK_REG; px <= LAST_STACK_REG; px++)
955 make_hard_regno_born (px);
956 #endif
957 /* No need to record conflicts for call clobbered regs if we
958 have nonlocal labels around, as we don't ever try to
959 allocate such regs in this case. */
960 if (!cfun->has_nonlocal_label && bb_has_abnormal_call_pred (bb))
961 for (px = 0; px < FIRST_PSEUDO_REGISTER; px++)
962 if (call_used_regs[px])
963 make_hard_regno_born (px);
966 bool live_change_p = false;
967 /* Check if bb border live info was changed. */
968 unsigned int live_pseudos_num = 0;
969 EXECUTE_IF_SET_IN_BITMAP (df_get_live_in (bb),
970 FIRST_PSEUDO_REGISTER, j, bi)
972 live_pseudos_num++;
973 if (! sparseset_bit_p (pseudos_live, j))
975 live_change_p = true;
976 if (lra_dump_file != NULL)
977 fprintf (lra_dump_file,
978 " r%d is removed as live at bb%d start\n", j, bb->index);
979 break;
982 if (! live_change_p
983 && sparseset_cardinality (pseudos_live) != live_pseudos_num)
985 live_change_p = true;
986 if (lra_dump_file != NULL)
987 EXECUTE_IF_SET_IN_SPARSESET (pseudos_live, j)
988 if (! bitmap_bit_p (df_get_live_in (bb), j))
989 fprintf (lra_dump_file,
990 " r%d is added to live at bb%d start\n", j, bb->index);
992 /* See if we'll need an increment at the end of this basic block.
993 An increment is needed if the PSEUDOS_LIVE set is not empty,
994 to make sure the finish points are set up correctly. */
995 need_curr_point_incr = (sparseset_cardinality (pseudos_live) > 0);
997 EXECUTE_IF_SET_IN_SPARSESET (pseudos_live, i)
998 mark_pseudo_dead (i, curr_point);
1000 EXECUTE_IF_SET_IN_BITMAP (df_get_live_in (bb), FIRST_PSEUDO_REGISTER, j, bi)
1002 if (sparseset_cardinality (pseudos_live_through_calls) == 0)
1003 break;
1004 if (sparseset_bit_p (pseudos_live_through_calls, j))
1005 check_pseudos_live_through_calls (j);
1008 if (need_curr_point_incr)
1009 next_program_point (curr_point, freq);
1011 return live_change_p;
1014 /* Compress pseudo live ranges by removing program points where
1015 nothing happens. Complexity of many algorithms in LRA is linear
1016 function of program points number. To speed up the code we try to
1017 minimize the number of the program points here. */
1018 static void
1019 remove_some_program_points_and_update_live_ranges (void)
1021 unsigned i;
1022 int n, max_regno;
1023 int *map;
1024 lra_live_range_t r, prev_r, next_r;
1025 sbitmap born_or_dead, born, dead;
1026 sbitmap_iterator sbi;
1027 bool born_p, dead_p, prev_born_p, prev_dead_p;
1029 born = sbitmap_alloc (lra_live_max_point);
1030 dead = sbitmap_alloc (lra_live_max_point);
1031 bitmap_clear (born);
1032 bitmap_clear (dead);
1033 max_regno = max_reg_num ();
1034 for (i = FIRST_PSEUDO_REGISTER; i < (unsigned) max_regno; i++)
1036 for (r = lra_reg_info[i].live_ranges; r != NULL; r = r->next)
1038 lra_assert (r->start <= r->finish);
1039 bitmap_set_bit (born, r->start);
1040 bitmap_set_bit (dead, r->finish);
1043 born_or_dead = sbitmap_alloc (lra_live_max_point);
1044 bitmap_ior (born_or_dead, born, dead);
1045 map = XCNEWVEC (int, lra_live_max_point);
1046 n = -1;
1047 prev_born_p = prev_dead_p = false;
1048 EXECUTE_IF_SET_IN_BITMAP (born_or_dead, 0, i, sbi)
1050 born_p = bitmap_bit_p (born, i);
1051 dead_p = bitmap_bit_p (dead, i);
1052 if ((prev_born_p && ! prev_dead_p && born_p && ! dead_p)
1053 || (prev_dead_p && ! prev_born_p && dead_p && ! born_p))
1055 map[i] = n;
1056 lra_point_freq[n] = MAX (lra_point_freq[n], lra_point_freq[i]);
1058 else
1060 map[i] = ++n;
1061 lra_point_freq[n] = lra_point_freq[i];
1063 prev_born_p = born_p;
1064 prev_dead_p = dead_p;
1066 sbitmap_free (born_or_dead);
1067 sbitmap_free (born);
1068 sbitmap_free (dead);
1069 n++;
1070 if (lra_dump_file != NULL)
1071 fprintf (lra_dump_file, "Compressing live ranges: from %d to %d - %d%%\n",
1072 lra_live_max_point, n, 100 * n / lra_live_max_point);
1073 if (n < lra_live_max_point)
1075 lra_live_max_point = n;
1076 for (i = FIRST_PSEUDO_REGISTER; i < (unsigned) max_regno; i++)
1078 for (prev_r = NULL, r = lra_reg_info[i].live_ranges;
1079 r != NULL;
1080 r = next_r)
1082 next_r = r->next;
1083 r->start = map[r->start];
1084 r->finish = map[r->finish];
1085 if (prev_r == NULL || prev_r->start > r->finish + 1)
1087 prev_r = r;
1088 continue;
1090 prev_r->start = r->start;
1091 prev_r->next = next_r;
1092 free_live_range (r);
1096 free (map);
1099 /* Print live ranges R to file F. */
1100 void
1101 lra_print_live_range_list (FILE *f, lra_live_range_t r)
1103 for (; r != NULL; r = r->next)
1104 fprintf (f, " [%d..%d]", r->start, r->finish);
1105 fprintf (f, "\n");
1108 DEBUG_FUNCTION void
1109 debug (lra_live_range &ref)
1111 lra_print_live_range_list (stderr, &ref);
1114 DEBUG_FUNCTION void
1115 debug (lra_live_range *ptr)
1117 if (ptr)
1118 debug (*ptr);
1119 else
1120 fprintf (stderr, "<nil>\n");
1123 /* Print live ranges R to stderr. */
1124 void
1125 lra_debug_live_range_list (lra_live_range_t r)
1127 lra_print_live_range_list (stderr, r);
1130 /* Print live ranges of pseudo REGNO to file F. */
1131 static void
1132 print_pseudo_live_ranges (FILE *f, int regno)
1134 if (lra_reg_info[regno].live_ranges == NULL)
1135 return;
1136 fprintf (f, " r%d:", regno);
1137 lra_print_live_range_list (f, lra_reg_info[regno].live_ranges);
1140 /* Print live ranges of pseudo REGNO to stderr. */
1141 void
1142 lra_debug_pseudo_live_ranges (int regno)
1144 print_pseudo_live_ranges (stderr, regno);
1147 /* Print live ranges of all pseudos to file F. */
1148 static void
1149 print_live_ranges (FILE *f)
1151 int i, max_regno;
1153 max_regno = max_reg_num ();
1154 for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
1155 print_pseudo_live_ranges (f, i);
1158 /* Print live ranges of all pseudos to stderr. */
1159 void
1160 lra_debug_live_ranges (void)
1162 print_live_ranges (stderr);
1165 /* Compress pseudo live ranges. */
1166 static void
1167 compress_live_ranges (void)
1169 remove_some_program_points_and_update_live_ranges ();
1170 if (lra_dump_file != NULL)
1172 fprintf (lra_dump_file, "Ranges after the compression:\n");
1173 print_live_ranges (lra_dump_file);
1179 /* The number of the current live range pass. */
1180 int lra_live_range_iter;
1182 /* The function creates live ranges only for memory pseudos (or for
1183 all ones if ALL_P), set up CONFLICT_HARD_REGS for the pseudos. It
1184 also does dead insn elimination if DEAD_INSN_P and global live
1185 analysis only for pseudos and only if the pseudo live info was
1186 changed on a BB border. Return TRUE if the live info was
1187 changed. */
1188 static bool
1189 lra_create_live_ranges_1 (bool all_p, bool dead_insn_p)
1191 basic_block bb;
1192 int i, hard_regno, max_regno = max_reg_num ();
1193 int curr_point;
1194 bool bb_live_change_p, have_referenced_pseudos = false;
1196 timevar_push (TV_LRA_CREATE_LIVE_RANGES);
1198 complete_info_p = all_p;
1199 if (lra_dump_file != NULL)
1200 fprintf (lra_dump_file,
1201 "\n********** Pseudo live ranges #%d: **********\n\n",
1202 ++lra_live_range_iter);
1203 memset (lra_hard_reg_usage, 0, sizeof (lra_hard_reg_usage));
1204 for (i = 0; i < max_regno; i++)
1206 lra_reg_info[i].live_ranges = NULL;
1207 CLEAR_HARD_REG_SET (lra_reg_info[i].conflict_hard_regs);
1208 lra_reg_info[i].preferred_hard_regno1 = -1;
1209 lra_reg_info[i].preferred_hard_regno2 = -1;
1210 lra_reg_info[i].preferred_hard_regno_profit1 = 0;
1211 lra_reg_info[i].preferred_hard_regno_profit2 = 0;
1212 #ifdef STACK_REGS
1213 lra_reg_info[i].no_stack_p = false;
1214 #endif
1215 /* The biggest mode is already set but its value might be to
1216 conservative because of recent transformation. Here in this
1217 file we recalculate it again as it costs practically
1218 nothing. */
1219 if (regno_reg_rtx[i] != NULL_RTX)
1220 lra_reg_info[i].biggest_mode = GET_MODE (regno_reg_rtx[i]);
1221 else
1222 lra_reg_info[i].biggest_mode = VOIDmode;
1223 #ifdef ENABLE_CHECKING
1224 lra_reg_info[i].call_p = false;
1225 #endif
1226 if (i >= FIRST_PSEUDO_REGISTER
1227 && lra_reg_info[i].nrefs != 0)
1229 if ((hard_regno = reg_renumber[i]) >= 0)
1230 lra_hard_reg_usage[hard_regno] += lra_reg_info[i].freq;
1231 have_referenced_pseudos = true;
1234 lra_free_copies ();
1236 /* Under some circumstances, we can have functions without pseudo
1237 registers. For such functions, lra_live_max_point will be 0,
1238 see e.g. PR55604, and there's nothing more to do for us here. */
1239 if (! have_referenced_pseudos)
1241 timevar_pop (TV_LRA_CREATE_LIVE_RANGES);
1242 return false;
1245 pseudos_live = sparseset_alloc (max_regno);
1246 pseudos_live_through_calls = sparseset_alloc (max_regno);
1247 pseudos_live_through_setjumps = sparseset_alloc (max_regno);
1248 start_living = sparseset_alloc (max_regno);
1249 start_dying = sparseset_alloc (max_regno);
1250 dead_set = sparseset_alloc (max_regno);
1251 unused_set = sparseset_alloc (max_regno);
1252 curr_point = 0;
1253 point_freq_vec.create (get_max_uid () * 2);
1254 lra_point_freq = point_freq_vec.address ();
1255 int *post_order_rev_cfg = XNEWVEC (int, last_basic_block_for_fn (cfun));
1256 int n_blocks_inverted = inverted_post_order_compute (post_order_rev_cfg);
1257 lra_assert (n_blocks_inverted == n_basic_blocks_for_fn (cfun));
1258 bb_live_change_p = false;
1259 for (i = n_blocks_inverted - 1; i >= 0; --i)
1261 bb = BASIC_BLOCK_FOR_FN (cfun, post_order_rev_cfg[i]);
1262 if (bb == EXIT_BLOCK_PTR_FOR_FN (cfun) || bb
1263 == ENTRY_BLOCK_PTR_FOR_FN (cfun))
1264 continue;
1265 if (process_bb_lives (bb, curr_point, dead_insn_p))
1266 bb_live_change_p = true;
1268 if (bb_live_change_p)
1270 /* We need to clear pseudo live info as some pseudos can
1271 disappear, e.g. pseudos with used equivalences. */
1272 FOR_EACH_BB_FN (bb, cfun)
1274 bitmap_clear_range (df_get_live_in (bb), FIRST_PSEUDO_REGISTER,
1275 max_regno - FIRST_PSEUDO_REGISTER);
1276 bitmap_clear_range (df_get_live_out (bb), FIRST_PSEUDO_REGISTER,
1277 max_regno - FIRST_PSEUDO_REGISTER);
1279 /* As we did not change CFG since LRA start we can use
1280 DF-infrastructure solver to solve live data flow problem. */
1281 df_simple_dataflow
1282 (DF_BACKWARD, NULL, live_con_fun_0, live_con_fun_n,
1283 live_trans_fun, &all_blocks,
1284 df_get_postorder (DF_BACKWARD), df_get_n_blocks (DF_BACKWARD));
1285 if (lra_dump_file != NULL)
1287 fprintf (lra_dump_file,
1288 "Global pseudo live data have been updated:\n");
1289 basic_block bb;
1290 FOR_EACH_BB_FN (bb, cfun)
1292 bb_data_t bb_info = get_bb_data (bb);
1293 bitmap bb_livein = df_get_live_in (bb);
1294 bitmap bb_liveout = df_get_live_out (bb);
1296 fprintf (lra_dump_file, "\nBB %d:\n", bb->index);
1297 lra_dump_bitmap_with_title (" gen:",
1298 &bb_info->gen_pseudos, bb->index);
1299 lra_dump_bitmap_with_title (" killed:",
1300 &bb_info->killed_pseudos, bb->index);
1301 lra_dump_bitmap_with_title (" livein:", bb_livein, bb->index);
1302 lra_dump_bitmap_with_title (" liveout:", bb_liveout, bb->index);
1306 free (post_order_rev_cfg);
1307 lra_live_max_point = curr_point;
1308 if (lra_dump_file != NULL)
1309 print_live_ranges (lra_dump_file);
1310 /* Clean up. */
1311 sparseset_free (unused_set);
1312 sparseset_free (dead_set);
1313 sparseset_free (start_dying);
1314 sparseset_free (start_living);
1315 sparseset_free (pseudos_live_through_calls);
1316 sparseset_free (pseudos_live_through_setjumps);
1317 sparseset_free (pseudos_live);
1318 compress_live_ranges ();
1319 timevar_pop (TV_LRA_CREATE_LIVE_RANGES);
1320 return bb_live_change_p;
1323 /* The main entry function creates live-ranges and other live info
1324 necessary for the assignment sub-pass. It uses
1325 lra_creates_live_ranges_1 -- so read comments for the
1326 function. */
1327 void
1328 lra_create_live_ranges (bool all_p, bool dead_insn_p)
1330 if (! lra_create_live_ranges_1 (all_p, dead_insn_p))
1331 return;
1332 if (lra_dump_file != NULL)
1333 fprintf (lra_dump_file, "Live info was changed -- recalculate it\n");
1334 /* Live info was changed on a bb border. It means that some info,
1335 e.g. about conflict regs, calls crossed, and live ranges may be
1336 wrong. We need this info for allocation. So recalculate it
1337 again but without removing dead insns which can change live info
1338 again. Repetitive live range calculations are expensive therefore
1339 we stop here as we already have correct info although some
1340 improvement in rare cases could be possible on this sub-pass if
1341 we do dead insn elimination again (still the improvement may
1342 happen later). */
1343 lra_clear_live_ranges ();
1344 bool res = lra_create_live_ranges_1 (all_p, false);
1345 lra_assert (! res);
1348 /* Finish all live ranges. */
1349 void
1350 lra_clear_live_ranges (void)
1352 int i;
1354 for (i = 0; i < max_reg_num (); i++)
1355 free_live_range_list (lra_reg_info[i].live_ranges);
1356 point_freq_vec.release ();
1359 /* Initialize live ranges data once per function. */
1360 void
1361 lra_live_ranges_init (void)
1363 live_range_pool = create_alloc_pool ("live ranges",
1364 sizeof (struct lra_live_range), 100);
1365 bitmap_initialize (&temp_bitmap, &reg_obstack);
1366 initiate_live_solver ();
1369 /* Finish live ranges data once per function. */
1370 void
1371 lra_live_ranges_finish (void)
1373 finish_live_solver ();
1374 bitmap_clear (&temp_bitmap);
1375 free_alloc_pool (live_range_pool);