OSDN Git Service

668861c15b963d7d2479ca4f826f3c21254cda30
[pf3gnuchains/gcc-fork.git] / gcc / tree-nested.c
1 /* Nested function decomposition for trees.
2    Copyright (C) 2004 Free Software Foundation, Inc.
3
4    This file is part of GCC.
5
6    GCC is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2, or (at your option)
9    any later version.
10
11    GCC is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
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
18    the Free Software Foundation, 59 Temple Place - Suite 330,
19    Boston, MA 02111-1307, USA.  */
20
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "tm.h"
25 #include "tree.h"
26 #include "rtl.h"
27 #include "tm_p.h"
28 #include "function.h"
29 #include "tree-dump.h"
30 #include "tree-inline.h"
31 #include "tree-gimple.h"
32 #include "tree-iterator.h"
33 #include "tree-flow.h"
34 #include "cgraph.h"
35 #include "expr.h"
36 #include "langhooks.h"
37 #include "ggc.h"
38
39
40 /* The object of this pass is to lower the representation of a set of nested
41    functions in order to expose all of the gory details of the various
42    nonlocal references.  We want to do this sooner rather than later, in
43    order to give us more freedom in emitting all of the functions in question.
44
45    Back in olden times, when gcc was young, we developed an insanely 
46    complicated scheme whereby variables which were referenced nonlocally
47    were forced to live in the stack of the declaring function, and then
48    the nested functions magically discovered where these variables were
49    placed.  In order for this scheme to function properly, it required
50    that the outer function be partially expanded, then we switch to 
51    compiling the inner function, and once done with those we switch back
52    to compiling the outer function.  Such delicate ordering requirements
53    makes it difficult to do whole translation unit optimizations 
54    involving such functions.
55
56    The implementation here is much more direct.  Everything that can be
57    referenced by an inner function is a member of an explicitly created
58    structure herein called the "nonlocal frame struct".  The incomming
59    static chain for a nested function is a pointer to this struct in 
60    the parent.  In this way, we settle on known offsets from a known
61    base, and so are decoupled from the logic that places objects in the
62    function's stack frame.  More importantly, we don't have to wait for
63    that to happen -- since the compilation of the inner function is no
64    longer tied to a real stack frame, the nonlocal frame struct can be
65    allocated anywhere.  Which means that the outer function is now
66    inlinable.
67
68    Theory of operation here is very simple.  Iterate over all the 
69    statements in all the functions (depth first) several times, 
70    allocating structures and fields on demand.  In general we want to
71    examine inner functions first, so that we can avoid making changes
72    to outer functions which are unnecessary.
73
74    The order of the passes matters a bit, in that later passes will be
75    skipped if it is discovered that the functions don't actually interact
76    at all.  That is, they're nested in the lexical sense but could have
77    been written as independent functions without change.  */
78
79
80 struct var_map_elt
81 {
82   tree old;
83   tree new;
84 };
85
86 struct nesting_info
87 {
88   struct nesting_info *outer;
89   struct nesting_info *inner;
90   struct nesting_info *next;
91   
92   htab_t var_map;
93   tree context;
94   tree new_local_var_chain;
95   tree frame_type;
96   tree frame_decl;
97   tree chain_field;
98   tree chain_decl;
99   tree nl_goto_field;
100
101   bool any_parm_remapped;
102   bool any_tramp_created;
103 };
104
105
106 /* Hashing and equality functions for nesting_info->var_map.  */
107
108 static hashval_t
109 var_map_hash (const void *x)
110 {
111   const struct var_map_elt *a = x;
112   return htab_hash_pointer (a->old);
113 }
114
115 static int
116 var_map_eq (const void *x, const void *y)
117 {
118   const struct var_map_elt *a = x;
119   const struct var_map_elt *b = y;
120   return a->old == b->old;
121 }
122
123 /* We're working in so many different function contexts simultaneously,
124    that create_tmp_var is dangerous.  Prevent mishap.  */
125 #define create_tmp_var cant_use_create_tmp_var_here_dummy
126
127 /* Like create_tmp_var, except record the variable for registration at
128    the given nesting level.  */
129
130 static tree
131 create_tmp_var_for (struct nesting_info *info, tree type, const char *prefix)
132 {
133   tree tmp_var;
134
135 #if defined ENABLE_CHECKING
136   /* If the type is of variable size or a type which must be created by the
137      frontend, something is wrong.  Note that we explicitly allow
138      incomplete types here, since we create them ourselves here.  */
139   if (TREE_ADDRESSABLE (type)
140       || (TYPE_SIZE_UNIT (type)
141           && TREE_CODE (TYPE_SIZE_UNIT (type)) != INTEGER_CST))
142     abort ();
143 #endif
144
145   tmp_var = create_tmp_var_raw (type, prefix);
146   DECL_CONTEXT (tmp_var) = info->context;
147   TREE_CHAIN (tmp_var) = info->new_local_var_chain;
148   info->new_local_var_chain = tmp_var;
149
150   return tmp_var;
151 }
152
153 /* Take the address of EXP.  Mark it for addressability as necessary.  */
154
155 static tree
156 build_addr (tree exp)
157 {
158   tree base = exp;
159
160   while (TREE_CODE (base) == REALPART_EXPR || TREE_CODE (base) == IMAGPART_EXPR
161          || handled_component_p (base))
162     base = TREE_OPERAND (base, 0);
163
164   if (DECL_P (base))
165     TREE_ADDRESSABLE (base) = 1;
166
167   return build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (exp)), exp);
168 }
169
170 /* Insert FIELD into TYPE, sorted by alignment requirements.  */
171
172 static void
173 insert_field_into_struct (tree type, tree field)
174 {
175   tree *p;
176
177   DECL_CONTEXT (field) = type;
178
179   for (p = &TYPE_FIELDS (type); *p ; p = &TREE_CHAIN (*p))
180     if (DECL_ALIGN (field) >= DECL_ALIGN (*p))
181       break;
182
183   TREE_CHAIN (field) = *p;
184   *p = field;
185 }
186
187 /* Build or return the RECORD_TYPE that describes the frame state that is
188    shared between INFO->CONTEXT and its nested functions.  This record will
189    not be complete until finalize_nesting_tree; up until that point we'll
190    be adding fields as necessary.
191
192    We also build the DECL that represents this frame in the function.  */
193
194 static tree
195 get_frame_type (struct nesting_info *info)
196 {
197   tree type = info->frame_type;
198   if (!type)
199     {
200       char *name;
201
202       type = make_node (RECORD_TYPE);
203
204       name = concat ("FRAME.",
205                      IDENTIFIER_POINTER (DECL_NAME (info->context)),
206                      NULL);
207       TYPE_NAME (type) = get_identifier (name);
208       free (name);
209
210       info->frame_type = type;
211       info->frame_decl = create_tmp_var_for (info, type, "FRAME");
212     }
213   return type;
214 }
215
216 /* Return true if DECL should be referenced by pointer in the non-local
217    frame structure.  */
218
219 static bool
220 use_pointer_in_frame (tree decl)
221 {
222   if (TREE_CODE (decl) == PARM_DECL)
223     {
224       /* It's illegal to copy TREE_ADDRESSABLE, impossible to copy variable
225          sized decls, and inefficient to copy large aggregates.  Don't bother
226          moving anything but scalar variables.  */
227       return AGGREGATE_TYPE_P (TREE_TYPE (decl));
228     }
229   else
230     {
231       /* Variable sized types make things "interesting" in the frame.  */
232       return DECL_SIZE (decl) == NULL || !TREE_CONSTANT (DECL_SIZE (decl));
233     }
234 }
235
236 /* Given DECL, a non-locally accessed variable, find or create a field
237    in the non-local frame structure for the given nesting context.  */
238
239 static tree
240 lookup_field_for_decl (struct nesting_info *info, tree decl,
241                        enum insert_option insert)
242 {
243   struct var_map_elt *elt, dummy;
244   void **slot;
245   tree field;
246
247   dummy.old = decl;
248   slot = htab_find_slot (info->var_map, &dummy, insert);
249   if (!slot)
250     {
251       if (insert == INSERT)
252         abort ();
253       return NULL;
254     }
255   elt = *slot;
256
257   if (!elt && insert == INSERT)
258     {
259       field = make_node (FIELD_DECL);
260       DECL_NAME (field) = DECL_NAME (decl);
261
262       if (use_pointer_in_frame (decl))
263         {
264           TREE_TYPE (field) = build_pointer_type (TREE_TYPE (decl));
265           DECL_ALIGN (field) = TYPE_ALIGN (TREE_TYPE (field));
266           DECL_NONADDRESSABLE_P (field) = 1;
267         }
268       else
269         {
270           TREE_TYPE (field) = TREE_TYPE (decl);
271           DECL_SOURCE_LOCATION (field) = DECL_SOURCE_LOCATION (decl);
272           DECL_ALIGN (field) = DECL_ALIGN (decl);
273           DECL_USER_ALIGN (field) = DECL_USER_ALIGN (decl);
274           TREE_ADDRESSABLE (field) = TREE_ADDRESSABLE (decl);
275           DECL_NONADDRESSABLE_P (field) = !TREE_ADDRESSABLE (decl);
276           TREE_THIS_VOLATILE (field) = TREE_THIS_VOLATILE (decl);
277         }
278
279       insert_field_into_struct (get_frame_type (info), field);
280   
281       elt = xmalloc (sizeof (*elt));
282       elt->old = decl;
283       elt->new = field;
284       *slot = elt;
285
286       if (TREE_CODE (decl) == PARM_DECL)
287         info->any_parm_remapped = true;
288     }
289   else
290     field = elt ? elt->new : NULL;
291
292   return field;
293 }
294
295 /* Build or return the variable that holds the static chain within
296    INFO->CONTEXT.  This variable may only be used within INFO->CONTEXT.  */
297
298 static tree
299 get_chain_decl (struct nesting_info *info)
300 {
301   tree decl = info->chain_decl;
302   if (!decl)
303     {
304       tree type;
305
306       type = get_frame_type (info->outer);
307       type = build_pointer_type (type);
308
309       /* Note that this variable is *not* entered into any BIND_EXPR;
310          the construction of this variable is handled specially in
311          expand_function_start and initialize_inlined_parameters.
312          Note also that it's represented as a parameter.  This is more
313          close to the truth, since the initial value does come from 
314          the caller.  */
315       decl = build_decl (PARM_DECL, create_tmp_var_name ("CHAIN"), type);
316       DECL_ARTIFICIAL (decl) = 1;
317       DECL_IGNORED_P (decl) = 1;
318       TREE_USED (decl) = 1;
319       DECL_CONTEXT (decl) = info->context;
320       DECL_ARG_TYPE (decl) = type;
321
322       /* Tell tree-inline.c that we never write to this variable, so
323          it can copy-prop the replacement value immediately.  */
324       TREE_READONLY (decl) = 1;
325
326       info->chain_decl = decl;
327     }
328   return decl;
329 }
330
331 /* Build or return the field within the non-local frame state that holds
332    the static chain for INFO->CONTEXT.  This is the way to walk back up
333    multiple nesting levels.  */
334
335 static tree
336 get_chain_field (struct nesting_info *info)
337 {
338   tree field = info->chain_field;
339   if (!field)
340     {
341       tree type = build_pointer_type (get_frame_type (info->outer));
342
343       field = make_node (FIELD_DECL);
344       DECL_NAME (field) = get_identifier ("__chain");
345       TREE_TYPE (field) = type;
346       DECL_ALIGN (field) = TYPE_ALIGN (type);
347       DECL_NONADDRESSABLE_P (field) = 1;
348
349       insert_field_into_struct (get_frame_type (info), field);
350
351       info->chain_field = field;
352     }
353   return field;
354 }
355
356 /* Copy EXP into a temporary.  Allocate the temporary in the context of
357    INFO and insert the initialization statement before TSI.  */
358
359 static tree
360 init_tmp_var (struct nesting_info *info, tree exp, tree_stmt_iterator *tsi)
361 {
362   tree t, stmt;
363
364   t = create_tmp_var_for (info, TREE_TYPE (exp), NULL);
365   stmt = build (MODIFY_EXPR, TREE_TYPE (t), t, exp);
366   SET_EXPR_LOCUS (stmt, EXPR_LOCUS (tsi_stmt (*tsi)));
367   tsi_link_before (tsi, stmt, TSI_SAME_STMT);
368
369   return t;
370 }
371
372 /* Similarly, but only do so to force EXP to satisfy is_gimple_val.  */
373
374 static tree
375 gimplify_val (struct nesting_info *info, tree exp, tree_stmt_iterator *tsi)
376 {
377   if (is_gimple_val (exp))
378     return exp;
379   else
380     return init_tmp_var (info, exp, tsi);
381 }
382
383 /* Build or return the type used to represent a nested function trampoline.  */
384
385 static GTY(()) tree trampoline_type;
386
387 static tree
388 get_trampoline_type (void)
389 {
390   tree record, t;
391   unsigned align, size;
392
393   if (trampoline_type)
394     return trampoline_type;
395
396   align = TRAMPOLINE_ALIGNMENT;
397   size = TRAMPOLINE_SIZE;
398
399   /* If we won't be able to guarantee alignment simply via TYPE_ALIGN,
400      then allocate extra space so that we can do dynamic alignment.  */
401   if (align > STACK_BOUNDARY)
402     {
403       size += ((align/BITS_PER_UNIT) - 1) & -(STACK_BOUNDARY/BITS_PER_UNIT);
404       align = STACK_BOUNDARY;
405     }
406
407   t = build_index_type (build_int_2 (size - 1, 0));
408   t = build_array_type (char_type_node, t);
409   t = build_decl (FIELD_DECL, get_identifier ("__data"), t);
410   DECL_ALIGN (t) = align;
411   DECL_USER_ALIGN (t) = 1;
412
413   record = make_node (RECORD_TYPE);
414   TYPE_NAME (record) = get_identifier ("__builtin_trampoline");
415   TYPE_FIELDS (record) = t;
416   layout_type (record);
417
418   return record;
419 }
420
421 /* Given DECL, a nested function, find or create a field in the non-local
422    frame structure for a trampoline for this function.  */
423
424 static tree
425 lookup_tramp_for_decl (struct nesting_info *info, tree decl,
426                        enum insert_option insert)
427 {
428   struct var_map_elt *elt, dummy;
429   void **slot;
430   tree field;
431
432   dummy.old = decl;
433   slot = htab_find_slot (info->var_map, &dummy, insert);
434   if (!slot)
435     {
436       if (insert == INSERT)
437         abort ();
438       return NULL;
439     }
440   elt = *slot;
441
442   if (!elt && insert == INSERT)
443     {
444       field = make_node (FIELD_DECL);
445       DECL_NAME (field) = DECL_NAME (decl);
446       TREE_TYPE (field) = get_trampoline_type ();
447       TREE_ADDRESSABLE (field) = 1;
448
449       insert_field_into_struct (get_frame_type (info), field);
450
451       elt = xmalloc (sizeof (*elt));
452       elt->old = decl;
453       elt->new = field;
454       *slot = elt;
455
456       info->any_tramp_created = true;
457     }
458   else
459     field = elt ? elt->new : NULL;
460
461   return field;
462
463
464 /* Build or return the field within the non-local frame state that holds
465    the non-local goto "jmp_buf".  The buffer itself is maintained by the
466    rtl middle-end as dynamic stack space is allocated.  */
467
468 static tree
469 get_nl_goto_field (struct nesting_info *info)
470 {
471   tree field = info->nl_goto_field;
472   if (!field)
473     {
474       unsigned size;
475       tree type;
476
477       /* For __builtin_nonlocal_goto, we need N words.  The first is the
478          frame pointer, the rest is for the target's stack pointer save
479          area.  The number of words is controlled by STACK_SAVEAREA_MODE;
480          not the best interface, but it'll do for now.  */
481       if (Pmode == ptr_mode)
482         type = ptr_type_node;
483       else
484         type = lang_hooks.types.type_for_mode (Pmode, 1);
485
486       size = GET_MODE_SIZE (STACK_SAVEAREA_MODE (SAVE_NONLOCAL));
487       size = size / GET_MODE_SIZE (Pmode);
488       size = size + 1;
489
490       type = build_array_type (type, build_index_type (build_int_2 (size, 0)));
491
492       field = make_node (FIELD_DECL);
493       DECL_NAME (field) = get_identifier ("__nl_goto_buf");
494       TREE_TYPE (field) = type;
495       DECL_ALIGN (field) = TYPE_ALIGN (type);
496       TREE_ADDRESSABLE (field) = 1;
497
498       insert_field_into_struct (get_frame_type (info), field);
499
500       info->nl_goto_field = field;
501     }
502
503   return field;
504 }
505 \f
506 /* Convenience routines to walk all statements of a gimple function.
507
508    For each statement, we invoke CALLBACK via walk_tree.  The passed
509    data is a walk_stmt_info structure.  Of note here is a TSI that
510    points to the current statement being walked.  The VAL_ONLY flag
511    that indicates whether the *TP being examined may be replaced 
512    with something that matches is_gimple_val (if true) or something
513    slightly more complicated (if false).  "Something" technically 
514    means the common subset of is_gimple_lvalue and is_gimple_rhs, 
515    but we never try to form anything more complicated than that, so
516    we don't bother checking.  */
517
518 struct walk_stmt_info
519 {
520   walk_tree_fn callback;
521   tree_stmt_iterator tsi;
522   struct nesting_info *info;
523   bool val_only;
524 };
525
526 /* A subroutine of walk_function.  Iterate over all sub-statements of *TP.  */
527
528 static void
529 walk_stmts (struct walk_stmt_info *wi, tree *tp)
530 {
531   tree t = *tp;
532   if (!t)
533     return;
534
535   switch (TREE_CODE (t))
536     {
537     case STATEMENT_LIST:
538       {
539         tree_stmt_iterator i;
540         for (i = tsi_start (t); !tsi_end_p (i); tsi_next (&i))
541           {
542             wi->tsi = i;
543             walk_stmts (wi, tsi_stmt_ptr (i));
544           }
545       }
546       break;
547
548     case COND_EXPR:
549       walk_tree (&COND_EXPR_COND (t), wi->callback, wi, NULL);
550       walk_stmts (wi, &COND_EXPR_THEN (t));
551       walk_stmts (wi, &COND_EXPR_ELSE (t));
552       break;
553     case CATCH_EXPR:
554       walk_stmts (wi, &CATCH_BODY (t));
555       break;
556     case EH_FILTER_EXPR:
557       walk_stmts (wi, &EH_FILTER_FAILURE (t));
558       break;
559     case TRY_CATCH_EXPR:
560     case TRY_FINALLY_EXPR:
561       walk_stmts (wi, &TREE_OPERAND (t, 0));
562       walk_stmts (wi, &TREE_OPERAND (t, 1));
563       break;
564     case BIND_EXPR:
565       walk_stmts (wi, &BIND_EXPR_BODY (t));
566       break;
567
568     case RETURN_EXPR:
569       walk_stmts (wi, &TREE_OPERAND (t, 0));
570       break;
571
572     case MODIFY_EXPR:
573       /* The immediate arguments of a MODIFY_EXPR may use COMPONENT_REF.  */
574       wi->val_only = false;
575       walk_tree (&TREE_OPERAND (t, 0), wi->callback, wi, NULL);
576       wi->val_only = false;
577       walk_tree (&TREE_OPERAND (t, 1), wi->callback, wi, NULL);
578       wi->val_only = true;
579       break;
580
581     default:
582       wi->val_only = true;
583       walk_tree (tp, wi->callback, wi, NULL);
584       break;
585     }
586 }
587
588 /* Invoke CALLBACK on all statements of INFO->CONTEXT.  */
589
590 static void
591 walk_function (walk_tree_fn callback, struct nesting_info *info)
592 {
593   struct walk_stmt_info wi;
594
595   memset (&wi, 0, sizeof (wi));
596   wi.callback = callback;
597   wi.info = info;
598   wi.val_only = true;
599
600   walk_stmts (&wi, &DECL_SAVED_TREE (info->context));
601 }
602
603 /* Similarly for ROOT and all functions nested underneath, depth first.  */
604     
605 static void
606 walk_all_functions (walk_tree_fn callback, struct nesting_info *root)
607 {
608   do
609     {
610       if (root->inner)
611         walk_all_functions (callback, root->inner);
612       walk_function (callback, root);
613       root = root->next;
614     }
615   while (root);
616 }
617
618 \f
619 /* Construct our local datastructure describing the function nesting
620    tree rooted by CGN.  */
621
622 static struct nesting_info *
623 create_nesting_tree (struct cgraph_node *cgn)
624 {
625   struct nesting_info *info = xcalloc (1, sizeof (*info));
626   info->var_map = htab_create (7, var_map_hash, var_map_eq, free);
627   info->context = cgn->decl;
628
629   for (cgn = cgn->nested; cgn ; cgn = cgn->next_nested)
630     {
631       struct nesting_info *sub = create_nesting_tree (cgn);
632       sub->outer = info;
633       sub->next = info->inner;
634       info->inner = sub;
635     }
636
637   return info;
638 }
639
640 /* Return an expression computing the static chain for TARGET_CONTEXT
641    from INFO->CONTEXT.  Insert any necessary computations before TSI.  */
642
643 static tree
644 get_static_chain (struct nesting_info *info, tree target_context,
645                   tree_stmt_iterator *tsi)
646 {
647   struct nesting_info *i;
648   tree x;
649
650   if (info->context == target_context)
651     {
652       x = build_addr (info->frame_decl);
653     }
654   else
655     {
656       x = get_chain_decl (info);
657
658       for (i = info->outer; i->context != target_context; i = i->outer)
659         {
660           tree field = get_chain_field (i);
661
662           x = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (x)), x);
663           x = build (COMPONENT_REF, TREE_TYPE (field), x, field, NULL_TREE);
664           x = init_tmp_var (info, x, tsi);
665         }
666     }
667
668   return x;
669 }
670
671 /* Return an expression referencing FIELD from TARGET_CONTEXT's non-local
672    frame as seen from INFO->CONTEXT.  Insert any necessary computations
673    before TSI.  */
674
675 static tree
676 get_frame_field (struct nesting_info *info, tree target_context,
677                  tree field, tree_stmt_iterator *tsi)
678 {
679   struct nesting_info *i;
680   tree x;
681
682   if (info->context == target_context)
683     {
684       /* Make sure frame_decl gets created.  */
685       (void) get_frame_type (info);
686       x = info->frame_decl;
687     }
688   else
689     {
690       x = get_chain_decl (info);
691
692       for (i = info->outer; i->context != target_context; i = i->outer)
693         {
694           tree field = get_chain_field (i);
695
696           x = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (x)), x);
697           x = build (COMPONENT_REF, TREE_TYPE (field), x, field, NULL_TREE);
698           x = init_tmp_var (info, x, tsi);
699         }
700
701       x = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (x)), x);
702     }
703
704   x = build (COMPONENT_REF, TREE_TYPE (field), x, field, NULL_TREE);
705   return x;
706 }
707
708 /* Called via walk_function+walk_tree, rewrite all references to VAR
709    and PARM_DECLs that belong to outer functions.
710
711    The rewrite will involve some number of structure accesses back up
712    the static chain.  E.g. for a variable FOO up one nesting level it'll
713    be CHAIN->FOO.  For two levels it'll be CHAIN->__chain->FOO.  Further
714    indirections apply to decls for which use_pointer_in_frame is true.  */
715
716 static tree
717 convert_nonlocal_reference (tree *tp, int *walk_subtrees, void *data)
718 {
719   struct walk_stmt_info *wi = data;
720   struct nesting_info *info = wi->info;
721   tree t = *tp;
722
723   *walk_subtrees = 0;
724   switch (TREE_CODE (t))
725     {
726     case VAR_DECL:
727       /* Non-automatic variables are never processed.  */
728       if (TREE_STATIC (t) || DECL_EXTERNAL (t))
729         break;
730       /* FALLTHRU */
731
732     case PARM_DECL:
733       if (decl_function_context (t) != info->context)
734         {
735           tree target_context = decl_function_context (t);
736           struct nesting_info *i;
737           tree x;
738
739           for (i = info->outer; i->context != target_context; i = i->outer)
740             continue;
741           x = lookup_field_for_decl (i, t, INSERT);
742           x = get_frame_field (info, target_context, x, &wi->tsi);
743           if (use_pointer_in_frame (t))
744             {
745               x = init_tmp_var (info, x, &wi->tsi);
746               x = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (x)), x);
747             }
748           if (wi->val_only)
749             x = init_tmp_var (info, x, &wi->tsi);
750
751           *tp = x;
752         }
753       break;
754
755     case GOTO_EXPR:
756       /* Don't walk non-local gotos for now.  */
757       if (TREE_CODE (GOTO_DESTINATION (t)) != LABEL_DECL)
758         {
759           *walk_subtrees = 1;
760           wi->val_only = true;
761         }
762       break;
763
764     case LABEL_DECL:
765       /* We're taking the address of a label from a parent function, but
766          this is not itself a non-local goto.  Mark the label such that it
767          will not be deleted, much as we would with a label address in
768          static storage.  */
769       if (decl_function_context (t) != info->context)
770         FORCED_LABEL (t) = 1;
771       break;
772
773     case ADDR_EXPR:
774       {
775         bool save_val_only = wi->val_only;
776         tree save_sub = TREE_OPERAND (t, 0);
777
778         wi->val_only = false;
779         walk_tree (&TREE_OPERAND (t, 0), convert_nonlocal_reference, wi, NULL);
780         wi->val_only = true;
781
782         if (save_sub != TREE_OPERAND (t, 0))
783           {
784             /* If we changed anything, then TREE_INVARIANT is be wrong,
785                since we're no longer directly referencing a decl.  */
786             TREE_INVARIANT (t) = 0;
787
788             /* If the callback converted the address argument in a context
789                where we only accept variables (and min_invariant, presumably),
790                then compute the address into a temporary.  */
791             if (save_val_only)
792               *tp = gimplify_val (wi->info, t, &wi->tsi);
793           }
794       }
795       break;
796
797     case REALPART_EXPR:
798     case IMAGPART_EXPR:
799     case COMPONENT_REF:
800     case ARRAY_REF:
801     case ARRAY_RANGE_REF:
802     case BIT_FIELD_REF:
803       /* Go down this entire nest and just look at the final prefix and
804          anything that describes the references.  Otherwise, we lose track
805          of whether a NOP_EXPR or VIEW_CONVERT_EXPR needs a simple value.  */
806       wi->val_only = true;
807       for (; handled_component_p (t)
808            || TREE_CODE (t) == REALPART_EXPR || TREE_CODE (t) == IMAGPART_EXPR;
809            tp = &TREE_OPERAND (t, 0), t = *tp)
810         {
811           if (TREE_CODE (t) == COMPONENT_REF)
812             walk_tree (&TREE_OPERAND (t, 2), convert_nonlocal_reference, wi,
813                        NULL);
814           else if (TREE_CODE (t) == ARRAY_REF
815                    || TREE_CODE (t) == ARRAY_RANGE_REF)
816             {
817               walk_tree (&TREE_OPERAND (t, 1), convert_nonlocal_reference, wi,
818                          NULL);
819               walk_tree (&TREE_OPERAND (t, 2), convert_nonlocal_reference, wi,
820                          NULL);
821               walk_tree (&TREE_OPERAND (t, 3), convert_nonlocal_reference, wi,
822                          NULL);
823             }
824           else if (TREE_CODE (t) == BIT_FIELD_REF)
825             {
826               walk_tree (&TREE_OPERAND (t, 1), convert_nonlocal_reference, wi,
827                          NULL);
828               walk_tree (&TREE_OPERAND (t, 2), convert_nonlocal_reference, wi,
829                          NULL);
830             }
831         }
832       wi->val_only = false;
833       walk_tree (tp, convert_nonlocal_reference, wi, NULL);
834       break;
835
836     default:
837       if (!DECL_P (t) && !TYPE_P (t))
838         {
839           *walk_subtrees = 1;
840           wi->val_only = true;
841         }
842       break;
843     }
844
845   return NULL_TREE;
846 }
847
848 /* Called via walk_function+walk_tree, rewrite all references to VAR
849    and PARM_DECLs that were referenced by inner nested functions.
850    The rewrite will be a structure reference to the local frame variable.  */
851
852 static tree
853 convert_local_reference (tree *tp, int *walk_subtrees, void *data)
854 {
855   struct walk_stmt_info *wi = data;
856   struct nesting_info *info = wi->info;
857   tree t = *tp, field, x, y;
858
859   switch (TREE_CODE (t))
860     {
861     case VAR_DECL:
862       /* Non-automatic variables are never processed.  */
863       if (TREE_STATIC (t) || DECL_EXTERNAL (t))
864         break;
865       /* FALLTHRU */
866
867     case PARM_DECL:
868       if (decl_function_context (t) == info->context)
869         {
870           /* If we copied a pointer to the frame, then the original decl
871              is used unchanged in the parent function.  */
872           if (use_pointer_in_frame (t))
873             break;
874
875           /* No need to transform anything if no child references the
876              variable.  */
877           field = lookup_field_for_decl (info, t, NO_INSERT);
878           if (!field)
879             break;
880
881           x = get_frame_field (info, info->context, field, &wi->tsi);
882           if (wi->val_only)
883             x = init_tmp_var (info, x, &wi->tsi);
884           *tp = x;
885         }
886       break;
887
888     case ADDR_EXPR:
889       {
890         bool save_val_only = wi->val_only;
891         tree save_sub = TREE_OPERAND (t, 0);
892
893         wi->val_only = false;
894         walk_tree (&TREE_OPERAND (t, 0), convert_local_reference, wi, NULL);
895         wi->val_only = save_val_only;
896
897         /* If we converted anything ... */
898         if (TREE_OPERAND (t, 0) != save_sub)
899           {
900             /* Then the frame decl is now addressable.  */
901             TREE_ADDRESSABLE (info->frame_decl) = 1;
902
903             /* If we are in a context where we only accept values, then
904                compute the address into a temporary.  */
905             if (save_val_only)
906               *tp = gimplify_val (wi->info, t, &wi->tsi);
907           }
908       }
909       break;
910
911     case CALL_EXPR:
912       *walk_subtrees = 1;
913
914       /* Ready for some fun?  We need to recognize
915             __builtin_stack_alloc (&x, n)
916          and insert
917             FRAME.x = &x
918          after that.  X should have use_pointer_in_frame set.  We can't
919          do this any earlier, since we can't meaningfully evaluate &x.  */
920
921       x = get_callee_fndecl (t);
922       if (!x || DECL_BUILT_IN_CLASS (x) != BUILT_IN_NORMAL)
923         break;
924       if (DECL_FUNCTION_CODE (x) != BUILT_IN_STACK_ALLOC)
925         break;
926       t = TREE_VALUE (TREE_OPERAND (t, 1));
927       if (TREE_CODE (t) != ADDR_EXPR)
928         abort ();
929       t = TREE_OPERAND (t, 0);
930       if (TREE_CODE (t) != VAR_DECL)
931         abort ();
932       field = lookup_field_for_decl (info, t, NO_INSERT);
933       if (!field)
934         break;
935       if (!use_pointer_in_frame (t))
936         abort ();
937
938       x = build_addr (t);
939       y = get_frame_field (info, info->context, field, &wi->tsi);
940       x = build (MODIFY_EXPR, void_type_node, y, x);
941       SET_EXPR_LOCUS (x, EXPR_LOCUS (tsi_stmt (wi->tsi)));
942       tsi_link_after (&wi->tsi, x, TSI_SAME_STMT);
943       break;
944
945     case REALPART_EXPR:
946     case IMAGPART_EXPR:
947     case COMPONENT_REF:
948     case ARRAY_REF:
949     case ARRAY_RANGE_REF:
950     case BIT_FIELD_REF:
951       /* Go down this entire nest and just look at the final prefix and
952          anything that describes the references.  Otherwise, we lose track
953          of whether a NOP_EXPR or VIEW_CONVERT_EXPR needs a simple value.  */
954       wi->val_only = true;
955       for (; handled_component_p (t)
956            || TREE_CODE (t) == REALPART_EXPR || TREE_CODE (t) == IMAGPART_EXPR;
957            tp = &TREE_OPERAND (t, 0), t = *tp)
958         {
959           if (TREE_CODE (t) == COMPONENT_REF)
960             walk_tree (&TREE_OPERAND (t, 2), convert_local_reference, wi,
961                        NULL);
962           else if (TREE_CODE (t) == ARRAY_REF
963                    || TREE_CODE (t) == ARRAY_RANGE_REF)
964             {
965               walk_tree (&TREE_OPERAND (t, 1), convert_local_reference, wi,
966                          NULL);
967               walk_tree (&TREE_OPERAND (t, 2), convert_local_reference, wi,
968                          NULL);
969               walk_tree (&TREE_OPERAND (t, 3), convert_local_reference, wi,
970                          NULL);
971             }
972           else if (TREE_CODE (t) == BIT_FIELD_REF)
973             {
974               walk_tree (&TREE_OPERAND (t, 1), convert_local_reference, wi,
975                          NULL);
976               walk_tree (&TREE_OPERAND (t, 2), convert_local_reference, wi,
977                          NULL);
978             }
979         }
980       wi->val_only = false;
981       walk_tree (tp, convert_local_reference, wi, NULL);
982       break;
983
984     default:
985       if (!DECL_P (t) && !TYPE_P (t))
986         {
987           *walk_subtrees = 1;
988           wi->val_only = true;
989         }
990       break;
991     }
992
993   return NULL_TREE;
994 }
995
996 /* Called via walk_function+walk_tree, rewrite all GOTO_EXPRs that 
997    reference labels from outer functions.  The rewrite will be a 
998    call to __builtin_nonlocal_goto.  */
999
1000 static tree
1001 convert_nl_goto_reference (tree *tp, int *walk_subtrees, void *data)
1002 {
1003   struct walk_stmt_info *wi = data;
1004   struct nesting_info *info = wi->info, *i;
1005   tree t = *tp, label, new_label, target_context, x, arg, field;
1006   struct var_map_elt *elt;
1007   void **slot;
1008
1009   *walk_subtrees = 0;
1010   if (TREE_CODE (t) != GOTO_EXPR)
1011     return NULL_TREE;
1012   label = GOTO_DESTINATION (t);
1013   if (TREE_CODE (label) != LABEL_DECL)
1014     return NULL_TREE;
1015   target_context = decl_function_context (label);
1016   if (target_context == info->context)
1017     return NULL_TREE;
1018
1019   for (i = info->outer; target_context != i->context; i = i->outer)
1020     continue;
1021
1022   /* The original user label may also be use for a normal goto, therefore
1023      we must create a new label that will actually receive the abnormal
1024      control transfer.  This new label will be marked LABEL_NONLOCAL; this
1025      mark will trigger proper behavior in the cfg, as well as cause the
1026      (hairy target-specific) non-local goto receiver code to be generated
1027      when we expand rtl.  */
1028   new_label = create_artificial_label ();
1029   DECL_NONLOCAL (new_label) = 1;
1030
1031   /* Enter this association into var_map so that we can insert the new
1032      label into the IL during a second pass.  */
1033   elt = xmalloc (sizeof (*elt));
1034   elt->old = label;
1035   elt->new = new_label;
1036   slot = htab_find_slot (i->var_map, elt, INSERT);
1037   *slot = elt;
1038   
1039   /* Build: __builtin_nl_goto(new_label, &chain->nl_goto_field).  */
1040   field = get_nl_goto_field (i);
1041   x = get_frame_field (info, target_context, field, &wi->tsi);
1042   x = build_addr (x);
1043   x = gimplify_val (info, x, &wi->tsi);
1044   arg = tree_cons (NULL, x, NULL);
1045   x = build_addr (new_label);
1046   arg = tree_cons (NULL, x, arg);
1047   x = implicit_built_in_decls[BUILT_IN_NONLOCAL_GOTO];
1048   x = build_function_call_expr (x, arg);
1049
1050   SET_EXPR_LOCUS (x, EXPR_LOCUS (tsi_stmt (wi->tsi)));
1051   *tsi_stmt_ptr (wi->tsi) = x;
1052
1053   return NULL_TREE;
1054 }
1055
1056 /* Called via walk_function+walk_tree, rewrite all LABEL_EXPRs that 
1057    are referenced via nonlocal goto from a nested function.  The rewrite
1058    will involve installing a newly generated DECL_NONLOCAL label, and
1059    (potentially) a branch around the rtl gunk that is assumed to be 
1060    attached to such a label.  */
1061
1062 static tree
1063 convert_nl_goto_receiver (tree *tp, int *walk_subtrees, void *data)
1064 {
1065   struct walk_stmt_info *wi = data;
1066   struct nesting_info *info = wi->info;
1067   tree t = *tp, label, new_label, x;
1068   struct var_map_elt *elt, dummy;
1069   tree_stmt_iterator tmp_tsi;
1070
1071   *walk_subtrees = 0;
1072   if (TREE_CODE (t) != LABEL_EXPR)
1073     return NULL_TREE;
1074   label = LABEL_EXPR_LABEL (t);
1075
1076   dummy.old = label;
1077   elt = htab_find (info->var_map, &dummy);
1078   if (!elt)
1079     return NULL_TREE;
1080   new_label = elt->new;
1081
1082   /* If there's any possibility that the previous statement falls through,
1083      then we must branch around the new non-local label.  */
1084   tmp_tsi = wi->tsi;
1085   tsi_prev (&tmp_tsi);
1086   if (tsi_end_p (tmp_tsi) || block_may_fallthru (tsi_stmt (tmp_tsi)))
1087     {
1088       x = build1 (GOTO_EXPR, void_type_node, label);
1089       tsi_link_before (&wi->tsi, x, TSI_SAME_STMT);
1090     }
1091   x = build1 (LABEL_EXPR, void_type_node, new_label);
1092   tsi_link_before (&wi->tsi, x, TSI_SAME_STMT);
1093
1094   return NULL_TREE;
1095 }
1096
1097 /* Called via walk_function+walk_tree, rewrite all references to addresses
1098    of nested functions that require the use of trampolines.  The rewrite
1099    will involve a reference a trampoline generated for the occasion.  */
1100
1101 static tree
1102 convert_tramp_reference (tree *tp, int *walk_subtrees, void *data)
1103 {
1104   struct walk_stmt_info *wi = data;
1105   struct nesting_info *info = wi->info, *i;
1106   tree t = *tp, decl, target_context, x, arg;
1107
1108   *walk_subtrees = 0;
1109   switch (TREE_CODE (t))
1110     {
1111     case ADDR_EXPR:
1112       /* Build
1113            T.1 = &CHAIN->tramp;
1114            T.2 = __builtin_adjust_trampoline (T.1);
1115            T.3 = (func_type)T.2;
1116       */
1117
1118       decl = TREE_OPERAND (t, 0);
1119       if (TREE_CODE (decl) != FUNCTION_DECL)
1120         break;
1121
1122       /* Only need to process nested functions.  */
1123       target_context = decl_function_context (decl);
1124       if (!target_context)
1125         break;
1126
1127       /* If the nested function doesn't use a static chain, then
1128          it doesn't need a trampoline.  */
1129       if (DECL_NO_STATIC_CHAIN (decl))
1130         break;
1131
1132       /* Lookup the immediate parent of the callee, as that's where
1133          we need to insert the trampoline.  */
1134       for (i = info; i->context != target_context; i = i->outer)
1135         continue;
1136       x = lookup_tramp_for_decl (i, decl, INSERT);
1137
1138       /* Compute the address of the field holding the trampoline.  */
1139       x = get_frame_field (info, target_context, x, &wi->tsi);
1140       x = build_addr (x);
1141       x = gimplify_val (info, x, &wi->tsi);
1142       arg = tree_cons (NULL, x, NULL);
1143
1144       /* Do machine-specific ugliness.  Normally this will involve
1145          computing extra alignment, but it can really be anything.  */
1146       x = implicit_built_in_decls[BUILT_IN_ADJUST_TRAMPOLINE];
1147       x = build_function_call_expr (x, arg);
1148       x = init_tmp_var (info, x, &wi->tsi);
1149
1150       /* Cast back to the proper function type.  */
1151       x = build1 (NOP_EXPR, TREE_TYPE (t), x);
1152       x = init_tmp_var (info, x, &wi->tsi);
1153
1154       *tp = x;
1155       break;
1156
1157     case CALL_EXPR:
1158       /* Only walk call arguments, lest we generate trampolines for
1159          direct calls.  */
1160       walk_tree (&TREE_OPERAND (t, 1), convert_tramp_reference, wi, NULL);
1161       break;
1162
1163     default:
1164       if (!DECL_P (t) && !TYPE_P (t))
1165         *walk_subtrees = 1;
1166       break;
1167     }
1168
1169   return NULL_TREE;
1170 }
1171
1172 /* Called via walk_function+walk_tree, rewrite all CALL_EXPRs that 
1173    reference nested functions to make sure that the static chain is
1174    set up properly for the call.  */
1175
1176 static tree
1177 convert_call_expr (tree *tp, int *walk_subtrees, void *data)
1178 {
1179   struct walk_stmt_info *wi = data;
1180   struct nesting_info *info = wi->info;
1181   tree t = *tp, decl, target_context;
1182
1183   *walk_subtrees = 0;
1184   switch (TREE_CODE (t))
1185     {
1186     case CALL_EXPR:
1187       decl = get_callee_fndecl (t);
1188       if (!decl)
1189         break;
1190       target_context = decl_function_context (decl);
1191       if (target_context && !DECL_NO_STATIC_CHAIN (decl))
1192         TREE_OPERAND (t, 2)
1193           = get_static_chain (info, target_context, &wi->tsi);
1194       break;
1195
1196     case RETURN_EXPR:
1197     case MODIFY_EXPR:
1198       /* Only return and modify may contain calls.  */
1199       *walk_subtrees = 1;
1200       break;
1201
1202     default:
1203       break;
1204     }
1205
1206   return NULL_TREE;
1207 }
1208
1209 /* Walk the nesting tree starting with ROOT, depth first.  Convert all
1210    trampolines and call expressions.  On the way back up, determine if
1211    a nested function actually uses its static chain; if not, remember that.  */
1212
1213 static void
1214 convert_all_function_calls (struct nesting_info *root)
1215 {
1216   do
1217     {
1218       if (root->inner)
1219         convert_all_function_calls (root->inner);
1220
1221       walk_function (convert_tramp_reference, root);
1222       walk_function (convert_call_expr, root);
1223
1224       /* If the function does not use a static chain, then remember that.  */
1225       if (root->outer && !root->chain_decl && !root->chain_field)
1226         DECL_NO_STATIC_CHAIN (root->context) = 1;
1227       else
1228         {
1229 #ifdef ENABLE_CHECKING
1230           if (DECL_NO_STATIC_CHAIN (root->context))
1231             abort ();
1232 #endif
1233         }
1234
1235       root = root->next;
1236     }
1237   while (root);
1238 }
1239
1240 /* Do "everything else" to clean up or complete state collected by the
1241    various walking passes -- lay out the types and decls, generate code
1242    to initialize the frame decl, store critical expressions in the
1243    struct function for rtl to find.  */
1244
1245 static void
1246 finalize_nesting_tree_1 (struct nesting_info *root)
1247 {
1248   tree stmt_list = NULL;
1249   tree context = root->context;
1250   struct function *sf;
1251
1252   /* If we created a non-local frame type or decl, we need to lay them
1253      out at this time.  */
1254   if (root->frame_type)
1255     {
1256       layout_type (root->frame_type);
1257       layout_decl (root->frame_decl, 0);
1258     }
1259
1260   /* If any parameters were referenced non-locally, then we need to 
1261      insert a copy.  Likewise, if any variables were referenced by
1262      pointer, we need to initialize the address.  */
1263   if (root->any_parm_remapped)
1264     {
1265       tree p;
1266       for (p = DECL_ARGUMENTS (context); p ; p = TREE_CHAIN (p))
1267         {
1268           tree field, x, y;
1269
1270           field = lookup_field_for_decl (root, p, NO_INSERT);
1271           if (!field)
1272             continue;
1273
1274           if (use_pointer_in_frame (p))
1275             x = build_addr (p);
1276           else
1277             x = p;
1278
1279           y = build (COMPONENT_REF, TREE_TYPE (field),
1280                      root->frame_decl, field, NULL_TREE);
1281           x = build (MODIFY_EXPR, TREE_TYPE (field), y, x);
1282           append_to_statement_list (x, &stmt_list);
1283         }
1284     }
1285
1286   /* If a chain_field was created, then it needs to be initialized
1287      from chain_decl.  */
1288   if (root->chain_field)
1289     {
1290       tree x = build (COMPONENT_REF, TREE_TYPE (root->chain_field),
1291                       root->frame_decl, root->chain_field, NULL_TREE);
1292       x = build (MODIFY_EXPR, TREE_TYPE (x), x, get_chain_decl (root));
1293       append_to_statement_list (x, &stmt_list);
1294     }
1295
1296   /* If trampolines were created, then we need to initialize them.  */
1297   if (root->any_tramp_created)
1298     {
1299       struct nesting_info *i;
1300       for (i = root->inner; i ; i = i->next)
1301         {
1302           tree arg, x, field;
1303
1304           field = lookup_tramp_for_decl (root, i->context, NO_INSERT);
1305           if (!field)
1306             continue;
1307
1308           if (DECL_NO_STATIC_CHAIN (i->context))
1309             x = null_pointer_node;
1310           else
1311             x = build_addr (root->frame_decl);
1312           arg = tree_cons (NULL, x, NULL);
1313
1314           x = build_addr (i->context);
1315           arg = tree_cons (NULL, x, arg);
1316
1317           x = build (COMPONENT_REF, TREE_TYPE (field),
1318                      root->frame_decl, field, NULL_TREE);
1319           x = build_addr (x);
1320           arg = tree_cons (NULL, x, arg);
1321
1322           x = implicit_built_in_decls[BUILT_IN_INIT_TRAMPOLINE];
1323           x = build_function_call_expr (x, arg);
1324
1325           append_to_statement_list (x, &stmt_list);
1326         }
1327     }
1328
1329   /* If we created initialization statements, insert them.  */
1330   if (stmt_list)
1331     {
1332       annotate_all_with_locus (&stmt_list,
1333                                DECL_SOURCE_LOCATION (context));
1334       append_to_statement_list (BIND_EXPR_BODY (DECL_SAVED_TREE (context)),
1335                                 &stmt_list);
1336       BIND_EXPR_BODY (DECL_SAVED_TREE (context)) = stmt_list;
1337     }
1338
1339   /* If a chain_decl was created, then it needs to be registered with
1340      struct function so that it gets initialized from the static chain
1341      register at the beginning of the function.  */
1342   sf = DECL_STRUCT_FUNCTION (root->context);
1343   sf->static_chain_decl = root->chain_decl;
1344
1345   /* Similarly for the non-local goto save area.  */
1346   if (root->nl_goto_field)
1347     {
1348       sf->nonlocal_goto_save_area
1349         = get_frame_field (root, context, root->nl_goto_field, NULL);
1350       sf->has_nonlocal_label = 1;
1351     }
1352
1353   /* Make sure all new local variables get inserted into the
1354      proper BIND_EXPR.  */
1355   if (root->new_local_var_chain)
1356     declare_tmp_vars (root->new_local_var_chain,
1357                       DECL_SAVED_TREE (root->context));
1358
1359   /* Dump the translated tree function.  */
1360   dump_function (TDI_nested, root->context);
1361 }
1362
1363 static void
1364 finalize_nesting_tree (struct nesting_info *root)
1365 {
1366   do
1367     {
1368       if (root->inner)
1369         finalize_nesting_tree (root->inner);
1370       finalize_nesting_tree_1 (root);
1371       root = root->next;
1372     }
1373   while (root);
1374 }
1375
1376 /* Free the data structures allocated during this pass.  */
1377
1378 static void
1379 free_nesting_tree (struct nesting_info *root)
1380 {
1381   struct nesting_info *next;
1382   do
1383     {
1384       if (root->inner)
1385         free_nesting_tree (root->inner);
1386       htab_delete (root->var_map);
1387       next = root->next;
1388       free (root);
1389       root = next;
1390     }
1391   while (root);
1392 }
1393
1394 /* Main entry point for this pass.  Process FNDECL and all of its nested
1395    subroutines and turn them into something less tightly bound.  */
1396
1397 void
1398 lower_nested_functions (tree fndecl)
1399 {
1400   struct nesting_info *root;
1401   struct cgraph_node *cgn;
1402
1403   /* If there are no nested functions, there's nothing to do.  */
1404   cgn = cgraph_node (fndecl);
1405   if (!cgn->nested)
1406     return;
1407
1408   root = create_nesting_tree (cgn);
1409   walk_all_functions (convert_nonlocal_reference, root);
1410   walk_all_functions (convert_local_reference, root);
1411   walk_all_functions (convert_nl_goto_reference, root);
1412   walk_all_functions (convert_nl_goto_receiver, root);
1413   convert_all_function_calls (root);
1414   finalize_nesting_tree (root);
1415   free_nesting_tree (root);
1416 }
1417
1418 #include "gt-tree-nested.h"