1 /* Variable tracking routines for the GNU compiler.
2 Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GCC is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING. If not, write to the Free
18 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
21 /* This file contains the variable tracking pass. It computes where
22 variables are located (which registers or where in memory) at each position
23 in instruction stream and emits notes describing the locations.
24 Debug information (DWARF2 location lists) is finally generated from
26 With this debug information, it is possible to show variables
27 even when debugging optimized code.
29 How does the variable tracking pass work?
31 First, it scans RTL code for uses, stores and clobbers (register/memory
32 references in instructions), for call insns and for stack adjustments
33 separately for each basic block and saves them to an array of micro
35 The micro operations of one instruction are ordered so that
36 pre-modifying stack adjustment < use < use with no var < call insn <
37 < set < clobber < post-modifying stack adjustment
39 Then, a forward dataflow analysis is performed to find out how locations
40 of variables change through code and to propagate the variable locations
41 along control flow graph.
42 The IN set for basic block BB is computed as a union of OUT sets of BB's
43 predecessors, the OUT set for BB is copied from the IN set for BB and
44 is changed according to micro operations in BB.
46 The IN and OUT sets for basic blocks consist of a current stack adjustment
47 (used for adjusting offset of variables addressed using stack pointer),
48 the table of structures describing the locations of parts of a variable
49 and for each physical register a linked list for each physical register.
50 The linked list is a list of variable parts stored in the register,
51 i.e. it is a list of triplets (reg, decl, offset) where decl is
52 REG_EXPR (reg) and offset is REG_OFFSET (reg). The linked list is used for
53 effective deleting appropriate variable parts when we set or clobber the
56 There may be more than one variable part in a register. The linked lists
57 should be pretty short so it is a good data structure here.
58 For example in the following code, register allocator may assign same
59 register to variables A and B, and both of them are stored in the same
72 Finally, the NOTE_INSN_VAR_LOCATION notes describing the variable locations
73 are emitted to appropriate positions in RTL code. Each such a note describes
74 the location of one variable at the point in instruction stream where the
75 note is. There is no need to emit a note for each variable before each
76 instruction, we only emit these notes where the location of variable changes
77 (this means that we also emit notes for changes between the OUT set of the
78 previous block and the IN set of the current block).
80 The notes consist of two parts:
81 1. the declaration (from REG_EXPR or MEM_EXPR)
82 2. the location of a variable - it is either a simple register/memory
83 reference (for simple variables, for example int),
84 or a parallel of register/memory references (for a large variables
85 which consist of several parts, for example long long).
91 #include "coretypes.h"
95 #include "hard-reg-set.h"
96 #include "basic-block.h"
99 #include "insn-config.h"
102 #include "alloc-pool.h"
108 #include "tree-pass.h"
110 /* Type of micro operation. */
111 enum micro_operation_type
113 MO_USE, /* Use location (REG or MEM). */
114 MO_USE_NO_VAR,/* Use location which is not associated with a variable
115 or the variable is not trackable. */
116 MO_SET, /* Set location. */
117 MO_CLOBBER, /* Clobber location. */
118 MO_CALL, /* Call insn. */
119 MO_ADJUST /* Adjust stack pointer. */
122 /* Where shall the note be emitted? BEFORE or AFTER the instruction. */
125 EMIT_NOTE_BEFORE_INSN,
129 /* Structure holding information about micro operation. */
130 typedef struct micro_operation_def
132 /* Type of micro operation. */
133 enum micro_operation_type type;
139 /* Stack adjustment. */
140 HOST_WIDE_INT adjust;
143 /* The instruction which the micro operation is in. */
147 /* Structure for passing some other parameters to function
148 emit_note_insn_var_location. */
149 typedef struct emit_note_data_def
151 /* The instruction which the note will be emitted before/after. */
154 /* Where the note will be emitted (before/after insn)? */
155 enum emit_note_where where;
158 /* Description of location of a part of a variable. The content of a physical
159 register is described by a chain of these structures.
160 The chains are pretty short (usually 1 or 2 elements) and thus
161 chain is the best data structure. */
162 typedef struct attrs_def
164 /* Pointer to next member of the list. */
165 struct attrs_def *next;
167 /* The rtx of register. */
170 /* The declaration corresponding to LOC. */
173 /* Offset from start of DECL. */
174 HOST_WIDE_INT offset;
177 /* Structure holding the IN or OUT set for a basic block. */
178 typedef struct dataflow_set_def
180 /* Adjustment of stack offset. */
181 HOST_WIDE_INT stack_adjust;
183 /* Attributes for registers (lists of attrs). */
184 attrs regs[FIRST_PSEUDO_REGISTER];
186 /* Variable locations. */
190 /* The structure (one for each basic block) containing the information
191 needed for variable tracking. */
192 typedef struct variable_tracking_info_def
194 /* Number of micro operations stored in the MOS array. */
197 /* The array of micro operations. */
198 micro_operation *mos;
200 /* The IN and OUT set for dataflow analysis. */
204 /* Has the block been visited in DFS? */
206 } *variable_tracking_info;
208 /* Structure for chaining the locations. */
209 typedef struct location_chain_def
211 /* Next element in the chain. */
212 struct location_chain_def *next;
214 /* The location (REG or MEM). */
218 /* Structure describing one part of variable. */
219 typedef struct variable_part_def
221 /* Chain of locations of the part. */
222 location_chain loc_chain;
224 /* Location which was last emitted to location list. */
227 /* The offset in the variable. */
228 HOST_WIDE_INT offset;
231 /* Maximum number of location parts. */
232 #define MAX_VAR_PARTS 16
234 /* Structure describing where the variable is located. */
235 typedef struct variable_def
237 /* The declaration of the variable. */
240 /* Reference count. */
243 /* Number of variable parts. */
246 /* The variable parts. */
247 variable_part var_part[MAX_VAR_PARTS];
250 /* Hash function for DECL for VARIABLE_HTAB. */
251 #define VARIABLE_HASH_VAL(decl) (DECL_UID (decl))
253 /* Pointer to the BB's information specific to variable tracking pass. */
254 #define VTI(BB) ((variable_tracking_info) (BB)->aux)
256 /* Alloc pool for struct attrs_def. */
257 static alloc_pool attrs_pool;
259 /* Alloc pool for struct variable_def. */
260 static alloc_pool var_pool;
262 /* Alloc pool for struct location_chain_def. */
263 static alloc_pool loc_chain_pool;
265 /* Changed variables, notes will be emitted for them. */
266 static htab_t changed_variables;
268 /* Shall notes be emitted? */
269 static bool emit_notes;
271 /* Fake variable for stack pointer. */
272 tree frame_base_decl;
274 /* Stack adjust caused by function prologue. */
275 static HOST_WIDE_INT frame_stack_adjust;
277 /* Local function prototypes. */
278 static void stack_adjust_offset_pre_post (rtx, HOST_WIDE_INT *,
280 static void insn_stack_adjust_offset_pre_post (rtx, HOST_WIDE_INT *,
282 static void bb_stack_adjust_offset (basic_block);
283 static HOST_WIDE_INT prologue_stack_adjust (void);
284 static bool vt_stack_adjustments (void);
285 static rtx adjust_stack_reference (rtx, HOST_WIDE_INT);
286 static hashval_t variable_htab_hash (const void *);
287 static int variable_htab_eq (const void *, const void *);
288 static void variable_htab_free (void *);
290 static void init_attrs_list_set (attrs *);
291 static void attrs_list_clear (attrs *);
292 static attrs attrs_list_member (attrs, tree, HOST_WIDE_INT);
293 static void attrs_list_insert (attrs *, tree, HOST_WIDE_INT, rtx);
294 static void attrs_list_copy (attrs *, attrs);
295 static void attrs_list_union (attrs *, attrs);
297 static void vars_clear (htab_t);
298 static variable unshare_variable (dataflow_set *set, variable var);
299 static int vars_copy_1 (void **, void *);
300 static void vars_copy (htab_t, htab_t);
301 static void var_reg_delete_and_set (dataflow_set *, rtx);
302 static void var_reg_delete (dataflow_set *, rtx);
303 static void var_regno_delete (dataflow_set *, int);
304 static void var_mem_delete_and_set (dataflow_set *, rtx);
305 static void var_mem_delete (dataflow_set *, rtx);
307 static void dataflow_set_init (dataflow_set *, int);
308 static void dataflow_set_clear (dataflow_set *);
309 static void dataflow_set_copy (dataflow_set *, dataflow_set *);
310 static int variable_union_info_cmp_pos (const void *, const void *);
311 static int variable_union (void **, void *);
312 static void dataflow_set_union (dataflow_set *, dataflow_set *);
313 static bool variable_part_different_p (variable_part *, variable_part *);
314 static bool variable_different_p (variable, variable, bool);
315 static int dataflow_set_different_1 (void **, void *);
316 static int dataflow_set_different_2 (void **, void *);
317 static bool dataflow_set_different (dataflow_set *, dataflow_set *);
318 static void dataflow_set_destroy (dataflow_set *);
320 static bool contains_symbol_ref (rtx);
321 static bool track_expr_p (tree);
322 static int count_uses (rtx *, void *);
323 static void count_uses_1 (rtx *, void *);
324 static void count_stores (rtx, rtx, void *);
325 static int add_uses (rtx *, void *);
326 static void add_uses_1 (rtx *, void *);
327 static void add_stores (rtx, rtx, void *);
328 static bool compute_bb_dataflow (basic_block);
329 static void vt_find_locations (void);
331 static void dump_attrs_list (attrs);
332 static int dump_variable (void **, void *);
333 static void dump_vars (htab_t);
334 static void dump_dataflow_set (dataflow_set *);
335 static void dump_dataflow_sets (void);
337 static void variable_was_changed (variable, htab_t);
338 static void set_frame_base_location (dataflow_set *, rtx);
339 static void set_variable_part (dataflow_set *, rtx, tree, HOST_WIDE_INT);
340 static void delete_variable_part (dataflow_set *, rtx, tree, HOST_WIDE_INT);
341 static int emit_note_insn_var_location (void **, void *);
342 static void emit_notes_for_changes (rtx, enum emit_note_where);
343 static int emit_notes_for_differences_1 (void **, void *);
344 static int emit_notes_for_differences_2 (void **, void *);
345 static void emit_notes_for_differences (rtx, dataflow_set *, dataflow_set *);
346 static void emit_notes_in_bb (basic_block);
347 static void vt_emit_notes (void);
349 static bool vt_get_decl_and_offset (rtx, tree *, HOST_WIDE_INT *);
350 static void vt_add_function_parameters (void);
351 static void vt_initialize (void);
352 static void vt_finalize (void);
354 /* Given a SET, calculate the amount of stack adjustment it contains
355 PRE- and POST-modifying stack pointer.
356 This function is similar to stack_adjust_offset. */
359 stack_adjust_offset_pre_post (rtx pattern, HOST_WIDE_INT *pre,
362 rtx src = SET_SRC (pattern);
363 rtx dest = SET_DEST (pattern);
366 if (dest == stack_pointer_rtx)
368 /* (set (reg sp) (plus (reg sp) (const_int))) */
369 code = GET_CODE (src);
370 if (! (code == PLUS || code == MINUS)
371 || XEXP (src, 0) != stack_pointer_rtx
372 || GET_CODE (XEXP (src, 1)) != CONST_INT)
376 *post += INTVAL (XEXP (src, 1));
378 *post -= INTVAL (XEXP (src, 1));
380 else if (MEM_P (dest))
382 /* (set (mem (pre_dec (reg sp))) (foo)) */
383 src = XEXP (dest, 0);
384 code = GET_CODE (src);
390 if (XEXP (src, 0) == stack_pointer_rtx)
392 rtx val = XEXP (XEXP (src, 1), 1);
393 /* We handle only adjustments by constant amount. */
394 gcc_assert (GET_CODE (XEXP (src, 1)) == PLUS &&
395 GET_CODE (val) == CONST_INT);
397 if (code == PRE_MODIFY)
398 *pre -= INTVAL (val);
400 *post -= INTVAL (val);
406 if (XEXP (src, 0) == stack_pointer_rtx)
408 *pre += GET_MODE_SIZE (GET_MODE (dest));
414 if (XEXP (src, 0) == stack_pointer_rtx)
416 *post += GET_MODE_SIZE (GET_MODE (dest));
422 if (XEXP (src, 0) == stack_pointer_rtx)
424 *pre -= GET_MODE_SIZE (GET_MODE (dest));
430 if (XEXP (src, 0) == stack_pointer_rtx)
432 *post -= GET_MODE_SIZE (GET_MODE (dest));
443 /* Given an INSN, calculate the amount of stack adjustment it contains
444 PRE- and POST-modifying stack pointer. */
447 insn_stack_adjust_offset_pre_post (rtx insn, HOST_WIDE_INT *pre,
453 if (GET_CODE (PATTERN (insn)) == SET)
454 stack_adjust_offset_pre_post (PATTERN (insn), pre, post);
455 else if (GET_CODE (PATTERN (insn)) == PARALLEL
456 || GET_CODE (PATTERN (insn)) == SEQUENCE)
460 /* There may be stack adjustments inside compound insns. Search
462 for ( i = XVECLEN (PATTERN (insn), 0) - 1; i >= 0; i--)
463 if (GET_CODE (XVECEXP (PATTERN (insn), 0, i)) == SET)
464 stack_adjust_offset_pre_post (XVECEXP (PATTERN (insn), 0, i),
469 /* Compute stack adjustment in basic block BB. */
472 bb_stack_adjust_offset (basic_block bb)
474 HOST_WIDE_INT offset;
477 offset = VTI (bb)->in.stack_adjust;
478 for (i = 0; i < VTI (bb)->n_mos; i++)
480 if (VTI (bb)->mos[i].type == MO_ADJUST)
481 offset += VTI (bb)->mos[i].u.adjust;
482 else if (VTI (bb)->mos[i].type != MO_CALL)
484 if (MEM_P (VTI (bb)->mos[i].u.loc))
486 VTI (bb)->mos[i].u.loc
487 = adjust_stack_reference (VTI (bb)->mos[i].u.loc, -offset);
491 VTI (bb)->out.stack_adjust = offset;
494 /* Compute stack adjustment caused by function prologue. */
497 prologue_stack_adjust (void)
499 HOST_WIDE_INT offset = 0;
500 basic_block bb = ENTRY_BLOCK_PTR->next_bb;
507 end = NEXT_INSN (BB_END (bb));
508 for (insn = BB_HEAD (bb); insn != end; insn = NEXT_INSN (insn))
511 && NOTE_LINE_NUMBER (insn) == NOTE_INSN_PROLOGUE_END)
518 insn_stack_adjust_offset_pre_post (insn, &tmp, &tmp);
526 /* Compute stack adjustments for all blocks by traversing DFS tree.
527 Return true when the adjustments on all incoming edges are consistent.
528 Heavily borrowed from flow_depth_first_order_compute. */
531 vt_stack_adjustments (void)
533 edge_iterator *stack;
536 /* Initialize entry block. */
537 VTI (ENTRY_BLOCK_PTR)->visited = true;
538 VTI (ENTRY_BLOCK_PTR)->out.stack_adjust = frame_stack_adjust;
540 /* Allocate stack for back-tracking up CFG. */
541 stack = xmalloc ((n_basic_blocks + 1) * sizeof (edge_iterator));
544 /* Push the first edge on to the stack. */
545 stack[sp++] = ei_start (ENTRY_BLOCK_PTR->succs);
553 /* Look at the edge on the top of the stack. */
555 src = ei_edge (ei)->src;
556 dest = ei_edge (ei)->dest;
558 /* Check if the edge destination has been visited yet. */
559 if (!VTI (dest)->visited)
561 VTI (dest)->visited = true;
562 VTI (dest)->in.stack_adjust = VTI (src)->out.stack_adjust;
563 bb_stack_adjust_offset (dest);
565 if (EDGE_COUNT (dest->succs) > 0)
566 /* Since the DEST node has been visited for the first
567 time, check its successors. */
568 stack[sp++] = ei_start (dest->succs);
572 /* Check whether the adjustments on the edges are the same. */
573 if (VTI (dest)->in.stack_adjust != VTI (src)->out.stack_adjust)
579 if (! ei_one_before_end_p (ei))
580 /* Go to the next edge. */
581 ei_next (&stack[sp - 1]);
583 /* Return to previous level if there are no more edges. */
592 /* Adjust stack reference MEM by ADJUSTMENT bytes and return the new rtx. */
595 adjust_stack_reference (rtx mem, HOST_WIDE_INT adjustment)
603 adjusted_mem = copy_rtx (mem);
604 XEXP (adjusted_mem, 0) = replace_rtx (XEXP (adjusted_mem, 0),
606 gen_rtx_PLUS (Pmode, stack_pointer_rtx,
607 GEN_INT (adjustment)));
608 tmp = simplify_rtx (XEXP (adjusted_mem, 0));
610 XEXP (adjusted_mem, 0) = tmp;
615 /* The hash function for variable_htab, computes the hash value
616 from the declaration of variable X. */
619 variable_htab_hash (const void *x)
621 const variable v = (const variable) x;
623 return (VARIABLE_HASH_VAL (v->decl));
626 /* Compare the declaration of variable X with declaration Y. */
629 variable_htab_eq (const void *x, const void *y)
631 const variable v = (const variable) x;
632 const tree decl = (const tree) y;
634 return (VARIABLE_HASH_VAL (v->decl) == VARIABLE_HASH_VAL (decl));
637 /* Free the element of VARIABLE_HTAB (its type is struct variable_def). */
640 variable_htab_free (void *elem)
643 variable var = (variable) elem;
644 location_chain node, next;
646 gcc_assert (var->refcount > 0);
649 if (var->refcount > 0)
652 for (i = 0; i < var->n_var_parts; i++)
654 for (node = var->var_part[i].loc_chain; node; node = next)
657 pool_free (loc_chain_pool, node);
659 var->var_part[i].loc_chain = NULL;
661 pool_free (var_pool, var);
664 /* Initialize the set (array) SET of attrs to empty lists. */
667 init_attrs_list_set (attrs *set)
671 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
675 /* Make the list *LISTP empty. */
678 attrs_list_clear (attrs *listp)
682 for (list = *listp; list; list = next)
685 pool_free (attrs_pool, list);
690 /* Return true if the pair of DECL and OFFSET is the member of the LIST. */
693 attrs_list_member (attrs list, tree decl, HOST_WIDE_INT offset)
695 for (; list; list = list->next)
696 if (list->decl == decl && list->offset == offset)
701 /* Insert the triplet DECL, OFFSET, LOC to the list *LISTP. */
704 attrs_list_insert (attrs *listp, tree decl, HOST_WIDE_INT offset, rtx loc)
708 list = pool_alloc (attrs_pool);
711 list->offset = offset;
716 /* Copy all nodes from SRC and create a list *DSTP of the copies. */
719 attrs_list_copy (attrs *dstp, attrs src)
723 attrs_list_clear (dstp);
724 for (; src; src = src->next)
726 n = pool_alloc (attrs_pool);
729 n->offset = src->offset;
735 /* Add all nodes from SRC which are not in *DSTP to *DSTP. */
738 attrs_list_union (attrs *dstp, attrs src)
740 for (; src; src = src->next)
742 if (!attrs_list_member (*dstp, src->decl, src->offset))
743 attrs_list_insert (dstp, src->decl, src->offset, src->loc);
747 /* Delete all variables from hash table VARS. */
750 vars_clear (htab_t vars)
755 /* Return a copy of a variable VAR and insert it to dataflow set SET. */
758 unshare_variable (dataflow_set *set, variable var)
764 new_var = pool_alloc (var_pool);
765 new_var->decl = var->decl;
766 new_var->refcount = 1;
768 new_var->n_var_parts = var->n_var_parts;
770 for (i = 0; i < var->n_var_parts; i++)
773 location_chain *nextp;
775 new_var->var_part[i].offset = var->var_part[i].offset;
776 nextp = &new_var->var_part[i].loc_chain;
777 for (node = var->var_part[i].loc_chain; node; node = node->next)
779 location_chain new_lc;
781 new_lc = pool_alloc (loc_chain_pool);
783 new_lc->loc = node->loc;
786 nextp = &new_lc->next;
789 /* We are at the basic block boundary when copying variable description
790 so set the CUR_LOC to be the first element of the chain. */
791 if (new_var->var_part[i].loc_chain)
792 new_var->var_part[i].cur_loc = new_var->var_part[i].loc_chain->loc;
794 new_var->var_part[i].cur_loc = NULL;
797 slot = htab_find_slot_with_hash (set->vars, new_var->decl,
798 VARIABLE_HASH_VAL (new_var->decl),
804 /* Add a variable from *SLOT to hash table DATA and increase its reference
808 vars_copy_1 (void **slot, void *data)
810 htab_t dst = (htab_t) data;
813 src = *(variable *) slot;
816 dstp = (variable *) htab_find_slot_with_hash (dst, src->decl,
817 VARIABLE_HASH_VAL (src->decl),
821 /* Continue traversing the hash table. */
825 /* Copy all variables from hash table SRC to hash table DST. */
828 vars_copy (htab_t dst, htab_t src)
831 htab_traverse (src, vars_copy_1, dst);
834 /* Delete current content of register LOC in dataflow set SET
835 and set the register to contain REG_EXPR (LOC), REG_OFFSET (LOC). */
838 var_reg_delete_and_set (dataflow_set *set, rtx loc)
840 tree decl = REG_EXPR (loc);
841 HOST_WIDE_INT offset = REG_OFFSET (loc);
845 nextp = &set->regs[REGNO (loc)];
846 for (node = *nextp; node; node = next)
849 if (node->decl != decl || node->offset != offset)
851 delete_variable_part (set, node->loc, node->decl, node->offset);
852 pool_free (attrs_pool, node);
861 if (set->regs[REGNO (loc)] == NULL)
862 attrs_list_insert (&set->regs[REGNO (loc)], decl, offset, loc);
863 set_variable_part (set, loc, decl, offset);
866 /* Delete current content of register LOC in dataflow set SET. */
869 var_reg_delete (dataflow_set *set, rtx loc)
871 attrs *reg = &set->regs[REGNO (loc)];
874 for (node = *reg; node; node = next)
877 delete_variable_part (set, node->loc, node->decl, node->offset);
878 pool_free (attrs_pool, node);
883 /* Delete content of register with number REGNO in dataflow set SET. */
886 var_regno_delete (dataflow_set *set, int regno)
888 attrs *reg = &set->regs[regno];
891 for (node = *reg; node; node = next)
894 delete_variable_part (set, node->loc, node->decl, node->offset);
895 pool_free (attrs_pool, node);
900 /* Delete and set the location part of variable MEM_EXPR (LOC)
901 in dataflow set SET to LOC.
902 Adjust the address first if it is stack pointer based. */
905 var_mem_delete_and_set (dataflow_set *set, rtx loc)
907 tree decl = MEM_EXPR (loc);
908 HOST_WIDE_INT offset = MEM_OFFSET (loc) ? INTVAL (MEM_OFFSET (loc)) : 0;
910 set_variable_part (set, loc, decl, offset);
913 /* Delete the location part LOC from dataflow set SET.
914 Adjust the address first if it is stack pointer based. */
917 var_mem_delete (dataflow_set *set, rtx loc)
919 tree decl = MEM_EXPR (loc);
920 HOST_WIDE_INT offset = MEM_OFFSET (loc) ? INTVAL (MEM_OFFSET (loc)) : 0;
922 delete_variable_part (set, loc, decl, offset);
925 /* Initialize dataflow set SET to be empty.
926 VARS_SIZE is the initial size of hash table VARS. */
929 dataflow_set_init (dataflow_set *set, int vars_size)
931 init_attrs_list_set (set->regs);
932 set->vars = htab_create (vars_size, variable_htab_hash, variable_htab_eq,
934 set->stack_adjust = 0;
937 /* Delete the contents of dataflow set SET. */
940 dataflow_set_clear (dataflow_set *set)
944 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
945 attrs_list_clear (&set->regs[i]);
947 vars_clear (set->vars);
950 /* Copy the contents of dataflow set SRC to DST. */
953 dataflow_set_copy (dataflow_set *dst, dataflow_set *src)
957 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
958 attrs_list_copy (&dst->regs[i], src->regs[i]);
960 vars_copy (dst->vars, src->vars);
961 dst->stack_adjust = src->stack_adjust;
964 /* Information for merging lists of locations for a given offset of variable.
966 struct variable_union_info
968 /* Node of the location chain. */
971 /* The sum of positions in the input chains. */
974 /* The position in the chains of SRC and DST dataflow sets. */
979 /* Compare function for qsort, order the structures by POS element. */
982 variable_union_info_cmp_pos (const void *n1, const void *n2)
984 const struct variable_union_info *i1 = n1;
985 const struct variable_union_info *i2 = n2;
987 if (i1->pos != i2->pos)
988 return i1->pos - i2->pos;
990 return (i1->pos_dst - i2->pos_dst);
993 /* Compute union of location parts of variable *SLOT and the same variable
994 from hash table DATA. Compute "sorted" union of the location chains
995 for common offsets, i.e. the locations of a variable part are sorted by
996 a priority where the priority is the sum of the positions in the 2 chains
997 (if a location is only in one list the position in the second list is
998 defined to be larger than the length of the chains).
999 When we are updating the location parts the newest location is in the
1000 beginning of the chain, so when we do the described "sorted" union
1001 we keep the newest locations in the beginning. */
1004 variable_union (void **slot, void *data)
1006 variable src, dst, *dstp;
1007 dataflow_set *set = (dataflow_set *) data;
1010 src = *(variable *) slot;
1011 dstp = (variable *) htab_find_slot_with_hash (set->vars, src->decl,
1012 VARIABLE_HASH_VAL (src->decl),
1018 /* If CUR_LOC of some variable part is not the first element of
1019 the location chain we are going to change it so we have to make
1020 a copy of the variable. */
1021 for (k = 0; k < src->n_var_parts; k++)
1023 gcc_assert (!src->var_part[k].loc_chain
1024 == !src->var_part[k].cur_loc);
1025 if (src->var_part[k].loc_chain)
1027 gcc_assert (src->var_part[k].cur_loc);
1028 if (src->var_part[k].cur_loc != src->var_part[k].loc_chain->loc)
1032 if (k < src->n_var_parts)
1033 unshare_variable (set, src);
1037 /* Continue traversing the hash table. */
1043 gcc_assert (src->n_var_parts);
1045 /* Count the number of location parts, result is K. */
1046 for (i = 0, j = 0, k = 0;
1047 i < src->n_var_parts && j < dst->n_var_parts; k++)
1049 if (src->var_part[i].offset == dst->var_part[j].offset)
1054 else if (src->var_part[i].offset < dst->var_part[j].offset)
1059 k += src->n_var_parts - i;
1060 k += dst->n_var_parts - j;
1062 /* We track only variables whose size is <= MAX_VAR_PARTS bytes
1063 thus there are at most MAX_VAR_PARTS different offsets. */
1064 gcc_assert (k <= MAX_VAR_PARTS);
1066 if (dst->refcount > 1 && dst->n_var_parts != k)
1067 dst = unshare_variable (set, dst);
1069 i = src->n_var_parts - 1;
1070 j = dst->n_var_parts - 1;
1071 dst->n_var_parts = k;
1073 for (k--; k >= 0; k--)
1075 location_chain node, node2;
1077 if (i >= 0 && j >= 0
1078 && src->var_part[i].offset == dst->var_part[j].offset)
1080 /* Compute the "sorted" union of the chains, i.e. the locations which
1081 are in both chains go first, they are sorted by the sum of
1082 positions in the chains. */
1085 struct variable_union_info *vui;
1087 /* If DST is shared compare the location chains.
1088 If they are different we will modify the chain in DST with
1089 high probability so make a copy of DST. */
1090 if (dst->refcount > 1)
1092 for (node = src->var_part[i].loc_chain,
1093 node2 = dst->var_part[j].loc_chain; node && node2;
1094 node = node->next, node2 = node2->next)
1096 if (!((REG_P (node2->loc)
1097 && REG_P (node->loc)
1098 && REGNO (node2->loc) == REGNO (node->loc))
1099 || rtx_equal_p (node2->loc, node->loc)))
1103 dst = unshare_variable (set, dst);
1107 for (node = src->var_part[i].loc_chain; node; node = node->next)
1110 for (node = dst->var_part[j].loc_chain; node; node = node->next)
1112 vui = xcalloc (src_l + dst_l, sizeof (struct variable_union_info));
1114 /* Fill in the locations from DST. */
1115 for (node = dst->var_part[j].loc_chain, jj = 0; node;
1116 node = node->next, jj++)
1119 vui[jj].pos_dst = jj;
1121 /* Value larger than a sum of 2 valid positions. */
1122 vui[jj].pos_src = src_l + dst_l;
1125 /* Fill in the locations from SRC. */
1127 for (node = src->var_part[i].loc_chain, ii = 0; node;
1128 node = node->next, ii++)
1130 /* Find location from NODE. */
1131 for (jj = 0; jj < dst_l; jj++)
1133 if ((REG_P (vui[jj].lc->loc)
1134 && REG_P (node->loc)
1135 && REGNO (vui[jj].lc->loc) == REGNO (node->loc))
1136 || rtx_equal_p (vui[jj].lc->loc, node->loc))
1138 vui[jj].pos_src = ii;
1142 if (jj >= dst_l) /* The location has not been found. */
1144 location_chain new_node;
1146 /* Copy the location from SRC. */
1147 new_node = pool_alloc (loc_chain_pool);
1148 new_node->loc = node->loc;
1149 vui[n].lc = new_node;
1150 vui[n].pos_src = ii;
1151 vui[n].pos_dst = src_l + dst_l;
1156 for (ii = 0; ii < src_l + dst_l; ii++)
1157 vui[ii].pos = vui[ii].pos_src + vui[ii].pos_dst;
1159 qsort (vui, n, sizeof (struct variable_union_info),
1160 variable_union_info_cmp_pos);
1162 /* Reconnect the nodes in sorted order. */
1163 for (ii = 1; ii < n; ii++)
1164 vui[ii - 1].lc->next = vui[ii].lc;
1165 vui[n - 1].lc->next = NULL;
1167 dst->var_part[k].loc_chain = vui[0].lc;
1168 dst->var_part[k].offset = dst->var_part[j].offset;
1174 else if ((i >= 0 && j >= 0
1175 && src->var_part[i].offset < dst->var_part[j].offset)
1178 dst->var_part[k] = dst->var_part[j];
1181 else if ((i >= 0 && j >= 0
1182 && src->var_part[i].offset > dst->var_part[j].offset)
1185 location_chain *nextp;
1187 /* Copy the chain from SRC. */
1188 nextp = &dst->var_part[k].loc_chain;
1189 for (node = src->var_part[i].loc_chain; node; node = node->next)
1191 location_chain new_lc;
1193 new_lc = pool_alloc (loc_chain_pool);
1194 new_lc->next = NULL;
1195 new_lc->loc = node->loc;
1198 nextp = &new_lc->next;
1201 dst->var_part[k].offset = src->var_part[i].offset;
1205 /* We are at the basic block boundary when computing union
1206 so set the CUR_LOC to be the first element of the chain. */
1207 if (dst->var_part[k].loc_chain)
1208 dst->var_part[k].cur_loc = dst->var_part[k].loc_chain->loc;
1210 dst->var_part[k].cur_loc = NULL;
1213 /* Continue traversing the hash table. */
1217 /* Compute union of dataflow sets SRC and DST and store it to DST. */
1220 dataflow_set_union (dataflow_set *dst, dataflow_set *src)
1224 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
1225 attrs_list_union (&dst->regs[i], src->regs[i]);
1227 htab_traverse (src->vars, variable_union, dst);
1230 /* Flag whether two dataflow sets being compared contain different data. */
1232 dataflow_set_different_value;
1235 variable_part_different_p (variable_part *vp1, variable_part *vp2)
1237 location_chain lc1, lc2;
1239 for (lc1 = vp1->loc_chain; lc1; lc1 = lc1->next)
1241 for (lc2 = vp2->loc_chain; lc2; lc2 = lc2->next)
1243 if (REG_P (lc1->loc) && REG_P (lc2->loc))
1245 if (REGNO (lc1->loc) == REGNO (lc2->loc))
1248 if (rtx_equal_p (lc1->loc, lc2->loc))
1257 /* Return true if variables VAR1 and VAR2 are different.
1258 If COMPARE_CURRENT_LOCATION is true compare also the cur_loc of each
1262 variable_different_p (variable var1, variable var2,
1263 bool compare_current_location)
1270 if (var1->n_var_parts != var2->n_var_parts)
1273 for (i = 0; i < var1->n_var_parts; i++)
1275 if (var1->var_part[i].offset != var2->var_part[i].offset)
1277 if (compare_current_location)
1279 if (!((REG_P (var1->var_part[i].cur_loc)
1280 && REG_P (var2->var_part[i].cur_loc)
1281 && (REGNO (var1->var_part[i].cur_loc)
1282 == REGNO (var2->var_part[i].cur_loc)))
1283 || rtx_equal_p (var1->var_part[i].cur_loc,
1284 var2->var_part[i].cur_loc)))
1287 if (variable_part_different_p (&var1->var_part[i], &var2->var_part[i]))
1289 if (variable_part_different_p (&var2->var_part[i], &var1->var_part[i]))
1295 /* Compare variable *SLOT with the same variable in hash table DATA
1296 and set DATAFLOW_SET_DIFFERENT_VALUE if they are different. */
1299 dataflow_set_different_1 (void **slot, void *data)
1301 htab_t htab = (htab_t) data;
1302 variable var1, var2;
1304 var1 = *(variable *) slot;
1305 var2 = htab_find_with_hash (htab, var1->decl,
1306 VARIABLE_HASH_VAL (var1->decl));
1309 dataflow_set_different_value = true;
1311 /* Stop traversing the hash table. */
1315 if (variable_different_p (var1, var2, false))
1317 dataflow_set_different_value = true;
1319 /* Stop traversing the hash table. */
1323 /* Continue traversing the hash table. */
1327 /* Compare variable *SLOT with the same variable in hash table DATA
1328 and set DATAFLOW_SET_DIFFERENT_VALUE if they are different. */
1331 dataflow_set_different_2 (void **slot, void *data)
1333 htab_t htab = (htab_t) data;
1334 variable var1, var2;
1336 var1 = *(variable *) slot;
1337 var2 = htab_find_with_hash (htab, var1->decl,
1338 VARIABLE_HASH_VAL (var1->decl));
1341 dataflow_set_different_value = true;
1343 /* Stop traversing the hash table. */
1347 /* If both variables are defined they have been already checked for
1349 gcc_assert (!variable_different_p (var1, var2, false));
1351 /* Continue traversing the hash table. */
1355 /* Return true if dataflow sets OLD_SET and NEW_SET differ. */
1358 dataflow_set_different (dataflow_set *old_set, dataflow_set *new_set)
1360 dataflow_set_different_value = false;
1362 htab_traverse (old_set->vars, dataflow_set_different_1, new_set->vars);
1363 if (!dataflow_set_different_value)
1365 /* We have compared the variables which are in both hash tables
1366 so now only check whether there are some variables in NEW_SET->VARS
1367 which are not in OLD_SET->VARS. */
1368 htab_traverse (new_set->vars, dataflow_set_different_2, old_set->vars);
1370 return dataflow_set_different_value;
1373 /* Free the contents of dataflow set SET. */
1376 dataflow_set_destroy (dataflow_set *set)
1380 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
1381 attrs_list_clear (&set->regs[i]);
1383 htab_delete (set->vars);
1387 /* Return true if RTL X contains a SYMBOL_REF. */
1390 contains_symbol_ref (rtx x)
1399 code = GET_CODE (x);
1400 if (code == SYMBOL_REF)
1403 fmt = GET_RTX_FORMAT (code);
1404 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
1408 if (contains_symbol_ref (XEXP (x, i)))
1411 else if (fmt[i] == 'E')
1414 for (j = 0; j < XVECLEN (x, i); j++)
1415 if (contains_symbol_ref (XVECEXP (x, i, j)))
1423 /* Shall EXPR be tracked? */
1426 track_expr_p (tree expr)
1431 /* If EXPR is not a parameter or a variable do not track it. */
1432 if (TREE_CODE (expr) != VAR_DECL && TREE_CODE (expr) != PARM_DECL)
1435 /* It also must have a name... */
1436 if (!DECL_NAME (expr))
1439 /* ... and a RTL assigned to it. */
1440 decl_rtl = DECL_RTL_IF_SET (expr);
1444 /* If this expression is really a debug alias of some other declaration, we
1445 don't need to track this expression if the ultimate declaration is
1448 if (DECL_DEBUG_EXPR_IS_FROM (realdecl) && DECL_DEBUG_EXPR (realdecl))
1450 realdecl = DECL_DEBUG_EXPR (realdecl);
1451 /* ??? We don't yet know how to emit DW_OP_piece for variable
1452 that has been SRA'ed. */
1453 if (!DECL_P (realdecl))
1457 /* Do not track EXPR if REALDECL it should be ignored for debugging
1459 if (DECL_IGNORED_P (realdecl))
1462 /* Do not track global variables until we are able to emit correct location
1464 if (TREE_STATIC (realdecl))
1467 /* When the EXPR is a DECL for alias of some variable (see example)
1468 the TREE_STATIC flag is not used. Disable tracking all DECLs whose
1469 DECL_RTL contains SYMBOL_REF.
1472 extern char **_dl_argv_internal __attribute__ ((alias ("_dl_argv")));
1475 if (MEM_P (decl_rtl)
1476 && contains_symbol_ref (XEXP (decl_rtl, 0)))
1479 /* If RTX is a memory it should not be very large (because it would be
1480 an array or struct). */
1481 if (MEM_P (decl_rtl))
1483 /* Do not track structures and arrays. */
1484 if (GET_MODE (decl_rtl) == BLKmode)
1486 if (MEM_SIZE (decl_rtl)
1487 && INTVAL (MEM_SIZE (decl_rtl)) > MAX_VAR_PARTS)
1494 /* Count uses (register and memory references) LOC which will be tracked.
1495 INSN is instruction which the LOC is part of. */
1498 count_uses (rtx *loc, void *insn)
1500 basic_block bb = BLOCK_FOR_INSN ((rtx) insn);
1504 gcc_assert (REGNO (*loc) < FIRST_PSEUDO_REGISTER);
1507 else if (MEM_P (*loc)
1509 && track_expr_p (MEM_EXPR (*loc)))
1517 /* Helper function for finding all uses of REG/MEM in X in insn INSN. */
1520 count_uses_1 (rtx *x, void *insn)
1522 for_each_rtx (x, count_uses, insn);
1525 /* Count stores (register and memory references) LOC which will be tracked.
1526 INSN is instruction which the LOC is part of. */
1529 count_stores (rtx loc, rtx expr ATTRIBUTE_UNUSED, void *insn)
1531 count_uses (&loc, insn);
1534 /* Add uses (register and memory references) LOC which will be tracked
1535 to VTI (bb)->mos. INSN is instruction which the LOC is part of. */
1538 add_uses (rtx *loc, void *insn)
1542 basic_block bb = BLOCK_FOR_INSN ((rtx) insn);
1543 micro_operation *mo = VTI (bb)->mos + VTI (bb)->n_mos++;
1545 mo->type = ((REG_EXPR (*loc) && track_expr_p (REG_EXPR (*loc)))
1546 ? MO_USE : MO_USE_NO_VAR);
1548 mo->insn = (rtx) insn;
1550 else if (MEM_P (*loc)
1552 && track_expr_p (MEM_EXPR (*loc)))
1554 basic_block bb = BLOCK_FOR_INSN ((rtx) insn);
1555 micro_operation *mo = VTI (bb)->mos + VTI (bb)->n_mos++;
1559 mo->insn = (rtx) insn;
1565 /* Helper function for finding all uses of REG/MEM in X in insn INSN. */
1568 add_uses_1 (rtx *x, void *insn)
1570 for_each_rtx (x, add_uses, insn);
1573 /* Add stores (register and memory references) LOC which will be tracked
1574 to VTI (bb)->mos. EXPR is the RTL expression containing the store.
1575 INSN is instruction which the LOC is part of. */
1578 add_stores (rtx loc, rtx expr, void *insn)
1582 basic_block bb = BLOCK_FOR_INSN ((rtx) insn);
1583 micro_operation *mo = VTI (bb)->mos + VTI (bb)->n_mos++;
1585 mo->type = ((GET_CODE (expr) != CLOBBER && REG_EXPR (loc)
1586 && track_expr_p (REG_EXPR (loc)))
1587 ? MO_SET : MO_CLOBBER);
1589 mo->insn = (rtx) insn;
1591 else if (MEM_P (loc)
1593 && track_expr_p (MEM_EXPR (loc)))
1595 basic_block bb = BLOCK_FOR_INSN ((rtx) insn);
1596 micro_operation *mo = VTI (bb)->mos + VTI (bb)->n_mos++;
1598 mo->type = GET_CODE (expr) == CLOBBER ? MO_CLOBBER : MO_SET;
1600 mo->insn = (rtx) insn;
1604 /* Compute the changes of variable locations in the basic block BB. */
1607 compute_bb_dataflow (basic_block bb)
1611 dataflow_set old_out;
1612 dataflow_set *in = &VTI (bb)->in;
1613 dataflow_set *out = &VTI (bb)->out;
1615 dataflow_set_init (&old_out, htab_elements (VTI (bb)->out.vars) + 3);
1616 dataflow_set_copy (&old_out, out);
1617 dataflow_set_copy (out, in);
1619 n = VTI (bb)->n_mos;
1620 for (i = 0; i < n; i++)
1622 switch (VTI (bb)->mos[i].type)
1625 for (r = 0; r < FIRST_PSEUDO_REGISTER; r++)
1626 if (TEST_HARD_REG_BIT (call_used_reg_set, r))
1627 var_regno_delete (out, r);
1633 rtx loc = VTI (bb)->mos[i].u.loc;
1636 var_reg_delete_and_set (out, loc);
1637 else if (MEM_P (loc))
1638 var_mem_delete_and_set (out, loc);
1645 rtx loc = VTI (bb)->mos[i].u.loc;
1648 var_reg_delete (out, loc);
1649 else if (MEM_P (loc))
1650 var_mem_delete (out, loc);
1658 out->stack_adjust += VTI (bb)->mos[i].u.adjust;
1659 base = gen_rtx_MEM (Pmode, plus_constant (stack_pointer_rtx,
1660 out->stack_adjust));
1661 set_frame_base_location (out, base);
1667 changed = dataflow_set_different (&old_out, out);
1668 dataflow_set_destroy (&old_out);
1672 /* Find the locations of variables in the whole function. */
1675 vt_find_locations (void)
1677 fibheap_t worklist, pending, fibheap_swap;
1678 sbitmap visited, in_worklist, in_pending, sbitmap_swap;
1685 /* Compute reverse completion order of depth first search of the CFG
1686 so that the data-flow runs faster. */
1687 rc_order = xmalloc (n_basic_blocks * sizeof (int));
1688 bb_order = xmalloc (last_basic_block * sizeof (int));
1689 flow_depth_first_order_compute (NULL, rc_order);
1690 for (i = 0; i < n_basic_blocks; i++)
1691 bb_order[rc_order[i]] = i;
1694 worklist = fibheap_new ();
1695 pending = fibheap_new ();
1696 visited = sbitmap_alloc (last_basic_block);
1697 in_worklist = sbitmap_alloc (last_basic_block);
1698 in_pending = sbitmap_alloc (last_basic_block);
1699 sbitmap_zero (in_worklist);
1702 fibheap_insert (pending, bb_order[bb->index], bb);
1703 sbitmap_ones (in_pending);
1705 while (!fibheap_empty (pending))
1707 fibheap_swap = pending;
1709 worklist = fibheap_swap;
1710 sbitmap_swap = in_pending;
1711 in_pending = in_worklist;
1712 in_worklist = sbitmap_swap;
1714 sbitmap_zero (visited);
1716 while (!fibheap_empty (worklist))
1718 bb = fibheap_extract_min (worklist);
1719 RESET_BIT (in_worklist, bb->index);
1720 if (!TEST_BIT (visited, bb->index))
1725 SET_BIT (visited, bb->index);
1727 /* Calculate the IN set as union of predecessor OUT sets. */
1728 dataflow_set_clear (&VTI (bb)->in);
1729 FOR_EACH_EDGE (e, ei, bb->preds)
1731 dataflow_set_union (&VTI (bb)->in, &VTI (e->src)->out);
1734 changed = compute_bb_dataflow (bb);
1737 FOR_EACH_EDGE (e, ei, bb->succs)
1739 if (e->dest == EXIT_BLOCK_PTR)
1745 if (TEST_BIT (visited, e->dest->index))
1747 if (!TEST_BIT (in_pending, e->dest->index))
1749 /* Send E->DEST to next round. */
1750 SET_BIT (in_pending, e->dest->index);
1751 fibheap_insert (pending,
1752 bb_order[e->dest->index],
1756 else if (!TEST_BIT (in_worklist, e->dest->index))
1758 /* Add E->DEST to current round. */
1759 SET_BIT (in_worklist, e->dest->index);
1760 fibheap_insert (worklist, bb_order[e->dest->index],
1770 fibheap_delete (worklist);
1771 fibheap_delete (pending);
1772 sbitmap_free (visited);
1773 sbitmap_free (in_worklist);
1774 sbitmap_free (in_pending);
1777 /* Print the content of the LIST to dump file. */
1780 dump_attrs_list (attrs list)
1782 for (; list; list = list->next)
1784 print_mem_expr (dump_file, list->decl);
1785 fprintf (dump_file, "+");
1786 fprintf (dump_file, HOST_WIDE_INT_PRINT_DEC, list->offset);
1788 fprintf (dump_file, "\n");
1791 /* Print the information about variable *SLOT to dump file. */
1794 dump_variable (void **slot, void *data ATTRIBUTE_UNUSED)
1796 variable var = *(variable *) slot;
1798 location_chain node;
1800 fprintf (dump_file, " name: %s\n",
1801 IDENTIFIER_POINTER (DECL_NAME (var->decl)));
1802 for (i = 0; i < var->n_var_parts; i++)
1804 fprintf (dump_file, " offset %ld\n",
1805 (long) var->var_part[i].offset);
1806 for (node = var->var_part[i].loc_chain; node; node = node->next)
1808 fprintf (dump_file, " ");
1809 print_rtl_single (dump_file, node->loc);
1813 /* Continue traversing the hash table. */
1817 /* Print the information about variables from hash table VARS to dump file. */
1820 dump_vars (htab_t vars)
1822 if (htab_elements (vars) > 0)
1824 fprintf (dump_file, "Variables:\n");
1825 htab_traverse (vars, dump_variable, NULL);
1829 /* Print the dataflow set SET to dump file. */
1832 dump_dataflow_set (dataflow_set *set)
1836 fprintf (dump_file, "Stack adjustment: ");
1837 fprintf (dump_file, HOST_WIDE_INT_PRINT_DEC, set->stack_adjust);
1838 fprintf (dump_file, "\n");
1839 for (i = 1; i < FIRST_PSEUDO_REGISTER; i++)
1843 fprintf (dump_file, "Reg %d:", i);
1844 dump_attrs_list (set->regs[i]);
1847 dump_vars (set->vars);
1848 fprintf (dump_file, "\n");
1851 /* Print the IN and OUT sets for each basic block to dump file. */
1854 dump_dataflow_sets (void)
1860 fprintf (dump_file, "\nBasic block %d:\n", bb->index);
1861 fprintf (dump_file, "IN:\n");
1862 dump_dataflow_set (&VTI (bb)->in);
1863 fprintf (dump_file, "OUT:\n");
1864 dump_dataflow_set (&VTI (bb)->out);
1868 /* Add variable VAR to the hash table of changed variables and
1869 if it has no locations delete it from hash table HTAB. */
1872 variable_was_changed (variable var, htab_t htab)
1874 hashval_t hash = VARIABLE_HASH_VAL (var->decl);
1880 slot = (variable *) htab_find_slot_with_hash (changed_variables,
1881 var->decl, hash, INSERT);
1883 if (htab && var->n_var_parts == 0)
1888 empty_var = pool_alloc (var_pool);
1889 empty_var->decl = var->decl;
1890 empty_var->refcount = 1;
1891 empty_var->n_var_parts = 0;
1894 old = htab_find_slot_with_hash (htab, var->decl, hash,
1897 htab_clear_slot (htab, old);
1907 if (var->n_var_parts == 0)
1909 void **slot = htab_find_slot_with_hash (htab, var->decl, hash,
1912 htab_clear_slot (htab, slot);
1917 /* Set the location of frame_base_decl to LOC in dataflow set SET. This
1918 function expects that frame_base_decl has already one location for offset 0
1919 in the variable table. */
1922 set_frame_base_location (dataflow_set *set, rtx loc)
1926 var = htab_find_with_hash (set->vars, frame_base_decl,
1927 VARIABLE_HASH_VAL (frame_base_decl));
1929 gcc_assert (var->n_var_parts == 1);
1930 gcc_assert (!var->var_part[0].offset);
1931 gcc_assert (var->var_part[0].loc_chain);
1933 /* If frame_base_decl is shared unshare it first. */
1934 if (var->refcount > 1)
1935 var = unshare_variable (set, var);
1937 var->var_part[0].loc_chain->loc = loc;
1938 var->var_part[0].cur_loc = loc;
1939 variable_was_changed (var, set->vars);
1942 /* Set the part of variable's location in the dataflow set SET. The variable
1943 part is specified by variable's declaration DECL and offset OFFSET and the
1944 part's location by LOC. */
1947 set_variable_part (dataflow_set *set, rtx loc, tree decl, HOST_WIDE_INT offset)
1950 location_chain node, next;
1951 location_chain *nextp;
1955 slot = htab_find_slot_with_hash (set->vars, decl,
1956 VARIABLE_HASH_VAL (decl), INSERT);
1959 /* Create new variable information. */
1960 var = pool_alloc (var_pool);
1963 var->n_var_parts = 1;
1964 var->var_part[0].offset = offset;
1965 var->var_part[0].loc_chain = NULL;
1966 var->var_part[0].cur_loc = NULL;
1972 var = (variable) *slot;
1974 /* Find the location part. */
1976 high = var->n_var_parts;
1979 pos = (low + high) / 2;
1980 if (var->var_part[pos].offset < offset)
1987 if (pos < var->n_var_parts && var->var_part[pos].offset == offset)
1989 node = var->var_part[pos].loc_chain;
1992 && ((REG_P (node->loc) && REG_P (loc)
1993 && REGNO (node->loc) == REGNO (loc))
1994 || rtx_equal_p (node->loc, loc)))
1996 /* LOC is in the beginning of the chain so we have nothing
2002 /* We have to make a copy of a shared variable. */
2003 if (var->refcount > 1)
2004 var = unshare_variable (set, var);
2009 /* We have not found the location part, new one will be created. */
2011 /* We have to make a copy of the shared variable. */
2012 if (var->refcount > 1)
2013 var = unshare_variable (set, var);
2015 /* We track only variables whose size is <= MAX_VAR_PARTS bytes
2016 thus there are at most MAX_VAR_PARTS different offsets. */
2017 gcc_assert (var->n_var_parts < MAX_VAR_PARTS);
2019 /* We have to move the elements of array starting at index low to the
2021 for (high = var->n_var_parts; high > low; high--)
2022 var->var_part[high] = var->var_part[high - 1];
2025 var->var_part[pos].offset = offset;
2026 var->var_part[pos].loc_chain = NULL;
2027 var->var_part[pos].cur_loc = NULL;
2031 /* Delete the location from the list. */
2032 nextp = &var->var_part[pos].loc_chain;
2033 for (node = var->var_part[pos].loc_chain; node; node = next)
2036 if ((REG_P (node->loc) && REG_P (loc)
2037 && REGNO (node->loc) == REGNO (loc))
2038 || rtx_equal_p (node->loc, loc))
2040 pool_free (loc_chain_pool, node);
2045 nextp = &node->next;
2048 /* Add the location to the beginning. */
2049 node = pool_alloc (loc_chain_pool);
2051 node->next = var->var_part[pos].loc_chain;
2052 var->var_part[pos].loc_chain = node;
2054 /* If no location was emitted do so. */
2055 if (var->var_part[pos].cur_loc == NULL)
2057 var->var_part[pos].cur_loc = loc;
2058 variable_was_changed (var, set->vars);
2062 /* Delete the part of variable's location from dataflow set SET. The variable
2063 part is specified by variable's declaration DECL and offset OFFSET and the
2064 part's location by LOC. */
2067 delete_variable_part (dataflow_set *set, rtx loc, tree decl,
2068 HOST_WIDE_INT offset)
2073 slot = htab_find_slot_with_hash (set->vars, decl, VARIABLE_HASH_VAL (decl),
2077 variable var = (variable) *slot;
2079 /* Find the location part. */
2081 high = var->n_var_parts;
2084 pos = (low + high) / 2;
2085 if (var->var_part[pos].offset < offset)
2092 if (pos < var->n_var_parts && var->var_part[pos].offset == offset)
2094 location_chain node, next;
2095 location_chain *nextp;
2098 if (var->refcount > 1)
2100 /* If the variable contains the location part we have to
2101 make a copy of the variable. */
2102 for (node = var->var_part[pos].loc_chain; node;
2105 if ((REG_P (node->loc) && REG_P (loc)
2106 && REGNO (node->loc) == REGNO (loc))
2107 || rtx_equal_p (node->loc, loc))
2109 var = unshare_variable (set, var);
2115 /* Delete the location part. */
2116 nextp = &var->var_part[pos].loc_chain;
2117 for (node = *nextp; node; node = next)
2120 if ((REG_P (node->loc) && REG_P (loc)
2121 && REGNO (node->loc) == REGNO (loc))
2122 || rtx_equal_p (node->loc, loc))
2124 pool_free (loc_chain_pool, node);
2129 nextp = &node->next;
2132 /* If we have deleted the location which was last emitted
2133 we have to emit new location so add the variable to set
2134 of changed variables. */
2135 if (var->var_part[pos].cur_loc
2137 && REG_P (var->var_part[pos].cur_loc)
2138 && REGNO (loc) == REGNO (var->var_part[pos].cur_loc))
2139 || rtx_equal_p (loc, var->var_part[pos].cur_loc)))
2142 if (var->var_part[pos].loc_chain)
2143 var->var_part[pos].cur_loc = var->var_part[pos].loc_chain->loc;
2148 if (var->var_part[pos].loc_chain == NULL)
2151 while (pos < var->n_var_parts)
2153 var->var_part[pos] = var->var_part[pos + 1];
2158 variable_was_changed (var, set->vars);
2163 /* Emit the NOTE_INSN_VAR_LOCATION for variable *VARP. DATA contains
2164 additional parameters: WHERE specifies whether the note shall be emitted
2165 before of after instruction INSN. */
2168 emit_note_insn_var_location (void **varp, void *data)
2170 variable var = *(variable *) varp;
2171 rtx insn = ((emit_note_data *)data)->insn;
2172 enum emit_note_where where = ((emit_note_data *)data)->where;
2174 int i, j, n_var_parts;
2176 HOST_WIDE_INT last_limit;
2177 tree type_size_unit;
2178 HOST_WIDE_INT offsets[MAX_VAR_PARTS];
2179 rtx loc[MAX_VAR_PARTS];
2181 gcc_assert (var->decl);
2186 for (i = 0; i < var->n_var_parts; i++)
2188 enum machine_mode mode, wider_mode;
2190 if (last_limit < var->var_part[i].offset)
2195 else if (last_limit > var->var_part[i].offset)
2197 offsets[n_var_parts] = var->var_part[i].offset;
2198 loc[n_var_parts] = var->var_part[i].loc_chain->loc;
2199 mode = GET_MODE (loc[n_var_parts]);
2200 last_limit = offsets[n_var_parts] + GET_MODE_SIZE (mode);
2202 /* Attempt to merge adjacent registers or memory. */
2203 wider_mode = GET_MODE_WIDER_MODE (mode);
2204 for (j = i + 1; j < var->n_var_parts; j++)
2205 if (last_limit <= var->var_part[j].offset)
2207 if (j < var->n_var_parts
2208 && wider_mode != VOIDmode
2209 && GET_CODE (loc[n_var_parts])
2210 == GET_CODE (var->var_part[j].loc_chain->loc)
2211 && mode == GET_MODE (var->var_part[j].loc_chain->loc)
2212 && last_limit == var->var_part[j].offset)
2215 rtx loc2 = var->var_part[j].loc_chain->loc;
2217 if (REG_P (loc[n_var_parts])
2218 && hard_regno_nregs[REGNO (loc[n_var_parts])][mode] * 2
2219 == hard_regno_nregs[REGNO (loc[n_var_parts])][wider_mode]
2220 && REGNO (loc[n_var_parts])
2221 + hard_regno_nregs[REGNO (loc[n_var_parts])][mode]
2224 if (! WORDS_BIG_ENDIAN && ! BYTES_BIG_ENDIAN)
2225 new_loc = simplify_subreg (wider_mode, loc[n_var_parts],
2227 else if (WORDS_BIG_ENDIAN && BYTES_BIG_ENDIAN)
2228 new_loc = simplify_subreg (wider_mode, loc2, mode, 0);
2231 if (!REG_P (new_loc)
2232 || REGNO (new_loc) != REGNO (loc[n_var_parts]))
2235 REG_ATTRS (new_loc) = REG_ATTRS (loc[n_var_parts]);
2238 else if (MEM_P (loc[n_var_parts])
2239 && GET_CODE (XEXP (loc2, 0)) == PLUS
2240 && GET_CODE (XEXP (XEXP (loc2, 0), 0)) == REG
2241 && GET_CODE (XEXP (XEXP (loc2, 0), 1)) == CONST_INT)
2243 if ((GET_CODE (XEXP (loc[n_var_parts], 0)) == REG
2244 && rtx_equal_p (XEXP (loc[n_var_parts], 0),
2245 XEXP (XEXP (loc2, 0), 0))
2246 && INTVAL (XEXP (XEXP (loc2, 0), 1))
2247 == GET_MODE_SIZE (mode))
2248 || (GET_CODE (XEXP (loc[n_var_parts], 0)) == PLUS
2249 && GET_CODE (XEXP (XEXP (loc[n_var_parts], 0), 1))
2251 && rtx_equal_p (XEXP (XEXP (loc[n_var_parts], 0), 0),
2252 XEXP (XEXP (loc2, 0), 0))
2253 && INTVAL (XEXP (XEXP (loc[n_var_parts], 0), 1))
2254 + GET_MODE_SIZE (mode)
2255 == INTVAL (XEXP (XEXP (loc2, 0), 1))))
2256 new_loc = adjust_address_nv (loc[n_var_parts],
2262 loc[n_var_parts] = new_loc;
2264 last_limit = offsets[n_var_parts] + GET_MODE_SIZE (mode);
2270 type_size_unit = TYPE_SIZE_UNIT (TREE_TYPE (var->decl));
2271 if ((unsigned HOST_WIDE_INT) last_limit < TREE_INT_CST_LOW (type_size_unit))
2274 if (where == EMIT_NOTE_AFTER_INSN)
2275 note = emit_note_after (NOTE_INSN_VAR_LOCATION, insn);
2277 note = emit_note_before (NOTE_INSN_VAR_LOCATION, insn);
2281 NOTE_VAR_LOCATION (note) = gen_rtx_VAR_LOCATION (VOIDmode, var->decl,
2284 else if (n_var_parts == 1)
2287 = gen_rtx_EXPR_LIST (VOIDmode, loc[0], GEN_INT (offsets[0]));
2289 NOTE_VAR_LOCATION (note) = gen_rtx_VAR_LOCATION (VOIDmode, var->decl,
2292 else if (n_var_parts)
2296 for (i = 0; i < n_var_parts; i++)
2298 = gen_rtx_EXPR_LIST (VOIDmode, loc[i], GEN_INT (offsets[i]));
2300 parallel = gen_rtx_PARALLEL (VOIDmode,
2301 gen_rtvec_v (n_var_parts, loc));
2302 NOTE_VAR_LOCATION (note) = gen_rtx_VAR_LOCATION (VOIDmode, var->decl,
2306 htab_clear_slot (changed_variables, varp);
2308 /* When there are no location parts the variable has been already
2309 removed from hash table and a new empty variable was created.
2310 Free the empty variable. */
2311 if (var->n_var_parts == 0)
2313 pool_free (var_pool, var);
2316 /* Continue traversing the hash table. */
2320 /* Emit NOTE_INSN_VAR_LOCATION note for each variable from a chain
2321 CHANGED_VARIABLES and delete this chain. WHERE specifies whether the notes
2322 shall be emitted before of after instruction INSN. */
2325 emit_notes_for_changes (rtx insn, enum emit_note_where where)
2327 emit_note_data data;
2331 htab_traverse (changed_variables, emit_note_insn_var_location, &data);
2334 /* Add variable *SLOT to the chain CHANGED_VARIABLES if it differs from the
2335 same variable in hash table DATA or is not there at all. */
2338 emit_notes_for_differences_1 (void **slot, void *data)
2340 htab_t new_vars = (htab_t) data;
2341 variable old_var, new_var;
2343 old_var = *(variable *) slot;
2344 new_var = htab_find_with_hash (new_vars, old_var->decl,
2345 VARIABLE_HASH_VAL (old_var->decl));
2349 /* Variable has disappeared. */
2352 empty_var = pool_alloc (var_pool);
2353 empty_var->decl = old_var->decl;
2354 empty_var->refcount = 1;
2355 empty_var->n_var_parts = 0;
2356 variable_was_changed (empty_var, NULL);
2358 else if (variable_different_p (old_var, new_var, true))
2360 variable_was_changed (new_var, NULL);
2363 /* Continue traversing the hash table. */
2367 /* Add variable *SLOT to the chain CHANGED_VARIABLES if it is not in hash
2371 emit_notes_for_differences_2 (void **slot, void *data)
2373 htab_t old_vars = (htab_t) data;
2374 variable old_var, new_var;
2376 new_var = *(variable *) slot;
2377 old_var = htab_find_with_hash (old_vars, new_var->decl,
2378 VARIABLE_HASH_VAL (new_var->decl));
2381 /* Variable has appeared. */
2382 variable_was_changed (new_var, NULL);
2385 /* Continue traversing the hash table. */
2389 /* Emit notes before INSN for differences between dataflow sets OLD_SET and
2393 emit_notes_for_differences (rtx insn, dataflow_set *old_set,
2394 dataflow_set *new_set)
2396 htab_traverse (old_set->vars, emit_notes_for_differences_1, new_set->vars);
2397 htab_traverse (new_set->vars, emit_notes_for_differences_2, old_set->vars);
2398 emit_notes_for_changes (insn, EMIT_NOTE_BEFORE_INSN);
2401 /* Emit the notes for changes of location parts in the basic block BB. */
2404 emit_notes_in_bb (basic_block bb)
2409 dataflow_set_init (&set, htab_elements (VTI (bb)->in.vars) + 3);
2410 dataflow_set_copy (&set, &VTI (bb)->in);
2412 for (i = 0; i < VTI (bb)->n_mos; i++)
2414 rtx insn = VTI (bb)->mos[i].insn;
2416 switch (VTI (bb)->mos[i].type)
2422 for (r = 0; r < FIRST_PSEUDO_REGISTER; r++)
2423 if (TEST_HARD_REG_BIT (call_used_reg_set, r))
2425 var_regno_delete (&set, r);
2427 emit_notes_for_changes (insn, EMIT_NOTE_AFTER_INSN);
2434 rtx loc = VTI (bb)->mos[i].u.loc;
2437 var_reg_delete_and_set (&set, loc);
2439 var_mem_delete_and_set (&set, loc);
2441 if (VTI (bb)->mos[i].type == MO_USE)
2442 emit_notes_for_changes (insn, EMIT_NOTE_BEFORE_INSN);
2444 emit_notes_for_changes (insn, EMIT_NOTE_AFTER_INSN);
2451 rtx loc = VTI (bb)->mos[i].u.loc;
2454 var_reg_delete (&set, loc);
2456 var_mem_delete (&set, loc);
2458 if (VTI (bb)->mos[i].type == MO_USE_NO_VAR)
2459 emit_notes_for_changes (insn, EMIT_NOTE_BEFORE_INSN);
2461 emit_notes_for_changes (insn, EMIT_NOTE_AFTER_INSN);
2469 set.stack_adjust += VTI (bb)->mos[i].u.adjust;
2470 base = gen_rtx_MEM (Pmode, plus_constant (stack_pointer_rtx,
2472 set_frame_base_location (&set, base);
2473 emit_notes_for_changes (insn, EMIT_NOTE_AFTER_INSN);
2478 dataflow_set_destroy (&set);
2481 /* Emit notes for the whole function. */
2484 vt_emit_notes (void)
2487 dataflow_set *last_out;
2490 gcc_assert (!htab_elements (changed_variables));
2492 /* Enable emitting notes by functions (mainly by set_variable_part and
2493 delete_variable_part). */
2496 dataflow_set_init (&empty, 7);
2501 /* Emit the notes for changes of variable locations between two
2502 subsequent basic blocks. */
2503 emit_notes_for_differences (BB_HEAD (bb), last_out, &VTI (bb)->in);
2505 /* Emit the notes for the changes in the basic block itself. */
2506 emit_notes_in_bb (bb);
2508 last_out = &VTI (bb)->out;
2510 dataflow_set_destroy (&empty);
2514 /* If there is a declaration and offset associated with register/memory RTL
2515 assign declaration to *DECLP and offset to *OFFSETP, and return true. */
2518 vt_get_decl_and_offset (rtx rtl, tree *declp, HOST_WIDE_INT *offsetp)
2522 if (REG_ATTRS (rtl))
2524 *declp = REG_EXPR (rtl);
2525 *offsetp = REG_OFFSET (rtl);
2529 else if (MEM_P (rtl))
2531 if (MEM_ATTRS (rtl))
2533 *declp = MEM_EXPR (rtl);
2534 *offsetp = MEM_OFFSET (rtl) ? INTVAL (MEM_OFFSET (rtl)) : 0;
2541 /* Insert function parameters to IN and OUT sets of ENTRY_BLOCK. */
2544 vt_add_function_parameters (void)
2548 for (parm = DECL_ARGUMENTS (current_function_decl);
2549 parm; parm = TREE_CHAIN (parm))
2551 rtx decl_rtl = DECL_RTL_IF_SET (parm);
2552 rtx incoming = DECL_INCOMING_RTL (parm);
2554 HOST_WIDE_INT offset;
2557 if (TREE_CODE (parm) != PARM_DECL)
2560 if (!DECL_NAME (parm))
2563 if (!decl_rtl || !incoming)
2566 if (GET_MODE (decl_rtl) == BLKmode || GET_MODE (incoming) == BLKmode)
2569 if (!vt_get_decl_and_offset (incoming, &decl, &offset))
2570 if (!vt_get_decl_and_offset (decl_rtl, &decl, &offset))
2576 gcc_assert (parm == decl);
2578 incoming = eliminate_regs (incoming, 0, NULL_RTX);
2579 out = &VTI (ENTRY_BLOCK_PTR)->out;
2581 if (REG_P (incoming))
2583 gcc_assert (REGNO (incoming) < FIRST_PSEUDO_REGISTER);
2584 attrs_list_insert (&out->regs[REGNO (incoming)],
2585 parm, offset, incoming);
2586 set_variable_part (out, incoming, parm, offset);
2588 else if (MEM_P (incoming))
2590 set_variable_part (out, incoming, parm, offset);
2595 /* Allocate and initialize the data structures for variable tracking
2596 and parse the RTL to get the micro operations. */
2599 vt_initialize (void)
2603 alloc_aux_for_blocks (sizeof (struct variable_tracking_info_def));
2608 HOST_WIDE_INT pre, post;
2610 /* Count the number of micro operations. */
2611 VTI (bb)->n_mos = 0;
2612 for (insn = BB_HEAD (bb); insn != NEXT_INSN (BB_END (bb));
2613 insn = NEXT_INSN (insn))
2617 if (!frame_pointer_needed)
2619 insn_stack_adjust_offset_pre_post (insn, &pre, &post);
2625 note_uses (&PATTERN (insn), count_uses_1, insn);
2626 note_stores (PATTERN (insn), count_stores, insn);
2632 /* Add the micro-operations to the array. */
2633 VTI (bb)->mos = xmalloc (VTI (bb)->n_mos
2634 * sizeof (struct micro_operation_def));
2635 VTI (bb)->n_mos = 0;
2636 for (insn = BB_HEAD (bb); insn != NEXT_INSN (BB_END (bb));
2637 insn = NEXT_INSN (insn))
2643 if (!frame_pointer_needed)
2645 insn_stack_adjust_offset_pre_post (insn, &pre, &post);
2648 micro_operation *mo = VTI (bb)->mos + VTI (bb)->n_mos++;
2650 mo->type = MO_ADJUST;
2656 n1 = VTI (bb)->n_mos;
2657 note_uses (&PATTERN (insn), add_uses_1, insn);
2658 n2 = VTI (bb)->n_mos - 1;
2660 /* Order the MO_USEs to be before MO_USE_NO_VARs. */
2663 while (n1 < n2 && VTI (bb)->mos[n1].type == MO_USE)
2665 while (n1 < n2 && VTI (bb)->mos[n2].type == MO_USE_NO_VAR)
2671 sw = VTI (bb)->mos[n1];
2672 VTI (bb)->mos[n1] = VTI (bb)->mos[n2];
2673 VTI (bb)->mos[n2] = sw;
2679 micro_operation *mo = VTI (bb)->mos + VTI (bb)->n_mos++;
2685 n1 = VTI (bb)->n_mos;
2686 note_stores (PATTERN (insn), add_stores, insn);
2687 n2 = VTI (bb)->n_mos - 1;
2689 /* Order the MO_SETs to be before MO_CLOBBERs. */
2692 while (n1 < n2 && VTI (bb)->mos[n1].type == MO_SET)
2694 while (n1 < n2 && VTI (bb)->mos[n2].type == MO_CLOBBER)
2700 sw = VTI (bb)->mos[n1];
2701 VTI (bb)->mos[n1] = VTI (bb)->mos[n2];
2702 VTI (bb)->mos[n2] = sw;
2706 if (!frame_pointer_needed && post)
2708 micro_operation *mo = VTI (bb)->mos + VTI (bb)->n_mos++;
2710 mo->type = MO_ADJUST;
2711 mo->u.adjust = post;
2718 /* Init the IN and OUT sets. */
2721 VTI (bb)->visited = false;
2722 dataflow_set_init (&VTI (bb)->in, 7);
2723 dataflow_set_init (&VTI (bb)->out, 7);
2726 attrs_pool = create_alloc_pool ("attrs_def pool",
2727 sizeof (struct attrs_def), 1024);
2728 var_pool = create_alloc_pool ("variable_def pool",
2729 sizeof (struct variable_def), 64);
2730 loc_chain_pool = create_alloc_pool ("location_chain_def pool",
2731 sizeof (struct location_chain_def),
2733 changed_variables = htab_create (10, variable_htab_hash, variable_htab_eq,
2735 vt_add_function_parameters ();
2737 if (!frame_pointer_needed)
2741 /* Create fake variable for tracking stack pointer changes. */
2742 frame_base_decl = make_node (VAR_DECL);
2743 DECL_NAME (frame_base_decl) = get_identifier ("___frame_base_decl");
2744 TREE_TYPE (frame_base_decl) = char_type_node;
2745 DECL_ARTIFICIAL (frame_base_decl) = 1;
2746 DECL_IGNORED_P (frame_base_decl) = 1;
2748 /* Set its initial "location". */
2749 frame_stack_adjust = -prologue_stack_adjust ();
2750 base = gen_rtx_MEM (Pmode, plus_constant (stack_pointer_rtx,
2751 frame_stack_adjust));
2752 set_variable_part (&VTI (ENTRY_BLOCK_PTR)->out, base, frame_base_decl, 0);
2756 frame_base_decl = NULL;
2760 /* Free the data structures needed for variable tracking. */
2769 free (VTI (bb)->mos);
2774 dataflow_set_destroy (&VTI (bb)->in);
2775 dataflow_set_destroy (&VTI (bb)->out);
2777 free_aux_for_blocks ();
2778 free_alloc_pool (attrs_pool);
2779 free_alloc_pool (var_pool);
2780 free_alloc_pool (loc_chain_pool);
2781 htab_delete (changed_variables);
2784 /* The entry point to variable tracking pass. */
2787 variable_tracking_main (void)
2789 if (n_basic_blocks > 500 && n_edges / n_basic_blocks >= 20)
2792 mark_dfs_back_edges ();
2794 if (!frame_pointer_needed)
2796 if (!vt_stack_adjustments ())
2803 vt_find_locations ();
2808 dump_dataflow_sets ();
2809 dump_flow_info (dump_file);
2816 gate_handle_var_tracking (void)
2818 return (flag_var_tracking);
2823 struct tree_opt_pass pass_variable_tracking =
2825 "vartrack", /* name */
2826 gate_handle_var_tracking, /* gate */
2827 variable_tracking_main, /* execute */
2830 0, /* static_pass_number */
2831 TV_VAR_TRACKING, /* tv_id */
2832 0, /* properties_required */
2833 0, /* properties_provided */
2834 0, /* properties_destroyed */
2835 0, /* todo_flags_start */
2836 TODO_dump_func, /* todo_flags_finish */