annotate gcc/lra-lives.c @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Build live ranges for pseudos.
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
2 Copyright (C) 2010-2020 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
3 Contributed by Vladimir Makarov <vmakarov@redhat.com>.
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 This file is part of GCC.
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 GCC is free software; you can redistribute it and/or modify it under
kono
parents:
diff changeset
8 the terms of the GNU General Public License as published by the Free
kono
parents:
diff changeset
9 Software Foundation; either version 3, or (at your option) any later
kono
parents:
diff changeset
10 version.
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
kono
parents:
diff changeset
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
kono
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
kono
parents:
diff changeset
15 for more details.
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
18 along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
19 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21
kono
parents:
diff changeset
22 /* This file contains code to build pseudo live-ranges (analogous
kono
parents:
diff changeset
23 structures used in IRA, so read comments about the live-ranges
kono
parents:
diff changeset
24 there) and other info necessary for other passes to assign
kono
parents:
diff changeset
25 hard-registers to pseudos, coalesce the spilled pseudos, and assign
kono
parents:
diff changeset
26 stack memory slots to spilled pseudos. */
kono
parents:
diff changeset
27
kono
parents:
diff changeset
28 #include "config.h"
kono
parents:
diff changeset
29 #include "system.h"
kono
parents:
diff changeset
30 #include "coretypes.h"
kono
parents:
diff changeset
31 #include "backend.h"
kono
parents:
diff changeset
32 #include "rtl.h"
kono
parents:
diff changeset
33 #include "tree.h"
kono
parents:
diff changeset
34 #include "predict.h"
kono
parents:
diff changeset
35 #include "df.h"
kono
parents:
diff changeset
36 #include "memmodel.h"
kono
parents:
diff changeset
37 #include "tm_p.h"
kono
parents:
diff changeset
38 #include "insn-config.h"
kono
parents:
diff changeset
39 #include "regs.h"
kono
parents:
diff changeset
40 #include "ira.h"
kono
parents:
diff changeset
41 #include "recog.h"
kono
parents:
diff changeset
42 #include "cfganal.h"
kono
parents:
diff changeset
43 #include "sparseset.h"
kono
parents:
diff changeset
44 #include "lra-int.h"
kono
parents:
diff changeset
45 #include "target.h"
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
46 #include "function-abi.h"
111
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 /* Program points are enumerated by numbers from range
kono
parents:
diff changeset
49 0..LRA_LIVE_MAX_POINT-1. There are approximately two times more
kono
parents:
diff changeset
50 program points than insns. Program points are places in the
kono
parents:
diff changeset
51 program where liveness info can be changed. In most general case
kono
parents:
diff changeset
52 (there are more complicated cases too) some program points
kono
parents:
diff changeset
53 correspond to places where input operand dies and other ones
kono
parents:
diff changeset
54 correspond to places where output operands are born. */
kono
parents:
diff changeset
55 int lra_live_max_point;
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 /* Accumulated execution frequency of all references for each hard
kono
parents:
diff changeset
58 register. */
kono
parents:
diff changeset
59 int lra_hard_reg_usage[FIRST_PSEUDO_REGISTER];
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 /* A global flag whose true value says to build live ranges for all
kono
parents:
diff changeset
62 pseudos, otherwise the live ranges only for pseudos got memory is
kono
parents:
diff changeset
63 build. True value means also building copies and setting up hard
kono
parents:
diff changeset
64 register preferences. The complete info is necessary only for the
kono
parents:
diff changeset
65 assignment pass. The complete info is not needed for the
kono
parents:
diff changeset
66 coalescing and spill passes. */
kono
parents:
diff changeset
67 static bool complete_info_p;
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 /* Pseudos live at current point in the RTL scan. */
kono
parents:
diff changeset
70 static sparseset pseudos_live;
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 /* Pseudos probably living through calls and setjumps. As setjump is
kono
parents:
diff changeset
73 a call too, if a bit in PSEUDOS_LIVE_THROUGH_SETJUMPS is set up
kono
parents:
diff changeset
74 then the corresponding bit in PSEUDOS_LIVE_THROUGH_CALLS is set up
kono
parents:
diff changeset
75 too. These data are necessary for cases when only one subreg of a
kono
parents:
diff changeset
76 multi-reg pseudo is set up after a call. So we decide it is
kono
parents:
diff changeset
77 probably live when traversing bb backward. We are sure about
kono
parents:
diff changeset
78 living when we see its usage or definition of the pseudo. */
kono
parents:
diff changeset
79 static sparseset pseudos_live_through_calls;
kono
parents:
diff changeset
80 static sparseset pseudos_live_through_setjumps;
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 /* Set of hard regs (except eliminable ones) currently live. */
kono
parents:
diff changeset
83 static HARD_REG_SET hard_regs_live;
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 /* Set of pseudos and hard registers start living/dying in the current
kono
parents:
diff changeset
86 insn. These sets are used to update REG_DEAD and REG_UNUSED notes
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
87 in the insn. */
111
kono
parents:
diff changeset
88 static sparseset start_living, start_dying;
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 /* Set of pseudos and hard regs dead and unused in the current
kono
parents:
diff changeset
91 insn. */
kono
parents:
diff changeset
92 static sparseset unused_set, dead_set;
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 /* Bitmap used for holding intermediate bitmap operation results. */
kono
parents:
diff changeset
95 static bitmap_head temp_bitmap;
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 /* Pool for pseudo live ranges. */
kono
parents:
diff changeset
98 static object_allocator<lra_live_range> lra_live_range_pool ("live ranges");
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 /* Free live range list LR. */
kono
parents:
diff changeset
101 static void
kono
parents:
diff changeset
102 free_live_range_list (lra_live_range_t lr)
kono
parents:
diff changeset
103 {
kono
parents:
diff changeset
104 lra_live_range_t next;
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 while (lr != NULL)
kono
parents:
diff changeset
107 {
kono
parents:
diff changeset
108 next = lr->next;
kono
parents:
diff changeset
109 lra_live_range_pool.remove (lr);
kono
parents:
diff changeset
110 lr = next;
kono
parents:
diff changeset
111 }
kono
parents:
diff changeset
112 }
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 /* Create and return pseudo live range with given attributes. */
kono
parents:
diff changeset
115 static lra_live_range_t
kono
parents:
diff changeset
116 create_live_range (int regno, int start, int finish, lra_live_range_t next)
kono
parents:
diff changeset
117 {
kono
parents:
diff changeset
118 lra_live_range_t p = lra_live_range_pool.allocate ();
kono
parents:
diff changeset
119 p->regno = regno;
kono
parents:
diff changeset
120 p->start = start;
kono
parents:
diff changeset
121 p->finish = finish;
kono
parents:
diff changeset
122 p->next = next;
kono
parents:
diff changeset
123 return p;
kono
parents:
diff changeset
124 }
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 /* Copy live range R and return the result. */
kono
parents:
diff changeset
127 static lra_live_range_t
kono
parents:
diff changeset
128 copy_live_range (lra_live_range_t r)
kono
parents:
diff changeset
129 {
kono
parents:
diff changeset
130 return new (lra_live_range_pool) lra_live_range (*r);
kono
parents:
diff changeset
131 }
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 /* Copy live range list given by its head R and return the result. */
kono
parents:
diff changeset
134 lra_live_range_t
kono
parents:
diff changeset
135 lra_copy_live_range_list (lra_live_range_t r)
kono
parents:
diff changeset
136 {
kono
parents:
diff changeset
137 lra_live_range_t p, first, *chain;
kono
parents:
diff changeset
138
kono
parents:
diff changeset
139 first = NULL;
kono
parents:
diff changeset
140 for (chain = &first; r != NULL; r = r->next)
kono
parents:
diff changeset
141 {
kono
parents:
diff changeset
142 p = copy_live_range (r);
kono
parents:
diff changeset
143 *chain = p;
kono
parents:
diff changeset
144 chain = &p->next;
kono
parents:
diff changeset
145 }
kono
parents:
diff changeset
146 return first;
kono
parents:
diff changeset
147 }
kono
parents:
diff changeset
148
kono
parents:
diff changeset
149 /* Merge *non-intersected* ranges R1 and R2 and returns the result.
kono
parents:
diff changeset
150 The function maintains the order of ranges and tries to minimize
kono
parents:
diff changeset
151 size of the result range list. Ranges R1 and R2 may not be used
kono
parents:
diff changeset
152 after the call. */
kono
parents:
diff changeset
153 lra_live_range_t
kono
parents:
diff changeset
154 lra_merge_live_ranges (lra_live_range_t r1, lra_live_range_t r2)
kono
parents:
diff changeset
155 {
kono
parents:
diff changeset
156 lra_live_range_t first, last;
kono
parents:
diff changeset
157
kono
parents:
diff changeset
158 if (r1 == NULL)
kono
parents:
diff changeset
159 return r2;
kono
parents:
diff changeset
160 if (r2 == NULL)
kono
parents:
diff changeset
161 return r1;
kono
parents:
diff changeset
162 for (first = last = NULL; r1 != NULL && r2 != NULL;)
kono
parents:
diff changeset
163 {
kono
parents:
diff changeset
164 if (r1->start < r2->start)
kono
parents:
diff changeset
165 std::swap (r1, r2);
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167 if (r1->start == r2->finish + 1)
kono
parents:
diff changeset
168 {
kono
parents:
diff changeset
169 /* Joint ranges: merge r1 and r2 into r1. */
kono
parents:
diff changeset
170 r1->start = r2->start;
kono
parents:
diff changeset
171 lra_live_range_t temp = r2;
kono
parents:
diff changeset
172 r2 = r2->next;
kono
parents:
diff changeset
173 lra_live_range_pool.remove (temp);
kono
parents:
diff changeset
174 }
kono
parents:
diff changeset
175 else
kono
parents:
diff changeset
176 {
kono
parents:
diff changeset
177 gcc_assert (r2->finish + 1 < r1->start);
kono
parents:
diff changeset
178 /* Add r1 to the result. */
kono
parents:
diff changeset
179 if (first == NULL)
kono
parents:
diff changeset
180 first = last = r1;
kono
parents:
diff changeset
181 else
kono
parents:
diff changeset
182 {
kono
parents:
diff changeset
183 last->next = r1;
kono
parents:
diff changeset
184 last = r1;
kono
parents:
diff changeset
185 }
kono
parents:
diff changeset
186 r1 = r1->next;
kono
parents:
diff changeset
187 }
kono
parents:
diff changeset
188 }
kono
parents:
diff changeset
189 if (r1 != NULL)
kono
parents:
diff changeset
190 {
kono
parents:
diff changeset
191 if (first == NULL)
kono
parents:
diff changeset
192 first = r1;
kono
parents:
diff changeset
193 else
kono
parents:
diff changeset
194 last->next = r1;
kono
parents:
diff changeset
195 }
kono
parents:
diff changeset
196 else
kono
parents:
diff changeset
197 {
kono
parents:
diff changeset
198 lra_assert (r2 != NULL);
kono
parents:
diff changeset
199 if (first == NULL)
kono
parents:
diff changeset
200 first = r2;
kono
parents:
diff changeset
201 else
kono
parents:
diff changeset
202 last->next = r2;
kono
parents:
diff changeset
203 }
kono
parents:
diff changeset
204 return first;
kono
parents:
diff changeset
205 }
kono
parents:
diff changeset
206
kono
parents:
diff changeset
207 /* Return TRUE if live ranges R1 and R2 intersect. */
kono
parents:
diff changeset
208 bool
kono
parents:
diff changeset
209 lra_intersected_live_ranges_p (lra_live_range_t r1, lra_live_range_t r2)
kono
parents:
diff changeset
210 {
kono
parents:
diff changeset
211 /* Remember the live ranges are always kept ordered. */
kono
parents:
diff changeset
212 while (r1 != NULL && r2 != NULL)
kono
parents:
diff changeset
213 {
kono
parents:
diff changeset
214 if (r1->start > r2->finish)
kono
parents:
diff changeset
215 r1 = r1->next;
kono
parents:
diff changeset
216 else if (r2->start > r1->finish)
kono
parents:
diff changeset
217 r2 = r2->next;
kono
parents:
diff changeset
218 else
kono
parents:
diff changeset
219 return true;
kono
parents:
diff changeset
220 }
kono
parents:
diff changeset
221 return false;
kono
parents:
diff changeset
222 }
kono
parents:
diff changeset
223
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
224 enum point_type {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
225 DEF_POINT,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
226 USE_POINT
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
227 };
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
228
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
229 /* Return TRUE if set A contains a pseudo register, otherwise, return FALSE. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
230 static bool
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
231 sparseset_contains_pseudos_p (sparseset a)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
232 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
233 int regno;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
234 EXECUTE_IF_SET_IN_SPARSESET (a, regno)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
235 if (!HARD_REGISTER_NUM_P (regno))
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
236 return true;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
237 return false;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
238 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
239
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
240 /* Mark pseudo REGNO as living or dying at program point POINT, depending on
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
241 whether TYPE is a definition or a use. If this is the first reference to
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
242 REGNO that we've encountered, then create a new live range for it. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
243
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
244 static void
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
245 update_pseudo_point (int regno, int point, enum point_type type)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
246 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
247 lra_live_range_t p;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
248
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
249 /* Don't compute points for hard registers. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
250 if (HARD_REGISTER_NUM_P (regno))
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
251 return;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
252
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
253 if (complete_info_p || lra_get_regno_hard_regno (regno) < 0)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
254 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
255 if (type == DEF_POINT)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
256 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
257 if (sparseset_bit_p (pseudos_live, regno))
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
258 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
259 p = lra_reg_info[regno].live_ranges;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
260 lra_assert (p != NULL);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
261 p->finish = point;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
262 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
263 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
264 else /* USE_POINT */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
265 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
266 if (!sparseset_bit_p (pseudos_live, regno)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
267 && ((p = lra_reg_info[regno].live_ranges) == NULL
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
268 || (p->finish != point && p->finish + 1 != point)))
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
269 lra_reg_info[regno].live_ranges
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
270 = create_live_range (regno, point, -1, p);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
271 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
272 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
273 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
274
111
kono
parents:
diff changeset
275 /* The corresponding bitmaps of BB currently being processed. */
kono
parents:
diff changeset
276 static bitmap bb_killed_pseudos, bb_gen_pseudos;
kono
parents:
diff changeset
277
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
278 /* Record hard register REGNO as now being live. It updates
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
279 living hard regs and START_LIVING. */
111
kono
parents:
diff changeset
280 static void
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
281 make_hard_regno_live (int regno)
111
kono
parents:
diff changeset
282 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
283 lra_assert (HARD_REGISTER_NUM_P (regno));
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
284 if (TEST_HARD_REG_BIT (hard_regs_live, regno)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
285 || TEST_HARD_REG_BIT (eliminable_regset, regno))
111
kono
parents:
diff changeset
286 return;
kono
parents:
diff changeset
287 SET_HARD_REG_BIT (hard_regs_live, regno);
kono
parents:
diff changeset
288 sparseset_set_bit (start_living, regno);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
289 if (fixed_regs[regno] || TEST_HARD_REG_BIT (hard_regs_spilled_into, regno))
111
kono
parents:
diff changeset
290 bitmap_set_bit (bb_gen_pseudos, regno);
kono
parents:
diff changeset
291 }
kono
parents:
diff changeset
292
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
293 /* Process the definition of hard register REGNO. This updates
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
294 hard_regs_live, START_DYING and conflict hard regs for living
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
295 pseudos. */
111
kono
parents:
diff changeset
296 static void
kono
parents:
diff changeset
297 make_hard_regno_dead (int regno)
kono
parents:
diff changeset
298 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
299 if (TEST_HARD_REG_BIT (eliminable_regset, regno))
111
kono
parents:
diff changeset
300 return;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
301
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
302 lra_assert (HARD_REGISTER_NUM_P (regno));
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
303 unsigned int i;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
304 EXECUTE_IF_SET_IN_SPARSESET (pseudos_live, i)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
305 SET_HARD_REG_BIT (lra_reg_info[i].conflict_hard_regs, regno);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
306
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
307 if (! TEST_HARD_REG_BIT (hard_regs_live, regno))
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
308 return;
111
kono
parents:
diff changeset
309 CLEAR_HARD_REG_BIT (hard_regs_live, regno);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
310 sparseset_set_bit (start_dying, regno);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
311 if (fixed_regs[regno] || TEST_HARD_REG_BIT (hard_regs_spilled_into, regno))
111
kono
parents:
diff changeset
312 {
kono
parents:
diff changeset
313 bitmap_clear_bit (bb_gen_pseudos, regno);
kono
parents:
diff changeset
314 bitmap_set_bit (bb_killed_pseudos, regno);
kono
parents:
diff changeset
315 }
kono
parents:
diff changeset
316 }
kono
parents:
diff changeset
317
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
318 /* Mark pseudo REGNO as now being live and update START_LIVING. */
111
kono
parents:
diff changeset
319 static void
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
320 mark_pseudo_live (int regno)
111
kono
parents:
diff changeset
321 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
322 lra_assert (!HARD_REGISTER_NUM_P (regno));
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
323 if (sparseset_bit_p (pseudos_live, regno))
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
324 return;
111
kono
parents:
diff changeset
325
kono
parents:
diff changeset
326 sparseset_set_bit (pseudos_live, regno);
kono
parents:
diff changeset
327 sparseset_set_bit (start_living, regno);
kono
parents:
diff changeset
328 }
kono
parents:
diff changeset
329
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
330 /* Mark pseudo REGNO as now being dead and update START_DYING. */
111
kono
parents:
diff changeset
331 static void
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
332 mark_pseudo_dead (int regno)
111
kono
parents:
diff changeset
333 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
334 lra_assert (!HARD_REGISTER_NUM_P (regno));
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
335 lra_reg_info[regno].conflict_hard_regs |= hard_regs_live;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
336 if (!sparseset_bit_p (pseudos_live, regno))
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
337 return;
111
kono
parents:
diff changeset
338
kono
parents:
diff changeset
339 sparseset_clear_bit (pseudos_live, regno);
kono
parents:
diff changeset
340 sparseset_set_bit (start_dying, regno);
kono
parents:
diff changeset
341 }
kono
parents:
diff changeset
342
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
343 /* Mark register REGNO (pseudo or hard register) in MODE as being live
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
344 and update BB_GEN_PSEUDOS. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
345 static void
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
346 mark_regno_live (int regno, machine_mode mode)
111
kono
parents:
diff changeset
347 {
kono
parents:
diff changeset
348 int last;
kono
parents:
diff changeset
349
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
350 if (HARD_REGISTER_NUM_P (regno))
111
kono
parents:
diff changeset
351 {
kono
parents:
diff changeset
352 for (last = end_hard_regno (mode, regno); regno < last; regno++)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
353 make_hard_regno_live (regno);
111
kono
parents:
diff changeset
354 }
kono
parents:
diff changeset
355 else
kono
parents:
diff changeset
356 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
357 mark_pseudo_live (regno);
111
kono
parents:
diff changeset
358 bitmap_set_bit (bb_gen_pseudos, regno);
kono
parents:
diff changeset
359 }
kono
parents:
diff changeset
360 }
kono
parents:
diff changeset
361
kono
parents:
diff changeset
362
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
363 /* Mark register REGNO (pseudo or hard register) in MODE as being dead
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
364 and update BB_GEN_PSEUDOS and BB_KILLED_PSEUDOS. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
365 static void
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
366 mark_regno_dead (int regno, machine_mode mode)
111
kono
parents:
diff changeset
367 {
kono
parents:
diff changeset
368 int last;
kono
parents:
diff changeset
369
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
370 if (HARD_REGISTER_NUM_P (regno))
111
kono
parents:
diff changeset
371 {
kono
parents:
diff changeset
372 for (last = end_hard_regno (mode, regno); regno < last; regno++)
kono
parents:
diff changeset
373 make_hard_regno_dead (regno);
kono
parents:
diff changeset
374 }
kono
parents:
diff changeset
375 else
kono
parents:
diff changeset
376 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
377 mark_pseudo_dead (regno);
111
kono
parents:
diff changeset
378 bitmap_clear_bit (bb_gen_pseudos, regno);
kono
parents:
diff changeset
379 bitmap_set_bit (bb_killed_pseudos, regno);
kono
parents:
diff changeset
380 }
kono
parents:
diff changeset
381 }
kono
parents:
diff changeset
382
kono
parents:
diff changeset
383
kono
parents:
diff changeset
384
kono
parents:
diff changeset
385 /* This page contains code for making global live analysis of pseudos.
kono
parents:
diff changeset
386 The code works only when pseudo live info is changed on a BB
kono
parents:
diff changeset
387 border. That might be a consequence of some global transformations
kono
parents:
diff changeset
388 in LRA, e.g. PIC pseudo reuse or rematerialization. */
kono
parents:
diff changeset
389
kono
parents:
diff changeset
390 /* Structure describing local BB data used for pseudo
kono
parents:
diff changeset
391 live-analysis. */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
392 class bb_data_pseudos
111
kono
parents:
diff changeset
393 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
394 public:
111
kono
parents:
diff changeset
395 /* Basic block about which the below data are. */
kono
parents:
diff changeset
396 basic_block bb;
kono
parents:
diff changeset
397 bitmap_head killed_pseudos; /* pseudos killed in the BB. */
kono
parents:
diff changeset
398 bitmap_head gen_pseudos; /* pseudos generated in the BB. */
kono
parents:
diff changeset
399 };
kono
parents:
diff changeset
400
kono
parents:
diff changeset
401 /* Array for all BB data. Indexed by the corresponding BB index. */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
402 typedef class bb_data_pseudos *bb_data_t;
111
kono
parents:
diff changeset
403
kono
parents:
diff changeset
404 /* All basic block data are referred through the following array. */
kono
parents:
diff changeset
405 static bb_data_t bb_data;
kono
parents:
diff changeset
406
kono
parents:
diff changeset
407 /* Two small functions for access to the bb data. */
kono
parents:
diff changeset
408 static inline bb_data_t
kono
parents:
diff changeset
409 get_bb_data (basic_block bb)
kono
parents:
diff changeset
410 {
kono
parents:
diff changeset
411 return &bb_data[(bb)->index];
kono
parents:
diff changeset
412 }
kono
parents:
diff changeset
413
kono
parents:
diff changeset
414 static inline bb_data_t
kono
parents:
diff changeset
415 get_bb_data_by_index (int index)
kono
parents:
diff changeset
416 {
kono
parents:
diff changeset
417 return &bb_data[index];
kono
parents:
diff changeset
418 }
kono
parents:
diff changeset
419
kono
parents:
diff changeset
420 /* Bitmap with all hard regs. */
kono
parents:
diff changeset
421 static bitmap_head all_hard_regs_bitmap;
kono
parents:
diff changeset
422
kono
parents:
diff changeset
423 /* The transfer function used by the DF equation solver to propagate
kono
parents:
diff changeset
424 live info through block with BB_INDEX according to the following
kono
parents:
diff changeset
425 equation:
kono
parents:
diff changeset
426
kono
parents:
diff changeset
427 bb.livein = (bb.liveout - bb.kill) OR bb.gen
kono
parents:
diff changeset
428 */
kono
parents:
diff changeset
429 static bool
kono
parents:
diff changeset
430 live_trans_fun (int bb_index)
kono
parents:
diff changeset
431 {
kono
parents:
diff changeset
432 basic_block bb = get_bb_data_by_index (bb_index)->bb;
kono
parents:
diff changeset
433 bitmap bb_liveout = df_get_live_out (bb);
kono
parents:
diff changeset
434 bitmap bb_livein = df_get_live_in (bb);
kono
parents:
diff changeset
435 bb_data_t bb_info = get_bb_data (bb);
kono
parents:
diff changeset
436
kono
parents:
diff changeset
437 bitmap_and_compl (&temp_bitmap, bb_liveout, &all_hard_regs_bitmap);
kono
parents:
diff changeset
438 return bitmap_ior_and_compl (bb_livein, &bb_info->gen_pseudos,
kono
parents:
diff changeset
439 &temp_bitmap, &bb_info->killed_pseudos);
kono
parents:
diff changeset
440 }
kono
parents:
diff changeset
441
kono
parents:
diff changeset
442 /* The confluence function used by the DF equation solver to set up
kono
parents:
diff changeset
443 live info for a block BB without predecessor. */
kono
parents:
diff changeset
444 static void
kono
parents:
diff changeset
445 live_con_fun_0 (basic_block bb)
kono
parents:
diff changeset
446 {
kono
parents:
diff changeset
447 bitmap_and_into (df_get_live_out (bb), &all_hard_regs_bitmap);
kono
parents:
diff changeset
448 }
kono
parents:
diff changeset
449
kono
parents:
diff changeset
450 /* The confluence function used by the DF equation solver to propagate
kono
parents:
diff changeset
451 live info from successor to predecessor on edge E according to the
kono
parents:
diff changeset
452 following equation:
kono
parents:
diff changeset
453
kono
parents:
diff changeset
454 bb.liveout = 0 for entry block | OR (livein of successors)
kono
parents:
diff changeset
455 */
kono
parents:
diff changeset
456 static bool
kono
parents:
diff changeset
457 live_con_fun_n (edge e)
kono
parents:
diff changeset
458 {
kono
parents:
diff changeset
459 basic_block bb = e->src;
kono
parents:
diff changeset
460 basic_block dest = e->dest;
kono
parents:
diff changeset
461 bitmap bb_liveout = df_get_live_out (bb);
kono
parents:
diff changeset
462 bitmap dest_livein = df_get_live_in (dest);
kono
parents:
diff changeset
463
kono
parents:
diff changeset
464 return bitmap_ior_and_compl_into (bb_liveout,
kono
parents:
diff changeset
465 dest_livein, &all_hard_regs_bitmap);
kono
parents:
diff changeset
466 }
kono
parents:
diff changeset
467
kono
parents:
diff changeset
468 /* Indexes of all function blocks. */
kono
parents:
diff changeset
469 static bitmap_head all_blocks;
kono
parents:
diff changeset
470
kono
parents:
diff changeset
471 /* Allocate and initialize data needed for global pseudo live
kono
parents:
diff changeset
472 analysis. */
kono
parents:
diff changeset
473 static void
kono
parents:
diff changeset
474 initiate_live_solver (void)
kono
parents:
diff changeset
475 {
kono
parents:
diff changeset
476 bitmap_initialize (&all_hard_regs_bitmap, &reg_obstack);
kono
parents:
diff changeset
477 bitmap_set_range (&all_hard_regs_bitmap, 0, FIRST_PSEUDO_REGISTER);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
478 bb_data = XNEWVEC (class bb_data_pseudos, last_basic_block_for_fn (cfun));
111
kono
parents:
diff changeset
479 bitmap_initialize (&all_blocks, &reg_obstack);
kono
parents:
diff changeset
480
kono
parents:
diff changeset
481 basic_block bb;
kono
parents:
diff changeset
482 FOR_ALL_BB_FN (bb, cfun)
kono
parents:
diff changeset
483 {
kono
parents:
diff changeset
484 bb_data_t bb_info = get_bb_data (bb);
kono
parents:
diff changeset
485 bb_info->bb = bb;
kono
parents:
diff changeset
486 bitmap_initialize (&bb_info->killed_pseudos, &reg_obstack);
kono
parents:
diff changeset
487 bitmap_initialize (&bb_info->gen_pseudos, &reg_obstack);
kono
parents:
diff changeset
488 bitmap_set_bit (&all_blocks, bb->index);
kono
parents:
diff changeset
489 }
kono
parents:
diff changeset
490 }
kono
parents:
diff changeset
491
kono
parents:
diff changeset
492 /* Free all data needed for global pseudo live analysis. */
kono
parents:
diff changeset
493 static void
kono
parents:
diff changeset
494 finish_live_solver (void)
kono
parents:
diff changeset
495 {
kono
parents:
diff changeset
496 basic_block bb;
kono
parents:
diff changeset
497
kono
parents:
diff changeset
498 bitmap_clear (&all_blocks);
kono
parents:
diff changeset
499 FOR_ALL_BB_FN (bb, cfun)
kono
parents:
diff changeset
500 {
kono
parents:
diff changeset
501 bb_data_t bb_info = get_bb_data (bb);
kono
parents:
diff changeset
502 bitmap_clear (&bb_info->killed_pseudos);
kono
parents:
diff changeset
503 bitmap_clear (&bb_info->gen_pseudos);
kono
parents:
diff changeset
504 }
kono
parents:
diff changeset
505 free (bb_data);
kono
parents:
diff changeset
506 bitmap_clear (&all_hard_regs_bitmap);
kono
parents:
diff changeset
507 }
kono
parents:
diff changeset
508
kono
parents:
diff changeset
509
kono
parents:
diff changeset
510
kono
parents:
diff changeset
511 /* Insn currently scanned. */
kono
parents:
diff changeset
512 static rtx_insn *curr_insn;
kono
parents:
diff changeset
513 /* The insn data. */
kono
parents:
diff changeset
514 static lra_insn_recog_data_t curr_id;
kono
parents:
diff changeset
515 /* The insn static data. */
kono
parents:
diff changeset
516 static struct lra_static_insn_data *curr_static_id;
kono
parents:
diff changeset
517
kono
parents:
diff changeset
518 /* Vec containing execution frequencies of program points. */
kono
parents:
diff changeset
519 static vec<int> point_freq_vec;
kono
parents:
diff changeset
520
kono
parents:
diff changeset
521 /* The start of the above vector elements. */
kono
parents:
diff changeset
522 int *lra_point_freq;
kono
parents:
diff changeset
523
kono
parents:
diff changeset
524 /* Increment the current program point POINT to the next point which has
kono
parents:
diff changeset
525 execution frequency FREQ. */
kono
parents:
diff changeset
526 static void
kono
parents:
diff changeset
527 next_program_point (int &point, int freq)
kono
parents:
diff changeset
528 {
kono
parents:
diff changeset
529 point_freq_vec.safe_push (freq);
kono
parents:
diff changeset
530 lra_point_freq = point_freq_vec.address ();
kono
parents:
diff changeset
531 point++;
kono
parents:
diff changeset
532 }
kono
parents:
diff changeset
533
kono
parents:
diff changeset
534 /* Update the preference of HARD_REGNO for pseudo REGNO by PROFIT. */
kono
parents:
diff changeset
535 void
kono
parents:
diff changeset
536 lra_setup_reload_pseudo_preferenced_hard_reg (int regno,
kono
parents:
diff changeset
537 int hard_regno, int profit)
kono
parents:
diff changeset
538 {
kono
parents:
diff changeset
539 lra_assert (regno >= lra_constraint_new_regno_start);
kono
parents:
diff changeset
540 if (lra_reg_info[regno].preferred_hard_regno1 == hard_regno)
kono
parents:
diff changeset
541 lra_reg_info[regno].preferred_hard_regno_profit1 += profit;
kono
parents:
diff changeset
542 else if (lra_reg_info[regno].preferred_hard_regno2 == hard_regno)
kono
parents:
diff changeset
543 lra_reg_info[regno].preferred_hard_regno_profit2 += profit;
kono
parents:
diff changeset
544 else if (lra_reg_info[regno].preferred_hard_regno1 < 0)
kono
parents:
diff changeset
545 {
kono
parents:
diff changeset
546 lra_reg_info[regno].preferred_hard_regno1 = hard_regno;
kono
parents:
diff changeset
547 lra_reg_info[regno].preferred_hard_regno_profit1 = profit;
kono
parents:
diff changeset
548 }
kono
parents:
diff changeset
549 else if (lra_reg_info[regno].preferred_hard_regno2 < 0
kono
parents:
diff changeset
550 || profit > lra_reg_info[regno].preferred_hard_regno_profit2)
kono
parents:
diff changeset
551 {
kono
parents:
diff changeset
552 lra_reg_info[regno].preferred_hard_regno2 = hard_regno;
kono
parents:
diff changeset
553 lra_reg_info[regno].preferred_hard_regno_profit2 = profit;
kono
parents:
diff changeset
554 }
kono
parents:
diff changeset
555 else
kono
parents:
diff changeset
556 return;
kono
parents:
diff changeset
557 /* Keep the 1st hard regno as more profitable. */
kono
parents:
diff changeset
558 if (lra_reg_info[regno].preferred_hard_regno1 >= 0
kono
parents:
diff changeset
559 && lra_reg_info[regno].preferred_hard_regno2 >= 0
kono
parents:
diff changeset
560 && (lra_reg_info[regno].preferred_hard_regno_profit2
kono
parents:
diff changeset
561 > lra_reg_info[regno].preferred_hard_regno_profit1))
kono
parents:
diff changeset
562 {
kono
parents:
diff changeset
563 std::swap (lra_reg_info[regno].preferred_hard_regno1,
kono
parents:
diff changeset
564 lra_reg_info[regno].preferred_hard_regno2);
kono
parents:
diff changeset
565 std::swap (lra_reg_info[regno].preferred_hard_regno_profit1,
kono
parents:
diff changeset
566 lra_reg_info[regno].preferred_hard_regno_profit2);
kono
parents:
diff changeset
567 }
kono
parents:
diff changeset
568 if (lra_dump_file != NULL)
kono
parents:
diff changeset
569 {
kono
parents:
diff changeset
570 if ((hard_regno = lra_reg_info[regno].preferred_hard_regno1) >= 0)
kono
parents:
diff changeset
571 fprintf (lra_dump_file,
kono
parents:
diff changeset
572 " Hard reg %d is preferable by r%d with profit %d\n",
kono
parents:
diff changeset
573 hard_regno, regno,
kono
parents:
diff changeset
574 lra_reg_info[regno].preferred_hard_regno_profit1);
kono
parents:
diff changeset
575 if ((hard_regno = lra_reg_info[regno].preferred_hard_regno2) >= 0)
kono
parents:
diff changeset
576 fprintf (lra_dump_file,
kono
parents:
diff changeset
577 " Hard reg %d is preferable by r%d with profit %d\n",
kono
parents:
diff changeset
578 hard_regno, regno,
kono
parents:
diff changeset
579 lra_reg_info[regno].preferred_hard_regno_profit2);
kono
parents:
diff changeset
580 }
kono
parents:
diff changeset
581 }
kono
parents:
diff changeset
582
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
583 /* Check whether REGNO lives through calls and setjmps and clear
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
584 the corresponding bits in PSEUDOS_LIVE_THROUGH_CALLS and
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
585 PSEUDOS_LIVE_THROUGH_SETJUMPS. All calls in the region described
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
586 by PSEUDOS_LIVE_THROUGH_CALLS have the given ABI. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
587
111
kono
parents:
diff changeset
588 static inline void
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
589 check_pseudos_live_through_calls (int regno, const function_abi &abi)
111
kono
parents:
diff changeset
590 {
kono
parents:
diff changeset
591 if (! sparseset_bit_p (pseudos_live_through_calls, regno))
kono
parents:
diff changeset
592 return;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
593
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
594 machine_mode mode = PSEUDO_REGNO_MODE (regno);
111
kono
parents:
diff changeset
595
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
596 sparseset_clear_bit (pseudos_live_through_calls, regno);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
597 lra_reg_info[regno].conflict_hard_regs |= abi.mode_clobbers (mode);
111
kono
parents:
diff changeset
598 if (! sparseset_bit_p (pseudos_live_through_setjumps, regno))
kono
parents:
diff changeset
599 return;
kono
parents:
diff changeset
600 sparseset_clear_bit (pseudos_live_through_setjumps, regno);
kono
parents:
diff changeset
601 /* Don't allocate pseudos that cross setjmps or any call, if this
kono
parents:
diff changeset
602 function receives a nonlocal goto. */
kono
parents:
diff changeset
603 SET_HARD_REG_SET (lra_reg_info[regno].conflict_hard_regs);
kono
parents:
diff changeset
604 }
kono
parents:
diff changeset
605
kono
parents:
diff changeset
606 /* Return true if insn REG is an early clobber operand in alternative
kono
parents:
diff changeset
607 NALT. Negative NALT means that we don't know the current insn
kono
parents:
diff changeset
608 alternative. So assume the worst. */
kono
parents:
diff changeset
609 static inline bool
kono
parents:
diff changeset
610 reg_early_clobber_p (const struct lra_insn_reg *reg, int n_alt)
kono
parents:
diff changeset
611 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
612 return (n_alt == LRA_UNKNOWN_ALT
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
613 ? reg->early_clobber_alts != 0
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
614 : (n_alt != LRA_NON_CLOBBERED_ALT
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
615 && TEST_BIT (reg->early_clobber_alts, n_alt)));
111
kono
parents:
diff changeset
616 }
kono
parents:
diff changeset
617
kono
parents:
diff changeset
618 /* Process insns of the basic block BB to update pseudo live ranges,
kono
parents:
diff changeset
619 pseudo hard register conflicts, and insn notes. We do it on
kono
parents:
diff changeset
620 backward scan of BB insns. CURR_POINT is the program point where
kono
parents:
diff changeset
621 BB ends. The function updates this counter and returns in
kono
parents:
diff changeset
622 CURR_POINT the program point where BB starts. The function also
kono
parents:
diff changeset
623 does local live info updates and can delete the dead insns if
kono
parents:
diff changeset
624 DEAD_INSN_P. It returns true if pseudo live info was
kono
parents:
diff changeset
625 changed at the BB start. */
kono
parents:
diff changeset
626 static bool
kono
parents:
diff changeset
627 process_bb_lives (basic_block bb, int &curr_point, bool dead_insn_p)
kono
parents:
diff changeset
628 {
kono
parents:
diff changeset
629 int i, regno, freq;
kono
parents:
diff changeset
630 unsigned int j;
kono
parents:
diff changeset
631 bitmap_iterator bi;
kono
parents:
diff changeset
632 bitmap reg_live_out;
kono
parents:
diff changeset
633 unsigned int px;
kono
parents:
diff changeset
634 rtx_insn *next;
kono
parents:
diff changeset
635 rtx link, *link_loc;
kono
parents:
diff changeset
636 bool need_curr_point_incr;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
637 /* Only has a meaningful value once we've seen a call. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
638 function_abi last_call_abi = default_function_abi;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
639
111
kono
parents:
diff changeset
640 reg_live_out = df_get_live_out (bb);
kono
parents:
diff changeset
641 sparseset_clear (pseudos_live);
kono
parents:
diff changeset
642 sparseset_clear (pseudos_live_through_calls);
kono
parents:
diff changeset
643 sparseset_clear (pseudos_live_through_setjumps);
kono
parents:
diff changeset
644 REG_SET_TO_HARD_REG_SET (hard_regs_live, reg_live_out);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
645 hard_regs_live &= ~eliminable_regset;
111
kono
parents:
diff changeset
646 EXECUTE_IF_SET_IN_BITMAP (reg_live_out, FIRST_PSEUDO_REGISTER, j, bi)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
647 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
648 update_pseudo_point (j, curr_point, USE_POINT);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
649 mark_pseudo_live (j);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
650 }
111
kono
parents:
diff changeset
651
kono
parents:
diff changeset
652 bb_gen_pseudos = &get_bb_data (bb)->gen_pseudos;
kono
parents:
diff changeset
653 bb_killed_pseudos = &get_bb_data (bb)->killed_pseudos;
kono
parents:
diff changeset
654 bitmap_clear (bb_gen_pseudos);
kono
parents:
diff changeset
655 bitmap_clear (bb_killed_pseudos);
kono
parents:
diff changeset
656 freq = REG_FREQ_FROM_BB (bb);
kono
parents:
diff changeset
657
kono
parents:
diff changeset
658 if (lra_dump_file != NULL)
kono
parents:
diff changeset
659 fprintf (lra_dump_file, " BB %d\n", bb->index);
kono
parents:
diff changeset
660
kono
parents:
diff changeset
661 /* Scan the code of this basic block, noting which pseudos and hard
kono
parents:
diff changeset
662 regs are born or die.
kono
parents:
diff changeset
663
kono
parents:
diff changeset
664 Note that this loop treats uninitialized values as live until the
kono
parents:
diff changeset
665 beginning of the block. For example, if an instruction uses
kono
parents:
diff changeset
666 (reg:DI foo), and only (subreg:SI (reg:DI foo) 0) is ever set,
kono
parents:
diff changeset
667 FOO will remain live until the beginning of the block. Likewise
kono
parents:
diff changeset
668 if FOO is not set at all. This is unnecessarily pessimistic, but
kono
parents:
diff changeset
669 it probably doesn't matter much in practice. */
kono
parents:
diff changeset
670 FOR_BB_INSNS_REVERSE_SAFE (bb, curr_insn, next)
kono
parents:
diff changeset
671 {
kono
parents:
diff changeset
672 bool call_p;
kono
parents:
diff changeset
673 int n_alt, dst_regno, src_regno;
kono
parents:
diff changeset
674 rtx set;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
675 struct lra_insn_reg *reg;
111
kono
parents:
diff changeset
676
kono
parents:
diff changeset
677 if (!NONDEBUG_INSN_P (curr_insn))
kono
parents:
diff changeset
678 continue;
kono
parents:
diff changeset
679
kono
parents:
diff changeset
680 curr_id = lra_get_insn_recog_data (curr_insn);
kono
parents:
diff changeset
681 curr_static_id = curr_id->insn_static_data;
kono
parents:
diff changeset
682 n_alt = curr_id->used_insn_alternative;
kono
parents:
diff changeset
683 if (lra_dump_file != NULL)
kono
parents:
diff changeset
684 fprintf (lra_dump_file, " Insn %u: point = %d, n_alt = %d\n",
kono
parents:
diff changeset
685 INSN_UID (curr_insn), curr_point, n_alt);
kono
parents:
diff changeset
686
kono
parents:
diff changeset
687 set = single_set (curr_insn);
kono
parents:
diff changeset
688
kono
parents:
diff changeset
689 if (dead_insn_p && set != NULL_RTX
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
690 && REG_P (SET_DEST (set)) && !HARD_REGISTER_P (SET_DEST (set))
111
kono
parents:
diff changeset
691 && find_reg_note (curr_insn, REG_EH_REGION, NULL_RTX) == NULL_RTX
kono
parents:
diff changeset
692 && ! may_trap_p (PATTERN (curr_insn))
kono
parents:
diff changeset
693 /* Don't do premature remove of pic offset pseudo as we can
kono
parents:
diff changeset
694 start to use it after some reload generation. */
kono
parents:
diff changeset
695 && (pic_offset_table_rtx == NULL_RTX
kono
parents:
diff changeset
696 || pic_offset_table_rtx != SET_DEST (set)))
kono
parents:
diff changeset
697 {
kono
parents:
diff changeset
698 bool remove_p = true;
kono
parents:
diff changeset
699
kono
parents:
diff changeset
700 for (reg = curr_id->regs; reg != NULL; reg = reg->next)
kono
parents:
diff changeset
701 if (reg->type != OP_IN && sparseset_bit_p (pseudos_live, reg->regno))
kono
parents:
diff changeset
702 {
kono
parents:
diff changeset
703 remove_p = false;
kono
parents:
diff changeset
704 break;
kono
parents:
diff changeset
705 }
kono
parents:
diff changeset
706 for (reg = curr_static_id->hard_regs; reg != NULL; reg = reg->next)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
707 if (reg->type != OP_IN)
111
kono
parents:
diff changeset
708 {
kono
parents:
diff changeset
709 remove_p = false;
kono
parents:
diff changeset
710 break;
kono
parents:
diff changeset
711 }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
712
111
kono
parents:
diff changeset
713 if (remove_p && ! volatile_refs_p (PATTERN (curr_insn)))
kono
parents:
diff changeset
714 {
kono
parents:
diff changeset
715 dst_regno = REGNO (SET_DEST (set));
kono
parents:
diff changeset
716 if (lra_dump_file != NULL)
kono
parents:
diff changeset
717 fprintf (lra_dump_file, " Deleting dead insn %u\n",
kono
parents:
diff changeset
718 INSN_UID (curr_insn));
kono
parents:
diff changeset
719 lra_set_insn_deleted (curr_insn);
kono
parents:
diff changeset
720 if (lra_reg_info[dst_regno].nrefs == 0)
kono
parents:
diff changeset
721 {
kono
parents:
diff changeset
722 /* There might be some debug insns with the pseudo. */
kono
parents:
diff changeset
723 unsigned int uid;
kono
parents:
diff changeset
724 rtx_insn *insn;
kono
parents:
diff changeset
725
kono
parents:
diff changeset
726 bitmap_copy (&temp_bitmap, &lra_reg_info[dst_regno].insn_bitmap);
kono
parents:
diff changeset
727 EXECUTE_IF_SET_IN_BITMAP (&temp_bitmap, 0, uid, bi)
kono
parents:
diff changeset
728 {
kono
parents:
diff changeset
729 insn = lra_insn_recog_data[uid]->insn;
kono
parents:
diff changeset
730 lra_substitute_pseudo_within_insn (insn, dst_regno,
kono
parents:
diff changeset
731 SET_SRC (set), true);
kono
parents:
diff changeset
732 lra_update_insn_regno_info (insn);
kono
parents:
diff changeset
733 }
kono
parents:
diff changeset
734 }
kono
parents:
diff changeset
735 continue;
kono
parents:
diff changeset
736 }
kono
parents:
diff changeset
737 }
kono
parents:
diff changeset
738
kono
parents:
diff changeset
739 /* Update max ref width and hard reg usage. */
kono
parents:
diff changeset
740 for (reg = curr_id->regs; reg != NULL; reg = reg->next)
kono
parents:
diff changeset
741 {
kono
parents:
diff changeset
742 int i, regno = reg->regno;
kono
parents:
diff changeset
743
kono
parents:
diff changeset
744 if (partial_subreg_p (lra_reg_info[regno].biggest_mode,
kono
parents:
diff changeset
745 reg->biggest_mode))
kono
parents:
diff changeset
746 lra_reg_info[regno].biggest_mode = reg->biggest_mode;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
747 if (HARD_REGISTER_NUM_P (regno))
111
kono
parents:
diff changeset
748 {
kono
parents:
diff changeset
749 lra_hard_reg_usage[regno] += freq;
kono
parents:
diff changeset
750 /* A hard register explicitly can be used in small mode,
kono
parents:
diff changeset
751 but implicitly it can be used in natural mode as a
kono
parents:
diff changeset
752 part of multi-register group. Process this case
kono
parents:
diff changeset
753 here. */
kono
parents:
diff changeset
754 for (i = 1; i < hard_regno_nregs (regno, reg->biggest_mode); i++)
kono
parents:
diff changeset
755 if (partial_subreg_p (lra_reg_info[regno + i].biggest_mode,
kono
parents:
diff changeset
756 GET_MODE (regno_reg_rtx[regno + i])))
kono
parents:
diff changeset
757 lra_reg_info[regno + i].biggest_mode
kono
parents:
diff changeset
758 = GET_MODE (regno_reg_rtx[regno + i]);
kono
parents:
diff changeset
759 }
kono
parents:
diff changeset
760 }
kono
parents:
diff changeset
761
kono
parents:
diff changeset
762 call_p = CALL_P (curr_insn);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
763
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
764 /* If we have a simple register copy and the source reg is live after
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
765 this instruction, then remove the source reg from the live set so
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
766 that it will not conflict with the destination reg. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
767 rtx ignore_reg = non_conflicting_reg_copy_p (curr_insn);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
768 if (ignore_reg != NULL_RTX)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
769 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
770 int ignore_regno = REGNO (ignore_reg);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
771 if (HARD_REGISTER_NUM_P (ignore_regno)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
772 && TEST_HARD_REG_BIT (hard_regs_live, ignore_regno))
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
773 CLEAR_HARD_REG_BIT (hard_regs_live, ignore_regno);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
774 else if (!HARD_REGISTER_NUM_P (ignore_regno)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
775 && sparseset_bit_p (pseudos_live, ignore_regno))
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
776 sparseset_clear_bit (pseudos_live, ignore_regno);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
777 else
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
778 /* We don't need any special handling of the source reg if
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
779 it is dead after this instruction. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
780 ignore_reg = NULL_RTX;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
781 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
782
111
kono
parents:
diff changeset
783 src_regno = (set != NULL_RTX && REG_P (SET_SRC (set))
kono
parents:
diff changeset
784 ? REGNO (SET_SRC (set)) : -1);
kono
parents:
diff changeset
785 dst_regno = (set != NULL_RTX && REG_P (SET_DEST (set))
kono
parents:
diff changeset
786 ? REGNO (SET_DEST (set)) : -1);
kono
parents:
diff changeset
787 if (complete_info_p
kono
parents:
diff changeset
788 && src_regno >= 0 && dst_regno >= 0
kono
parents:
diff changeset
789 /* Check that source regno does not conflict with
kono
parents:
diff changeset
790 destination regno to exclude most impossible
kono
parents:
diff changeset
791 preferences. */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
792 && (((!HARD_REGISTER_NUM_P (src_regno)
111
kono
parents:
diff changeset
793 && (! sparseset_bit_p (pseudos_live, src_regno)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
794 || (!HARD_REGISTER_NUM_P (dst_regno)
111
kono
parents:
diff changeset
795 && lra_reg_val_equal_p (src_regno,
kono
parents:
diff changeset
796 lra_reg_info[dst_regno].val,
kono
parents:
diff changeset
797 lra_reg_info[dst_regno].offset))))
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
798 || (HARD_REGISTER_NUM_P (src_regno)
111
kono
parents:
diff changeset
799 && ! TEST_HARD_REG_BIT (hard_regs_live, src_regno)))
kono
parents:
diff changeset
800 /* It might be 'inheritance pseudo <- reload pseudo'. */
kono
parents:
diff changeset
801 || (src_regno >= lra_constraint_new_regno_start
kono
parents:
diff changeset
802 && dst_regno >= lra_constraint_new_regno_start
kono
parents:
diff changeset
803 /* Remember to skip special cases where src/dest regnos are
kono
parents:
diff changeset
804 the same, e.g. insn SET pattern has matching constraints
kono
parents:
diff changeset
805 like =r,0. */
kono
parents:
diff changeset
806 && src_regno != dst_regno)))
kono
parents:
diff changeset
807 {
kono
parents:
diff changeset
808 int hard_regno = -1, regno = -1;
kono
parents:
diff changeset
809
kono
parents:
diff changeset
810 if (dst_regno >= lra_constraint_new_regno_start
kono
parents:
diff changeset
811 && src_regno >= lra_constraint_new_regno_start)
kono
parents:
diff changeset
812 {
kono
parents:
diff changeset
813 /* It might be still an original (non-reload) insn with
kono
parents:
diff changeset
814 one unused output and a constraint requiring to use
kono
parents:
diff changeset
815 the same reg for input/output operands. In this case
kono
parents:
diff changeset
816 dst_regno and src_regno have the same value, we don't
kono
parents:
diff changeset
817 need a misleading copy for this case. */
kono
parents:
diff changeset
818 if (dst_regno != src_regno)
kono
parents:
diff changeset
819 lra_create_copy (dst_regno, src_regno, freq);
kono
parents:
diff changeset
820 }
kono
parents:
diff changeset
821 else if (dst_regno >= lra_constraint_new_regno_start)
kono
parents:
diff changeset
822 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
823 if (!HARD_REGISTER_NUM_P (hard_regno = src_regno))
111
kono
parents:
diff changeset
824 hard_regno = reg_renumber[src_regno];
kono
parents:
diff changeset
825 regno = dst_regno;
kono
parents:
diff changeset
826 }
kono
parents:
diff changeset
827 else if (src_regno >= lra_constraint_new_regno_start)
kono
parents:
diff changeset
828 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
829 if (!HARD_REGISTER_NUM_P (hard_regno = dst_regno))
111
kono
parents:
diff changeset
830 hard_regno = reg_renumber[dst_regno];
kono
parents:
diff changeset
831 regno = src_regno;
kono
parents:
diff changeset
832 }
kono
parents:
diff changeset
833 if (regno >= 0 && hard_regno >= 0)
kono
parents:
diff changeset
834 lra_setup_reload_pseudo_preferenced_hard_reg
kono
parents:
diff changeset
835 (regno, hard_regno, freq);
kono
parents:
diff changeset
836 }
kono
parents:
diff changeset
837
kono
parents:
diff changeset
838 sparseset_clear (start_living);
kono
parents:
diff changeset
839
kono
parents:
diff changeset
840 /* Mark each defined value as live. We need to do this for
kono
parents:
diff changeset
841 unused values because they still conflict with quantities
kono
parents:
diff changeset
842 that are live at the time of the definition. */
kono
parents:
diff changeset
843 for (reg = curr_id->regs; reg != NULL; reg = reg->next)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
844 if (reg->type != OP_IN)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
845 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
846 update_pseudo_point (reg->regno, curr_point, USE_POINT);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
847 mark_regno_live (reg->regno, reg->biggest_mode);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
848 /* ??? Should be a no-op for unused registers. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
849 check_pseudos_live_through_calls (reg->regno, last_call_abi);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
850 }
111
kono
parents:
diff changeset
851
kono
parents:
diff changeset
852 for (reg = curr_static_id->hard_regs; reg != NULL; reg = reg->next)
kono
parents:
diff changeset
853 if (reg->type != OP_IN)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
854 make_hard_regno_live (reg->regno);
111
kono
parents:
diff changeset
855
kono
parents:
diff changeset
856 if (curr_id->arg_hard_regs != NULL)
kono
parents:
diff changeset
857 for (i = 0; (regno = curr_id->arg_hard_regs[i]) >= 0; i++)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
858 if (!HARD_REGISTER_NUM_P (regno))
111
kono
parents:
diff changeset
859 /* It is a clobber. */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
860 make_hard_regno_live (regno - FIRST_PSEUDO_REGISTER);
111
kono
parents:
diff changeset
861
kono
parents:
diff changeset
862 sparseset_copy (unused_set, start_living);
kono
parents:
diff changeset
863
kono
parents:
diff changeset
864 sparseset_clear (start_dying);
kono
parents:
diff changeset
865
kono
parents:
diff changeset
866 /* See which defined values die here. */
kono
parents:
diff changeset
867 for (reg = curr_id->regs; reg != NULL; reg = reg->next)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
868 if (reg->type != OP_IN
111
kono
parents:
diff changeset
869 && ! reg_early_clobber_p (reg, n_alt) && ! reg->subreg_p)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
870 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
871 if (reg->type == OP_OUT)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
872 update_pseudo_point (reg->regno, curr_point, DEF_POINT);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
873 mark_regno_dead (reg->regno, reg->biggest_mode);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
874 }
111
kono
parents:
diff changeset
875
kono
parents:
diff changeset
876 for (reg = curr_static_id->hard_regs; reg != NULL; reg = reg->next)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
877 if (reg->type != OP_IN
111
kono
parents:
diff changeset
878 && ! reg_early_clobber_p (reg, n_alt) && ! reg->subreg_p)
kono
parents:
diff changeset
879 make_hard_regno_dead (reg->regno);
kono
parents:
diff changeset
880
kono
parents:
diff changeset
881 if (curr_id->arg_hard_regs != NULL)
kono
parents:
diff changeset
882 for (i = 0; (regno = curr_id->arg_hard_regs[i]) >= 0; i++)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
883 if (!HARD_REGISTER_NUM_P (regno))
111
kono
parents:
diff changeset
884 /* It is a clobber. */
kono
parents:
diff changeset
885 make_hard_regno_dead (regno - FIRST_PSEUDO_REGISTER);
kono
parents:
diff changeset
886
kono
parents:
diff changeset
887 if (call_p)
kono
parents:
diff changeset
888 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
889 function_abi call_abi = insn_callee_abi (curr_insn);
111
kono
parents:
diff changeset
890
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
891 if (last_call_abi != call_abi)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
892 EXECUTE_IF_SET_IN_SPARSESET (pseudos_live, j)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
893 check_pseudos_live_through_calls (j, last_call_abi);
111
kono
parents:
diff changeset
894
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
895 last_call_abi = call_abi;
111
kono
parents:
diff changeset
896
kono
parents:
diff changeset
897 sparseset_ior (pseudos_live_through_calls,
kono
parents:
diff changeset
898 pseudos_live_through_calls, pseudos_live);
kono
parents:
diff changeset
899 if (cfun->has_nonlocal_label
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
900 || (!targetm.setjmp_preserves_nonvolatile_regs_p ()
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
901 && (find_reg_note (curr_insn, REG_SETJMP, NULL_RTX)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
902 != NULL_RTX)))
111
kono
parents:
diff changeset
903 sparseset_ior (pseudos_live_through_setjumps,
kono
parents:
diff changeset
904 pseudos_live_through_setjumps, pseudos_live);
kono
parents:
diff changeset
905 }
kono
parents:
diff changeset
906
kono
parents:
diff changeset
907 /* Increment the current program point if we must. */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
908 if (sparseset_contains_pseudos_p (unused_set)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
909 || sparseset_contains_pseudos_p (start_dying))
111
kono
parents:
diff changeset
910 next_program_point (curr_point, freq);
kono
parents:
diff changeset
911
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
912 /* If we removed the source reg from a simple register copy from the
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
913 live set above, then add it back now so we don't accidentally add
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
914 it to the start_living set below. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
915 if (ignore_reg != NULL_RTX)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
916 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
917 int ignore_regno = REGNO (ignore_reg);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
918 if (HARD_REGISTER_NUM_P (ignore_regno))
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
919 SET_HARD_REG_BIT (hard_regs_live, ignore_regno);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
920 else
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
921 sparseset_set_bit (pseudos_live, ignore_regno);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
922 }
111
kono
parents:
diff changeset
923
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
924 sparseset_clear (start_living);
111
kono
parents:
diff changeset
925
kono
parents:
diff changeset
926 /* Mark each used value as live. */
kono
parents:
diff changeset
927 for (reg = curr_id->regs; reg != NULL; reg = reg->next)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
928 if (reg->type != OP_OUT)
111
kono
parents:
diff changeset
929 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
930 if (reg->type == OP_IN)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
931 update_pseudo_point (reg->regno, curr_point, USE_POINT);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
932 mark_regno_live (reg->regno, reg->biggest_mode);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
933 check_pseudos_live_through_calls (reg->regno, last_call_abi);
111
kono
parents:
diff changeset
934 }
kono
parents:
diff changeset
935
kono
parents:
diff changeset
936 for (reg = curr_static_id->hard_regs; reg != NULL; reg = reg->next)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
937 if (reg->type != OP_OUT)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
938 make_hard_regno_live (reg->regno);
111
kono
parents:
diff changeset
939
kono
parents:
diff changeset
940 if (curr_id->arg_hard_regs != NULL)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
941 /* Make argument hard registers live. */
111
kono
parents:
diff changeset
942 for (i = 0; (regno = curr_id->arg_hard_regs[i]) >= 0; i++)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
943 if (HARD_REGISTER_NUM_P (regno))
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
944 make_hard_regno_live (regno);
111
kono
parents:
diff changeset
945
kono
parents:
diff changeset
946 sparseset_and_compl (dead_set, start_living, start_dying);
kono
parents:
diff changeset
947
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
948 sparseset_clear (start_dying);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
949
111
kono
parents:
diff changeset
950 /* Mark early clobber outputs dead. */
kono
parents:
diff changeset
951 for (reg = curr_id->regs; reg != NULL; reg = reg->next)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
952 if (reg->type != OP_IN
111
kono
parents:
diff changeset
953 && reg_early_clobber_p (reg, n_alt) && ! reg->subreg_p)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
954 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
955 if (reg->type == OP_OUT)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
956 update_pseudo_point (reg->regno, curr_point, DEF_POINT);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
957 mark_regno_dead (reg->regno, reg->biggest_mode);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
958
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
959 /* We're done processing inputs, so make sure early clobber
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
960 operands that are both inputs and outputs are still live. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
961 if (reg->type == OP_INOUT)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
962 mark_regno_live (reg->regno, reg->biggest_mode);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
963 }
111
kono
parents:
diff changeset
964
kono
parents:
diff changeset
965 for (reg = curr_static_id->hard_regs; reg != NULL; reg = reg->next)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
966 if (reg->type != OP_IN
111
kono
parents:
diff changeset
967 && reg_early_clobber_p (reg, n_alt) && ! reg->subreg_p)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
968 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
969 struct lra_insn_reg *reg2;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
970
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
971 /* We can have early clobbered non-operand hard reg and
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
972 the same hard reg as an insn input. Don't make hard
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
973 reg dead before the insns. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
974 for (reg2 = curr_id->regs; reg2 != NULL; reg2 = reg2->next)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
975 if (reg2->type != OP_OUT && reg2->regno == reg->regno)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
976 break;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
977 if (reg2 == NULL)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
978 make_hard_regno_dead (reg->regno);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
979 }
111
kono
parents:
diff changeset
980
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
981 /* Increment the current program point if we must. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
982 if (sparseset_contains_pseudos_p (dead_set)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
983 || sparseset_contains_pseudos_p (start_dying))
111
kono
parents:
diff changeset
984 next_program_point (curr_point, freq);
kono
parents:
diff changeset
985
kono
parents:
diff changeset
986 /* Update notes. */
kono
parents:
diff changeset
987 for (link_loc = &REG_NOTES (curr_insn); (link = *link_loc) != NULL_RTX;)
kono
parents:
diff changeset
988 {
kono
parents:
diff changeset
989 if (REG_NOTE_KIND (link) != REG_DEAD
kono
parents:
diff changeset
990 && REG_NOTE_KIND (link) != REG_UNUSED)
kono
parents:
diff changeset
991 ;
kono
parents:
diff changeset
992 else if (REG_P (XEXP (link, 0)))
kono
parents:
diff changeset
993 {
kono
parents:
diff changeset
994 regno = REGNO (XEXP (link, 0));
kono
parents:
diff changeset
995 if ((REG_NOTE_KIND (link) == REG_DEAD
kono
parents:
diff changeset
996 && ! sparseset_bit_p (dead_set, regno))
kono
parents:
diff changeset
997 || (REG_NOTE_KIND (link) == REG_UNUSED
kono
parents:
diff changeset
998 && ! sparseset_bit_p (unused_set, regno)))
kono
parents:
diff changeset
999 {
kono
parents:
diff changeset
1000 *link_loc = XEXP (link, 1);
kono
parents:
diff changeset
1001 continue;
kono
parents:
diff changeset
1002 }
kono
parents:
diff changeset
1003 if (REG_NOTE_KIND (link) == REG_DEAD)
kono
parents:
diff changeset
1004 sparseset_clear_bit (dead_set, regno);
kono
parents:
diff changeset
1005 else if (REG_NOTE_KIND (link) == REG_UNUSED)
kono
parents:
diff changeset
1006 sparseset_clear_bit (unused_set, regno);
kono
parents:
diff changeset
1007 }
kono
parents:
diff changeset
1008 link_loc = &XEXP (link, 1);
kono
parents:
diff changeset
1009 }
kono
parents:
diff changeset
1010 EXECUTE_IF_SET_IN_SPARSESET (dead_set, j)
kono
parents:
diff changeset
1011 add_reg_note (curr_insn, REG_DEAD, regno_reg_rtx[j]);
kono
parents:
diff changeset
1012 EXECUTE_IF_SET_IN_SPARSESET (unused_set, j)
kono
parents:
diff changeset
1013 add_reg_note (curr_insn, REG_UNUSED, regno_reg_rtx[j]);
kono
parents:
diff changeset
1014 }
kono
parents:
diff changeset
1015
kono
parents:
diff changeset
1016 if (bb_has_eh_pred (bb))
kono
parents:
diff changeset
1017 for (j = 0; ; ++j)
kono
parents:
diff changeset
1018 {
kono
parents:
diff changeset
1019 unsigned int regno = EH_RETURN_DATA_REGNO (j);
kono
parents:
diff changeset
1020
kono
parents:
diff changeset
1021 if (regno == INVALID_REGNUM)
kono
parents:
diff changeset
1022 break;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1023 make_hard_regno_live (regno);
111
kono
parents:
diff changeset
1024 }
kono
parents:
diff changeset
1025
kono
parents:
diff changeset
1026 bool live_change_p = false;
kono
parents:
diff changeset
1027 /* Check if bb border live info was changed. */
kono
parents:
diff changeset
1028 unsigned int live_pseudos_num = 0;
kono
parents:
diff changeset
1029 EXECUTE_IF_SET_IN_BITMAP (df_get_live_in (bb),
kono
parents:
diff changeset
1030 FIRST_PSEUDO_REGISTER, j, bi)
kono
parents:
diff changeset
1031 {
kono
parents:
diff changeset
1032 live_pseudos_num++;
kono
parents:
diff changeset
1033 if (! sparseset_bit_p (pseudos_live, j))
kono
parents:
diff changeset
1034 {
kono
parents:
diff changeset
1035 live_change_p = true;
kono
parents:
diff changeset
1036 if (lra_dump_file != NULL)
kono
parents:
diff changeset
1037 fprintf (lra_dump_file,
kono
parents:
diff changeset
1038 " r%d is removed as live at bb%d start\n", j, bb->index);
kono
parents:
diff changeset
1039 break;
kono
parents:
diff changeset
1040 }
kono
parents:
diff changeset
1041 }
kono
parents:
diff changeset
1042 if (! live_change_p
kono
parents:
diff changeset
1043 && sparseset_cardinality (pseudos_live) != live_pseudos_num)
kono
parents:
diff changeset
1044 {
kono
parents:
diff changeset
1045 live_change_p = true;
kono
parents:
diff changeset
1046 if (lra_dump_file != NULL)
kono
parents:
diff changeset
1047 EXECUTE_IF_SET_IN_SPARSESET (pseudos_live, j)
kono
parents:
diff changeset
1048 if (! bitmap_bit_p (df_get_live_in (bb), j))
kono
parents:
diff changeset
1049 fprintf (lra_dump_file,
kono
parents:
diff changeset
1050 " r%d is added to live at bb%d start\n", j, bb->index);
kono
parents:
diff changeset
1051 }
kono
parents:
diff changeset
1052
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1053 /* The order of this code and the code below is important. At this
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1054 point hard_regs_live does genuinely contain only live registers.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1055 Below we pretend other hard registers are live in order to create
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1056 conflicts with pseudos, but this fake live set shouldn't leak out
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1057 into the df info. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1058 for (i = 0; HARD_REGISTER_NUM_P (i); ++i)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1059 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1060 if (!TEST_HARD_REG_BIT (hard_regs_live, i))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1061 continue;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1062
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1063 if (!TEST_HARD_REG_BIT (hard_regs_spilled_into, i))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1064 continue;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1065
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1066 if (bitmap_bit_p (df_get_live_in (bb), i))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1067 continue;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1068
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1069 live_change_p = true;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1070 if (lra_dump_file)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1071 fprintf (lra_dump_file,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1072 " hard reg r%d is added to live at bb%d start\n", i,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1073 bb->index);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1074 bitmap_set_bit (df_get_live_in (bb), i);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1075 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1076
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1077 /* Pseudos can't go in stack regs at the start of a basic block that
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1078 is reached by an abnormal edge. Likewise for registers that are at
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1079 least partly call clobbered, because caller-save, fixup_abnormal_edges
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1080 and possibly the table driven EH machinery are not quite ready to
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1081 handle such pseudos live across such edges. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1082 if (bb_has_abnormal_pred (bb))
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1083 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1084 #ifdef STACK_REGS
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1085 EXECUTE_IF_SET_IN_SPARSESET (pseudos_live, px)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1086 lra_reg_info[px].no_stack_p = true;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1087 for (px = FIRST_STACK_REG; px <= LAST_STACK_REG; px++)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1088 make_hard_regno_live (px);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1089 #endif
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1090 /* No need to record conflicts for call clobbered regs if we
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1091 have nonlocal labels around, as we don't ever try to
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1092 allocate such regs in this case. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1093 if (!cfun->has_nonlocal_label
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1094 && has_abnormal_call_or_eh_pred_edge_p (bb))
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1095 for (px = 0; HARD_REGISTER_NUM_P (px); px++)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1096 if (eh_edge_abi.clobbers_at_least_part_of_reg_p (px)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1097 #ifdef REAL_PIC_OFFSET_TABLE_REGNUM
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1098 /* We should create a conflict of PIC pseudo with PIC
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1099 hard reg as PIC hard reg can have a wrong value after
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1100 jump described by the abnormal edge. In this case we
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1101 cannot allocate PIC hard reg to PIC pseudo as PIC
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1102 pseudo will also have a wrong value. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1103 || (px == REAL_PIC_OFFSET_TABLE_REGNUM
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1104 && pic_offset_table_rtx != NULL_RTX
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1105 && !HARD_REGISTER_P (pic_offset_table_rtx))
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1106 #endif
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1107 )
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1108 make_hard_regno_live (px);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1109 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1110
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1111 /* See if we'll need an increment at the end of this basic block.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1112 An increment is needed if the PSEUDOS_LIVE set is not empty,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1113 to make sure the finish points are set up correctly. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1114 need_curr_point_incr = (sparseset_cardinality (pseudos_live) > 0);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1115
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1116 EXECUTE_IF_SET_IN_SPARSESET (pseudos_live, i)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1117 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1118 update_pseudo_point (i, curr_point, DEF_POINT);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1119 mark_pseudo_dead (i);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1120 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1121
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1122 EXECUTE_IF_SET_IN_BITMAP (df_get_live_in (bb), FIRST_PSEUDO_REGISTER, j, bi)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1123 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1124 if (sparseset_cardinality (pseudos_live_through_calls) == 0)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1125 break;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1126 if (sparseset_bit_p (pseudos_live_through_calls, j))
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1127 check_pseudos_live_through_calls (j, last_call_abi);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1128 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1129
111
kono
parents:
diff changeset
1130 if (need_curr_point_incr)
kono
parents:
diff changeset
1131 next_program_point (curr_point, freq);
kono
parents:
diff changeset
1132
kono
parents:
diff changeset
1133 return live_change_p;
kono
parents:
diff changeset
1134 }
kono
parents:
diff changeset
1135
kono
parents:
diff changeset
1136 /* Compress pseudo live ranges by removing program points where
kono
parents:
diff changeset
1137 nothing happens. Complexity of many algorithms in LRA is linear
kono
parents:
diff changeset
1138 function of program points number. To speed up the code we try to
kono
parents:
diff changeset
1139 minimize the number of the program points here. */
kono
parents:
diff changeset
1140 static void
kono
parents:
diff changeset
1141 remove_some_program_points_and_update_live_ranges (void)
kono
parents:
diff changeset
1142 {
kono
parents:
diff changeset
1143 unsigned i;
kono
parents:
diff changeset
1144 int n, max_regno;
kono
parents:
diff changeset
1145 int *map;
kono
parents:
diff changeset
1146 lra_live_range_t r, prev_r, next_r;
kono
parents:
diff changeset
1147 sbitmap_iterator sbi;
kono
parents:
diff changeset
1148 bool born_p, dead_p, prev_born_p, prev_dead_p;
kono
parents:
diff changeset
1149
kono
parents:
diff changeset
1150 auto_sbitmap born (lra_live_max_point);
kono
parents:
diff changeset
1151 auto_sbitmap dead (lra_live_max_point);
kono
parents:
diff changeset
1152 bitmap_clear (born);
kono
parents:
diff changeset
1153 bitmap_clear (dead);
kono
parents:
diff changeset
1154 max_regno = max_reg_num ();
kono
parents:
diff changeset
1155 for (i = FIRST_PSEUDO_REGISTER; i < (unsigned) max_regno; i++)
kono
parents:
diff changeset
1156 {
kono
parents:
diff changeset
1157 for (r = lra_reg_info[i].live_ranges; r != NULL; r = r->next)
kono
parents:
diff changeset
1158 {
kono
parents:
diff changeset
1159 lra_assert (r->start <= r->finish);
kono
parents:
diff changeset
1160 bitmap_set_bit (born, r->start);
kono
parents:
diff changeset
1161 bitmap_set_bit (dead, r->finish);
kono
parents:
diff changeset
1162 }
kono
parents:
diff changeset
1163 }
kono
parents:
diff changeset
1164 auto_sbitmap born_or_dead (lra_live_max_point);
kono
parents:
diff changeset
1165 bitmap_ior (born_or_dead, born, dead);
kono
parents:
diff changeset
1166 map = XCNEWVEC (int, lra_live_max_point);
kono
parents:
diff changeset
1167 n = -1;
kono
parents:
diff changeset
1168 prev_born_p = prev_dead_p = false;
kono
parents:
diff changeset
1169 EXECUTE_IF_SET_IN_BITMAP (born_or_dead, 0, i, sbi)
kono
parents:
diff changeset
1170 {
kono
parents:
diff changeset
1171 born_p = bitmap_bit_p (born, i);
kono
parents:
diff changeset
1172 dead_p = bitmap_bit_p (dead, i);
kono
parents:
diff changeset
1173 if ((prev_born_p && ! prev_dead_p && born_p && ! dead_p)
kono
parents:
diff changeset
1174 || (prev_dead_p && ! prev_born_p && dead_p && ! born_p))
kono
parents:
diff changeset
1175 {
kono
parents:
diff changeset
1176 map[i] = n;
kono
parents:
diff changeset
1177 lra_point_freq[n] = MAX (lra_point_freq[n], lra_point_freq[i]);
kono
parents:
diff changeset
1178 }
kono
parents:
diff changeset
1179 else
kono
parents:
diff changeset
1180 {
kono
parents:
diff changeset
1181 map[i] = ++n;
kono
parents:
diff changeset
1182 lra_point_freq[n] = lra_point_freq[i];
kono
parents:
diff changeset
1183 }
kono
parents:
diff changeset
1184 prev_born_p = born_p;
kono
parents:
diff changeset
1185 prev_dead_p = dead_p;
kono
parents:
diff changeset
1186 }
kono
parents:
diff changeset
1187 n++;
kono
parents:
diff changeset
1188 if (lra_dump_file != NULL)
kono
parents:
diff changeset
1189 fprintf (lra_dump_file, "Compressing live ranges: from %d to %d - %d%%\n",
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1190 lra_live_max_point, n,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1191 lra_live_max_point ? 100 * n / lra_live_max_point : 100);
111
kono
parents:
diff changeset
1192 if (n < lra_live_max_point)
kono
parents:
diff changeset
1193 {
kono
parents:
diff changeset
1194 lra_live_max_point = n;
kono
parents:
diff changeset
1195 for (i = FIRST_PSEUDO_REGISTER; i < (unsigned) max_regno; i++)
kono
parents:
diff changeset
1196 {
kono
parents:
diff changeset
1197 for (prev_r = NULL, r = lra_reg_info[i].live_ranges;
kono
parents:
diff changeset
1198 r != NULL;
kono
parents:
diff changeset
1199 r = next_r)
kono
parents:
diff changeset
1200 {
kono
parents:
diff changeset
1201 next_r = r->next;
kono
parents:
diff changeset
1202 r->start = map[r->start];
kono
parents:
diff changeset
1203 r->finish = map[r->finish];
kono
parents:
diff changeset
1204 if (prev_r == NULL || prev_r->start > r->finish + 1)
kono
parents:
diff changeset
1205 {
kono
parents:
diff changeset
1206 prev_r = r;
kono
parents:
diff changeset
1207 continue;
kono
parents:
diff changeset
1208 }
kono
parents:
diff changeset
1209 prev_r->start = r->start;
kono
parents:
diff changeset
1210 prev_r->next = next_r;
kono
parents:
diff changeset
1211 lra_live_range_pool.remove (r);
kono
parents:
diff changeset
1212 }
kono
parents:
diff changeset
1213 }
kono
parents:
diff changeset
1214 }
kono
parents:
diff changeset
1215 free (map);
kono
parents:
diff changeset
1216 }
kono
parents:
diff changeset
1217
kono
parents:
diff changeset
1218 /* Print live ranges R to file F. */
kono
parents:
diff changeset
1219 void
kono
parents:
diff changeset
1220 lra_print_live_range_list (FILE *f, lra_live_range_t r)
kono
parents:
diff changeset
1221 {
kono
parents:
diff changeset
1222 for (; r != NULL; r = r->next)
kono
parents:
diff changeset
1223 fprintf (f, " [%d..%d]", r->start, r->finish);
kono
parents:
diff changeset
1224 fprintf (f, "\n");
kono
parents:
diff changeset
1225 }
kono
parents:
diff changeset
1226
kono
parents:
diff changeset
1227 DEBUG_FUNCTION void
kono
parents:
diff changeset
1228 debug (lra_live_range &ref)
kono
parents:
diff changeset
1229 {
kono
parents:
diff changeset
1230 lra_print_live_range_list (stderr, &ref);
kono
parents:
diff changeset
1231 }
kono
parents:
diff changeset
1232
kono
parents:
diff changeset
1233 DEBUG_FUNCTION void
kono
parents:
diff changeset
1234 debug (lra_live_range *ptr)
kono
parents:
diff changeset
1235 {
kono
parents:
diff changeset
1236 if (ptr)
kono
parents:
diff changeset
1237 debug (*ptr);
kono
parents:
diff changeset
1238 else
kono
parents:
diff changeset
1239 fprintf (stderr, "<nil>\n");
kono
parents:
diff changeset
1240 }
kono
parents:
diff changeset
1241
kono
parents:
diff changeset
1242 /* Print live ranges R to stderr. */
kono
parents:
diff changeset
1243 void
kono
parents:
diff changeset
1244 lra_debug_live_range_list (lra_live_range_t r)
kono
parents:
diff changeset
1245 {
kono
parents:
diff changeset
1246 lra_print_live_range_list (stderr, r);
kono
parents:
diff changeset
1247 }
kono
parents:
diff changeset
1248
kono
parents:
diff changeset
1249 /* Print live ranges of pseudo REGNO to file F. */
kono
parents:
diff changeset
1250 static void
kono
parents:
diff changeset
1251 print_pseudo_live_ranges (FILE *f, int regno)
kono
parents:
diff changeset
1252 {
kono
parents:
diff changeset
1253 if (lra_reg_info[regno].live_ranges == NULL)
kono
parents:
diff changeset
1254 return;
kono
parents:
diff changeset
1255 fprintf (f, " r%d:", regno);
kono
parents:
diff changeset
1256 lra_print_live_range_list (f, lra_reg_info[regno].live_ranges);
kono
parents:
diff changeset
1257 }
kono
parents:
diff changeset
1258
kono
parents:
diff changeset
1259 /* Print live ranges of pseudo REGNO to stderr. */
kono
parents:
diff changeset
1260 void
kono
parents:
diff changeset
1261 lra_debug_pseudo_live_ranges (int regno)
kono
parents:
diff changeset
1262 {
kono
parents:
diff changeset
1263 print_pseudo_live_ranges (stderr, regno);
kono
parents:
diff changeset
1264 }
kono
parents:
diff changeset
1265
kono
parents:
diff changeset
1266 /* Print live ranges of all pseudos to file F. */
kono
parents:
diff changeset
1267 static void
kono
parents:
diff changeset
1268 print_live_ranges (FILE *f)
kono
parents:
diff changeset
1269 {
kono
parents:
diff changeset
1270 int i, max_regno;
kono
parents:
diff changeset
1271
kono
parents:
diff changeset
1272 max_regno = max_reg_num ();
kono
parents:
diff changeset
1273 for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
kono
parents:
diff changeset
1274 print_pseudo_live_ranges (f, i);
kono
parents:
diff changeset
1275 }
kono
parents:
diff changeset
1276
kono
parents:
diff changeset
1277 /* Print live ranges of all pseudos to stderr. */
kono
parents:
diff changeset
1278 void
kono
parents:
diff changeset
1279 lra_debug_live_ranges (void)
kono
parents:
diff changeset
1280 {
kono
parents:
diff changeset
1281 print_live_ranges (stderr);
kono
parents:
diff changeset
1282 }
kono
parents:
diff changeset
1283
kono
parents:
diff changeset
1284 /* Compress pseudo live ranges. */
kono
parents:
diff changeset
1285 static void
kono
parents:
diff changeset
1286 compress_live_ranges (void)
kono
parents:
diff changeset
1287 {
kono
parents:
diff changeset
1288 remove_some_program_points_and_update_live_ranges ();
kono
parents:
diff changeset
1289 if (lra_dump_file != NULL)
kono
parents:
diff changeset
1290 {
kono
parents:
diff changeset
1291 fprintf (lra_dump_file, "Ranges after the compression:\n");
kono
parents:
diff changeset
1292 print_live_ranges (lra_dump_file);
kono
parents:
diff changeset
1293 }
kono
parents:
diff changeset
1294 }
kono
parents:
diff changeset
1295
kono
parents:
diff changeset
1296
kono
parents:
diff changeset
1297
kono
parents:
diff changeset
1298 /* The number of the current live range pass. */
kono
parents:
diff changeset
1299 int lra_live_range_iter;
kono
parents:
diff changeset
1300
kono
parents:
diff changeset
1301 /* The function creates live ranges only for memory pseudos (or for
kono
parents:
diff changeset
1302 all ones if ALL_P), set up CONFLICT_HARD_REGS for the pseudos. It
kono
parents:
diff changeset
1303 also does dead insn elimination if DEAD_INSN_P and global live
kono
parents:
diff changeset
1304 analysis only for pseudos and only if the pseudo live info was
kono
parents:
diff changeset
1305 changed on a BB border. Return TRUE if the live info was
kono
parents:
diff changeset
1306 changed. */
kono
parents:
diff changeset
1307 static bool
kono
parents:
diff changeset
1308 lra_create_live_ranges_1 (bool all_p, bool dead_insn_p)
kono
parents:
diff changeset
1309 {
kono
parents:
diff changeset
1310 basic_block bb;
kono
parents:
diff changeset
1311 int i, hard_regno, max_regno = max_reg_num ();
kono
parents:
diff changeset
1312 int curr_point;
kono
parents:
diff changeset
1313 bool bb_live_change_p, have_referenced_pseudos = false;
kono
parents:
diff changeset
1314
kono
parents:
diff changeset
1315 timevar_push (TV_LRA_CREATE_LIVE_RANGES);
kono
parents:
diff changeset
1316
kono
parents:
diff changeset
1317 complete_info_p = all_p;
kono
parents:
diff changeset
1318 if (lra_dump_file != NULL)
kono
parents:
diff changeset
1319 fprintf (lra_dump_file,
kono
parents:
diff changeset
1320 "\n********** Pseudo live ranges #%d: **********\n\n",
kono
parents:
diff changeset
1321 ++lra_live_range_iter);
kono
parents:
diff changeset
1322 memset (lra_hard_reg_usage, 0, sizeof (lra_hard_reg_usage));
kono
parents:
diff changeset
1323 for (i = 0; i < max_regno; i++)
kono
parents:
diff changeset
1324 {
kono
parents:
diff changeset
1325 lra_reg_info[i].live_ranges = NULL;
kono
parents:
diff changeset
1326 CLEAR_HARD_REG_SET (lra_reg_info[i].conflict_hard_regs);
kono
parents:
diff changeset
1327 lra_reg_info[i].preferred_hard_regno1 = -1;
kono
parents:
diff changeset
1328 lra_reg_info[i].preferred_hard_regno2 = -1;
kono
parents:
diff changeset
1329 lra_reg_info[i].preferred_hard_regno_profit1 = 0;
kono
parents:
diff changeset
1330 lra_reg_info[i].preferred_hard_regno_profit2 = 0;
kono
parents:
diff changeset
1331 #ifdef STACK_REGS
kono
parents:
diff changeset
1332 lra_reg_info[i].no_stack_p = false;
kono
parents:
diff changeset
1333 #endif
kono
parents:
diff changeset
1334 /* The biggest mode is already set but its value might be to
kono
parents:
diff changeset
1335 conservative because of recent transformation. Here in this
kono
parents:
diff changeset
1336 file we recalculate it again as it costs practically
kono
parents:
diff changeset
1337 nothing. */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1338 if (!HARD_REGISTER_NUM_P (i) && regno_reg_rtx[i] != NULL_RTX)
111
kono
parents:
diff changeset
1339 lra_reg_info[i].biggest_mode = GET_MODE (regno_reg_rtx[i]);
kono
parents:
diff changeset
1340 else
kono
parents:
diff changeset
1341 lra_reg_info[i].biggest_mode = VOIDmode;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1342 if (!HARD_REGISTER_NUM_P (i)
111
kono
parents:
diff changeset
1343 && lra_reg_info[i].nrefs != 0)
kono
parents:
diff changeset
1344 {
kono
parents:
diff changeset
1345 if ((hard_regno = reg_renumber[i]) >= 0)
kono
parents:
diff changeset
1346 lra_hard_reg_usage[hard_regno] += lra_reg_info[i].freq;
kono
parents:
diff changeset
1347 have_referenced_pseudos = true;
kono
parents:
diff changeset
1348 }
kono
parents:
diff changeset
1349 }
kono
parents:
diff changeset
1350 lra_free_copies ();
kono
parents:
diff changeset
1351
kono
parents:
diff changeset
1352 /* Under some circumstances, we can have functions without pseudo
kono
parents:
diff changeset
1353 registers. For such functions, lra_live_max_point will be 0,
kono
parents:
diff changeset
1354 see e.g. PR55604, and there's nothing more to do for us here. */
kono
parents:
diff changeset
1355 if (! have_referenced_pseudos)
kono
parents:
diff changeset
1356 {
kono
parents:
diff changeset
1357 timevar_pop (TV_LRA_CREATE_LIVE_RANGES);
kono
parents:
diff changeset
1358 return false;
kono
parents:
diff changeset
1359 }
kono
parents:
diff changeset
1360
kono
parents:
diff changeset
1361 pseudos_live = sparseset_alloc (max_regno);
kono
parents:
diff changeset
1362 pseudos_live_through_calls = sparseset_alloc (max_regno);
kono
parents:
diff changeset
1363 pseudos_live_through_setjumps = sparseset_alloc (max_regno);
kono
parents:
diff changeset
1364 start_living = sparseset_alloc (max_regno);
kono
parents:
diff changeset
1365 start_dying = sparseset_alloc (max_regno);
kono
parents:
diff changeset
1366 dead_set = sparseset_alloc (max_regno);
kono
parents:
diff changeset
1367 unused_set = sparseset_alloc (max_regno);
kono
parents:
diff changeset
1368 curr_point = 0;
kono
parents:
diff changeset
1369 unsigned new_length = get_max_uid () * 2;
kono
parents:
diff changeset
1370 point_freq_vec.truncate (0);
kono
parents:
diff changeset
1371 point_freq_vec.reserve_exact (new_length);
kono
parents:
diff changeset
1372 lra_point_freq = point_freq_vec.address ();
kono
parents:
diff changeset
1373 auto_vec<int, 20> post_order_rev_cfg;
kono
parents:
diff changeset
1374 inverted_post_order_compute (&post_order_rev_cfg);
kono
parents:
diff changeset
1375 lra_assert (post_order_rev_cfg.length () == (unsigned) n_basic_blocks_for_fn (cfun));
kono
parents:
diff changeset
1376 bb_live_change_p = false;
kono
parents:
diff changeset
1377 for (i = post_order_rev_cfg.length () - 1; i >= 0; --i)
kono
parents:
diff changeset
1378 {
kono
parents:
diff changeset
1379 bb = BASIC_BLOCK_FOR_FN (cfun, post_order_rev_cfg[i]);
kono
parents:
diff changeset
1380 if (bb == EXIT_BLOCK_PTR_FOR_FN (cfun) || bb
kono
parents:
diff changeset
1381 == ENTRY_BLOCK_PTR_FOR_FN (cfun))
kono
parents:
diff changeset
1382 continue;
kono
parents:
diff changeset
1383 if (process_bb_lives (bb, curr_point, dead_insn_p))
kono
parents:
diff changeset
1384 bb_live_change_p = true;
kono
parents:
diff changeset
1385 }
kono
parents:
diff changeset
1386 if (bb_live_change_p)
kono
parents:
diff changeset
1387 {
kono
parents:
diff changeset
1388 /* We need to clear pseudo live info as some pseudos can
kono
parents:
diff changeset
1389 disappear, e.g. pseudos with used equivalences. */
kono
parents:
diff changeset
1390 FOR_EACH_BB_FN (bb, cfun)
kono
parents:
diff changeset
1391 {
kono
parents:
diff changeset
1392 bitmap_clear_range (df_get_live_in (bb), FIRST_PSEUDO_REGISTER,
kono
parents:
diff changeset
1393 max_regno - FIRST_PSEUDO_REGISTER);
kono
parents:
diff changeset
1394 bitmap_clear_range (df_get_live_out (bb), FIRST_PSEUDO_REGISTER,
kono
parents:
diff changeset
1395 max_regno - FIRST_PSEUDO_REGISTER);
kono
parents:
diff changeset
1396 }
kono
parents:
diff changeset
1397 /* As we did not change CFG since LRA start we can use
kono
parents:
diff changeset
1398 DF-infrastructure solver to solve live data flow problem. */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1399 for (int i = 0; HARD_REGISTER_NUM_P (i); ++i)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1400 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1401 if (TEST_HARD_REG_BIT (hard_regs_spilled_into, i))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1402 bitmap_clear_bit (&all_hard_regs_bitmap, i);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1403 }
111
kono
parents:
diff changeset
1404 df_simple_dataflow
kono
parents:
diff changeset
1405 (DF_BACKWARD, NULL, live_con_fun_0, live_con_fun_n,
kono
parents:
diff changeset
1406 live_trans_fun, &all_blocks,
kono
parents:
diff changeset
1407 df_get_postorder (DF_BACKWARD), df_get_n_blocks (DF_BACKWARD));
kono
parents:
diff changeset
1408 if (lra_dump_file != NULL)
kono
parents:
diff changeset
1409 {
kono
parents:
diff changeset
1410 fprintf (lra_dump_file,
kono
parents:
diff changeset
1411 "Global pseudo live data have been updated:\n");
kono
parents:
diff changeset
1412 basic_block bb;
kono
parents:
diff changeset
1413 FOR_EACH_BB_FN (bb, cfun)
kono
parents:
diff changeset
1414 {
kono
parents:
diff changeset
1415 bb_data_t bb_info = get_bb_data (bb);
kono
parents:
diff changeset
1416 bitmap bb_livein = df_get_live_in (bb);
kono
parents:
diff changeset
1417 bitmap bb_liveout = df_get_live_out (bb);
kono
parents:
diff changeset
1418
kono
parents:
diff changeset
1419 fprintf (lra_dump_file, "\nBB %d:\n", bb->index);
kono
parents:
diff changeset
1420 lra_dump_bitmap_with_title (" gen:",
kono
parents:
diff changeset
1421 &bb_info->gen_pseudos, bb->index);
kono
parents:
diff changeset
1422 lra_dump_bitmap_with_title (" killed:",
kono
parents:
diff changeset
1423 &bb_info->killed_pseudos, bb->index);
kono
parents:
diff changeset
1424 lra_dump_bitmap_with_title (" livein:", bb_livein, bb->index);
kono
parents:
diff changeset
1425 lra_dump_bitmap_with_title (" liveout:", bb_liveout, bb->index);
kono
parents:
diff changeset
1426 }
kono
parents:
diff changeset
1427 }
kono
parents:
diff changeset
1428 }
kono
parents:
diff changeset
1429 lra_live_max_point = curr_point;
kono
parents:
diff changeset
1430 if (lra_dump_file != NULL)
kono
parents:
diff changeset
1431 print_live_ranges (lra_dump_file);
kono
parents:
diff changeset
1432 /* Clean up. */
kono
parents:
diff changeset
1433 sparseset_free (unused_set);
kono
parents:
diff changeset
1434 sparseset_free (dead_set);
kono
parents:
diff changeset
1435 sparseset_free (start_dying);
kono
parents:
diff changeset
1436 sparseset_free (start_living);
kono
parents:
diff changeset
1437 sparseset_free (pseudos_live_through_calls);
kono
parents:
diff changeset
1438 sparseset_free (pseudos_live_through_setjumps);
kono
parents:
diff changeset
1439 sparseset_free (pseudos_live);
kono
parents:
diff changeset
1440 compress_live_ranges ();
kono
parents:
diff changeset
1441 timevar_pop (TV_LRA_CREATE_LIVE_RANGES);
kono
parents:
diff changeset
1442 return bb_live_change_p;
kono
parents:
diff changeset
1443 }
kono
parents:
diff changeset
1444
kono
parents:
diff changeset
1445 /* The main entry function creates live-ranges and other live info
kono
parents:
diff changeset
1446 necessary for the assignment sub-pass. It uses
kono
parents:
diff changeset
1447 lra_creates_live_ranges_1 -- so read comments for the
kono
parents:
diff changeset
1448 function. */
kono
parents:
diff changeset
1449 void
kono
parents:
diff changeset
1450 lra_create_live_ranges (bool all_p, bool dead_insn_p)
kono
parents:
diff changeset
1451 {
kono
parents:
diff changeset
1452 if (! lra_create_live_ranges_1 (all_p, dead_insn_p))
kono
parents:
diff changeset
1453 return;
kono
parents:
diff changeset
1454 if (lra_dump_file != NULL)
kono
parents:
diff changeset
1455 fprintf (lra_dump_file, "Live info was changed -- recalculate it\n");
kono
parents:
diff changeset
1456 /* Live info was changed on a bb border. It means that some info,
kono
parents:
diff changeset
1457 e.g. about conflict regs, calls crossed, and live ranges may be
kono
parents:
diff changeset
1458 wrong. We need this info for allocation. So recalculate it
kono
parents:
diff changeset
1459 again but without removing dead insns which can change live info
kono
parents:
diff changeset
1460 again. Repetitive live range calculations are expensive therefore
kono
parents:
diff changeset
1461 we stop here as we already have correct info although some
kono
parents:
diff changeset
1462 improvement in rare cases could be possible on this sub-pass if
kono
parents:
diff changeset
1463 we do dead insn elimination again (still the improvement may
kono
parents:
diff changeset
1464 happen later). */
kono
parents:
diff changeset
1465 lra_clear_live_ranges ();
kono
parents:
diff changeset
1466 bool res = lra_create_live_ranges_1 (all_p, false);
kono
parents:
diff changeset
1467 lra_assert (! res);
kono
parents:
diff changeset
1468 }
kono
parents:
diff changeset
1469
kono
parents:
diff changeset
1470 /* Finish all live ranges. */
kono
parents:
diff changeset
1471 void
kono
parents:
diff changeset
1472 lra_clear_live_ranges (void)
kono
parents:
diff changeset
1473 {
kono
parents:
diff changeset
1474 int i;
kono
parents:
diff changeset
1475
kono
parents:
diff changeset
1476 for (i = 0; i < max_reg_num (); i++)
kono
parents:
diff changeset
1477 free_live_range_list (lra_reg_info[i].live_ranges);
kono
parents:
diff changeset
1478 point_freq_vec.release ();
kono
parents:
diff changeset
1479 }
kono
parents:
diff changeset
1480
kono
parents:
diff changeset
1481 /* Initialize live ranges data once per function. */
kono
parents:
diff changeset
1482 void
kono
parents:
diff changeset
1483 lra_live_ranges_init (void)
kono
parents:
diff changeset
1484 {
kono
parents:
diff changeset
1485 bitmap_initialize (&temp_bitmap, &reg_obstack);
kono
parents:
diff changeset
1486 initiate_live_solver ();
kono
parents:
diff changeset
1487 }
kono
parents:
diff changeset
1488
kono
parents:
diff changeset
1489 /* Finish live ranges data once per function. */
kono
parents:
diff changeset
1490 void
kono
parents:
diff changeset
1491 lra_live_ranges_finish (void)
kono
parents:
diff changeset
1492 {
kono
parents:
diff changeset
1493 finish_live_solver ();
kono
parents:
diff changeset
1494 bitmap_clear (&temp_bitmap);
kono
parents:
diff changeset
1495 lra_live_range_pool.release ();
kono
parents:
diff changeset
1496 }