1 /* GIMPLE lowering pass. Converts High GIMPLE into Low GIMPLE.
3 Copyright (C) 2003-2014 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"
26 #include "tree-nested.h"
28 #include "basic-block.h"
29 #include "tree-ssa-alias.h"
30 #include "internal-fn.h"
31 #include "gimple-expr.h"
34 #include "gimple-iterator.h"
35 #include "tree-iterator.h"
36 #include "tree-inline.h"
39 #include "diagnostic-core.h"
40 #include "tree-pass.h"
41 #include "langhooks.h"
42 #include "gimple-low.h"
43 #include "tree-nested.h"
45 /* The differences between High GIMPLE and Low GIMPLE are the
48 1- Lexical scopes are removed (i.e., GIMPLE_BIND disappears).
50 2- GIMPLE_TRY and GIMPLE_CATCH are converted to abnormal control
51 flow and exception regions are built as an on-the-side region
52 hierarchy (See tree-eh.c:lower_eh_constructs).
54 3- Multiple identical return statements are grouped into a single
55 return and gotos to the unique return site. */
57 /* Match a return statement with a label. During lowering, we identify
58 identical return statements and replace duplicates with a jump to
59 the corresponding label. */
60 struct return_statements_t
65 typedef struct return_statements_t return_statements_t
;
70 /* Block the current statement belongs to. */
73 /* A vector of label and return statements to be moved to the end
75 vec
<return_statements_t
> return_statements
;
77 /* True if the current statement cannot fall through. */
80 /* True if the function calls __builtin_setjmp. */
81 bool calls_builtin_setjmp
;
84 static void lower_stmt (gimple_stmt_iterator
*, struct lower_data
*);
85 static void lower_gimple_bind (gimple_stmt_iterator
*, struct lower_data
*);
86 static void lower_try_catch (gimple_stmt_iterator
*, struct lower_data
*);
87 static void lower_gimple_return (gimple_stmt_iterator
*, struct lower_data
*);
88 static void lower_builtin_setjmp (gimple_stmt_iterator
*);
91 /* Lower the body of current_function_decl from High GIMPLE into Low
95 lower_function_body (void)
97 struct lower_data data
;
98 gimple_seq body
= gimple_body (current_function_decl
);
99 gimple_seq lowered_body
;
100 gimple_stmt_iterator i
;
105 /* The gimplifier should've left a body of exactly one statement,
106 namely a GIMPLE_BIND. */
107 gcc_assert (gimple_seq_first (body
) == gimple_seq_last (body
)
108 && gimple_code (gimple_seq_first_stmt (body
)) == GIMPLE_BIND
);
110 memset (&data
, 0, sizeof (data
));
111 data
.block
= DECL_INITIAL (current_function_decl
);
112 BLOCK_SUBBLOCKS (data
.block
) = NULL_TREE
;
113 BLOCK_CHAIN (data
.block
) = NULL_TREE
;
114 TREE_ASM_WRITTEN (data
.block
) = 1;
115 data
.return_statements
.create (8);
117 bind
= gimple_seq_first_stmt (body
);
119 gimple_seq_add_stmt (&lowered_body
, bind
);
120 i
= gsi_start (lowered_body
);
121 lower_gimple_bind (&i
, &data
);
123 i
= gsi_last (lowered_body
);
125 /* If the function falls off the end, we need a null return statement.
126 If we've already got one in the return_statements vector, we don't
127 need to do anything special. Otherwise build one by hand. */
128 if (gimple_seq_may_fallthru (lowered_body
)
129 && (data
.return_statements
.is_empty ()
130 || (gimple_return_retval (data
.return_statements
.last().stmt
)
133 x
= gimple_build_return (NULL
);
134 gimple_set_location (x
, cfun
->function_end_locus
);
135 gimple_set_block (x
, DECL_INITIAL (current_function_decl
));
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 (!data
.return_statements
.is_empty ())
143 return_statements_t t
= data
.return_statements
.pop ();
144 x
= gimple_build_label (t
.label
);
145 gsi_insert_after (&i
, x
, GSI_CONTINUE_LINKING
);
146 gsi_insert_after (&i
, t
.stmt
, GSI_CONTINUE_LINKING
);
149 /* If the function calls __builtin_setjmp, we need to emit the computed
150 goto that will serve as the unique dispatcher for all the receivers. */
151 if (data
.calls_builtin_setjmp
)
153 tree disp_label
, disp_var
, arg
;
155 /* Build 'DISP_LABEL:' and insert. */
156 disp_label
= create_artificial_label (cfun
->function_end_locus
);
157 /* This mark will create forward edges from every call site. */
158 DECL_NONLOCAL (disp_label
) = 1;
159 cfun
->has_nonlocal_label
= 1;
160 x
= gimple_build_label (disp_label
);
161 gsi_insert_after (&i
, x
, GSI_CONTINUE_LINKING
);
163 /* Build 'DISP_VAR = __builtin_setjmp_dispatcher (DISP_LABEL);'
165 disp_var
= create_tmp_var (ptr_type_node
, "setjmpvar");
166 arg
= build_addr (disp_label
, current_function_decl
);
167 t
= builtin_decl_implicit (BUILT_IN_SETJMP_DISPATCHER
);
168 x
= gimple_build_call (t
, 1, arg
);
169 gimple_call_set_lhs (x
, disp_var
);
171 /* Build 'goto DISP_VAR;' and insert. */
172 gsi_insert_after (&i
, x
, GSI_CONTINUE_LINKING
);
173 x
= gimple_build_goto (disp_var
);
174 gsi_insert_after (&i
, x
, GSI_CONTINUE_LINKING
);
177 /* Once the old body has been lowered, replace it with the new
179 gimple_set_body (current_function_decl
, lowered_body
);
181 gcc_assert (data
.block
== DECL_INITIAL (current_function_decl
));
182 BLOCK_SUBBLOCKS (data
.block
)
183 = blocks_nreverse (BLOCK_SUBBLOCKS (data
.block
));
185 clear_block_marks (data
.block
);
186 data
.return_statements
.release ();
192 const pass_data pass_data_lower_cf
=
194 GIMPLE_PASS
, /* type */
196 OPTGROUP_NONE
, /* optinfo_flags */
197 false, /* has_gate */
198 true, /* has_execute */
200 PROP_gimple_any
, /* properties_required */
201 PROP_gimple_lcf
, /* properties_provided */
202 0, /* properties_destroyed */
203 0, /* todo_flags_start */
204 0, /* todo_flags_finish */
207 class pass_lower_cf
: public gimple_opt_pass
210 pass_lower_cf (gcc::context
*ctxt
)
211 : gimple_opt_pass (pass_data_lower_cf
, ctxt
)
214 /* opt_pass methods: */
215 unsigned int execute () { return lower_function_body (); }
217 }; // class pass_lower_cf
222 make_pass_lower_cf (gcc::context
*ctxt
)
224 return new pass_lower_cf (ctxt
);
227 /* Lower sequence SEQ. Unlike gimplification the statements are not relowered
228 when they are changed -- if this has to be done, the lowering routine must
229 do it explicitly. DATA is passed through the recursion. */
232 lower_sequence (gimple_seq
*seq
, struct lower_data
*data
)
234 gimple_stmt_iterator gsi
;
236 for (gsi
= gsi_start (*seq
); !gsi_end_p (gsi
); )
237 lower_stmt (&gsi
, data
);
241 /* Lower the OpenMP directive statement pointed by GSI. DATA is
242 passed through the recursion. */
245 lower_omp_directive (gimple_stmt_iterator
*gsi
, struct lower_data
*data
)
249 stmt
= gsi_stmt (*gsi
);
251 lower_sequence (gimple_omp_body_ptr (stmt
), data
);
252 gsi_insert_seq_after (gsi
, gimple_omp_body (stmt
), GSI_CONTINUE_LINKING
);
253 gimple_omp_set_body (stmt
, NULL
);
258 /* Lower statement GSI. DATA is passed through the recursion. We try to
259 track the fallthruness of statements and get rid of unreachable return
260 statements in order to prevent the EH lowering pass from adding useless
261 edges that can cause bogus warnings to be issued later; this guess need
262 not be 100% accurate, simply be conservative and reset cannot_fallthru
263 to false if we don't know. */
266 lower_stmt (gimple_stmt_iterator
*gsi
, struct lower_data
*data
)
268 gimple stmt
= gsi_stmt (*gsi
);
270 gimple_set_block (stmt
, data
->block
);
272 switch (gimple_code (stmt
))
275 lower_gimple_bind (gsi
, data
);
276 /* Propagate fallthruness. */
282 data
->cannot_fallthru
= true;
287 if (data
->cannot_fallthru
)
289 gsi_remove (gsi
, false);
290 /* Propagate fallthruness. */
294 lower_gimple_return (gsi
, data
);
295 data
->cannot_fallthru
= true;
300 if (gimple_try_kind (stmt
) == GIMPLE_TRY_CATCH
)
301 lower_try_catch (gsi
, data
);
304 /* It must be a GIMPLE_TRY_FINALLY. */
305 bool cannot_fallthru
;
306 lower_sequence (gimple_try_eval_ptr (stmt
), data
);
307 cannot_fallthru
= data
->cannot_fallthru
;
309 /* The finally clause is always executed after the try clause,
310 so if it does not fall through, then the try-finally will not
311 fall through. Otherwise, if the try clause does not fall
312 through, then when the finally clause falls through it will
313 resume execution wherever the try clause was going. So the
314 whole try-finally will only fall through if both the try
315 clause and the finally clause fall through. */
316 data
->cannot_fallthru
= false;
317 lower_sequence (gimple_try_cleanup_ptr (stmt
), data
);
318 data
->cannot_fallthru
|= cannot_fallthru
;
324 lower_sequence (gimple_eh_else_n_body_ptr (stmt
), data
);
325 lower_sequence (gimple_eh_else_e_body_ptr (stmt
), data
);
333 case GIMPLE_EH_MUST_NOT_THROW
:
335 case GIMPLE_OMP_SECTIONS
:
336 case GIMPLE_OMP_SECTIONS_SWITCH
:
337 case GIMPLE_OMP_SECTION
:
338 case GIMPLE_OMP_SINGLE
:
339 case GIMPLE_OMP_MASTER
:
340 case GIMPLE_OMP_TASKGROUP
:
341 case GIMPLE_OMP_ORDERED
:
342 case GIMPLE_OMP_CRITICAL
:
343 case GIMPLE_OMP_RETURN
:
344 case GIMPLE_OMP_ATOMIC_LOAD
:
345 case GIMPLE_OMP_ATOMIC_STORE
:
346 case GIMPLE_OMP_CONTINUE
:
351 tree decl
= gimple_call_fndecl (stmt
);
354 for (i
= 0; i
< gimple_call_num_args (stmt
); i
++)
356 tree arg
= gimple_call_arg (stmt
, i
);
358 TREE_SET_BLOCK (arg
, data
->block
);
362 && DECL_BUILT_IN_CLASS (decl
) == BUILT_IN_NORMAL
363 && DECL_FUNCTION_CODE (decl
) == BUILT_IN_SETJMP
)
365 lower_builtin_setjmp (gsi
);
366 data
->cannot_fallthru
= false;
367 data
->calls_builtin_setjmp
= true;
371 if (decl
&& (flags_from_decl_or_type (decl
) & ECF_NORETURN
))
373 data
->cannot_fallthru
= true;
380 case GIMPLE_OMP_PARALLEL
:
381 case GIMPLE_OMP_TASK
:
382 case GIMPLE_OMP_TARGET
:
383 case GIMPLE_OMP_TEAMS
:
384 data
->cannot_fallthru
= false;
385 lower_omp_directive (gsi
, data
);
386 data
->cannot_fallthru
= false;
389 case GIMPLE_TRANSACTION
:
390 lower_sequence (gimple_transaction_body_ptr (stmt
), data
);
397 data
->cannot_fallthru
= false;
401 /* Lower a bind_expr TSI. DATA is passed through the recursion. */
404 lower_gimple_bind (gimple_stmt_iterator
*gsi
, struct lower_data
*data
)
406 tree old_block
= data
->block
;
407 gimple stmt
= gsi_stmt (*gsi
);
408 tree new_block
= gimple_bind_block (stmt
);
412 if (new_block
== old_block
)
414 /* The outermost block of the original function may not be the
415 outermost statement chain of the gimplified function. So we
416 may see the outermost block just inside the function. */
417 gcc_assert (new_block
== DECL_INITIAL (current_function_decl
));
422 /* We do not expect to handle duplicate blocks. */
423 gcc_assert (!TREE_ASM_WRITTEN (new_block
));
424 TREE_ASM_WRITTEN (new_block
) = 1;
426 /* Block tree may get clobbered by inlining. Normally this would
427 be fixed in rest_of_decl_compilation using block notes, but
428 since we are not going to emit them, it is up to us. */
429 BLOCK_CHAIN (new_block
) = BLOCK_SUBBLOCKS (old_block
);
430 BLOCK_SUBBLOCKS (old_block
) = new_block
;
431 BLOCK_SUBBLOCKS (new_block
) = NULL_TREE
;
432 BLOCK_SUPERCONTEXT (new_block
) = old_block
;
434 data
->block
= new_block
;
438 record_vars (gimple_bind_vars (stmt
));
439 lower_sequence (gimple_bind_body_ptr (stmt
), data
);
443 gcc_assert (data
->block
== new_block
);
445 BLOCK_SUBBLOCKS (new_block
)
446 = blocks_nreverse (BLOCK_SUBBLOCKS (new_block
));
447 data
->block
= old_block
;
450 /* The GIMPLE_BIND no longer carries any useful information -- kill it. */
451 gsi_insert_seq_before (gsi
, gimple_bind_body (stmt
), GSI_SAME_STMT
);
452 gsi_remove (gsi
, false);
455 /* Same as above, but for a GIMPLE_TRY_CATCH. */
458 lower_try_catch (gimple_stmt_iterator
*gsi
, struct lower_data
*data
)
460 bool cannot_fallthru
;
461 gimple stmt
= gsi_stmt (*gsi
);
462 gimple_stmt_iterator i
;
464 /* We don't handle GIMPLE_TRY_FINALLY. */
465 gcc_assert (gimple_try_kind (stmt
) == GIMPLE_TRY_CATCH
);
467 lower_sequence (gimple_try_eval_ptr (stmt
), data
);
468 cannot_fallthru
= data
->cannot_fallthru
;
470 i
= gsi_start (*gimple_try_cleanup_ptr (stmt
));
471 switch (gimple_code (gsi_stmt (i
)))
474 /* We expect to see a sequence of GIMPLE_CATCH stmts, each with a
475 catch expression and a body. The whole try/catch may fall
476 through iff any of the catch bodies falls through. */
477 for (; !gsi_end_p (i
); gsi_next (&i
))
479 data
->cannot_fallthru
= false;
480 lower_sequence (gimple_catch_handler_ptr (gsi_stmt (i
)), data
);
481 if (!data
->cannot_fallthru
)
482 cannot_fallthru
= false;
486 case GIMPLE_EH_FILTER
:
487 /* The exception filter expression only matters if there is an
488 exception. If the exception does not match EH_FILTER_TYPES,
489 we will execute EH_FILTER_FAILURE, and we will fall through
490 if that falls through. If the exception does match
491 EH_FILTER_TYPES, the stack unwinder will continue up the
492 stack, so we will not fall through. We don't know whether we
493 will throw an exception which matches EH_FILTER_TYPES or not,
494 so we just ignore EH_FILTER_TYPES and assume that we might
495 throw an exception which doesn't match. */
496 data
->cannot_fallthru
= false;
497 lower_sequence (gimple_eh_filter_failure_ptr (gsi_stmt (i
)), data
);
498 if (!data
->cannot_fallthru
)
499 cannot_fallthru
= false;
503 /* This case represents statements to be executed when an
504 exception occurs. Those statements are implicitly followed
505 by a GIMPLE_RESX to resume execution after the exception. So
506 in this case the try/catch never falls through. */
507 data
->cannot_fallthru
= false;
508 lower_sequence (gimple_try_cleanup_ptr (stmt
), data
);
512 data
->cannot_fallthru
= cannot_fallthru
;
517 /* Try to determine whether a TRY_CATCH expression can fall through.
518 This is a subroutine of gimple_stmt_may_fallthru. */
521 gimple_try_catch_may_fallthru (gimple stmt
)
523 gimple_stmt_iterator i
;
525 /* We don't handle GIMPLE_TRY_FINALLY. */
526 gcc_assert (gimple_try_kind (stmt
) == GIMPLE_TRY_CATCH
);
528 /* If the TRY block can fall through, the whole TRY_CATCH can
530 if (gimple_seq_may_fallthru (gimple_try_eval (stmt
)))
533 i
= gsi_start (*gimple_try_cleanup_ptr (stmt
));
534 switch (gimple_code (gsi_stmt (i
)))
537 /* We expect to see a sequence of GIMPLE_CATCH stmts, each with a
538 catch expression and a body. The whole try/catch may fall
539 through iff any of the catch bodies falls through. */
540 for (; !gsi_end_p (i
); gsi_next (&i
))
542 if (gimple_seq_may_fallthru (gimple_catch_handler (gsi_stmt (i
))))
547 case GIMPLE_EH_FILTER
:
548 /* The exception filter expression only matters if there is an
549 exception. If the exception does not match EH_FILTER_TYPES,
550 we will execute EH_FILTER_FAILURE, and we will fall through
551 if that falls through. If the exception does match
552 EH_FILTER_TYPES, the stack unwinder will continue up the
553 stack, so we will not fall through. We don't know whether we
554 will throw an exception which matches EH_FILTER_TYPES or not,
555 so we just ignore EH_FILTER_TYPES and assume that we might
556 throw an exception which doesn't match. */
557 return gimple_seq_may_fallthru (gimple_eh_filter_failure (gsi_stmt (i
)));
560 /* This case represents statements to be executed when an
561 exception occurs. Those statements are implicitly followed
562 by a GIMPLE_RESX to resume execution after the exception. So
563 in this case the try/catch never falls through. */
569 /* Try to determine if we can continue executing the statement
570 immediately following STMT. This guess need not be 100% accurate;
571 simply be conservative and return true if we don't know. This is
572 used only to avoid stupidly generating extra code. If we're wrong,
573 we'll just delete the extra code later. */
576 gimple_stmt_may_fallthru (gimple stmt
)
581 switch (gimple_code (stmt
))
586 /* Easy cases. If the last statement of the seq implies
587 control transfer, then we can't fall through. */
591 /* Switch has already been lowered and represents a branch
592 to a selected label and hence can't fall through. */
596 /* GIMPLE_COND's are already lowered into a two-way branch. They
597 can't fall through. */
601 return gimple_seq_may_fallthru (gimple_bind_body (stmt
));
604 if (gimple_try_kind (stmt
) == GIMPLE_TRY_CATCH
)
605 return gimple_try_catch_may_fallthru (stmt
);
607 /* It must be a GIMPLE_TRY_FINALLY. */
609 /* The finally clause is always executed after the try clause,
610 so if it does not fall through, then the try-finally will not
611 fall through. Otherwise, if the try clause does not fall
612 through, then when the finally clause falls through it will
613 resume execution wherever the try clause was going. So the
614 whole try-finally will only fall through if both the try
615 clause and the finally clause fall through. */
616 return (gimple_seq_may_fallthru (gimple_try_eval (stmt
))
617 && gimple_seq_may_fallthru (gimple_try_cleanup (stmt
)));
620 return (gimple_seq_may_fallthru (gimple_eh_else_n_body (stmt
))
621 || gimple_seq_may_fallthru (gimple_eh_else_e_body (stmt
)));
624 /* Functions that do not return do not fall through. */
625 return (gimple_call_flags (stmt
) & ECF_NORETURN
) == 0;
633 /* Same as gimple_stmt_may_fallthru, but for the gimple sequence SEQ. */
636 gimple_seq_may_fallthru (gimple_seq seq
)
638 return gimple_stmt_may_fallthru (gimple_seq_last_stmt (seq
));
642 /* Lower a GIMPLE_RETURN GSI. DATA is passed through the recursion. */
645 lower_gimple_return (gimple_stmt_iterator
*gsi
, struct lower_data
*data
)
647 gimple stmt
= gsi_stmt (*gsi
);
650 return_statements_t tmp_rs
;
652 /* Match this up with an existing return statement that's been created. */
653 for (i
= data
->return_statements
.length () - 1;
656 tmp_rs
= data
->return_statements
[i
];
658 if (gimple_return_retval (stmt
) == gimple_return_retval (tmp_rs
.stmt
))
660 /* Remove the line number from the representative return statement.
661 It now fills in for many such returns. Failure to remove this
662 will result in incorrect results for coverage analysis. */
663 gimple_set_location (tmp_rs
.stmt
, UNKNOWN_LOCATION
);
669 /* Not found. Create a new label and record the return statement. */
670 tmp_rs
.label
= create_artificial_label (cfun
->function_end_locus
);
672 data
->return_statements
.safe_push (tmp_rs
);
674 /* Generate a goto statement and remove the return statement. */
676 /* When not optimizing, make sure user returns are preserved. */
677 if (!optimize
&& gimple_has_location (stmt
))
678 DECL_ARTIFICIAL (tmp_rs
.label
) = 0;
679 t
= gimple_build_goto (tmp_rs
.label
);
680 gimple_set_location (t
, gimple_location (stmt
));
681 gimple_set_block (t
, gimple_block (stmt
));
682 gsi_insert_before (gsi
, t
, GSI_SAME_STMT
);
683 gsi_remove (gsi
, false);
686 /* Lower a __builtin_setjmp GSI.
688 __builtin_setjmp is passed a pointer to an array of five words (not
689 all will be used on all machines). It operates similarly to the C
690 library function of the same name, but is more efficient.
692 It is lowered into 3 other builtins, namely __builtin_setjmp_setup,
693 __builtin_setjmp_dispatcher and __builtin_setjmp_receiver, but with
694 __builtin_setjmp_dispatcher shared among all the instances; that's
695 why it is only emitted at the end by lower_function_body.
697 After full lowering, the body of the function should look like:
706 __builtin_setjmp_setup (&buf, &<D1847>);
710 __builtin_setjmp_receiver (&<D1847>);
713 if (D.1844 == 0) goto <D1848>; else goto <D1849>;
717 __builtin_setjmp_setup (&buf, &<D2847>);
721 __builtin_setjmp_receiver (&<D2847>);
724 if (D.2844 == 0) goto <D2848>; else goto <D2849>;
730 <D3853>: [non-local];
731 setjmpvar.0 = __builtin_setjmp_dispatcher (&<D3853>);
735 The dispatcher block will be both the unique destination of all the
736 abnormal call edges and the unique source of all the abnormal edges
737 to the receivers, thus keeping the complexity explosion localized. */
740 lower_builtin_setjmp (gimple_stmt_iterator
*gsi
)
742 gimple stmt
= gsi_stmt (*gsi
);
743 location_t loc
= gimple_location (stmt
);
744 tree cont_label
= create_artificial_label (loc
);
745 tree next_label
= create_artificial_label (loc
);
749 /* NEXT_LABEL is the label __builtin_longjmp will jump to. Its address is
750 passed to both __builtin_setjmp_setup and __builtin_setjmp_receiver. */
751 FORCED_LABEL (next_label
) = 1;
753 dest
= gimple_call_lhs (stmt
);
755 /* Build '__builtin_setjmp_setup (BUF, NEXT_LABEL)' and insert. */
756 arg
= build_addr (next_label
, current_function_decl
);
757 t
= builtin_decl_implicit (BUILT_IN_SETJMP_SETUP
);
758 g
= gimple_build_call (t
, 2, gimple_call_arg (stmt
, 0), arg
);
759 gimple_set_location (g
, loc
);
760 gimple_set_block (g
, gimple_block (stmt
));
761 gsi_insert_before (gsi
, g
, GSI_SAME_STMT
);
763 /* Build 'DEST = 0' and insert. */
766 g
= gimple_build_assign (dest
, build_zero_cst (TREE_TYPE (dest
)));
767 gimple_set_location (g
, loc
);
768 gimple_set_block (g
, gimple_block (stmt
));
769 gsi_insert_before (gsi
, g
, GSI_SAME_STMT
);
772 /* Build 'goto CONT_LABEL' and insert. */
773 g
= gimple_build_goto (cont_label
);
774 gsi_insert_before (gsi
, g
, GSI_SAME_STMT
);
776 /* Build 'NEXT_LABEL:' and insert. */
777 g
= gimple_build_label (next_label
);
778 gsi_insert_before (gsi
, g
, GSI_SAME_STMT
);
780 /* Build '__builtin_setjmp_receiver (NEXT_LABEL)' and insert. */
781 arg
= build_addr (next_label
, current_function_decl
);
782 t
= builtin_decl_implicit (BUILT_IN_SETJMP_RECEIVER
);
783 g
= gimple_build_call (t
, 1, arg
);
784 gimple_set_location (g
, loc
);
785 gimple_set_block (g
, gimple_block (stmt
));
786 gsi_insert_before (gsi
, g
, GSI_SAME_STMT
);
788 /* Build 'DEST = 1' and insert. */
791 g
= gimple_build_assign (dest
, fold_convert_loc (loc
, TREE_TYPE (dest
),
793 gimple_set_location (g
, loc
);
794 gimple_set_block (g
, gimple_block (stmt
));
795 gsi_insert_before (gsi
, g
, GSI_SAME_STMT
);
798 /* Build 'CONT_LABEL:' and insert. */
799 g
= gimple_build_label (cont_label
);
800 gsi_insert_before (gsi
, g
, GSI_SAME_STMT
);
802 /* Remove the call to __builtin_setjmp. */
803 gsi_remove (gsi
, false);
807 /* Record the variables in VARS into function FN. */
810 record_vars_into (tree vars
, tree fn
)
812 bool change_cfun
= fn
!= current_function_decl
;
815 push_cfun (DECL_STRUCT_FUNCTION (fn
));
817 for (; vars
; vars
= DECL_CHAIN (vars
))
821 /* BIND_EXPRs contains also function/type/constant declarations
822 we don't need to care about. */
823 if (TREE_CODE (var
) != VAR_DECL
)
826 /* Nothing to do in this case. */
827 if (DECL_EXTERNAL (var
))
830 /* Record the variable. */
831 add_local_decl (cfun
, var
);
839 /* Record the variables in VARS into current_function_decl. */
842 record_vars (tree vars
)
844 record_vars_into (vars
, current_function_decl
);