1 /* Dataflow support routines.
2 Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
3 Contributed by Michael P. Hayes (m.hayes@elec.canterbury.ac.nz,
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 2, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING. If not, write to the Free
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
26 This file provides some dataflow routines for computing reaching defs,
27 upward exposed uses, live variables, def-use chains, and use-def
28 chains. The global dataflow is performed using simple iterative
29 methods with a worklist and could be sped up by ordering the blocks
30 with a depth first search order.
32 A `struct ref' data structure (ref) is allocated for every register
33 reference (def or use) and this records the insn and bb the ref is
34 found within. The refs are linked together in chains of uses and defs
35 for each insn and for each register. Each ref also has a chain field
36 that links all the use refs for a def or all the def refs for a use.
37 This is used to create use-def or def-use chains.
42 Here's an example of using the dataflow routines.
48 df_analyse (df, 0, DF_ALL);
50 df_dump (df, DF_ALL, stderr);
55 df_init simply creates a poor man's object (df) that needs to be
56 passed to all the dataflow routines. df_finish destroys this
57 object and frees up any allocated memory.
59 df_analyse performs the following:
61 1. Records defs and uses by scanning the insns in each basic block
62 or by scanning the insns queued by df_insn_modify.
63 2. Links defs and uses into insn-def and insn-use chains.
64 3. Links defs and uses into reg-def and reg-use chains.
65 4. Assigns LUIDs to each insn (for modified blocks).
66 5. Calculates local reaching definitions.
67 6. Calculates global reaching definitions.
68 7. Creates use-def chains.
69 8. Calculates local reaching uses (upwards exposed uses).
70 9. Calculates global reaching uses.
71 10. Creates def-use chains.
72 11. Calculates local live registers.
73 12. Calculates global live registers.
74 13. Calculates register lifetimes and determines local registers.
79 Note that the dataflow information is not updated for every newly
80 deleted or created insn. If the dataflow information requires
81 updating then all the changed, new, or deleted insns needs to be
82 marked with df_insn_modify (or df_insns_modify) either directly or
83 indirectly (say through calling df_insn_delete). df_insn_modify
84 marks all the modified insns to get processed the next time df_analyse
87 Beware that tinkering with insns may invalidate the dataflow information.
88 The philosophy behind these routines is that once the dataflow
89 information has been gathered, the user should store what they require
90 before they tinker with any insn. Once a reg is replaced, for example,
91 then the reg-def/reg-use chains will point to the wrong place. Once a
92 whole lot of changes have been made, df_analyse can be called again
93 to update the dataflow information. Currently, this is not very smart
94 with regard to propagating changes to the dataflow so it should not
100 The basic object is a REF (reference) and this may either be a DEF
101 (definition) or a USE of a register.
103 These are linked into a variety of lists; namely reg-def, reg-use,
104 insn-def, insn-use, def-use, and use-def lists. For example,
105 the reg-def lists contain all the refs that define a given register
106 while the insn-use lists contain all the refs used by an insn.
108 Note that the reg-def and reg-use chains are generally short (except for the
109 hard registers) and thus it is much faster to search these chains
110 rather than searching the def or use bitmaps.
112 If the insns are in SSA form then the reg-def and use-def lists
113 should only contain the single defining ref.
117 1) Incremental dataflow analysis.
119 Note that if a loop invariant insn is hoisted (or sunk), we do not
120 need to change the def-use or use-def chains. All we have to do is to
121 change the bb field for all the associated defs and uses and to
122 renumber the LUIDs for the original and new basic blocks of the insn.
124 When shadowing loop mems we create new uses and defs for new pseudos
125 so we do not affect the existing dataflow information.
127 My current strategy is to queue up all modified, created, or deleted
128 insns so when df_analyse is called we can easily determine all the new
129 or deleted refs. Currently the global dataflow information is
130 recomputed from scratch but this could be propagated more efficiently.
132 2) Improved global data flow computation using depth first search.
134 3) Reduced memory requirements.
136 We could operate a pool of ref structures. When a ref is deleted it
137 gets returned to the pool (say by linking on to a chain of free refs).
138 This will require a pair of bitmaps for defs and uses so that we can
139 tell which ones have been changed. Alternatively, we could
140 periodically squeeze the def and use tables and associated bitmaps and
141 renumber the def and use ids.
143 4) Ordering of reg-def and reg-use lists.
145 Should the first entry in the def list be the first def (within a BB)?
146 Similarly, should the first entry in the use list be the last use
149 5) Working with a sub-CFG.
151 Often the whole CFG does not need to be analysed, for example,
152 when optimising a loop, only certain registers are of interest.
153 Perhaps there should be a bitmap argument to df_analyse to specify
154 which registers should be analysed? */
156 #define HANDLE_SUBREG
162 #include "insn-config.h"
164 #include "function.h"
167 #include "hard-reg-set.h"
168 #include "basic-block.h"
174 #define FOR_EACH_BB_IN_BITMAP(BITMAP, MIN, BB, CODE) \
176 unsigned int node_; \
177 EXECUTE_IF_SET_IN_BITMAP (BITMAP, MIN, node_, \
178 {(BB) = BASIC_BLOCK (node_); CODE;});} while (0)
180 #define FOR_EACH_BB_IN_BITMAP_REV(BITMAP, MIN, BB, CODE) \
182 unsigned int node_; \
183 EXECUTE_IF_SET_IN_BITMAP_REV (BITMAP, node_, \
184 {(BB) = BASIC_BLOCK (node_); CODE;});} while (0)
186 #define FOR_EACH_BB_IN_SBITMAP(BITMAP, MIN, BB, CODE) \
188 unsigned int node_; \
189 EXECUTE_IF_SET_IN_SBITMAP (BITMAP, MIN, node_, \
190 {(BB) = BASIC_BLOCK (node_); CODE;});} while (0)
192 #define obstack_chunk_alloc xmalloc
193 #define obstack_chunk_free free
195 static struct obstack df_ref_obstack;
196 static struct df *ddf;
198 static void df_reg_table_realloc PARAMS((struct df *, int));
200 static void df_def_table_realloc PARAMS((struct df *, int));
202 static void df_insn_table_realloc PARAMS((struct df *, int));
203 static void df_bitmaps_alloc PARAMS((struct df *, int));
204 static void df_bitmaps_free PARAMS((struct df *, int));
205 static void df_free PARAMS((struct df *));
206 static void df_alloc PARAMS((struct df *, int));
208 static rtx df_reg_clobber_gen PARAMS((unsigned int));
209 static rtx df_reg_use_gen PARAMS((unsigned int));
211 static inline struct df_link *df_link_create PARAMS((struct ref *,
213 static struct df_link *df_ref_unlink PARAMS((struct df_link **, struct ref *));
214 static void df_def_unlink PARAMS((struct df *, struct ref *));
215 static void df_use_unlink PARAMS((struct df *, struct ref *));
216 static void df_insn_refs_unlink PARAMS ((struct df *, basic_block, rtx));
218 static void df_bb_refs_unlink PARAMS ((struct df *, basic_block));
219 static void df_refs_unlink PARAMS ((struct df *, bitmap));
222 static struct ref *df_ref_create PARAMS((struct df *,
224 enum df_ref_type, enum df_ref_flags));
225 static void df_ref_record_1 PARAMS((struct df *, rtx, rtx *,
226 rtx, enum df_ref_type,
228 static void df_ref_record PARAMS((struct df *, rtx, rtx *,
229 rtx, enum df_ref_type,
231 static void df_def_record_1 PARAMS((struct df *, rtx, basic_block, rtx));
232 static void df_defs_record PARAMS((struct df *, rtx, basic_block, rtx));
233 static void df_uses_record PARAMS((struct df *, rtx *,
234 enum df_ref_type, basic_block, rtx,
236 static void df_insn_refs_record PARAMS((struct df *, basic_block, rtx));
237 static void df_bb_refs_record PARAMS((struct df *, basic_block));
238 static void df_refs_record PARAMS((struct df *, bitmap));
240 static void df_bb_reg_def_chain_create PARAMS((struct df *, basic_block));
241 static void df_reg_def_chain_create PARAMS((struct df *, bitmap));
242 static void df_bb_reg_use_chain_create PARAMS((struct df *, basic_block));
243 static void df_reg_use_chain_create PARAMS((struct df *, bitmap));
244 static void df_bb_du_chain_create PARAMS((struct df *, basic_block, bitmap));
245 static void df_du_chain_create PARAMS((struct df *, bitmap));
246 static void df_bb_ud_chain_create PARAMS((struct df *, basic_block));
247 static void df_ud_chain_create PARAMS((struct df *, bitmap));
248 static void df_bb_rd_local_compute PARAMS((struct df *, basic_block));
249 static void df_rd_local_compute PARAMS((struct df *, bitmap));
250 static void df_bb_ru_local_compute PARAMS((struct df *, basic_block));
251 static void df_ru_local_compute PARAMS((struct df *, bitmap));
252 static void df_bb_lr_local_compute PARAMS((struct df *, basic_block));
253 static void df_lr_local_compute PARAMS((struct df *, bitmap));
254 static void df_bb_reg_info_compute PARAMS((struct df *, basic_block, bitmap));
255 static void df_reg_info_compute PARAMS((struct df *, bitmap));
257 static int df_bb_luids_set PARAMS((struct df *df, basic_block));
258 static int df_luids_set PARAMS((struct df *df, bitmap));
260 static int df_modified_p PARAMS ((struct df *, bitmap));
261 static int df_refs_queue PARAMS ((struct df *));
262 static int df_refs_process PARAMS ((struct df *));
263 static int df_bb_refs_update PARAMS ((struct df *, basic_block));
264 static int df_refs_update PARAMS ((struct df *));
265 static void df_analyse_1 PARAMS((struct df *, bitmap, int, int));
267 static void df_insns_modify PARAMS((struct df *, basic_block,
269 static int df_rtx_mem_replace PARAMS ((rtx *, void *));
270 static int df_rtx_reg_replace PARAMS ((rtx *, void *));
271 void df_refs_reg_replace PARAMS ((struct df *, bitmap,
272 struct df_link *, rtx, rtx));
274 static int df_def_dominates_all_uses_p PARAMS((struct df *, struct ref *def));
275 static int df_def_dominates_uses_p PARAMS((struct df *,
276 struct ref *def, bitmap));
277 static struct ref *df_bb_regno_last_use_find PARAMS((struct df *, basic_block,
279 static struct ref *df_bb_regno_first_def_find PARAMS((struct df *, basic_block,
281 static struct ref *df_bb_insn_regno_last_use_find PARAMS((struct df *,
284 static struct ref *df_bb_insn_regno_first_def_find PARAMS((struct df *,
288 static void df_chain_dump PARAMS((struct df_link *, FILE *file));
289 static void df_chain_dump_regno PARAMS((struct df_link *, FILE *file));
290 static void df_regno_debug PARAMS ((struct df *, unsigned int, FILE *));
291 static void df_ref_debug PARAMS ((struct df *, struct ref *, FILE *));
292 static void df_rd_transfer_function PARAMS ((int, int *, bitmap, bitmap,
293 bitmap, bitmap, void *));
294 static void df_ru_transfer_function PARAMS ((int, int *, bitmap, bitmap,
295 bitmap, bitmap, void *));
296 static void df_lr_transfer_function PARAMS ((int, int *, bitmap, bitmap,
297 bitmap, bitmap, void *));
298 static void hybrid_search_bitmap PARAMS ((basic_block, bitmap *, bitmap *,
299 bitmap *, bitmap *, enum df_flow_dir,
300 enum df_confluence_op,
301 transfer_function_bitmap,
302 sbitmap, sbitmap, void *));
303 static void hybrid_search_sbitmap PARAMS ((basic_block, sbitmap *, sbitmap *,
304 sbitmap *, sbitmap *, enum df_flow_dir,
305 enum df_confluence_op,
306 transfer_function_sbitmap,
307 sbitmap, sbitmap, void *));
308 static inline bool read_modify_subreg_p PARAMS ((rtx));
311 /* Local memory allocation/deallocation routines. */
314 /* Increase the insn info table by SIZE more elements. */
316 df_insn_table_realloc (df, size)
320 /* Make table 25 percent larger by default. */
322 size = df->insn_size / 4;
324 size += df->insn_size;
326 df->insns = (struct insn_info *)
327 xrealloc (df->insns, size * sizeof (struct insn_info));
329 memset (df->insns + df->insn_size, 0,
330 (size - df->insn_size) * sizeof (struct insn_info));
332 df->insn_size = size;
334 if (! df->insns_modified)
336 df->insns_modified = BITMAP_XMALLOC ();
337 bitmap_zero (df->insns_modified);
342 /* Increase the reg info table by SIZE more elements. */
344 df_reg_table_realloc (df, size)
348 /* Make table 25 percent larger by default. */
350 size = df->reg_size / 4;
352 size += df->reg_size;
354 df->regs = (struct reg_info *)
355 xrealloc (df->regs, size * sizeof (struct reg_info));
357 /* Zero the new entries. */
358 memset (df->regs + df->reg_size, 0,
359 (size - df->reg_size) * sizeof (struct reg_info));
366 /* Not currently used. */
368 df_def_table_realloc (df, size)
375 /* Make table 25 percent larger by default. */
377 size = df->def_size / 4;
379 df->def_size += size;
380 df->defs = xrealloc (df->defs,
381 df->def_size * sizeof (*df->defs));
383 /* Allocate a new block of memory and link into list of blocks
384 that will need to be freed later. */
386 refs = xmalloc (size * sizeof (*refs));
388 /* Link all the new refs together, overloading the chain field. */
389 for (i = 0; i < size - 1; i++)
390 refs[i].chain = (struct df_link *)(refs + i + 1);
391 refs[size - 1].chain = 0;
397 /* Allocate bitmaps for each basic block. */
399 df_bitmaps_alloc (df, flags)
406 /* Free the bitmaps if they need resizing. */
407 if ((flags & DF_LR) && df->n_regs < (unsigned int)max_reg_num ())
408 dflags |= DF_LR | DF_RU;
409 if ((flags & DF_RU) && df->n_uses < df->use_id)
411 if ((flags & DF_RD) && df->n_defs < df->def_id)
415 df_bitmaps_free (df, dflags);
417 df->n_defs = df->def_id;
418 df->n_uses = df->use_id;
422 struct bb_info *bb_info = DF_BB_INFO (df, bb);
424 if (flags & DF_RD && ! bb_info->rd_in)
426 /* Allocate bitmaps for reaching definitions. */
427 bb_info->rd_kill = BITMAP_XMALLOC ();
428 bitmap_zero (bb_info->rd_kill);
429 bb_info->rd_gen = BITMAP_XMALLOC ();
430 bitmap_zero (bb_info->rd_gen);
431 bb_info->rd_in = BITMAP_XMALLOC ();
432 bb_info->rd_out = BITMAP_XMALLOC ();
433 bb_info->rd_valid = 0;
436 if (flags & DF_RU && ! bb_info->ru_in)
438 /* Allocate bitmaps for upward exposed uses. */
439 bb_info->ru_kill = BITMAP_XMALLOC ();
440 bitmap_zero (bb_info->ru_kill);
441 /* Note the lack of symmetry. */
442 bb_info->ru_gen = BITMAP_XMALLOC ();
443 bitmap_zero (bb_info->ru_gen);
444 bb_info->ru_in = BITMAP_XMALLOC ();
445 bb_info->ru_out = BITMAP_XMALLOC ();
446 bb_info->ru_valid = 0;
449 if (flags & DF_LR && ! bb_info->lr_in)
451 /* Allocate bitmaps for live variables. */
452 bb_info->lr_def = BITMAP_XMALLOC ();
453 bitmap_zero (bb_info->lr_def);
454 bb_info->lr_use = BITMAP_XMALLOC ();
455 bitmap_zero (bb_info->lr_use);
456 bb_info->lr_in = BITMAP_XMALLOC ();
457 bb_info->lr_out = BITMAP_XMALLOC ();
458 bb_info->lr_valid = 0;
464 /* Free bitmaps for each basic block. */
466 df_bitmaps_free (df, flags)
467 struct df *df ATTRIBUTE_UNUSED;
474 struct bb_info *bb_info = DF_BB_INFO (df, bb);
479 if ((flags & DF_RD) && bb_info->rd_in)
481 /* Free bitmaps for reaching definitions. */
482 BITMAP_XFREE (bb_info->rd_kill);
483 bb_info->rd_kill = NULL;
484 BITMAP_XFREE (bb_info->rd_gen);
485 bb_info->rd_gen = NULL;
486 BITMAP_XFREE (bb_info->rd_in);
487 bb_info->rd_in = NULL;
488 BITMAP_XFREE (bb_info->rd_out);
489 bb_info->rd_out = NULL;
492 if ((flags & DF_RU) && bb_info->ru_in)
494 /* Free bitmaps for upward exposed uses. */
495 BITMAP_XFREE (bb_info->ru_kill);
496 bb_info->ru_kill = NULL;
497 BITMAP_XFREE (bb_info->ru_gen);
498 bb_info->ru_gen = NULL;
499 BITMAP_XFREE (bb_info->ru_in);
500 bb_info->ru_in = NULL;
501 BITMAP_XFREE (bb_info->ru_out);
502 bb_info->ru_out = NULL;
505 if ((flags & DF_LR) && bb_info->lr_in)
507 /* Free bitmaps for live variables. */
508 BITMAP_XFREE (bb_info->lr_def);
509 bb_info->lr_def = NULL;
510 BITMAP_XFREE (bb_info->lr_use);
511 bb_info->lr_use = NULL;
512 BITMAP_XFREE (bb_info->lr_in);
513 bb_info->lr_in = NULL;
514 BITMAP_XFREE (bb_info->lr_out);
515 bb_info->lr_out = NULL;
518 df->flags &= ~(flags & (DF_RD | DF_RU | DF_LR));
522 /* Allocate and initialise dataflow memory. */
524 df_alloc (df, n_regs)
531 gcc_obstack_init (&df_ref_obstack);
533 /* Perhaps we should use LUIDs to save memory for the insn_refs
534 table. This is only a small saving; a few pointers. */
535 n_insns = get_max_uid () + 1;
539 /* Approximate number of defs by number of insns. */
540 df->def_size = n_insns;
541 df->defs = xmalloc (df->def_size * sizeof (*df->defs));
545 /* Approximate number of uses by twice number of insns. */
546 df->use_size = n_insns * 2;
547 df->uses = xmalloc (df->use_size * sizeof (*df->uses));
550 df->n_bbs = n_basic_blocks;
552 /* Allocate temporary working array used during local dataflow analysis. */
553 df->reg_def_last = xmalloc (df->n_regs * sizeof (struct ref *));
555 df_insn_table_realloc (df, n_insns);
557 df_reg_table_realloc (df, df->n_regs);
559 df->bbs_modified = BITMAP_XMALLOC ();
560 bitmap_zero (df->bbs_modified);
564 df->bbs = xcalloc (df->n_bbs, sizeof (struct bb_info));
566 df->all_blocks = BITMAP_XMALLOC ();
568 bitmap_set_bit (df->all_blocks, bb->index);
572 /* Free all the dataflow info. */
577 df_bitmaps_free (df, DF_ALL);
605 if (df->bbs_modified)
606 BITMAP_XFREE (df->bbs_modified);
607 df->bbs_modified = 0;
609 if (df->insns_modified)
610 BITMAP_XFREE (df->insns_modified);
611 df->insns_modified = 0;
613 BITMAP_XFREE (df->all_blocks);
616 obstack_free (&df_ref_obstack, NULL);
619 /* Local miscellaneous routines. */
621 /* Return a USE for register REGNO. */
622 static rtx df_reg_use_gen (regno)
628 reg = regno >= FIRST_PSEUDO_REGISTER
629 ? regno_reg_rtx[regno] : gen_rtx_REG (reg_raw_mode[regno], regno);
631 use = gen_rtx_USE (GET_MODE (reg), reg);
636 /* Return a CLOBBER for register REGNO. */
637 static rtx df_reg_clobber_gen (regno)
643 reg = regno >= FIRST_PSEUDO_REGISTER
644 ? regno_reg_rtx[regno] : gen_rtx_REG (reg_raw_mode[regno], regno);
646 use = gen_rtx_CLOBBER (GET_MODE (reg), reg);
650 /* Local chain manipulation routines. */
652 /* Create a link in a def-use or use-def chain. */
653 static inline struct df_link *
654 df_link_create (ref, next)
656 struct df_link *next;
658 struct df_link *link;
660 link = (struct df_link *) obstack_alloc (&df_ref_obstack,
668 /* Add REF to chain head pointed to by PHEAD. */
669 static struct df_link *
670 df_ref_unlink (phead, ref)
671 struct df_link **phead;
674 struct df_link *link = *phead;
680 /* Only a single ref. It must be the one we want.
681 If not, the def-use and use-def chains are likely to
683 if (link->ref != ref)
685 /* Now have an empty chain. */
690 /* Multiple refs. One of them must be us. */
691 if (link->ref == ref)
696 for (; link->next; link = link->next)
698 if (link->next->ref == ref)
700 /* Unlink from list. */
701 link->next = link->next->next;
712 /* Unlink REF from all def-use/use-def chains, etc. */
714 df_ref_remove (df, ref)
718 if (DF_REF_REG_DEF_P (ref))
720 df_def_unlink (df, ref);
721 df_ref_unlink (&df->insns[DF_REF_INSN_UID (ref)].defs, ref);
725 df_use_unlink (df, ref);
726 df_ref_unlink (&df->insns[DF_REF_INSN_UID (ref)].uses, ref);
732 /* Unlink DEF from use-def and reg-def chains. */
734 df_def_unlink (df, def)
735 struct df *df ATTRIBUTE_UNUSED;
738 struct df_link *du_link;
739 unsigned int dregno = DF_REF_REGNO (def);
741 /* Follow def-use chain to find all the uses of this def. */
742 for (du_link = DF_REF_CHAIN (def); du_link; du_link = du_link->next)
744 struct ref *use = du_link->ref;
746 /* Unlink this def from the use-def chain. */
747 df_ref_unlink (&DF_REF_CHAIN (use), def);
749 DF_REF_CHAIN (def) = 0;
751 /* Unlink def from reg-def chain. */
752 df_ref_unlink (&df->regs[dregno].defs, def);
754 df->defs[DF_REF_ID (def)] = 0;
758 /* Unlink use from def-use and reg-use chains. */
760 df_use_unlink (df, use)
761 struct df *df ATTRIBUTE_UNUSED;
764 struct df_link *ud_link;
765 unsigned int uregno = DF_REF_REGNO (use);
767 /* Follow use-def chain to find all the defs of this use. */
768 for (ud_link = DF_REF_CHAIN (use); ud_link; ud_link = ud_link->next)
770 struct ref *def = ud_link->ref;
772 /* Unlink this use from the def-use chain. */
773 df_ref_unlink (&DF_REF_CHAIN (def), use);
775 DF_REF_CHAIN (use) = 0;
777 /* Unlink use from reg-use chain. */
778 df_ref_unlink (&df->regs[uregno].uses, use);
780 df->uses[DF_REF_ID (use)] = 0;
783 /* Local routines for recording refs. */
786 /* Create a new ref of type DF_REF_TYPE for register REG at address
787 LOC within INSN of BB. */
789 df_ref_create (df, reg, loc, insn, ref_type, ref_flags)
794 enum df_ref_type ref_type;
795 enum df_ref_flags ref_flags;
797 struct ref *this_ref;
800 this_ref = (struct ref *) obstack_alloc (&df_ref_obstack,
802 DF_REF_REG (this_ref) = reg;
803 DF_REF_LOC (this_ref) = loc;
804 DF_REF_INSN (this_ref) = insn;
805 DF_REF_CHAIN (this_ref) = 0;
806 DF_REF_TYPE (this_ref) = ref_type;
807 DF_REF_FLAGS (this_ref) = ref_flags;
808 uid = INSN_UID (insn);
810 if (ref_type == DF_REF_REG_DEF)
812 if (df->def_id >= df->def_size)
814 /* Make table 25 percent larger. */
815 df->def_size += (df->def_size / 4);
816 df->defs = xrealloc (df->defs,
817 df->def_size * sizeof (*df->defs));
819 DF_REF_ID (this_ref) = df->def_id;
820 df->defs[df->def_id++] = this_ref;
824 if (df->use_id >= df->use_size)
826 /* Make table 25 percent larger. */
827 df->use_size += (df->use_size / 4);
828 df->uses = xrealloc (df->uses,
829 df->use_size * sizeof (*df->uses));
831 DF_REF_ID (this_ref) = df->use_id;
832 df->uses[df->use_id++] = this_ref;
838 /* Create a new reference of type DF_REF_TYPE for a single register REG,
839 used inside the LOC rtx of INSN. */
841 df_ref_record_1 (df, reg, loc, insn, ref_type, ref_flags)
846 enum df_ref_type ref_type;
847 enum df_ref_flags ref_flags;
849 df_ref_create (df, reg, loc, insn, ref_type, ref_flags);
853 /* Create new references of type DF_REF_TYPE for each part of register REG
854 at address LOC within INSN of BB. */
856 df_ref_record (df, reg, loc, insn, ref_type, ref_flags)
861 enum df_ref_type ref_type;
862 enum df_ref_flags ref_flags;
866 if (GET_CODE (reg) != REG && GET_CODE (reg) != SUBREG)
869 /* For the reg allocator we are interested in some SUBREG rtx's, but not
870 all. Notably only those representing a word extraction from a multi-word
871 reg. As written in the docu those should have the form
872 (subreg:SI (reg:M A) N), with size(SImode) > size(Mmode).
873 XXX Is that true? We could also use the global word_mode variable. */
874 if (GET_CODE (reg) == SUBREG
875 && (GET_MODE_SIZE (GET_MODE (reg)) < GET_MODE_SIZE (word_mode)
876 || GET_MODE_SIZE (GET_MODE (reg))
877 >= GET_MODE_SIZE (GET_MODE (SUBREG_REG (reg)))))
879 loc = &SUBREG_REG (reg);
883 regno = REGNO (GET_CODE (reg) == SUBREG ? SUBREG_REG (reg) : reg);
884 if (regno < FIRST_PSEUDO_REGISTER)
889 if (! (df->flags & DF_HARD_REGS))
892 /* GET_MODE (reg) is correct here. We don't want to go into a SUBREG
893 for the mode, because we only want to add references to regs, which
894 are really referenced. E.g. a (subreg:SI (reg:DI 0) 0) does _not_
895 reference the whole reg 0 in DI mode (which would also include
896 reg 1, at least, if 0 and 1 are SImode registers). */
897 endregno = regno + HARD_REGNO_NREGS (regno, GET_MODE (reg));
899 for (i = regno; i < endregno; i++)
900 df_ref_record_1 (df, gen_rtx_REG (reg_raw_mode[i], i),
901 loc, insn, ref_type, ref_flags);
905 df_ref_record_1 (df, reg, loc, insn, ref_type, ref_flags);
909 /* Writes to SUBREG of inndermode wider than word and outermode shorter than
910 word are read-modify-write. */
913 read_modify_subreg_p (x)
916 if (GET_CODE (x) != SUBREG)
918 if (GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))) <= UNITS_PER_WORD)
920 if (GET_MODE_SIZE (GET_MODE (x)) > UNITS_PER_WORD)
925 /* Process all the registers defined in the rtx, X. */
927 df_def_record_1 (df, x, bb, insn)
933 rtx *loc = &SET_DEST (x);
935 enum df_ref_flags flags = 0;
937 /* Some targets place small structures in registers for
938 return values of functions. */
939 if (GET_CODE (dst) == PARALLEL && GET_MODE (dst) == BLKmode)
943 for (i = XVECLEN (dst, 0) - 1; i >= 0; i--)
944 df_def_record_1 (df, XVECEXP (dst, 0, i), bb, insn);
948 /* May be, we should flag the use of strict_low_part somehow. Might be
949 handy for the reg allocator. */
950 while (GET_CODE (dst) == STRICT_LOW_PART
951 || GET_CODE (dst) == ZERO_EXTRACT
952 || GET_CODE (dst) == SIGN_EXTRACT
953 || read_modify_subreg_p (dst))
955 /* Strict low part always contains SUBREG, but we don't want to make
956 it appear outside, as whole register is always considered. */
957 if (GET_CODE (dst) == STRICT_LOW_PART)
959 loc = &XEXP (dst, 0);
962 loc = &XEXP (dst, 0);
964 flags |= DF_REF_READ_WRITE;
967 if (GET_CODE (dst) == REG
968 || (GET_CODE (dst) == SUBREG && GET_CODE (SUBREG_REG (dst)) == REG))
969 df_ref_record (df, dst, loc, insn, DF_REF_REG_DEF, flags);
973 /* Process all the registers defined in the pattern rtx, X. */
975 df_defs_record (df, x, bb, insn)
981 RTX_CODE code = GET_CODE (x);
983 if (code == SET || code == CLOBBER)
985 /* Mark the single def within the pattern. */
986 df_def_record_1 (df, x, bb, insn);
988 else if (code == PARALLEL)
992 /* Mark the multiple defs within the pattern. */
993 for (i = XVECLEN (x, 0) - 1; i >= 0; i--)
995 code = GET_CODE (XVECEXP (x, 0, i));
996 if (code == SET || code == CLOBBER)
997 df_def_record_1 (df, XVECEXP (x, 0, i), bb, insn);
1003 /* Process all the registers used in the rtx at address LOC. */
1005 df_uses_record (df, loc, ref_type, bb, insn, flags)
1008 enum df_ref_type ref_type;
1011 enum df_ref_flags flags;
1019 code = GET_CODE (x);
1034 /* If we are clobbering a MEM, mark any registers inside the address
1036 if (GET_CODE (XEXP (x, 0)) == MEM)
1037 df_uses_record (df, &XEXP (XEXP (x, 0), 0),
1038 DF_REF_REG_MEM_STORE, bb, insn, flags);
1040 /* If we're clobbering a REG then we have a def so ignore. */
1044 df_uses_record (df, &XEXP (x, 0), DF_REF_REG_MEM_LOAD, bb, insn, flags);
1048 /* While we're here, optimize this case. */
1050 /* In case the SUBREG is not of a register, don't optimize. */
1051 if (GET_CODE (SUBREG_REG (x)) != REG)
1053 loc = &SUBREG_REG (x);
1054 df_uses_record (df, loc, ref_type, bb, insn, flags);
1058 /* ... Fall through ... */
1061 /* See a register (or subreg) other than being set. */
1062 df_ref_record (df, x, loc, insn, ref_type, flags);
1067 rtx dst = SET_DEST (x);
1069 df_uses_record (df, &SET_SRC (x), DF_REF_REG_USE, bb, insn, 0);
1071 switch (GET_CODE (dst))
1074 if (read_modify_subreg_p (dst))
1076 df_uses_record (df, &SUBREG_REG (dst), DF_REF_REG_USE, bb,
1077 insn, DF_REF_READ_WRITE);
1080 /* ... FALLTHRU ... */
1085 df_uses_record (df, &XEXP (dst, 0),
1086 DF_REF_REG_MEM_STORE,
1089 case STRICT_LOW_PART:
1090 /* A strict_low_part uses the whole reg not only the subreg. */
1091 dst = XEXP (dst, 0);
1092 if (GET_CODE (dst) != SUBREG)
1094 df_uses_record (df, &SUBREG_REG (dst), DF_REF_REG_USE, bb,
1095 insn, DF_REF_READ_WRITE);
1099 df_uses_record (df, &XEXP (dst, 0), DF_REF_REG_USE, bb, insn,
1101 df_uses_record (df, &XEXP (dst, 1), DF_REF_REG_USE, bb, insn, 0);
1102 df_uses_record (df, &XEXP (dst, 2), DF_REF_REG_USE, bb, insn, 0);
1103 dst = XEXP (dst, 0);
1115 case UNSPEC_VOLATILE:
1119 /* Traditional and volatile asm instructions must be considered to use
1120 and clobber all hard registers, all pseudo-registers and all of
1121 memory. So must TRAP_IF and UNSPEC_VOLATILE operations.
1123 Consider for instance a volatile asm that changes the fpu rounding
1124 mode. An insn should not be moved across this even if it only uses
1125 pseudo-regs because it might give an incorrectly rounded result.
1127 For now, just mark any regs we can find in ASM_OPERANDS as
1130 /* For all ASM_OPERANDS, we must traverse the vector of input operands.
1131 We can not just fall through here since then we would be confused
1132 by the ASM_INPUT rtx inside ASM_OPERANDS, which do not indicate
1133 traditional asms unlike their normal usage. */
1134 if (code == ASM_OPERANDS)
1138 for (j = 0; j < ASM_OPERANDS_INPUT_LENGTH (x); j++)
1139 df_uses_record (df, &ASM_OPERANDS_INPUT (x, j),
1140 DF_REF_REG_USE, bb, insn, 0);
1152 /* Catch the def of the register being modified. */
1153 df_ref_record (df, XEXP (x, 0), &XEXP (x, 0), insn, DF_REF_REG_DEF, DF_REF_READ_WRITE);
1155 /* ... Fall through to handle uses ... */
1161 /* Recursively scan the operands of this expression. */
1163 const char *fmt = GET_RTX_FORMAT (code);
1166 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
1170 /* Tail recursive case: save a function call level. */
1176 df_uses_record (df, &XEXP (x, i), ref_type, bb, insn, flags);
1178 else if (fmt[i] == 'E')
1181 for (j = 0; j < XVECLEN (x, i); j++)
1182 df_uses_record (df, &XVECEXP (x, i, j), ref_type,
1190 /* Record all the df within INSN of basic block BB. */
1192 df_insn_refs_record (df, bb, insn)
1203 /* Record register defs */
1204 df_defs_record (df, PATTERN (insn), bb, insn);
1206 if (df->flags & DF_EQUIV_NOTES)
1207 for (note = REG_NOTES (insn); note;
1208 note = XEXP (note, 1))
1210 switch (REG_NOTE_KIND (note))
1214 df_uses_record (df, &XEXP (note, 0), DF_REF_REG_USE,
1221 if (GET_CODE (insn) == CALL_INSN)
1226 /* Record the registers used to pass arguments. */
1227 for (note = CALL_INSN_FUNCTION_USAGE (insn); note;
1228 note = XEXP (note, 1))
1230 if (GET_CODE (XEXP (note, 0)) == USE)
1231 df_uses_record (df, &XEXP (XEXP (note, 0), 0), DF_REF_REG_USE,
1235 /* The stack ptr is used (honorarily) by a CALL insn. */
1236 x = df_reg_use_gen (STACK_POINTER_REGNUM);
1237 df_uses_record (df, &XEXP (x, 0), DF_REF_REG_USE, bb, insn, 0);
1239 if (df->flags & DF_HARD_REGS)
1241 /* Calls may also reference any of the global registers,
1242 so they are recorded as used. */
1243 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
1246 x = df_reg_use_gen (i);
1247 df_uses_record (df, &SET_DEST (x),
1248 DF_REF_REG_USE, bb, insn, 0);
1253 /* Record the register uses. */
1254 df_uses_record (df, &PATTERN (insn),
1255 DF_REF_REG_USE, bb, insn, 0);
1258 if (GET_CODE (insn) == CALL_INSN)
1262 if (df->flags & DF_HARD_REGS)
1264 /* Kill all registers invalidated by a call. */
1265 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
1266 if (TEST_HARD_REG_BIT (regs_invalidated_by_call, i))
1268 rtx reg_clob = df_reg_clobber_gen (i);
1269 df_defs_record (df, reg_clob, bb, insn);
1273 /* There may be extra registers to be clobbered. */
1274 for (note = CALL_INSN_FUNCTION_USAGE (insn);
1276 note = XEXP (note, 1))
1277 if (GET_CODE (XEXP (note, 0)) == CLOBBER)
1278 df_defs_record (df, XEXP (note, 0), bb, insn);
1284 /* Record all the refs within the basic block BB. */
1286 df_bb_refs_record (df, bb)
1292 /* Scan the block an insn at a time from beginning to end. */
1293 for (insn = bb->head; ; insn = NEXT_INSN (insn))
1297 /* Record defs within INSN. */
1298 df_insn_refs_record (df, bb, insn);
1300 if (insn == bb->end)
1306 /* Record all the refs in the basic blocks specified by BLOCKS. */
1308 df_refs_record (df, blocks)
1314 FOR_EACH_BB_IN_BITMAP (blocks, 0, bb,
1316 df_bb_refs_record (df, bb);
1320 /* Dataflow analysis routines. */
1323 /* Create reg-def chains for basic block BB. These are a list of
1324 definitions for each register. */
1326 df_bb_reg_def_chain_create (df, bb)
1332 /* Perhaps the defs should be sorted using a depth first search
1333 of the CFG (or possibly a breadth first search). We currently
1334 scan the basic blocks in reverse order so that the first defs
1335 appear at the start of the chain. */
1337 for (insn = bb->end; insn && insn != PREV_INSN (bb->head);
1338 insn = PREV_INSN (insn))
1340 struct df_link *link;
1341 unsigned int uid = INSN_UID (insn);
1343 if (! INSN_P (insn))
1346 for (link = df->insns[uid].defs; link; link = link->next)
1348 struct ref *def = link->ref;
1349 unsigned int dregno = DF_REF_REGNO (def);
1351 df->regs[dregno].defs
1352 = df_link_create (def, df->regs[dregno].defs);
1358 /* Create reg-def chains for each basic block within BLOCKS. These
1359 are a list of definitions for each register. */
1361 df_reg_def_chain_create (df, blocks)
1367 FOR_EACH_BB_IN_BITMAP/*_REV*/ (blocks, 0, bb,
1369 df_bb_reg_def_chain_create (df, bb);
1374 /* Create reg-use chains for basic block BB. These are a list of uses
1375 for each register. */
1377 df_bb_reg_use_chain_create (df, bb)
1383 /* Scan in forward order so that the last uses appear at the
1384 start of the chain. */
1386 for (insn = bb->head; insn && insn != NEXT_INSN (bb->end);
1387 insn = NEXT_INSN (insn))
1389 struct df_link *link;
1390 unsigned int uid = INSN_UID (insn);
1392 if (! INSN_P (insn))
1395 for (link = df->insns[uid].uses; link; link = link->next)
1397 struct ref *use = link->ref;
1398 unsigned int uregno = DF_REF_REGNO (use);
1400 df->regs[uregno].uses
1401 = df_link_create (use, df->regs[uregno].uses);
1407 /* Create reg-use chains for each basic block within BLOCKS. These
1408 are a list of uses for each register. */
1410 df_reg_use_chain_create (df, blocks)
1416 FOR_EACH_BB_IN_BITMAP (blocks, 0, bb,
1418 df_bb_reg_use_chain_create (df, bb);
1423 /* Create def-use chains from reaching use bitmaps for basic block BB. */
1425 df_bb_du_chain_create (df, bb, ru)
1430 struct bb_info *bb_info = DF_BB_INFO (df, bb);
1433 bitmap_copy (ru, bb_info->ru_out);
1435 /* For each def in BB create a linked list (chain) of uses
1436 reached from the def. */
1437 for (insn = bb->end; insn && insn != PREV_INSN (bb->head);
1438 insn = PREV_INSN (insn))
1440 struct df_link *def_link;
1441 struct df_link *use_link;
1442 unsigned int uid = INSN_UID (insn);
1444 if (! INSN_P (insn))
1447 /* For each def in insn... */
1448 for (def_link = df->insns[uid].defs; def_link; def_link = def_link->next)
1450 struct ref *def = def_link->ref;
1451 unsigned int dregno = DF_REF_REGNO (def);
1453 DF_REF_CHAIN (def) = 0;
1455 /* While the reg-use chains are not essential, it
1456 is _much_ faster to search these short lists rather
1457 than all the reaching uses, especially for large functions. */
1458 for (use_link = df->regs[dregno].uses; use_link;
1459 use_link = use_link->next)
1461 struct ref *use = use_link->ref;
1463 if (bitmap_bit_p (ru, DF_REF_ID (use)))
1466 = df_link_create (use, DF_REF_CHAIN (def));
1468 bitmap_clear_bit (ru, DF_REF_ID (use));
1473 /* For each use in insn... */
1474 for (use_link = df->insns[uid].uses; use_link; use_link = use_link->next)
1476 struct ref *use = use_link->ref;
1477 bitmap_set_bit (ru, DF_REF_ID (use));
1483 /* Create def-use chains from reaching use bitmaps for basic blocks
1486 df_du_chain_create (df, blocks)
1493 ru = BITMAP_XMALLOC ();
1495 FOR_EACH_BB_IN_BITMAP (blocks, 0, bb,
1497 df_bb_du_chain_create (df, bb, ru);
1504 /* Create use-def chains from reaching def bitmaps for basic block BB. */
1506 df_bb_ud_chain_create (df, bb)
1510 struct bb_info *bb_info = DF_BB_INFO (df, bb);
1511 struct ref **reg_def_last = df->reg_def_last;
1514 memset (reg_def_last, 0, df->n_regs * sizeof (struct ref *));
1516 /* For each use in BB create a linked list (chain) of defs
1517 that reach the use. */
1518 for (insn = bb->head; insn && insn != NEXT_INSN (bb->end);
1519 insn = NEXT_INSN (insn))
1521 unsigned int uid = INSN_UID (insn);
1522 struct df_link *use_link;
1523 struct df_link *def_link;
1525 if (! INSN_P (insn))
1528 /* For each use in insn... */
1529 for (use_link = df->insns[uid].uses; use_link; use_link = use_link->next)
1531 struct ref *use = use_link->ref;
1532 unsigned int regno = DF_REF_REGNO (use);
1534 DF_REF_CHAIN (use) = 0;
1536 /* Has regno been defined in this BB yet? If so, use
1537 the last def as the single entry for the use-def
1538 chain for this use. Otherwise, we need to add all
1539 the defs using this regno that reach the start of
1541 if (reg_def_last[regno])
1544 = df_link_create (reg_def_last[regno], 0);
1548 /* While the reg-def chains are not essential, it is
1549 _much_ faster to search these short lists rather than
1550 all the reaching defs, especially for large
1552 for (def_link = df->regs[regno].defs; def_link;
1553 def_link = def_link->next)
1555 struct ref *def = def_link->ref;
1557 if (bitmap_bit_p (bb_info->rd_in, DF_REF_ID (def)))
1560 = df_link_create (def, DF_REF_CHAIN (use));
1567 /* For each def in insn...record the last def of each reg. */
1568 for (def_link = df->insns[uid].defs; def_link; def_link = def_link->next)
1570 struct ref *def = def_link->ref;
1571 int dregno = DF_REF_REGNO (def);
1573 reg_def_last[dregno] = def;
1579 /* Create use-def chains from reaching def bitmaps for basic blocks
1582 df_ud_chain_create (df, blocks)
1588 FOR_EACH_BB_IN_BITMAP (blocks, 0, bb,
1590 df_bb_ud_chain_create (df, bb);
1597 df_rd_transfer_function (bb, changed, in, out, gen, kill, data)
1598 int bb ATTRIBUTE_UNUSED;
1600 bitmap in, out, gen, kill;
1601 void *data ATTRIBUTE_UNUSED;
1603 *changed = bitmap_union_of_diff (out, gen, in, kill);
1606 df_ru_transfer_function (bb, changed, in, out, gen, kill, data)
1607 int bb ATTRIBUTE_UNUSED;
1609 bitmap in, out, gen, kill;
1610 void *data ATTRIBUTE_UNUSED;
1612 *changed = bitmap_union_of_diff (in, gen, out, kill);
1616 df_lr_transfer_function (bb, changed, in, out, use, def, data)
1617 int bb ATTRIBUTE_UNUSED;
1619 bitmap in, out, use, def;
1620 void *data ATTRIBUTE_UNUSED;
1622 *changed = bitmap_union_of_diff (in, use, out, def);
1626 /* Compute local reaching def info for basic block BB. */
1628 df_bb_rd_local_compute (df, bb)
1632 struct bb_info *bb_info = DF_BB_INFO (df, bb);
1635 for (insn = bb->head; insn && insn != NEXT_INSN (bb->end);
1636 insn = NEXT_INSN (insn))
1638 unsigned int uid = INSN_UID (insn);
1639 struct df_link *def_link;
1641 if (! INSN_P (insn))
1644 for (def_link = df->insns[uid].defs; def_link; def_link = def_link->next)
1646 struct ref *def = def_link->ref;
1647 unsigned int regno = DF_REF_REGNO (def);
1648 struct df_link *def2_link;
1650 for (def2_link = df->regs[regno].defs; def2_link;
1651 def2_link = def2_link->next)
1653 struct ref *def2 = def2_link->ref;
1655 /* Add all defs of this reg to the set of kills. This
1656 is greedy since many of these defs will not actually
1657 be killed by this BB but it keeps things a lot
1659 bitmap_set_bit (bb_info->rd_kill, DF_REF_ID (def2));
1661 /* Zap from the set of gens for this BB. */
1662 bitmap_clear_bit (bb_info->rd_gen, DF_REF_ID (def2));
1665 bitmap_set_bit (bb_info->rd_gen, DF_REF_ID (def));
1669 bb_info->rd_valid = 1;
1673 /* Compute local reaching def info for each basic block within BLOCKS. */
1675 df_rd_local_compute (df, blocks)
1681 FOR_EACH_BB_IN_BITMAP (blocks, 0, bb,
1683 df_bb_rd_local_compute (df, bb);
1688 /* Compute local reaching use (upward exposed use) info for basic
1691 df_bb_ru_local_compute (df, bb)
1695 /* This is much more tricky than computing reaching defs. With
1696 reaching defs, defs get killed by other defs. With upwards
1697 exposed uses, these get killed by defs with the same regno. */
1699 struct bb_info *bb_info = DF_BB_INFO (df, bb);
1703 for (insn = bb->end; insn && insn != PREV_INSN (bb->head);
1704 insn = PREV_INSN (insn))
1706 unsigned int uid = INSN_UID (insn);
1707 struct df_link *def_link;
1708 struct df_link *use_link;
1710 if (! INSN_P (insn))
1713 for (def_link = df->insns[uid].defs; def_link; def_link = def_link->next)
1715 struct ref *def = def_link->ref;
1716 unsigned int dregno = DF_REF_REGNO (def);
1718 for (use_link = df->regs[dregno].uses; use_link;
1719 use_link = use_link->next)
1721 struct ref *use = use_link->ref;
1723 /* Add all uses of this reg to the set of kills. This
1724 is greedy since many of these uses will not actually
1725 be killed by this BB but it keeps things a lot
1727 bitmap_set_bit (bb_info->ru_kill, DF_REF_ID (use));
1729 /* Zap from the set of gens for this BB. */
1730 bitmap_clear_bit (bb_info->ru_gen, DF_REF_ID (use));
1734 for (use_link = df->insns[uid].uses; use_link; use_link = use_link->next)
1736 struct ref *use = use_link->ref;
1737 /* Add use to set of gens in this BB. */
1738 bitmap_set_bit (bb_info->ru_gen, DF_REF_ID (use));
1741 bb_info->ru_valid = 1;
1745 /* Compute local reaching use (upward exposed use) info for each basic
1746 block within BLOCKS. */
1748 df_ru_local_compute (df, blocks)
1754 FOR_EACH_BB_IN_BITMAP (blocks, 0, bb,
1756 df_bb_ru_local_compute (df, bb);
1761 /* Compute local live variable info for basic block BB. */
1763 df_bb_lr_local_compute (df, bb)
1767 struct bb_info *bb_info = DF_BB_INFO (df, bb);
1770 for (insn = bb->end; insn && insn != PREV_INSN (bb->head);
1771 insn = PREV_INSN (insn))
1773 unsigned int uid = INSN_UID (insn);
1774 struct df_link *link;
1776 if (! INSN_P (insn))
1779 for (link = df->insns[uid].defs; link; link = link->next)
1781 struct ref *def = link->ref;
1782 unsigned int dregno = DF_REF_REGNO (def);
1784 /* Add def to set of defs in this BB. */
1785 bitmap_set_bit (bb_info->lr_def, dregno);
1787 bitmap_clear_bit (bb_info->lr_use, dregno);
1790 for (link = df->insns[uid].uses; link; link = link->next)
1792 struct ref *use = link->ref;
1793 /* Add use to set of uses in this BB. */
1794 bitmap_set_bit (bb_info->lr_use, DF_REF_REGNO (use));
1797 bb_info->lr_valid = 1;
1801 /* Compute local live variable info for each basic block within BLOCKS. */
1803 df_lr_local_compute (df, blocks)
1809 FOR_EACH_BB_IN_BITMAP (blocks, 0, bb,
1811 df_bb_lr_local_compute (df, bb);
1816 /* Compute register info: lifetime, bb, and number of defs and uses
1817 for basic block BB. */
1819 df_bb_reg_info_compute (df, bb, live)
1824 struct reg_info *reg_info = df->regs;
1825 struct bb_info *bb_info = DF_BB_INFO (df, bb);
1828 bitmap_copy (live, bb_info->lr_out);
1830 for (insn = bb->end; insn && insn != PREV_INSN (bb->head);
1831 insn = PREV_INSN (insn))
1833 unsigned int uid = INSN_UID (insn);
1835 struct df_link *link;
1837 if (! INSN_P (insn))
1840 for (link = df->insns[uid].defs; link; link = link->next)
1842 struct ref *def = link->ref;
1843 unsigned int dregno = DF_REF_REGNO (def);
1845 /* Kill this register. */
1846 bitmap_clear_bit (live, dregno);
1847 reg_info[dregno].n_defs++;
1850 for (link = df->insns[uid].uses; link; link = link->next)
1852 struct ref *use = link->ref;
1853 unsigned int uregno = DF_REF_REGNO (use);
1855 /* This register is now live. */
1856 bitmap_set_bit (live, uregno);
1857 reg_info[uregno].n_uses++;
1860 /* Increment lifetimes of all live registers. */
1861 EXECUTE_IF_SET_IN_BITMAP (live, 0, regno,
1863 reg_info[regno].lifetime++;
1869 /* Compute register info: lifetime, bb, and number of defs and uses. */
1871 df_reg_info_compute (df, blocks)
1878 live = BITMAP_XMALLOC ();
1880 FOR_EACH_BB_IN_BITMAP (blocks, 0, bb,
1882 df_bb_reg_info_compute (df, bb, live);
1885 BITMAP_XFREE (live);
1889 /* Assign LUIDs for BB. */
1891 df_bb_luids_set (df, bb)
1898 /* The LUIDs are monotonically increasing for each basic block. */
1900 for (insn = bb->head; ; insn = NEXT_INSN (insn))
1903 DF_INSN_LUID (df, insn) = luid++;
1904 DF_INSN_LUID (df, insn) = luid;
1906 if (insn == bb->end)
1913 /* Assign LUIDs for each basic block within BLOCKS. */
1915 df_luids_set (df, blocks)
1922 FOR_EACH_BB_IN_BITMAP (blocks, 0, bb,
1924 total += df_bb_luids_set (df, bb);
1929 /* Perform dataflow analysis using existing DF structure for blocks
1930 within BLOCKS. If BLOCKS is zero, use all basic blocks in the CFG. */
1932 df_analyse_1 (df, blocks, flags, update)
1945 if (flags & DF_UD_CHAIN)
1946 aflags |= DF_RD | DF_RD_CHAIN;
1948 if (flags & DF_DU_CHAIN)
1952 aflags |= DF_RU_CHAIN;
1954 if (flags & DF_REG_INFO)
1958 blocks = df->all_blocks;
1963 df_refs_update (df);
1964 /* More fine grained incremental dataflow analysis would be
1965 nice. For now recompute the whole shebang for the
1968 df_refs_unlink (df, blocks);
1970 /* All the def-use, use-def chains can be potentially
1971 modified by changes in one block. The size of the
1972 bitmaps can also change. */
1976 /* Scan the function for all register defs and uses. */
1978 df_refs_record (df, blocks);
1980 /* Link all the new defs and uses to the insns. */
1981 df_refs_process (df);
1984 /* Allocate the bitmaps now the total number of defs and uses are
1985 known. If the number of defs or uses have changed, then
1986 these bitmaps need to be reallocated. */
1987 df_bitmaps_alloc (df, aflags);
1989 /* Set the LUIDs for each specified basic block. */
1990 df_luids_set (df, blocks);
1992 /* Recreate reg-def and reg-use chains from scratch so that first
1993 def is at the head of the reg-def chain and the last use is at
1994 the head of the reg-use chain. This is only important for
1995 regs local to a basic block as it speeds up searching. */
1996 if (aflags & DF_RD_CHAIN)
1998 df_reg_def_chain_create (df, blocks);
2001 if (aflags & DF_RU_CHAIN)
2003 df_reg_use_chain_create (df, blocks);
2006 df->dfs_order = xmalloc (sizeof(int) * n_basic_blocks);
2007 df->rc_order = xmalloc (sizeof(int) * n_basic_blocks);
2008 df->rts_order = xmalloc (sizeof(int) * n_basic_blocks);
2009 df->inverse_dfs_map = xmalloc (sizeof(int) * n_basic_blocks);
2010 df->inverse_rc_map = xmalloc (sizeof(int) * n_basic_blocks);
2011 df->inverse_rts_map = xmalloc (sizeof(int) * n_basic_blocks);
2013 flow_depth_first_order_compute (df->dfs_order, df->rc_order);
2014 flow_reverse_top_sort_order_compute (df->rts_order);
2015 for (i = 0; i < n_basic_blocks; i ++)
2017 df->inverse_dfs_map[df->dfs_order[i]] = i;
2018 df->inverse_rc_map[df->rc_order[i]] = i;
2019 df->inverse_rts_map[df->rts_order[i]] = i;
2023 /* Compute the sets of gens and kills for the defs of each bb. */
2024 df_rd_local_compute (df, df->flags & DF_RD ? blocks : df->all_blocks);
2026 bitmap *in = xmalloc (sizeof (bitmap) * n_basic_blocks);
2027 bitmap *out = xmalloc (sizeof (bitmap) * n_basic_blocks);
2028 bitmap *gen = xmalloc (sizeof (bitmap) * n_basic_blocks);
2029 bitmap *kill = xmalloc (sizeof (bitmap) * n_basic_blocks);
2032 in[bb->index] = DF_BB_INFO (df, bb)->rd_in;
2033 out[bb->index] = DF_BB_INFO (df, bb)->rd_out;
2034 gen[bb->index] = DF_BB_INFO (df, bb)->rd_gen;
2035 kill[bb->index] = DF_BB_INFO (df, bb)->rd_kill;
2037 iterative_dataflow_bitmap (in, out, gen, kill, df->all_blocks,
2038 FORWARD, UNION, df_rd_transfer_function,
2039 df->inverse_rc_map, NULL);
2047 if (aflags & DF_UD_CHAIN)
2049 /* Create use-def chains. */
2050 df_ud_chain_create (df, df->all_blocks);
2052 if (! (flags & DF_RD))
2058 /* Compute the sets of gens and kills for the upwards exposed
2060 df_ru_local_compute (df, df->flags & DF_RU ? blocks : df->all_blocks);
2062 bitmap *in = xmalloc (sizeof (bitmap) * n_basic_blocks);
2063 bitmap *out = xmalloc (sizeof (bitmap) * n_basic_blocks);
2064 bitmap *gen = xmalloc (sizeof (bitmap) * n_basic_blocks);
2065 bitmap *kill = xmalloc (sizeof (bitmap) * n_basic_blocks);
2068 in[bb->index] = DF_BB_INFO (df, bb)->ru_in;
2069 out[bb->index] = DF_BB_INFO (df, bb)->ru_out;
2070 gen[bb->index] = DF_BB_INFO (df, bb)->ru_gen;
2071 kill[bb->index] = DF_BB_INFO (df, bb)->ru_kill;
2073 iterative_dataflow_bitmap (in, out, gen, kill, df->all_blocks,
2074 BACKWARD, UNION, df_ru_transfer_function,
2075 df->inverse_rts_map, NULL);
2083 if (aflags & DF_DU_CHAIN)
2085 /* Create def-use chains. */
2086 df_du_chain_create (df, df->all_blocks);
2088 if (! (flags & DF_RU))
2092 /* Free up bitmaps that are no longer required. */
2094 df_bitmaps_free (df, dflags);
2098 /* Compute the sets of defs and uses of live variables. */
2099 df_lr_local_compute (df, df->flags & DF_LR ? blocks : df->all_blocks);
2101 bitmap *in = xmalloc (sizeof (bitmap) * n_basic_blocks);
2102 bitmap *out = xmalloc (sizeof (bitmap) * n_basic_blocks);
2103 bitmap *use = xmalloc (sizeof (bitmap) * n_basic_blocks);
2104 bitmap *def = xmalloc (sizeof (bitmap) * n_basic_blocks);
2107 in[bb->index] = DF_BB_INFO (df, bb)->lr_in;
2108 out[bb->index] = DF_BB_INFO (df, bb)->lr_out;
2109 use[bb->index] = DF_BB_INFO (df, bb)->lr_use;
2110 def[bb->index] = DF_BB_INFO (df, bb)->lr_def;
2112 iterative_dataflow_bitmap (in, out, use, def, df->all_blocks,
2113 BACKWARD, UNION, df_lr_transfer_function,
2114 df->inverse_rts_map, NULL);
2122 if (aflags & DF_REG_INFO)
2124 df_reg_info_compute (df, df->all_blocks);
2126 free (df->dfs_order);
2127 free (df->rc_order);
2128 free (df->rts_order);
2129 free (df->inverse_rc_map);
2130 free (df->inverse_dfs_map);
2131 free (df->inverse_rts_map);
2135 /* Initialise dataflow analysis. */
2141 df = xcalloc (1, sizeof (struct df));
2143 /* Squirrel away a global for debugging. */
2150 /* Start queuing refs. */
2155 df->def_id_save = df->def_id;
2156 df->use_id_save = df->use_id;
2157 /* ???? Perhaps we should save current obstack state so that we can
2163 /* Process queued refs. */
2165 df_refs_process (df)
2170 /* Build new insn-def chains. */
2171 for (i = df->def_id_save; i != df->def_id; i++)
2173 struct ref *def = df->defs[i];
2174 unsigned int uid = DF_REF_INSN_UID (def);
2176 /* Add def to head of def list for INSN. */
2178 = df_link_create (def, df->insns[uid].defs);
2181 /* Build new insn-use chains. */
2182 for (i = df->use_id_save; i != df->use_id; i++)
2184 struct ref *use = df->uses[i];
2185 unsigned int uid = DF_REF_INSN_UID (use);
2187 /* Add use to head of use list for INSN. */
2189 = df_link_create (use, df->insns[uid].uses);
2195 /* Update refs for basic block BB. */
2197 df_bb_refs_update (df, bb)
2204 /* While we have to scan the chain of insns for this BB, we don't
2205 need to allocate and queue a long chain of BB/INSN pairs. Using
2206 a bitmap for insns_modified saves memory and avoids queuing
2209 for (insn = bb->head; ; insn = NEXT_INSN (insn))
2213 uid = INSN_UID (insn);
2215 if (bitmap_bit_p (df->insns_modified, uid))
2217 /* Delete any allocated refs of this insn. MPH, FIXME. */
2218 df_insn_refs_unlink (df, bb, insn);
2220 /* Scan the insn for refs. */
2221 df_insn_refs_record (df, bb, insn);
2224 bitmap_clear_bit (df->insns_modified, uid);
2227 if (insn == bb->end)
2234 /* Process all the modified/deleted insns that were queued. */
2242 if ((unsigned int)max_reg_num () >= df->reg_size)
2243 df_reg_table_realloc (df, 0);
2247 FOR_EACH_BB_IN_BITMAP (df->bbs_modified, 0, bb,
2249 count += df_bb_refs_update (df, bb);
2252 df_refs_process (df);
2257 /* Return non-zero if any of the requested blocks in the bitmap
2258 BLOCKS have been modified. */
2260 df_modified_p (df, blocks)
2271 if (bitmap_bit_p (df->bbs_modified, bb->index)
2272 && (! blocks || (blocks == (bitmap) -1) || bitmap_bit_p (blocks, bb->index)))
2282 /* Analyse dataflow info for the basic blocks specified by the bitmap
2283 BLOCKS, or for the whole CFG if BLOCKS is zero, or just for the
2284 modified blocks if BLOCKS is -1. */
2286 df_analyse (df, blocks, flags)
2293 /* We could deal with additional basic blocks being created by
2294 rescanning everything again. */
2295 if (df->n_bbs && df->n_bbs != (unsigned int)n_basic_blocks)
2298 update = df_modified_p (df, blocks);
2299 if (update || (flags != df->flags))
2305 /* Recompute everything from scratch. */
2308 /* Allocate and initialise data structures. */
2309 df_alloc (df, max_reg_num ());
2310 df_analyse_1 (df, 0, flags, 0);
2315 if (blocks == (bitmap) -1)
2316 blocks = df->bbs_modified;
2321 df_analyse_1 (df, blocks, flags, 1);
2322 bitmap_zero (df->bbs_modified);
2329 /* Free all the dataflow info and the DF structure. */
2339 /* Unlink INSN from its reference information. */
2341 df_insn_refs_unlink (df, bb, insn)
2343 basic_block bb ATTRIBUTE_UNUSED;
2346 struct df_link *link;
2349 uid = INSN_UID (insn);
2351 /* Unlink all refs defined by this insn. */
2352 for (link = df->insns[uid].defs; link; link = link->next)
2353 df_def_unlink (df, link->ref);
2355 /* Unlink all refs used by this insn. */
2356 for (link = df->insns[uid].uses; link; link = link->next)
2357 df_use_unlink (df, link->ref);
2359 df->insns[uid].defs = 0;
2360 df->insns[uid].uses = 0;
2365 /* Unlink all the insns within BB from their reference information. */
2367 df_bb_refs_unlink (df, bb)
2373 /* Scan the block an insn at a time from beginning to end. */
2374 for (insn = bb->head; ; insn = NEXT_INSN (insn))
2378 /* Unlink refs for INSN. */
2379 df_insn_refs_unlink (df, bb, insn);
2381 if (insn == bb->end)
2387 /* Unlink all the refs in the basic blocks specified by BLOCKS.
2388 Not currently used. */
2390 df_refs_unlink (df, blocks)
2398 FOR_EACH_BB_IN_BITMAP (blocks, 0, bb,
2400 df_bb_refs_unlink (df, bb);
2407 df_bb_refs_unlink (df, bb);
2413 /* Functions to modify insns. */
2416 /* Delete INSN and all its reference information. */
2418 df_insn_delete (df, bb, insn)
2420 basic_block bb ATTRIBUTE_UNUSED;
2423 /* If the insn is a jump, we should perhaps call delete_insn to
2424 handle the JUMP_LABEL? */
2426 /* We should not be deleting the NOTE_INSN_BASIC_BLOCK or label. */
2427 if (insn == bb->head)
2430 /* Delete the insn. */
2433 df_insn_modify (df, bb, insn);
2435 return NEXT_INSN (insn);
2439 /* Mark that INSN within BB may have changed (created/modified/deleted).
2440 This may be called multiple times for the same insn. There is no
2441 harm calling this function if the insn wasn't changed; it will just
2442 slow down the rescanning of refs. */
2444 df_insn_modify (df, bb, insn)
2451 uid = INSN_UID (insn);
2453 if (uid >= df->insn_size)
2454 df_insn_table_realloc (df, 0);
2456 bitmap_set_bit (df->bbs_modified, bb->index);
2457 bitmap_set_bit (df->insns_modified, uid);
2459 /* For incremental updating on the fly, perhaps we could make a copy
2460 of all the refs of the original insn and turn them into
2461 anti-refs. When df_refs_update finds these anti-refs, it annihilates
2462 the original refs. If validate_change fails then these anti-refs
2463 will just get ignored. */
2467 typedef struct replace_args
2476 /* Replace mem pointed to by PX with its associated pseudo register.
2477 DATA is actually a pointer to a structure describing the
2478 instruction currently being scanned and the MEM we are currently
2481 df_rtx_mem_replace (px, data)
2485 replace_args *args = (replace_args *) data;
2488 if (mem == NULL_RTX)
2491 switch (GET_CODE (mem))
2497 /* We're not interested in the MEM associated with a
2498 CONST_DOUBLE, so there's no need to traverse into one. */
2502 /* This is not a MEM. */
2506 if (!rtx_equal_p (args->match, mem))
2507 /* This is not the MEM we are currently replacing. */
2510 /* Actually replace the MEM. */
2511 validate_change (args->insn, px, args->replacement, 1);
2519 df_insn_mem_replace (df, bb, insn, mem, reg)
2530 args.replacement = reg;
2533 /* Search and replace all matching mems within insn. */
2534 for_each_rtx (&insn, df_rtx_mem_replace, &args);
2537 df_insn_modify (df, bb, insn);
2539 /* ???? FIXME. We may have a new def or one or more new uses of REG
2540 in INSN. REG should be a new pseudo so it won't affect the
2541 dataflow information that we currently have. We should add
2542 the new uses and defs to INSN and then recreate the chains
2543 when df_analyse is called. */
2544 return args.modified;
2548 /* Replace one register with another. Called through for_each_rtx; PX
2549 points to the rtx being scanned. DATA is actually a pointer to a
2550 structure of arguments. */
2552 df_rtx_reg_replace (px, data)
2557 replace_args *args = (replace_args *) data;
2562 if (x == args->match)
2564 validate_change (args->insn, px, args->replacement, 1);
2572 /* Replace the reg within every ref on CHAIN that is within the set
2573 BLOCKS of basic blocks with NEWREG. Also update the regs within
2576 df_refs_reg_replace (df, blocks, chain, oldreg, newreg)
2579 struct df_link *chain;
2583 struct df_link *link;
2587 blocks = df->all_blocks;
2589 args.match = oldreg;
2590 args.replacement = newreg;
2593 for (link = chain; link; link = link->next)
2595 struct ref *ref = link->ref;
2596 rtx insn = DF_REF_INSN (ref);
2598 if (! INSN_P (insn))
2601 if (bitmap_bit_p (blocks, DF_REF_BBNO (ref)))
2603 df_ref_reg_replace (df, ref, oldreg, newreg);
2605 /* Replace occurrences of the reg within the REG_NOTES. */
2606 if ((! link->next || DF_REF_INSN (ref)
2607 != DF_REF_INSN (link->next->ref))
2608 && REG_NOTES (insn))
2611 for_each_rtx (®_NOTES (insn), df_rtx_reg_replace, &args);
2616 /* Temporary check to ensure that we have a grip on which
2617 regs should be replaced. */
2624 /* Replace all occurrences of register OLDREG with register NEWREG in
2625 blocks defined by bitmap BLOCKS. This also replaces occurrences of
2626 OLDREG in the REG_NOTES but only for insns containing OLDREG. This
2627 routine expects the reg-use and reg-def chains to be valid. */
2629 df_reg_replace (df, blocks, oldreg, newreg)
2635 unsigned int oldregno = REGNO (oldreg);
2637 df_refs_reg_replace (df, blocks, df->regs[oldregno].defs, oldreg, newreg);
2638 df_refs_reg_replace (df, blocks, df->regs[oldregno].uses, oldreg, newreg);
2643 /* Try replacing the reg within REF with NEWREG. Do not modify
2644 def-use/use-def chains. */
2646 df_ref_reg_replace (df, ref, oldreg, newreg)
2652 /* Check that insn was deleted by being converted into a NOTE. If
2653 so ignore this insn. */
2654 if (! INSN_P (DF_REF_INSN (ref)))
2657 if (oldreg && oldreg != DF_REF_REG (ref))
2660 if (! validate_change (DF_REF_INSN (ref), DF_REF_LOC (ref), newreg, 1))
2663 df_insn_modify (df, DF_REF_BB (ref), DF_REF_INSN (ref));
2669 df_bb_def_use_swap (df, bb, def_insn, use_insn, regno)
2680 struct df_link *link;
2682 def = df_bb_insn_regno_first_def_find (df, bb, def_insn, regno);
2686 use = df_bb_insn_regno_last_use_find (df, bb, use_insn, regno);
2690 /* The USE no longer exists. */
2691 use_uid = INSN_UID (use_insn);
2692 df_use_unlink (df, use);
2693 df_ref_unlink (&df->insns[use_uid].uses, use);
2695 /* The DEF requires shifting so remove it from DEF_INSN
2696 and add it to USE_INSN by reusing LINK. */
2697 def_uid = INSN_UID (def_insn);
2698 link = df_ref_unlink (&df->insns[def_uid].defs, def);
2700 link->next = df->insns[use_uid].defs;
2701 df->insns[use_uid].defs = link;
2704 link = df_ref_unlink (&df->regs[regno].defs, def);
2706 link->next = df->regs[regno].defs;
2707 df->insns[regno].defs = link;
2710 DF_REF_INSN (def) = use_insn;
2715 /* Record df between FIRST_INSN and LAST_INSN inclusive. All new
2716 insns must be processed by this routine. */
2718 df_insns_modify (df, bb, first_insn, last_insn)
2726 for (insn = first_insn; ; insn = NEXT_INSN (insn))
2730 /* A non-const call should not have slipped through the net. If
2731 it does, we need to create a new basic block. Ouch. The
2732 same applies for a label. */
2733 if ((GET_CODE (insn) == CALL_INSN
2734 && ! CONST_OR_PURE_CALL_P (insn))
2735 || GET_CODE (insn) == CODE_LABEL)
2738 uid = INSN_UID (insn);
2740 if (uid >= df->insn_size)
2741 df_insn_table_realloc (df, 0);
2743 df_insn_modify (df, bb, insn);
2745 if (insn == last_insn)
2751 /* Emit PATTERN before INSN within BB. */
2753 df_pattern_emit_before (df, pattern, bb, insn)
2754 struct df *df ATTRIBUTE_UNUSED;
2760 rtx prev_insn = PREV_INSN (insn);
2762 /* We should not be inserting before the start of the block. */
2763 if (insn == bb->head)
2765 ret_insn = emit_insn_before (pattern, insn);
2766 if (ret_insn == insn)
2769 df_insns_modify (df, bb, NEXT_INSN (prev_insn), ret_insn);
2774 /* Emit PATTERN after INSN within BB. */
2776 df_pattern_emit_after (df, pattern, bb, insn)
2784 ret_insn = emit_insn_after (pattern, insn);
2785 if (ret_insn == insn)
2788 df_insns_modify (df, bb, NEXT_INSN (insn), ret_insn);
2793 /* Emit jump PATTERN after INSN within BB. */
2795 df_jump_pattern_emit_after (df, pattern, bb, insn)
2803 ret_insn = emit_jump_insn_after (pattern, insn);
2804 if (ret_insn == insn)
2807 df_insns_modify (df, bb, NEXT_INSN (insn), ret_insn);
2812 /* Move INSN within BB before BEFORE_INSN within BEFORE_BB.
2814 This function should only be used to move loop invariant insns
2815 out of a loop where it has been proven that the def-use info
2816 will still be valid. */
2818 df_insn_move_before (df, bb, insn, before_bb, before_insn)
2822 basic_block before_bb;
2825 struct df_link *link;
2829 return df_pattern_emit_before (df, insn, before_bb, before_insn);
2831 uid = INSN_UID (insn);
2833 /* Change bb for all df defined and used by this insn. */
2834 for (link = df->insns[uid].defs; link; link = link->next)
2835 DF_REF_BB (link->ref) = before_bb;
2836 for (link = df->insns[uid].uses; link; link = link->next)
2837 DF_REF_BB (link->ref) = before_bb;
2839 /* The lifetimes of the registers used in this insn will be reduced
2840 while the lifetimes of the registers defined in this insn
2841 are likely to be increased. */
2843 /* ???? Perhaps all the insns moved should be stored on a list
2844 which df_analyse removes when it recalculates data flow. */
2846 return emit_insn_before (insn, before_insn);
2849 /* Functions to query dataflow information. */
2853 df_insn_regno_def_p (df, bb, insn, regno)
2855 basic_block bb ATTRIBUTE_UNUSED;
2860 struct df_link *link;
2862 uid = INSN_UID (insn);
2864 for (link = df->insns[uid].defs; link; link = link->next)
2866 struct ref *def = link->ref;
2868 if (DF_REF_REGNO (def) == regno)
2877 df_def_dominates_all_uses_p (df, def)
2878 struct df *df ATTRIBUTE_UNUSED;
2881 struct df_link *du_link;
2883 /* Follow def-use chain to find all the uses of this def. */
2884 for (du_link = DF_REF_CHAIN (def); du_link; du_link = du_link->next)
2886 struct ref *use = du_link->ref;
2887 struct df_link *ud_link;
2889 /* Follow use-def chain to check all the defs for this use. */
2890 for (ud_link = DF_REF_CHAIN (use); ud_link; ud_link = ud_link->next)
2891 if (ud_link->ref != def)
2899 df_insn_dominates_all_uses_p (df, bb, insn)
2901 basic_block bb ATTRIBUTE_UNUSED;
2905 struct df_link *link;
2907 uid = INSN_UID (insn);
2909 for (link = df->insns[uid].defs; link; link = link->next)
2911 struct ref *def = link->ref;
2913 if (! df_def_dominates_all_uses_p (df, def))
2921 /* Return non-zero if all DF dominates all the uses within the bitmap
2924 df_def_dominates_uses_p (df, def, blocks)
2925 struct df *df ATTRIBUTE_UNUSED;
2929 struct df_link *du_link;
2931 /* Follow def-use chain to find all the uses of this def. */
2932 for (du_link = DF_REF_CHAIN (def); du_link; du_link = du_link->next)
2934 struct ref *use = du_link->ref;
2935 struct df_link *ud_link;
2937 /* Only worry about the uses within BLOCKS. For example,
2938 consider a register defined within a loop that is live at the
2940 if (bitmap_bit_p (blocks, DF_REF_BBNO (use)))
2942 /* Follow use-def chain to check all the defs for this use. */
2943 for (ud_link = DF_REF_CHAIN (use); ud_link; ud_link = ud_link->next)
2944 if (ud_link->ref != def)
2952 /* Return non-zero if all the defs of INSN within BB dominates
2953 all the corresponding uses. */
2955 df_insn_dominates_uses_p (df, bb, insn, blocks)
2957 basic_block bb ATTRIBUTE_UNUSED;
2962 struct df_link *link;
2964 uid = INSN_UID (insn);
2966 for (link = df->insns[uid].defs; link; link = link->next)
2968 struct ref *def = link->ref;
2970 /* Only consider the defs within BLOCKS. */
2971 if (bitmap_bit_p (blocks, DF_REF_BBNO (def))
2972 && ! df_def_dominates_uses_p (df, def, blocks))
2979 /* Return the basic block that REG referenced in or NULL if referenced
2980 in multiple basic blocks. */
2982 df_regno_bb (df, regno)
2986 struct df_link *defs = df->regs[regno].defs;
2987 struct df_link *uses = df->regs[regno].uses;
2988 struct ref *def = defs ? defs->ref : 0;
2989 struct ref *use = uses ? uses->ref : 0;
2990 basic_block bb_def = def ? DF_REF_BB (def) : 0;
2991 basic_block bb_use = use ? DF_REF_BB (use) : 0;
2993 /* Compare blocks of first def and last use. ???? FIXME. What if
2994 the reg-def and reg-use lists are not correctly ordered. */
2995 return bb_def == bb_use ? bb_def : 0;
2999 /* Return non-zero if REG used in multiple basic blocks. */
3001 df_reg_global_p (df, reg)
3005 return df_regno_bb (df, REGNO (reg)) != 0;
3009 /* Return total lifetime (in insns) of REG. */
3011 df_reg_lifetime (df, reg)
3015 return df->regs[REGNO (reg)].lifetime;
3019 /* Return non-zero if REG live at start of BB. */
3021 df_bb_reg_live_start_p (df, bb, reg)
3022 struct df *df ATTRIBUTE_UNUSED;
3026 struct bb_info *bb_info = DF_BB_INFO (df, bb);
3028 #ifdef ENABLE_CHECKING
3029 if (! bb_info->lr_in)
3033 return bitmap_bit_p (bb_info->lr_in, REGNO (reg));
3037 /* Return non-zero if REG live at end of BB. */
3039 df_bb_reg_live_end_p (df, bb, reg)
3040 struct df *df ATTRIBUTE_UNUSED;
3044 struct bb_info *bb_info = DF_BB_INFO (df, bb);
3046 #ifdef ENABLE_CHECKING
3047 if (! bb_info->lr_in)
3051 return bitmap_bit_p (bb_info->lr_out, REGNO (reg));
3055 /* Return -1 if life of REG1 before life of REG2, 1 if life of REG1
3056 after life of REG2, or 0, if the lives overlap. */
3058 df_bb_regs_lives_compare (df, bb, reg1, reg2)
3064 unsigned int regno1 = REGNO (reg1);
3065 unsigned int regno2 = REGNO (reg2);
3072 /* The regs must be local to BB. */
3073 if (df_regno_bb (df, regno1) != bb
3074 || df_regno_bb (df, regno2) != bb)
3077 def2 = df_bb_regno_first_def_find (df, bb, regno2);
3078 use1 = df_bb_regno_last_use_find (df, bb, regno1);
3080 if (DF_INSN_LUID (df, DF_REF_INSN (def2))
3081 > DF_INSN_LUID (df, DF_REF_INSN (use1)))
3084 def1 = df_bb_regno_first_def_find (df, bb, regno1);
3085 use2 = df_bb_regno_last_use_find (df, bb, regno2);
3087 if (DF_INSN_LUID (df, DF_REF_INSN (def1))
3088 > DF_INSN_LUID (df, DF_REF_INSN (use2)))
3095 /* Return last use of REGNO within BB. */
3097 df_bb_regno_last_use_find (df, bb, regno)
3099 basic_block bb ATTRIBUTE_UNUSED;
3102 struct df_link *link;
3104 /* This assumes that the reg-use list is ordered such that for any
3105 BB, the last use is found first. However, since the BBs are not
3106 ordered, the first use in the chain is not necessarily the last
3107 use in the function. */
3108 for (link = df->regs[regno].uses; link; link = link->next)
3110 struct ref *use = link->ref;
3112 if (DF_REF_BB (use) == bb)
3119 /* Return first def of REGNO within BB. */
3121 df_bb_regno_first_def_find (df, bb, regno)
3123 basic_block bb ATTRIBUTE_UNUSED;
3126 struct df_link *link;
3128 /* This assumes that the reg-def list is ordered such that for any
3129 BB, the first def is found first. However, since the BBs are not
3130 ordered, the first def in the chain is not necessarily the first
3131 def in the function. */
3132 for (link = df->regs[regno].defs; link; link = link->next)
3134 struct ref *def = link->ref;
3136 if (DF_REF_BB (def) == bb)
3143 /* Return first use of REGNO inside INSN within BB. */
3145 df_bb_insn_regno_last_use_find (df, bb, insn, regno)
3147 basic_block bb ATTRIBUTE_UNUSED;
3152 struct df_link *link;
3154 uid = INSN_UID (insn);
3156 for (link = df->insns[uid].uses; link; link = link->next)
3158 struct ref *use = link->ref;
3160 if (DF_REF_REGNO (use) == regno)
3168 /* Return first def of REGNO inside INSN within BB. */
3170 df_bb_insn_regno_first_def_find (df, bb, insn, regno)
3172 basic_block bb ATTRIBUTE_UNUSED;
3177 struct df_link *link;
3179 uid = INSN_UID (insn);
3181 for (link = df->insns[uid].defs; link; link = link->next)
3183 struct ref *def = link->ref;
3185 if (DF_REF_REGNO (def) == regno)
3193 /* Return insn using REG if the BB contains only a single
3194 use and def of REG. */
3196 df_bb_single_def_use_insn_find (df, bb, insn, reg)
3204 struct df_link *du_link;
3206 def = df_bb_insn_regno_first_def_find (df, bb, insn, REGNO (reg));
3211 du_link = DF_REF_CHAIN (def);
3218 /* Check if def is dead. */
3222 /* Check for multiple uses. */
3226 return DF_REF_INSN (use);
3229 /* Functions for debugging/dumping dataflow information. */
3232 /* Dump a def-use or use-def chain for REF to FILE. */
3234 df_chain_dump (link, file)
3235 struct df_link *link;
3238 fprintf (file, "{ ");
3239 for (; link; link = link->next)
3241 fprintf (file, "%c%d ",
3242 DF_REF_REG_DEF_P (link->ref) ? 'd' : 'u',
3243 DF_REF_ID (link->ref));
3245 fprintf (file, "}");
3249 df_chain_dump_regno (link, file)
3250 struct df_link *link;
3253 fprintf (file, "{ ");
3254 for (; link; link = link->next)
3256 fprintf (file, "%c%d(%d) ",
3257 DF_REF_REG_DEF_P (link->ref) ? 'd' : 'u',
3258 DF_REF_ID (link->ref),
3259 DF_REF_REGNO (link->ref));
3261 fprintf (file, "}");
3264 /* Dump dataflow info. */
3266 df_dump (df, flags, file)
3277 fprintf (file, "\nDataflow summary:\n");
3278 fprintf (file, "n_regs = %d, n_defs = %d, n_uses = %d, n_bbs = %d\n",
3279 df->n_regs, df->n_defs, df->n_uses, df->n_bbs);
3285 fprintf (file, "Reaching defs:\n");
3288 struct bb_info *bb_info = DF_BB_INFO (df, bb);
3290 if (! bb_info->rd_in)
3293 fprintf (file, "bb %d in \t", bb->index);
3294 dump_bitmap (file, bb_info->rd_in);
3295 fprintf (file, "bb %d gen \t", bb->index);
3296 dump_bitmap (file, bb_info->rd_gen);
3297 fprintf (file, "bb %d kill\t", bb->index);
3298 dump_bitmap (file, bb_info->rd_kill);
3299 fprintf (file, "bb %d out \t", bb->index);
3300 dump_bitmap (file, bb_info->rd_out);
3304 if (flags & DF_UD_CHAIN)
3306 fprintf (file, "Use-def chains:\n");
3307 for (j = 0; j < df->n_defs; j++)
3311 fprintf (file, "d%d bb %d luid %d insn %d reg %d ",
3312 j, DF_REF_BBNO (df->defs[j]),
3313 DF_INSN_LUID (df, DF_REF_INSN (df->defs[j])),
3314 DF_REF_INSN_UID (df->defs[j]),
3315 DF_REF_REGNO (df->defs[j]));
3316 if (df->defs[j]->flags & DF_REF_READ_WRITE)
3317 fprintf (file, "read/write ");
3318 df_chain_dump (DF_REF_CHAIN (df->defs[j]), file);
3319 fprintf (file, "\n");
3326 fprintf (file, "Reaching uses:\n");
3329 struct bb_info *bb_info = DF_BB_INFO (df, bb);
3331 if (! bb_info->ru_in)
3334 fprintf (file, "bb %d in \t", bb->index);
3335 dump_bitmap (file, bb_info->ru_in);
3336 fprintf (file, "bb %d gen \t", bb->index);
3337 dump_bitmap (file, bb_info->ru_gen);
3338 fprintf (file, "bb %d kill\t", bb->index);
3339 dump_bitmap (file, bb_info->ru_kill);
3340 fprintf (file, "bb %d out \t", bb->index);
3341 dump_bitmap (file, bb_info->ru_out);
3345 if (flags & DF_DU_CHAIN)
3347 fprintf (file, "Def-use chains:\n");
3348 for (j = 0; j < df->n_uses; j++)
3352 fprintf (file, "u%d bb %d luid %d insn %d reg %d ",
3353 j, DF_REF_BBNO (df->uses[j]),
3354 DF_INSN_LUID (df, DF_REF_INSN (df->uses[j])),
3355 DF_REF_INSN_UID (df->uses[j]),
3356 DF_REF_REGNO (df->uses[j]));
3357 if (df->uses[j]->flags & DF_REF_READ_WRITE)
3358 fprintf (file, "read/write ");
3359 df_chain_dump (DF_REF_CHAIN (df->uses[j]), file);
3360 fprintf (file, "\n");
3367 fprintf (file, "Live regs:\n");
3370 struct bb_info *bb_info = DF_BB_INFO (df, bb);
3372 if (! bb_info->lr_in)
3375 fprintf (file, "bb %d in \t", bb->index);
3376 dump_bitmap (file, bb_info->lr_in);
3377 fprintf (file, "bb %d use \t", bb->index);
3378 dump_bitmap (file, bb_info->lr_use);
3379 fprintf (file, "bb %d def \t", bb->index);
3380 dump_bitmap (file, bb_info->lr_def);
3381 fprintf (file, "bb %d out \t", bb->index);
3382 dump_bitmap (file, bb_info->lr_out);
3386 if (flags & (DF_REG_INFO | DF_RD_CHAIN | DF_RU_CHAIN))
3388 struct reg_info *reg_info = df->regs;
3390 fprintf (file, "Register info:\n");
3391 for (j = 0; j < df->n_regs; j++)
3393 if (((flags & DF_REG_INFO)
3394 && (reg_info[j].n_uses || reg_info[j].n_defs))
3395 || ((flags & DF_RD_CHAIN) && reg_info[j].defs)
3396 || ((flags & DF_RU_CHAIN) && reg_info[j].uses))
3398 fprintf (file, "reg %d", j);
3399 if ((flags & DF_RD_CHAIN) && (flags & DF_RU_CHAIN))
3401 basic_block bb = df_regno_bb (df, j);
3404 fprintf (file, " bb %d", bb->index);
3406 fprintf (file, " bb ?");
3408 if (flags & DF_REG_INFO)
3410 fprintf (file, " life %d", reg_info[j].lifetime);
3413 if ((flags & DF_REG_INFO) || (flags & DF_RD_CHAIN))
3415 fprintf (file, " defs ");
3416 if (flags & DF_REG_INFO)
3417 fprintf (file, "%d ", reg_info[j].n_defs);
3418 if (flags & DF_RD_CHAIN)
3419 df_chain_dump (reg_info[j].defs, file);
3422 if ((flags & DF_REG_INFO) || (flags & DF_RU_CHAIN))
3424 fprintf (file, " uses ");
3425 if (flags & DF_REG_INFO)
3426 fprintf (file, "%d ", reg_info[j].n_uses);
3427 if (flags & DF_RU_CHAIN)
3428 df_chain_dump (reg_info[j].uses, file);
3431 fprintf (file, "\n");
3435 fprintf (file, "\n");
3440 df_insn_debug (df, insn, file)
3448 uid = INSN_UID (insn);
3449 if (uid >= df->insn_size)
3452 if (df->insns[uid].defs)
3453 bbi = DF_REF_BBNO (df->insns[uid].defs->ref);
3454 else if (df->insns[uid].uses)
3455 bbi = DF_REF_BBNO (df->insns[uid].uses->ref);
3459 fprintf (file, "insn %d bb %d luid %d defs ",
3460 uid, bbi, DF_INSN_LUID (df, insn));
3461 df_chain_dump (df->insns[uid].defs, file);
3462 fprintf (file, " uses ");
3463 df_chain_dump (df->insns[uid].uses, file);
3464 fprintf (file, "\n");
3468 df_insn_debug_regno (df, insn, file)
3476 uid = INSN_UID (insn);
3477 if (uid >= df->insn_size)
3480 if (df->insns[uid].defs)
3481 bbi = DF_REF_BBNO (df->insns[uid].defs->ref);
3482 else if (df->insns[uid].uses)
3483 bbi = DF_REF_BBNO (df->insns[uid].uses->ref);
3487 fprintf (file, "insn %d bb %d luid %d defs ",
3488 uid, bbi, DF_INSN_LUID (df, insn));
3489 df_chain_dump_regno (df->insns[uid].defs, file);
3490 fprintf (file, " uses ");
3491 df_chain_dump_regno (df->insns[uid].uses, file);
3492 fprintf (file, "\n");
3496 df_regno_debug (df, regno, file)
3501 if (regno >= df->reg_size)
3504 fprintf (file, "reg %d life %d defs ",
3505 regno, df->regs[regno].lifetime);
3506 df_chain_dump (df->regs[regno].defs, file);
3507 fprintf (file, " uses ");
3508 df_chain_dump (df->regs[regno].uses, file);
3509 fprintf (file, "\n");
3514 df_ref_debug (df, ref, file)
3519 fprintf (file, "%c%d ",
3520 DF_REF_REG_DEF_P (ref) ? 'd' : 'u',
3522 fprintf (file, "reg %d bb %d luid %d insn %d chain ",
3525 DF_INSN_LUID (df, DF_REF_INSN (ref)),
3526 INSN_UID (DF_REF_INSN (ref)));
3527 df_chain_dump (DF_REF_CHAIN (ref), file);
3528 fprintf (file, "\n");
3533 debug_df_insn (insn)
3536 df_insn_debug (ddf, insn, stderr);
3545 df_regno_debug (ddf, REGNO (reg), stderr);
3550 debug_df_regno (regno)
3553 df_regno_debug (ddf, regno, stderr);
3561 df_ref_debug (ddf, ref, stderr);
3566 debug_df_defno (defno)
3569 df_ref_debug (ddf, ddf->defs[defno], stderr);
3574 debug_df_useno (defno)
3577 df_ref_debug (ddf, ddf->uses[defno], stderr);
3582 debug_df_chain (link)
3583 struct df_link *link;
3585 df_chain_dump (link, stderr);
3586 fputc ('\n', stderr);
3589 /* Hybrid search algorithm from "Implementation Techniques for
3590 Efficient Data-Flow Analysis of Large Programs". */
3592 hybrid_search_bitmap (block, in, out, gen, kill, dir,
3593 conf_op, transfun, visited, pending,
3596 bitmap *in, *out, *gen, *kill;
3597 enum df_flow_dir dir;
3598 enum df_confluence_op conf_op;
3599 transfer_function_bitmap transfun;
3605 int i = block->index;
3607 basic_block bb= block;
3608 SET_BIT (visited, block->index);
3609 if (TEST_BIT (pending, block->index))
3613 /* Calculate <conf_op> of predecessor_outs */
3614 bitmap_zero (in[i]);
3615 for (e = bb->pred; e != 0; e = e->pred_next)
3617 if (e->src == ENTRY_BLOCK_PTR)
3622 bitmap_a_or_b (in[i], in[i], out[e->src->index]);
3625 bitmap_a_and_b (in[i], in[i], out[e->src->index]);
3632 /* Calculate <conf_op> of successor ins */
3633 bitmap_zero(out[i]);
3634 for (e = bb->succ; e != 0; e = e->succ_next)
3636 if (e->dest == EXIT_BLOCK_PTR)
3641 bitmap_a_or_b (out[i], out[i], in[e->dest->index]);
3644 bitmap_a_and_b (out[i], out[i], in[e->dest->index]);
3650 (*transfun)(i, &changed, in[i], out[i], gen[i], kill[i], data);
3651 RESET_BIT (pending, i);
3656 for (e = bb->succ; e != 0; e = e->succ_next)
3658 if (e->dest == EXIT_BLOCK_PTR || e->dest->index == i)
3660 SET_BIT (pending, e->dest->index);
3665 for (e = bb->pred; e != 0; e = e->pred_next)
3667 if (e->src == ENTRY_BLOCK_PTR || e->dest->index == i)
3669 SET_BIT (pending, e->src->index);
3676 for (e = bb->succ; e != 0; e = e->succ_next)
3678 if (e->dest == EXIT_BLOCK_PTR || e->dest->index == i)
3680 if (!TEST_BIT (visited, e->dest->index))
3681 hybrid_search_bitmap (e->dest, in, out, gen, kill, dir,
3682 conf_op, transfun, visited, pending,
3688 for (e = bb->pred; e != 0; e = e->pred_next)
3690 if (e->src == ENTRY_BLOCK_PTR || e->src->index == i)
3692 if (!TEST_BIT (visited, e->src->index))
3693 hybrid_search_bitmap (e->src, in, out, gen, kill, dir,
3694 conf_op, transfun, visited, pending,
3701 /* Hybrid search for sbitmaps, rather than bitmaps. */
3703 hybrid_search_sbitmap (block, in, out, gen, kill, dir,
3704 conf_op, transfun, visited, pending,
3707 sbitmap *in, *out, *gen, *kill;
3708 enum df_flow_dir dir;
3709 enum df_confluence_op conf_op;
3710 transfer_function_sbitmap transfun;
3716 int i = block->index;
3718 basic_block bb= block;
3719 SET_BIT (visited, block->index);
3720 if (TEST_BIT (pending, block->index))
3724 /* Calculate <conf_op> of predecessor_outs */
3725 sbitmap_zero (in[i]);
3726 for (e = bb->pred; e != 0; e = e->pred_next)
3728 if (e->src == ENTRY_BLOCK_PTR)
3733 sbitmap_a_or_b (in[i], in[i], out[e->src->index]);
3736 sbitmap_a_and_b (in[i], in[i], out[e->src->index]);
3743 /* Calculate <conf_op> of successor ins */
3744 sbitmap_zero(out[i]);
3745 for (e = bb->succ; e != 0; e = e->succ_next)
3747 if (e->dest == EXIT_BLOCK_PTR)
3752 sbitmap_a_or_b (out[i], out[i], in[e->dest->index]);
3755 sbitmap_a_and_b (out[i], out[i], in[e->dest->index]);
3761 (*transfun)(i, &changed, in[i], out[i], gen[i], kill[i], data);
3762 RESET_BIT (pending, i);
3767 for (e = bb->succ; e != 0; e = e->succ_next)
3769 if (e->dest == EXIT_BLOCK_PTR || e->dest->index == i)
3771 SET_BIT (pending, e->dest->index);
3776 for (e = bb->pred; e != 0; e = e->pred_next)
3778 if (e->src == ENTRY_BLOCK_PTR || e->dest->index == i)
3780 SET_BIT (pending, e->src->index);
3787 for (e = bb->succ; e != 0; e = e->succ_next)
3789 if (e->dest == EXIT_BLOCK_PTR || e->dest->index == i)
3791 if (!TEST_BIT (visited, e->dest->index))
3792 hybrid_search_sbitmap (e->dest, in, out, gen, kill, dir,
3793 conf_op, transfun, visited, pending,
3799 for (e = bb->pred; e != 0; e = e->pred_next)
3801 if (e->src == ENTRY_BLOCK_PTR || e->src->index == i)
3803 if (!TEST_BIT (visited, e->src->index))
3804 hybrid_search_sbitmap (e->src, in, out, gen, kill, dir,
3805 conf_op, transfun, visited, pending,
3816 in, out = Filled in by function.
3817 blocks = Blocks to analyze.
3818 dir = Dataflow direction.
3819 conf_op = Confluence operation.
3820 transfun = Transfer function.
3821 order = Order to iterate in. (Should map block numbers -> order)
3822 data = Whatever you want. It's passed to the transfer function.
3824 This function will perform iterative bitvector dataflow, producing
3825 the in and out sets. Even if you only want to perform it for a
3826 small number of blocks, the vectors for in and out must be large
3827 enough for *all* blocks, because changing one block might affect
3828 others. However, it'll only put what you say to analyze on the
3831 For forward problems, you probably want to pass in a mapping of
3832 block number to rc_order (like df->inverse_rc_map).
3835 iterative_dataflow_sbitmap (in, out, gen, kill, blocks,
3836 dir, conf_op, transfun, order, data)
3837 sbitmap *in, *out, *gen, *kill;
3839 enum df_flow_dir dir;
3840 enum df_confluence_op conf_op;
3841 transfer_function_sbitmap transfun;
3848 sbitmap visited, pending;
3849 pending = sbitmap_alloc (n_basic_blocks);
3850 visited = sbitmap_alloc (n_basic_blocks);
3851 sbitmap_zero (pending);
3852 sbitmap_zero (visited);
3853 worklist = fibheap_new ();
3854 EXECUTE_IF_SET_IN_BITMAP (blocks, 0, i,
3856 fibheap_insert (worklist, order[i], (void *) (size_t) i);
3857 SET_BIT (pending, i);
3859 sbitmap_copy (out[i], gen[i]);
3861 sbitmap_copy (in[i], gen[i]);
3863 while (sbitmap_first_set_bit (pending) != -1)
3865 while (!fibheap_empty (worklist))
3867 i = (size_t) fibheap_extract_min (worklist);
3868 bb = BASIC_BLOCK (i);
3869 if (!TEST_BIT (visited, bb->index))
3870 hybrid_search_sbitmap (bb, in, out, gen, kill, dir,
3871 conf_op, transfun, visited, pending, data);
3873 if (sbitmap_first_set_bit (pending) != -1)
3875 EXECUTE_IF_SET_IN_BITMAP (blocks, 0, i,
3877 fibheap_insert (worklist, order[i], (void *) (size_t) i);
3879 sbitmap_zero (visited);
3886 sbitmap_free (pending);
3887 sbitmap_free (visited);
3888 fibheap_delete (worklist);
3891 /* Exactly the same as iterative_dataflow_sbitmap, except it works on
3894 iterative_dataflow_bitmap (in, out, gen, kill, blocks,
3895 dir, conf_op, transfun, order, data)
3896 bitmap *in, *out, *gen, *kill;
3898 enum df_flow_dir dir;
3899 enum df_confluence_op conf_op;
3900 transfer_function_bitmap transfun;
3907 sbitmap visited, pending;
3908 pending = sbitmap_alloc (n_basic_blocks);
3909 visited = sbitmap_alloc (n_basic_blocks);
3910 sbitmap_zero (pending);
3911 sbitmap_zero (visited);
3912 worklist = fibheap_new ();
3913 EXECUTE_IF_SET_IN_BITMAP (blocks, 0, i,
3915 fibheap_insert (worklist, order[i], (void *) (size_t) i);
3916 SET_BIT (pending, i);
3918 bitmap_copy (out[i], gen[i]);
3920 bitmap_copy (in[i], gen[i]);
3922 while (sbitmap_first_set_bit (pending) != -1)
3924 while (!fibheap_empty (worklist))
3926 i = (size_t) fibheap_extract_min (worklist);
3927 bb = BASIC_BLOCK (i);
3928 if (!TEST_BIT (visited, bb->index))
3929 hybrid_search_bitmap (bb, in, out, gen, kill, dir,
3930 conf_op, transfun, visited, pending, data);
3932 if (sbitmap_first_set_bit (pending) != -1)
3934 EXECUTE_IF_SET_IN_BITMAP (blocks, 0, i,
3936 fibheap_insert (worklist, order[i], (void *) (size_t) i);
3938 sbitmap_zero (visited);
3945 sbitmap_free (pending);
3946 sbitmap_free (visited);
3947 fibheap_delete (worklist);