1 /* Scanning of rtl for dataflow analysis.
2 Copyright (C) 1999-2014 Free Software Foundation, Inc.
3 Originally contributed by Michael P. Hayes
4 (m.hayes@elec.canterbury.ac.nz, mhayes@redhat.com)
5 Major rewrite contributed by Danny Berlin (dberlin@dberlin.org)
6 and Kenneth Zadeck (zadeck@naturalbridge.com).
8 This file is part of GCC.
10 GCC is free software; you can redistribute it and/or modify it under
11 the terms of the GNU General Public License as published by the Free
12 Software Foundation; either version 3, or (at your option) any later
15 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
16 WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 You should have received a copy of the GNU General Public License
21 along with GCC; see the file COPYING3. If not see
22 <http://www.gnu.org/licenses/>. */
26 #include "coretypes.h"
30 #include "insn-config.h"
34 #include "alloc-pool.h"
36 #include "hard-reg-set.h"
37 #include "basic-block.h"
43 #include "target-def.h"
45 #include "emit-rtl.h" /* FIXME: Can go away once crtl is moved to rtl.h. */
48 typedef struct df_mw_hardreg
*df_mw_hardreg_ptr
;
52 #define HAVE_epilogue 0
55 #define HAVE_prologue 0
57 #ifndef HAVE_sibcall_epilogue
58 #define HAVE_sibcall_epilogue 0
62 #define EPILOGUE_USES(REGNO) 0
65 /* The following two macros free the vecs that hold either the refs or
66 the mw refs. They are a little tricky because the vec has 0
67 elements is special and is not to be freed. */
68 #define df_scan_free_ref_vec(V) \
74 #define df_scan_free_mws_vec(V) \
80 /* The set of hard registers in eliminables[i].from. */
82 static HARD_REG_SET elim_reg_set
;
84 /* Initialize ur_in and ur_out as if all hard registers were partially
87 struct df_collection_rec
89 auto_vec
<df_ref
, 128> def_vec
;
90 auto_vec
<df_ref
, 32> use_vec
;
91 auto_vec
<df_ref
, 32> eq_use_vec
;
92 auto_vec
<df_mw_hardreg_ptr
, 32> mw_vec
;
95 static df_ref df_null_ref_rec
[1];
96 static struct df_mw_hardreg
* df_null_mw_rec
[1];
98 static void df_ref_record (enum df_ref_class
, struct df_collection_rec
*,
100 basic_block
, struct df_insn_info
*,
101 enum df_ref_type
, int ref_flags
);
102 static void df_def_record_1 (struct df_collection_rec
*, rtx
*,
103 basic_block
, struct df_insn_info
*,
105 static void df_defs_record (struct df_collection_rec
*, rtx
,
106 basic_block
, struct df_insn_info
*,
108 static void df_uses_record (struct df_collection_rec
*,
109 rtx
*, enum df_ref_type
,
110 basic_block
, struct df_insn_info
*,
113 static void df_install_ref_incremental (df_ref
);
114 static df_ref
df_ref_create_structure (enum df_ref_class
,
115 struct df_collection_rec
*, rtx
, rtx
*,
116 basic_block
, struct df_insn_info
*,
117 enum df_ref_type
, int ref_flags
);
118 static void df_insn_refs_collect (struct df_collection_rec
*,
119 basic_block
, struct df_insn_info
*);
120 static void df_canonize_collection_rec (struct df_collection_rec
*);
122 static void df_get_regular_block_artificial_uses (bitmap
);
123 static void df_get_eh_block_artificial_uses (bitmap
);
125 static void df_record_entry_block_defs (bitmap
);
126 static void df_record_exit_block_uses (bitmap
);
127 static void df_get_exit_block_use_set (bitmap
);
128 static void df_get_entry_block_def_set (bitmap
);
129 static void df_grow_ref_info (struct df_ref_info
*, unsigned int);
130 static void df_ref_chain_delete_du_chain (df_ref
*);
131 static void df_ref_chain_delete (df_ref
*);
133 static void df_refs_add_to_chains (struct df_collection_rec
*,
134 basic_block
, rtx
, unsigned int);
136 static bool df_insn_refs_verify (struct df_collection_rec
*, basic_block
, rtx
, bool);
137 static void df_entry_block_defs_collect (struct df_collection_rec
*, bitmap
);
138 static void df_exit_block_uses_collect (struct df_collection_rec
*, bitmap
);
139 static void df_install_ref (df_ref
, struct df_reg_info
*,
140 struct df_ref_info
*, bool);
142 static int df_ref_compare (const void *, const void *);
143 static int df_mw_compare (const void *, const void *);
145 static void df_insn_info_delete (unsigned int);
147 /* Indexed by hardware reg number, is true if that register is ever
148 used in the current function.
150 In df-scan.c, this is set up to record the hard regs used
151 explicitly. Reload adds in the hard regs used for holding pseudo
152 regs. Final uses it to generate the code in the function prologue
153 and epilogue to save and restore registers as needed. */
155 static bool regs_ever_live
[FIRST_PSEUDO_REGISTER
];
157 /* Flags used to tell df_refs_add_to_chains() which vectors it should copy. */
158 static const unsigned int copy_defs
= 0x1;
159 static const unsigned int copy_uses
= 0x2;
160 static const unsigned int copy_eq_uses
= 0x4;
161 static const unsigned int copy_mw
= 0x8;
162 static const unsigned int copy_all
= copy_defs
| copy_uses
| copy_eq_uses
165 /*----------------------------------------------------------------------------
166 SCANNING DATAFLOW PROBLEM
168 There are several ways in which scanning looks just like the other
169 dataflow problems. It shares the all the mechanisms for local info
170 as well as basic block info. Where it differs is when and how often
171 it gets run. It also has no need for the iterative solver.
172 ----------------------------------------------------------------------------*/
174 /* Problem data for the scanning dataflow function. */
175 struct df_scan_problem_data
177 alloc_pool ref_base_pool
;
178 alloc_pool ref_artificial_pool
;
179 alloc_pool ref_regular_pool
;
180 alloc_pool insn_pool
;
182 alloc_pool mw_reg_pool
;
183 bitmap_obstack reg_bitmaps
;
184 bitmap_obstack insn_bitmaps
;
187 typedef struct df_scan_bb_info
*df_scan_bb_info_t
;
190 /* Internal function to shut down the scanning problem. */
192 df_scan_free_internal (void)
194 struct df_scan_problem_data
*problem_data
195 = (struct df_scan_problem_data
*) df_scan
->problem_data
;
199 /* The vectors that hold the refs are not pool allocated because
200 they come in many sizes. This makes them impossible to delete
202 for (i
= 0; i
< DF_INSN_SIZE (); i
++)
204 struct df_insn_info
*insn_info
= DF_INSN_UID_GET (i
);
205 /* Skip the insns that have no insn_info or have been
209 df_scan_free_ref_vec (insn_info
->defs
);
210 df_scan_free_ref_vec (insn_info
->uses
);
211 df_scan_free_ref_vec (insn_info
->eq_uses
);
212 df_scan_free_mws_vec (insn_info
->mw_hardregs
);
216 FOR_ALL_BB_FN (bb
, cfun
)
218 unsigned int bb_index
= bb
->index
;
219 struct df_scan_bb_info
*bb_info
= df_scan_get_bb_info (bb_index
);
222 df_scan_free_ref_vec (bb_info
->artificial_defs
);
223 df_scan_free_ref_vec (bb_info
->artificial_uses
);
227 free (df
->def_info
.refs
);
228 free (df
->def_info
.begin
);
229 free (df
->def_info
.count
);
230 memset (&df
->def_info
, 0, (sizeof (struct df_ref_info
)));
232 free (df
->use_info
.refs
);
233 free (df
->use_info
.begin
);
234 free (df
->use_info
.count
);
235 memset (&df
->use_info
, 0, (sizeof (struct df_ref_info
)));
241 free (df
->eq_use_regs
);
242 df
->eq_use_regs
= NULL
;
244 DF_REG_SIZE (df
) = 0;
250 free (df_scan
->block_info
);
251 df_scan
->block_info
= NULL
;
252 df_scan
->block_info_size
= 0;
254 bitmap_clear (&df
->hardware_regs_used
);
255 bitmap_clear (&df
->regular_block_artificial_uses
);
256 bitmap_clear (&df
->eh_block_artificial_uses
);
257 BITMAP_FREE (df
->entry_block_defs
);
258 BITMAP_FREE (df
->exit_block_uses
);
259 bitmap_clear (&df
->insns_to_delete
);
260 bitmap_clear (&df
->insns_to_rescan
);
261 bitmap_clear (&df
->insns_to_notes_rescan
);
263 free_alloc_pool (problem_data
->ref_base_pool
);
264 free_alloc_pool (problem_data
->ref_artificial_pool
);
265 free_alloc_pool (problem_data
->ref_regular_pool
);
266 free_alloc_pool (problem_data
->insn_pool
);
267 free_alloc_pool (problem_data
->reg_pool
);
268 free_alloc_pool (problem_data
->mw_reg_pool
);
269 bitmap_obstack_release (&problem_data
->reg_bitmaps
);
270 bitmap_obstack_release (&problem_data
->insn_bitmaps
);
271 free (df_scan
->problem_data
);
275 /* Free basic block info. */
278 df_scan_free_bb_info (basic_block bb
, void *vbb_info
)
280 struct df_scan_bb_info
*bb_info
= (struct df_scan_bb_info
*) vbb_info
;
281 unsigned int bb_index
= bb
->index
;
283 /* See if bb_info is initialized. */
284 if (bb_info
->artificial_defs
)
287 FOR_BB_INSNS (bb
, insn
)
290 df_insn_info_delete (INSN_UID (insn
));
293 if (bb_index
< df_scan
->block_info_size
)
294 bb_info
= df_scan_get_bb_info (bb_index
);
296 /* Get rid of any artificial uses or defs. */
297 if (bb_info
->artificial_defs
)
299 df_ref_chain_delete_du_chain (bb_info
->artificial_defs
);
300 df_ref_chain_delete_du_chain (bb_info
->artificial_uses
);
301 df_ref_chain_delete (bb_info
->artificial_defs
);
302 df_ref_chain_delete (bb_info
->artificial_uses
);
303 bb_info
->artificial_defs
= NULL
;
304 bb_info
->artificial_uses
= NULL
;
310 /* Allocate the problem data for the scanning problem. This should be
311 called when the problem is created or when the entire function is to
314 df_scan_alloc (bitmap all_blocks ATTRIBUTE_UNUSED
)
316 struct df_scan_problem_data
*problem_data
;
317 unsigned int insn_num
= get_max_uid () + 1;
318 unsigned int block_size
= 512;
321 /* Given the number of pools, this is really faster than tearing
323 if (df_scan
->problem_data
)
324 df_scan_free_internal ();
326 problem_data
= XNEW (struct df_scan_problem_data
);
327 df_scan
->problem_data
= problem_data
;
328 df_scan
->computed
= true;
330 problem_data
->ref_base_pool
331 = create_alloc_pool ("df_scan ref base",
332 sizeof (struct df_base_ref
), block_size
);
333 problem_data
->ref_artificial_pool
334 = create_alloc_pool ("df_scan ref artificial",
335 sizeof (struct df_artificial_ref
), block_size
);
336 problem_data
->ref_regular_pool
337 = create_alloc_pool ("df_scan ref regular",
338 sizeof (struct df_regular_ref
), block_size
);
339 problem_data
->insn_pool
340 = create_alloc_pool ("df_scan insn",
341 sizeof (struct df_insn_info
), block_size
);
342 problem_data
->reg_pool
343 = create_alloc_pool ("df_scan reg",
344 sizeof (struct df_reg_info
), block_size
);
345 problem_data
->mw_reg_pool
346 = create_alloc_pool ("df_scan mw_reg",
347 sizeof (struct df_mw_hardreg
), block_size
/ 16);
349 bitmap_obstack_initialize (&problem_data
->reg_bitmaps
);
350 bitmap_obstack_initialize (&problem_data
->insn_bitmaps
);
352 insn_num
+= insn_num
/ 4;
355 df_grow_insn_info ();
356 df_grow_bb_info (df_scan
);
358 FOR_ALL_BB_FN (bb
, cfun
)
360 unsigned int bb_index
= bb
->index
;
361 struct df_scan_bb_info
*bb_info
= df_scan_get_bb_info (bb_index
);
362 bb_info
->artificial_defs
= NULL
;
363 bb_info
->artificial_uses
= NULL
;
366 bitmap_initialize (&df
->hardware_regs_used
, &problem_data
->reg_bitmaps
);
367 bitmap_initialize (&df
->regular_block_artificial_uses
, &problem_data
->reg_bitmaps
);
368 bitmap_initialize (&df
->eh_block_artificial_uses
, &problem_data
->reg_bitmaps
);
369 df
->entry_block_defs
= BITMAP_ALLOC (&problem_data
->reg_bitmaps
);
370 df
->exit_block_uses
= BITMAP_ALLOC (&problem_data
->reg_bitmaps
);
371 bitmap_initialize (&df
->insns_to_delete
, &problem_data
->insn_bitmaps
);
372 bitmap_initialize (&df
->insns_to_rescan
, &problem_data
->insn_bitmaps
);
373 bitmap_initialize (&df
->insns_to_notes_rescan
, &problem_data
->insn_bitmaps
);
374 df_scan
->optional_p
= false;
378 /* Free all of the data associated with the scan problem. */
383 if (df_scan
->problem_data
)
384 df_scan_free_internal ();
386 if (df
->blocks_to_analyze
)
388 BITMAP_FREE (df
->blocks_to_analyze
);
389 df
->blocks_to_analyze
= NULL
;
395 /* Dump the preamble for DF_SCAN dump. */
397 df_scan_start_dump (FILE *file ATTRIBUTE_UNUSED
)
408 fprintf (file
, ";; invalidated by call \t");
409 df_print_regset (file
, regs_invalidated_by_call_regset
);
410 fprintf (file
, ";; hardware regs used \t");
411 df_print_regset (file
, &df
->hardware_regs_used
);
412 fprintf (file
, ";; regular block artificial uses \t");
413 df_print_regset (file
, &df
->regular_block_artificial_uses
);
414 fprintf (file
, ";; eh block artificial uses \t");
415 df_print_regset (file
, &df
->eh_block_artificial_uses
);
416 fprintf (file
, ";; entry block defs \t");
417 df_print_regset (file
, df
->entry_block_defs
);
418 fprintf (file
, ";; exit block uses \t");
419 df_print_regset (file
, df
->exit_block_uses
);
420 fprintf (file
, ";; regs ever live \t");
421 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
422 if (df_regs_ever_live_p (i
))
423 fprintf (file
, " %d[%s]", i
, reg_names
[i
]);
424 fprintf (file
, "\n;; ref usage \t");
426 for (i
= 0; i
< (int)df
->regs_inited
; i
++)
427 if (DF_REG_DEF_COUNT (i
) || DF_REG_USE_COUNT (i
) || DF_REG_EQ_USE_COUNT (i
))
429 const char * sep
= "";
431 fprintf (file
, "r%d={", i
);
432 if (DF_REG_DEF_COUNT (i
))
434 fprintf (file
, "%dd", DF_REG_DEF_COUNT (i
));
436 dcount
+= DF_REG_DEF_COUNT (i
);
438 if (DF_REG_USE_COUNT (i
))
440 fprintf (file
, "%s%du", sep
, DF_REG_USE_COUNT (i
));
442 ucount
+= DF_REG_USE_COUNT (i
);
444 if (DF_REG_EQ_USE_COUNT (i
))
446 fprintf (file
, "%s%de", sep
, DF_REG_EQ_USE_COUNT (i
));
447 ecount
+= DF_REG_EQ_USE_COUNT (i
);
449 fprintf (file
, "} ");
452 FOR_EACH_BB_FN (bb
, cfun
)
453 FOR_BB_INSNS (bb
, insn
)
462 fprintf (file
, "\n;; total ref usage %d{%dd,%du,%de}"
463 " in %d{%d regular + %d call} insns.\n",
464 dcount
+ ucount
+ ecount
, dcount
, ucount
, ecount
,
465 icount
+ ccount
, icount
, ccount
);
468 /* Dump the bb_info for a given basic block. */
470 df_scan_start_block (basic_block bb
, FILE *file
)
472 struct df_scan_bb_info
*bb_info
473 = df_scan_get_bb_info (bb
->index
);
477 fprintf (file
, ";; bb %d artificial_defs: ", bb
->index
);
478 df_refs_chain_dump (bb_info
->artificial_defs
, true, file
);
479 fprintf (file
, "\n;; bb %d artificial_uses: ", bb
->index
);
480 df_refs_chain_dump (bb_info
->artificial_uses
, true, file
);
481 fprintf (file
, "\n");
486 FOR_BB_INSNS (bb
, insn
)
488 df_insn_debug (insn
, false, file
);
493 static struct df_problem problem_SCAN
=
495 DF_SCAN
, /* Problem id. */
496 DF_NONE
, /* Direction. */
497 df_scan_alloc
, /* Allocate the problem specific data. */
498 NULL
, /* Reset global information. */
499 df_scan_free_bb_info
, /* Free basic block info. */
500 NULL
, /* Local compute function. */
501 NULL
, /* Init the solution specific data. */
502 NULL
, /* Iterative solver. */
503 NULL
, /* Confluence operator 0. */
504 NULL
, /* Confluence operator n. */
505 NULL
, /* Transfer function. */
506 NULL
, /* Finalize function. */
507 df_scan_free
, /* Free all of the problem information. */
508 NULL
, /* Remove this problem from the stack of dataflow problems. */
509 df_scan_start_dump
, /* Debugging. */
510 df_scan_start_block
, /* Debugging start block. */
511 NULL
, /* Debugging end block. */
512 NULL
, /* Debugging start insn. */
513 NULL
, /* Debugging end insn. */
514 NULL
, /* Incremental solution verify start. */
515 NULL
, /* Incremental solution verify end. */
516 NULL
, /* Dependent problem. */
517 sizeof (struct df_scan_bb_info
),/* Size of entry of block_info array. */
518 TV_DF_SCAN
, /* Timing variable. */
519 false /* Reset blocks on dropping out of blocks_to_analyze. */
523 /* Create a new DATAFLOW instance and add it to an existing instance
524 of DF. The returned structure is what is used to get at the
528 df_scan_add_problem (void)
530 df_add_problem (&problem_SCAN
);
534 /*----------------------------------------------------------------------------
535 Storage Allocation Utilities
536 ----------------------------------------------------------------------------*/
539 /* First, grow the reg_info information. If the current size is less than
540 the number of pseudos, grow to 25% more than the number of
543 Second, assure that all of the slots up to max_reg_num have been
544 filled with reg_info structures. */
547 df_grow_reg_info (void)
549 unsigned int max_reg
= max_reg_num ();
550 unsigned int new_size
= max_reg
;
551 struct df_scan_problem_data
*problem_data
552 = (struct df_scan_problem_data
*) df_scan
->problem_data
;
555 if (df
->regs_size
< new_size
)
557 new_size
+= new_size
/ 4;
558 df
->def_regs
= XRESIZEVEC (struct df_reg_info
*, df
->def_regs
, new_size
);
559 df
->use_regs
= XRESIZEVEC (struct df_reg_info
*, df
->use_regs
, new_size
);
560 df
->eq_use_regs
= XRESIZEVEC (struct df_reg_info
*, df
->eq_use_regs
,
562 df
->def_info
.begin
= XRESIZEVEC (unsigned, df
->def_info
.begin
, new_size
);
563 df
->def_info
.count
= XRESIZEVEC (unsigned, df
->def_info
.count
, new_size
);
564 df
->use_info
.begin
= XRESIZEVEC (unsigned, df
->use_info
.begin
, new_size
);
565 df
->use_info
.count
= XRESIZEVEC (unsigned, df
->use_info
.count
, new_size
);
566 df
->regs_size
= new_size
;
569 for (i
= df
->regs_inited
; i
< max_reg
; i
++)
571 struct df_reg_info
*reg_info
;
573 reg_info
= (struct df_reg_info
*) pool_alloc (problem_data
->reg_pool
);
574 memset (reg_info
, 0, sizeof (struct df_reg_info
));
575 df
->def_regs
[i
] = reg_info
;
576 reg_info
= (struct df_reg_info
*) pool_alloc (problem_data
->reg_pool
);
577 memset (reg_info
, 0, sizeof (struct df_reg_info
));
578 df
->use_regs
[i
] = reg_info
;
579 reg_info
= (struct df_reg_info
*) pool_alloc (problem_data
->reg_pool
);
580 memset (reg_info
, 0, sizeof (struct df_reg_info
));
581 df
->eq_use_regs
[i
] = reg_info
;
582 df
->def_info
.begin
[i
] = 0;
583 df
->def_info
.count
[i
] = 0;
584 df
->use_info
.begin
[i
] = 0;
585 df
->use_info
.count
[i
] = 0;
588 df
->regs_inited
= max_reg
;
592 /* Grow the ref information. */
595 df_grow_ref_info (struct df_ref_info
*ref_info
, unsigned int new_size
)
597 if (ref_info
->refs_size
< new_size
)
599 ref_info
->refs
= XRESIZEVEC (df_ref
, ref_info
->refs
, new_size
);
600 memset (ref_info
->refs
+ ref_info
->refs_size
, 0,
601 (new_size
- ref_info
->refs_size
) *sizeof (df_ref
));
602 ref_info
->refs_size
= new_size
;
607 /* Check and grow the ref information if necessary. This routine
608 guarantees total_size + BITMAP_ADDEND amount of entries in refs
609 array. It updates ref_info->refs_size only and does not change
610 ref_info->total_size. */
613 df_check_and_grow_ref_info (struct df_ref_info
*ref_info
,
614 unsigned bitmap_addend
)
616 if (ref_info
->refs_size
< ref_info
->total_size
+ bitmap_addend
)
618 int new_size
= ref_info
->total_size
+ bitmap_addend
;
619 new_size
+= ref_info
->total_size
/ 4;
620 df_grow_ref_info (ref_info
, new_size
);
625 /* Grow the ref information. If the current size is less than the
626 number of instructions, grow to 25% more than the number of
630 df_grow_insn_info (void)
632 unsigned int new_size
= get_max_uid () + 1;
633 if (DF_INSN_SIZE () < new_size
)
635 new_size
+= new_size
/ 4;
636 df
->insns
= XRESIZEVEC (struct df_insn_info
*, df
->insns
, new_size
);
637 memset (df
->insns
+ df
->insns_size
, 0,
638 (new_size
- DF_INSN_SIZE ()) *sizeof (struct df_insn_info
*));
639 DF_INSN_SIZE () = new_size
;
646 /*----------------------------------------------------------------------------
647 PUBLIC INTERFACES FOR SMALL GRAIN CHANGES TO SCANNING.
648 ----------------------------------------------------------------------------*/
650 /* Rescan all of the block_to_analyze or all of the blocks in the
651 function if df_set_blocks if blocks_to_analyze is NULL; */
654 df_scan_blocks (void)
658 df
->def_info
.ref_order
= DF_REF_ORDER_NO_TABLE
;
659 df
->use_info
.ref_order
= DF_REF_ORDER_NO_TABLE
;
661 df_get_regular_block_artificial_uses (&df
->regular_block_artificial_uses
);
662 df_get_eh_block_artificial_uses (&df
->eh_block_artificial_uses
);
664 bitmap_ior_into (&df
->eh_block_artificial_uses
,
665 &df
->regular_block_artificial_uses
);
667 /* ENTRY and EXIT blocks have special defs/uses. */
668 df_get_entry_block_def_set (df
->entry_block_defs
);
669 df_record_entry_block_defs (df
->entry_block_defs
);
670 df_get_exit_block_use_set (df
->exit_block_uses
);
671 df_record_exit_block_uses (df
->exit_block_uses
);
672 df_set_bb_dirty (BASIC_BLOCK_FOR_FN (cfun
, ENTRY_BLOCK
));
673 df_set_bb_dirty (BASIC_BLOCK_FOR_FN (cfun
, EXIT_BLOCK
));
676 FOR_EACH_BB_FN (bb
, cfun
)
678 unsigned int bb_index
= bb
->index
;
679 df_bb_refs_record (bb_index
, true);
683 /* Create new refs under address LOC within INSN. This function is
684 only used externally. REF_FLAGS must be either 0 or DF_REF_IN_NOTE,
685 depending on whether LOC is inside PATTERN (INSN) or a note. */
688 df_uses_create (rtx
*loc
, rtx insn
, int ref_flags
)
690 gcc_assert (!(ref_flags
& ~DF_REF_IN_NOTE
));
691 df_uses_record (NULL
, loc
, DF_REF_REG_USE
,
692 BLOCK_FOR_INSN (insn
),
693 DF_INSN_INFO_GET (insn
),
697 /* Create a new ref of type DF_REF_TYPE for register REG at address
698 LOC within INSN of BB. This function is only used externally. */
701 df_ref_create (rtx reg
, rtx
*loc
, rtx insn
,
703 enum df_ref_type ref_type
,
706 enum df_ref_class cl
;
710 /* You cannot hack artificial refs. */
718 return df_ref_create_structure (cl
, NULL
, reg
, loc
, bb
,
719 DF_INSN_INFO_GET (insn
),
720 ref_type
, ref_flags
);
724 df_install_ref_incremental (df_ref ref
)
726 struct df_reg_info
**reg_info
;
727 struct df_ref_info
*ref_info
;
729 df_ref
**ref_rec_ptr
;
730 unsigned int count
= 0;
733 rtx insn
= DF_REF_INSN (ref
);
734 basic_block bb
= BLOCK_FOR_INSN (insn
);
736 if (DF_REF_REG_DEF_P (ref
))
738 reg_info
= df
->def_regs
;
739 ref_info
= &df
->def_info
;
740 ref_rec_ptr
= &DF_INSN_DEFS (insn
);
741 add_to_table
= ref_info
->ref_order
!= DF_REF_ORDER_NO_TABLE
;
743 else if (DF_REF_FLAGS (ref
) & DF_REF_IN_NOTE
)
745 reg_info
= df
->eq_use_regs
;
746 ref_info
= &df
->use_info
;
747 ref_rec_ptr
= &DF_INSN_EQ_USES (insn
);
748 switch (ref_info
->ref_order
)
750 case DF_REF_ORDER_UNORDERED_WITH_NOTES
:
751 case DF_REF_ORDER_BY_REG_WITH_NOTES
:
752 case DF_REF_ORDER_BY_INSN_WITH_NOTES
:
756 add_to_table
= false;
762 reg_info
= df
->use_regs
;
763 ref_info
= &df
->use_info
;
764 ref_rec_ptr
= &DF_INSN_USES (insn
);
765 add_to_table
= ref_info
->ref_order
!= DF_REF_ORDER_NO_TABLE
;
768 /* Do not add if ref is not in the right blocks. */
769 if (add_to_table
&& df
->analyze_subset
)
770 add_to_table
= bitmap_bit_p (df
->blocks_to_analyze
, bb
->index
);
772 df_install_ref (ref
, reg_info
[DF_REF_REGNO (ref
)], ref_info
, add_to_table
);
775 switch (ref_info
->ref_order
)
777 case DF_REF_ORDER_UNORDERED_WITH_NOTES
:
778 case DF_REF_ORDER_BY_REG_WITH_NOTES
:
779 case DF_REF_ORDER_BY_INSN_WITH_NOTES
:
780 ref_info
->ref_order
= DF_REF_ORDER_UNORDERED_WITH_NOTES
;
783 ref_info
->ref_order
= DF_REF_ORDER_UNORDERED
;
787 ref_rec
= *ref_rec_ptr
;
794 ref_rec
= *ref_rec_ptr
;
797 ref_rec
= XRESIZEVEC (df_ref
, ref_rec
, count
+2);
798 *ref_rec_ptr
= ref_rec
;
799 ref_rec
[count
] = ref
;
800 ref_rec
[count
+1] = NULL
;
801 qsort (ref_rec
, count
+ 1, sizeof (df_ref
), df_ref_compare
);
805 df_ref
*ref_rec
= XNEWVEC (df_ref
, 2);
808 *ref_rec_ptr
= ref_rec
;
814 fprintf (dump_file
, "adding ref ");
815 df_ref_debug (ref
, dump_file
);
818 /* By adding the ref directly, df_insn_rescan my not find any
819 differences even though the block will have changed. So we need
820 to mark the block dirty ourselves. */
821 if (!DEBUG_INSN_P (DF_REF_INSN (ref
)))
822 df_set_bb_dirty (bb
);
827 /*----------------------------------------------------------------------------
828 UTILITIES TO CREATE AND DESTROY REFS AND CHAINS.
829 ----------------------------------------------------------------------------*/
832 df_free_ref (df_ref ref
)
834 struct df_scan_problem_data
*problem_data
835 = (struct df_scan_problem_data
*) df_scan
->problem_data
;
837 switch (DF_REF_CLASS (ref
))
840 pool_free (problem_data
->ref_base_pool
, ref
);
843 case DF_REF_ARTIFICIAL
:
844 pool_free (problem_data
->ref_artificial_pool
, ref
);
848 pool_free (problem_data
->ref_regular_pool
, ref
);
854 /* Unlink and delete REF at the reg_use, reg_eq_use or reg_def chain.
855 Also delete the def-use or use-def chain if it exists. */
858 df_reg_chain_unlink (df_ref ref
)
860 df_ref next
= DF_REF_NEXT_REG (ref
);
861 df_ref prev
= DF_REF_PREV_REG (ref
);
862 int id
= DF_REF_ID (ref
);
863 struct df_reg_info
*reg_info
;
866 if (DF_REF_REG_DEF_P (ref
))
868 int regno
= DF_REF_REGNO (ref
);
869 reg_info
= DF_REG_DEF_GET (regno
);
870 refs
= df
->def_info
.refs
;
874 if (DF_REF_FLAGS (ref
) & DF_REF_IN_NOTE
)
876 reg_info
= DF_REG_EQ_USE_GET (DF_REF_REGNO (ref
));
877 switch (df
->use_info
.ref_order
)
879 case DF_REF_ORDER_UNORDERED_WITH_NOTES
:
880 case DF_REF_ORDER_BY_REG_WITH_NOTES
:
881 case DF_REF_ORDER_BY_INSN_WITH_NOTES
:
882 refs
= df
->use_info
.refs
;
890 reg_info
= DF_REG_USE_GET (DF_REF_REGNO (ref
));
891 refs
= df
->use_info
.refs
;
897 if (df
->analyze_subset
)
899 if (bitmap_bit_p (df
->blocks_to_analyze
, DF_REF_BBNO (ref
)))
906 /* Delete any def-use or use-def chains that start here. It is
907 possible that there is trash in this field. This happens for
908 insns that have been deleted when rescanning has been deferred
909 and the chain problem has also been deleted. The chain tear down
910 code skips deleted insns. */
911 if (df_chain
&& DF_REF_CHAIN (ref
))
912 df_chain_unlink (ref
);
915 if (DF_REF_FLAGS_IS_SET (ref
, DF_HARD_REG_LIVE
))
917 gcc_assert (DF_REF_REGNO (ref
) < FIRST_PSEUDO_REGISTER
);
918 df
->hard_regs_live_count
[DF_REF_REGNO (ref
)]--;
921 /* Unlink from the reg chain. If there is no prev, this is the
922 first of the list. If not, just join the next and prev. */
924 DF_REF_NEXT_REG (prev
) = next
;
927 gcc_assert (reg_info
->reg_chain
== ref
);
928 reg_info
->reg_chain
= next
;
931 DF_REF_PREV_REG (next
) = prev
;
937 /* Remove REF from VEC. */
940 df_ref_compress_rec (df_ref
**vec_ptr
, df_ref ref
)
942 df_ref
*vec
= *vec_ptr
;
946 while (*vec
&& *vec
!= ref
)
958 *vec_ptr
= df_null_ref_rec
;
963 /* Unlink REF from all def-use/use-def chains, etc. */
966 df_ref_remove (df_ref ref
)
971 fprintf (dump_file
, "removing ref ");
972 df_ref_debug (ref
, dump_file
);
976 if (DF_REF_REG_DEF_P (ref
))
978 if (DF_REF_IS_ARTIFICIAL (ref
))
980 struct df_scan_bb_info
*bb_info
981 = df_scan_get_bb_info (DF_REF_BBNO (ref
));
982 df_ref_compress_rec (&bb_info
->artificial_defs
, ref
);
986 unsigned int uid
= DF_REF_INSN_UID (ref
);
987 struct df_insn_info
*insn_rec
= DF_INSN_UID_GET (uid
);
988 df_ref_compress_rec (&insn_rec
->defs
, ref
);
993 if (DF_REF_IS_ARTIFICIAL (ref
))
995 struct df_scan_bb_info
*bb_info
996 = df_scan_get_bb_info (DF_REF_BBNO (ref
));
997 df_ref_compress_rec (&bb_info
->artificial_uses
, ref
);
1001 unsigned int uid
= DF_REF_INSN_UID (ref
);
1002 struct df_insn_info
*insn_rec
= DF_INSN_UID_GET (uid
);
1004 if (DF_REF_FLAGS (ref
) & DF_REF_IN_NOTE
)
1005 df_ref_compress_rec (&insn_rec
->eq_uses
, ref
);
1007 df_ref_compress_rec (&insn_rec
->uses
, ref
);
1011 /* By deleting the ref directly, df_insn_rescan my not find any
1012 differences even though the block will have changed. So we need
1013 to mark the block dirty ourselves. */
1014 if (!DEBUG_INSN_P (DF_REF_INSN (ref
)))
1015 df_set_bb_dirty (DF_REF_BB (ref
));
1016 df_reg_chain_unlink (ref
);
1020 /* Create the insn record for INSN. If there was one there, zero it
1023 struct df_insn_info
*
1024 df_insn_create_insn_record (rtx insn
)
1026 struct df_scan_problem_data
*problem_data
1027 = (struct df_scan_problem_data
*) df_scan
->problem_data
;
1028 struct df_insn_info
*insn_rec
;
1030 df_grow_insn_info ();
1031 insn_rec
= DF_INSN_INFO_GET (insn
);
1034 insn_rec
= (struct df_insn_info
*) pool_alloc (problem_data
->insn_pool
);
1035 DF_INSN_INFO_SET (insn
, insn_rec
);
1037 memset (insn_rec
, 0, sizeof (struct df_insn_info
));
1038 insn_rec
->insn
= insn
;
1043 /* Delete all du chain (DF_REF_CHAIN()) of all refs in the ref chain. */
1046 df_ref_chain_delete_du_chain (df_ref
*ref_rec
)
1050 df_ref ref
= *ref_rec
;
1051 /* CHAIN is allocated by DF_CHAIN. So make sure to
1052 pass df_scan instance for the problem. */
1053 if (DF_REF_CHAIN (ref
))
1054 df_chain_unlink (ref
);
1060 /* Delete all refs in the ref chain. */
1063 df_ref_chain_delete (df_ref
*ref_rec
)
1065 df_ref
*start
= ref_rec
;
1068 df_reg_chain_unlink (*ref_rec
);
1072 /* If the list is empty, it has a special shared element that is not
1079 /* Delete the hardreg chain. */
1082 df_mw_hardreg_chain_delete (struct df_mw_hardreg
**hardregs
)
1084 struct df_scan_problem_data
*problem_data
;
1089 problem_data
= (struct df_scan_problem_data
*) df_scan
->problem_data
;
1093 pool_free (problem_data
->mw_reg_pool
, *hardregs
);
1099 /* Delete all of the refs information from the insn with UID.
1100 Internal helper for df_insn_delete, df_insn_rescan, and other
1101 df-scan routines that don't have to work in deferred mode
1102 and do not have to mark basic blocks for re-processing. */
1105 df_insn_info_delete (unsigned int uid
)
1107 struct df_insn_info
*insn_info
= DF_INSN_UID_SAFE_GET (uid
);
1109 bitmap_clear_bit (&df
->insns_to_delete
, uid
);
1110 bitmap_clear_bit (&df
->insns_to_rescan
, uid
);
1111 bitmap_clear_bit (&df
->insns_to_notes_rescan
, uid
);
1114 struct df_scan_problem_data
*problem_data
1115 = (struct df_scan_problem_data
*) df_scan
->problem_data
;
1117 /* In general, notes do not have the insn_info fields
1118 initialized. However, combine deletes insns by changing them
1119 to notes. How clever. So we cannot just check if it is a
1120 valid insn before short circuiting this code, we need to see
1121 if we actually initialized it. */
1122 if (insn_info
->defs
)
1124 df_mw_hardreg_chain_delete (insn_info
->mw_hardregs
);
1128 df_ref_chain_delete_du_chain (insn_info
->defs
);
1129 df_ref_chain_delete_du_chain (insn_info
->uses
);
1130 df_ref_chain_delete_du_chain (insn_info
->eq_uses
);
1133 df_ref_chain_delete (insn_info
->defs
);
1134 df_ref_chain_delete (insn_info
->uses
);
1135 df_ref_chain_delete (insn_info
->eq_uses
);
1136 df_scan_free_mws_vec (insn_info
->mw_hardregs
);
1138 pool_free (problem_data
->insn_pool
, insn_info
);
1139 DF_INSN_UID_SET (uid
, NULL
);
1143 /* Delete all of the refs information from INSN, either right now
1144 or marked for later in deferred mode. */
1147 df_insn_delete (rtx insn
)
1152 gcc_checking_assert (INSN_P (insn
));
1157 uid
= INSN_UID (insn
);
1158 bb
= BLOCK_FOR_INSN (insn
);
1160 /* ??? bb can be NULL after pass_free_cfg. At that point, DF should
1161 not exist anymore (as mentioned in df-core.c: "The only requirement
1162 [for DF] is that there be a correct control flow graph." Clearly
1163 that isn't the case after pass_free_cfg. But DF is freed much later
1164 because some back-ends want to use DF info even though the CFG is
1165 already gone. It's not clear to me whether that is safe, actually.
1166 In any case, we expect BB to be non-NULL at least up to register
1167 allocation, so disallow a non-NULL BB up to there. Not perfect
1168 but better than nothing... */
1169 gcc_checking_assert (bb
!= NULL
|| reload_completed
);
1171 df_grow_bb_info (df_scan
);
1172 df_grow_reg_info ();
1174 /* The block must be marked as dirty now, rather than later as in
1175 df_insn_rescan and df_notes_rescan because it may not be there at
1176 rescanning time and the mark would blow up.
1177 DEBUG_INSNs do not make a block's data flow solution dirty (at
1178 worst the LUIDs are no longer contiguous). */
1179 if (bb
!= NULL
&& NONDEBUG_INSN_P (insn
))
1180 df_set_bb_dirty (bb
);
1182 /* The client has deferred rescanning. */
1183 if (df
->changeable_flags
& DF_DEFER_INSN_RESCAN
)
1185 struct df_insn_info
*insn_info
= DF_INSN_UID_SAFE_GET (uid
);
1188 bitmap_clear_bit (&df
->insns_to_rescan
, uid
);
1189 bitmap_clear_bit (&df
->insns_to_notes_rescan
, uid
);
1190 bitmap_set_bit (&df
->insns_to_delete
, uid
);
1193 fprintf (dump_file
, "deferring deletion of insn with uid = %d.\n", uid
);
1198 fprintf (dump_file
, "deleting insn with uid = %d.\n", uid
);
1200 df_insn_info_delete (uid
);
1204 /* Free all of the refs and the mw_hardregs in COLLECTION_REC. */
1207 df_free_collection_rec (struct df_collection_rec
*collection_rec
)
1210 struct df_scan_problem_data
*problem_data
1211 = (struct df_scan_problem_data
*) df_scan
->problem_data
;
1213 struct df_mw_hardreg
*mw
;
1215 FOR_EACH_VEC_ELT (collection_rec
->def_vec
, ix
, ref
)
1217 FOR_EACH_VEC_ELT (collection_rec
->use_vec
, ix
, ref
)
1219 FOR_EACH_VEC_ELT (collection_rec
->eq_use_vec
, ix
, ref
)
1221 FOR_EACH_VEC_ELT (collection_rec
->mw_vec
, ix
, mw
)
1222 pool_free (problem_data
->mw_reg_pool
, mw
);
1224 collection_rec
->def_vec
.release ();
1225 collection_rec
->use_vec
.release ();
1226 collection_rec
->eq_use_vec
.release ();
1227 collection_rec
->mw_vec
.release ();
1230 /* Rescan INSN. Return TRUE if the rescanning produced any changes. */
1233 df_insn_rescan (rtx insn
)
1235 unsigned int uid
= INSN_UID (insn
);
1236 struct df_insn_info
*insn_info
= NULL
;
1237 basic_block bb
= BLOCK_FOR_INSN (insn
);
1238 struct df_collection_rec collection_rec
;
1240 if ((!df
) || (!INSN_P (insn
)))
1246 fprintf (dump_file
, "no bb for insn with uid = %d.\n", uid
);
1250 /* The client has disabled rescanning and plans to do it itself. */
1251 if (df
->changeable_flags
& DF_NO_INSN_RESCAN
)
1254 df_grow_bb_info (df_scan
);
1255 df_grow_reg_info ();
1257 insn_info
= DF_INSN_UID_SAFE_GET (uid
);
1259 /* The client has deferred rescanning. */
1260 if (df
->changeable_flags
& DF_DEFER_INSN_RESCAN
)
1264 insn_info
= df_insn_create_insn_record (insn
);
1265 insn_info
->defs
= df_null_ref_rec
;
1266 insn_info
->uses
= df_null_ref_rec
;
1267 insn_info
->eq_uses
= df_null_ref_rec
;
1268 insn_info
->mw_hardregs
= df_null_mw_rec
;
1271 fprintf (dump_file
, "deferring rescan insn with uid = %d.\n", uid
);
1273 bitmap_clear_bit (&df
->insns_to_delete
, uid
);
1274 bitmap_clear_bit (&df
->insns_to_notes_rescan
, uid
);
1275 bitmap_set_bit (&df
->insns_to_rescan
, INSN_UID (insn
));
1279 bitmap_clear_bit (&df
->insns_to_delete
, uid
);
1280 bitmap_clear_bit (&df
->insns_to_rescan
, uid
);
1281 bitmap_clear_bit (&df
->insns_to_notes_rescan
, uid
);
1285 bool the_same
= df_insn_refs_verify (&collection_rec
, bb
, insn
, false);
1286 /* If there's no change, return false. */
1289 df_free_collection_rec (&collection_rec
);
1291 fprintf (dump_file
, "verify found no changes in insn with uid = %d.\n", uid
);
1295 fprintf (dump_file
, "rescanning insn with uid = %d.\n", uid
);
1297 /* There's change - we need to delete the existing info.
1298 Since the insn isn't moved, we can salvage its LUID. */
1299 luid
= DF_INSN_LUID (insn
);
1300 df_insn_info_delete (uid
);
1301 df_insn_create_insn_record (insn
);
1302 DF_INSN_LUID (insn
) = luid
;
1306 struct df_insn_info
*insn_info
= df_insn_create_insn_record (insn
);
1307 df_insn_refs_collect (&collection_rec
, bb
, insn_info
);
1309 fprintf (dump_file
, "scanning new insn with uid = %d.\n", uid
);
1312 df_refs_add_to_chains (&collection_rec
, bb
, insn
, copy_all
);
1313 if (!DEBUG_INSN_P (insn
))
1314 df_set_bb_dirty (bb
);
1319 /* Same as df_insn_rescan, but don't mark the basic block as
1323 df_insn_rescan_debug_internal (rtx insn
)
1325 unsigned int uid
= INSN_UID (insn
);
1326 struct df_insn_info
*insn_info
;
1328 gcc_assert (DEBUG_INSN_P (insn
)
1329 && VAR_LOC_UNKNOWN_P (INSN_VAR_LOCATION_LOC (insn
)));
1334 insn_info
= DF_INSN_UID_SAFE_GET (INSN_UID (insn
));
1339 fprintf (dump_file
, "deleting debug_insn with uid = %d.\n", uid
);
1341 bitmap_clear_bit (&df
->insns_to_delete
, uid
);
1342 bitmap_clear_bit (&df
->insns_to_rescan
, uid
);
1343 bitmap_clear_bit (&df
->insns_to_notes_rescan
, uid
);
1345 if (!insn_info
->defs
)
1348 if (insn_info
->defs
== df_null_ref_rec
1349 && insn_info
->uses
== df_null_ref_rec
1350 && insn_info
->eq_uses
== df_null_ref_rec
1351 && insn_info
->mw_hardregs
== df_null_mw_rec
)
1354 df_mw_hardreg_chain_delete (insn_info
->mw_hardregs
);
1358 df_ref_chain_delete_du_chain (insn_info
->defs
);
1359 df_ref_chain_delete_du_chain (insn_info
->uses
);
1360 df_ref_chain_delete_du_chain (insn_info
->eq_uses
);
1363 df_ref_chain_delete (insn_info
->defs
);
1364 df_ref_chain_delete (insn_info
->uses
);
1365 df_ref_chain_delete (insn_info
->eq_uses
);
1366 df_scan_free_mws_vec (insn_info
->mw_hardregs
);
1368 insn_info
->defs
= df_null_ref_rec
;
1369 insn_info
->uses
= df_null_ref_rec
;
1370 insn_info
->eq_uses
= df_null_ref_rec
;
1371 insn_info
->mw_hardregs
= df_null_mw_rec
;
1377 /* Rescan all of the insns in the function. Note that the artificial
1378 uses and defs are not touched. This function will destroy def-use
1379 or use-def chains. */
1382 df_insn_rescan_all (void)
1384 bool no_insn_rescan
= false;
1385 bool defer_insn_rescan
= false;
1391 bitmap_initialize (&tmp
, &df_bitmap_obstack
);
1393 if (df
->changeable_flags
& DF_NO_INSN_RESCAN
)
1395 df_clear_flags (DF_NO_INSN_RESCAN
);
1396 no_insn_rescan
= true;
1399 if (df
->changeable_flags
& DF_DEFER_INSN_RESCAN
)
1401 df_clear_flags (DF_DEFER_INSN_RESCAN
);
1402 defer_insn_rescan
= true;
1405 bitmap_copy (&tmp
, &df
->insns_to_delete
);
1406 EXECUTE_IF_SET_IN_BITMAP (&tmp
, 0, uid
, bi
)
1408 struct df_insn_info
*insn_info
= DF_INSN_UID_SAFE_GET (uid
);
1410 df_insn_info_delete (uid
);
1413 bitmap_clear (&tmp
);
1414 bitmap_clear (&df
->insns_to_delete
);
1415 bitmap_clear (&df
->insns_to_rescan
);
1416 bitmap_clear (&df
->insns_to_notes_rescan
);
1418 FOR_EACH_BB_FN (bb
, cfun
)
1421 FOR_BB_INSNS (bb
, insn
)
1423 df_insn_rescan (insn
);
1428 df_set_flags (DF_NO_INSN_RESCAN
);
1429 if (defer_insn_rescan
)
1430 df_set_flags (DF_DEFER_INSN_RESCAN
);
1434 /* Process all of the deferred rescans or deletions. */
1437 df_process_deferred_rescans (void)
1439 bool no_insn_rescan
= false;
1440 bool defer_insn_rescan
= false;
1445 bitmap_initialize (&tmp
, &df_bitmap_obstack
);
1447 if (df
->changeable_flags
& DF_NO_INSN_RESCAN
)
1449 df_clear_flags (DF_NO_INSN_RESCAN
);
1450 no_insn_rescan
= true;
1453 if (df
->changeable_flags
& DF_DEFER_INSN_RESCAN
)
1455 df_clear_flags (DF_DEFER_INSN_RESCAN
);
1456 defer_insn_rescan
= true;
1460 fprintf (dump_file
, "starting the processing of deferred insns\n");
1462 bitmap_copy (&tmp
, &df
->insns_to_delete
);
1463 EXECUTE_IF_SET_IN_BITMAP (&tmp
, 0, uid
, bi
)
1465 struct df_insn_info
*insn_info
= DF_INSN_UID_SAFE_GET (uid
);
1467 df_insn_info_delete (uid
);
1470 bitmap_copy (&tmp
, &df
->insns_to_rescan
);
1471 EXECUTE_IF_SET_IN_BITMAP (&tmp
, 0, uid
, bi
)
1473 struct df_insn_info
*insn_info
= DF_INSN_UID_SAFE_GET (uid
);
1475 df_insn_rescan (insn_info
->insn
);
1478 bitmap_copy (&tmp
, &df
->insns_to_notes_rescan
);
1479 EXECUTE_IF_SET_IN_BITMAP (&tmp
, 0, uid
, bi
)
1481 struct df_insn_info
*insn_info
= DF_INSN_UID_SAFE_GET (uid
);
1483 df_notes_rescan (insn_info
->insn
);
1487 fprintf (dump_file
, "ending the processing of deferred insns\n");
1489 bitmap_clear (&tmp
);
1490 bitmap_clear (&df
->insns_to_delete
);
1491 bitmap_clear (&df
->insns_to_rescan
);
1492 bitmap_clear (&df
->insns_to_notes_rescan
);
1495 df_set_flags (DF_NO_INSN_RESCAN
);
1496 if (defer_insn_rescan
)
1497 df_set_flags (DF_DEFER_INSN_RESCAN
);
1499 /* If someone changed regs_ever_live during this pass, fix up the
1500 entry and exit blocks. */
1501 if (df
->redo_entry_and_exit
)
1503 df_update_entry_exit_and_calls ();
1504 df
->redo_entry_and_exit
= false;
1509 /* Count the number of refs. Include the defs if INCLUDE_DEFS. Include
1510 the uses if INCLUDE_USES. Include the eq_uses if
1514 df_count_refs (bool include_defs
, bool include_uses
,
1515 bool include_eq_uses
)
1519 unsigned int m
= df
->regs_inited
;
1521 for (regno
= 0; regno
< m
; regno
++)
1524 size
+= DF_REG_DEF_COUNT (regno
);
1526 size
+= DF_REG_USE_COUNT (regno
);
1527 if (include_eq_uses
)
1528 size
+= DF_REG_EQ_USE_COUNT (regno
);
1534 /* Take build ref table for either the uses or defs from the reg-use
1535 or reg-def chains. This version processes the refs in reg order
1536 which is likely to be best if processing the whole function. */
1539 df_reorganize_refs_by_reg_by_reg (struct df_ref_info
*ref_info
,
1542 bool include_eq_uses
)
1544 unsigned int m
= df
->regs_inited
;
1546 unsigned int offset
= 0;
1549 if (df
->changeable_flags
& DF_NO_HARD_REGS
)
1551 start
= FIRST_PSEUDO_REGISTER
;
1552 memset (ref_info
->begin
, 0, sizeof (int) * FIRST_PSEUDO_REGISTER
);
1553 memset (ref_info
->count
, 0, sizeof (int) * FIRST_PSEUDO_REGISTER
);
1558 ref_info
->total_size
1559 = df_count_refs (include_defs
, include_uses
, include_eq_uses
);
1561 df_check_and_grow_ref_info (ref_info
, 1);
1563 for (regno
= start
; regno
< m
; regno
++)
1566 ref_info
->begin
[regno
] = offset
;
1569 df_ref ref
= DF_REG_DEF_CHAIN (regno
);
1572 ref_info
->refs
[offset
] = ref
;
1573 DF_REF_ID (ref
) = offset
++;
1575 ref
= DF_REF_NEXT_REG (ref
);
1576 gcc_checking_assert (offset
< ref_info
->refs_size
);
1581 df_ref ref
= DF_REG_USE_CHAIN (regno
);
1584 ref_info
->refs
[offset
] = ref
;
1585 DF_REF_ID (ref
) = offset
++;
1587 ref
= DF_REF_NEXT_REG (ref
);
1588 gcc_checking_assert (offset
< ref_info
->refs_size
);
1591 if (include_eq_uses
)
1593 df_ref ref
= DF_REG_EQ_USE_CHAIN (regno
);
1596 ref_info
->refs
[offset
] = ref
;
1597 DF_REF_ID (ref
) = offset
++;
1599 ref
= DF_REF_NEXT_REG (ref
);
1600 gcc_checking_assert (offset
< ref_info
->refs_size
);
1603 ref_info
->count
[regno
] = count
;
1606 /* The bitmap size is not decremented when refs are deleted. So
1607 reset it now that we have squished out all of the empty
1609 ref_info
->table_size
= offset
;
1613 /* Take build ref table for either the uses or defs from the reg-use
1614 or reg-def chains. This version processes the refs in insn order
1615 which is likely to be best if processing some segment of the
1619 df_reorganize_refs_by_reg_by_insn (struct df_ref_info
*ref_info
,
1622 bool include_eq_uses
)
1625 unsigned int bb_index
;
1626 unsigned int m
= df
->regs_inited
;
1627 unsigned int offset
= 0;
1630 = (df
->changeable_flags
& DF_NO_HARD_REGS
) ? FIRST_PSEUDO_REGISTER
: 0;
1632 memset (ref_info
->begin
, 0, sizeof (int) * df
->regs_inited
);
1633 memset (ref_info
->count
, 0, sizeof (int) * df
->regs_inited
);
1635 ref_info
->total_size
= df_count_refs (include_defs
, include_uses
, include_eq_uses
);
1636 df_check_and_grow_ref_info (ref_info
, 1);
1638 EXECUTE_IF_SET_IN_BITMAP (df
->blocks_to_analyze
, 0, bb_index
, bi
)
1640 basic_block bb
= BASIC_BLOCK_FOR_FN (cfun
, bb_index
);
1646 for (ref_rec
= df_get_artificial_defs (bb_index
); *ref_rec
; ref_rec
++)
1648 unsigned int regno
= DF_REF_REGNO (*ref_rec
);
1649 ref_info
->count
[regno
]++;
1652 for (ref_rec
= df_get_artificial_uses (bb_index
); *ref_rec
; ref_rec
++)
1654 unsigned int regno
= DF_REF_REGNO (*ref_rec
);
1655 ref_info
->count
[regno
]++;
1658 FOR_BB_INSNS (bb
, insn
)
1662 struct df_insn_info
*insn_info
= DF_INSN_INFO_GET (insn
);
1665 FOR_EACH_INSN_INFO_DEF (def
, insn_info
)
1667 unsigned int regno
= DF_REF_REGNO (def
);
1668 ref_info
->count
[regno
]++;
1671 FOR_EACH_INSN_INFO_USE (use
, insn_info
)
1673 unsigned int regno
= DF_REF_REGNO (use
);
1674 ref_info
->count
[regno
]++;
1676 if (include_eq_uses
)
1677 FOR_EACH_INSN_INFO_EQ_USE (use
, insn_info
)
1679 unsigned int regno
= DF_REF_REGNO (use
);
1680 ref_info
->count
[regno
]++;
1686 for (r
= start
; r
< m
; r
++)
1688 ref_info
->begin
[r
] = offset
;
1689 offset
+= ref_info
->count
[r
];
1690 ref_info
->count
[r
] = 0;
1693 EXECUTE_IF_SET_IN_BITMAP (df
->blocks_to_analyze
, 0, bb_index
, bi
)
1695 basic_block bb
= BASIC_BLOCK_FOR_FN (cfun
, bb_index
);
1701 for (ref_rec
= df_get_artificial_defs (bb_index
); *ref_rec
; ref_rec
++)
1703 df_ref ref
= *ref_rec
;
1704 unsigned int regno
= DF_REF_REGNO (ref
);
1708 = ref_info
->begin
[regno
] + ref_info
->count
[regno
]++;
1709 DF_REF_ID (ref
) = id
;
1710 ref_info
->refs
[id
] = ref
;
1714 for (ref_rec
= df_get_artificial_uses (bb_index
); *ref_rec
; ref_rec
++)
1716 df_ref ref
= *ref_rec
;
1717 unsigned int regno
= DF_REF_REGNO (ref
);
1721 = ref_info
->begin
[regno
] + ref_info
->count
[regno
]++;
1722 DF_REF_ID (ref
) = id
;
1723 ref_info
->refs
[id
] = ref
;
1727 FOR_BB_INSNS (bb
, insn
)
1731 struct df_insn_info
*insn_info
= DF_INSN_INFO_GET (insn
);
1734 FOR_EACH_INSN_INFO_DEF (def
, insn_info
)
1736 unsigned int regno
= DF_REF_REGNO (def
);
1740 = ref_info
->begin
[regno
] + ref_info
->count
[regno
]++;
1741 DF_REF_ID (def
) = id
;
1742 ref_info
->refs
[id
] = def
;
1746 FOR_EACH_INSN_INFO_USE (use
, insn_info
)
1748 unsigned int regno
= DF_REF_REGNO (use
);
1752 = ref_info
->begin
[regno
] + ref_info
->count
[regno
]++;
1753 DF_REF_ID (use
) = id
;
1754 ref_info
->refs
[id
] = use
;
1757 if (include_eq_uses
)
1758 FOR_EACH_INSN_INFO_EQ_USE (use
, insn_info
)
1760 unsigned int regno
= DF_REF_REGNO (use
);
1764 = ref_info
->begin
[regno
] + ref_info
->count
[regno
]++;
1765 DF_REF_ID (use
) = id
;
1766 ref_info
->refs
[id
] = use
;
1773 /* The bitmap size is not decremented when refs are deleted. So
1774 reset it now that we have squished out all of the empty
1777 ref_info
->table_size
= offset
;
1780 /* Take build ref table for either the uses or defs from the reg-use
1781 or reg-def chains. */
1784 df_reorganize_refs_by_reg (struct df_ref_info
*ref_info
,
1787 bool include_eq_uses
)
1789 if (df
->analyze_subset
)
1790 df_reorganize_refs_by_reg_by_insn (ref_info
, include_defs
,
1791 include_uses
, include_eq_uses
);
1793 df_reorganize_refs_by_reg_by_reg (ref_info
, include_defs
,
1794 include_uses
, include_eq_uses
);
1798 /* Add the refs in REF_VEC to the table in REF_INFO starting at OFFSET. */
1800 df_add_refs_to_table (unsigned int offset
,
1801 struct df_ref_info
*ref_info
,
1806 df_ref ref
= *ref_vec
;
1807 if ((!(df
->changeable_flags
& DF_NO_HARD_REGS
))
1808 || (DF_REF_REGNO (ref
) >= FIRST_PSEUDO_REGISTER
))
1810 ref_info
->refs
[offset
] = ref
;
1811 DF_REF_ID (*ref_vec
) = offset
++;
1819 /* Count the number of refs in all of the insns of BB. Include the
1820 defs if INCLUDE_DEFS. Include the uses if INCLUDE_USES. Include the
1821 eq_uses if INCLUDE_EQ_USES. */
1824 df_reorganize_refs_by_insn_bb (basic_block bb
, unsigned int offset
,
1825 struct df_ref_info
*ref_info
,
1826 bool include_defs
, bool include_uses
,
1827 bool include_eq_uses
)
1832 offset
= df_add_refs_to_table (offset
, ref_info
,
1833 df_get_artificial_defs (bb
->index
));
1835 offset
= df_add_refs_to_table (offset
, ref_info
,
1836 df_get_artificial_uses (bb
->index
));
1838 FOR_BB_INSNS (bb
, insn
)
1841 unsigned int uid
= INSN_UID (insn
);
1843 offset
= df_add_refs_to_table (offset
, ref_info
,
1844 DF_INSN_UID_DEFS (uid
));
1846 offset
= df_add_refs_to_table (offset
, ref_info
,
1847 DF_INSN_UID_USES (uid
));
1848 if (include_eq_uses
)
1849 offset
= df_add_refs_to_table (offset
, ref_info
,
1850 DF_INSN_UID_EQ_USES (uid
));
1856 /* Organize the refs by insn into the table in REF_INFO. If
1857 blocks_to_analyze is defined, use that set, otherwise the entire
1858 program. Include the defs if INCLUDE_DEFS. Include the uses if
1859 INCLUDE_USES. Include the eq_uses if INCLUDE_EQ_USES. */
1862 df_reorganize_refs_by_insn (struct df_ref_info
*ref_info
,
1863 bool include_defs
, bool include_uses
,
1864 bool include_eq_uses
)
1867 unsigned int offset
= 0;
1869 ref_info
->total_size
= df_count_refs (include_defs
, include_uses
, include_eq_uses
);
1870 df_check_and_grow_ref_info (ref_info
, 1);
1871 if (df
->blocks_to_analyze
)
1876 EXECUTE_IF_SET_IN_BITMAP (df
->blocks_to_analyze
, 0, index
, bi
)
1878 offset
= df_reorganize_refs_by_insn_bb (BASIC_BLOCK_FOR_FN (cfun
,
1881 include_defs
, include_uses
,
1885 ref_info
->table_size
= offset
;
1889 FOR_ALL_BB_FN (bb
, cfun
)
1890 offset
= df_reorganize_refs_by_insn_bb (bb
, offset
, ref_info
,
1891 include_defs
, include_uses
,
1893 ref_info
->table_size
= offset
;
1898 /* If the use refs in DF are not organized, reorganize them. */
1901 df_maybe_reorganize_use_refs (enum df_ref_order order
)
1903 if (order
== df
->use_info
.ref_order
)
1908 case DF_REF_ORDER_BY_REG
:
1909 df_reorganize_refs_by_reg (&df
->use_info
, false, true, false);
1912 case DF_REF_ORDER_BY_REG_WITH_NOTES
:
1913 df_reorganize_refs_by_reg (&df
->use_info
, false, true, true);
1916 case DF_REF_ORDER_BY_INSN
:
1917 df_reorganize_refs_by_insn (&df
->use_info
, false, true, false);
1920 case DF_REF_ORDER_BY_INSN_WITH_NOTES
:
1921 df_reorganize_refs_by_insn (&df
->use_info
, false, true, true);
1924 case DF_REF_ORDER_NO_TABLE
:
1925 free (df
->use_info
.refs
);
1926 df
->use_info
.refs
= NULL
;
1927 df
->use_info
.refs_size
= 0;
1930 case DF_REF_ORDER_UNORDERED
:
1931 case DF_REF_ORDER_UNORDERED_WITH_NOTES
:
1936 df
->use_info
.ref_order
= order
;
1940 /* If the def refs in DF are not organized, reorganize them. */
1943 df_maybe_reorganize_def_refs (enum df_ref_order order
)
1945 if (order
== df
->def_info
.ref_order
)
1950 case DF_REF_ORDER_BY_REG
:
1951 df_reorganize_refs_by_reg (&df
->def_info
, true, false, false);
1954 case DF_REF_ORDER_BY_INSN
:
1955 df_reorganize_refs_by_insn (&df
->def_info
, true, false, false);
1958 case DF_REF_ORDER_NO_TABLE
:
1959 free (df
->def_info
.refs
);
1960 df
->def_info
.refs
= NULL
;
1961 df
->def_info
.refs_size
= 0;
1964 case DF_REF_ORDER_BY_INSN_WITH_NOTES
:
1965 case DF_REF_ORDER_BY_REG_WITH_NOTES
:
1966 case DF_REF_ORDER_UNORDERED
:
1967 case DF_REF_ORDER_UNORDERED_WITH_NOTES
:
1972 df
->def_info
.ref_order
= order
;
1976 /* Change all of the basic block references in INSN to use the insn's
1977 current basic block. This function is called from routines that move
1978 instructions from one block to another. */
1981 df_insn_change_bb (rtx insn
, basic_block new_bb
)
1983 basic_block old_bb
= BLOCK_FOR_INSN (insn
);
1984 struct df_insn_info
*insn_info
;
1985 unsigned int uid
= INSN_UID (insn
);
1987 if (old_bb
== new_bb
)
1990 set_block_for_insn (insn
, new_bb
);
1996 fprintf (dump_file
, "changing bb of uid %d\n", uid
);
1998 insn_info
= DF_INSN_UID_SAFE_GET (uid
);
1999 if (insn_info
== NULL
)
2002 fprintf (dump_file
, " unscanned insn\n");
2003 df_insn_rescan (insn
);
2010 df_set_bb_dirty (new_bb
);
2014 fprintf (dump_file
, " from %d to %d\n",
2015 old_bb
->index
, new_bb
->index
);
2016 df_set_bb_dirty (old_bb
);
2020 fprintf (dump_file
, " to %d\n", new_bb
->index
);
2024 /* Helper function for df_ref_change_reg_with_loc. */
2027 df_ref_change_reg_with_loc_1 (struct df_reg_info
*old_df
,
2028 struct df_reg_info
*new_df
,
2029 int new_regno
, rtx loc
)
2031 df_ref the_ref
= old_df
->reg_chain
;
2035 if ((!DF_REF_IS_ARTIFICIAL (the_ref
))
2036 && DF_REF_LOC (the_ref
)
2037 && (*DF_REF_LOC (the_ref
) == loc
))
2039 df_ref next_ref
= DF_REF_NEXT_REG (the_ref
);
2040 df_ref prev_ref
= DF_REF_PREV_REG (the_ref
);
2041 df_ref
*ref_vec
, *ref_vec_t
;
2042 struct df_insn_info
*insn_info
= DF_REF_INSN_INFO (the_ref
);
2043 unsigned int count
= 0;
2045 DF_REF_REGNO (the_ref
) = new_regno
;
2046 DF_REF_REG (the_ref
) = regno_reg_rtx
[new_regno
];
2048 /* Pull the_ref out of the old regno chain. */
2050 DF_REF_NEXT_REG (prev_ref
) = next_ref
;
2052 old_df
->reg_chain
= next_ref
;
2054 DF_REF_PREV_REG (next_ref
) = prev_ref
;
2057 /* Put the ref into the new regno chain. */
2058 DF_REF_PREV_REG (the_ref
) = NULL
;
2059 DF_REF_NEXT_REG (the_ref
) = new_df
->reg_chain
;
2060 if (new_df
->reg_chain
)
2061 DF_REF_PREV_REG (new_df
->reg_chain
) = the_ref
;
2062 new_df
->reg_chain
= the_ref
;
2064 if (DF_REF_BB (the_ref
))
2065 df_set_bb_dirty (DF_REF_BB (the_ref
));
2067 /* Need to sort the record again that the ref was in because
2068 the regno is a sorting key. First, find the right
2070 if (DF_REF_FLAGS (the_ref
) & DF_REF_IN_NOTE
)
2071 ref_vec
= insn_info
->eq_uses
;
2073 ref_vec
= insn_info
->uses
;
2075 fprintf (dump_file
, "changing reg in insn %d\n",
2076 DF_REF_INSN_UID (the_ref
));
2078 ref_vec_t
= ref_vec
;
2080 /* Find the length. */
2086 qsort (ref_vec
, count
, sizeof (df_ref
), df_ref_compare
);
2091 the_ref
= DF_REF_NEXT_REG (the_ref
);
2096 /* Change the regno of all refs that contained LOC from OLD_REGNO to
2097 NEW_REGNO. Refs that do not match LOC are not changed which means
2098 that artificial refs are not changed since they have no loc. This
2099 call is to support the SET_REGNO macro. */
2102 df_ref_change_reg_with_loc (int old_regno
, int new_regno
, rtx loc
)
2104 if ((!df
) || (old_regno
== -1) || (old_regno
== new_regno
))
2107 df_grow_reg_info ();
2109 df_ref_change_reg_with_loc_1 (DF_REG_DEF_GET (old_regno
),
2110 DF_REG_DEF_GET (new_regno
), new_regno
, loc
);
2111 df_ref_change_reg_with_loc_1 (DF_REG_USE_GET (old_regno
),
2112 DF_REG_USE_GET (new_regno
), new_regno
, loc
);
2113 df_ref_change_reg_with_loc_1 (DF_REG_EQ_USE_GET (old_regno
),
2114 DF_REG_EQ_USE_GET (new_regno
), new_regno
, loc
);
2118 /* Delete the mw_hardregs that point into the eq_notes. */
2121 df_mw_hardreg_chain_delete_eq_uses (struct df_insn_info
*insn_info
)
2123 struct df_mw_hardreg
**mw_vec
= insn_info
->mw_hardregs
;
2124 unsigned int deleted
= 0;
2125 unsigned int count
= 0;
2126 struct df_scan_problem_data
*problem_data
2127 = (struct df_scan_problem_data
*) df_scan
->problem_data
;
2134 if ((*mw_vec
)->flags
& DF_REF_IN_NOTE
)
2136 struct df_mw_hardreg
**temp_vec
= mw_vec
;
2138 pool_free (problem_data
->mw_reg_pool
, *mw_vec
);
2140 /* Shove the remaining ones down one to fill the gap. While
2141 this looks n**2, it is highly unusual to have any mw regs
2142 in eq_notes and the chances of more than one are almost
2146 *temp_vec
= *(temp_vec
+ 1);
2160 df_scan_free_mws_vec (insn_info
->mw_hardregs
);
2161 insn_info
->mw_hardregs
= df_null_mw_rec
;
2168 /* Rescan only the REG_EQUIV/REG_EQUAL notes part of INSN. */
2171 df_notes_rescan (rtx insn
)
2173 struct df_insn_info
*insn_info
;
2174 unsigned int uid
= INSN_UID (insn
);
2179 /* The client has disabled rescanning and plans to do it itself. */
2180 if (df
->changeable_flags
& DF_NO_INSN_RESCAN
)
2183 /* Do nothing if the insn hasn't been emitted yet. */
2184 if (!BLOCK_FOR_INSN (insn
))
2187 df_grow_bb_info (df_scan
);
2188 df_grow_reg_info ();
2190 insn_info
= DF_INSN_UID_SAFE_GET (INSN_UID (insn
));
2192 /* The client has deferred rescanning. */
2193 if (df
->changeable_flags
& DF_DEFER_INSN_RESCAN
)
2197 insn_info
= df_insn_create_insn_record (insn
);
2198 insn_info
->defs
= df_null_ref_rec
;
2199 insn_info
->uses
= df_null_ref_rec
;
2200 insn_info
->eq_uses
= df_null_ref_rec
;
2201 insn_info
->mw_hardregs
= df_null_mw_rec
;
2204 bitmap_clear_bit (&df
->insns_to_delete
, uid
);
2205 /* If the insn is set to be rescanned, it does not need to also
2206 be notes rescanned. */
2207 if (!bitmap_bit_p (&df
->insns_to_rescan
, uid
))
2208 bitmap_set_bit (&df
->insns_to_notes_rescan
, INSN_UID (insn
));
2212 bitmap_clear_bit (&df
->insns_to_delete
, uid
);
2213 bitmap_clear_bit (&df
->insns_to_notes_rescan
, uid
);
2217 basic_block bb
= BLOCK_FOR_INSN (insn
);
2219 struct df_collection_rec collection_rec
;
2220 unsigned int num_deleted
;
2221 unsigned int mw_len
;
2223 num_deleted
= df_mw_hardreg_chain_delete_eq_uses (insn_info
);
2224 df_ref_chain_delete (insn_info
->eq_uses
);
2225 insn_info
->eq_uses
= NULL
;
2227 /* Process REG_EQUIV/REG_EQUAL notes */
2228 for (note
= REG_NOTES (insn
); note
;
2229 note
= XEXP (note
, 1))
2231 switch (REG_NOTE_KIND (note
))
2235 df_uses_record (&collection_rec
,
2236 &XEXP (note
, 0), DF_REF_REG_USE
,
2237 bb
, insn_info
, DF_REF_IN_NOTE
);
2243 /* Find some place to put any new mw_hardregs. */
2244 df_canonize_collection_rec (&collection_rec
);
2245 mw_len
= collection_rec
.mw_vec
.length ();
2248 unsigned int count
= 0;
2249 struct df_mw_hardreg
**mw_rec
= insn_info
->mw_hardregs
;
2258 /* Append to the end of the existing record after
2259 expanding it if necessary. */
2260 if (mw_len
> num_deleted
)
2262 insn_info
->mw_hardregs
=
2263 XRESIZEVEC (struct df_mw_hardreg
*,
2264 insn_info
->mw_hardregs
,
2265 count
+ 1 + mw_len
);
2267 memcpy (&insn_info
->mw_hardregs
[count
],
2268 collection_rec
.mw_vec
.address (),
2269 mw_len
* sizeof (struct df_mw_hardreg
*));
2270 insn_info
->mw_hardregs
[count
+ mw_len
] = NULL
;
2271 qsort (insn_info
->mw_hardregs
, count
+ mw_len
,
2272 sizeof (struct df_mw_hardreg
*), df_mw_compare
);
2276 /* No vector there. */
2277 insn_info
->mw_hardregs
2278 = XNEWVEC (struct df_mw_hardreg
*, 1 + mw_len
);
2279 memcpy (insn_info
->mw_hardregs
,
2280 collection_rec
.mw_vec
.address (),
2281 mw_len
* sizeof (struct df_mw_hardreg
*));
2282 insn_info
->mw_hardregs
[mw_len
] = NULL
;
2285 df_refs_add_to_chains (&collection_rec
, bb
, insn
, copy_eq_uses
);
2288 df_insn_rescan (insn
);
2293 /*----------------------------------------------------------------------------
2294 Hard core instruction scanning code. No external interfaces here,
2295 just a lot of routines that look inside insns.
2296 ----------------------------------------------------------------------------*/
2299 /* Return true if the contents of two df_ref's are identical.
2300 It ignores DF_REF_MARKER. */
2303 df_ref_equal_p (df_ref ref1
, df_ref ref2
)
2311 if (DF_REF_CLASS (ref1
) != DF_REF_CLASS (ref2
)
2312 || DF_REF_REGNO (ref1
) != DF_REF_REGNO (ref2
)
2313 || DF_REF_REG (ref1
) != DF_REF_REG (ref2
)
2314 || DF_REF_TYPE (ref1
) != DF_REF_TYPE (ref2
)
2315 || ((DF_REF_FLAGS (ref1
) & ~(DF_REF_REG_MARKER
+ DF_REF_MW_HARDREG
))
2316 != (DF_REF_FLAGS (ref2
) & ~(DF_REF_REG_MARKER
+ DF_REF_MW_HARDREG
)))
2317 || DF_REF_BB (ref1
) != DF_REF_BB (ref2
)
2318 || DF_REF_INSN_INFO (ref1
) != DF_REF_INSN_INFO (ref2
))
2321 switch (DF_REF_CLASS (ref1
))
2323 case DF_REF_ARTIFICIAL
:
2327 case DF_REF_REGULAR
:
2328 return DF_REF_LOC (ref1
) == DF_REF_LOC (ref2
);
2337 /* Compare REF1 and REF2 for sorting. This is only called from places
2338 where all of the refs are of the same type, in the same insn, and
2339 have the same bb. So these fields are not checked. */
2342 df_ref_compare (const void *r1
, const void *r2
)
2344 const df_ref ref1
= *(const df_ref
*)r1
;
2345 const df_ref ref2
= *(const df_ref
*)r2
;
2350 if (DF_REF_CLASS (ref1
) != DF_REF_CLASS (ref2
))
2351 return (int)DF_REF_CLASS (ref1
) - (int)DF_REF_CLASS (ref2
);
2353 if (DF_REF_REGNO (ref1
) != DF_REF_REGNO (ref2
))
2354 return (int)DF_REF_REGNO (ref1
) - (int)DF_REF_REGNO (ref2
);
2356 if (DF_REF_TYPE (ref1
) != DF_REF_TYPE (ref2
))
2357 return (int)DF_REF_TYPE (ref1
) - (int)DF_REF_TYPE (ref2
);
2359 if (DF_REF_REG (ref1
) != DF_REF_REG (ref2
))
2360 return (int)DF_REF_ORDER (ref1
) - (int)DF_REF_ORDER (ref2
);
2362 /* Cannot look at the LOC field on artificial refs. */
2363 if (DF_REF_CLASS (ref1
) != DF_REF_ARTIFICIAL
2364 && DF_REF_LOC (ref1
) != DF_REF_LOC (ref2
))
2365 return (int)DF_REF_ORDER (ref1
) - (int)DF_REF_ORDER (ref2
);
2367 if (DF_REF_FLAGS (ref1
) != DF_REF_FLAGS (ref2
))
2369 /* If two refs are identical except that one of them has is from
2370 a mw and one is not, we need to have the one with the mw
2372 if (DF_REF_FLAGS_IS_SET (ref1
, DF_REF_MW_HARDREG
) ==
2373 DF_REF_FLAGS_IS_SET (ref2
, DF_REF_MW_HARDREG
))
2374 return DF_REF_FLAGS (ref1
) - DF_REF_FLAGS (ref2
);
2375 else if (DF_REF_FLAGS_IS_SET (ref1
, DF_REF_MW_HARDREG
))
2381 return (int)DF_REF_ORDER (ref1
) - (int)DF_REF_ORDER (ref2
);
2385 df_swap_refs (vec
<df_ref
, va_heap
> *ref_vec
, int i
, int j
)
2387 df_ref tmp
= (*ref_vec
)[i
];
2388 (*ref_vec
)[i
] = (*ref_vec
)[j
];
2389 (*ref_vec
)[j
] = tmp
;
2392 /* Sort and compress a set of refs. */
2395 df_sort_and_compress_refs (vec
<df_ref
, va_heap
> *ref_vec
)
2399 unsigned int dist
= 0;
2401 count
= ref_vec
->length ();
2403 /* If there are 1 or 0 elements, there is nothing to do. */
2406 else if (count
== 2)
2408 df_ref r0
= (*ref_vec
)[0];
2409 df_ref r1
= (*ref_vec
)[1];
2410 if (df_ref_compare (&r0
, &r1
) > 0)
2411 df_swap_refs (ref_vec
, 0, 1);
2415 for (i
= 0; i
< count
- 1; i
++)
2417 df_ref r0
= (*ref_vec
)[i
];
2418 df_ref r1
= (*ref_vec
)[i
+ 1];
2419 if (df_ref_compare (&r0
, &r1
) >= 0)
2422 /* If the array is already strictly ordered,
2423 which is the most common case for large COUNT case
2424 (which happens for CALL INSNs),
2425 no need to sort and filter out duplicate.
2426 Simply return the count.
2427 Make sure DF_GET_ADD_REFS adds refs in the increasing order
2428 of DF_REF_COMPARE. */
2431 ref_vec
->qsort (df_ref_compare
);
2434 for (i
=0; i
<count
-dist
; i
++)
2436 /* Find the next ref that is not equal to the current ref. */
2437 while (i
+ dist
+ 1 < count
2438 && df_ref_equal_p ((*ref_vec
)[i
],
2439 (*ref_vec
)[i
+ dist
+ 1]))
2441 df_free_ref ((*ref_vec
)[i
+ dist
+ 1]);
2444 /* Copy it down to the next position. */
2445 if (dist
&& i
+ dist
+ 1 < count
)
2446 (*ref_vec
)[i
+ 1] = (*ref_vec
)[i
+ dist
+ 1];
2450 ref_vec
->truncate (count
);
2454 /* Return true if the contents of two df_ref's are identical.
2455 It ignores DF_REF_MARKER. */
2458 df_mw_equal_p (struct df_mw_hardreg
*mw1
, struct df_mw_hardreg
*mw2
)
2462 return (mw1
== mw2
) ||
2463 (mw1
->mw_reg
== mw2
->mw_reg
2464 && mw1
->type
== mw2
->type
2465 && mw1
->flags
== mw2
->flags
2466 && mw1
->start_regno
== mw2
->start_regno
2467 && mw1
->end_regno
== mw2
->end_regno
);
2471 /* Compare MW1 and MW2 for sorting. */
2474 df_mw_compare (const void *m1
, const void *m2
)
2476 const struct df_mw_hardreg
*const mw1
= *(const struct df_mw_hardreg
*const*)m1
;
2477 const struct df_mw_hardreg
*const mw2
= *(const struct df_mw_hardreg
*const*)m2
;
2482 if (mw1
->type
!= mw2
->type
)
2483 return mw1
->type
- mw2
->type
;
2485 if (mw1
->flags
!= mw2
->flags
)
2486 return mw1
->flags
- mw2
->flags
;
2488 if (mw1
->start_regno
!= mw2
->start_regno
)
2489 return mw1
->start_regno
- mw2
->start_regno
;
2491 if (mw1
->end_regno
!= mw2
->end_regno
)
2492 return mw1
->end_regno
- mw2
->end_regno
;
2494 if (mw1
->mw_reg
!= mw2
->mw_reg
)
2495 return mw1
->mw_order
- mw2
->mw_order
;
2501 /* Sort and compress a set of refs. */
2504 df_sort_and_compress_mws (vec
<df_mw_hardreg_ptr
, va_heap
> *mw_vec
)
2507 struct df_scan_problem_data
*problem_data
2508 = (struct df_scan_problem_data
*) df_scan
->problem_data
;
2510 unsigned int dist
= 0;
2512 count
= mw_vec
->length ();
2515 else if (count
== 2)
2517 struct df_mw_hardreg
*m0
= (*mw_vec
)[0];
2518 struct df_mw_hardreg
*m1
= (*mw_vec
)[1];
2519 if (df_mw_compare (&m0
, &m1
) > 0)
2521 struct df_mw_hardreg
*tmp
= (*mw_vec
)[0];
2522 (*mw_vec
)[0] = (*mw_vec
)[1];
2527 mw_vec
->qsort (df_mw_compare
);
2529 for (i
=0; i
<count
-dist
; i
++)
2531 /* Find the next ref that is not equal to the current ref. */
2532 while (i
+ dist
+ 1 < count
2533 && df_mw_equal_p ((*mw_vec
)[i
], (*mw_vec
)[i
+ dist
+ 1]))
2535 pool_free (problem_data
->mw_reg_pool
,
2536 (*mw_vec
)[i
+ dist
+ 1]);
2539 /* Copy it down to the next position. */
2540 if (dist
&& i
+ dist
+ 1 < count
)
2541 (*mw_vec
)[i
+ 1] = (*mw_vec
)[i
+ dist
+ 1];
2545 mw_vec
->truncate (count
);
2549 /* Sort and remove duplicates from the COLLECTION_REC. */
2552 df_canonize_collection_rec (struct df_collection_rec
*collection_rec
)
2554 df_sort_and_compress_refs (&collection_rec
->def_vec
);
2555 df_sort_and_compress_refs (&collection_rec
->use_vec
);
2556 df_sort_and_compress_refs (&collection_rec
->eq_use_vec
);
2557 df_sort_and_compress_mws (&collection_rec
->mw_vec
);
2561 /* Add the new df_ref to appropriate reg_info/ref_info chains. */
2564 df_install_ref (df_ref this_ref
,
2565 struct df_reg_info
*reg_info
,
2566 struct df_ref_info
*ref_info
,
2569 unsigned int regno
= DF_REF_REGNO (this_ref
);
2570 /* Add the ref to the reg_{def,use,eq_use} chain. */
2571 df_ref head
= reg_info
->reg_chain
;
2573 reg_info
->reg_chain
= this_ref
;
2576 if (DF_REF_FLAGS_IS_SET (this_ref
, DF_HARD_REG_LIVE
))
2578 gcc_assert (regno
< FIRST_PSEUDO_REGISTER
);
2579 df
->hard_regs_live_count
[regno
]++;
2582 gcc_checking_assert (DF_REF_NEXT_REG (this_ref
) == NULL
2583 && DF_REF_PREV_REG (this_ref
) == NULL
);
2585 DF_REF_NEXT_REG (this_ref
) = head
;
2587 /* We cannot actually link to the head of the chain. */
2588 DF_REF_PREV_REG (this_ref
) = NULL
;
2591 DF_REF_PREV_REG (head
) = this_ref
;
2595 gcc_assert (ref_info
->ref_order
!= DF_REF_ORDER_NO_TABLE
);
2596 df_check_and_grow_ref_info (ref_info
, 1);
2597 DF_REF_ID (this_ref
) = ref_info
->table_size
;
2598 /* Add the ref to the big array of defs. */
2599 ref_info
->refs
[ref_info
->table_size
] = this_ref
;
2600 ref_info
->table_size
++;
2603 DF_REF_ID (this_ref
) = -1;
2605 ref_info
->total_size
++;
2609 /* This function takes one of the groups of refs (defs, uses or
2610 eq_uses) and installs the entire group into the insn. It also adds
2611 each of these refs into the appropriate chains. */
2614 df_install_refs (basic_block bb
,
2615 const vec
<df_ref
, va_heap
> *old_vec
,
2616 struct df_reg_info
**reg_info
,
2617 struct df_ref_info
*ref_info
,
2620 unsigned int count
= old_vec
->length ();
2623 df_ref
*new_vec
= XNEWVEC (df_ref
, count
+ 1);
2628 switch (ref_info
->ref_order
)
2630 case DF_REF_ORDER_UNORDERED_WITH_NOTES
:
2631 case DF_REF_ORDER_BY_REG_WITH_NOTES
:
2632 case DF_REF_ORDER_BY_INSN_WITH_NOTES
:
2633 ref_info
->ref_order
= DF_REF_ORDER_UNORDERED_WITH_NOTES
;
2634 add_to_table
= true;
2636 case DF_REF_ORDER_UNORDERED
:
2637 case DF_REF_ORDER_BY_REG
:
2638 case DF_REF_ORDER_BY_INSN
:
2639 ref_info
->ref_order
= DF_REF_ORDER_UNORDERED
;
2640 add_to_table
= !is_notes
;
2643 add_to_table
= false;
2647 /* Do not add if ref is not in the right blocks. */
2648 if (add_to_table
&& df
->analyze_subset
)
2649 add_to_table
= bitmap_bit_p (df
->blocks_to_analyze
, bb
->index
);
2651 FOR_EACH_VEC_ELT (*old_vec
, ix
, this_ref
)
2653 new_vec
[ix
] = this_ref
;
2654 df_install_ref (this_ref
, reg_info
[DF_REF_REGNO (this_ref
)],
2655 ref_info
, add_to_table
);
2658 new_vec
[count
] = NULL
;
2662 return df_null_ref_rec
;
2666 /* This function takes the mws installs the entire group into the
2669 static struct df_mw_hardreg
**
2670 df_install_mws (const vec
<df_mw_hardreg_ptr
, va_heap
> *old_vec
)
2672 unsigned int count
= old_vec
->length ();
2675 struct df_mw_hardreg
**new_vec
2676 = XNEWVEC (struct df_mw_hardreg
*, count
+ 1);
2677 memcpy (new_vec
, old_vec
->address (),
2678 sizeof (struct df_mw_hardreg
*) * count
);
2679 new_vec
[count
] = NULL
;
2683 return df_null_mw_rec
;
2687 /* Add a chain of df_refs to appropriate ref chain/reg_info/ref_info
2688 chains and update other necessary information. */
2691 df_refs_add_to_chains (struct df_collection_rec
*collection_rec
,
2692 basic_block bb
, rtx insn
, unsigned int flags
)
2696 struct df_insn_info
*insn_rec
= DF_INSN_INFO_GET (insn
);
2697 /* If there is a vector in the collection rec, add it to the
2698 insn. A null rec is a signal that the caller will handle the
2700 if (flags
& copy_defs
)
2702 df_scan_free_ref_vec (insn_rec
->defs
);
2704 = df_install_refs (bb
, &collection_rec
->def_vec
,
2706 &df
->def_info
, false);
2708 if (flags
& copy_uses
)
2710 df_scan_free_ref_vec (insn_rec
->uses
);
2712 = df_install_refs (bb
, &collection_rec
->use_vec
,
2714 &df
->use_info
, false);
2716 if (flags
& copy_eq_uses
)
2718 df_scan_free_ref_vec (insn_rec
->eq_uses
);
2720 = df_install_refs (bb
, &collection_rec
->eq_use_vec
,
2722 &df
->use_info
, true);
2724 if (flags
& copy_mw
)
2726 df_scan_free_mws_vec (insn_rec
->mw_hardregs
);
2727 insn_rec
->mw_hardregs
2728 = df_install_mws (&collection_rec
->mw_vec
);
2733 struct df_scan_bb_info
*bb_info
= df_scan_get_bb_info (bb
->index
);
2735 df_scan_free_ref_vec (bb_info
->artificial_defs
);
2736 bb_info
->artificial_defs
2737 = df_install_refs (bb
, &collection_rec
->def_vec
,
2739 &df
->def_info
, false);
2740 df_scan_free_ref_vec (bb_info
->artificial_uses
);
2741 bb_info
->artificial_uses
2742 = df_install_refs (bb
, &collection_rec
->use_vec
,
2744 &df
->use_info
, false);
2749 /* Allocate a ref and initialize its fields. */
2752 df_ref_create_structure (enum df_ref_class cl
,
2753 struct df_collection_rec
*collection_rec
,
2755 basic_block bb
, struct df_insn_info
*info
,
2756 enum df_ref_type ref_type
,
2759 df_ref this_ref
= NULL
;
2760 int regno
= REGNO (GET_CODE (reg
) == SUBREG
? SUBREG_REG (reg
) : reg
);
2761 struct df_scan_problem_data
*problem_data
2762 = (struct df_scan_problem_data
*) df_scan
->problem_data
;
2767 this_ref
= (df_ref
) pool_alloc (problem_data
->ref_base_pool
);
2768 gcc_checking_assert (loc
== NULL
);
2771 case DF_REF_ARTIFICIAL
:
2772 this_ref
= (df_ref
) pool_alloc (problem_data
->ref_artificial_pool
);
2773 this_ref
->artificial_ref
.bb
= bb
;
2774 gcc_checking_assert (loc
== NULL
);
2777 case DF_REF_REGULAR
:
2778 this_ref
= (df_ref
) pool_alloc (problem_data
->ref_regular_pool
);
2779 this_ref
->regular_ref
.loc
= loc
;
2780 gcc_checking_assert (loc
);
2784 DF_REF_CLASS (this_ref
) = cl
;
2785 DF_REF_ID (this_ref
) = -1;
2786 DF_REF_REG (this_ref
) = reg
;
2787 DF_REF_REGNO (this_ref
) = regno
;
2788 DF_REF_TYPE (this_ref
) = ref_type
;
2789 DF_REF_INSN_INFO (this_ref
) = info
;
2790 DF_REF_CHAIN (this_ref
) = NULL
;
2791 DF_REF_FLAGS (this_ref
) = ref_flags
;
2792 DF_REF_NEXT_REG (this_ref
) = NULL
;
2793 DF_REF_PREV_REG (this_ref
) = NULL
;
2794 DF_REF_ORDER (this_ref
) = df
->ref_order
++;
2796 /* We need to clear this bit because fwprop, and in the future
2797 possibly other optimizations sometimes create new refs using ond
2798 refs as the model. */
2799 DF_REF_FLAGS_CLEAR (this_ref
, DF_HARD_REG_LIVE
);
2801 /* See if this ref needs to have DF_HARD_REG_LIVE bit set. */
2802 if (regno
< FIRST_PSEUDO_REGISTER
2803 && !DF_REF_IS_ARTIFICIAL (this_ref
)
2804 && !DEBUG_INSN_P (DF_REF_INSN (this_ref
)))
2806 if (DF_REF_REG_DEF_P (this_ref
))
2808 if (!DF_REF_FLAGS_IS_SET (this_ref
, DF_REF_MAY_CLOBBER
))
2809 DF_REF_FLAGS_SET (this_ref
, DF_HARD_REG_LIVE
);
2811 else if (!(TEST_HARD_REG_BIT (elim_reg_set
, regno
)
2812 && (regno
== FRAME_POINTER_REGNUM
2813 || regno
== ARG_POINTER_REGNUM
)))
2814 DF_REF_FLAGS_SET (this_ref
, DF_HARD_REG_LIVE
);
2819 if (DF_REF_REG_DEF_P (this_ref
))
2820 collection_rec
->def_vec
.safe_push (this_ref
);
2821 else if (DF_REF_FLAGS (this_ref
) & DF_REF_IN_NOTE
)
2822 collection_rec
->eq_use_vec
.safe_push (this_ref
);
2824 collection_rec
->use_vec
.safe_push (this_ref
);
2827 df_install_ref_incremental (this_ref
);
2833 /* Create new references of type DF_REF_TYPE for each part of register REG
2834 at address LOC within INSN of BB. */
2838 df_ref_record (enum df_ref_class cl
,
2839 struct df_collection_rec
*collection_rec
,
2841 basic_block bb
, struct df_insn_info
*insn_info
,
2842 enum df_ref_type ref_type
,
2847 gcc_checking_assert (REG_P (reg
) || GET_CODE (reg
) == SUBREG
);
2849 regno
= REGNO (GET_CODE (reg
) == SUBREG
? SUBREG_REG (reg
) : reg
);
2850 if (regno
< FIRST_PSEUDO_REGISTER
)
2852 struct df_mw_hardreg
*hardreg
= NULL
;
2853 struct df_scan_problem_data
*problem_data
2854 = (struct df_scan_problem_data
*) df_scan
->problem_data
;
2856 unsigned int endregno
;
2859 if (GET_CODE (reg
) == SUBREG
)
2861 regno
+= subreg_regno_offset (regno
, GET_MODE (SUBREG_REG (reg
)),
2862 SUBREG_BYTE (reg
), GET_MODE (reg
));
2863 endregno
= regno
+ subreg_nregs (reg
);
2866 endregno
= END_HARD_REGNO (reg
);
2868 /* If this is a multiword hardreg, we create some extra
2869 datastructures that will enable us to easily build REG_DEAD
2870 and REG_UNUSED notes. */
2872 && (endregno
!= regno
+ 1) && insn_info
)
2874 /* Sets to a subreg of a multiword register are partial.
2875 Sets to a non-subreg of a multiword register are not. */
2876 if (GET_CODE (reg
) == SUBREG
)
2877 ref_flags
|= DF_REF_PARTIAL
;
2878 ref_flags
|= DF_REF_MW_HARDREG
;
2880 hardreg
= (struct df_mw_hardreg
*) pool_alloc (problem_data
->mw_reg_pool
);
2881 hardreg
->type
= ref_type
;
2882 hardreg
->flags
= ref_flags
;
2883 hardreg
->mw_reg
= reg
;
2884 hardreg
->start_regno
= regno
;
2885 hardreg
->end_regno
= endregno
- 1;
2886 hardreg
->mw_order
= df
->ref_order
++;
2887 collection_rec
->mw_vec
.safe_push (hardreg
);
2890 for (i
= regno
; i
< endregno
; i
++)
2892 ref
= df_ref_create_structure (cl
, collection_rec
, regno_reg_rtx
[i
], loc
,
2893 bb
, insn_info
, ref_type
, ref_flags
);
2895 gcc_assert (ORIGINAL_REGNO (DF_REF_REG (ref
)) == i
);
2900 df_ref_create_structure (cl
, collection_rec
, reg
, loc
, bb
, insn_info
,
2901 ref_type
, ref_flags
);
2906 /* A set to a non-paradoxical SUBREG for which the number of word_mode units
2907 covered by the outer mode is smaller than that covered by the inner mode,
2908 is a read-modify-write operation.
2909 This function returns true iff the SUBREG X is such a SUBREG. */
2912 df_read_modify_subreg_p (rtx x
)
2914 unsigned int isize
, osize
;
2915 if (GET_CODE (x
) != SUBREG
)
2917 isize
= GET_MODE_SIZE (GET_MODE (SUBREG_REG (x
)));
2918 osize
= GET_MODE_SIZE (GET_MODE (x
));
2919 return isize
> osize
2920 && isize
> REGMODE_NATURAL_SIZE (GET_MODE (SUBREG_REG (x
)));
2924 /* Process all the registers defined in the rtx pointed by LOC.
2925 Autoincrement/decrement definitions will be picked up by df_uses_record.
2926 Any change here has to be matched in df_find_hard_reg_defs_1. */
2929 df_def_record_1 (struct df_collection_rec
*collection_rec
,
2930 rtx
*loc
, basic_block bb
, struct df_insn_info
*insn_info
,
2935 /* It is legal to have a set destination be a parallel. */
2936 if (GET_CODE (dst
) == PARALLEL
)
2939 for (i
= XVECLEN (dst
, 0) - 1; i
>= 0; i
--)
2941 rtx temp
= XVECEXP (dst
, 0, i
);
2942 gcc_assert (GET_CODE (temp
) == EXPR_LIST
);
2943 df_def_record_1 (collection_rec
, &XEXP (temp
, 0),
2944 bb
, insn_info
, flags
);
2949 if (GET_CODE (dst
) == STRICT_LOW_PART
)
2951 flags
|= DF_REF_READ_WRITE
| DF_REF_PARTIAL
| DF_REF_STRICT_LOW_PART
;
2953 loc
= &XEXP (dst
, 0);
2957 if (GET_CODE (dst
) == ZERO_EXTRACT
)
2959 flags
|= DF_REF_READ_WRITE
| DF_REF_PARTIAL
| DF_REF_ZERO_EXTRACT
;
2961 loc
= &XEXP (dst
, 0);
2965 /* At this point if we do not have a reg or a subreg, just return. */
2968 df_ref_record (DF_REF_REGULAR
, collection_rec
,
2969 dst
, loc
, bb
, insn_info
, DF_REF_REG_DEF
, flags
);
2971 /* We want to keep sp alive everywhere - by making all
2972 writes to sp also use of sp. */
2973 if (REGNO (dst
) == STACK_POINTER_REGNUM
)
2974 df_ref_record (DF_REF_BASE
, collection_rec
,
2975 dst
, NULL
, bb
, insn_info
, DF_REF_REG_USE
, flags
);
2977 else if (GET_CODE (dst
) == SUBREG
&& REG_P (SUBREG_REG (dst
)))
2979 if (df_read_modify_subreg_p (dst
))
2980 flags
|= DF_REF_READ_WRITE
| DF_REF_PARTIAL
;
2982 flags
|= DF_REF_SUBREG
;
2984 df_ref_record (DF_REF_REGULAR
, collection_rec
,
2985 dst
, loc
, bb
, insn_info
, DF_REF_REG_DEF
, flags
);
2990 /* Process all the registers defined in the pattern rtx, X. Any change
2991 here has to be matched in df_find_hard_reg_defs. */
2994 df_defs_record (struct df_collection_rec
*collection_rec
,
2995 rtx x
, basic_block bb
, struct df_insn_info
*insn_info
,
2998 RTX_CODE code
= GET_CODE (x
);
3004 df_def_record_1 (collection_rec
, &SET_DEST (x
), bb
, insn_info
, flags
);
3008 flags
|= DF_REF_MUST_CLOBBER
;
3009 df_def_record_1 (collection_rec
, &XEXP (x
, 0), bb
, insn_info
, flags
);
3013 df_defs_record (collection_rec
, COND_EXEC_CODE (x
),
3014 bb
, insn_info
, DF_REF_CONDITIONAL
);
3018 for (i
= 0; i
< XVECLEN (x
, 0); i
++)
3019 df_defs_record (collection_rec
, XVECEXP (x
, 0, i
),
3020 bb
, insn_info
, flags
);
3023 /* No DEFs to record in other cases */
3028 /* Set bits in *DEFS for hard registers found in the rtx DST, which is the
3029 destination of a set or clobber. This has to match the logic in
3030 df_defs_record_1. */
3033 df_find_hard_reg_defs_1 (rtx dst
, HARD_REG_SET
*defs
)
3035 /* It is legal to have a set destination be a parallel. */
3036 if (GET_CODE (dst
) == PARALLEL
)
3039 for (i
= XVECLEN (dst
, 0) - 1; i
>= 0; i
--)
3041 rtx temp
= XVECEXP (dst
, 0, i
);
3042 gcc_assert (GET_CODE (temp
) == EXPR_LIST
);
3043 df_find_hard_reg_defs_1 (XEXP (temp
, 0), defs
);
3048 if (GET_CODE (dst
) == STRICT_LOW_PART
)
3049 dst
= XEXP (dst
, 0);
3051 if (GET_CODE (dst
) == ZERO_EXTRACT
)
3052 dst
= XEXP (dst
, 0);
3054 /* At this point if we do not have a reg or a subreg, just return. */
3055 if (REG_P (dst
) && HARD_REGISTER_P (dst
))
3056 SET_HARD_REG_BIT (*defs
, REGNO (dst
));
3057 else if (GET_CODE (dst
) == SUBREG
3058 && REG_P (SUBREG_REG (dst
)) && HARD_REGISTER_P (dst
))
3059 SET_HARD_REG_BIT (*defs
, REGNO (SUBREG_REG (dst
)));
3062 /* Set bits in *DEFS for hard registers defined in the pattern X. This
3063 has to match the logic in df_defs_record. */
3066 df_find_hard_reg_defs (rtx x
, HARD_REG_SET
*defs
)
3068 RTX_CODE code
= GET_CODE (x
);
3074 df_find_hard_reg_defs_1 (SET_DEST (x
), defs
);
3078 df_find_hard_reg_defs_1 (XEXP (x
, 0), defs
);
3082 df_find_hard_reg_defs (COND_EXEC_CODE (x
), defs
);
3086 for (i
= 0; i
< XVECLEN (x
, 0); i
++)
3087 df_find_hard_reg_defs (XVECEXP (x
, 0, i
), defs
);
3090 /* No DEFs to record in other cases */
3096 /* Process all the registers used in the rtx at address LOC. */
3099 df_uses_record (struct df_collection_rec
*collection_rec
,
3100 rtx
*loc
, enum df_ref_type ref_type
,
3101 basic_block bb
, struct df_insn_info
*insn_info
,
3111 code
= GET_CODE (x
);
3125 /* If we are clobbering a MEM, mark any registers inside the address
3127 if (MEM_P (XEXP (x
, 0)))
3128 df_uses_record (collection_rec
,
3129 &XEXP (XEXP (x
, 0), 0),
3130 DF_REF_REG_MEM_STORE
,
3134 /* If we're clobbering a REG then we have a def so ignore. */
3138 df_uses_record (collection_rec
,
3139 &XEXP (x
, 0), DF_REF_REG_MEM_LOAD
,
3140 bb
, insn_info
, flags
& DF_REF_IN_NOTE
);
3144 /* While we're here, optimize this case. */
3145 flags
|= DF_REF_PARTIAL
;
3146 /* In case the SUBREG is not of a REG, do not optimize. */
3147 if (!REG_P (SUBREG_REG (x
)))
3149 loc
= &SUBREG_REG (x
);
3150 df_uses_record (collection_rec
, loc
, ref_type
, bb
, insn_info
, flags
);
3153 /* ... Fall through ... */
3156 df_ref_record (DF_REF_REGULAR
, collection_rec
,
3157 x
, loc
, bb
, insn_info
,
3164 df_uses_record (collection_rec
,
3165 &XEXP (x
, 1), ref_type
, bb
, insn_info
, flags
);
3166 df_uses_record (collection_rec
,
3167 &XEXP (x
, 2), ref_type
, bb
, insn_info
, flags
);
3169 /* If the parameters to the zero or sign extract are
3170 constants, strip them off and recurse, otherwise there is
3171 no information that we can gain from this operation. */
3172 if (code
== ZERO_EXTRACT
)
3173 flags
|= DF_REF_ZERO_EXTRACT
;
3175 flags
|= DF_REF_SIGN_EXTRACT
;
3177 df_uses_record (collection_rec
,
3178 &XEXP (x
, 0), ref_type
, bb
, insn_info
, flags
);
3185 rtx dst
= SET_DEST (x
);
3186 gcc_assert (!(flags
& DF_REF_IN_NOTE
));
3187 df_uses_record (collection_rec
,
3188 &SET_SRC (x
), DF_REF_REG_USE
, bb
, insn_info
, flags
);
3190 switch (GET_CODE (dst
))
3193 if (df_read_modify_subreg_p (dst
))
3195 df_uses_record (collection_rec
, &SUBREG_REG (dst
),
3196 DF_REF_REG_USE
, bb
, insn_info
,
3197 flags
| DF_REF_READ_WRITE
| DF_REF_SUBREG
);
3208 df_uses_record (collection_rec
, &XEXP (dst
, 0),
3209 DF_REF_REG_MEM_STORE
, bb
, insn_info
, flags
);
3211 case STRICT_LOW_PART
:
3213 rtx
*temp
= &XEXP (dst
, 0);
3214 /* A strict_low_part uses the whole REG and not just the
3216 dst
= XEXP (dst
, 0);
3217 df_uses_record (collection_rec
,
3218 (GET_CODE (dst
) == SUBREG
) ? &SUBREG_REG (dst
) : temp
,
3219 DF_REF_REG_USE
, bb
, insn_info
,
3220 DF_REF_READ_WRITE
| DF_REF_STRICT_LOW_PART
);
3225 df_uses_record (collection_rec
, &XEXP (dst
, 1),
3226 DF_REF_REG_USE
, bb
, insn_info
, flags
);
3227 df_uses_record (collection_rec
, &XEXP (dst
, 2),
3228 DF_REF_REG_USE
, bb
, insn_info
, flags
);
3229 if (GET_CODE (XEXP (dst
,0)) == MEM
)
3230 df_uses_record (collection_rec
, &XEXP (dst
, 0),
3231 DF_REF_REG_USE
, bb
, insn_info
,
3234 df_uses_record (collection_rec
, &XEXP (dst
, 0),
3235 DF_REF_REG_USE
, bb
, insn_info
,
3236 DF_REF_READ_WRITE
| DF_REF_ZERO_EXTRACT
);
3251 case UNSPEC_VOLATILE
:
3255 /* Traditional and volatile asm instructions must be
3256 considered to use and clobber all hard registers, all
3257 pseudo-registers and all of memory. So must TRAP_IF and
3258 UNSPEC_VOLATILE operations.
3260 Consider for instance a volatile asm that changes the fpu
3261 rounding mode. An insn should not be moved across this
3262 even if it only uses pseudo-regs because it might give an
3263 incorrectly rounded result.
3265 However, flow.c's liveness computation did *not* do this,
3266 giving the reasoning as " ?!? Unfortunately, marking all
3267 hard registers as live causes massive problems for the
3268 register allocator and marking all pseudos as live creates
3269 mountains of uninitialized variable warnings."
3271 In order to maintain the status quo with regard to liveness
3272 and uses, we do what flow.c did and just mark any regs we
3273 can find in ASM_OPERANDS as used. In global asm insns are
3274 scanned and regs_asm_clobbered is filled out.
3276 For all ASM_OPERANDS, we must traverse the vector of input
3277 operands. We can not just fall through here since then we
3278 would be confused by the ASM_INPUT rtx inside ASM_OPERANDS,
3279 which do not indicate traditional asms unlike their normal
3281 if (code
== ASM_OPERANDS
)
3285 for (j
= 0; j
< ASM_OPERANDS_INPUT_LENGTH (x
); j
++)
3286 df_uses_record (collection_rec
, &ASM_OPERANDS_INPUT (x
, j
),
3287 DF_REF_REG_USE
, bb
, insn_info
, flags
);
3294 df_uses_record (collection_rec
,
3295 &PAT_VAR_LOCATION_LOC (x
),
3296 DF_REF_REG_USE
, bb
, insn_info
, flags
);
3305 gcc_assert (!DEBUG_INSN_P (insn_info
->insn
));
3306 /* Catch the def of the register being modified. */
3307 df_ref_record (DF_REF_REGULAR
, collection_rec
, XEXP (x
, 0), &XEXP (x
, 0),
3310 flags
| DF_REF_READ_WRITE
| DF_REF_PRE_POST_MODIFY
);
3312 /* ... Fall through to handle uses ... */
3318 /* Recursively scan the operands of this expression. */
3320 const char *fmt
= GET_RTX_FORMAT (code
);
3323 for (i
= GET_RTX_LENGTH (code
) - 1; i
>= 0; i
--)
3327 /* Tail recursive case: save a function call level. */
3333 df_uses_record (collection_rec
, &XEXP (x
, i
), ref_type
,
3334 bb
, insn_info
, flags
);
3336 else if (fmt
[i
] == 'E')
3339 for (j
= 0; j
< XVECLEN (x
, i
); j
++)
3340 df_uses_record (collection_rec
,
3341 &XVECEXP (x
, i
, j
), ref_type
,
3342 bb
, insn_info
, flags
);
3351 /* For all DF_REF_CONDITIONAL defs, add a corresponding uses. */
3354 df_get_conditional_uses (struct df_collection_rec
*collection_rec
)
3359 FOR_EACH_VEC_ELT (collection_rec
->def_vec
, ix
, ref
)
3361 if (DF_REF_FLAGS_IS_SET (ref
, DF_REF_CONDITIONAL
))
3365 use
= df_ref_create_structure (DF_REF_CLASS (ref
), collection_rec
, DF_REF_REG (ref
),
3366 DF_REF_LOC (ref
), DF_REF_BB (ref
),
3367 DF_REF_INSN_INFO (ref
), DF_REF_REG_USE
,
3368 DF_REF_FLAGS (ref
) & ~DF_REF_CONDITIONAL
);
3369 DF_REF_REGNO (use
) = DF_REF_REGNO (ref
);
3375 /* Get call's extra defs and uses (track caller-saved registers). */
3378 df_get_call_refs (struct df_collection_rec
*collection_rec
,
3380 struct df_insn_info
*insn_info
,
3384 bool is_sibling_call
;
3386 HARD_REG_SET defs_generated
;
3387 HARD_REG_SET fn_reg_set_usage
;
3389 CLEAR_HARD_REG_SET (defs_generated
);
3390 df_find_hard_reg_defs (PATTERN (insn_info
->insn
), &defs_generated
);
3391 is_sibling_call
= SIBLING_CALL_P (insn_info
->insn
);
3392 get_call_reg_set_usage (insn_info
->insn
, &fn_reg_set_usage
,
3393 regs_invalidated_by_call
);
3395 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
3397 if (i
== STACK_POINTER_REGNUM
)
3398 /* The stack ptr is used (honorarily) by a CALL insn. */
3399 df_ref_record (DF_REF_BASE
, collection_rec
, regno_reg_rtx
[i
],
3400 NULL
, bb
, insn_info
, DF_REF_REG_USE
,
3401 DF_REF_CALL_STACK_USAGE
| flags
);
3402 else if (global_regs
[i
])
3404 /* Calls to const functions cannot access any global registers and
3405 calls to pure functions cannot set them. All other calls may
3406 reference any of the global registers, so they are recorded as
3408 if (!RTL_CONST_CALL_P (insn_info
->insn
))
3410 df_ref_record (DF_REF_BASE
, collection_rec
, regno_reg_rtx
[i
],
3411 NULL
, bb
, insn_info
, DF_REF_REG_USE
, flags
);
3412 if (!RTL_PURE_CALL_P (insn_info
->insn
))
3413 df_ref_record (DF_REF_BASE
, collection_rec
, regno_reg_rtx
[i
],
3414 NULL
, bb
, insn_info
, DF_REF_REG_DEF
, flags
);
3417 else if (TEST_HARD_REG_BIT (fn_reg_set_usage
, i
)
3418 /* no clobbers for regs that are the result of the call */
3419 && !TEST_HARD_REG_BIT (defs_generated
, i
)
3420 && (!is_sibling_call
3421 || !bitmap_bit_p (df
->exit_block_uses
, i
)
3422 || refers_to_regno_p (i
, i
+1,
3423 crtl
->return_rtx
, NULL
)))
3424 df_ref_record (DF_REF_BASE
, collection_rec
, regno_reg_rtx
[i
],
3425 NULL
, bb
, insn_info
, DF_REF_REG_DEF
,
3426 DF_REF_MAY_CLOBBER
| flags
);
3429 /* Record the registers used to pass arguments, and explicitly
3430 noted as clobbered. */
3431 for (note
= CALL_INSN_FUNCTION_USAGE (insn_info
->insn
); note
;
3432 note
= XEXP (note
, 1))
3434 if (GET_CODE (XEXP (note
, 0)) == USE
)
3435 df_uses_record (collection_rec
, &XEXP (XEXP (note
, 0), 0),
3436 DF_REF_REG_USE
, bb
, insn_info
, flags
);
3437 else if (GET_CODE (XEXP (note
, 0)) == CLOBBER
)
3439 if (REG_P (XEXP (XEXP (note
, 0), 0)))
3441 unsigned int regno
= REGNO (XEXP (XEXP (note
, 0), 0));
3442 if (!TEST_HARD_REG_BIT (defs_generated
, regno
))
3443 df_defs_record (collection_rec
, XEXP (note
, 0), bb
,
3447 df_uses_record (collection_rec
, &XEXP (note
, 0),
3448 DF_REF_REG_USE
, bb
, insn_info
, flags
);
3455 /* Collect all refs in the INSN. This function is free of any
3456 side-effect - it will create and return a lists of df_ref's in the
3457 COLLECTION_REC without putting those refs into existing ref chains
3461 df_insn_refs_collect (struct df_collection_rec
*collection_rec
,
3462 basic_block bb
, struct df_insn_info
*insn_info
)
3465 bool is_cond_exec
= (GET_CODE (PATTERN (insn_info
->insn
)) == COND_EXEC
);
3467 /* Clear out the collection record. */
3468 collection_rec
->def_vec
.truncate (0);
3469 collection_rec
->use_vec
.truncate (0);
3470 collection_rec
->eq_use_vec
.truncate (0);
3471 collection_rec
->mw_vec
.truncate (0);
3473 /* Process REG_EQUIV/REG_EQUAL notes. */
3474 for (note
= REG_NOTES (insn_info
->insn
); note
;
3475 note
= XEXP (note
, 1))
3477 switch (REG_NOTE_KIND (note
))
3481 df_uses_record (collection_rec
,
3482 &XEXP (note
, 0), DF_REF_REG_USE
,
3483 bb
, insn_info
, DF_REF_IN_NOTE
);
3485 case REG_NON_LOCAL_GOTO
:
3486 /* The frame ptr is used by a non-local goto. */
3487 df_ref_record (DF_REF_BASE
, collection_rec
,
3488 regno_reg_rtx
[FRAME_POINTER_REGNUM
],
3489 NULL
, bb
, insn_info
,
3491 #if !HARD_FRAME_POINTER_IS_FRAME_POINTER
3492 df_ref_record (DF_REF_BASE
, collection_rec
,
3493 regno_reg_rtx
[HARD_FRAME_POINTER_REGNUM
],
3494 NULL
, bb
, insn_info
,
3503 /* For CALL_INSNs, first record DF_REF_BASE register defs, as well as
3504 uses from CALL_INSN_FUNCTION_USAGE. */
3505 if (CALL_P (insn_info
->insn
))
3506 df_get_call_refs (collection_rec
, bb
, insn_info
,
3507 (is_cond_exec
) ? DF_REF_CONDITIONAL
: 0);
3509 /* Record other defs. These should be mostly for DF_REF_REGULAR, so
3510 that a qsort on the defs is unnecessary in most cases. */
3511 df_defs_record (collection_rec
,
3512 PATTERN (insn_info
->insn
), bb
, insn_info
, 0);
3514 /* Record the register uses. */
3515 df_uses_record (collection_rec
,
3516 &PATTERN (insn_info
->insn
), DF_REF_REG_USE
, bb
, insn_info
, 0);
3518 /* DF_REF_CONDITIONAL needs corresponding USES. */
3520 df_get_conditional_uses (collection_rec
);
3522 df_canonize_collection_rec (collection_rec
);
3525 /* Recompute the luids for the insns in BB. */
3528 df_recompute_luids (basic_block bb
)
3533 df_grow_insn_info ();
3535 /* Scan the block an insn at a time from beginning to end. */
3536 FOR_BB_INSNS (bb
, insn
)
3538 struct df_insn_info
*insn_info
= DF_INSN_INFO_GET (insn
);
3539 /* Inserting labels does not always trigger the incremental
3543 gcc_assert (!INSN_P (insn
));
3544 insn_info
= df_insn_create_insn_record (insn
);
3547 DF_INSN_INFO_LUID (insn_info
) = luid
;
3554 /* Collect all artificial refs at the block level for BB and add them
3555 to COLLECTION_REC. */
3558 df_bb_refs_collect (struct df_collection_rec
*collection_rec
, basic_block bb
)
3560 collection_rec
->def_vec
.truncate (0);
3561 collection_rec
->use_vec
.truncate (0);
3562 collection_rec
->eq_use_vec
.truncate (0);
3563 collection_rec
->mw_vec
.truncate (0);
3565 if (bb
->index
== ENTRY_BLOCK
)
3567 df_entry_block_defs_collect (collection_rec
, df
->entry_block_defs
);
3570 else if (bb
->index
== EXIT_BLOCK
)
3572 df_exit_block_uses_collect (collection_rec
, df
->exit_block_uses
);
3576 #ifdef EH_RETURN_DATA_REGNO
3577 if (bb_has_eh_pred (bb
))
3580 /* Mark the registers that will contain data for the handler. */
3583 unsigned regno
= EH_RETURN_DATA_REGNO (i
);
3584 if (regno
== INVALID_REGNUM
)
3586 df_ref_record (DF_REF_ARTIFICIAL
, collection_rec
, regno_reg_rtx
[regno
], NULL
,
3587 bb
, NULL
, DF_REF_REG_DEF
, DF_REF_AT_TOP
);
3592 /* Add the hard_frame_pointer if this block is the target of a
3594 if (bb
->flags
& BB_NON_LOCAL_GOTO_TARGET
)
3595 df_ref_record (DF_REF_ARTIFICIAL
, collection_rec
, hard_frame_pointer_rtx
, NULL
,
3596 bb
, NULL
, DF_REF_REG_DEF
, DF_REF_AT_TOP
);
3598 /* Add the artificial uses. */
3599 if (bb
->index
>= NUM_FIXED_BLOCKS
)
3603 bitmap au
= bb_has_eh_pred (bb
)
3604 ? &df
->eh_block_artificial_uses
3605 : &df
->regular_block_artificial_uses
;
3607 EXECUTE_IF_SET_IN_BITMAP (au
, 0, regno
, bi
)
3609 df_ref_record (DF_REF_ARTIFICIAL
, collection_rec
, regno_reg_rtx
[regno
], NULL
,
3610 bb
, NULL
, DF_REF_REG_USE
, 0);
3614 df_canonize_collection_rec (collection_rec
);
3618 /* Record all the refs within the basic block BB_INDEX and scan the instructions if SCAN_INSNS. */
3621 df_bb_refs_record (int bb_index
, bool scan_insns
)
3623 basic_block bb
= BASIC_BLOCK_FOR_FN (cfun
, bb_index
);
3630 df_collection_rec collection_rec
;
3631 df_grow_bb_info (df_scan
);
3633 /* Scan the block an insn at a time from beginning to end. */
3634 FOR_BB_INSNS (bb
, insn
)
3636 struct df_insn_info
*insn_info
= DF_INSN_INFO_GET (insn
);
3637 gcc_assert (!insn_info
);
3639 insn_info
= df_insn_create_insn_record (insn
);
3642 /* Record refs within INSN. */
3643 DF_INSN_INFO_LUID (insn_info
) = luid
++;
3644 df_insn_refs_collect (&collection_rec
, bb
, DF_INSN_INFO_GET (insn
));
3645 df_refs_add_to_chains (&collection_rec
, bb
, insn
, copy_all
);
3647 DF_INSN_INFO_LUID (insn_info
) = luid
;
3650 /* Other block level artificial refs */
3651 df_bb_refs_collect (&collection_rec
, bb
);
3652 df_refs_add_to_chains (&collection_rec
, bb
, NULL
, copy_all
);
3654 /* Now that the block has been processed, set the block as dirty so
3655 LR and LIVE will get it processed. */
3656 df_set_bb_dirty (bb
);
3660 /* Get the artificial use set for a regular (i.e. non-exit/non-entry)
3664 df_get_regular_block_artificial_uses (bitmap regular_block_artificial_uses
)
3670 bitmap_clear (regular_block_artificial_uses
);
3672 if (reload_completed
)
3674 if (frame_pointer_needed
)
3675 bitmap_set_bit (regular_block_artificial_uses
, HARD_FRAME_POINTER_REGNUM
);
3678 /* Before reload, there are a few registers that must be forced
3679 live everywhere -- which might not already be the case for
3680 blocks within infinite loops. */
3682 unsigned int picreg
= PIC_OFFSET_TABLE_REGNUM
;
3684 /* Any reference to any pseudo before reload is a potential
3685 reference of the frame pointer. */
3686 bitmap_set_bit (regular_block_artificial_uses
, FRAME_POINTER_REGNUM
);
3688 #if !HARD_FRAME_POINTER_IS_FRAME_POINTER
3689 bitmap_set_bit (regular_block_artificial_uses
, HARD_FRAME_POINTER_REGNUM
);
3692 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
3693 /* Pseudos with argument area equivalences may require
3694 reloading via the argument pointer. */
3695 if (fixed_regs
[ARG_POINTER_REGNUM
])
3696 bitmap_set_bit (regular_block_artificial_uses
, ARG_POINTER_REGNUM
);
3699 /* Any constant, or pseudo with constant equivalences, may
3700 require reloading from memory using the pic register. */
3701 if (picreg
!= INVALID_REGNUM
3702 && fixed_regs
[picreg
])
3703 bitmap_set_bit (regular_block_artificial_uses
, picreg
);
3705 /* The all-important stack pointer must always be live. */
3706 bitmap_set_bit (regular_block_artificial_uses
, STACK_POINTER_REGNUM
);
3709 /* EH_USES registers are used:
3710 1) at all insns that might throw (calls or with -fnon-call-exceptions
3713 3) to support backtraces and/or debugging, anywhere between their
3714 initialization and where they the saved registers are restored
3715 from them, including the cases where we don't reach the epilogue
3716 (noreturn call or infinite loop). */
3717 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
3719 bitmap_set_bit (regular_block_artificial_uses
, i
);
3724 /* Get the artificial use set for an eh block. */
3727 df_get_eh_block_artificial_uses (bitmap eh_block_artificial_uses
)
3729 bitmap_clear (eh_block_artificial_uses
);
3731 /* The following code (down through the arg_pointer setting APPEARS
3732 to be necessary because there is nothing that actually
3733 describes what the exception handling code may actually need
3735 if (reload_completed
)
3737 if (frame_pointer_needed
)
3739 bitmap_set_bit (eh_block_artificial_uses
, FRAME_POINTER_REGNUM
);
3740 #if !HARD_FRAME_POINTER_IS_FRAME_POINTER
3741 bitmap_set_bit (eh_block_artificial_uses
, HARD_FRAME_POINTER_REGNUM
);
3744 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
3745 if (fixed_regs
[ARG_POINTER_REGNUM
])
3746 bitmap_set_bit (eh_block_artificial_uses
, ARG_POINTER_REGNUM
);
3753 /*----------------------------------------------------------------------------
3754 Specialized hard register scanning functions.
3755 ----------------------------------------------------------------------------*/
3758 /* Mark a register in SET. Hard registers in large modes get all
3759 of their component registers set as well. */
3762 df_mark_reg (rtx reg
, void *vset
)
3764 bitmap set
= (bitmap
) vset
;
3765 int regno
= REGNO (reg
);
3767 gcc_assert (GET_MODE (reg
) != BLKmode
);
3769 if (regno
< FIRST_PSEUDO_REGISTER
)
3771 int n
= hard_regno_nregs
[regno
][GET_MODE (reg
)];
3772 bitmap_set_range (set
, regno
, n
);
3775 bitmap_set_bit (set
, regno
);
3779 /* Set the bit for regs that are considered being defined at the entry. */
3782 df_get_entry_block_def_set (bitmap entry_block_defs
)
3787 bitmap_clear (entry_block_defs
);
3789 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
3792 bitmap_set_bit (entry_block_defs
, i
);
3793 if (FUNCTION_ARG_REGNO_P (i
))
3794 bitmap_set_bit (entry_block_defs
, INCOMING_REGNO (i
));
3797 /* The always important stack pointer. */
3798 bitmap_set_bit (entry_block_defs
, STACK_POINTER_REGNUM
);
3800 /* Once the prologue has been generated, all of these registers
3801 should just show up in the first regular block. */
3802 if (HAVE_prologue
&& epilogue_completed
)
3804 /* Defs for the callee saved registers are inserted so that the
3805 pushes have some defining location. */
3806 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
3807 if ((call_used_regs
[i
] == 0) && (df_regs_ever_live_p (i
)))
3808 bitmap_set_bit (entry_block_defs
, i
);
3811 r
= targetm
.calls
.struct_value_rtx (current_function_decl
, true);
3813 bitmap_set_bit (entry_block_defs
, REGNO (r
));
3815 /* If the function has an incoming STATIC_CHAIN, it has to show up
3816 in the entry def set. */
3817 r
= targetm
.calls
.static_chain (current_function_decl
, true);
3819 bitmap_set_bit (entry_block_defs
, REGNO (r
));
3821 if ((!reload_completed
) || frame_pointer_needed
)
3823 /* Any reference to any pseudo before reload is a potential
3824 reference of the frame pointer. */
3825 bitmap_set_bit (entry_block_defs
, FRAME_POINTER_REGNUM
);
3826 #if !HARD_FRAME_POINTER_IS_FRAME_POINTER
3827 /* If they are different, also mark the hard frame pointer as live. */
3828 if (!LOCAL_REGNO (HARD_FRAME_POINTER_REGNUM
))
3829 bitmap_set_bit (entry_block_defs
, HARD_FRAME_POINTER_REGNUM
);
3833 /* These registers are live everywhere. */
3834 if (!reload_completed
)
3836 #ifdef PIC_OFFSET_TABLE_REGNUM
3837 unsigned int picreg
= PIC_OFFSET_TABLE_REGNUM
;
3840 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
3841 /* Pseudos with argument area equivalences may require
3842 reloading via the argument pointer. */
3843 if (fixed_regs
[ARG_POINTER_REGNUM
])
3844 bitmap_set_bit (entry_block_defs
, ARG_POINTER_REGNUM
);
3847 #ifdef PIC_OFFSET_TABLE_REGNUM
3848 /* Any constant, or pseudo with constant equivalences, may
3849 require reloading from memory using the pic register. */
3850 if (picreg
!= INVALID_REGNUM
3851 && fixed_regs
[picreg
])
3852 bitmap_set_bit (entry_block_defs
, picreg
);
3856 #ifdef INCOMING_RETURN_ADDR_RTX
3857 if (REG_P (INCOMING_RETURN_ADDR_RTX
))
3858 bitmap_set_bit (entry_block_defs
, REGNO (INCOMING_RETURN_ADDR_RTX
));
3861 targetm
.extra_live_on_entry (entry_block_defs
);
3865 /* Return the (conservative) set of hard registers that are defined on
3866 entry to the function.
3867 It uses df->entry_block_defs to determine which register
3868 reference to include. */
3871 df_entry_block_defs_collect (struct df_collection_rec
*collection_rec
,
3872 bitmap entry_block_defs
)
3877 EXECUTE_IF_SET_IN_BITMAP (entry_block_defs
, 0, i
, bi
)
3879 df_ref_record (DF_REF_ARTIFICIAL
, collection_rec
, regno_reg_rtx
[i
], NULL
,
3880 ENTRY_BLOCK_PTR_FOR_FN (cfun
), NULL
, DF_REF_REG_DEF
, 0);
3883 df_canonize_collection_rec (collection_rec
);
3887 /* Record the (conservative) set of hard registers that are defined on
3888 entry to the function. */
3891 df_record_entry_block_defs (bitmap entry_block_defs
)
3893 struct df_collection_rec collection_rec
;
3894 df_entry_block_defs_collect (&collection_rec
, entry_block_defs
);
3896 /* Process bb_refs chain */
3897 df_refs_add_to_chains (&collection_rec
,
3898 BASIC_BLOCK_FOR_FN (cfun
, ENTRY_BLOCK
),
3904 /* Update the defs in the entry block. */
3907 df_update_entry_block_defs (void)
3910 bool changed
= false;
3912 bitmap_initialize (&refs
, &df_bitmap_obstack
);
3913 df_get_entry_block_def_set (&refs
);
3914 if (df
->entry_block_defs
)
3916 if (!bitmap_equal_p (df
->entry_block_defs
, &refs
))
3918 struct df_scan_bb_info
*bb_info
= df_scan_get_bb_info (ENTRY_BLOCK
);
3919 df_ref_chain_delete_du_chain (bb_info
->artificial_defs
);
3920 df_ref_chain_delete (bb_info
->artificial_defs
);
3921 bb_info
->artificial_defs
= NULL
;
3927 struct df_scan_problem_data
*problem_data
3928 = (struct df_scan_problem_data
*) df_scan
->problem_data
;
3930 df
->entry_block_defs
= BITMAP_ALLOC (&problem_data
->reg_bitmaps
);
3936 df_record_entry_block_defs (&refs
);
3937 bitmap_copy (df
->entry_block_defs
, &refs
);
3938 df_set_bb_dirty (BASIC_BLOCK_FOR_FN (cfun
, ENTRY_BLOCK
));
3940 bitmap_clear (&refs
);
3944 /* Set the bit for regs that are considered being used at the exit. */
3947 df_get_exit_block_use_set (bitmap exit_block_uses
)
3950 unsigned int picreg
= PIC_OFFSET_TABLE_REGNUM
;
3952 bitmap_clear (exit_block_uses
);
3954 /* Stack pointer is always live at the exit. */
3955 bitmap_set_bit (exit_block_uses
, STACK_POINTER_REGNUM
);
3957 /* Mark the frame pointer if needed at the end of the function.
3958 If we end up eliminating it, it will be removed from the live
3959 list of each basic block by reload. */
3961 if ((!reload_completed
) || frame_pointer_needed
)
3963 bitmap_set_bit (exit_block_uses
, FRAME_POINTER_REGNUM
);
3964 #if !HARD_FRAME_POINTER_IS_FRAME_POINTER
3965 /* If they are different, also mark the hard frame pointer as live. */
3966 if (!LOCAL_REGNO (HARD_FRAME_POINTER_REGNUM
))
3967 bitmap_set_bit (exit_block_uses
, HARD_FRAME_POINTER_REGNUM
);
3971 /* Many architectures have a GP register even without flag_pic.
3972 Assume the pic register is not in use, or will be handled by
3973 other means, if it is not fixed. */
3974 if (!PIC_OFFSET_TABLE_REG_CALL_CLOBBERED
3975 && picreg
!= INVALID_REGNUM
3976 && fixed_regs
[picreg
])
3977 bitmap_set_bit (exit_block_uses
, picreg
);
3979 /* Mark all global registers, and all registers used by the
3980 epilogue as being live at the end of the function since they
3981 may be referenced by our caller. */
3982 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
3983 if (global_regs
[i
] || EPILOGUE_USES (i
))
3984 bitmap_set_bit (exit_block_uses
, i
);
3986 if (HAVE_epilogue
&& epilogue_completed
)
3988 /* Mark all call-saved registers that we actually used. */
3989 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
3990 if (df_regs_ever_live_p (i
) && !LOCAL_REGNO (i
)
3991 && !TEST_HARD_REG_BIT (regs_invalidated_by_call
, i
))
3992 bitmap_set_bit (exit_block_uses
, i
);
3995 #ifdef EH_RETURN_DATA_REGNO
3996 /* Mark the registers that will contain data for the handler. */
3997 if (reload_completed
&& crtl
->calls_eh_return
)
4000 unsigned regno
= EH_RETURN_DATA_REGNO (i
);
4001 if (regno
== INVALID_REGNUM
)
4003 bitmap_set_bit (exit_block_uses
, regno
);
4007 #ifdef EH_RETURN_STACKADJ_RTX
4008 if ((!HAVE_epilogue
|| ! epilogue_completed
)
4009 && crtl
->calls_eh_return
)
4011 rtx tmp
= EH_RETURN_STACKADJ_RTX
;
4012 if (tmp
&& REG_P (tmp
))
4013 df_mark_reg (tmp
, exit_block_uses
);
4017 #ifdef EH_RETURN_HANDLER_RTX
4018 if ((!HAVE_epilogue
|| ! epilogue_completed
)
4019 && crtl
->calls_eh_return
)
4021 rtx tmp
= EH_RETURN_HANDLER_RTX
;
4022 if (tmp
&& REG_P (tmp
))
4023 df_mark_reg (tmp
, exit_block_uses
);
4027 /* Mark function return value. */
4028 diddle_return_value (df_mark_reg
, (void*) exit_block_uses
);
4032 /* Return the refs of hard registers that are used in the exit block.
4033 It uses df->exit_block_uses to determine register to include. */
4036 df_exit_block_uses_collect (struct df_collection_rec
*collection_rec
, bitmap exit_block_uses
)
4041 EXECUTE_IF_SET_IN_BITMAP (exit_block_uses
, 0, i
, bi
)
4042 df_ref_record (DF_REF_ARTIFICIAL
, collection_rec
, regno_reg_rtx
[i
], NULL
,
4043 EXIT_BLOCK_PTR_FOR_FN (cfun
), NULL
, DF_REF_REG_USE
, 0);
4045 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
4046 /* It is deliberate that this is not put in the exit block uses but
4047 I do not know why. */
4048 if (reload_completed
4049 && !bitmap_bit_p (exit_block_uses
, ARG_POINTER_REGNUM
)
4050 && bb_has_eh_pred (EXIT_BLOCK_PTR_FOR_FN (cfun
))
4051 && fixed_regs
[ARG_POINTER_REGNUM
])
4052 df_ref_record (DF_REF_ARTIFICIAL
, collection_rec
, regno_reg_rtx
[ARG_POINTER_REGNUM
], NULL
,
4053 EXIT_BLOCK_PTR_FOR_FN (cfun
), NULL
, DF_REF_REG_USE
, 0);
4056 df_canonize_collection_rec (collection_rec
);
4060 /* Record the set of hard registers that are used in the exit block.
4061 It uses df->exit_block_uses to determine which bit to include. */
4064 df_record_exit_block_uses (bitmap exit_block_uses
)
4066 struct df_collection_rec collection_rec
;
4067 df_exit_block_uses_collect (&collection_rec
, exit_block_uses
);
4069 /* Process bb_refs chain */
4070 df_refs_add_to_chains (&collection_rec
,
4071 BASIC_BLOCK_FOR_FN (cfun
, EXIT_BLOCK
),
4077 /* Update the uses in the exit block. */
4080 df_update_exit_block_uses (void)
4083 bool changed
= false;
4085 bitmap_initialize (&refs
, &df_bitmap_obstack
);
4086 df_get_exit_block_use_set (&refs
);
4087 if (df
->exit_block_uses
)
4089 if (!bitmap_equal_p (df
->exit_block_uses
, &refs
))
4091 struct df_scan_bb_info
*bb_info
= df_scan_get_bb_info (EXIT_BLOCK
);
4092 df_ref_chain_delete_du_chain (bb_info
->artificial_uses
);
4093 df_ref_chain_delete (bb_info
->artificial_uses
);
4094 bb_info
->artificial_uses
= NULL
;
4100 struct df_scan_problem_data
*problem_data
4101 = (struct df_scan_problem_data
*) df_scan
->problem_data
;
4103 df
->exit_block_uses
= BITMAP_ALLOC (&problem_data
->reg_bitmaps
);
4109 df_record_exit_block_uses (&refs
);
4110 bitmap_copy (df
->exit_block_uses
,& refs
);
4111 df_set_bb_dirty (BASIC_BLOCK_FOR_FN (cfun
, EXIT_BLOCK
));
4113 bitmap_clear (&refs
);
4116 static bool initialized
= false;
4119 /* Initialize some platform specific structures. */
4122 df_hard_reg_init (void)
4124 #ifdef ELIMINABLE_REGS
4126 static const struct {const int from
, to
; } eliminables
[] = ELIMINABLE_REGS
;
4131 /* Record which registers will be eliminated. We use this in
4133 CLEAR_HARD_REG_SET (elim_reg_set
);
4135 #ifdef ELIMINABLE_REGS
4136 for (i
= 0; i
< (int) ARRAY_SIZE (eliminables
); i
++)
4137 SET_HARD_REG_BIT (elim_reg_set
, eliminables
[i
].from
);
4139 SET_HARD_REG_BIT (elim_reg_set
, FRAME_POINTER_REGNUM
);
4146 /* Recompute the parts of scanning that are based on regs_ever_live
4147 because something changed in that array. */
4150 df_update_entry_exit_and_calls (void)
4154 df_update_entry_block_defs ();
4155 df_update_exit_block_uses ();
4157 /* The call insns need to be rescanned because there may be changes
4158 in the set of registers clobbered across the call. */
4159 FOR_EACH_BB_FN (bb
, cfun
)
4162 FOR_BB_INSNS (bb
, insn
)
4164 if (INSN_P (insn
) && CALL_P (insn
))
4165 df_insn_rescan (insn
);
4171 /* Return true if hard REG is actually used in the some instruction.
4172 There are a fair number of conditions that affect the setting of
4173 this array. See the comment in df.h for df->hard_regs_live_count
4174 for the conditions that this array is set. */
4177 df_hard_reg_used_p (unsigned int reg
)
4179 return df
->hard_regs_live_count
[reg
] != 0;
4183 /* A count of the number of times REG is actually used in the some
4184 instruction. There are a fair number of conditions that affect the
4185 setting of this array. See the comment in df.h for
4186 df->hard_regs_live_count for the conditions that this array is
4191 df_hard_reg_used_count (unsigned int reg
)
4193 return df
->hard_regs_live_count
[reg
];
4197 /* Get the value of regs_ever_live[REGNO]. */
4200 df_regs_ever_live_p (unsigned int regno
)
4202 return regs_ever_live
[regno
];
4206 /* Set regs_ever_live[REGNO] to VALUE. If this cause regs_ever_live
4207 to change, schedule that change for the next update. */
4210 df_set_regs_ever_live (unsigned int regno
, bool value
)
4212 if (regs_ever_live
[regno
] == value
)
4215 regs_ever_live
[regno
] = value
;
4217 df
->redo_entry_and_exit
= true;
4221 /* Compute "regs_ever_live" information from the underlying df
4222 information. Set the vector to all false if RESET. */
4225 df_compute_regs_ever_live (bool reset
)
4228 bool changed
= df
->redo_entry_and_exit
;
4231 memset (regs_ever_live
, 0, sizeof (regs_ever_live
));
4233 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
4234 if ((!regs_ever_live
[i
]) && df_hard_reg_used_p (i
))
4236 regs_ever_live
[i
] = true;
4240 df_update_entry_exit_and_calls ();
4241 df
->redo_entry_and_exit
= false;
4245 /*----------------------------------------------------------------------------
4246 Dataflow ref information verification functions.
4248 df_reg_chain_mark (refs, regno, is_def, is_eq_use)
4249 df_reg_chain_verify_unmarked (refs)
4250 df_refs_verify (vec<stack, va_df_ref>, ref*, bool)
4251 df_mws_verify (mw*, mw*, bool)
4252 df_insn_refs_verify (collection_rec, bb, insn, bool)
4253 df_bb_refs_verify (bb, refs, bool)
4255 df_exit_block_bitmap_verify (bool)
4256 df_entry_block_bitmap_verify (bool)
4258 ----------------------------------------------------------------------------*/
4261 /* Mark all refs in the reg chain. Verify that all of the registers
4262 are in the correct chain. */
4265 df_reg_chain_mark (df_ref refs
, unsigned int regno
,
4266 bool is_def
, bool is_eq_use
)
4268 unsigned int count
= 0;
4270 for (ref
= refs
; ref
; ref
= DF_REF_NEXT_REG (ref
))
4272 gcc_assert (!DF_REF_IS_REG_MARKED (ref
));
4274 /* If there are no def-use or use-def chains, make sure that all
4275 of the chains are clear. */
4277 gcc_assert (!DF_REF_CHAIN (ref
));
4279 /* Check to make sure the ref is in the correct chain. */
4280 gcc_assert (DF_REF_REGNO (ref
) == regno
);
4282 gcc_assert (DF_REF_REG_DEF_P (ref
));
4284 gcc_assert (!DF_REF_REG_DEF_P (ref
));
4287 gcc_assert ((DF_REF_FLAGS (ref
) & DF_REF_IN_NOTE
));
4289 gcc_assert ((DF_REF_FLAGS (ref
) & DF_REF_IN_NOTE
) == 0);
4291 if (DF_REF_NEXT_REG (ref
))
4292 gcc_assert (DF_REF_PREV_REG (DF_REF_NEXT_REG (ref
)) == ref
);
4294 DF_REF_REG_MARK (ref
);
4300 /* Verify that all of the registers in the chain are unmarked. */
4303 df_reg_chain_verify_unmarked (df_ref refs
)
4306 for (ref
= refs
; ref
; ref
= DF_REF_NEXT_REG (ref
))
4307 gcc_assert (!DF_REF_IS_REG_MARKED (ref
));
4311 /* Verify that NEW_REC and OLD_REC have exactly the same members. */
4314 df_refs_verify (const vec
<df_ref
, va_heap
> *new_rec
, df_ref
*old_rec
,
4320 FOR_EACH_VEC_ELT (*new_rec
, ix
, new_ref
)
4322 if (*old_rec
== NULL
|| !df_ref_equal_p (new_ref
, *old_rec
))
4330 /* Abort if fail is called from the function level verifier. If
4331 that is the context, mark this reg as being seem. */
4334 gcc_assert (DF_REF_IS_REG_MARKED (*old_rec
));
4335 DF_REF_REG_UNMARK (*old_rec
);
4342 gcc_assert (*old_rec
== NULL
);
4344 return *old_rec
== NULL
;
4349 /* Verify that NEW_REC and OLD_REC have exactly the same members. */
4352 df_mws_verify (const vec
<df_mw_hardreg_ptr
, va_heap
> *new_rec
,
4353 struct df_mw_hardreg
**old_rec
,
4357 struct df_mw_hardreg
*new_reg
;
4359 FOR_EACH_VEC_ELT (*new_rec
, ix
, new_reg
)
4361 if (*old_rec
== NULL
|| !df_mw_equal_p (new_reg
, *old_rec
))
4372 gcc_assert (*old_rec
== NULL
);
4374 return *old_rec
== NULL
;
4379 /* Return true if the existing insn refs information is complete and
4380 correct. Otherwise (i.e. if there's any missing or extra refs),
4381 return the correct df_ref chain in REFS_RETURN.
4383 If ABORT_IF_FAIL, leave the refs that are verified (already in the
4384 ref chain) as DF_REF_MARKED(). If it's false, then it's a per-insn
4385 verification mode instead of the whole function, so unmark
4388 If ABORT_IF_FAIL is set, this function never returns false. */
4391 df_insn_refs_verify (struct df_collection_rec
*collection_rec
,
4396 bool ret1
, ret2
, ret3
, ret4
;
4397 unsigned int uid
= INSN_UID (insn
);
4398 struct df_insn_info
*insn_info
= DF_INSN_INFO_GET (insn
);
4400 df_insn_refs_collect (collection_rec
, bb
, insn_info
);
4402 if (!DF_INSN_UID_DEFS (uid
))
4404 /* The insn_rec was created but it was never filled out. */
4411 /* Unfortunately we cannot opt out early if one of these is not
4412 right because the marks will not get cleared. */
4413 ret1
= df_refs_verify (&collection_rec
->def_vec
, DF_INSN_UID_DEFS (uid
),
4415 ret2
= df_refs_verify (&collection_rec
->use_vec
, DF_INSN_UID_USES (uid
),
4417 ret3
= df_refs_verify (&collection_rec
->eq_use_vec
, DF_INSN_UID_EQ_USES (uid
),
4419 ret4
= df_mws_verify (&collection_rec
->mw_vec
, DF_INSN_UID_MWS (uid
),
4421 return (ret1
&& ret2
&& ret3
&& ret4
);
4425 /* Return true if all refs in the basic block are correct and complete.
4426 Due to df_ref_chain_verify, it will cause all refs
4427 that are verified to have DF_REF_MARK bit set. */
4430 df_bb_verify (basic_block bb
)
4433 struct df_scan_bb_info
*bb_info
= df_scan_get_bb_info (bb
->index
);
4434 struct df_collection_rec collection_rec
;
4436 gcc_assert (bb_info
);
4438 /* Scan the block, one insn at a time, from beginning to end. */
4439 FOR_BB_INSNS_REVERSE (bb
, insn
)
4443 df_insn_refs_verify (&collection_rec
, bb
, insn
, true);
4444 df_free_collection_rec (&collection_rec
);
4447 /* Do the artificial defs and uses. */
4448 df_bb_refs_collect (&collection_rec
, bb
);
4449 df_refs_verify (&collection_rec
.def_vec
, df_get_artificial_defs (bb
->index
), true);
4450 df_refs_verify (&collection_rec
.use_vec
, df_get_artificial_uses (bb
->index
), true);
4451 df_free_collection_rec (&collection_rec
);
4457 /* Returns true if the entry block has correct and complete df_ref set.
4458 If not it either aborts if ABORT_IF_FAIL is true or returns false. */
4461 df_entry_block_bitmap_verify (bool abort_if_fail
)
4463 bitmap_head entry_block_defs
;
4466 bitmap_initialize (&entry_block_defs
, &df_bitmap_obstack
);
4467 df_get_entry_block_def_set (&entry_block_defs
);
4469 is_eq
= bitmap_equal_p (&entry_block_defs
, df
->entry_block_defs
);
4471 if (!is_eq
&& abort_if_fail
)
4473 fprintf (stderr
, "entry_block_defs = ");
4474 df_print_regset (stderr
, &entry_block_defs
);
4475 fprintf (stderr
, "df->entry_block_defs = ");
4476 df_print_regset (stderr
, df
->entry_block_defs
);
4480 bitmap_clear (&entry_block_defs
);
4486 /* Returns true if the exit block has correct and complete df_ref set.
4487 If not it either aborts if ABORT_IF_FAIL is true or returns false. */
4490 df_exit_block_bitmap_verify (bool abort_if_fail
)
4492 bitmap_head exit_block_uses
;
4495 bitmap_initialize (&exit_block_uses
, &df_bitmap_obstack
);
4496 df_get_exit_block_use_set (&exit_block_uses
);
4498 is_eq
= bitmap_equal_p (&exit_block_uses
, df
->exit_block_uses
);
4500 if (!is_eq
&& abort_if_fail
)
4502 fprintf (stderr
, "exit_block_uses = ");
4503 df_print_regset (stderr
, &exit_block_uses
);
4504 fprintf (stderr
, "df->exit_block_uses = ");
4505 df_print_regset (stderr
, df
->exit_block_uses
);
4509 bitmap_clear (&exit_block_uses
);
4515 /* Return true if df_ref information for all insns in all blocks are
4516 correct and complete. */
4519 df_scan_verify (void)
4523 bitmap_head regular_block_artificial_uses
;
4524 bitmap_head eh_block_artificial_uses
;
4529 /* Verification is a 4 step process. */
4531 /* (1) All of the refs are marked by going through the reg chains. */
4532 for (i
= 0; i
< DF_REG_SIZE (df
); i
++)
4534 gcc_assert (df_reg_chain_mark (DF_REG_DEF_CHAIN (i
), i
, true, false)
4535 == DF_REG_DEF_COUNT (i
));
4536 gcc_assert (df_reg_chain_mark (DF_REG_USE_CHAIN (i
), i
, false, false)
4537 == DF_REG_USE_COUNT (i
));
4538 gcc_assert (df_reg_chain_mark (DF_REG_EQ_USE_CHAIN (i
), i
, false, true)
4539 == DF_REG_EQ_USE_COUNT (i
));
4542 /* (2) There are various bitmaps whose value may change over the
4543 course of the compilation. This step recomputes them to make
4544 sure that they have not slipped out of date. */
4545 bitmap_initialize (®ular_block_artificial_uses
, &df_bitmap_obstack
);
4546 bitmap_initialize (&eh_block_artificial_uses
, &df_bitmap_obstack
);
4548 df_get_regular_block_artificial_uses (®ular_block_artificial_uses
);
4549 df_get_eh_block_artificial_uses (&eh_block_artificial_uses
);
4551 bitmap_ior_into (&eh_block_artificial_uses
,
4552 ®ular_block_artificial_uses
);
4554 /* Check artificial_uses bitmaps didn't change. */
4555 gcc_assert (bitmap_equal_p (®ular_block_artificial_uses
,
4556 &df
->regular_block_artificial_uses
));
4557 gcc_assert (bitmap_equal_p (&eh_block_artificial_uses
,
4558 &df
->eh_block_artificial_uses
));
4560 bitmap_clear (®ular_block_artificial_uses
);
4561 bitmap_clear (&eh_block_artificial_uses
);
4563 /* Verify entry block and exit block. These only verify the bitmaps,
4564 the refs are verified in df_bb_verify. */
4565 df_entry_block_bitmap_verify (true);
4566 df_exit_block_bitmap_verify (true);
4568 /* (3) All of the insns in all of the blocks are traversed and the
4569 marks are cleared both in the artificial refs attached to the
4570 blocks and the real refs inside the insns. It is a failure to
4571 clear a mark that has not been set as this means that the ref in
4572 the block or insn was not in the reg chain. */
4574 FOR_ALL_BB_FN (bb
, cfun
)
4577 /* (4) See if all reg chains are traversed a second time. This time
4578 a check is made that the marks are clear. A set mark would be a
4579 from a reg that is not in any insn or basic block. */
4581 for (i
= 0; i
< DF_REG_SIZE (df
); i
++)
4583 df_reg_chain_verify_unmarked (DF_REG_DEF_CHAIN (i
));
4584 df_reg_chain_verify_unmarked (DF_REG_USE_CHAIN (i
));
4585 df_reg_chain_verify_unmarked (DF_REG_EQ_USE_CHAIN (i
));