* config/pa/linux-atomic.c (__kernel_cmpxchg): Reorder arguments to
[official-gcc.git] / gcc / lra-lives.c
blob88c0ef671b4e806c520078f38c40f6dfb214abd2
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), true);
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)
772 /* It might be still an original (non-reload) insn with
773 one unused output and a constraint requiring to use
774 the same reg for input/output operands. In this case
775 dst_regno and src_regno have the same value, we don't
776 need a misleading copy for this case. */
777 if (dst_regno != src_regno)
778 lra_create_copy (dst_regno, src_regno, freq);
780 else if (dst_regno >= lra_constraint_new_regno_start)
782 if ((hard_regno = src_regno) >= FIRST_PSEUDO_REGISTER)
783 hard_regno = reg_renumber[src_regno];
784 regno = dst_regno;
786 else if (src_regno >= lra_constraint_new_regno_start)
788 if ((hard_regno = dst_regno) >= FIRST_PSEUDO_REGISTER)
789 hard_regno = reg_renumber[dst_regno];
790 regno = src_regno;
792 if (regno >= 0 && hard_regno >= 0)
793 lra_setup_reload_pseudo_preferenced_hard_reg
794 (regno, hard_regno, freq);
797 sparseset_clear (start_living);
799 /* Try to avoid unnecessary program point increments, this saves
800 a lot of time in remove_some_program_points_and_update_live_ranges.
801 We only need an increment if something becomes live or dies at this
802 program point. */
803 need_curr_point_incr = false;
805 /* Mark each defined value as live. We need to do this for
806 unused values because they still conflict with quantities
807 that are live at the time of the definition. */
808 for (reg = curr_id->regs; reg != NULL; reg = reg->next)
809 if (reg->type != OP_IN)
811 need_curr_point_incr
812 |= mark_regno_live (reg->regno, reg->biggest_mode,
813 curr_point);
814 check_pseudos_live_through_calls (reg->regno);
817 for (reg = curr_static_id->hard_regs; reg != NULL; reg = reg->next)
818 if (reg->type != OP_IN)
819 make_hard_regno_born (reg->regno, false);
821 sparseset_copy (unused_set, start_living);
823 sparseset_clear (start_dying);
825 /* See which defined values die here. */
826 for (reg = curr_id->regs; reg != NULL; reg = reg->next)
827 if (reg->type == OP_OUT && ! reg->early_clobber && ! reg->subreg_p)
828 need_curr_point_incr
829 |= mark_regno_dead (reg->regno, reg->biggest_mode,
830 curr_point);
832 for (reg = curr_static_id->hard_regs; reg != NULL; reg = reg->next)
833 if (reg->type == OP_OUT && ! reg->early_clobber && ! reg->subreg_p)
834 make_hard_regno_dead (reg->regno);
836 if (call_p)
838 if (flag_ipa_ra)
840 HARD_REG_SET this_call_used_reg_set;
841 get_call_reg_set_usage (curr_insn, &this_call_used_reg_set,
842 call_used_reg_set);
844 EXECUTE_IF_SET_IN_SPARSESET (pseudos_live, j)
845 IOR_HARD_REG_SET (lra_reg_info[j].actual_call_used_reg_set,
846 this_call_used_reg_set);
849 sparseset_ior (pseudos_live_through_calls,
850 pseudos_live_through_calls, pseudos_live);
851 if (cfun->has_nonlocal_label
852 || find_reg_note (curr_insn, REG_SETJMP,
853 NULL_RTX) != NULL_RTX)
854 sparseset_ior (pseudos_live_through_setjumps,
855 pseudos_live_through_setjumps, pseudos_live);
858 /* Increment the current program point if we must. */
859 if (need_curr_point_incr)
860 next_program_point (curr_point, freq);
862 sparseset_clear (start_living);
864 need_curr_point_incr = false;
866 /* Mark each used value as live. */
867 for (reg = curr_id->regs; reg != NULL; reg = reg->next)
868 if (reg->type == OP_IN)
870 need_curr_point_incr
871 |= mark_regno_live (reg->regno, reg->biggest_mode,
872 curr_point);
873 check_pseudos_live_through_calls (reg->regno);
876 for (reg = curr_static_id->hard_regs; reg != NULL; reg = reg->next)
877 if (reg->type == OP_IN)
878 make_hard_regno_born (reg->regno, false);
880 if (curr_id->arg_hard_regs != NULL)
881 /* Make argument hard registers live. Don't create conflict
882 of used REAL_PIC_OFFSET_TABLE_REGNUM and the pic pseudo. */
883 for (i = 0; (regno = curr_id->arg_hard_regs[i]) >= 0; i++)
884 make_hard_regno_born (regno, true);
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 if (bb_has_eh_pred (bb))
933 for (j = 0; ; ++j)
935 unsigned int regno = EH_RETURN_DATA_REGNO (j);
937 if (regno == INVALID_REGNUM)
938 break;
939 make_hard_regno_born (regno, false);
942 /* Pseudos can't go in stack regs at the start of a basic block that
943 is reached by an abnormal edge. Likewise for call clobbered regs,
944 because caller-save, fixup_abnormal_edges and possibly the table
945 driven EH machinery are not quite ready to handle such pseudos
946 live across such edges. */
947 if (bb_has_abnormal_pred (bb))
949 #ifdef STACK_REGS
950 EXECUTE_IF_SET_IN_SPARSESET (pseudos_live, px)
951 lra_reg_info[px].no_stack_p = true;
952 for (px = FIRST_STACK_REG; px <= LAST_STACK_REG; px++)
953 make_hard_regno_born (px, false);
954 #endif
955 /* No need to record conflicts for call clobbered regs if we
956 have nonlocal labels around, as we don't ever try to
957 allocate such regs in this case. */
958 if (!cfun->has_nonlocal_label && bb_has_abnormal_call_pred (bb))
959 for (px = 0; px < FIRST_PSEUDO_REGISTER; px++)
960 if (call_used_regs[px])
961 make_hard_regno_born (px, false);
964 bool live_change_p = false;
965 /* Check if bb border live info was changed. */
966 unsigned int live_pseudos_num = 0;
967 EXECUTE_IF_SET_IN_BITMAP (df_get_live_in (bb),
968 FIRST_PSEUDO_REGISTER, j, bi)
970 live_pseudos_num++;
971 if (! sparseset_bit_p (pseudos_live, j))
973 live_change_p = true;
974 if (lra_dump_file != NULL)
975 fprintf (lra_dump_file,
976 " r%d is removed as live at bb%d start\n", j, bb->index);
977 break;
980 if (! live_change_p
981 && sparseset_cardinality (pseudos_live) != live_pseudos_num)
983 live_change_p = true;
984 if (lra_dump_file != NULL)
985 EXECUTE_IF_SET_IN_SPARSESET (pseudos_live, j)
986 if (! bitmap_bit_p (df_get_live_in (bb), j))
987 fprintf (lra_dump_file,
988 " r%d is added to live at bb%d start\n", j, bb->index);
990 /* See if we'll need an increment at the end of this basic block.
991 An increment is needed if the PSEUDOS_LIVE set is not empty,
992 to make sure the finish points are set up correctly. */
993 need_curr_point_incr = (sparseset_cardinality (pseudos_live) > 0);
995 EXECUTE_IF_SET_IN_SPARSESET (pseudos_live, i)
996 mark_pseudo_dead (i, curr_point);
998 EXECUTE_IF_SET_IN_BITMAP (df_get_live_in (bb), FIRST_PSEUDO_REGISTER, j, bi)
1000 if (sparseset_cardinality (pseudos_live_through_calls) == 0)
1001 break;
1002 if (sparseset_bit_p (pseudos_live_through_calls, j))
1003 check_pseudos_live_through_calls (j);
1006 if (need_curr_point_incr)
1007 next_program_point (curr_point, freq);
1009 return live_change_p;
1012 /* Compress pseudo live ranges by removing program points where
1013 nothing happens. Complexity of many algorithms in LRA is linear
1014 function of program points number. To speed up the code we try to
1015 minimize the number of the program points here. */
1016 static void
1017 remove_some_program_points_and_update_live_ranges (void)
1019 unsigned i;
1020 int n, max_regno;
1021 int *map;
1022 lra_live_range_t r, prev_r, next_r;
1023 sbitmap born_or_dead, born, dead;
1024 sbitmap_iterator sbi;
1025 bool born_p, dead_p, prev_born_p, prev_dead_p;
1027 born = sbitmap_alloc (lra_live_max_point);
1028 dead = sbitmap_alloc (lra_live_max_point);
1029 bitmap_clear (born);
1030 bitmap_clear (dead);
1031 max_regno = max_reg_num ();
1032 for (i = FIRST_PSEUDO_REGISTER; i < (unsigned) max_regno; i++)
1034 for (r = lra_reg_info[i].live_ranges; r != NULL; r = r->next)
1036 lra_assert (r->start <= r->finish);
1037 bitmap_set_bit (born, r->start);
1038 bitmap_set_bit (dead, r->finish);
1041 born_or_dead = sbitmap_alloc (lra_live_max_point);
1042 bitmap_ior (born_or_dead, born, dead);
1043 map = XCNEWVEC (int, lra_live_max_point);
1044 n = -1;
1045 prev_born_p = prev_dead_p = false;
1046 EXECUTE_IF_SET_IN_BITMAP (born_or_dead, 0, i, sbi)
1048 born_p = bitmap_bit_p (born, i);
1049 dead_p = bitmap_bit_p (dead, i);
1050 if ((prev_born_p && ! prev_dead_p && born_p && ! dead_p)
1051 || (prev_dead_p && ! prev_born_p && dead_p && ! born_p))
1053 map[i] = n;
1054 lra_point_freq[n] = MAX (lra_point_freq[n], lra_point_freq[i]);
1056 else
1058 map[i] = ++n;
1059 lra_point_freq[n] = lra_point_freq[i];
1061 prev_born_p = born_p;
1062 prev_dead_p = dead_p;
1064 sbitmap_free (born_or_dead);
1065 sbitmap_free (born);
1066 sbitmap_free (dead);
1067 n++;
1068 if (lra_dump_file != NULL)
1069 fprintf (lra_dump_file, "Compressing live ranges: from %d to %d - %d%%\n",
1070 lra_live_max_point, n, 100 * n / lra_live_max_point);
1071 if (n < lra_live_max_point)
1073 lra_live_max_point = n;
1074 for (i = FIRST_PSEUDO_REGISTER; i < (unsigned) max_regno; i++)
1076 for (prev_r = NULL, r = lra_reg_info[i].live_ranges;
1077 r != NULL;
1078 r = next_r)
1080 next_r = r->next;
1081 r->start = map[r->start];
1082 r->finish = map[r->finish];
1083 if (prev_r == NULL || prev_r->start > r->finish + 1)
1085 prev_r = r;
1086 continue;
1088 prev_r->start = r->start;
1089 prev_r->next = next_r;
1090 delete r;
1094 free (map);
1097 /* Print live ranges R to file F. */
1098 void
1099 lra_print_live_range_list (FILE *f, lra_live_range_t r)
1101 for (; r != NULL; r = r->next)
1102 fprintf (f, " [%d..%d]", r->start, r->finish);
1103 fprintf (f, "\n");
1106 DEBUG_FUNCTION void
1107 debug (lra_live_range &ref)
1109 lra_print_live_range_list (stderr, &ref);
1112 DEBUG_FUNCTION void
1113 debug (lra_live_range *ptr)
1115 if (ptr)
1116 debug (*ptr);
1117 else
1118 fprintf (stderr, "<nil>\n");
1121 /* Print live ranges R to stderr. */
1122 void
1123 lra_debug_live_range_list (lra_live_range_t r)
1125 lra_print_live_range_list (stderr, r);
1128 /* Print live ranges of pseudo REGNO to file F. */
1129 static void
1130 print_pseudo_live_ranges (FILE *f, int regno)
1132 if (lra_reg_info[regno].live_ranges == NULL)
1133 return;
1134 fprintf (f, " r%d:", regno);
1135 lra_print_live_range_list (f, lra_reg_info[regno].live_ranges);
1138 /* Print live ranges of pseudo REGNO to stderr. */
1139 void
1140 lra_debug_pseudo_live_ranges (int regno)
1142 print_pseudo_live_ranges (stderr, regno);
1145 /* Print live ranges of all pseudos to file F. */
1146 static void
1147 print_live_ranges (FILE *f)
1149 int i, max_regno;
1151 max_regno = max_reg_num ();
1152 for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
1153 print_pseudo_live_ranges (f, i);
1156 /* Print live ranges of all pseudos to stderr. */
1157 void
1158 lra_debug_live_ranges (void)
1160 print_live_ranges (stderr);
1163 /* Compress pseudo live ranges. */
1164 static void
1165 compress_live_ranges (void)
1167 remove_some_program_points_and_update_live_ranges ();
1168 if (lra_dump_file != NULL)
1170 fprintf (lra_dump_file, "Ranges after the compression:\n");
1171 print_live_ranges (lra_dump_file);
1177 /* The number of the current live range pass. */
1178 int lra_live_range_iter;
1180 /* The function creates live ranges only for memory pseudos (or for
1181 all ones if ALL_P), set up CONFLICT_HARD_REGS for the pseudos. It
1182 also does dead insn elimination if DEAD_INSN_P and global live
1183 analysis only for pseudos and only if the pseudo live info was
1184 changed on a BB border. Return TRUE if the live info was
1185 changed. */
1186 static bool
1187 lra_create_live_ranges_1 (bool all_p, bool dead_insn_p)
1189 basic_block bb;
1190 int i, hard_regno, max_regno = max_reg_num ();
1191 int curr_point;
1192 bool bb_live_change_p, have_referenced_pseudos = false;
1194 timevar_push (TV_LRA_CREATE_LIVE_RANGES);
1196 complete_info_p = all_p;
1197 if (lra_dump_file != NULL)
1198 fprintf (lra_dump_file,
1199 "\n********** Pseudo live ranges #%d: **********\n\n",
1200 ++lra_live_range_iter);
1201 memset (lra_hard_reg_usage, 0, sizeof (lra_hard_reg_usage));
1202 for (i = 0; i < max_regno; i++)
1204 lra_reg_info[i].live_ranges = NULL;
1205 CLEAR_HARD_REG_SET (lra_reg_info[i].conflict_hard_regs);
1206 lra_reg_info[i].preferred_hard_regno1 = -1;
1207 lra_reg_info[i].preferred_hard_regno2 = -1;
1208 lra_reg_info[i].preferred_hard_regno_profit1 = 0;
1209 lra_reg_info[i].preferred_hard_regno_profit2 = 0;
1210 #ifdef STACK_REGS
1211 lra_reg_info[i].no_stack_p = false;
1212 #endif
1213 /* The biggest mode is already set but its value might be to
1214 conservative because of recent transformation. Here in this
1215 file we recalculate it again as it costs practically
1216 nothing. */
1217 if (regno_reg_rtx[i] != NULL_RTX)
1218 lra_reg_info[i].biggest_mode = GET_MODE (regno_reg_rtx[i]);
1219 else
1220 lra_reg_info[i].biggest_mode = VOIDmode;
1221 #ifdef ENABLE_CHECKING
1222 lra_reg_info[i].call_p = false;
1223 #endif
1224 if (i >= FIRST_PSEUDO_REGISTER
1225 && lra_reg_info[i].nrefs != 0)
1227 if ((hard_regno = reg_renumber[i]) >= 0)
1228 lra_hard_reg_usage[hard_regno] += lra_reg_info[i].freq;
1229 have_referenced_pseudos = true;
1232 lra_free_copies ();
1234 /* Under some circumstances, we can have functions without pseudo
1235 registers. For such functions, lra_live_max_point will be 0,
1236 see e.g. PR55604, and there's nothing more to do for us here. */
1237 if (! have_referenced_pseudos)
1239 timevar_pop (TV_LRA_CREATE_LIVE_RANGES);
1240 return false;
1243 pseudos_live = sparseset_alloc (max_regno);
1244 pseudos_live_through_calls = sparseset_alloc (max_regno);
1245 pseudos_live_through_setjumps = sparseset_alloc (max_regno);
1246 start_living = sparseset_alloc (max_regno);
1247 start_dying = sparseset_alloc (max_regno);
1248 dead_set = sparseset_alloc (max_regno);
1249 unused_set = sparseset_alloc (max_regno);
1250 curr_point = 0;
1251 point_freq_vec.create (get_max_uid () * 2);
1252 lra_point_freq = point_freq_vec.address ();
1253 int *post_order_rev_cfg = XNEWVEC (int, last_basic_block_for_fn (cfun));
1254 int n_blocks_inverted = inverted_post_order_compute (post_order_rev_cfg);
1255 lra_assert (n_blocks_inverted == n_basic_blocks_for_fn (cfun));
1256 bb_live_change_p = false;
1257 for (i = n_blocks_inverted - 1; i >= 0; --i)
1259 bb = BASIC_BLOCK_FOR_FN (cfun, post_order_rev_cfg[i]);
1260 if (bb == EXIT_BLOCK_PTR_FOR_FN (cfun) || bb
1261 == ENTRY_BLOCK_PTR_FOR_FN (cfun))
1262 continue;
1263 if (process_bb_lives (bb, curr_point, dead_insn_p))
1264 bb_live_change_p = true;
1266 if (bb_live_change_p)
1268 /* We need to clear pseudo live info as some pseudos can
1269 disappear, e.g. pseudos with used equivalences. */
1270 FOR_EACH_BB_FN (bb, cfun)
1272 bitmap_clear_range (df_get_live_in (bb), FIRST_PSEUDO_REGISTER,
1273 max_regno - FIRST_PSEUDO_REGISTER);
1274 bitmap_clear_range (df_get_live_out (bb), FIRST_PSEUDO_REGISTER,
1275 max_regno - FIRST_PSEUDO_REGISTER);
1277 /* As we did not change CFG since LRA start we can use
1278 DF-infrastructure solver to solve live data flow problem. */
1279 df_simple_dataflow
1280 (DF_BACKWARD, NULL, live_con_fun_0, live_con_fun_n,
1281 live_trans_fun, &all_blocks,
1282 df_get_postorder (DF_BACKWARD), df_get_n_blocks (DF_BACKWARD));
1283 if (lra_dump_file != NULL)
1285 fprintf (lra_dump_file,
1286 "Global pseudo live data have been updated:\n");
1287 basic_block bb;
1288 FOR_EACH_BB_FN (bb, cfun)
1290 bb_data_t bb_info = get_bb_data (bb);
1291 bitmap bb_livein = df_get_live_in (bb);
1292 bitmap bb_liveout = df_get_live_out (bb);
1294 fprintf (lra_dump_file, "\nBB %d:\n", bb->index);
1295 lra_dump_bitmap_with_title (" gen:",
1296 &bb_info->gen_pseudos, bb->index);
1297 lra_dump_bitmap_with_title (" killed:",
1298 &bb_info->killed_pseudos, bb->index);
1299 lra_dump_bitmap_with_title (" livein:", bb_livein, bb->index);
1300 lra_dump_bitmap_with_title (" liveout:", bb_liveout, bb->index);
1304 free (post_order_rev_cfg);
1305 lra_live_max_point = curr_point;
1306 if (lra_dump_file != NULL)
1307 print_live_ranges (lra_dump_file);
1308 /* Clean up. */
1309 sparseset_free (unused_set);
1310 sparseset_free (dead_set);
1311 sparseset_free (start_dying);
1312 sparseset_free (start_living);
1313 sparseset_free (pseudos_live_through_calls);
1314 sparseset_free (pseudos_live_through_setjumps);
1315 sparseset_free (pseudos_live);
1316 compress_live_ranges ();
1317 timevar_pop (TV_LRA_CREATE_LIVE_RANGES);
1318 return bb_live_change_p;
1321 /* The main entry function creates live-ranges and other live info
1322 necessary for the assignment sub-pass. It uses
1323 lra_creates_live_ranges_1 -- so read comments for the
1324 function. */
1325 void
1326 lra_create_live_ranges (bool all_p, bool dead_insn_p)
1328 if (! lra_create_live_ranges_1 (all_p, dead_insn_p))
1329 return;
1330 if (lra_dump_file != NULL)
1331 fprintf (lra_dump_file, "Live info was changed -- recalculate it\n");
1332 /* Live info was changed on a bb border. It means that some info,
1333 e.g. about conflict regs, calls crossed, and live ranges may be
1334 wrong. We need this info for allocation. So recalculate it
1335 again but without removing dead insns which can change live info
1336 again. Repetitive live range calculations are expensive therefore
1337 we stop here as we already have correct info although some
1338 improvement in rare cases could be possible on this sub-pass if
1339 we do dead insn elimination again (still the improvement may
1340 happen later). */
1341 lra_clear_live_ranges ();
1342 bool res = lra_create_live_ranges_1 (all_p, false);
1343 lra_assert (! res);
1346 /* Finish all live ranges. */
1347 void
1348 lra_clear_live_ranges (void)
1350 int i;
1352 for (i = 0; i < max_reg_num (); i++)
1353 free_live_range_list (lra_reg_info[i].live_ranges);
1354 point_freq_vec.release ();
1357 /* Initialize live ranges data once per function. */
1358 void
1359 lra_live_ranges_init (void)
1361 bitmap_initialize (&temp_bitmap, &reg_obstack);
1362 initiate_live_solver ();
1365 /* Finish live ranges data once per function. */
1366 void
1367 lra_live_ranges_finish (void)
1369 finish_live_solver ();
1370 bitmap_clear (&temp_bitmap);
1371 lra_live_range::pool.release ();