1 /* Build live ranges for pseudos.
2 Copyright (C) 2010-2017 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
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
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. */
30 #include "coretypes.h"
38 #include "insn-config.h"
43 #include "sparseset.h"
47 /* Program points are enumerated by numbers from range
48 0..LRA_LIVE_MAX_POINT-1. There are approximately two times more
49 program points than insns. Program points are places in the
50 program where liveness info can be changed. In most general case
51 (there are more complicated cases too) some program points
52 correspond to places where input operand dies and other ones
53 correspond to places where output operands are born. */
54 int lra_live_max_point
;
56 /* Accumulated execution frequency of all references for each hard
58 int lra_hard_reg_usage
[FIRST_PSEUDO_REGISTER
];
60 /* A global flag whose true value says to build live ranges for all
61 pseudos, otherwise the live ranges only for pseudos got memory is
62 build. True value means also building copies and setting up hard
63 register preferences. The complete info is necessary only for the
64 assignment pass. The complete info is not needed for the
65 coalescing and spill passes. */
66 static bool complete_info_p
;
68 /* Pseudos live at current point in the RTL scan. */
69 static sparseset pseudos_live
;
71 /* Pseudos probably living through calls and setjumps. As setjump is
72 a call too, if a bit in PSEUDOS_LIVE_THROUGH_SETJUMPS is set up
73 then the corresponding bit in PSEUDOS_LIVE_THROUGH_CALLS is set up
74 too. These data are necessary for cases when only one subreg of a
75 multi-reg pseudo is set up after a call. So we decide it is
76 probably live when traversing bb backward. We are sure about
77 living when we see its usage or definition of the pseudo. */
78 static sparseset pseudos_live_through_calls
;
79 static sparseset pseudos_live_through_setjumps
;
81 /* Set of hard regs (except eliminable ones) currently live. */
82 static HARD_REG_SET hard_regs_live
;
84 /* Set of pseudos and hard registers start living/dying in the current
85 insn. These sets are used to update REG_DEAD and REG_UNUSED notes
87 static sparseset start_living
, start_dying
;
89 /* Set of pseudos and hard regs dead and unused in the current
91 static sparseset unused_set
, dead_set
;
93 /* Bitmap used for holding intermediate bitmap operation results. */
94 static bitmap_head temp_bitmap
;
96 /* Pool for pseudo live ranges. */
97 static object_allocator
<lra_live_range
> lra_live_range_pool ("live ranges");
99 /* Free live range list LR. */
101 free_live_range_list (lra_live_range_t lr
)
103 lra_live_range_t next
;
108 lra_live_range_pool
.remove (lr
);
113 /* Create and return pseudo live range with given attributes. */
114 static lra_live_range_t
115 create_live_range (int regno
, int start
, int finish
, lra_live_range_t next
)
117 lra_live_range_t p
= lra_live_range_pool
.allocate ();
125 /* Copy live range R and return the result. */
126 static lra_live_range_t
127 copy_live_range (lra_live_range_t r
)
129 return new (lra_live_range_pool
) lra_live_range (*r
);
132 /* Copy live range list given by its head R and return the result. */
134 lra_copy_live_range_list (lra_live_range_t r
)
136 lra_live_range_t p
, first
, *chain
;
139 for (chain
= &first
; r
!= NULL
; r
= r
->next
)
141 p
= copy_live_range (r
);
148 /* Merge *non-intersected* ranges R1 and R2 and returns the result.
149 The function maintains the order of ranges and tries to minimize
150 size of the result range list. Ranges R1 and R2 may not be used
153 lra_merge_live_ranges (lra_live_range_t r1
, lra_live_range_t r2
)
155 lra_live_range_t first
, last
;
161 for (first
= last
= NULL
; r1
!= NULL
&& r2
!= NULL
;)
163 if (r1
->start
< r2
->start
)
166 if (r1
->start
== r2
->finish
+ 1)
168 /* Joint ranges: merge r1 and r2 into r1. */
169 r1
->start
= r2
->start
;
170 lra_live_range_t temp
= r2
;
172 lra_live_range_pool
.remove (temp
);
176 gcc_assert (r2
->finish
+ 1 < r1
->start
);
177 /* Add r1 to the result. */
197 lra_assert (r2
!= NULL
);
206 /* Return TRUE if live ranges R1 and R2 intersect. */
208 lra_intersected_live_ranges_p (lra_live_range_t r1
, lra_live_range_t r2
)
210 /* Remember the live ranges are always kept ordered. */
211 while (r1
!= NULL
&& r2
!= NULL
)
213 if (r1
->start
> r2
->finish
)
215 else if (r2
->start
> r1
->finish
)
223 /* The function processing birth of hard register REGNO. It updates
224 living hard regs, START_LIVING, and conflict hard regs for living
225 pseudos. Conflict hard regs for the pic pseudo is not updated if
226 REGNO is REAL_PIC_OFFSET_TABLE_REGNUM and CHECK_PIC_PSEUDO_P is
229 make_hard_regno_born (int regno
, bool check_pic_pseudo_p ATTRIBUTE_UNUSED
)
233 lra_assert (regno
< FIRST_PSEUDO_REGISTER
);
234 if (TEST_HARD_REG_BIT (hard_regs_live
, regno
))
236 SET_HARD_REG_BIT (hard_regs_live
, regno
);
237 sparseset_set_bit (start_living
, regno
);
238 EXECUTE_IF_SET_IN_SPARSESET (pseudos_live
, i
)
239 #ifdef REAL_PIC_OFFSET_TABLE_REGNUM
240 if (! check_pic_pseudo_p
241 || regno
!= REAL_PIC_OFFSET_TABLE_REGNUM
242 || pic_offset_table_rtx
== NULL
243 || i
!= REGNO (pic_offset_table_rtx
))
245 SET_HARD_REG_BIT (lra_reg_info
[i
].conflict_hard_regs
, regno
);
248 /* Process the death of hard register REGNO. This updates
249 hard_regs_live and START_DYING. */
251 make_hard_regno_dead (int regno
)
253 lra_assert (regno
< FIRST_PSEUDO_REGISTER
);
254 if (! TEST_HARD_REG_BIT (hard_regs_live
, regno
))
256 sparseset_set_bit (start_dying
, regno
);
257 CLEAR_HARD_REG_BIT (hard_regs_live
, regno
);
260 /* Mark pseudo REGNO as living at program point POINT, update conflicting
261 hard registers of the pseudo and START_LIVING, and start a new live
262 range for the pseudo corresponding to REGNO if it is necessary. */
264 mark_pseudo_live (int regno
, int point
)
268 lra_assert (regno
>= FIRST_PSEUDO_REGISTER
);
269 lra_assert (! sparseset_bit_p (pseudos_live
, regno
));
270 sparseset_set_bit (pseudos_live
, regno
);
271 IOR_HARD_REG_SET (lra_reg_info
[regno
].conflict_hard_regs
, hard_regs_live
);
273 if ((complete_info_p
|| lra_get_regno_hard_regno (regno
) < 0)
274 && ((p
= lra_reg_info
[regno
].live_ranges
) == NULL
275 || (p
->finish
!= point
&& p
->finish
+ 1 != point
)))
276 lra_reg_info
[regno
].live_ranges
277 = create_live_range (regno
, point
, -1, p
);
278 sparseset_set_bit (start_living
, regno
);
281 /* Mark pseudo REGNO as not living at program point POINT and update
283 This finishes the current live range for the pseudo corresponding
286 mark_pseudo_dead (int regno
, int point
)
290 lra_assert (regno
>= FIRST_PSEUDO_REGISTER
);
291 lra_assert (sparseset_bit_p (pseudos_live
, regno
));
292 sparseset_clear_bit (pseudos_live
, regno
);
293 sparseset_set_bit (start_dying
, regno
);
294 if (complete_info_p
|| lra_get_regno_hard_regno (regno
) < 0)
296 p
= lra_reg_info
[regno
].live_ranges
;
297 lra_assert (p
!= NULL
);
302 /* The corresponding bitmaps of BB currently being processed. */
303 static bitmap bb_killed_pseudos
, bb_gen_pseudos
;
305 /* Mark register REGNO (pseudo or hard register) in MODE as live at
306 program point POINT. Update BB_GEN_PSEUDOS.
307 Return TRUE if the liveness tracking sets were modified, or FALSE
308 if nothing changed. */
310 mark_regno_live (int regno
, machine_mode mode
, int point
)
313 bool changed
= false;
315 if (regno
< FIRST_PSEUDO_REGISTER
)
317 for (last
= end_hard_regno (mode
, regno
); regno
< last
; regno
++)
318 make_hard_regno_born (regno
, false);
322 if (! sparseset_bit_p (pseudos_live
, regno
))
324 mark_pseudo_live (regno
, point
);
327 bitmap_set_bit (bb_gen_pseudos
, regno
);
333 /* Mark register REGNO in MODE as dead at program point POINT. Update
334 BB_GEN_PSEUDOS and BB_KILLED_PSEUDOS. Return TRUE if the liveness
335 tracking sets were modified, or FALSE if nothing changed. */
337 mark_regno_dead (int regno
, machine_mode mode
, int point
)
340 bool changed
= false;
342 if (regno
< FIRST_PSEUDO_REGISTER
)
344 for (last
= end_hard_regno (mode
, regno
); regno
< last
; regno
++)
345 make_hard_regno_dead (regno
);
349 if (sparseset_bit_p (pseudos_live
, regno
))
351 mark_pseudo_dead (regno
, point
);
354 bitmap_clear_bit (bb_gen_pseudos
, regno
);
355 bitmap_set_bit (bb_killed_pseudos
, regno
);
362 /* This page contains code for making global live analysis of pseudos.
363 The code works only when pseudo live info is changed on a BB
364 border. That might be a consequence of some global transformations
365 in LRA, e.g. PIC pseudo reuse or rematerialization. */
367 /* Structure describing local BB data used for pseudo
369 struct bb_data_pseudos
371 /* Basic block about which the below data are. */
373 bitmap_head killed_pseudos
; /* pseudos killed in the BB. */
374 bitmap_head gen_pseudos
; /* pseudos generated in the BB. */
377 /* Array for all BB data. Indexed by the corresponding BB index. */
378 typedef struct bb_data_pseudos
*bb_data_t
;
380 /* All basic block data are referred through the following array. */
381 static bb_data_t bb_data
;
383 /* Two small functions for access to the bb data. */
384 static inline bb_data_t
385 get_bb_data (basic_block bb
)
387 return &bb_data
[(bb
)->index
];
390 static inline bb_data_t
391 get_bb_data_by_index (int index
)
393 return &bb_data
[index
];
396 /* Bitmap with all hard regs. */
397 static bitmap_head all_hard_regs_bitmap
;
399 /* The transfer function used by the DF equation solver to propagate
400 live info through block with BB_INDEX according to the following
403 bb.livein = (bb.liveout - bb.kill) OR bb.gen
406 live_trans_fun (int bb_index
)
408 basic_block bb
= get_bb_data_by_index (bb_index
)->bb
;
409 bitmap bb_liveout
= df_get_live_out (bb
);
410 bitmap bb_livein
= df_get_live_in (bb
);
411 bb_data_t bb_info
= get_bb_data (bb
);
413 bitmap_and_compl (&temp_bitmap
, bb_liveout
, &all_hard_regs_bitmap
);
414 return bitmap_ior_and_compl (bb_livein
, &bb_info
->gen_pseudos
,
415 &temp_bitmap
, &bb_info
->killed_pseudos
);
418 /* The confluence function used by the DF equation solver to set up
419 live info for a block BB without predecessor. */
421 live_con_fun_0 (basic_block bb
)
423 bitmap_and_into (df_get_live_out (bb
), &all_hard_regs_bitmap
);
426 /* The confluence function used by the DF equation solver to propagate
427 live info from successor to predecessor on edge E according to the
430 bb.liveout = 0 for entry block | OR (livein of successors)
433 live_con_fun_n (edge e
)
435 basic_block bb
= e
->src
;
436 basic_block dest
= e
->dest
;
437 bitmap bb_liveout
= df_get_live_out (bb
);
438 bitmap dest_livein
= df_get_live_in (dest
);
440 return bitmap_ior_and_compl_into (bb_liveout
,
441 dest_livein
, &all_hard_regs_bitmap
);
444 /* Indexes of all function blocks. */
445 static bitmap_head all_blocks
;
447 /* Allocate and initialize data needed for global pseudo live
450 initiate_live_solver (void)
452 bitmap_initialize (&all_hard_regs_bitmap
, ®_obstack
);
453 bitmap_set_range (&all_hard_regs_bitmap
, 0, FIRST_PSEUDO_REGISTER
);
454 bb_data
= XNEWVEC (struct bb_data_pseudos
, last_basic_block_for_fn (cfun
));
455 bitmap_initialize (&all_blocks
, ®_obstack
);
458 FOR_ALL_BB_FN (bb
, cfun
)
460 bb_data_t bb_info
= get_bb_data (bb
);
462 bitmap_initialize (&bb_info
->killed_pseudos
, ®_obstack
);
463 bitmap_initialize (&bb_info
->gen_pseudos
, ®_obstack
);
464 bitmap_set_bit (&all_blocks
, bb
->index
);
468 /* Free all data needed for global pseudo live analysis. */
470 finish_live_solver (void)
474 bitmap_clear (&all_blocks
);
475 FOR_ALL_BB_FN (bb
, cfun
)
477 bb_data_t bb_info
= get_bb_data (bb
);
478 bitmap_clear (&bb_info
->killed_pseudos
);
479 bitmap_clear (&bb_info
->gen_pseudos
);
482 bitmap_clear (&all_hard_regs_bitmap
);
487 /* Insn currently scanned. */
488 static rtx_insn
*curr_insn
;
490 static lra_insn_recog_data_t curr_id
;
491 /* The insn static data. */
492 static struct lra_static_insn_data
*curr_static_id
;
494 /* Vec containing execution frequencies of program points. */
495 static vec
<int> point_freq_vec
;
497 /* The start of the above vector elements. */
500 /* Increment the current program point POINT to the next point which has
501 execution frequency FREQ. */
503 next_program_point (int &point
, int freq
)
505 point_freq_vec
.safe_push (freq
);
506 lra_point_freq
= point_freq_vec
.address ();
510 /* Update the preference of HARD_REGNO for pseudo REGNO by PROFIT. */
512 lra_setup_reload_pseudo_preferenced_hard_reg (int regno
,
513 int hard_regno
, int profit
)
515 lra_assert (regno
>= lra_constraint_new_regno_start
);
516 if (lra_reg_info
[regno
].preferred_hard_regno1
== hard_regno
)
517 lra_reg_info
[regno
].preferred_hard_regno_profit1
+= profit
;
518 else if (lra_reg_info
[regno
].preferred_hard_regno2
== hard_regno
)
519 lra_reg_info
[regno
].preferred_hard_regno_profit2
+= profit
;
520 else if (lra_reg_info
[regno
].preferred_hard_regno1
< 0)
522 lra_reg_info
[regno
].preferred_hard_regno1
= hard_regno
;
523 lra_reg_info
[regno
].preferred_hard_regno_profit1
= profit
;
525 else if (lra_reg_info
[regno
].preferred_hard_regno2
< 0
526 || profit
> lra_reg_info
[regno
].preferred_hard_regno_profit2
)
528 lra_reg_info
[regno
].preferred_hard_regno2
= hard_regno
;
529 lra_reg_info
[regno
].preferred_hard_regno_profit2
= profit
;
533 /* Keep the 1st hard regno as more profitable. */
534 if (lra_reg_info
[regno
].preferred_hard_regno1
>= 0
535 && lra_reg_info
[regno
].preferred_hard_regno2
>= 0
536 && (lra_reg_info
[regno
].preferred_hard_regno_profit2
537 > lra_reg_info
[regno
].preferred_hard_regno_profit1
))
539 std::swap (lra_reg_info
[regno
].preferred_hard_regno1
,
540 lra_reg_info
[regno
].preferred_hard_regno2
);
541 std::swap (lra_reg_info
[regno
].preferred_hard_regno_profit1
,
542 lra_reg_info
[regno
].preferred_hard_regno_profit2
);
544 if (lra_dump_file
!= NULL
)
546 if ((hard_regno
= lra_reg_info
[regno
].preferred_hard_regno1
) >= 0)
547 fprintf (lra_dump_file
,
548 " Hard reg %d is preferable by r%d with profit %d\n",
550 lra_reg_info
[regno
].preferred_hard_regno_profit1
);
551 if ((hard_regno
= lra_reg_info
[regno
].preferred_hard_regno2
) >= 0)
552 fprintf (lra_dump_file
,
553 " Hard reg %d is preferable by r%d with profit %d\n",
555 lra_reg_info
[regno
].preferred_hard_regno_profit2
);
559 /* Check that REGNO living through calls and setjumps, set up conflict
560 regs using LAST_CALL_USED_REG_SET, and clear corresponding bits in
561 PSEUDOS_LIVE_THROUGH_CALLS and PSEUDOS_LIVE_THROUGH_SETJUMPS. */
563 check_pseudos_live_through_calls (int regno
,
564 HARD_REG_SET last_call_used_reg_set
)
568 if (! sparseset_bit_p (pseudos_live_through_calls
, regno
))
570 sparseset_clear_bit (pseudos_live_through_calls
, regno
);
571 IOR_HARD_REG_SET (lra_reg_info
[regno
].conflict_hard_regs
,
572 last_call_used_reg_set
);
574 for (hr
= 0; hr
< FIRST_PSEUDO_REGISTER
; hr
++)
575 if (targetm
.hard_regno_call_part_clobbered (hr
,
576 PSEUDO_REGNO_MODE (regno
)))
577 SET_HARD_REG_BIT (lra_reg_info
[regno
].conflict_hard_regs
, hr
);
578 lra_reg_info
[regno
].call_p
= true;
579 if (! sparseset_bit_p (pseudos_live_through_setjumps
, regno
))
581 sparseset_clear_bit (pseudos_live_through_setjumps
, regno
);
582 /* Don't allocate pseudos that cross setjmps or any call, if this
583 function receives a nonlocal goto. */
584 SET_HARD_REG_SET (lra_reg_info
[regno
].conflict_hard_regs
);
587 /* Return true if insn REG is an early clobber operand in alternative
588 NALT. Negative NALT means that we don't know the current insn
589 alternative. So assume the worst. */
591 reg_early_clobber_p (const struct lra_insn_reg
*reg
, int n_alt
)
593 return (reg
->early_clobber
594 && (n_alt
< 0 || TEST_BIT (reg
->early_clobber_alts
, n_alt
)));
597 /* Process insns of the basic block BB to update pseudo live ranges,
598 pseudo hard register conflicts, and insn notes. We do it on
599 backward scan of BB insns. CURR_POINT is the program point where
600 BB ends. The function updates this counter and returns in
601 CURR_POINT the program point where BB starts. The function also
602 does local live info updates and can delete the dead insns if
603 DEAD_INSN_P. It returns true if pseudo live info was
604 changed at the BB start. */
606 process_bb_lives (basic_block bb
, int &curr_point
, bool dead_insn_p
)
615 bool need_curr_point_incr
;
616 HARD_REG_SET last_call_used_reg_set
;
618 reg_live_out
= df_get_live_out (bb
);
619 sparseset_clear (pseudos_live
);
620 sparseset_clear (pseudos_live_through_calls
);
621 sparseset_clear (pseudos_live_through_setjumps
);
622 CLEAR_HARD_REG_SET (last_call_used_reg_set
);
623 REG_SET_TO_HARD_REG_SET (hard_regs_live
, reg_live_out
);
624 AND_COMPL_HARD_REG_SET (hard_regs_live
, eliminable_regset
);
625 EXECUTE_IF_SET_IN_BITMAP (reg_live_out
, FIRST_PSEUDO_REGISTER
, j
, bi
)
626 mark_pseudo_live (j
, curr_point
);
628 bb_gen_pseudos
= &get_bb_data (bb
)->gen_pseudos
;
629 bb_killed_pseudos
= &get_bb_data (bb
)->killed_pseudos
;
630 bitmap_clear (bb_gen_pseudos
);
631 bitmap_clear (bb_killed_pseudos
);
632 freq
= REG_FREQ_FROM_BB (bb
);
634 if (lra_dump_file
!= NULL
)
635 fprintf (lra_dump_file
, " BB %d\n", bb
->index
);
637 /* Scan the code of this basic block, noting which pseudos and hard
638 regs are born or die.
640 Note that this loop treats uninitialized values as live until the
641 beginning of the block. For example, if an instruction uses
642 (reg:DI foo), and only (subreg:SI (reg:DI foo) 0) is ever set,
643 FOO will remain live until the beginning of the block. Likewise
644 if FOO is not set at all. This is unnecessarily pessimistic, but
645 it probably doesn't matter much in practice. */
646 FOR_BB_INSNS_REVERSE_SAFE (bb
, curr_insn
, next
)
649 int n_alt
, dst_regno
, src_regno
;
651 struct lra_insn_reg
*reg
;
653 if (!NONDEBUG_INSN_P (curr_insn
))
656 curr_id
= lra_get_insn_recog_data (curr_insn
);
657 curr_static_id
= curr_id
->insn_static_data
;
658 n_alt
= curr_id
->used_insn_alternative
;
659 if (lra_dump_file
!= NULL
)
660 fprintf (lra_dump_file
, " Insn %u: point = %d, n_alt = %d\n",
661 INSN_UID (curr_insn
), curr_point
, n_alt
);
663 set
= single_set (curr_insn
);
665 if (dead_insn_p
&& set
!= NULL_RTX
666 && REG_P (SET_DEST (set
)) && REGNO (SET_DEST (set
)) >= FIRST_PSEUDO_REGISTER
667 && find_reg_note (curr_insn
, REG_EH_REGION
, NULL_RTX
) == NULL_RTX
668 && ! may_trap_p (PATTERN (curr_insn
))
669 /* Don't do premature remove of pic offset pseudo as we can
670 start to use it after some reload generation. */
671 && (pic_offset_table_rtx
== NULL_RTX
672 || pic_offset_table_rtx
!= SET_DEST (set
)))
674 bool remove_p
= true;
676 for (reg
= curr_id
->regs
; reg
!= NULL
; reg
= reg
->next
)
677 if (reg
->type
!= OP_IN
&& sparseset_bit_p (pseudos_live
, reg
->regno
))
682 for (reg
= curr_static_id
->hard_regs
; reg
!= NULL
; reg
= reg
->next
)
683 if (reg
->type
!= OP_IN
)
688 if (remove_p
&& ! volatile_refs_p (PATTERN (curr_insn
)))
690 dst_regno
= REGNO (SET_DEST (set
));
691 if (lra_dump_file
!= NULL
)
692 fprintf (lra_dump_file
, " Deleting dead insn %u\n",
693 INSN_UID (curr_insn
));
694 lra_set_insn_deleted (curr_insn
);
695 if (lra_reg_info
[dst_regno
].nrefs
== 0)
697 /* There might be some debug insns with the pseudo. */
701 bitmap_copy (&temp_bitmap
, &lra_reg_info
[dst_regno
].insn_bitmap
);
702 EXECUTE_IF_SET_IN_BITMAP (&temp_bitmap
, 0, uid
, bi
)
704 insn
= lra_insn_recog_data
[uid
]->insn
;
705 lra_substitute_pseudo_within_insn (insn
, dst_regno
,
706 SET_SRC (set
), true);
707 lra_update_insn_regno_info (insn
);
714 /* Update max ref width and hard reg usage. */
715 for (reg
= curr_id
->regs
; reg
!= NULL
; reg
= reg
->next
)
717 int i
, regno
= reg
->regno
;
719 if (partial_subreg_p (lra_reg_info
[regno
].biggest_mode
,
721 lra_reg_info
[regno
].biggest_mode
= reg
->biggest_mode
;
722 if (regno
< FIRST_PSEUDO_REGISTER
)
724 lra_hard_reg_usage
[regno
] += freq
;
725 /* A hard register explicitly can be used in small mode,
726 but implicitly it can be used in natural mode as a
727 part of multi-register group. Process this case
729 for (i
= 1; i
< hard_regno_nregs (regno
, reg
->biggest_mode
); i
++)
730 if (partial_subreg_p (lra_reg_info
[regno
+ i
].biggest_mode
,
731 GET_MODE (regno_reg_rtx
[regno
+ i
])))
732 lra_reg_info
[regno
+ i
].biggest_mode
733 = GET_MODE (regno_reg_rtx
[regno
+ i
]);
737 call_p
= CALL_P (curr_insn
);
738 src_regno
= (set
!= NULL_RTX
&& REG_P (SET_SRC (set
))
739 ? REGNO (SET_SRC (set
)) : -1);
740 dst_regno
= (set
!= NULL_RTX
&& REG_P (SET_DEST (set
))
741 ? REGNO (SET_DEST (set
)) : -1);
743 && src_regno
>= 0 && dst_regno
>= 0
744 /* Check that source regno does not conflict with
745 destination regno to exclude most impossible
747 && (((src_regno
>= FIRST_PSEUDO_REGISTER
748 && (! sparseset_bit_p (pseudos_live
, src_regno
)
749 || (dst_regno
>= FIRST_PSEUDO_REGISTER
750 && lra_reg_val_equal_p (src_regno
,
751 lra_reg_info
[dst_regno
].val
,
752 lra_reg_info
[dst_regno
].offset
))))
753 || (src_regno
< FIRST_PSEUDO_REGISTER
754 && ! TEST_HARD_REG_BIT (hard_regs_live
, src_regno
)))
755 /* It might be 'inheritance pseudo <- reload pseudo'. */
756 || (src_regno
>= lra_constraint_new_regno_start
757 && dst_regno
>= lra_constraint_new_regno_start
758 /* Remember to skip special cases where src/dest regnos are
759 the same, e.g. insn SET pattern has matching constraints
761 && src_regno
!= dst_regno
)))
763 int hard_regno
= -1, regno
= -1;
765 if (dst_regno
>= lra_constraint_new_regno_start
766 && src_regno
>= lra_constraint_new_regno_start
)
768 /* It might be still an original (non-reload) insn with
769 one unused output and a constraint requiring to use
770 the same reg for input/output operands. In this case
771 dst_regno and src_regno have the same value, we don't
772 need a misleading copy for this case. */
773 if (dst_regno
!= src_regno
)
774 lra_create_copy (dst_regno
, src_regno
, freq
);
776 else if (dst_regno
>= lra_constraint_new_regno_start
)
778 if ((hard_regno
= src_regno
) >= FIRST_PSEUDO_REGISTER
)
779 hard_regno
= reg_renumber
[src_regno
];
782 else if (src_regno
>= lra_constraint_new_regno_start
)
784 if ((hard_regno
= dst_regno
) >= FIRST_PSEUDO_REGISTER
)
785 hard_regno
= reg_renumber
[dst_regno
];
788 if (regno
>= 0 && hard_regno
>= 0)
789 lra_setup_reload_pseudo_preferenced_hard_reg
790 (regno
, hard_regno
, freq
);
793 sparseset_clear (start_living
);
795 /* Try to avoid unnecessary program point increments, this saves
796 a lot of time in remove_some_program_points_and_update_live_ranges.
797 We only need an increment if something becomes live or dies at this
799 need_curr_point_incr
= false;
801 /* Mark each defined value as live. We need to do this for
802 unused values because they still conflict with quantities
803 that are live at the time of the definition. */
804 for (reg
= curr_id
->regs
; reg
!= NULL
; reg
= reg
->next
)
805 if (reg
->type
!= OP_IN
)
808 |= mark_regno_live (reg
->regno
, reg
->biggest_mode
,
810 check_pseudos_live_through_calls (reg
->regno
,
811 last_call_used_reg_set
);
814 for (reg
= curr_static_id
->hard_regs
; reg
!= NULL
; reg
= reg
->next
)
815 if (reg
->type
!= OP_IN
)
816 make_hard_regno_born (reg
->regno
, false);
818 if (curr_id
->arg_hard_regs
!= NULL
)
819 for (i
= 0; (regno
= curr_id
->arg_hard_regs
[i
]) >= 0; i
++)
820 if (regno
>= FIRST_PSEUDO_REGISTER
)
821 /* It is a clobber. */
822 make_hard_regno_born (regno
- FIRST_PSEUDO_REGISTER
, false);
824 sparseset_copy (unused_set
, start_living
);
826 sparseset_clear (start_dying
);
828 /* See which defined values die here. */
829 for (reg
= curr_id
->regs
; reg
!= NULL
; reg
= reg
->next
)
830 if (reg
->type
== OP_OUT
831 && ! reg_early_clobber_p (reg
, n_alt
) && ! reg
->subreg_p
)
833 |= mark_regno_dead (reg
->regno
, reg
->biggest_mode
,
836 for (reg
= curr_static_id
->hard_regs
; reg
!= NULL
; reg
= reg
->next
)
837 if (reg
->type
== OP_OUT
838 && ! reg_early_clobber_p (reg
, n_alt
) && ! reg
->subreg_p
)
839 make_hard_regno_dead (reg
->regno
);
841 if (curr_id
->arg_hard_regs
!= NULL
)
842 for (i
= 0; (regno
= curr_id
->arg_hard_regs
[i
]) >= 0; i
++)
843 if (regno
>= FIRST_PSEUDO_REGISTER
)
844 /* It is a clobber. */
845 make_hard_regno_dead (regno
- FIRST_PSEUDO_REGISTER
);
850 COPY_HARD_REG_SET(last_call_used_reg_set
, call_used_reg_set
);
853 HARD_REG_SET this_call_used_reg_set
;
854 get_call_reg_set_usage (curr_insn
, &this_call_used_reg_set
,
857 bool flush
= (! hard_reg_set_empty_p (last_call_used_reg_set
)
858 && ! hard_reg_set_equal_p (last_call_used_reg_set
,
859 this_call_used_reg_set
));
861 EXECUTE_IF_SET_IN_SPARSESET (pseudos_live
, j
)
863 IOR_HARD_REG_SET (lra_reg_info
[j
].actual_call_used_reg_set
,
864 this_call_used_reg_set
);
866 check_pseudos_live_through_calls
867 (j
, last_call_used_reg_set
);
869 COPY_HARD_REG_SET(last_call_used_reg_set
, this_call_used_reg_set
);
872 sparseset_ior (pseudos_live_through_calls
,
873 pseudos_live_through_calls
, pseudos_live
);
874 if (cfun
->has_nonlocal_label
875 || find_reg_note (curr_insn
, REG_SETJMP
,
876 NULL_RTX
) != NULL_RTX
)
877 sparseset_ior (pseudos_live_through_setjumps
,
878 pseudos_live_through_setjumps
, pseudos_live
);
881 /* Increment the current program point if we must. */
882 if (need_curr_point_incr
)
883 next_program_point (curr_point
, freq
);
885 sparseset_clear (start_living
);
887 need_curr_point_incr
= false;
889 /* Mark each used value as live. */
890 for (reg
= curr_id
->regs
; reg
!= NULL
; reg
= reg
->next
)
891 if (reg
->type
== OP_IN
)
894 |= mark_regno_live (reg
->regno
, reg
->biggest_mode
,
896 check_pseudos_live_through_calls (reg
->regno
,
897 last_call_used_reg_set
);
900 for (reg
= curr_static_id
->hard_regs
; reg
!= NULL
; reg
= reg
->next
)
901 if (reg
->type
== OP_IN
)
902 make_hard_regno_born (reg
->regno
, false);
904 if (curr_id
->arg_hard_regs
!= NULL
)
905 /* Make argument hard registers live. Don't create conflict
906 of used REAL_PIC_OFFSET_TABLE_REGNUM and the pic pseudo. */
907 for (i
= 0; (regno
= curr_id
->arg_hard_regs
[i
]) >= 0; i
++)
908 if (regno
< FIRST_PSEUDO_REGISTER
)
909 make_hard_regno_born (regno
, true);
911 sparseset_and_compl (dead_set
, start_living
, start_dying
);
913 /* Mark early clobber outputs dead. */
914 for (reg
= curr_id
->regs
; reg
!= NULL
; reg
= reg
->next
)
915 if (reg
->type
== OP_OUT
916 && reg_early_clobber_p (reg
, n_alt
) && ! reg
->subreg_p
)
918 |= mark_regno_dead (reg
->regno
, reg
->biggest_mode
,
921 for (reg
= curr_static_id
->hard_regs
; reg
!= NULL
; reg
= reg
->next
)
922 if (reg
->type
== OP_OUT
923 && reg_early_clobber_p (reg
, n_alt
) && ! reg
->subreg_p
)
924 make_hard_regno_dead (reg
->regno
);
926 if (need_curr_point_incr
)
927 next_program_point (curr_point
, freq
);
930 for (link_loc
= ®_NOTES (curr_insn
); (link
= *link_loc
) != NULL_RTX
;)
932 if (REG_NOTE_KIND (link
) != REG_DEAD
933 && REG_NOTE_KIND (link
) != REG_UNUSED
)
935 else if (REG_P (XEXP (link
, 0)))
937 regno
= REGNO (XEXP (link
, 0));
938 if ((REG_NOTE_KIND (link
) == REG_DEAD
939 && ! sparseset_bit_p (dead_set
, regno
))
940 || (REG_NOTE_KIND (link
) == REG_UNUSED
941 && ! sparseset_bit_p (unused_set
, regno
)))
943 *link_loc
= XEXP (link
, 1);
946 if (REG_NOTE_KIND (link
) == REG_DEAD
)
947 sparseset_clear_bit (dead_set
, regno
);
948 else if (REG_NOTE_KIND (link
) == REG_UNUSED
)
949 sparseset_clear_bit (unused_set
, regno
);
951 link_loc
= &XEXP (link
, 1);
953 EXECUTE_IF_SET_IN_SPARSESET (dead_set
, j
)
954 add_reg_note (curr_insn
, REG_DEAD
, regno_reg_rtx
[j
]);
955 EXECUTE_IF_SET_IN_SPARSESET (unused_set
, j
)
956 add_reg_note (curr_insn
, REG_UNUSED
, regno_reg_rtx
[j
]);
959 if (bb_has_eh_pred (bb
))
962 unsigned int regno
= EH_RETURN_DATA_REGNO (j
);
964 if (regno
== INVALID_REGNUM
)
966 make_hard_regno_born (regno
, false);
969 /* Pseudos can't go in stack regs at the start of a basic block that
970 is reached by an abnormal edge. Likewise for call clobbered regs,
971 because caller-save, fixup_abnormal_edges and possibly the table
972 driven EH machinery are not quite ready to handle such pseudos
973 live across such edges. */
974 if (bb_has_abnormal_pred (bb
))
977 EXECUTE_IF_SET_IN_SPARSESET (pseudos_live
, px
)
978 lra_reg_info
[px
].no_stack_p
= true;
979 for (px
= FIRST_STACK_REG
; px
<= LAST_STACK_REG
; px
++)
980 make_hard_regno_born (px
, false);
982 /* No need to record conflicts for call clobbered regs if we
983 have nonlocal labels around, as we don't ever try to
984 allocate such regs in this case. */
985 if (!cfun
->has_nonlocal_label
986 && has_abnormal_call_or_eh_pred_edge_p (bb
))
987 for (px
= 0; px
< FIRST_PSEUDO_REGISTER
; px
++)
988 if (call_used_regs
[px
]
989 #ifdef REAL_PIC_OFFSET_TABLE_REGNUM
990 /* We should create a conflict of PIC pseudo with PIC
991 hard reg as PIC hard reg can have a wrong value after
992 jump described by the abnormal edge. In this case we
993 can not allocate PIC hard reg to PIC pseudo as PIC
994 pseudo will also have a wrong value. */
995 || (px
== REAL_PIC_OFFSET_TABLE_REGNUM
996 && pic_offset_table_rtx
!= NULL_RTX
997 && REGNO (pic_offset_table_rtx
) >= FIRST_PSEUDO_REGISTER
)
1000 make_hard_regno_born (px
, false);
1003 bool live_change_p
= false;
1004 /* Check if bb border live info was changed. */
1005 unsigned int live_pseudos_num
= 0;
1006 EXECUTE_IF_SET_IN_BITMAP (df_get_live_in (bb
),
1007 FIRST_PSEUDO_REGISTER
, j
, bi
)
1010 if (! sparseset_bit_p (pseudos_live
, j
))
1012 live_change_p
= true;
1013 if (lra_dump_file
!= NULL
)
1014 fprintf (lra_dump_file
,
1015 " r%d is removed as live at bb%d start\n", j
, bb
->index
);
1020 && sparseset_cardinality (pseudos_live
) != live_pseudos_num
)
1022 live_change_p
= true;
1023 if (lra_dump_file
!= NULL
)
1024 EXECUTE_IF_SET_IN_SPARSESET (pseudos_live
, j
)
1025 if (! bitmap_bit_p (df_get_live_in (bb
), j
))
1026 fprintf (lra_dump_file
,
1027 " r%d is added to live at bb%d start\n", j
, bb
->index
);
1029 /* See if we'll need an increment at the end of this basic block.
1030 An increment is needed if the PSEUDOS_LIVE set is not empty,
1031 to make sure the finish points are set up correctly. */
1032 need_curr_point_incr
= (sparseset_cardinality (pseudos_live
) > 0);
1034 EXECUTE_IF_SET_IN_SPARSESET (pseudos_live
, i
)
1035 mark_pseudo_dead (i
, curr_point
);
1037 EXECUTE_IF_SET_IN_BITMAP (df_get_live_in (bb
), FIRST_PSEUDO_REGISTER
, j
, bi
)
1039 if (sparseset_cardinality (pseudos_live_through_calls
) == 0)
1041 if (sparseset_bit_p (pseudos_live_through_calls
, j
))
1042 check_pseudos_live_through_calls (j
, last_call_used_reg_set
);
1045 if (need_curr_point_incr
)
1046 next_program_point (curr_point
, freq
);
1048 return live_change_p
;
1051 /* Compress pseudo live ranges by removing program points where
1052 nothing happens. Complexity of many algorithms in LRA is linear
1053 function of program points number. To speed up the code we try to
1054 minimize the number of the program points here. */
1056 remove_some_program_points_and_update_live_ranges (void)
1061 lra_live_range_t r
, prev_r
, next_r
;
1062 sbitmap_iterator sbi
;
1063 bool born_p
, dead_p
, prev_born_p
, prev_dead_p
;
1065 auto_sbitmap
born (lra_live_max_point
);
1066 auto_sbitmap
dead (lra_live_max_point
);
1067 bitmap_clear (born
);
1068 bitmap_clear (dead
);
1069 max_regno
= max_reg_num ();
1070 for (i
= FIRST_PSEUDO_REGISTER
; i
< (unsigned) max_regno
; i
++)
1072 for (r
= lra_reg_info
[i
].live_ranges
; r
!= NULL
; r
= r
->next
)
1074 lra_assert (r
->start
<= r
->finish
);
1075 bitmap_set_bit (born
, r
->start
);
1076 bitmap_set_bit (dead
, r
->finish
);
1079 auto_sbitmap
born_or_dead (lra_live_max_point
);
1080 bitmap_ior (born_or_dead
, born
, dead
);
1081 map
= XCNEWVEC (int, lra_live_max_point
);
1083 prev_born_p
= prev_dead_p
= false;
1084 EXECUTE_IF_SET_IN_BITMAP (born_or_dead
, 0, i
, sbi
)
1086 born_p
= bitmap_bit_p (born
, i
);
1087 dead_p
= bitmap_bit_p (dead
, i
);
1088 if ((prev_born_p
&& ! prev_dead_p
&& born_p
&& ! dead_p
)
1089 || (prev_dead_p
&& ! prev_born_p
&& dead_p
&& ! born_p
))
1092 lra_point_freq
[n
] = MAX (lra_point_freq
[n
], lra_point_freq
[i
]);
1097 lra_point_freq
[n
] = lra_point_freq
[i
];
1099 prev_born_p
= born_p
;
1100 prev_dead_p
= dead_p
;
1103 if (lra_dump_file
!= NULL
)
1104 fprintf (lra_dump_file
, "Compressing live ranges: from %d to %d - %d%%\n",
1105 lra_live_max_point
, n
, 100 * n
/ lra_live_max_point
);
1106 if (n
< lra_live_max_point
)
1108 lra_live_max_point
= n
;
1109 for (i
= FIRST_PSEUDO_REGISTER
; i
< (unsigned) max_regno
; i
++)
1111 for (prev_r
= NULL
, r
= lra_reg_info
[i
].live_ranges
;
1116 r
->start
= map
[r
->start
];
1117 r
->finish
= map
[r
->finish
];
1118 if (prev_r
== NULL
|| prev_r
->start
> r
->finish
+ 1)
1123 prev_r
->start
= r
->start
;
1124 prev_r
->next
= next_r
;
1125 lra_live_range_pool
.remove (r
);
1132 /* Print live ranges R to file F. */
1134 lra_print_live_range_list (FILE *f
, lra_live_range_t r
)
1136 for (; r
!= NULL
; r
= r
->next
)
1137 fprintf (f
, " [%d..%d]", r
->start
, r
->finish
);
1142 debug (lra_live_range
&ref
)
1144 lra_print_live_range_list (stderr
, &ref
);
1148 debug (lra_live_range
*ptr
)
1153 fprintf (stderr
, "<nil>\n");
1156 /* Print live ranges R to stderr. */
1158 lra_debug_live_range_list (lra_live_range_t r
)
1160 lra_print_live_range_list (stderr
, r
);
1163 /* Print live ranges of pseudo REGNO to file F. */
1165 print_pseudo_live_ranges (FILE *f
, int regno
)
1167 if (lra_reg_info
[regno
].live_ranges
== NULL
)
1169 fprintf (f
, " r%d:", regno
);
1170 lra_print_live_range_list (f
, lra_reg_info
[regno
].live_ranges
);
1173 /* Print live ranges of pseudo REGNO to stderr. */
1175 lra_debug_pseudo_live_ranges (int regno
)
1177 print_pseudo_live_ranges (stderr
, regno
);
1180 /* Print live ranges of all pseudos to file F. */
1182 print_live_ranges (FILE *f
)
1186 max_regno
= max_reg_num ();
1187 for (i
= FIRST_PSEUDO_REGISTER
; i
< max_regno
; i
++)
1188 print_pseudo_live_ranges (f
, i
);
1191 /* Print live ranges of all pseudos to stderr. */
1193 lra_debug_live_ranges (void)
1195 print_live_ranges (stderr
);
1198 /* Compress pseudo live ranges. */
1200 compress_live_ranges (void)
1202 remove_some_program_points_and_update_live_ranges ();
1203 if (lra_dump_file
!= NULL
)
1205 fprintf (lra_dump_file
, "Ranges after the compression:\n");
1206 print_live_ranges (lra_dump_file
);
1212 /* The number of the current live range pass. */
1213 int lra_live_range_iter
;
1215 /* The function creates live ranges only for memory pseudos (or for
1216 all ones if ALL_P), set up CONFLICT_HARD_REGS for the pseudos. It
1217 also does dead insn elimination if DEAD_INSN_P and global live
1218 analysis only for pseudos and only if the pseudo live info was
1219 changed on a BB border. Return TRUE if the live info was
1222 lra_create_live_ranges_1 (bool all_p
, bool dead_insn_p
)
1225 int i
, hard_regno
, max_regno
= max_reg_num ();
1227 bool bb_live_change_p
, have_referenced_pseudos
= false;
1229 timevar_push (TV_LRA_CREATE_LIVE_RANGES
);
1231 complete_info_p
= all_p
;
1232 if (lra_dump_file
!= NULL
)
1233 fprintf (lra_dump_file
,
1234 "\n********** Pseudo live ranges #%d: **********\n\n",
1235 ++lra_live_range_iter
);
1236 memset (lra_hard_reg_usage
, 0, sizeof (lra_hard_reg_usage
));
1237 for (i
= 0; i
< max_regno
; i
++)
1239 lra_reg_info
[i
].live_ranges
= NULL
;
1240 CLEAR_HARD_REG_SET (lra_reg_info
[i
].conflict_hard_regs
);
1241 lra_reg_info
[i
].preferred_hard_regno1
= -1;
1242 lra_reg_info
[i
].preferred_hard_regno2
= -1;
1243 lra_reg_info
[i
].preferred_hard_regno_profit1
= 0;
1244 lra_reg_info
[i
].preferred_hard_regno_profit2
= 0;
1246 lra_reg_info
[i
].no_stack_p
= false;
1248 /* The biggest mode is already set but its value might be to
1249 conservative because of recent transformation. Here in this
1250 file we recalculate it again as it costs practically
1252 if (i
>= FIRST_PSEUDO_REGISTER
&& regno_reg_rtx
[i
] != NULL_RTX
)
1253 lra_reg_info
[i
].biggest_mode
= GET_MODE (regno_reg_rtx
[i
]);
1255 lra_reg_info
[i
].biggest_mode
= VOIDmode
;
1256 lra_reg_info
[i
].call_p
= false;
1257 if (i
>= FIRST_PSEUDO_REGISTER
1258 && lra_reg_info
[i
].nrefs
!= 0)
1260 if ((hard_regno
= reg_renumber
[i
]) >= 0)
1261 lra_hard_reg_usage
[hard_regno
] += lra_reg_info
[i
].freq
;
1262 have_referenced_pseudos
= true;
1267 /* Under some circumstances, we can have functions without pseudo
1268 registers. For such functions, lra_live_max_point will be 0,
1269 see e.g. PR55604, and there's nothing more to do for us here. */
1270 if (! have_referenced_pseudos
)
1272 timevar_pop (TV_LRA_CREATE_LIVE_RANGES
);
1276 pseudos_live
= sparseset_alloc (max_regno
);
1277 pseudos_live_through_calls
= sparseset_alloc (max_regno
);
1278 pseudos_live_through_setjumps
= sparseset_alloc (max_regno
);
1279 start_living
= sparseset_alloc (max_regno
);
1280 start_dying
= sparseset_alloc (max_regno
);
1281 dead_set
= sparseset_alloc (max_regno
);
1282 unused_set
= sparseset_alloc (max_regno
);
1284 unsigned new_length
= get_max_uid () * 2;
1285 point_freq_vec
.truncate (0);
1286 point_freq_vec
.reserve_exact (new_length
);
1287 lra_point_freq
= point_freq_vec
.address ();
1288 auto_vec
<int, 20> post_order_rev_cfg
;
1289 inverted_post_order_compute (&post_order_rev_cfg
);
1290 lra_assert (post_order_rev_cfg
.length () == (unsigned) n_basic_blocks_for_fn (cfun
));
1291 bb_live_change_p
= false;
1292 for (i
= post_order_rev_cfg
.length () - 1; i
>= 0; --i
)
1294 bb
= BASIC_BLOCK_FOR_FN (cfun
, post_order_rev_cfg
[i
]);
1295 if (bb
== EXIT_BLOCK_PTR_FOR_FN (cfun
) || bb
1296 == ENTRY_BLOCK_PTR_FOR_FN (cfun
))
1298 if (process_bb_lives (bb
, curr_point
, dead_insn_p
))
1299 bb_live_change_p
= true;
1301 if (bb_live_change_p
)
1303 /* We need to clear pseudo live info as some pseudos can
1304 disappear, e.g. pseudos with used equivalences. */
1305 FOR_EACH_BB_FN (bb
, cfun
)
1307 bitmap_clear_range (df_get_live_in (bb
), FIRST_PSEUDO_REGISTER
,
1308 max_regno
- FIRST_PSEUDO_REGISTER
);
1309 bitmap_clear_range (df_get_live_out (bb
), FIRST_PSEUDO_REGISTER
,
1310 max_regno
- FIRST_PSEUDO_REGISTER
);
1312 /* As we did not change CFG since LRA start we can use
1313 DF-infrastructure solver to solve live data flow problem. */
1315 (DF_BACKWARD
, NULL
, live_con_fun_0
, live_con_fun_n
,
1316 live_trans_fun
, &all_blocks
,
1317 df_get_postorder (DF_BACKWARD
), df_get_n_blocks (DF_BACKWARD
));
1318 if (lra_dump_file
!= NULL
)
1320 fprintf (lra_dump_file
,
1321 "Global pseudo live data have been updated:\n");
1323 FOR_EACH_BB_FN (bb
, cfun
)
1325 bb_data_t bb_info
= get_bb_data (bb
);
1326 bitmap bb_livein
= df_get_live_in (bb
);
1327 bitmap bb_liveout
= df_get_live_out (bb
);
1329 fprintf (lra_dump_file
, "\nBB %d:\n", bb
->index
);
1330 lra_dump_bitmap_with_title (" gen:",
1331 &bb_info
->gen_pseudos
, bb
->index
);
1332 lra_dump_bitmap_with_title (" killed:",
1333 &bb_info
->killed_pseudos
, bb
->index
);
1334 lra_dump_bitmap_with_title (" livein:", bb_livein
, bb
->index
);
1335 lra_dump_bitmap_with_title (" liveout:", bb_liveout
, bb
->index
);
1339 lra_live_max_point
= curr_point
;
1340 if (lra_dump_file
!= NULL
)
1341 print_live_ranges (lra_dump_file
);
1343 sparseset_free (unused_set
);
1344 sparseset_free (dead_set
);
1345 sparseset_free (start_dying
);
1346 sparseset_free (start_living
);
1347 sparseset_free (pseudos_live_through_calls
);
1348 sparseset_free (pseudos_live_through_setjumps
);
1349 sparseset_free (pseudos_live
);
1350 compress_live_ranges ();
1351 timevar_pop (TV_LRA_CREATE_LIVE_RANGES
);
1352 return bb_live_change_p
;
1355 /* The main entry function creates live-ranges and other live info
1356 necessary for the assignment sub-pass. It uses
1357 lra_creates_live_ranges_1 -- so read comments for the
1360 lra_create_live_ranges (bool all_p
, bool dead_insn_p
)
1362 if (! lra_create_live_ranges_1 (all_p
, dead_insn_p
))
1364 if (lra_dump_file
!= NULL
)
1365 fprintf (lra_dump_file
, "Live info was changed -- recalculate it\n");
1366 /* Live info was changed on a bb border. It means that some info,
1367 e.g. about conflict regs, calls crossed, and live ranges may be
1368 wrong. We need this info for allocation. So recalculate it
1369 again but without removing dead insns which can change live info
1370 again. Repetitive live range calculations are expensive therefore
1371 we stop here as we already have correct info although some
1372 improvement in rare cases could be possible on this sub-pass if
1373 we do dead insn elimination again (still the improvement may
1375 lra_clear_live_ranges ();
1376 bool res
= lra_create_live_ranges_1 (all_p
, false);
1380 /* Finish all live ranges. */
1382 lra_clear_live_ranges (void)
1386 for (i
= 0; i
< max_reg_num (); i
++)
1387 free_live_range_list (lra_reg_info
[i
].live_ranges
);
1388 point_freq_vec
.release ();
1391 /* Initialize live ranges data once per function. */
1393 lra_live_ranges_init (void)
1395 bitmap_initialize (&temp_bitmap
, ®_obstack
);
1396 initiate_live_solver ();
1399 /* Finish live ranges data once per function. */
1401 lra_live_ranges_finish (void)
1403 finish_live_solver ();
1404 bitmap_clear (&temp_bitmap
);
1405 lra_live_range_pool
.release ();