annotate gcc/valtrack.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Infrastructure for tracking user variable locations and values
kono
parents:
diff changeset
2 throughout compilation.
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
3 Copyright (C) 2010-2020 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
4 Contributed by Alexandre Oliva <aoliva@redhat.com>.
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 This file is part of GCC.
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 GCC is free software; you can redistribute it and/or modify it under
kono
parents:
diff changeset
9 the terms of the GNU General Public License as published by the Free
kono
parents:
diff changeset
10 Software Foundation; either version 3, or (at your option) any later
kono
parents:
diff changeset
11 version.
kono
parents:
diff changeset
12
kono
parents:
diff changeset
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
kono
parents:
diff changeset
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
kono
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
kono
parents:
diff changeset
16 for more details.
kono
parents:
diff changeset
17
kono
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
19 along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
20 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
21
kono
parents:
diff changeset
22 #include "config.h"
kono
parents:
diff changeset
23 #include "system.h"
kono
parents:
diff changeset
24 #include "coretypes.h"
kono
parents:
diff changeset
25 #include "backend.h"
kono
parents:
diff changeset
26 #include "rtl.h"
kono
parents:
diff changeset
27 #include "df.h"
kono
parents:
diff changeset
28 #include "valtrack.h"
kono
parents:
diff changeset
29 #include "regs.h"
kono
parents:
diff changeset
30 #include "memmodel.h"
kono
parents:
diff changeset
31 #include "emit-rtl.h"
kono
parents:
diff changeset
32 #include "rtl-iter.h"
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 /* gen_lowpart_no_emit hook implementation for DEBUG_INSNs. In DEBUG_INSNs,
kono
parents:
diff changeset
35 all lowpart SUBREGs are valid, despite what the machine requires for
kono
parents:
diff changeset
36 instructions. */
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 static rtx
kono
parents:
diff changeset
39 gen_lowpart_for_debug (machine_mode mode, rtx x)
kono
parents:
diff changeset
40 {
kono
parents:
diff changeset
41 rtx result = gen_lowpart_if_possible (mode, x);
kono
parents:
diff changeset
42 if (result)
kono
parents:
diff changeset
43 return result;
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 if (GET_MODE (x) != VOIDmode)
kono
parents:
diff changeset
46 return gen_rtx_raw_SUBREG (mode, x,
kono
parents:
diff changeset
47 subreg_lowpart_offset (mode, GET_MODE (x)));
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 return NULL_RTX;
kono
parents:
diff changeset
50 }
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 /* Replace auto-increment addressing modes with explicit operations to access
kono
parents:
diff changeset
53 the same addresses without modifying the corresponding registers. */
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 static rtx
kono
parents:
diff changeset
56 cleanup_auto_inc_dec (rtx src, machine_mode mem_mode ATTRIBUTE_UNUSED)
kono
parents:
diff changeset
57 {
kono
parents:
diff changeset
58 rtx x = src;
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 const RTX_CODE code = GET_CODE (x);
kono
parents:
diff changeset
61 int i;
kono
parents:
diff changeset
62 const char *fmt;
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 switch (code)
kono
parents:
diff changeset
65 {
kono
parents:
diff changeset
66 case REG:
kono
parents:
diff changeset
67 CASE_CONST_ANY:
kono
parents:
diff changeset
68 case SYMBOL_REF:
kono
parents:
diff changeset
69 case CODE_LABEL:
kono
parents:
diff changeset
70 case PC:
kono
parents:
diff changeset
71 case CC0:
kono
parents:
diff changeset
72 case SCRATCH:
kono
parents:
diff changeset
73 /* SCRATCH must be shared because they represent distinct values. */
kono
parents:
diff changeset
74 return x;
kono
parents:
diff changeset
75 case CLOBBER:
kono
parents:
diff changeset
76 /* Share clobbers of hard registers (like cc0), but do not share pseudo reg
kono
parents:
diff changeset
77 clobbers or clobbers of hard registers that originated as pseudos.
kono
parents:
diff changeset
78 This is needed to allow safe register renaming. */
kono
parents:
diff changeset
79 if (REG_P (XEXP (x, 0)) && REGNO (XEXP (x, 0)) < FIRST_PSEUDO_REGISTER
kono
parents:
diff changeset
80 && ORIGINAL_REGNO (XEXP (x, 0)) == REGNO (XEXP (x, 0)))
kono
parents:
diff changeset
81 return x;
kono
parents:
diff changeset
82 break;
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 case CONST:
kono
parents:
diff changeset
85 if (shared_const_p (x))
kono
parents:
diff changeset
86 return x;
kono
parents:
diff changeset
87 break;
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 case MEM:
kono
parents:
diff changeset
90 mem_mode = GET_MODE (x);
kono
parents:
diff changeset
91 break;
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 case PRE_INC:
kono
parents:
diff changeset
94 case PRE_DEC:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
95 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
96 gcc_assert (mem_mode != VOIDmode && mem_mode != BLKmode);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
97 poly_int64 offset = GET_MODE_SIZE (mem_mode);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
98 if (code == PRE_DEC)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
99 offset = -offset;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
100 return gen_rtx_PLUS (GET_MODE (x),
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
101 cleanup_auto_inc_dec (XEXP (x, 0), mem_mode),
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
102 gen_int_mode (offset, GET_MODE (x)));
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
103 }
111
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105 case POST_INC:
kono
parents:
diff changeset
106 case POST_DEC:
kono
parents:
diff changeset
107 case PRE_MODIFY:
kono
parents:
diff changeset
108 case POST_MODIFY:
kono
parents:
diff changeset
109 return cleanup_auto_inc_dec (code == PRE_MODIFY
kono
parents:
diff changeset
110 ? XEXP (x, 1) : XEXP (x, 0),
kono
parents:
diff changeset
111 mem_mode);
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 default:
kono
parents:
diff changeset
114 break;
kono
parents:
diff changeset
115 }
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 /* Copy the various flags, fields, and other information. We assume
kono
parents:
diff changeset
118 that all fields need copying, and then clear the fields that should
kono
parents:
diff changeset
119 not be copied. That is the sensible default behavior, and forces
kono
parents:
diff changeset
120 us to explicitly document why we are *not* copying a flag. */
kono
parents:
diff changeset
121 x = shallow_copy_rtx (x);
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 /* We do not copy FRAME_RELATED for INSNs. */
kono
parents:
diff changeset
124 if (INSN_P (x))
kono
parents:
diff changeset
125 RTX_FLAG (x, frame_related) = 0;
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127 fmt = GET_RTX_FORMAT (code);
kono
parents:
diff changeset
128 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
kono
parents:
diff changeset
129 if (fmt[i] == 'e')
kono
parents:
diff changeset
130 XEXP (x, i) = cleanup_auto_inc_dec (XEXP (x, i), mem_mode);
kono
parents:
diff changeset
131 else if (fmt[i] == 'E' || fmt[i] == 'V')
kono
parents:
diff changeset
132 {
kono
parents:
diff changeset
133 int j;
kono
parents:
diff changeset
134 XVEC (x, i) = rtvec_alloc (XVECLEN (x, i));
kono
parents:
diff changeset
135 for (j = 0; j < XVECLEN (x, i); j++)
kono
parents:
diff changeset
136 XVECEXP (x, i, j)
kono
parents:
diff changeset
137 = cleanup_auto_inc_dec (XVECEXP (src, i, j), mem_mode);
kono
parents:
diff changeset
138 }
kono
parents:
diff changeset
139
kono
parents:
diff changeset
140 return x;
kono
parents:
diff changeset
141 }
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143 /* Auxiliary data structure for propagate_for_debug_stmt. */
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 struct rtx_subst_pair
kono
parents:
diff changeset
146 {
kono
parents:
diff changeset
147 rtx to;
kono
parents:
diff changeset
148 bool adjusted;
kono
parents:
diff changeset
149 rtx_insn *insn;
kono
parents:
diff changeset
150 };
kono
parents:
diff changeset
151
kono
parents:
diff changeset
152 /* DATA points to an rtx_subst_pair. Return the value that should be
kono
parents:
diff changeset
153 substituted. */
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 static rtx
kono
parents:
diff changeset
156 propagate_for_debug_subst (rtx from, const_rtx old_rtx, void *data)
kono
parents:
diff changeset
157 {
kono
parents:
diff changeset
158 struct rtx_subst_pair *pair = (struct rtx_subst_pair *)data;
kono
parents:
diff changeset
159
kono
parents:
diff changeset
160 if (!rtx_equal_p (from, old_rtx))
kono
parents:
diff changeset
161 return NULL_RTX;
kono
parents:
diff changeset
162 if (!pair->adjusted)
kono
parents:
diff changeset
163 {
kono
parents:
diff changeset
164 pair->adjusted = true;
kono
parents:
diff changeset
165 pair->to = cleanup_auto_inc_dec (pair->to, VOIDmode);
kono
parents:
diff changeset
166 pair->to = make_compound_operation (pair->to, SET);
kono
parents:
diff changeset
167 /* Avoid propagation from growing DEBUG_INSN expressions too much. */
kono
parents:
diff changeset
168 int cnt = 0;
kono
parents:
diff changeset
169 subrtx_iterator::array_type array;
kono
parents:
diff changeset
170 FOR_EACH_SUBRTX (iter, array, pair->to, ALL)
kono
parents:
diff changeset
171 if (REG_P (*iter) && ++cnt > 1)
kono
parents:
diff changeset
172 {
kono
parents:
diff changeset
173 rtx dval = make_debug_expr_from_rtl (old_rtx);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
174 rtx to = pair->to;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
175 if (volatile_insn_p (to))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
176 to = gen_rtx_UNKNOWN_VAR_LOC ();
111
kono
parents:
diff changeset
177 /* Emit a debug bind insn. */
kono
parents:
diff changeset
178 rtx bind
kono
parents:
diff changeset
179 = gen_rtx_VAR_LOCATION (GET_MODE (old_rtx),
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
180 DEBUG_EXPR_TREE_DECL (dval), to,
111
kono
parents:
diff changeset
181 VAR_INIT_STATUS_INITIALIZED);
kono
parents:
diff changeset
182 rtx_insn *bind_insn = emit_debug_insn_before (bind, pair->insn);
kono
parents:
diff changeset
183 df_insn_rescan (bind_insn);
kono
parents:
diff changeset
184 pair->to = dval;
kono
parents:
diff changeset
185 break;
kono
parents:
diff changeset
186 }
kono
parents:
diff changeset
187 return pair->to;
kono
parents:
diff changeset
188 }
kono
parents:
diff changeset
189 return copy_rtx (pair->to);
kono
parents:
diff changeset
190 }
kono
parents:
diff changeset
191
kono
parents:
diff changeset
192 /* Replace all the occurrences of DEST with SRC in DEBUG_INSNs between INSN
kono
parents:
diff changeset
193 and LAST, not including INSN, but including LAST. Also stop at the end
kono
parents:
diff changeset
194 of THIS_BASIC_BLOCK. */
kono
parents:
diff changeset
195
kono
parents:
diff changeset
196 void
kono
parents:
diff changeset
197 propagate_for_debug (rtx_insn *insn, rtx_insn *last, rtx dest, rtx src,
kono
parents:
diff changeset
198 basic_block this_basic_block)
kono
parents:
diff changeset
199 {
kono
parents:
diff changeset
200 rtx_insn *next, *end = NEXT_INSN (BB_END (this_basic_block));
kono
parents:
diff changeset
201 rtx loc;
kono
parents:
diff changeset
202 rtx (*saved_rtl_hook_no_emit) (machine_mode, rtx);
kono
parents:
diff changeset
203
kono
parents:
diff changeset
204 struct rtx_subst_pair p;
kono
parents:
diff changeset
205 p.to = src;
kono
parents:
diff changeset
206 p.adjusted = false;
kono
parents:
diff changeset
207 p.insn = NEXT_INSN (insn);
kono
parents:
diff changeset
208
kono
parents:
diff changeset
209 next = NEXT_INSN (insn);
kono
parents:
diff changeset
210 last = NEXT_INSN (last);
kono
parents:
diff changeset
211 saved_rtl_hook_no_emit = rtl_hooks.gen_lowpart_no_emit;
kono
parents:
diff changeset
212 rtl_hooks.gen_lowpart_no_emit = gen_lowpart_for_debug;
kono
parents:
diff changeset
213 while (next != last && next != end)
kono
parents:
diff changeset
214 {
kono
parents:
diff changeset
215 insn = next;
kono
parents:
diff changeset
216 next = NEXT_INSN (insn);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
217 if (DEBUG_BIND_INSN_P (insn))
111
kono
parents:
diff changeset
218 {
kono
parents:
diff changeset
219 loc = simplify_replace_fn_rtx (INSN_VAR_LOCATION_LOC (insn),
kono
parents:
diff changeset
220 dest, propagate_for_debug_subst, &p);
kono
parents:
diff changeset
221 if (loc == INSN_VAR_LOCATION_LOC (insn))
kono
parents:
diff changeset
222 continue;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
223 if (volatile_insn_p (loc))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
224 loc = gen_rtx_UNKNOWN_VAR_LOC ();
111
kono
parents:
diff changeset
225 INSN_VAR_LOCATION_LOC (insn) = loc;
kono
parents:
diff changeset
226 df_insn_rescan (insn);
kono
parents:
diff changeset
227 }
kono
parents:
diff changeset
228 }
kono
parents:
diff changeset
229 rtl_hooks.gen_lowpart_no_emit = saved_rtl_hook_no_emit;
kono
parents:
diff changeset
230 }
kono
parents:
diff changeset
231
kono
parents:
diff changeset
232 /* Initialize DEBUG to an empty list, and clear USED, if given. */
kono
parents:
diff changeset
233
kono
parents:
diff changeset
234 void
kono
parents:
diff changeset
235 dead_debug_global_init (struct dead_debug_global *debug, bitmap used)
kono
parents:
diff changeset
236 {
kono
parents:
diff changeset
237 debug->used = used;
kono
parents:
diff changeset
238 debug->htab = NULL;
kono
parents:
diff changeset
239 if (used)
kono
parents:
diff changeset
240 bitmap_clear (used);
kono
parents:
diff changeset
241 }
kono
parents:
diff changeset
242
kono
parents:
diff changeset
243 /* Initialize DEBUG to an empty list, and clear USED, if given. Link
kono
parents:
diff changeset
244 back to GLOBAL, if given, and bring in used bits from it. */
kono
parents:
diff changeset
245
kono
parents:
diff changeset
246 void
kono
parents:
diff changeset
247 dead_debug_local_init (struct dead_debug_local *debug, bitmap used,
kono
parents:
diff changeset
248 struct dead_debug_global *global)
kono
parents:
diff changeset
249 {
kono
parents:
diff changeset
250 if (!used && global && global->used)
kono
parents:
diff changeset
251 used = BITMAP_ALLOC (NULL);
kono
parents:
diff changeset
252
kono
parents:
diff changeset
253 debug->head = NULL;
kono
parents:
diff changeset
254 debug->global = global;
kono
parents:
diff changeset
255 debug->used = used;
kono
parents:
diff changeset
256 debug->to_rescan = NULL;
kono
parents:
diff changeset
257
kono
parents:
diff changeset
258 if (used)
kono
parents:
diff changeset
259 {
kono
parents:
diff changeset
260 if (global && global->used)
kono
parents:
diff changeset
261 bitmap_copy (used, global->used);
kono
parents:
diff changeset
262 else
kono
parents:
diff changeset
263 bitmap_clear (used);
kono
parents:
diff changeset
264 }
kono
parents:
diff changeset
265 }
kono
parents:
diff changeset
266
kono
parents:
diff changeset
267 /* Locate the entry for REG in GLOBAL->htab. */
kono
parents:
diff changeset
268
kono
parents:
diff changeset
269 static dead_debug_global_entry *
kono
parents:
diff changeset
270 dead_debug_global_find (struct dead_debug_global *global, rtx reg)
kono
parents:
diff changeset
271 {
kono
parents:
diff changeset
272 dead_debug_global_entry temp_entry;
kono
parents:
diff changeset
273 temp_entry.reg = reg;
kono
parents:
diff changeset
274
kono
parents:
diff changeset
275 dead_debug_global_entry *entry = global->htab->find (&temp_entry);
kono
parents:
diff changeset
276 gcc_checking_assert (entry && entry->reg == temp_entry.reg);
kono
parents:
diff changeset
277
kono
parents:
diff changeset
278 return entry;
kono
parents:
diff changeset
279 }
kono
parents:
diff changeset
280
kono
parents:
diff changeset
281 /* Insert an entry mapping REG to DTEMP in GLOBAL->htab. */
kono
parents:
diff changeset
282
kono
parents:
diff changeset
283 static dead_debug_global_entry *
kono
parents:
diff changeset
284 dead_debug_global_insert (struct dead_debug_global *global, rtx reg, rtx dtemp)
kono
parents:
diff changeset
285 {
kono
parents:
diff changeset
286 dead_debug_global_entry temp_entry;
kono
parents:
diff changeset
287 temp_entry.reg = reg;
kono
parents:
diff changeset
288 temp_entry.dtemp = dtemp;
kono
parents:
diff changeset
289
kono
parents:
diff changeset
290 if (!global->htab)
kono
parents:
diff changeset
291 global->htab = new hash_table<dead_debug_hash_descr> (31);
kono
parents:
diff changeset
292
kono
parents:
diff changeset
293 dead_debug_global_entry **slot = global->htab->find_slot (&temp_entry,
kono
parents:
diff changeset
294 INSERT);
kono
parents:
diff changeset
295 gcc_checking_assert (!*slot);
kono
parents:
diff changeset
296 *slot = XNEW (dead_debug_global_entry);
kono
parents:
diff changeset
297 **slot = temp_entry;
kono
parents:
diff changeset
298 return *slot;
kono
parents:
diff changeset
299 }
kono
parents:
diff changeset
300
kono
parents:
diff changeset
301 /* If UREGNO, referenced by USE, is a pseudo marked as used in GLOBAL,
kono
parents:
diff changeset
302 replace it with a USE of the debug temp recorded for it, and
kono
parents:
diff changeset
303 return TRUE. Otherwise, just return FALSE.
kono
parents:
diff changeset
304
kono
parents:
diff changeset
305 If PTO_RESCAN is given, instead of rescanning modified INSNs right
kono
parents:
diff changeset
306 away, add their UIDs to the bitmap, allocating one of *PTO_RESCAN
kono
parents:
diff changeset
307 is NULL. */
kono
parents:
diff changeset
308
kono
parents:
diff changeset
309 static bool
kono
parents:
diff changeset
310 dead_debug_global_replace_temp (struct dead_debug_global *global,
kono
parents:
diff changeset
311 df_ref use, unsigned int uregno,
kono
parents:
diff changeset
312 bitmap *pto_rescan)
kono
parents:
diff changeset
313 {
kono
parents:
diff changeset
314 if (!global || uregno < FIRST_PSEUDO_REGISTER
kono
parents:
diff changeset
315 || !global->used
kono
parents:
diff changeset
316 || !REG_P (*DF_REF_REAL_LOC (use))
kono
parents:
diff changeset
317 || REGNO (*DF_REF_REAL_LOC (use)) != uregno
kono
parents:
diff changeset
318 || !bitmap_bit_p (global->used, uregno))
kono
parents:
diff changeset
319 return false;
kono
parents:
diff changeset
320
kono
parents:
diff changeset
321 dead_debug_global_entry *entry
kono
parents:
diff changeset
322 = dead_debug_global_find (global, *DF_REF_REAL_LOC (use));
kono
parents:
diff changeset
323 gcc_checking_assert (GET_CODE (entry->reg) == REG
kono
parents:
diff changeset
324 && REGNO (entry->reg) == uregno);
kono
parents:
diff changeset
325
kono
parents:
diff changeset
326 if (!entry->dtemp)
kono
parents:
diff changeset
327 return true;
kono
parents:
diff changeset
328
kono
parents:
diff changeset
329 *DF_REF_REAL_LOC (use) = entry->dtemp;
kono
parents:
diff changeset
330 if (!pto_rescan)
kono
parents:
diff changeset
331 df_insn_rescan (DF_REF_INSN (use));
kono
parents:
diff changeset
332 else
kono
parents:
diff changeset
333 {
kono
parents:
diff changeset
334 if (!*pto_rescan)
kono
parents:
diff changeset
335 *pto_rescan = BITMAP_ALLOC (NULL);
kono
parents:
diff changeset
336 bitmap_set_bit (*pto_rescan, INSN_UID (DF_REF_INSN (use)));
kono
parents:
diff changeset
337 }
kono
parents:
diff changeset
338
kono
parents:
diff changeset
339 return true;
kono
parents:
diff changeset
340 }
kono
parents:
diff changeset
341
kono
parents:
diff changeset
342 /* Reset all debug uses in HEAD, and clear DEBUG->to_rescan bits of
kono
parents:
diff changeset
343 each reset insn. DEBUG is not otherwise modified. If HEAD is
kono
parents:
diff changeset
344 DEBUG->head, DEBUG->head will be set to NULL at the end.
kono
parents:
diff changeset
345 Otherwise, entries from DEBUG->head that pertain to reset insns
kono
parents:
diff changeset
346 will be removed, and only then rescanned. */
kono
parents:
diff changeset
347
kono
parents:
diff changeset
348 static void
kono
parents:
diff changeset
349 dead_debug_reset_uses (struct dead_debug_local *debug,
kono
parents:
diff changeset
350 struct dead_debug_use *head)
kono
parents:
diff changeset
351 {
kono
parents:
diff changeset
352 bool got_head = (debug->head == head);
kono
parents:
diff changeset
353 bitmap rescan;
kono
parents:
diff changeset
354 struct dead_debug_use **tailp = &debug->head;
kono
parents:
diff changeset
355 struct dead_debug_use *cur;
kono
parents:
diff changeset
356 bitmap_iterator bi;
kono
parents:
diff changeset
357 unsigned int uid;
kono
parents:
diff changeset
358
kono
parents:
diff changeset
359 if (got_head)
kono
parents:
diff changeset
360 rescan = NULL;
kono
parents:
diff changeset
361 else
kono
parents:
diff changeset
362 rescan = BITMAP_ALLOC (NULL);
kono
parents:
diff changeset
363
kono
parents:
diff changeset
364 while (head)
kono
parents:
diff changeset
365 {
kono
parents:
diff changeset
366 struct dead_debug_use *next = head->next;
kono
parents:
diff changeset
367 rtx_insn *insn;
kono
parents:
diff changeset
368
kono
parents:
diff changeset
369 insn = DF_REF_INSN (head->use);
kono
parents:
diff changeset
370 if (!next || DF_REF_INSN (next->use) != insn)
kono
parents:
diff changeset
371 {
kono
parents:
diff changeset
372 INSN_VAR_LOCATION_LOC (insn) = gen_rtx_UNKNOWN_VAR_LOC ();
kono
parents:
diff changeset
373 if (got_head)
kono
parents:
diff changeset
374 df_insn_rescan_debug_internal (insn);
kono
parents:
diff changeset
375 else
kono
parents:
diff changeset
376 bitmap_set_bit (rescan, INSN_UID (insn));
kono
parents:
diff changeset
377 if (debug->to_rescan)
kono
parents:
diff changeset
378 bitmap_clear_bit (debug->to_rescan, INSN_UID (insn));
kono
parents:
diff changeset
379 }
kono
parents:
diff changeset
380 XDELETE (head);
kono
parents:
diff changeset
381 head = next;
kono
parents:
diff changeset
382 }
kono
parents:
diff changeset
383
kono
parents:
diff changeset
384 if (got_head)
kono
parents:
diff changeset
385 {
kono
parents:
diff changeset
386 debug->head = NULL;
kono
parents:
diff changeset
387 return;
kono
parents:
diff changeset
388 }
kono
parents:
diff changeset
389
kono
parents:
diff changeset
390 while ((cur = *tailp))
kono
parents:
diff changeset
391 if (bitmap_bit_p (rescan, INSN_UID (DF_REF_INSN (cur->use))))
kono
parents:
diff changeset
392 {
kono
parents:
diff changeset
393 *tailp = cur->next;
kono
parents:
diff changeset
394 XDELETE (cur);
kono
parents:
diff changeset
395 }
kono
parents:
diff changeset
396 else
kono
parents:
diff changeset
397 tailp = &cur->next;
kono
parents:
diff changeset
398
kono
parents:
diff changeset
399 EXECUTE_IF_SET_IN_BITMAP (rescan, 0, uid, bi)
kono
parents:
diff changeset
400 {
kono
parents:
diff changeset
401 struct df_insn_info *insn_info = DF_INSN_UID_SAFE_GET (uid);
kono
parents:
diff changeset
402 if (insn_info)
kono
parents:
diff changeset
403 df_insn_rescan_debug_internal (insn_info->insn);
kono
parents:
diff changeset
404 }
kono
parents:
diff changeset
405
kono
parents:
diff changeset
406 BITMAP_FREE (rescan);
kono
parents:
diff changeset
407 }
kono
parents:
diff changeset
408
kono
parents:
diff changeset
409 /* Promote pending local uses of pseudos in DEBUG to global
kono
parents:
diff changeset
410 substitutions. Uses of non-pseudos are left alone for
kono
parents:
diff changeset
411 resetting. */
kono
parents:
diff changeset
412
kono
parents:
diff changeset
413 static void
kono
parents:
diff changeset
414 dead_debug_promote_uses (struct dead_debug_local *debug)
kono
parents:
diff changeset
415 {
kono
parents:
diff changeset
416 for (struct dead_debug_use *head = debug->head, **headp = &debug->head;
kono
parents:
diff changeset
417 head; head = *headp)
kono
parents:
diff changeset
418 {
kono
parents:
diff changeset
419 rtx reg = *DF_REF_REAL_LOC (head->use);
kono
parents:
diff changeset
420 df_ref ref;
kono
parents:
diff changeset
421 dead_debug_global_entry *entry;
kono
parents:
diff changeset
422
kono
parents:
diff changeset
423 if (GET_CODE (reg) != REG
kono
parents:
diff changeset
424 || REGNO (reg) < FIRST_PSEUDO_REGISTER)
kono
parents:
diff changeset
425 {
kono
parents:
diff changeset
426 headp = &head->next;
kono
parents:
diff changeset
427 continue;
kono
parents:
diff changeset
428 }
kono
parents:
diff changeset
429
kono
parents:
diff changeset
430 if (!debug->global->used)
kono
parents:
diff changeset
431 debug->global->used = BITMAP_ALLOC (NULL);
kono
parents:
diff changeset
432
kono
parents:
diff changeset
433 bool added = bitmap_set_bit (debug->global->used, REGNO (reg));
kono
parents:
diff changeset
434 gcc_checking_assert (added);
kono
parents:
diff changeset
435
kono
parents:
diff changeset
436 entry = dead_debug_global_insert (debug->global, reg,
kono
parents:
diff changeset
437 make_debug_expr_from_rtl (reg));
kono
parents:
diff changeset
438
kono
parents:
diff changeset
439 gcc_checking_assert (entry->dtemp);
kono
parents:
diff changeset
440
kono
parents:
diff changeset
441 /* Tentatively remove the USE from the list. */
kono
parents:
diff changeset
442 *headp = head->next;
kono
parents:
diff changeset
443
kono
parents:
diff changeset
444 if (!debug->to_rescan)
kono
parents:
diff changeset
445 debug->to_rescan = BITMAP_ALLOC (NULL);
kono
parents:
diff changeset
446
kono
parents:
diff changeset
447 for (ref = DF_REG_USE_CHAIN (REGNO (reg)); ref;
kono
parents:
diff changeset
448 ref = DF_REF_NEXT_REG (ref))
kono
parents:
diff changeset
449 if (DEBUG_INSN_P (DF_REF_INSN (ref)))
kono
parents:
diff changeset
450 {
kono
parents:
diff changeset
451 if (!dead_debug_global_replace_temp (debug->global, ref,
kono
parents:
diff changeset
452 REGNO (reg),
kono
parents:
diff changeset
453 &debug->to_rescan))
kono
parents:
diff changeset
454 {
kono
parents:
diff changeset
455 rtx_insn *insn = DF_REF_INSN (ref);
kono
parents:
diff changeset
456 INSN_VAR_LOCATION_LOC (insn) = gen_rtx_UNKNOWN_VAR_LOC ();
kono
parents:
diff changeset
457 bitmap_set_bit (debug->to_rescan, INSN_UID (insn));
kono
parents:
diff changeset
458 }
kono
parents:
diff changeset
459 }
kono
parents:
diff changeset
460
kono
parents:
diff changeset
461 for (ref = DF_REG_DEF_CHAIN (REGNO (reg)); ref;
kono
parents:
diff changeset
462 ref = DF_REF_NEXT_REG (ref))
kono
parents:
diff changeset
463 if (!dead_debug_insert_temp (debug, REGNO (reg), DF_REF_INSN (ref),
kono
parents:
diff changeset
464 DEBUG_TEMP_BEFORE_WITH_VALUE))
kono
parents:
diff changeset
465 {
kono
parents:
diff changeset
466 rtx bind;
kono
parents:
diff changeset
467 bind = gen_rtx_VAR_LOCATION (GET_MODE (reg),
kono
parents:
diff changeset
468 DEBUG_EXPR_TREE_DECL (entry->dtemp),
kono
parents:
diff changeset
469 gen_rtx_UNKNOWN_VAR_LOC (),
kono
parents:
diff changeset
470 VAR_INIT_STATUS_INITIALIZED);
kono
parents:
diff changeset
471 rtx_insn *insn = emit_debug_insn_before (bind, DF_REF_INSN (ref));
kono
parents:
diff changeset
472 bitmap_set_bit (debug->to_rescan, INSN_UID (insn));
kono
parents:
diff changeset
473 }
kono
parents:
diff changeset
474
kono
parents:
diff changeset
475 entry->dtemp = NULL;
kono
parents:
diff changeset
476 XDELETE (head);
kono
parents:
diff changeset
477 }
kono
parents:
diff changeset
478 }
kono
parents:
diff changeset
479
kono
parents:
diff changeset
480 /* Reset all debug insns with pending uses. Release the bitmap in it,
kono
parents:
diff changeset
481 unless it is USED. USED must be the same bitmap passed to
kono
parents:
diff changeset
482 dead_debug_local_init. */
kono
parents:
diff changeset
483
kono
parents:
diff changeset
484 void
kono
parents:
diff changeset
485 dead_debug_local_finish (struct dead_debug_local *debug, bitmap used)
kono
parents:
diff changeset
486 {
kono
parents:
diff changeset
487 if (debug->global)
kono
parents:
diff changeset
488 dead_debug_promote_uses (debug);
kono
parents:
diff changeset
489
kono
parents:
diff changeset
490 if (debug->used != used)
kono
parents:
diff changeset
491 BITMAP_FREE (debug->used);
kono
parents:
diff changeset
492
kono
parents:
diff changeset
493 dead_debug_reset_uses (debug, debug->head);
kono
parents:
diff changeset
494
kono
parents:
diff changeset
495 if (debug->to_rescan)
kono
parents:
diff changeset
496 {
kono
parents:
diff changeset
497 bitmap_iterator bi;
kono
parents:
diff changeset
498 unsigned int uid;
kono
parents:
diff changeset
499
kono
parents:
diff changeset
500 EXECUTE_IF_SET_IN_BITMAP (debug->to_rescan, 0, uid, bi)
kono
parents:
diff changeset
501 {
kono
parents:
diff changeset
502 struct df_insn_info *insn_info = DF_INSN_UID_SAFE_GET (uid);
kono
parents:
diff changeset
503 if (insn_info)
kono
parents:
diff changeset
504 df_insn_rescan (insn_info->insn);
kono
parents:
diff changeset
505 }
kono
parents:
diff changeset
506 BITMAP_FREE (debug->to_rescan);
kono
parents:
diff changeset
507 }
kono
parents:
diff changeset
508 }
kono
parents:
diff changeset
509
kono
parents:
diff changeset
510 /* Release GLOBAL->used unless it is the same as USED. Release the
kono
parents:
diff changeset
511 mapping hash table if it was initialized. */
kono
parents:
diff changeset
512
kono
parents:
diff changeset
513 void
kono
parents:
diff changeset
514 dead_debug_global_finish (struct dead_debug_global *global, bitmap used)
kono
parents:
diff changeset
515 {
kono
parents:
diff changeset
516 if (global->used != used)
kono
parents:
diff changeset
517 BITMAP_FREE (global->used);
kono
parents:
diff changeset
518
kono
parents:
diff changeset
519 delete global->htab;
kono
parents:
diff changeset
520 global->htab = NULL;
kono
parents:
diff changeset
521 }
kono
parents:
diff changeset
522
kono
parents:
diff changeset
523 /* Add USE to DEBUG, or substitute it right away if it's a pseudo in
kono
parents:
diff changeset
524 the global substitution list. USE must be a dead reference to
kono
parents:
diff changeset
525 UREGNO in a debug insn. Create a bitmap for DEBUG as needed. */
kono
parents:
diff changeset
526
kono
parents:
diff changeset
527 void
kono
parents:
diff changeset
528 dead_debug_add (struct dead_debug_local *debug, df_ref use, unsigned int uregno)
kono
parents:
diff changeset
529 {
kono
parents:
diff changeset
530 if (dead_debug_global_replace_temp (debug->global, use, uregno,
kono
parents:
diff changeset
531 &debug->to_rescan))
kono
parents:
diff changeset
532 return;
kono
parents:
diff changeset
533
kono
parents:
diff changeset
534 struct dead_debug_use *newddu = XNEW (struct dead_debug_use);
kono
parents:
diff changeset
535
kono
parents:
diff changeset
536 newddu->use = use;
kono
parents:
diff changeset
537 newddu->next = debug->head;
kono
parents:
diff changeset
538 debug->head = newddu;
kono
parents:
diff changeset
539
kono
parents:
diff changeset
540 if (!debug->used)
kono
parents:
diff changeset
541 debug->used = BITMAP_ALLOC (NULL);
kono
parents:
diff changeset
542
kono
parents:
diff changeset
543 /* ??? If we dealt with split multi-registers below, we should set
kono
parents:
diff changeset
544 all registers for the used mode in case of hardware
kono
parents:
diff changeset
545 registers. */
kono
parents:
diff changeset
546 bitmap_set_bit (debug->used, uregno);
kono
parents:
diff changeset
547 }
kono
parents:
diff changeset
548
kono
parents:
diff changeset
549 /* Like lowpart_subreg, but if a subreg is not valid for machine, force
kono
parents:
diff changeset
550 it anyway - for use in debug insns. */
kono
parents:
diff changeset
551
kono
parents:
diff changeset
552 static rtx
kono
parents:
diff changeset
553 debug_lowpart_subreg (machine_mode outer_mode, rtx expr,
kono
parents:
diff changeset
554 machine_mode inner_mode)
kono
parents:
diff changeset
555 {
kono
parents:
diff changeset
556 if (inner_mode == VOIDmode)
kono
parents:
diff changeset
557 inner_mode = GET_MODE (expr);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
558 poly_int64 offset = subreg_lowpart_offset (outer_mode, inner_mode);
111
kono
parents:
diff changeset
559 rtx ret = simplify_gen_subreg (outer_mode, expr, inner_mode, offset);
kono
parents:
diff changeset
560 if (ret)
kono
parents:
diff changeset
561 return ret;
kono
parents:
diff changeset
562 return gen_rtx_raw_SUBREG (outer_mode, expr, offset);
kono
parents:
diff changeset
563 }
kono
parents:
diff changeset
564
kono
parents:
diff changeset
565 /* If UREGNO is referenced by any entry in DEBUG, emit a debug insn
kono
parents:
diff changeset
566 before or after INSN (depending on WHERE), that binds a (possibly
kono
parents:
diff changeset
567 global) debug temp to the widest-mode use of UREGNO, if WHERE is
kono
parents:
diff changeset
568 *_WITH_REG, or the value stored in UREGNO by INSN otherwise, and
kono
parents:
diff changeset
569 replace all uses of UREGNO in DEBUG with uses of the debug temp.
kono
parents:
diff changeset
570 INSN must be where UREGNO dies, if WHERE is *_BEFORE_*, or where it
kono
parents:
diff changeset
571 is set otherwise. Return the number of debug insns emitted. */
kono
parents:
diff changeset
572
kono
parents:
diff changeset
573 int
kono
parents:
diff changeset
574 dead_debug_insert_temp (struct dead_debug_local *debug, unsigned int uregno,
kono
parents:
diff changeset
575 rtx_insn *insn, enum debug_temp_where where)
kono
parents:
diff changeset
576 {
kono
parents:
diff changeset
577 struct dead_debug_use **tailp = &debug->head;
kono
parents:
diff changeset
578 struct dead_debug_use *cur;
kono
parents:
diff changeset
579 struct dead_debug_use *uses = NULL;
kono
parents:
diff changeset
580 struct dead_debug_use **usesp = &uses;
kono
parents:
diff changeset
581 rtx reg = NULL_RTX;
kono
parents:
diff changeset
582 rtx breg;
kono
parents:
diff changeset
583 rtx dval = NULL_RTX;
kono
parents:
diff changeset
584 rtx bind;
kono
parents:
diff changeset
585 bool global;
kono
parents:
diff changeset
586
kono
parents:
diff changeset
587 if (!debug->used)
kono
parents:
diff changeset
588 return 0;
kono
parents:
diff changeset
589
kono
parents:
diff changeset
590 global = (debug->global && debug->global->used
kono
parents:
diff changeset
591 && bitmap_bit_p (debug->global->used, uregno));
kono
parents:
diff changeset
592
kono
parents:
diff changeset
593 if (!global && !bitmap_clear_bit (debug->used, uregno))
kono
parents:
diff changeset
594 return 0;
kono
parents:
diff changeset
595
kono
parents:
diff changeset
596 /* Move all uses of uregno from debug->head to uses, setting mode to
kono
parents:
diff changeset
597 the widest referenced mode. */
kono
parents:
diff changeset
598 while ((cur = *tailp))
kono
parents:
diff changeset
599 {
kono
parents:
diff changeset
600 if (DF_REF_REGNO (cur->use) == uregno)
kono
parents:
diff changeset
601 {
kono
parents:
diff changeset
602 /* If this loc has been changed e.g. to debug_expr already
kono
parents:
diff changeset
603 as part of a multi-register use, just drop it. */
kono
parents:
diff changeset
604 if (!REG_P (*DF_REF_REAL_LOC (cur->use)))
kono
parents:
diff changeset
605 {
kono
parents:
diff changeset
606 *tailp = cur->next;
kono
parents:
diff changeset
607 XDELETE (cur);
kono
parents:
diff changeset
608 continue;
kono
parents:
diff changeset
609 }
kono
parents:
diff changeset
610 *usesp = cur;
kono
parents:
diff changeset
611 usesp = &cur->next;
kono
parents:
diff changeset
612 *tailp = cur->next;
kono
parents:
diff changeset
613 cur->next = NULL;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
614 /* "may" rather than "must" because we want (for example)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
615 N V4SFs to win over plain V4SF even though N might be 1. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
616 rtx candidate = *DF_REF_REAL_LOC (cur->use);
111
kono
parents:
diff changeset
617 if (!reg
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
618 || maybe_lt (GET_MODE_BITSIZE (GET_MODE (reg)),
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
619 GET_MODE_BITSIZE (GET_MODE (candidate))))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
620 reg = candidate;
111
kono
parents:
diff changeset
621 }
kono
parents:
diff changeset
622 else
kono
parents:
diff changeset
623 tailp = &(*tailp)->next;
kono
parents:
diff changeset
624 }
kono
parents:
diff changeset
625
kono
parents:
diff changeset
626 /* We may have dangling bits in debug->used for registers that were part
kono
parents:
diff changeset
627 of a multi-register use, one component of which has been reset. */
kono
parents:
diff changeset
628 if (reg == NULL)
kono
parents:
diff changeset
629 {
kono
parents:
diff changeset
630 gcc_checking_assert (!uses);
kono
parents:
diff changeset
631 if (!global)
kono
parents:
diff changeset
632 return 0;
kono
parents:
diff changeset
633 }
kono
parents:
diff changeset
634
kono
parents:
diff changeset
635 if (global)
kono
parents:
diff changeset
636 {
kono
parents:
diff changeset
637 if (!reg)
kono
parents:
diff changeset
638 reg = regno_reg_rtx[uregno];
kono
parents:
diff changeset
639 dead_debug_global_entry *entry
kono
parents:
diff changeset
640 = dead_debug_global_find (debug->global, reg);
kono
parents:
diff changeset
641 gcc_checking_assert (entry->reg == reg);
kono
parents:
diff changeset
642 dval = entry->dtemp;
kono
parents:
diff changeset
643 if (!dval)
kono
parents:
diff changeset
644 return 0;
kono
parents:
diff changeset
645 }
kono
parents:
diff changeset
646
kono
parents:
diff changeset
647 gcc_checking_assert (uses || global);
kono
parents:
diff changeset
648
kono
parents:
diff changeset
649 breg = reg;
kono
parents:
diff changeset
650 /* Recover the expression INSN stores in REG. */
kono
parents:
diff changeset
651 if (where == DEBUG_TEMP_BEFORE_WITH_VALUE)
kono
parents:
diff changeset
652 {
kono
parents:
diff changeset
653 rtx set = single_set (insn);
kono
parents:
diff changeset
654 rtx dest, src;
kono
parents:
diff changeset
655
kono
parents:
diff changeset
656 if (set)
kono
parents:
diff changeset
657 {
kono
parents:
diff changeset
658 dest = SET_DEST (set);
kono
parents:
diff changeset
659 src = SET_SRC (set);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
660 /* Reset uses if the REG-setting insn is a CALL. Asm in
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
661 DEBUG_INSN is never useful, we can't emit debug info for
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
662 that. And for volatile_insn_p, it is actually harmful -
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
663 DEBUG_INSNs shouldn't have any side-effects. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
664 if (GET_CODE (src) == CALL || GET_CODE (src) == ASM_OPERANDS
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
665 || volatile_insn_p (src))
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
666 set = NULL_RTX;
111
kono
parents:
diff changeset
667 }
kono
parents:
diff changeset
668
kono
parents:
diff changeset
669 /* ??? Should we try to extract it from a PARALLEL? */
kono
parents:
diff changeset
670 if (!set)
kono
parents:
diff changeset
671 breg = NULL;
kono
parents:
diff changeset
672 /* Cool, it's the same REG, we can use SRC. */
kono
parents:
diff changeset
673 else if (dest == reg)
kono
parents:
diff changeset
674 breg = cleanup_auto_inc_dec (src, VOIDmode);
kono
parents:
diff changeset
675 else if (REG_P (dest))
kono
parents:
diff changeset
676 {
kono
parents:
diff changeset
677 /* Hmm... Something's fishy, we should be setting REG here. */
kono
parents:
diff changeset
678 if (REGNO (dest) != REGNO (reg))
kono
parents:
diff changeset
679 breg = NULL;
kono
parents:
diff changeset
680 /* If we're not overwriting all the hardware registers that
kono
parents:
diff changeset
681 setting REG in its mode would, we won't know what to bind
kono
parents:
diff changeset
682 the debug temp to. ??? We could bind the debug_expr to a
kono
parents:
diff changeset
683 CONCAT or PARALLEL with the split multi-registers, and
kono
parents:
diff changeset
684 replace them as we found the corresponding sets. */
kono
parents:
diff changeset
685 else if (REG_NREGS (reg) != REG_NREGS (dest))
kono
parents:
diff changeset
686 breg = NULL;
kono
parents:
diff changeset
687 /* Ok, it's the same (hardware) REG, but with a different
kono
parents:
diff changeset
688 mode, so SUBREG it. */
kono
parents:
diff changeset
689 else
kono
parents:
diff changeset
690 breg = debug_lowpart_subreg (GET_MODE (reg),
kono
parents:
diff changeset
691 cleanup_auto_inc_dec (src, VOIDmode),
kono
parents:
diff changeset
692 GET_MODE (dest));
kono
parents:
diff changeset
693 }
kono
parents:
diff changeset
694 else if (GET_CODE (dest) == SUBREG)
kono
parents:
diff changeset
695 {
kono
parents:
diff changeset
696 /* We should be setting REG here. Lose. */
kono
parents:
diff changeset
697 if (REGNO (SUBREG_REG (dest)) != REGNO (reg))
kono
parents:
diff changeset
698 breg = NULL;
kono
parents:
diff changeset
699 /* Lose if we're setting something other than the lowpart of
kono
parents:
diff changeset
700 REG. */
kono
parents:
diff changeset
701 else if (!subreg_lowpart_p (dest))
kono
parents:
diff changeset
702 breg = NULL;
kono
parents:
diff changeset
703 /* If we're not overwriting all the hardware registers that
kono
parents:
diff changeset
704 setting REG in its mode would, we won't know what to bind
kono
parents:
diff changeset
705 the debug temp to. */
kono
parents:
diff changeset
706 else if (REGNO (reg) < FIRST_PSEUDO_REGISTER
kono
parents:
diff changeset
707 && (REG_NREGS (reg)
kono
parents:
diff changeset
708 != hard_regno_nregs (REGNO (reg), GET_MODE (dest))))
kono
parents:
diff changeset
709 breg = NULL;
kono
parents:
diff changeset
710 /* Yay, we can use SRC, just adjust its mode. */
kono
parents:
diff changeset
711 else
kono
parents:
diff changeset
712 breg = debug_lowpart_subreg (GET_MODE (reg),
kono
parents:
diff changeset
713 cleanup_auto_inc_dec (src, VOIDmode),
kono
parents:
diff changeset
714 GET_MODE (dest));
kono
parents:
diff changeset
715 }
kono
parents:
diff changeset
716 /* Oh well, we're out of luck. */
kono
parents:
diff changeset
717 else
kono
parents:
diff changeset
718 breg = NULL;
kono
parents:
diff changeset
719
kono
parents:
diff changeset
720 /* We couldn't figure out the value stored in REG, so reset all
kono
parents:
diff changeset
721 of its pending debug uses. */
kono
parents:
diff changeset
722 if (!breg)
kono
parents:
diff changeset
723 {
kono
parents:
diff changeset
724 dead_debug_reset_uses (debug, uses);
kono
parents:
diff changeset
725 return 0;
kono
parents:
diff changeset
726 }
kono
parents:
diff changeset
727 }
kono
parents:
diff changeset
728
kono
parents:
diff changeset
729 /* If there's a single (debug) use of an otherwise unused REG, and
kono
parents:
diff changeset
730 the debug use is not part of a larger expression, then it
kono
parents:
diff changeset
731 probably doesn't make sense to introduce a new debug temp. */
kono
parents:
diff changeset
732 if (where == DEBUG_TEMP_AFTER_WITH_REG && !uses->next)
kono
parents:
diff changeset
733 {
kono
parents:
diff changeset
734 rtx_insn *next = DF_REF_INSN (uses->use);
kono
parents:
diff changeset
735
kono
parents:
diff changeset
736 if (DEBUG_INSN_P (next) && reg == INSN_VAR_LOCATION_LOC (next))
kono
parents:
diff changeset
737 {
kono
parents:
diff changeset
738 XDELETE (uses);
kono
parents:
diff changeset
739 return 0;
kono
parents:
diff changeset
740 }
kono
parents:
diff changeset
741 }
kono
parents:
diff changeset
742
kono
parents:
diff changeset
743 if (!global)
kono
parents:
diff changeset
744 /* Create DEBUG_EXPR (and DEBUG_EXPR_DECL). */
kono
parents:
diff changeset
745 dval = make_debug_expr_from_rtl (reg);
kono
parents:
diff changeset
746
kono
parents:
diff changeset
747 /* Emit a debug bind insn before the insn in which reg dies. */
kono
parents:
diff changeset
748 bind = gen_rtx_VAR_LOCATION (GET_MODE (reg),
kono
parents:
diff changeset
749 DEBUG_EXPR_TREE_DECL (dval), breg,
kono
parents:
diff changeset
750 VAR_INIT_STATUS_INITIALIZED);
kono
parents:
diff changeset
751
kono
parents:
diff changeset
752 if (where == DEBUG_TEMP_AFTER_WITH_REG
kono
parents:
diff changeset
753 || where == DEBUG_TEMP_AFTER_WITH_REG_FORCE)
kono
parents:
diff changeset
754 bind = emit_debug_insn_after (bind, insn);
kono
parents:
diff changeset
755 else
kono
parents:
diff changeset
756 bind = emit_debug_insn_before (bind, insn);
kono
parents:
diff changeset
757 if (debug->to_rescan == NULL)
kono
parents:
diff changeset
758 debug->to_rescan = BITMAP_ALLOC (NULL);
kono
parents:
diff changeset
759 bitmap_set_bit (debug->to_rescan, INSN_UID (bind));
kono
parents:
diff changeset
760
kono
parents:
diff changeset
761 /* Adjust all uses. */
kono
parents:
diff changeset
762 while ((cur = uses))
kono
parents:
diff changeset
763 {
kono
parents:
diff changeset
764 if (GET_MODE (*DF_REF_REAL_LOC (cur->use)) == GET_MODE (reg))
kono
parents:
diff changeset
765 *DF_REF_REAL_LOC (cur->use) = dval;
kono
parents:
diff changeset
766 else
kono
parents:
diff changeset
767 *DF_REF_REAL_LOC (cur->use)
kono
parents:
diff changeset
768 = debug_lowpart_subreg (GET_MODE (*DF_REF_REAL_LOC (cur->use)), dval,
kono
parents:
diff changeset
769 GET_MODE (dval));
kono
parents:
diff changeset
770 /* ??? Should we simplify subreg of subreg? */
kono
parents:
diff changeset
771 bitmap_set_bit (debug->to_rescan, INSN_UID (DF_REF_INSN (cur->use)));
kono
parents:
diff changeset
772 uses = cur->next;
kono
parents:
diff changeset
773 XDELETE (cur);
kono
parents:
diff changeset
774 }
kono
parents:
diff changeset
775
kono
parents:
diff changeset
776 return 1;
kono
parents:
diff changeset
777 }