1 /* GIMPLE lowering pass. Converts High GIMPLE into Low GIMPLE.
3 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
23 #include "coretypes.h"
29 #include "tree-iterator.h"
30 #include "tree-inline.h"
31 #include "diagnostic.h"
32 #include "langhooks.h"
33 #include "langhooks-def.h"
34 #include "tree-flow.h"
42 #include "tree-pass.h"
44 /* The differences between High GIMPLE and Low GIMPLE are the
47 1- Lexical scopes are removed (i.e., GIMPLE_BIND disappears).
49 2- GIMPLE_TRY and GIMPLE_CATCH are converted to abnormal control
50 flow and exception regions are built as an on-the-side region
51 hierarchy (See tree-eh.c:lower_eh_constructs).
53 3- Multiple identical return statements are grouped into a single
54 return and gotos to the unique return site. */
56 /* Match a return statement with a label. During lowering, we identify
57 identical return statements and replace duplicates with a jump to
58 the corresponding label. */
59 struct return_statements_t
64 typedef struct return_statements_t return_statements_t
;
66 DEF_VEC_O(return_statements_t
);
67 DEF_VEC_ALLOC_O(return_statements_t
,heap
);
71 /* Block the current statement belongs to. */
74 /* A vector of label and return statements to be moved to the end
76 VEC(return_statements_t
,heap
) *return_statements
;
78 /* True if the function calls __builtin_setjmp. */
79 bool calls_builtin_setjmp
;
82 static void lower_stmt (gimple_stmt_iterator
*, struct lower_data
*);
83 static void lower_gimple_bind (gimple_stmt_iterator
*, struct lower_data
*);
84 static void lower_gimple_return (gimple_stmt_iterator
*, struct lower_data
*);
85 static void lower_builtin_setjmp (gimple_stmt_iterator
*);
88 /* Lower the body of current_function_decl from High GIMPLE into Low
92 lower_function_body (void)
94 struct lower_data data
;
95 gimple_seq body
= gimple_body (current_function_decl
);
96 gimple_seq lowered_body
;
97 gimple_stmt_iterator i
;
102 /* The gimplifier should've left a body of exactly one statement,
103 namely a GIMPLE_BIND. */
104 gcc_assert (gimple_seq_first (body
) == gimple_seq_last (body
)
105 && gimple_code (gimple_seq_first_stmt (body
)) == GIMPLE_BIND
);
107 memset (&data
, 0, sizeof (data
));
108 data
.block
= DECL_INITIAL (current_function_decl
);
109 BLOCK_SUBBLOCKS (data
.block
) = NULL_TREE
;
110 BLOCK_CHAIN (data
.block
) = NULL_TREE
;
111 TREE_ASM_WRITTEN (data
.block
) = 1;
112 data
.return_statements
= VEC_alloc (return_statements_t
, heap
, 8);
114 bind
= gimple_seq_first_stmt (body
);
116 gimple_seq_add_stmt (&lowered_body
, bind
);
117 i
= gsi_start (lowered_body
);
118 lower_gimple_bind (&i
, &data
);
120 /* Once the old body has been lowered, replace it with the new
122 gimple_set_body (current_function_decl
, lowered_body
);
124 i
= gsi_last (lowered_body
);
126 /* If the function falls off the end, we need a null return statement.
127 If we've already got one in the return_statements vector, we don't
128 need to do anything special. Otherwise build one by hand. */
129 if (gimple_seq_may_fallthru (lowered_body
)
130 && (VEC_empty (return_statements_t
, data
.return_statements
)
131 || gimple_return_retval (VEC_last (return_statements_t
,
132 data
.return_statements
)->stmt
) != NULL
))
134 x
= gimple_build_return (NULL
);
135 gimple_set_location (x
, cfun
->function_end_locus
);
136 gsi_insert_after (&i
, x
, GSI_CONTINUE_LINKING
);
139 /* If we lowered any return statements, emit the representative
140 at the end of the function. */
141 while (!VEC_empty (return_statements_t
, data
.return_statements
))
143 return_statements_t t
;
145 /* Unfortunately, we can't use VEC_pop because it returns void for
147 t
= *VEC_last (return_statements_t
, data
.return_statements
);
148 VEC_truncate (return_statements_t
,
149 data
.return_statements
,
150 VEC_length (return_statements_t
,
151 data
.return_statements
) - 1);
153 x
= gimple_build_label (t
.label
);
154 gsi_insert_after (&i
, x
, GSI_CONTINUE_LINKING
);
156 /* Remove the line number from the representative return statement.
157 It now fills in for many such returns. Failure to remove this
158 will result in incorrect results for coverage analysis. */
159 gimple_set_location (t
.stmt
, UNKNOWN_LOCATION
);
160 gsi_insert_after (&i
, t
.stmt
, GSI_CONTINUE_LINKING
);
163 /* If the function calls __builtin_setjmp, we need to emit the computed
164 goto that will serve as the unique dispatcher for all the receivers. */
165 if (data
.calls_builtin_setjmp
)
167 tree disp_label
, disp_var
, arg
;
169 /* Build 'DISP_LABEL:' and insert. */
170 disp_label
= create_artificial_label ();
171 /* This mark will create forward edges from every call site. */
172 DECL_NONLOCAL (disp_label
) = 1;
173 cfun
->has_nonlocal_label
= 1;
174 x
= gimple_build_label (disp_label
);
175 gsi_insert_after (&i
, x
, GSI_CONTINUE_LINKING
);
177 /* Build 'DISP_VAR = __builtin_setjmp_dispatcher (DISP_LABEL);'
179 disp_var
= create_tmp_var (ptr_type_node
, "setjmpvar");
180 arg
= build_addr (disp_label
, current_function_decl
);
181 t
= implicit_built_in_decls
[BUILT_IN_SETJMP_DISPATCHER
];
182 x
= gimple_build_call (t
, 1, arg
);
183 gimple_call_set_lhs (x
, disp_var
);
185 /* Build 'goto DISP_VAR;' and insert. */
186 gsi_insert_after (&i
, x
, GSI_CONTINUE_LINKING
);
187 x
= gimple_build_goto (disp_var
);
188 gsi_insert_after (&i
, x
, GSI_CONTINUE_LINKING
);
191 gcc_assert (data
.block
== DECL_INITIAL (current_function_decl
));
192 BLOCK_SUBBLOCKS (data
.block
)
193 = blocks_nreverse (BLOCK_SUBBLOCKS (data
.block
));
195 clear_block_marks (data
.block
);
196 VEC_free(return_statements_t
, heap
, data
.return_statements
);
200 struct gimple_opt_pass pass_lower_cf
=
206 lower_function_body
, /* execute */
209 0, /* static_pass_number */
211 PROP_gimple_any
, /* properties_required */
212 PROP_gimple_lcf
, /* properties_provided */
213 0, /* properties_destroyed */
214 0, /* todo_flags_start */
215 TODO_dump_func
/* todo_flags_finish */
220 /* Lower sequence SEQ. Unlike gimplification the statements are not relowered
221 when they are changed -- if this has to be done, the lowering routine must
222 do it explicitly. DATA is passed through the recursion. */
225 lower_sequence (gimple_seq seq
, struct lower_data
*data
)
227 gimple_stmt_iterator gsi
;
229 for (gsi
= gsi_start (seq
); !gsi_end_p (gsi
); )
230 lower_stmt (&gsi
, data
);
234 /* Lower the OpenMP directive statement pointed by GSI. DATA is
235 passed through the recursion. */
238 lower_omp_directive (gimple_stmt_iterator
*gsi
, struct lower_data
*data
)
242 stmt
= gsi_stmt (*gsi
);
244 lower_sequence (gimple_omp_body (stmt
), data
);
245 gsi_insert_before (gsi
, stmt
, GSI_SAME_STMT
);
246 gsi_insert_seq_before (gsi
, gimple_omp_body (stmt
), GSI_SAME_STMT
);
247 gimple_omp_set_body (stmt
, NULL
);
248 gsi_remove (gsi
, false);
252 /* Lower statement GSI. DATA is passed through the recursion. */
255 lower_stmt (gimple_stmt_iterator
*gsi
, struct lower_data
*data
)
257 gimple stmt
= gsi_stmt (*gsi
);
259 gimple_set_block (stmt
, data
->block
);
261 switch (gimple_code (stmt
))
264 lower_gimple_bind (gsi
, data
);
268 /* The gimplifier has already lowered this into gotos. */
272 lower_gimple_return (gsi
, data
);
276 lower_sequence (gimple_try_eval (stmt
), data
);
277 lower_sequence (gimple_try_cleanup (stmt
), data
);
281 lower_sequence (gimple_catch_handler (stmt
), data
);
284 case GIMPLE_EH_FILTER
:
285 lower_sequence (gimple_eh_filter_failure (stmt
), data
);
295 case GIMPLE_CHANGE_DYNAMIC_TYPE
:
297 case GIMPLE_OMP_SECTIONS
:
298 case GIMPLE_OMP_SECTIONS_SWITCH
:
299 case GIMPLE_OMP_SECTION
:
300 case GIMPLE_OMP_SINGLE
:
301 case GIMPLE_OMP_MASTER
:
302 case GIMPLE_OMP_ORDERED
:
303 case GIMPLE_OMP_CRITICAL
:
304 case GIMPLE_OMP_RETURN
:
305 case GIMPLE_OMP_ATOMIC_LOAD
:
306 case GIMPLE_OMP_ATOMIC_STORE
:
307 case GIMPLE_OMP_CONTINUE
:
312 tree decl
= gimple_call_fndecl (stmt
);
315 && DECL_BUILT_IN_CLASS (decl
) == BUILT_IN_NORMAL
316 && DECL_FUNCTION_CODE (decl
) == BUILT_IN_SETJMP
)
318 data
->calls_builtin_setjmp
= true;
319 lower_builtin_setjmp (gsi
);
325 case GIMPLE_OMP_PARALLEL
:
326 case GIMPLE_OMP_TASK
:
327 lower_omp_directive (gsi
, data
);
337 /* Lower a bind_expr TSI. DATA is passed through the recursion. */
340 lower_gimple_bind (gimple_stmt_iterator
*gsi
, struct lower_data
*data
)
342 tree old_block
= data
->block
;
343 gimple stmt
= gsi_stmt (*gsi
);
344 tree new_block
= gimple_bind_block (stmt
);
348 if (new_block
== old_block
)
350 /* The outermost block of the original function may not be the
351 outermost statement chain of the gimplified function. So we
352 may see the outermost block just inside the function. */
353 gcc_assert (new_block
== DECL_INITIAL (current_function_decl
));
358 /* We do not expect to handle duplicate blocks. */
359 gcc_assert (!TREE_ASM_WRITTEN (new_block
));
360 TREE_ASM_WRITTEN (new_block
) = 1;
362 /* Block tree may get clobbered by inlining. Normally this would
363 be fixed in rest_of_decl_compilation using block notes, but
364 since we are not going to emit them, it is up to us. */
365 BLOCK_CHAIN (new_block
) = BLOCK_SUBBLOCKS (old_block
);
366 BLOCK_SUBBLOCKS (old_block
) = new_block
;
367 BLOCK_SUBBLOCKS (new_block
) = NULL_TREE
;
368 BLOCK_SUPERCONTEXT (new_block
) = old_block
;
370 data
->block
= new_block
;
374 record_vars (gimple_bind_vars (stmt
));
375 lower_sequence (gimple_bind_body (stmt
), data
);
379 gcc_assert (data
->block
== new_block
);
381 BLOCK_SUBBLOCKS (new_block
)
382 = blocks_nreverse (BLOCK_SUBBLOCKS (new_block
));
383 data
->block
= old_block
;
386 /* The GIMPLE_BIND no longer carries any useful information -- kill it. */
387 gsi_insert_seq_before (gsi
, gimple_bind_body (stmt
), GSI_SAME_STMT
);
388 gsi_remove (gsi
, false);
391 /* Try to determine whether a TRY_CATCH expression can fall through.
392 This is a subroutine of block_may_fallthru. */
395 try_catch_may_fallthru (const_tree stmt
)
397 tree_stmt_iterator i
;
399 /* If the TRY block can fall through, the whole TRY_CATCH can
401 if (block_may_fallthru (TREE_OPERAND (stmt
, 0)))
404 i
= tsi_start (TREE_OPERAND (stmt
, 1));
405 switch (TREE_CODE (tsi_stmt (i
)))
408 /* We expect to see a sequence of CATCH_EXPR trees, each with a
409 catch expression and a body. The whole TRY_CATCH may fall
410 through iff any of the catch bodies falls through. */
411 for (; !tsi_end_p (i
); tsi_next (&i
))
413 if (block_may_fallthru (CATCH_BODY (tsi_stmt (i
))))
419 /* The exception filter expression only matters if there is an
420 exception. If the exception does not match EH_FILTER_TYPES,
421 we will execute EH_FILTER_FAILURE, and we will fall through
422 if that falls through. If the exception does match
423 EH_FILTER_TYPES, the stack unwinder will continue up the
424 stack, so we will not fall through. We don't know whether we
425 will throw an exception which matches EH_FILTER_TYPES or not,
426 so we just ignore EH_FILTER_TYPES and assume that we might
427 throw an exception which doesn't match. */
428 return block_may_fallthru (EH_FILTER_FAILURE (tsi_stmt (i
)));
431 /* This case represents statements to be executed when an
432 exception occurs. Those statements are implicitly followed
433 by a RESX_EXPR to resume execution after the exception. So
434 in this case the TRY_CATCH never falls through. */
440 /* Same as above, but for a GIMPLE_TRY_CATCH. */
443 gimple_try_catch_may_fallthru (gimple stmt
)
445 gimple_stmt_iterator i
;
447 /* We don't handle GIMPLE_TRY_FINALLY. */
448 gcc_assert (gimple_try_kind (stmt
) == GIMPLE_TRY_CATCH
);
450 /* If the TRY block can fall through, the whole TRY_CATCH can
452 if (gimple_seq_may_fallthru (gimple_try_eval (stmt
)))
455 i
= gsi_start (gimple_try_cleanup (stmt
));
456 switch (gimple_code (gsi_stmt (i
)))
459 /* We expect to see a sequence of GIMPLE_CATCH stmts, each with a
460 catch expression and a body. The whole try/catch may fall
461 through iff any of the catch bodies falls through. */
462 for (; !gsi_end_p (i
); gsi_next (&i
))
464 if (gimple_seq_may_fallthru (gimple_catch_handler (gsi_stmt (i
))))
469 case GIMPLE_EH_FILTER
:
470 /* The exception filter expression only matters if there is an
471 exception. If the exception does not match EH_FILTER_TYPES,
472 we will execute EH_FILTER_FAILURE, and we will fall through
473 if that falls through. If the exception does match
474 EH_FILTER_TYPES, the stack unwinder will continue up the
475 stack, so we will not fall through. We don't know whether we
476 will throw an exception which matches EH_FILTER_TYPES or not,
477 so we just ignore EH_FILTER_TYPES and assume that we might
478 throw an exception which doesn't match. */
479 return gimple_seq_may_fallthru (gimple_eh_filter_failure (gsi_stmt (i
)));
482 /* This case represents statements to be executed when an
483 exception occurs. Those statements are implicitly followed
484 by a GIMPLE_RESX to resume execution after the exception. So
485 in this case the try/catch never falls through. */
491 /* Try to determine if we can fall out of the bottom of BLOCK. This guess
492 need not be 100% accurate; simply be conservative and return true if we
493 don't know. This is used only to avoid stupidly generating extra code.
494 If we're wrong, we'll just delete the extra code later. */
497 block_may_fallthru (const_tree block
)
499 /* This CONST_CAST is okay because expr_last returns its argument
500 unmodified and we assign it to a const_tree. */
501 const_tree stmt
= expr_last (CONST_CAST_TREE(block
));
503 switch (stmt
? TREE_CODE (stmt
) : ERROR_MARK
)
508 /* Easy cases. If the last statement of the block implies
509 control transfer, then we can't fall through. */
513 /* If SWITCH_LABELS is set, this is lowered, and represents a
514 branch to a selected label and hence can not fall through.
515 Otherwise SWITCH_BODY is set, and the switch can fall
517 return SWITCH_LABELS (stmt
) == NULL_TREE
;
520 if (block_may_fallthru (COND_EXPR_THEN (stmt
)))
522 return block_may_fallthru (COND_EXPR_ELSE (stmt
));
525 return block_may_fallthru (BIND_EXPR_BODY (stmt
));
528 return try_catch_may_fallthru (stmt
);
530 case TRY_FINALLY_EXPR
:
531 /* The finally clause is always executed after the try clause,
532 so if it does not fall through, then the try-finally will not
533 fall through. Otherwise, if the try clause does not fall
534 through, then when the finally clause falls through it will
535 resume execution wherever the try clause was going. So the
536 whole try-finally will only fall through if both the try
537 clause and the finally clause fall through. */
538 return (block_may_fallthru (TREE_OPERAND (stmt
, 0))
539 && block_may_fallthru (TREE_OPERAND (stmt
, 1)));
542 if (TREE_CODE (TREE_OPERAND (stmt
, 1)) == CALL_EXPR
)
543 stmt
= TREE_OPERAND (stmt
, 1);
549 /* Functions that do not return do not fall through. */
550 return (call_expr_flags (stmt
) & ECF_NORETURN
) == 0;
552 case CLEANUP_POINT_EXPR
:
553 return block_may_fallthru (TREE_OPERAND (stmt
, 0));
561 /* Try to determine if we can continue executing the statement
562 immediately following STMT. This guess need not be 100% accurate;
563 simply be conservative and return true if we don't know. This is
564 used only to avoid stupidly generating extra code. If we're wrong,
565 we'll just delete the extra code later. */
568 gimple_stmt_may_fallthru (gimple stmt
)
573 switch (gimple_code (stmt
))
578 /* Easy cases. If the last statement of the seq implies
579 control transfer, then we can't fall through. */
583 /* Switch has already been lowered and represents a
584 branch to a selected label and hence can not fall through. */
588 /* GIMPLE_COND's are already lowered into a two-way branch. They
589 can't fall through. */
593 return gimple_seq_may_fallthru (gimple_bind_body (stmt
));
596 if (gimple_try_kind (stmt
) == GIMPLE_TRY_CATCH
)
597 return gimple_try_catch_may_fallthru (stmt
);
599 /* It must be a GIMPLE_TRY_FINALLY. */
601 /* The finally clause is always executed after the try clause,
602 so if it does not fall through, then the try-finally will not
603 fall through. Otherwise, if the try clause does not fall
604 through, then when the finally clause falls through it will
605 resume execution wherever the try clause was going. So the
606 whole try-finally will only fall through if both the try
607 clause and the finally clause fall through. */
608 return (gimple_seq_may_fallthru (gimple_try_eval (stmt
))
609 && gimple_seq_may_fallthru (gimple_try_cleanup (stmt
)));
615 /* Functions that do not return do not fall through. */
616 return (gimple_call_flags (stmt
) & ECF_NORETURN
) == 0;
624 /* Same as gimple_stmt_may_fallthru, but for the gimple sequence SEQ. */
627 gimple_seq_may_fallthru (gimple_seq seq
)
629 return gimple_stmt_may_fallthru (gimple_seq_last_stmt (seq
));
633 /* Lower a GIMPLE_RETURN GSI. DATA is passed through the recursion. */
636 lower_gimple_return (gimple_stmt_iterator
*gsi
, struct lower_data
*data
)
638 gimple stmt
= gsi_stmt (*gsi
);
641 return_statements_t tmp_rs
;
643 /* Match this up with an existing return statement that's been created. */
644 for (i
= VEC_length (return_statements_t
, data
->return_statements
) - 1;
647 tmp_rs
= *VEC_index (return_statements_t
, data
->return_statements
, i
);
649 if (gimple_return_retval (stmt
) == gimple_return_retval (tmp_rs
.stmt
))
653 /* Not found. Create a new label and record the return statement. */
654 tmp_rs
.label
= create_artificial_label ();
656 VEC_safe_push (return_statements_t
, heap
, data
->return_statements
, &tmp_rs
);
658 /* Generate a goto statement and remove the return statement. */
660 t
= gimple_build_goto (tmp_rs
.label
);
661 gimple_set_location (t
, gimple_location (stmt
));
662 gsi_insert_before (gsi
, t
, GSI_SAME_STMT
);
663 gsi_remove (gsi
, false);
666 /* Lower a __builtin_setjmp TSI.
668 __builtin_setjmp is passed a pointer to an array of five words (not
669 all will be used on all machines). It operates similarly to the C
670 library function of the same name, but is more efficient.
672 It is lowered into 3 other builtins, namely __builtin_setjmp_setup,
673 __builtin_setjmp_dispatcher and __builtin_setjmp_receiver, but with
674 __builtin_setjmp_dispatcher shared among all the instances; that's
675 why it is only emitted at the end by lower_function_body.
677 After full lowering, the body of the function should look like:
686 __builtin_setjmp_setup (&buf, &<D1847>);
690 __builtin_setjmp_receiver (&<D1847>);
693 if (D.1844 == 0) goto <D1848>; else goto <D1849>;
697 __builtin_setjmp_setup (&buf, &<D2847>);
701 __builtin_setjmp_receiver (&<D2847>);
704 if (D.2844 == 0) goto <D2848>; else goto <D2849>;
710 <D3853>: [non-local];
711 setjmpvar.0 = __builtin_setjmp_dispatcher (&<D3853>);
715 The dispatcher block will be both the unique destination of all the
716 abnormal call edges and the unique source of all the abnormal edges
717 to the receivers, thus keeping the complexity explosion localized. */
720 lower_builtin_setjmp (gimple_stmt_iterator
*gsi
)
722 gimple stmt
= gsi_stmt (*gsi
);
723 tree cont_label
= create_artificial_label ();
724 tree next_label
= create_artificial_label ();
728 /* NEXT_LABEL is the label __builtin_longjmp will jump to. Its address is
729 passed to both __builtin_setjmp_setup and __builtin_setjmp_receiver. */
730 FORCED_LABEL (next_label
) = 1;
732 dest
= gimple_call_lhs (stmt
);
734 /* Build '__builtin_setjmp_setup (BUF, NEXT_LABEL)' and insert. */
735 arg
= build_addr (next_label
, current_function_decl
);
736 t
= implicit_built_in_decls
[BUILT_IN_SETJMP_SETUP
];
737 g
= gimple_build_call (t
, 2, gimple_call_arg (stmt
, 0), arg
);
738 gimple_set_location (g
, gimple_location (stmt
));
739 gsi_insert_before (gsi
, g
, GSI_SAME_STMT
);
741 /* Build 'DEST = 0' and insert. */
744 g
= gimple_build_assign (dest
, fold_convert (TREE_TYPE (dest
),
746 gimple_set_location (g
, gimple_location (stmt
));
747 gsi_insert_before (gsi
, g
, GSI_SAME_STMT
);
750 /* Build 'goto CONT_LABEL' and insert. */
751 g
= gimple_build_goto (cont_label
);
752 gsi_insert_before (gsi
, g
, TSI_SAME_STMT
);
754 /* Build 'NEXT_LABEL:' and insert. */
755 g
= gimple_build_label (next_label
);
756 gsi_insert_before (gsi
, g
, GSI_SAME_STMT
);
758 /* Build '__builtin_setjmp_receiver (NEXT_LABEL)' and insert. */
759 arg
= build_addr (next_label
, current_function_decl
);
760 t
= implicit_built_in_decls
[BUILT_IN_SETJMP_RECEIVER
];
761 g
= gimple_build_call (t
, 1, arg
);
762 gimple_set_location (g
, gimple_location (stmt
));
763 gsi_insert_before (gsi
, g
, GSI_SAME_STMT
);
765 /* Build 'DEST = 1' and insert. */
768 g
= gimple_build_assign (dest
, fold_convert (TREE_TYPE (dest
),
770 gimple_set_location (g
, gimple_location (stmt
));
771 gsi_insert_before (gsi
, g
, GSI_SAME_STMT
);
774 /* Build 'CONT_LABEL:' and insert. */
775 g
= gimple_build_label (cont_label
);
776 gsi_insert_before (gsi
, g
, GSI_SAME_STMT
);
778 /* Remove the call to __builtin_setjmp. */
779 gsi_remove (gsi
, false);
783 /* Record the variables in VARS into function FN. */
786 record_vars_into (tree vars
, tree fn
)
788 if (fn
!= current_function_decl
)
789 push_cfun (DECL_STRUCT_FUNCTION (fn
));
791 for (; vars
; vars
= TREE_CHAIN (vars
))
795 /* BIND_EXPRs contains also function/type/constant declarations
796 we don't need to care about. */
797 if (TREE_CODE (var
) != VAR_DECL
)
800 /* Nothing to do in this case. */
801 if (DECL_EXTERNAL (var
))
804 /* Record the variable. */
805 cfun
->local_decls
= tree_cons (NULL_TREE
, var
,
809 if (fn
!= current_function_decl
)
814 /* Record the variables in VARS into current_function_decl. */
817 record_vars (tree vars
)
819 record_vars_into (vars
, current_function_decl
);
823 /* Mark BLOCK used if it has a used variable in it, then recurse over its
827 mark_blocks_with_used_vars (tree block
)
832 if (!TREE_USED (block
))
834 for (var
= BLOCK_VARS (block
);
836 var
= TREE_CHAIN (var
))
840 TREE_USED (block
) = true;
845 for (subblock
= BLOCK_SUBBLOCKS (block
);
847 subblock
= BLOCK_CHAIN (subblock
))
848 mark_blocks_with_used_vars (subblock
);
851 /* Mark the used attribute on blocks correctly. */
854 mark_used_blocks (void)
856 mark_blocks_with_used_vars (DECL_INITIAL (current_function_decl
));
861 struct gimple_opt_pass pass_mark_used_blocks
=
867 mark_used_blocks
, /* execute */
870 0, /* static_pass_number */
872 0, /* properties_required */
873 0, /* properties_provided */
874 0, /* properties_destroyed */
875 0, /* todo_flags_start */
876 TODO_dump_func
/* todo_flags_finish */