PR testsuite/66621
[official-gcc.git] / gcc / lra-lives.c
blob16e1f386b3e620b047753c55fe1835ae821d224a
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 "function.h"
40 #include "symtab.h"
41 #include "flags.h"
42 #include "alias.h"
43 #include "tree.h"
44 #include "expmed.h"
45 #include "dojump.h"
46 #include "explow.h"
47 #include "calls.h"
48 #include "emit-rtl.h"
49 #include "varasm.h"
50 #include "stmt.h"
51 #include "expr.h"
52 #include "predict.h"
53 #include "dominance.h"
54 #include "cfg.h"
55 #include "cfganal.h"
56 #include "basic-block.h"
57 #include "except.h"
58 #include "df.h"
59 #include "ira.h"
60 #include "sparseset.h"
61 #include "lra-int.h"
63 /* Program points are enumerated by numbers from range
64 0..LRA_LIVE_MAX_POINT-1. There are approximately two times more
65 program points than insns. Program points are places in the
66 program where liveness info can be changed. In most general case
67 (there are more complicated cases too) some program points
68 correspond to places where input operand dies and other ones
69 correspond to places where output operands are born. */
70 int lra_live_max_point;
72 /* Accumulated execution frequency of all references for each hard
73 register. */
74 int lra_hard_reg_usage[FIRST_PSEUDO_REGISTER];
76 /* A global flag whose true value says to build live ranges for all
77 pseudos, otherwise the live ranges only for pseudos got memory is
78 build. True value means also building copies and setting up hard
79 register preferences. The complete info is necessary only for the
80 assignment pass. The complete info is not needed for the
81 coalescing and spill passes. */
82 static bool complete_info_p;
84 /* Pseudos live at current point in the RTL scan. */
85 static sparseset pseudos_live;
87 /* Pseudos probably living through calls and setjumps. As setjump is
88 a call too, if a bit in PSEUDOS_LIVE_THROUGH_SETJUMPS is set up
89 then the corresponding bit in PSEUDOS_LIVE_THROUGH_CALLS is set up
90 too. These data are necessary for cases when only one subreg of a
91 multi-reg pseudo is set up after a call. So we decide it is
92 probably live when traversing bb backward. We are sure about
93 living when we see its usage or definition of the pseudo. */
94 static sparseset pseudos_live_through_calls;
95 static sparseset pseudos_live_through_setjumps;
97 /* Set of hard regs (except eliminable ones) currently live. */
98 static HARD_REG_SET hard_regs_live;
100 /* Set of pseudos and hard registers start living/dying in the current
101 insn. These sets are used to update REG_DEAD and REG_UNUSED notes
102 in the insn. */
103 static sparseset start_living, start_dying;
105 /* Set of pseudos and hard regs dead and unused in the current
106 insn. */
107 static sparseset unused_set, dead_set;
109 /* Bitmap used for holding intermediate bitmap operation results. */
110 static bitmap_head temp_bitmap;
112 /* Pool for pseudo live ranges. */
113 pool_allocator <lra_live_range> lra_live_range::pool ("live ranges", 100);
115 /* Free live range list LR. */
116 static void
117 free_live_range_list (lra_live_range_t lr)
119 lra_live_range_t next;
121 while (lr != NULL)
123 next = lr->next;
124 delete lr;
125 lr = next;
129 /* Create and return pseudo live range with given attributes. */
130 static lra_live_range_t
131 create_live_range (int regno, int start, int finish, lra_live_range_t next)
133 lra_live_range_t p = new lra_live_range;
134 p->regno = regno;
135 p->start = start;
136 p->finish = finish;
137 p->next = next;
138 return p;
141 /* Copy live range R and return the result. */
142 static lra_live_range_t
143 copy_live_range (lra_live_range_t r)
145 return new lra_live_range (*r);
148 /* Copy live range list given by its head R and return the result. */
149 lra_live_range_t
150 lra_copy_live_range_list (lra_live_range_t r)
152 lra_live_range_t p, first, *chain;
154 first = NULL;
155 for (chain = &first; r != NULL; r = r->next)
157 p = copy_live_range (r);
158 *chain = p;
159 chain = &p->next;
161 return first;
164 /* Merge *non-intersected* ranges R1 and R2 and returns the result.
165 The function maintains the order of ranges and tries to minimize
166 size of the result range list. Ranges R1 and R2 may not be used
167 after the call. */
168 lra_live_range_t
169 lra_merge_live_ranges (lra_live_range_t r1, lra_live_range_t r2)
171 lra_live_range_t first, last;
173 if (r1 == NULL)
174 return r2;
175 if (r2 == NULL)
176 return r1;
177 for (first = last = NULL; r1 != NULL && r2 != NULL;)
179 if (r1->start < r2->start)
180 std::swap (r1, r2);
182 if (r1->start == r2->finish + 1)
184 /* Joint ranges: merge r1 and r2 into r1. */
185 r1->start = r2->start;
186 lra_live_range_t temp = r2;
187 r2 = r2->next;
188 delete temp;
190 else
192 gcc_assert (r2->finish + 1 < r1->start);
193 /* Add r1 to the result. */
194 if (first == NULL)
195 first = last = r1;
196 else
198 last->next = r1;
199 last = r1;
201 r1 = r1->next;
204 if (r1 != NULL)
206 if (first == NULL)
207 first = r1;
208 else
209 last->next = r1;
211 else
213 lra_assert (r2 != NULL);
214 if (first == NULL)
215 first = r2;
216 else
217 last->next = r2;
219 return first;
222 /* Return TRUE if live ranges R1 and R2 intersect. */
223 bool
224 lra_intersected_live_ranges_p (lra_live_range_t r1, lra_live_range_t r2)
226 /* Remember the live ranges are always kept ordered. */
227 while (r1 != NULL && r2 != NULL)
229 if (r1->start > r2->finish)
230 r1 = r1->next;
231 else if (r2->start > r1->finish)
232 r2 = r2->next;
233 else
234 return true;
236 return false;
239 /* The function processing birth of hard register REGNO. It updates
240 living hard regs, START_LIVING, and conflict hard regs for living
241 pseudos. Conflict hard regs for the pic pseudo is not updated if
242 REGNO is REAL_PIC_OFFSET_TABLE_REGNUM and CHECK_PIC_PSEUDO_P is
243 true. */
244 static void
245 make_hard_regno_born (int regno, bool check_pic_pseudo_p ATTRIBUTE_UNUSED)
247 unsigned int i;
249 lra_assert (regno < FIRST_PSEUDO_REGISTER);
250 if (TEST_HARD_REG_BIT (hard_regs_live, regno))
251 return;
252 SET_HARD_REG_BIT (hard_regs_live, regno);
253 sparseset_set_bit (start_living, regno);
254 EXECUTE_IF_SET_IN_SPARSESET (pseudos_live, i)
255 #ifdef REAL_PIC_OFFSET_TABLE_REGNUM
256 if (! check_pic_pseudo_p
257 || regno != REAL_PIC_OFFSET_TABLE_REGNUM
258 || pic_offset_table_rtx == NULL
259 || i != REGNO (pic_offset_table_rtx))
260 #endif
261 SET_HARD_REG_BIT (lra_reg_info[i].conflict_hard_regs, regno);
264 /* Process the death of hard register REGNO. This updates
265 hard_regs_live and START_DYING. */
266 static void
267 make_hard_regno_dead (int regno)
269 lra_assert (regno < FIRST_PSEUDO_REGISTER);
270 if (! TEST_HARD_REG_BIT (hard_regs_live, regno))
271 return;
272 sparseset_set_bit (start_dying, regno);
273 CLEAR_HARD_REG_BIT (hard_regs_live, regno);
276 /* Mark pseudo REGNO as living at program point POINT, update conflicting
277 hard registers of the pseudo and START_LIVING, and start a new live
278 range for the pseudo corresponding to REGNO if it is necessary. */
279 static void
280 mark_pseudo_live (int regno, int point)
282 lra_live_range_t p;
284 lra_assert (regno >= FIRST_PSEUDO_REGISTER);
285 lra_assert (! sparseset_bit_p (pseudos_live, regno));
286 sparseset_set_bit (pseudos_live, regno);
287 IOR_HARD_REG_SET (lra_reg_info[regno].conflict_hard_regs, hard_regs_live);
289 if ((complete_info_p || lra_get_regno_hard_regno (regno) < 0)
290 && ((p = lra_reg_info[regno].live_ranges) == NULL
291 || (p->finish != point && p->finish + 1 != point)))
292 lra_reg_info[regno].live_ranges
293 = create_live_range (regno, point, -1, p);
294 sparseset_set_bit (start_living, regno);
297 /* Mark pseudo REGNO as not living at program point POINT and update
298 START_DYING.
299 This finishes the current live range for the pseudo corresponding
300 to REGNO. */
301 static void
302 mark_pseudo_dead (int regno, int point)
304 lra_live_range_t p;
306 lra_assert (regno >= FIRST_PSEUDO_REGISTER);
307 lra_assert (sparseset_bit_p (pseudos_live, regno));
308 sparseset_clear_bit (pseudos_live, regno);
309 sparseset_set_bit (start_dying, regno);
310 if (complete_info_p || lra_get_regno_hard_regno (regno) < 0)
312 p = lra_reg_info[regno].live_ranges;
313 lra_assert (p != NULL);
314 p->finish = point;
318 /* The corresponding bitmaps of BB currently being processed. */
319 static bitmap bb_killed_pseudos, bb_gen_pseudos;
321 /* Mark register REGNO (pseudo or hard register) in MODE as live at
322 program point POINT. Update BB_GEN_PSEUDOS.
323 Return TRUE if the liveness tracking sets were modified, or FALSE
324 if nothing changed. */
325 static bool
326 mark_regno_live (int regno, machine_mode mode, int point)
328 int last;
329 bool changed = false;
331 if (regno < FIRST_PSEUDO_REGISTER)
333 for (last = regno + hard_regno_nregs[regno][mode];
334 regno < last;
335 regno++)
336 make_hard_regno_born (regno, false);
338 else
340 if (! sparseset_bit_p (pseudos_live, regno))
342 mark_pseudo_live (regno, point);
343 changed = true;
345 bitmap_set_bit (bb_gen_pseudos, regno);
347 return changed;
351 /* Mark register REGNO in MODE as dead at program point POINT. Update
352 BB_GEN_PSEUDOS and BB_KILLED_PSEUDOS. Return TRUE if the liveness
353 tracking sets were modified, or FALSE if nothing changed. */
354 static bool
355 mark_regno_dead (int regno, machine_mode mode, int point)
357 int last;
358 bool changed = false;
360 if (regno < FIRST_PSEUDO_REGISTER)
362 for (last = regno + hard_regno_nregs[regno][mode];
363 regno < last;
364 regno++)
365 make_hard_regno_dead (regno);
367 else
369 if (sparseset_bit_p (pseudos_live, regno))
371 mark_pseudo_dead (regno, point);
372 changed = true;
374 bitmap_clear_bit (bb_gen_pseudos, regno);
375 bitmap_set_bit (bb_killed_pseudos, regno);
377 return changed;
382 /* This page contains code for making global live analysis of pseudos.
383 The code works only when pseudo live info is changed on a BB
384 border. That might be a consequence of some global transformations
385 in LRA, e.g. PIC pseudo reuse or rematerialization. */
387 /* Structure describing local BB data used for pseudo
388 live-analysis. */
389 struct bb_data_pseudos
391 /* Basic block about which the below data are. */
392 basic_block bb;
393 bitmap_head killed_pseudos; /* pseudos killed in the BB. */
394 bitmap_head gen_pseudos; /* pseudos generated in the BB. */
397 /* Array for all BB data. Indexed by the corresponding BB index. */
398 typedef struct bb_data_pseudos *bb_data_t;
400 /* All basic block data are referred through the following array. */
401 static bb_data_t bb_data;
403 /* Two small functions for access to the bb data. */
404 static inline bb_data_t
405 get_bb_data (basic_block bb)
407 return &bb_data[(bb)->index];
410 static inline bb_data_t
411 get_bb_data_by_index (int index)
413 return &bb_data[index];
416 /* Bitmap with all hard regs. */
417 static bitmap_head all_hard_regs_bitmap;
419 /* The transfer function used by the DF equation solver to propagate
420 live info through block with BB_INDEX according to the following
421 equation:
423 bb.livein = (bb.liveout - bb.kill) OR bb.gen
425 static bool
426 live_trans_fun (int bb_index)
428 basic_block bb = get_bb_data_by_index (bb_index)->bb;
429 bitmap bb_liveout = df_get_live_out (bb);
430 bitmap bb_livein = df_get_live_in (bb);
431 bb_data_t bb_info = get_bb_data (bb);
433 bitmap_and_compl (&temp_bitmap, bb_liveout, &all_hard_regs_bitmap);
434 return bitmap_ior_and_compl (bb_livein, &bb_info->gen_pseudos,
435 &temp_bitmap, &bb_info->killed_pseudos);
438 /* The confluence function used by the DF equation solver to set up
439 live info for a block BB without predecessor. */
440 static void
441 live_con_fun_0 (basic_block bb)
443 bitmap_and_into (df_get_live_out (bb), &all_hard_regs_bitmap);
446 /* The confluence function used by the DF equation solver to propagate
447 live info from successor to predecessor on edge E according to the
448 following equation:
450 bb.liveout = 0 for entry block | OR (livein of successors)
452 static bool
453 live_con_fun_n (edge e)
455 basic_block bb = e->src;
456 basic_block dest = e->dest;
457 bitmap bb_liveout = df_get_live_out (bb);
458 bitmap dest_livein = df_get_live_in (dest);
460 return bitmap_ior_and_compl_into (bb_liveout,
461 dest_livein, &all_hard_regs_bitmap);
464 /* Indexes of all function blocks. */
465 static bitmap_head all_blocks;
467 /* Allocate and initialize data needed for global pseudo live
468 analysis. */
469 static void
470 initiate_live_solver (void)
472 bitmap_initialize (&all_hard_regs_bitmap, &reg_obstack);
473 bitmap_set_range (&all_hard_regs_bitmap, 0, FIRST_PSEUDO_REGISTER);
474 bb_data = XNEWVEC (struct bb_data_pseudos, last_basic_block_for_fn (cfun));
475 bitmap_initialize (&all_blocks, &reg_obstack);
477 basic_block bb;
478 FOR_ALL_BB_FN (bb, cfun)
480 bb_data_t bb_info = get_bb_data (bb);
481 bb_info->bb = bb;
482 bitmap_initialize (&bb_info->killed_pseudos, &reg_obstack);
483 bitmap_initialize (&bb_info->gen_pseudos, &reg_obstack);
484 bitmap_set_bit (&all_blocks, bb->index);
488 /* Free all data needed for global pseudo live analysis. */
489 static void
490 finish_live_solver (void)
492 basic_block bb;
494 bitmap_clear (&all_blocks);
495 FOR_ALL_BB_FN (bb, cfun)
497 bb_data_t bb_info = get_bb_data (bb);
498 bitmap_clear (&bb_info->killed_pseudos);
499 bitmap_clear (&bb_info->gen_pseudos);
501 free (bb_data);
502 bitmap_clear (&all_hard_regs_bitmap);
507 /* Insn currently scanned. */
508 static rtx_insn *curr_insn;
509 /* The insn data. */
510 static lra_insn_recog_data_t curr_id;
511 /* The insn static data. */
512 static struct lra_static_insn_data *curr_static_id;
514 /* Return true when one of the predecessor edges of BB is marked with
515 EDGE_ABNORMAL_CALL or EDGE_EH. */
516 static bool
517 bb_has_abnormal_call_pred (basic_block bb)
519 edge e;
520 edge_iterator ei;
522 FOR_EACH_EDGE (e, ei, bb->preds)
524 if (e->flags & (EDGE_ABNORMAL_CALL | EDGE_EH))
525 return true;
527 return false;
530 /* Vec containing execution frequencies of program points. */
531 static vec<int> point_freq_vec;
533 /* The start of the above vector elements. */
534 int *lra_point_freq;
536 /* Increment the current program point POINT to the next point which has
537 execution frequency FREQ. */
538 static void
539 next_program_point (int &point, int freq)
541 point_freq_vec.safe_push (freq);
542 lra_point_freq = point_freq_vec.address ();
543 point++;
546 /* Update the preference of HARD_REGNO for pseudo REGNO by PROFIT. */
547 void
548 lra_setup_reload_pseudo_preferenced_hard_reg (int regno,
549 int hard_regno, int profit)
551 lra_assert (regno >= lra_constraint_new_regno_start);
552 if (lra_reg_info[regno].preferred_hard_regno1 == hard_regno)
553 lra_reg_info[regno].preferred_hard_regno_profit1 += profit;
554 else if (lra_reg_info[regno].preferred_hard_regno2 == hard_regno)
555 lra_reg_info[regno].preferred_hard_regno_profit2 += profit;
556 else if (lra_reg_info[regno].preferred_hard_regno1 < 0)
558 lra_reg_info[regno].preferred_hard_regno1 = hard_regno;
559 lra_reg_info[regno].preferred_hard_regno_profit1 = profit;
561 else if (lra_reg_info[regno].preferred_hard_regno2 < 0
562 || profit > lra_reg_info[regno].preferred_hard_regno_profit2)
564 lra_reg_info[regno].preferred_hard_regno2 = hard_regno;
565 lra_reg_info[regno].preferred_hard_regno_profit2 = profit;
567 else
568 return;
569 /* Keep the 1st hard regno as more profitable. */
570 if (lra_reg_info[regno].preferred_hard_regno1 >= 0
571 && lra_reg_info[regno].preferred_hard_regno2 >= 0
572 && (lra_reg_info[regno].preferred_hard_regno_profit2
573 > lra_reg_info[regno].preferred_hard_regno_profit1))
575 std::swap (lra_reg_info[regno].preferred_hard_regno1,
576 lra_reg_info[regno].preferred_hard_regno2);
577 std::swap (lra_reg_info[regno].preferred_hard_regno_profit1,
578 lra_reg_info[regno].preferred_hard_regno_profit2);
580 if (lra_dump_file != NULL)
582 if ((hard_regno = lra_reg_info[regno].preferred_hard_regno1) >= 0)
583 fprintf (lra_dump_file,
584 " Hard reg %d is preferable by r%d with profit %d\n",
585 hard_regno, regno,
586 lra_reg_info[regno].preferred_hard_regno_profit1);
587 if ((hard_regno = lra_reg_info[regno].preferred_hard_regno2) >= 0)
588 fprintf (lra_dump_file,
589 " Hard reg %d is preferable by r%d with profit %d\n",
590 hard_regno, regno,
591 lra_reg_info[regno].preferred_hard_regno_profit2);
595 /* Check that REGNO living through calls and setjumps, set up conflict
596 regs, and clear corresponding bits in PSEUDOS_LIVE_THROUGH_CALLS and
597 PSEUDOS_LIVE_THROUGH_SETJUMPS. */
598 static inline void
599 check_pseudos_live_through_calls (int regno)
601 int hr;
603 if (! sparseset_bit_p (pseudos_live_through_calls, regno))
604 return;
605 sparseset_clear_bit (pseudos_live_through_calls, regno);
606 IOR_HARD_REG_SET (lra_reg_info[regno].conflict_hard_regs,
607 call_used_reg_set);
609 for (hr = 0; hr < FIRST_PSEUDO_REGISTER; hr++)
610 if (HARD_REGNO_CALL_PART_CLOBBERED (hr, PSEUDO_REGNO_MODE (regno)))
611 SET_HARD_REG_BIT (lra_reg_info[regno].conflict_hard_regs, hr);
612 #ifdef ENABLE_CHECKING
613 lra_reg_info[regno].call_p = true;
614 #endif
615 if (! sparseset_bit_p (pseudos_live_through_setjumps, regno))
616 return;
617 sparseset_clear_bit (pseudos_live_through_setjumps, regno);
618 /* Don't allocate pseudos that cross setjmps or any call, if this
619 function receives a nonlocal goto. */
620 SET_HARD_REG_SET (lra_reg_info[regno].conflict_hard_regs);
623 /* Process insns of the basic block BB to update pseudo live ranges,
624 pseudo hard register conflicts, and insn notes. We do it on
625 backward scan of BB insns. CURR_POINT is the program point where
626 BB ends. The function updates this counter and returns in
627 CURR_POINT the program point where BB starts. The function also
628 does local live info updates and can delete the dead insns if
629 DEAD_INSN_P. It returns true if pseudo live info was
630 changed at the BB start. */
631 static bool
632 process_bb_lives (basic_block bb, int &curr_point, bool dead_insn_p)
634 int i, regno, freq;
635 unsigned int j;
636 bitmap_iterator bi;
637 bitmap reg_live_out;
638 unsigned int px;
639 rtx_insn *next;
640 rtx link, *link_loc;
641 bool need_curr_point_incr;
643 reg_live_out = df_get_live_out (bb);
644 sparseset_clear (pseudos_live);
645 sparseset_clear (pseudos_live_through_calls);
646 sparseset_clear (pseudos_live_through_setjumps);
647 REG_SET_TO_HARD_REG_SET (hard_regs_live, reg_live_out);
648 AND_COMPL_HARD_REG_SET (hard_regs_live, eliminable_regset);
649 EXECUTE_IF_SET_IN_BITMAP (reg_live_out, FIRST_PSEUDO_REGISTER, j, bi)
650 mark_pseudo_live (j, curr_point);
652 bb_gen_pseudos = &get_bb_data (bb)->gen_pseudos;
653 bb_killed_pseudos = &get_bb_data (bb)->killed_pseudos;
654 bitmap_clear (bb_gen_pseudos);
655 bitmap_clear (bb_killed_pseudos);
656 freq = REG_FREQ_FROM_BB (bb);
658 if (lra_dump_file != NULL)
659 fprintf (lra_dump_file, " BB %d\n", bb->index);
661 /* Scan the code of this basic block, noting which pseudos and hard
662 regs are born or die.
664 Note that this loop treats uninitialized values as live until the
665 beginning of the block. For example, if an instruction uses
666 (reg:DI foo), and only (subreg:SI (reg:DI foo) 0) is ever set,
667 FOO will remain live until the beginning of the block. Likewise
668 if FOO is not set at all. This is unnecessarily pessimistic, but
669 it probably doesn't matter much in practice. */
670 FOR_BB_INSNS_REVERSE_SAFE (bb, curr_insn, next)
672 bool call_p;
673 int dst_regno, src_regno;
674 rtx set;
675 struct lra_insn_reg *reg;
677 if (!NONDEBUG_INSN_P (curr_insn))
678 continue;
680 curr_id = lra_get_insn_recog_data (curr_insn);
681 curr_static_id = curr_id->insn_static_data;
682 if (lra_dump_file != NULL)
683 fprintf (lra_dump_file, " Insn %u: point = %d\n",
684 INSN_UID (curr_insn), curr_point);
686 set = single_set (curr_insn);
688 if (dead_insn_p && set != NULL_RTX
689 && REG_P (SET_DEST (set)) && REGNO (SET_DEST (set)) >= FIRST_PSEUDO_REGISTER
690 && find_reg_note (curr_insn, REG_EH_REGION, NULL_RTX) == NULL_RTX
691 && ! may_trap_p (PATTERN (curr_insn))
692 /* Don't do premature remove of pic offset pseudo as we can
693 start to use it after some reload generation. */
694 && (pic_offset_table_rtx == NULL_RTX
695 || pic_offset_table_rtx != SET_DEST (set)))
697 bool remove_p = true;
699 for (reg = curr_id->regs; reg != NULL; reg = reg->next)
700 if (reg->type != OP_IN && sparseset_bit_p (pseudos_live, reg->regno))
702 remove_p = false;
703 break;
705 for (reg = curr_static_id->hard_regs; reg != NULL; reg = reg->next)
706 if (reg->type != OP_IN)
708 remove_p = false;
709 break;
711 if (remove_p && ! volatile_refs_p (PATTERN (curr_insn)))
713 dst_regno = REGNO (SET_DEST (set));
714 if (lra_dump_file != NULL)
715 fprintf (lra_dump_file, " Deleting dead insn %u\n",
716 INSN_UID (curr_insn));
717 lra_set_insn_deleted (curr_insn);
718 if (lra_reg_info[dst_regno].nrefs == 0)
720 /* There might be some debug insns with the pseudo. */
721 unsigned int uid;
722 rtx_insn *insn;
724 bitmap_copy (&temp_bitmap, &lra_reg_info[dst_regno].insn_bitmap);
725 EXECUTE_IF_SET_IN_BITMAP (&temp_bitmap, 0, uid, bi)
727 insn = lra_insn_recog_data[uid]->insn;
728 lra_substitute_pseudo_within_insn (insn, dst_regno,
729 SET_SRC (set));
730 lra_update_insn_regno_info (insn);
733 continue;
737 /* Update max ref width and hard reg usage. */
738 for (reg = curr_id->regs; reg != NULL; reg = reg->next)
739 if (reg->regno >= FIRST_PSEUDO_REGISTER
740 && (GET_MODE_SIZE (reg->biggest_mode)
741 > GET_MODE_SIZE (lra_reg_info[reg->regno].biggest_mode)))
742 lra_reg_info[reg->regno].biggest_mode = reg->biggest_mode;
743 else if (reg->regno < FIRST_PSEUDO_REGISTER)
744 lra_hard_reg_usage[reg->regno] += freq;
746 call_p = CALL_P (curr_insn);
747 if (complete_info_p
748 && set != NULL_RTX
749 && REG_P (SET_DEST (set)) && REG_P (SET_SRC (set))
750 /* Check that source regno does not conflict with
751 destination regno to exclude most impossible
752 preferences. */
753 && ((((src_regno = REGNO (SET_SRC (set))) >= FIRST_PSEUDO_REGISTER
754 && ! sparseset_bit_p (pseudos_live, src_regno))
755 || (src_regno < FIRST_PSEUDO_REGISTER
756 && ! TEST_HARD_REG_BIT (hard_regs_live, src_regno)))
757 /* It might be 'inheritance pseudo <- reload pseudo'. */
758 || (src_regno >= lra_constraint_new_regno_start
759 && ((int) REGNO (SET_DEST (set))
760 >= lra_constraint_new_regno_start)
761 /* Remember to skip special cases where src/dest regnos are
762 the same, e.g. insn SET pattern has matching constraints
763 like =r,0. */
764 && src_regno != (int) REGNO (SET_DEST (set)))))
766 int hard_regno = -1, regno = -1;
768 dst_regno = REGNO (SET_DEST (set));
769 if (dst_regno >= lra_constraint_new_regno_start
770 && src_regno >= lra_constraint_new_regno_start)
771 lra_create_copy (dst_regno, src_regno, freq);
772 else if (dst_regno >= lra_constraint_new_regno_start)
774 if ((hard_regno = src_regno) >= FIRST_PSEUDO_REGISTER)
775 hard_regno = reg_renumber[src_regno];
776 regno = dst_regno;
778 else if (src_regno >= lra_constraint_new_regno_start)
780 if ((hard_regno = dst_regno) >= FIRST_PSEUDO_REGISTER)
781 hard_regno = reg_renumber[dst_regno];
782 regno = src_regno;
784 if (regno >= 0 && hard_regno >= 0)
785 lra_setup_reload_pseudo_preferenced_hard_reg
786 (regno, hard_regno, freq);
789 sparseset_clear (start_living);
791 /* Try to avoid unnecessary program point increments, this saves
792 a lot of time in remove_some_program_points_and_update_live_ranges.
793 We only need an increment if something becomes live or dies at this
794 program point. */
795 need_curr_point_incr = false;
797 /* Mark each defined value as live. We need to do this for
798 unused values because they still conflict with quantities
799 that are live at the time of the definition. */
800 for (reg = curr_id->regs; reg != NULL; reg = reg->next)
801 if (reg->type != OP_IN)
803 need_curr_point_incr
804 |= mark_regno_live (reg->regno, reg->biggest_mode,
805 curr_point);
806 check_pseudos_live_through_calls (reg->regno);
809 for (reg = curr_static_id->hard_regs; reg != NULL; reg = reg->next)
810 if (reg->type != OP_IN)
811 make_hard_regno_born (reg->regno, false);
813 sparseset_copy (unused_set, start_living);
815 sparseset_clear (start_dying);
817 /* See which defined values die here. */
818 for (reg = curr_id->regs; reg != NULL; reg = reg->next)
819 if (reg->type == OP_OUT && ! reg->early_clobber && ! reg->subreg_p)
820 need_curr_point_incr
821 |= mark_regno_dead (reg->regno, reg->biggest_mode,
822 curr_point);
824 for (reg = curr_static_id->hard_regs; reg != NULL; reg = reg->next)
825 if (reg->type == OP_OUT && ! reg->early_clobber && ! reg->subreg_p)
826 make_hard_regno_dead (reg->regno);
828 if (call_p)
830 if (flag_ipa_ra)
832 HARD_REG_SET this_call_used_reg_set;
833 get_call_reg_set_usage (curr_insn, &this_call_used_reg_set,
834 call_used_reg_set);
836 EXECUTE_IF_SET_IN_SPARSESET (pseudos_live, j)
837 IOR_HARD_REG_SET (lra_reg_info[j].actual_call_used_reg_set,
838 this_call_used_reg_set);
841 sparseset_ior (pseudos_live_through_calls,
842 pseudos_live_through_calls, pseudos_live);
843 if (cfun->has_nonlocal_label
844 || find_reg_note (curr_insn, REG_SETJMP,
845 NULL_RTX) != NULL_RTX)
846 sparseset_ior (pseudos_live_through_setjumps,
847 pseudos_live_through_setjumps, pseudos_live);
850 /* Increment the current program point if we must. */
851 if (need_curr_point_incr)
852 next_program_point (curr_point, freq);
854 sparseset_clear (start_living);
856 need_curr_point_incr = false;
858 /* Mark each used value as live. */
859 for (reg = curr_id->regs; reg != NULL; reg = reg->next)
860 if (reg->type == OP_IN)
862 need_curr_point_incr
863 |= mark_regno_live (reg->regno, reg->biggest_mode,
864 curr_point);
865 check_pseudos_live_through_calls (reg->regno);
868 for (reg = curr_static_id->hard_regs; reg != NULL; reg = reg->next)
869 if (reg->type == OP_IN)
870 make_hard_regno_born (reg->regno, false);
872 if (curr_id->arg_hard_regs != NULL)
873 /* Make argument hard registers live. Don't create conflict
874 of used REAL_PIC_OFFSET_TABLE_REGNUM and the pic pseudo. */
875 for (i = 0; (regno = curr_id->arg_hard_regs[i]) >= 0; i++)
876 make_hard_regno_born (regno, true);
878 sparseset_and_compl (dead_set, start_living, start_dying);
880 /* Mark early clobber outputs dead. */
881 for (reg = curr_id->regs; reg != NULL; reg = reg->next)
882 if (reg->type == OP_OUT && reg->early_clobber && ! reg->subreg_p)
883 need_curr_point_incr
884 |= mark_regno_dead (reg->regno, reg->biggest_mode,
885 curr_point);
887 for (reg = curr_static_id->hard_regs; reg != NULL; reg = reg->next)
888 if (reg->type == OP_OUT && reg->early_clobber && ! reg->subreg_p)
889 make_hard_regno_dead (reg->regno);
891 if (need_curr_point_incr)
892 next_program_point (curr_point, freq);
894 /* Update notes. */
895 for (link_loc = &REG_NOTES (curr_insn); (link = *link_loc) != NULL_RTX;)
897 if (REG_NOTE_KIND (link) != REG_DEAD
898 && REG_NOTE_KIND (link) != REG_UNUSED)
900 else if (REG_P (XEXP (link, 0)))
902 regno = REGNO (XEXP (link, 0));
903 if ((REG_NOTE_KIND (link) == REG_DEAD
904 && ! sparseset_bit_p (dead_set, regno))
905 || (REG_NOTE_KIND (link) == REG_UNUSED
906 && ! sparseset_bit_p (unused_set, regno)))
908 *link_loc = XEXP (link, 1);
909 continue;
911 if (REG_NOTE_KIND (link) == REG_DEAD)
912 sparseset_clear_bit (dead_set, regno);
913 else if (REG_NOTE_KIND (link) == REG_UNUSED)
914 sparseset_clear_bit (unused_set, regno);
916 link_loc = &XEXP (link, 1);
918 EXECUTE_IF_SET_IN_SPARSESET (dead_set, j)
919 add_reg_note (curr_insn, REG_DEAD, regno_reg_rtx[j]);
920 EXECUTE_IF_SET_IN_SPARSESET (unused_set, j)
921 add_reg_note (curr_insn, REG_UNUSED, regno_reg_rtx[j]);
924 if (bb_has_eh_pred (bb))
925 for (j = 0; ; ++j)
927 unsigned int regno = EH_RETURN_DATA_REGNO (j);
929 if (regno == INVALID_REGNUM)
930 break;
931 make_hard_regno_born (regno, false);
934 /* Pseudos can't go in stack regs at the start of a basic block that
935 is reached by an abnormal edge. Likewise for call clobbered regs,
936 because caller-save, fixup_abnormal_edges and possibly the table
937 driven EH machinery are not quite ready to handle such pseudos
938 live across such edges. */
939 if (bb_has_abnormal_pred (bb))
941 #ifdef STACK_REGS
942 EXECUTE_IF_SET_IN_SPARSESET (pseudos_live, px)
943 lra_reg_info[px].no_stack_p = true;
944 for (px = FIRST_STACK_REG; px <= LAST_STACK_REG; px++)
945 make_hard_regno_born (px, false);
946 #endif
947 /* No need to record conflicts for call clobbered regs if we
948 have nonlocal labels around, as we don't ever try to
949 allocate such regs in this case. */
950 if (!cfun->has_nonlocal_label && bb_has_abnormal_call_pred (bb))
951 for (px = 0; px < FIRST_PSEUDO_REGISTER; px++)
952 if (call_used_regs[px])
953 make_hard_regno_born (px, false);
956 bool live_change_p = false;
957 /* Check if bb border live info was changed. */
958 unsigned int live_pseudos_num = 0;
959 EXECUTE_IF_SET_IN_BITMAP (df_get_live_in (bb),
960 FIRST_PSEUDO_REGISTER, j, bi)
962 live_pseudos_num++;
963 if (! sparseset_bit_p (pseudos_live, j))
965 live_change_p = true;
966 if (lra_dump_file != NULL)
967 fprintf (lra_dump_file,
968 " r%d is removed as live at bb%d start\n", j, bb->index);
969 break;
972 if (! live_change_p
973 && sparseset_cardinality (pseudos_live) != live_pseudos_num)
975 live_change_p = true;
976 if (lra_dump_file != NULL)
977 EXECUTE_IF_SET_IN_SPARSESET (pseudos_live, j)
978 if (! bitmap_bit_p (df_get_live_in (bb), j))
979 fprintf (lra_dump_file,
980 " r%d is added to live at bb%d start\n", j, bb->index);
982 /* See if we'll need an increment at the end of this basic block.
983 An increment is needed if the PSEUDOS_LIVE set is not empty,
984 to make sure the finish points are set up correctly. */
985 need_curr_point_incr = (sparseset_cardinality (pseudos_live) > 0);
987 EXECUTE_IF_SET_IN_SPARSESET (pseudos_live, i)
988 mark_pseudo_dead (i, curr_point);
990 EXECUTE_IF_SET_IN_BITMAP (df_get_live_in (bb), FIRST_PSEUDO_REGISTER, j, bi)
992 if (sparseset_cardinality (pseudos_live_through_calls) == 0)
993 break;
994 if (sparseset_bit_p (pseudos_live_through_calls, j))
995 check_pseudos_live_through_calls (j);
998 if (need_curr_point_incr)
999 next_program_point (curr_point, freq);
1001 return live_change_p;
1004 /* Compress pseudo live ranges by removing program points where
1005 nothing happens. Complexity of many algorithms in LRA is linear
1006 function of program points number. To speed up the code we try to
1007 minimize the number of the program points here. */
1008 static void
1009 remove_some_program_points_and_update_live_ranges (void)
1011 unsigned i;
1012 int n, max_regno;
1013 int *map;
1014 lra_live_range_t r, prev_r, next_r;
1015 sbitmap born_or_dead, born, dead;
1016 sbitmap_iterator sbi;
1017 bool born_p, dead_p, prev_born_p, prev_dead_p;
1019 born = sbitmap_alloc (lra_live_max_point);
1020 dead = sbitmap_alloc (lra_live_max_point);
1021 bitmap_clear (born);
1022 bitmap_clear (dead);
1023 max_regno = max_reg_num ();
1024 for (i = FIRST_PSEUDO_REGISTER; i < (unsigned) max_regno; i++)
1026 for (r = lra_reg_info[i].live_ranges; r != NULL; r = r->next)
1028 lra_assert (r->start <= r->finish);
1029 bitmap_set_bit (born, r->start);
1030 bitmap_set_bit (dead, r->finish);
1033 born_or_dead = sbitmap_alloc (lra_live_max_point);
1034 bitmap_ior (born_or_dead, born, dead);
1035 map = XCNEWVEC (int, lra_live_max_point);
1036 n = -1;
1037 prev_born_p = prev_dead_p = false;
1038 EXECUTE_IF_SET_IN_BITMAP (born_or_dead, 0, i, sbi)
1040 born_p = bitmap_bit_p (born, i);
1041 dead_p = bitmap_bit_p (dead, i);
1042 if ((prev_born_p && ! prev_dead_p && born_p && ! dead_p)
1043 || (prev_dead_p && ! prev_born_p && dead_p && ! born_p))
1045 map[i] = n;
1046 lra_point_freq[n] = MAX (lra_point_freq[n], lra_point_freq[i]);
1048 else
1050 map[i] = ++n;
1051 lra_point_freq[n] = lra_point_freq[i];
1053 prev_born_p = born_p;
1054 prev_dead_p = dead_p;
1056 sbitmap_free (born_or_dead);
1057 sbitmap_free (born);
1058 sbitmap_free (dead);
1059 n++;
1060 if (lra_dump_file != NULL)
1061 fprintf (lra_dump_file, "Compressing live ranges: from %d to %d - %d%%\n",
1062 lra_live_max_point, n, 100 * n / lra_live_max_point);
1063 if (n < lra_live_max_point)
1065 lra_live_max_point = n;
1066 for (i = FIRST_PSEUDO_REGISTER; i < (unsigned) max_regno; i++)
1068 for (prev_r = NULL, r = lra_reg_info[i].live_ranges;
1069 r != NULL;
1070 r = next_r)
1072 next_r = r->next;
1073 r->start = map[r->start];
1074 r->finish = map[r->finish];
1075 if (prev_r == NULL || prev_r->start > r->finish + 1)
1077 prev_r = r;
1078 continue;
1080 prev_r->start = r->start;
1081 prev_r->next = next_r;
1082 delete r;
1086 free (map);
1089 /* Print live ranges R to file F. */
1090 void
1091 lra_print_live_range_list (FILE *f, lra_live_range_t r)
1093 for (; r != NULL; r = r->next)
1094 fprintf (f, " [%d..%d]", r->start, r->finish);
1095 fprintf (f, "\n");
1098 DEBUG_FUNCTION void
1099 debug (lra_live_range &ref)
1101 lra_print_live_range_list (stderr, &ref);
1104 DEBUG_FUNCTION void
1105 debug (lra_live_range *ptr)
1107 if (ptr)
1108 debug (*ptr);
1109 else
1110 fprintf (stderr, "<nil>\n");
1113 /* Print live ranges R to stderr. */
1114 void
1115 lra_debug_live_range_list (lra_live_range_t r)
1117 lra_print_live_range_list (stderr, r);
1120 /* Print live ranges of pseudo REGNO to file F. */
1121 static void
1122 print_pseudo_live_ranges (FILE *f, int regno)
1124 if (lra_reg_info[regno].live_ranges == NULL)
1125 return;
1126 fprintf (f, " r%d:", regno);
1127 lra_print_live_range_list (f, lra_reg_info[regno].live_ranges);
1130 /* Print live ranges of pseudo REGNO to stderr. */
1131 void
1132 lra_debug_pseudo_live_ranges (int regno)
1134 print_pseudo_live_ranges (stderr, regno);
1137 /* Print live ranges of all pseudos to file F. */
1138 static void
1139 print_live_ranges (FILE *f)
1141 int i, max_regno;
1143 max_regno = max_reg_num ();
1144 for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
1145 print_pseudo_live_ranges (f, i);
1148 /* Print live ranges of all pseudos to stderr. */
1149 void
1150 lra_debug_live_ranges (void)
1152 print_live_ranges (stderr);
1155 /* Compress pseudo live ranges. */
1156 static void
1157 compress_live_ranges (void)
1159 remove_some_program_points_and_update_live_ranges ();
1160 if (lra_dump_file != NULL)
1162 fprintf (lra_dump_file, "Ranges after the compression:\n");
1163 print_live_ranges (lra_dump_file);
1169 /* The number of the current live range pass. */
1170 int lra_live_range_iter;
1172 /* The function creates live ranges only for memory pseudos (or for
1173 all ones if ALL_P), set up CONFLICT_HARD_REGS for the pseudos. It
1174 also does dead insn elimination if DEAD_INSN_P and global live
1175 analysis only for pseudos and only if the pseudo live info was
1176 changed on a BB border. Return TRUE if the live info was
1177 changed. */
1178 static bool
1179 lra_create_live_ranges_1 (bool all_p, bool dead_insn_p)
1181 basic_block bb;
1182 int i, hard_regno, max_regno = max_reg_num ();
1183 int curr_point;
1184 bool bb_live_change_p, have_referenced_pseudos = false;
1186 timevar_push (TV_LRA_CREATE_LIVE_RANGES);
1188 complete_info_p = all_p;
1189 if (lra_dump_file != NULL)
1190 fprintf (lra_dump_file,
1191 "\n********** Pseudo live ranges #%d: **********\n\n",
1192 ++lra_live_range_iter);
1193 memset (lra_hard_reg_usage, 0, sizeof (lra_hard_reg_usage));
1194 for (i = 0; i < max_regno; i++)
1196 lra_reg_info[i].live_ranges = NULL;
1197 CLEAR_HARD_REG_SET (lra_reg_info[i].conflict_hard_regs);
1198 lra_reg_info[i].preferred_hard_regno1 = -1;
1199 lra_reg_info[i].preferred_hard_regno2 = -1;
1200 lra_reg_info[i].preferred_hard_regno_profit1 = 0;
1201 lra_reg_info[i].preferred_hard_regno_profit2 = 0;
1202 #ifdef STACK_REGS
1203 lra_reg_info[i].no_stack_p = false;
1204 #endif
1205 /* The biggest mode is already set but its value might be to
1206 conservative because of recent transformation. Here in this
1207 file we recalculate it again as it costs practically
1208 nothing. */
1209 if (regno_reg_rtx[i] != NULL_RTX)
1210 lra_reg_info[i].biggest_mode = GET_MODE (regno_reg_rtx[i]);
1211 else
1212 lra_reg_info[i].biggest_mode = VOIDmode;
1213 #ifdef ENABLE_CHECKING
1214 lra_reg_info[i].call_p = false;
1215 #endif
1216 if (i >= FIRST_PSEUDO_REGISTER
1217 && lra_reg_info[i].nrefs != 0)
1219 if ((hard_regno = reg_renumber[i]) >= 0)
1220 lra_hard_reg_usage[hard_regno] += lra_reg_info[i].freq;
1221 have_referenced_pseudos = true;
1224 lra_free_copies ();
1226 /* Under some circumstances, we can have functions without pseudo
1227 registers. For such functions, lra_live_max_point will be 0,
1228 see e.g. PR55604, and there's nothing more to do for us here. */
1229 if (! have_referenced_pseudos)
1231 timevar_pop (TV_LRA_CREATE_LIVE_RANGES);
1232 return false;
1235 pseudos_live = sparseset_alloc (max_regno);
1236 pseudos_live_through_calls = sparseset_alloc (max_regno);
1237 pseudos_live_through_setjumps = sparseset_alloc (max_regno);
1238 start_living = sparseset_alloc (max_regno);
1239 start_dying = sparseset_alloc (max_regno);
1240 dead_set = sparseset_alloc (max_regno);
1241 unused_set = sparseset_alloc (max_regno);
1242 curr_point = 0;
1243 point_freq_vec.create (get_max_uid () * 2);
1244 lra_point_freq = point_freq_vec.address ();
1245 int *post_order_rev_cfg = XNEWVEC (int, last_basic_block_for_fn (cfun));
1246 int n_blocks_inverted = inverted_post_order_compute (post_order_rev_cfg);
1247 lra_assert (n_blocks_inverted == n_basic_blocks_for_fn (cfun));
1248 bb_live_change_p = false;
1249 for (i = n_blocks_inverted - 1; i >= 0; --i)
1251 bb = BASIC_BLOCK_FOR_FN (cfun, post_order_rev_cfg[i]);
1252 if (bb == EXIT_BLOCK_PTR_FOR_FN (cfun) || bb
1253 == ENTRY_BLOCK_PTR_FOR_FN (cfun))
1254 continue;
1255 if (process_bb_lives (bb, curr_point, dead_insn_p))
1256 bb_live_change_p = true;
1258 if (bb_live_change_p)
1260 /* We need to clear pseudo live info as some pseudos can
1261 disappear, e.g. pseudos with used equivalences. */
1262 FOR_EACH_BB_FN (bb, cfun)
1264 bitmap_clear_range (df_get_live_in (bb), FIRST_PSEUDO_REGISTER,
1265 max_regno - FIRST_PSEUDO_REGISTER);
1266 bitmap_clear_range (df_get_live_out (bb), FIRST_PSEUDO_REGISTER,
1267 max_regno - FIRST_PSEUDO_REGISTER);
1269 /* As we did not change CFG since LRA start we can use
1270 DF-infrastructure solver to solve live data flow problem. */
1271 df_simple_dataflow
1272 (DF_BACKWARD, NULL, live_con_fun_0, live_con_fun_n,
1273 live_trans_fun, &all_blocks,
1274 df_get_postorder (DF_BACKWARD), df_get_n_blocks (DF_BACKWARD));
1275 if (lra_dump_file != NULL)
1277 fprintf (lra_dump_file,
1278 "Global pseudo live data have been updated:\n");
1279 basic_block bb;
1280 FOR_EACH_BB_FN (bb, cfun)
1282 bb_data_t bb_info = get_bb_data (bb);
1283 bitmap bb_livein = df_get_live_in (bb);
1284 bitmap bb_liveout = df_get_live_out (bb);
1286 fprintf (lra_dump_file, "\nBB %d:\n", bb->index);
1287 lra_dump_bitmap_with_title (" gen:",
1288 &bb_info->gen_pseudos, bb->index);
1289 lra_dump_bitmap_with_title (" killed:",
1290 &bb_info->killed_pseudos, bb->index);
1291 lra_dump_bitmap_with_title (" livein:", bb_livein, bb->index);
1292 lra_dump_bitmap_with_title (" liveout:", bb_liveout, bb->index);
1296 free (post_order_rev_cfg);
1297 lra_live_max_point = curr_point;
1298 if (lra_dump_file != NULL)
1299 print_live_ranges (lra_dump_file);
1300 /* Clean up. */
1301 sparseset_free (unused_set);
1302 sparseset_free (dead_set);
1303 sparseset_free (start_dying);
1304 sparseset_free (start_living);
1305 sparseset_free (pseudos_live_through_calls);
1306 sparseset_free (pseudos_live_through_setjumps);
1307 sparseset_free (pseudos_live);
1308 compress_live_ranges ();
1309 timevar_pop (TV_LRA_CREATE_LIVE_RANGES);
1310 return bb_live_change_p;
1313 /* The main entry function creates live-ranges and other live info
1314 necessary for the assignment sub-pass. It uses
1315 lra_creates_live_ranges_1 -- so read comments for the
1316 function. */
1317 void
1318 lra_create_live_ranges (bool all_p, bool dead_insn_p)
1320 if (! lra_create_live_ranges_1 (all_p, dead_insn_p))
1321 return;
1322 if (lra_dump_file != NULL)
1323 fprintf (lra_dump_file, "Live info was changed -- recalculate it\n");
1324 /* Live info was changed on a bb border. It means that some info,
1325 e.g. about conflict regs, calls crossed, and live ranges may be
1326 wrong. We need this info for allocation. So recalculate it
1327 again but without removing dead insns which can change live info
1328 again. Repetitive live range calculations are expensive therefore
1329 we stop here as we already have correct info although some
1330 improvement in rare cases could be possible on this sub-pass if
1331 we do dead insn elimination again (still the improvement may
1332 happen later). */
1333 lra_clear_live_ranges ();
1334 bool res = lra_create_live_ranges_1 (all_p, false);
1335 lra_assert (! res);
1338 /* Finish all live ranges. */
1339 void
1340 lra_clear_live_ranges (void)
1342 int i;
1344 for (i = 0; i < max_reg_num (); i++)
1345 free_live_range_list (lra_reg_info[i].live_ranges);
1346 point_freq_vec.release ();
1349 /* Initialize live ranges data once per function. */
1350 void
1351 lra_live_ranges_init (void)
1353 bitmap_initialize (&temp_bitmap, &reg_obstack);
1354 initiate_live_solver ();
1357 /* Finish live ranges data once per function. */
1358 void
1359 lra_live_ranges_finish (void)
1361 finish_live_solver ();
1362 bitmap_clear (&temp_bitmap);
1363 lra_live_range::pool.release ();