Create startup files from the GCC sources and drop our versions.
[dragonfly.git] / contrib / gcc-4.0 / gcc / cgraph.c
1 /* Callgraph handling code.
2    Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
3    Contributed by Jan Hubicka
4
5 This file is part of GCC.
6
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 2, or (at your option) any later
10 version.
11
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
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING.  If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA.  */
21
22 /*  This file contains basic routines manipulating call graph and variable pool
23   
24 The callgraph:
25
26     The call-graph is data structure designed for intra-procedural optimization
27     but it is also used in non-unit-at-a-time compilation to allow easier code
28     sharing.
29
30     The call-graph consist of nodes and edges represented via linked lists.
31     Each function (external or not) corresponds to the unique node (in
32     contrast to tree DECL nodes where we can have multiple nodes for each
33     function).
34
35     The mapping from declarations to call-graph nodes is done using hash table
36     based on DECL_ASSEMBLER_NAME, so it is essential for assembler name to
37     not change once the declaration is inserted into the call-graph.
38     The call-graph nodes are created lazily using cgraph_node function when
39     called for unknown declaration.
40     
41     When built, there is one edge for each direct call.  It is possible that
42     the reference will be later optimized out.  The call-graph is built
43     conservatively in order to make conservative data flow analysis possible.
44
45     The callgraph at the moment does not represent indirect calls or calls
46     from other compilation unit.  Flag NEEDED is set for each node that may
47     be accessed in such an invisible way and it shall be considered an
48     entry point to the callgraph.
49
50     Intraprocedural information:
51
52       Callgraph is place to store data needed for intraprocedural optimization.
53       All data structures are divided into three components: local_info that
54       is produced while analyzing the function, global_info that is result
55       of global walking of the callgraph on the end of compilation and
56       rtl_info used by RTL backend to propagate data from already compiled
57       functions to their callers.
58
59     Inlining plans:
60
61       The function inlining information is decided in advance and maintained
62       in the callgraph as so called inline plan.
63       For each inlined call, the callee's node is cloned to represent the
64       new function copy produced by inliner.
65       Each inlined call gets a unique corresponding clone node of the callee
66       and the data structure is updated while inlining is performed, so
67       the clones are eliminated and their callee edges redirected to the
68       caller. 
69
70       Each edge has "inline_failed" field.  When the field is set to NULL,
71       the call will be inlined.  When it is non-NULL it contains a reason
72       why inlining wasn't performed.
73
74
75 The varpool data structure:
76
77     Varpool is used to maintain variables in similar manner as call-graph
78     is used for functions.  Most of the API is symmetric replacing cgraph
79     function prefix by cgraph_varpool  */
80
81
82 #include "config.h"
83 #include "system.h"
84 #include "coretypes.h"
85 #include "tm.h"
86 #include "tree.h"
87 #include "langhooks.h"
88 #include "hashtab.h"
89 #include "toplev.h"
90 #include "flags.h"
91 #include "ggc.h"
92 #include "debug.h"
93 #include "target.h"
94 #include "cgraph.h"
95 #include "varray.h"
96 #include "output.h"
97 #include "intl.h"
98
99 static void cgraph_node_remove_callers (struct cgraph_node *node);
100 static inline void cgraph_edge_remove_caller (struct cgraph_edge *e);
101 static inline void cgraph_edge_remove_callee (struct cgraph_edge *e);
102
103 /* Hash table used to convert declarations into nodes.  */
104 static GTY((param_is (struct cgraph_node))) htab_t cgraph_hash;
105
106 /* The linked list of cgraph nodes.  */
107 struct cgraph_node *cgraph_nodes;
108
109 /* Queue of cgraph nodes scheduled to be lowered.  */
110 struct cgraph_node *cgraph_nodes_queue;
111
112 /* Number of nodes in existence.  */
113 int cgraph_n_nodes;
114
115 /* Maximal uid used in cgraph nodes.  */
116 int cgraph_max_uid;
117
118 /* Set when whole unit has been analyzed so we can access global info.  */
119 bool cgraph_global_info_ready = false;
120
121 /* Hash table used to convert declarations into nodes.  */
122 static GTY((param_is (struct cgraph_varpool_node))) htab_t cgraph_varpool_hash;
123
124 /* Queue of cgraph nodes scheduled to be lowered and output.  */
125 struct cgraph_varpool_node *cgraph_varpool_nodes_queue;
126
127 /* The linked list of cgraph varpool nodes.  */
128 static GTY(())  struct cgraph_varpool_node *cgraph_varpool_nodes;
129
130 static hashval_t hash_node (const void *);
131 static int eq_node (const void *, const void *);
132
133 /* Returns a hash code for P.  */
134
135 static hashval_t
136 hash_node (const void *p)
137 {
138   const struct cgraph_node *n = p;
139   return (hashval_t) DECL_UID (n->decl);
140 }
141
142 /* Returns nonzero if P1 and P2 are equal.  */
143
144 static int
145 eq_node (const void *p1, const void *p2)
146 {
147   const struct cgraph_node *n1 = p1, *n2 = p2;
148   return DECL_UID (n1->decl) == DECL_UID (n2->decl);
149 }
150
151 /* Allocate new callgraph node and insert it into basic data structures.  */
152 static struct cgraph_node *
153 cgraph_create_node (void)
154 {
155   struct cgraph_node *node;
156
157   node = ggc_alloc_cleared (sizeof (*node));
158   node->next = cgraph_nodes;
159   node->uid = cgraph_max_uid++;
160   if (cgraph_nodes)
161     cgraph_nodes->previous = node;
162   node->previous = NULL;
163   cgraph_nodes = node;
164   cgraph_n_nodes++;
165   return node;
166 }
167
168 /* Return cgraph node assigned to DECL.  Create new one when needed.  */
169 struct cgraph_node *
170 cgraph_node (tree decl)
171 {
172   struct cgraph_node key, *node, **slot;
173
174   gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
175
176   if (!cgraph_hash)
177     cgraph_hash = htab_create_ggc (10, hash_node, eq_node, NULL);
178
179   key.decl = decl;
180
181   slot = (struct cgraph_node **) htab_find_slot (cgraph_hash, &key, INSERT);
182
183   if (*slot)
184     return *slot;
185
186   node = cgraph_create_node ();
187   node->decl = decl;
188   *slot = node;
189   if (DECL_CONTEXT (decl) && TREE_CODE (DECL_CONTEXT (decl)) == FUNCTION_DECL)
190     {
191       node->origin = cgraph_node (DECL_CONTEXT (decl));
192       node->next_nested = node->origin->nested;
193       node->origin->nested = node;
194     }
195   return node;
196 }
197
198 /* Compare ASMNAME with the DECL_ASSEMBLER_NAME of DECL.  */
199
200 static bool
201 decl_assembler_name_equal (tree decl, tree asmname)
202 {
203   tree decl_asmname = DECL_ASSEMBLER_NAME (decl);
204
205   if (decl_asmname == asmname)
206     return true;
207
208   /* If the target assembler name was set by the user, things are trickier.
209      We have a leading '*' to begin with.  After that, it's arguable what
210      is the correct thing to do with -fleading-underscore.  Arguably, we've
211      historically been doing the wrong thing in assemble_alias by always
212      printing the leading underscore.  Since we're not changing that, make
213      sure user_label_prefix follows the '*' before matching.  */
214   if (IDENTIFIER_POINTER (decl_asmname)[0] == '*')
215     {
216       const char *decl_str = IDENTIFIER_POINTER (decl_asmname) + 1;
217       size_t ulp_len = strlen (user_label_prefix);
218
219       if (ulp_len == 0)
220         ;
221       else if (strncmp (decl_str, user_label_prefix, ulp_len) == 0)
222         decl_str += ulp_len;
223       else
224         return false;
225
226       return strcmp (decl_str, IDENTIFIER_POINTER (asmname)) == 0;
227     }
228
229   return false;
230 }
231
232
233 /* Return the cgraph node that has ASMNAME for its DECL_ASSEMBLER_NAME.
234    Return NULL if there's no such node.  */
235
236 struct cgraph_node *
237 cgraph_node_for_asm (tree asmname)
238 {
239   struct cgraph_node *node;
240
241   for (node = cgraph_nodes; node ; node = node->next)
242     if (decl_assembler_name_equal (node->decl, asmname))
243       return node;
244
245   return NULL;
246 }
247
248 /* Return callgraph edge representing CALL_EXPR.  */
249 struct cgraph_edge *
250 cgraph_edge (struct cgraph_node *node, tree call_expr)
251 {
252   struct cgraph_edge *e;
253
254   /* This loop may turn out to be performance problem.  In such case adding
255      hashtables into call nodes with very many edges is probably best
256      solution.  It is not good idea to add pointer into CALL_EXPR itself
257      because we want to make possible having multiple cgraph nodes representing
258      different clones of the same body before the body is actually cloned.  */
259   for (e = node->callees; e; e= e->next_callee)
260     if (e->call_expr == call_expr)
261       break;
262   return e;
263 }
264
265 /* Create edge from CALLER to CALLEE in the cgraph.  */
266
267 struct cgraph_edge *
268 cgraph_create_edge (struct cgraph_node *caller, struct cgraph_node *callee,
269                     tree call_expr)
270 {
271   struct cgraph_edge *edge = ggc_alloc (sizeof (struct cgraph_edge));
272 #ifdef ENABLE_CHECKING
273   struct cgraph_edge *e;
274
275   for (e = caller->callees; e; e = e->next_callee)
276     gcc_assert (e->call_expr != call_expr);
277 #endif
278
279   gcc_assert (TREE_CODE (call_expr) == CALL_EXPR);
280
281   if (!DECL_SAVED_TREE (callee->decl))
282     edge->inline_failed = N_("function body not available");
283   else if (callee->local.redefined_extern_inline)
284     edge->inline_failed = N_("redefined extern inline functions are not "
285                              "considered for inlining");
286   else if (callee->local.inlinable)
287     edge->inline_failed = N_("function not considered for inlining");
288   else
289     edge->inline_failed = N_("function not inlinable");
290
291   edge->aux = NULL;
292
293   edge->caller = caller;
294   edge->callee = callee;
295   edge->call_expr = call_expr;
296   edge->prev_caller = NULL;
297   edge->next_caller = callee->callers;
298   if (callee->callers)
299     callee->callers->prev_caller = edge;
300   edge->prev_callee = NULL;
301   edge->next_callee = caller->callees;
302   if (caller->callees)
303     caller->callees->prev_callee = edge;
304   caller->callees = edge;
305   callee->callers = edge;
306   return edge;
307 }
308
309 /* Remove the edge E from the list of the callers of the callee.  */
310
311 static inline void
312 cgraph_edge_remove_callee (struct cgraph_edge *e)
313 {
314   if (e->prev_caller)
315     e->prev_caller->next_caller = e->next_caller;
316   if (e->next_caller)
317     e->next_caller->prev_caller = e->prev_caller;
318   if (!e->prev_caller)
319     e->callee->callers = e->next_caller;
320 }
321
322 /* Remove the edge E from the list of the callees of the caller.  */
323
324 static inline void
325 cgraph_edge_remove_caller (struct cgraph_edge *e)
326 {
327   if (e->prev_callee)
328     e->prev_callee->next_callee = e->next_callee;
329   if (e->next_callee)
330     e->next_callee->prev_callee = e->prev_callee;
331   if (!e->prev_callee)
332     e->caller->callees = e->next_callee;
333 }
334
335 /* Remove the edge E in the cgraph.  */
336
337 void
338 cgraph_remove_edge (struct cgraph_edge *e)
339 {
340   /* Remove from callers list of the callee.  */
341   cgraph_edge_remove_callee (e);
342
343   /* Remove from callees list of the callers.  */
344   cgraph_edge_remove_caller (e);
345 }
346
347 /* Redirect callee of E to N.  The function does not update underlying
348    call expression.  */
349
350 void
351 cgraph_redirect_edge_callee (struct cgraph_edge *e, struct cgraph_node *n)
352 {
353   /* Remove from callers list of the current callee.  */
354   cgraph_edge_remove_callee (e);
355
356   /* Insert to callers list of the new callee.  */
357   e->prev_caller = NULL;
358   if (n->callers)
359     n->callers->prev_caller = e;
360   e->next_caller = n->callers;
361   n->callers = e;
362   e->callee = n;
363 }
364
365 /* Remove all callees from the node.  */
366
367 void
368 cgraph_node_remove_callees (struct cgraph_node *node)
369 {
370   struct cgraph_edge *e;
371
372   /* It is sufficient to remove the edges from the lists of callers of
373      the callees.  The callee list of the node can be zapped with one
374      assignment.  */
375   for (e = node->callees; e; e = e->next_callee)
376     cgraph_edge_remove_callee (e);
377   node->callees = NULL;
378 }
379
380 /* Remove all callers from the node.  */
381
382 static void
383 cgraph_node_remove_callers (struct cgraph_node *node)
384 {
385   struct cgraph_edge *e;
386
387   /* It is sufficient to remove the edges from the lists of callees of
388      the callers.  The caller list of the node can be zapped with one
389      assignment.  */
390   for (e = node->callers; e; e = e->next_caller)
391     cgraph_edge_remove_caller (e);
392   node->callers = NULL;
393 }
394
395 /* Remove the node from cgraph.  */
396
397 void
398 cgraph_remove_node (struct cgraph_node *node)
399 {
400   void **slot;
401   bool check_dead = 1;
402
403   cgraph_node_remove_callers (node);
404   cgraph_node_remove_callees (node);
405   while (node->nested)
406     cgraph_remove_node (node->nested);
407   if (node->origin)
408     {
409       struct cgraph_node **node2 = &node->origin->nested;
410
411       while (*node2 != node)
412         node2 = &(*node2)->next_nested;
413       *node2 = node->next_nested;
414     }
415   if (node->previous)
416     node->previous->next = node->next;
417   else
418     cgraph_nodes = node->next;
419   if (node->next)
420     node->next->previous = node->previous;
421   slot = htab_find_slot (cgraph_hash, node, NO_INSERT);
422   if (*slot == node)
423     {
424       if (node->next_clone)
425         *slot = node->next_clone;
426       else
427         {
428           htab_clear_slot (cgraph_hash, slot);
429           if (!dump_enabled_p (TDI_tree_all))
430             {
431               DECL_SAVED_TREE (node->decl) = NULL;
432               DECL_STRUCT_FUNCTION (node->decl) = NULL;
433             }
434           check_dead = false;
435         }
436     }
437   else
438     {
439       struct cgraph_node *n;
440
441       for (n = *slot; n->next_clone != node; n = n->next_clone)
442         continue;
443       n->next_clone = node->next_clone;
444     }
445
446   /* Work out whether we still need a function body (either there is inline
447      clone or there is out of line function whose body is not written).  */
448   if (check_dead && flag_unit_at_a_time)
449     {
450       struct cgraph_node *n;
451
452       for (n = *slot; n; n = n->next_clone)
453         if (n->global.inlined_to
454             || (!n->global.inlined_to
455                 && !TREE_ASM_WRITTEN (n->decl) && !DECL_EXTERNAL (n->decl)))
456           break;
457       if (!n && !dump_enabled_p (TDI_tree_all))
458         {
459           DECL_SAVED_TREE (node->decl) = NULL;
460           DECL_STRUCT_FUNCTION (node->decl) = NULL;
461           DECL_INITIAL (node->decl) = error_mark_node;
462         }
463     }
464   cgraph_n_nodes--;
465   /* Do not free the structure itself so the walk over chain can continue.  */
466 }
467
468 /* Notify finalize_compilation_unit that given node is reachable.  */
469
470 void
471 cgraph_mark_reachable_node (struct cgraph_node *node)
472 {
473   if (!node->reachable && node->local.finalized)
474     {
475       notice_global_symbol (node->decl);
476       node->reachable = 1;
477       gcc_assert (!cgraph_global_info_ready);
478
479       node->next_needed = cgraph_nodes_queue;
480       cgraph_nodes_queue = node;
481     }
482 }
483
484 /* Likewise indicate that a node is needed, i.e. reachable via some
485    external means.  */
486
487 void
488 cgraph_mark_needed_node (struct cgraph_node *node)
489 {
490   node->needed = 1;
491   cgraph_mark_reachable_node (node);
492 }
493
494 /* Return local info for the compiled function.  */
495
496 struct cgraph_local_info *
497 cgraph_local_info (tree decl)
498 {
499   struct cgraph_node *node;
500   
501   gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
502   node = cgraph_node (decl);
503   return &node->local;
504 }
505
506 /* Return local info for the compiled function.  */
507
508 struct cgraph_global_info *
509 cgraph_global_info (tree decl)
510 {
511   struct cgraph_node *node;
512   
513   gcc_assert (TREE_CODE (decl) == FUNCTION_DECL && cgraph_global_info_ready);
514   node = cgraph_node (decl);
515   return &node->global;
516 }
517
518 /* Return local info for the compiled function.  */
519
520 struct cgraph_rtl_info *
521 cgraph_rtl_info (tree decl)
522 {
523   struct cgraph_node *node;
524   
525   gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
526   node = cgraph_node (decl);
527   if (decl != current_function_decl
528       && !TREE_ASM_WRITTEN (node->decl))
529     return NULL;
530   return &node->rtl;
531 }
532
533 /* Return name of the node used in debug output.  */
534 const char *
535 cgraph_node_name (struct cgraph_node *node)
536 {
537   return lang_hooks.decl_printable_name (node->decl, 2);
538 }
539
540 /* Dump given cgraph node.  */
541 void
542 dump_cgraph_node (FILE *f, struct cgraph_node *node)
543 {
544   struct cgraph_edge *edge;
545   fprintf (f, "%s/%i:", cgraph_node_name (node), node->uid);
546   if (node->global.inlined_to)
547     fprintf (f, " (inline copy in %s/%i)",
548              cgraph_node_name (node->global.inlined_to),
549              node->global.inlined_to->uid);
550   if (node->local.self_insns)
551     fprintf (f, " %i insns", node->local.self_insns);
552   if (node->global.insns && node->global.insns != node->local.self_insns)
553     fprintf (f, " (%i after inlining)", node->global.insns);
554   if (node->origin)
555     fprintf (f, " nested in: %s", cgraph_node_name (node->origin));
556   if (node->needed)
557     fprintf (f, " needed");
558   else if (node->reachable)
559     fprintf (f, " reachable");
560   if (DECL_SAVED_TREE (node->decl))
561     fprintf (f, " tree");
562   if (node->output)
563     fprintf (f, " output");
564   if (node->local.local)
565     fprintf (f, " local");
566   if (node->local.disregard_inline_limits)
567     fprintf (f, " always_inline");
568   else if (node->local.inlinable)
569     fprintf (f, " inlinable");
570   if (TREE_ASM_WRITTEN (node->decl))
571     fprintf (f, " asm_written");
572
573   fprintf (f, "\n  called by: ");
574   for (edge = node->callers; edge; edge = edge->next_caller)
575     {
576       fprintf (f, "%s/%i ", cgraph_node_name (edge->caller),
577                edge->caller->uid);
578       if (!edge->inline_failed)
579         fprintf(f, "(inlined) ");
580     }
581
582   fprintf (f, "\n  calls: ");
583   for (edge = node->callees; edge; edge = edge->next_callee)
584     {
585       fprintf (f, "%s/%i ", cgraph_node_name (edge->callee),
586                edge->callee->uid);
587       if (!edge->inline_failed)
588         fprintf(f, "(inlined) ");
589     }
590   fprintf (f, "\n");
591 }
592
593 /* Dump the callgraph.  */
594
595 void
596 dump_cgraph (FILE *f)
597 {
598   struct cgraph_node *node;
599
600   fprintf (f, "callgraph:\n\n");
601   for (node = cgraph_nodes; node; node = node->next)
602     dump_cgraph_node (f, node);
603 }
604
605 /* Returns a hash code for P.  */
606
607 static hashval_t
608 hash_varpool_node (const void *p)
609 {
610   const struct cgraph_varpool_node *n = p;
611   return (hashval_t) DECL_UID (n->decl);
612 }
613
614 /* Returns nonzero if P1 and P2 are equal.  */
615
616 static int
617 eq_varpool_node (const void *p1, const void *p2)
618 {
619   const struct cgraph_varpool_node *n1 = p1, *n2 = p2;
620   return DECL_UID (n1->decl) == DECL_UID (n2->decl);
621 }
622
623 /* Return cgraph_varpool node assigned to DECL.  Create new one when needed.  */
624 struct cgraph_varpool_node *
625 cgraph_varpool_node (tree decl)
626 {
627   struct cgraph_varpool_node key, *node, **slot;
628
629   gcc_assert (DECL_P (decl) && TREE_CODE (decl) != FUNCTION_DECL);
630
631   if (!cgraph_varpool_hash)
632     cgraph_varpool_hash = htab_create_ggc (10, hash_varpool_node,
633                                            eq_varpool_node, NULL);
634   key.decl = decl;
635   slot = (struct cgraph_varpool_node **)
636     htab_find_slot (cgraph_varpool_hash, &key, INSERT);
637   if (*slot)
638     return *slot;
639   node = ggc_alloc_cleared (sizeof (*node));
640   node->decl = decl;
641   node->next = cgraph_varpool_nodes;
642   cgraph_varpool_nodes = node;
643   *slot = node;
644   return node;
645 }
646
647 struct cgraph_varpool_node *
648 cgraph_varpool_node_for_asm (tree asmname)
649 {
650   struct cgraph_varpool_node *node;
651
652   for (node = cgraph_varpool_nodes; node ; node = node->next)
653     if (decl_assembler_name_equal (node->decl, asmname))
654       return node;
655
656   return NULL;
657 }
658
659 /* Set the DECL_ASSEMBLER_NAME and update cgraph hashtables.  */
660 void
661 change_decl_assembler_name (tree decl, tree name)
662 {
663   if (!DECL_ASSEMBLER_NAME_SET_P (decl))
664     {
665       SET_DECL_ASSEMBLER_NAME (decl, name);
666       return;
667     }
668   if (name == DECL_ASSEMBLER_NAME (decl))
669     return;
670
671   if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))
672       && DECL_RTL_SET_P (decl))
673     warning ("%D renamed after being referenced in assembly", decl);
674
675   SET_DECL_ASSEMBLER_NAME (decl, name);
676 }
677
678 /* Notify finalize_compilation_unit that given node is reachable
679    or needed.  */
680 void
681 cgraph_varpool_mark_needed_node (struct cgraph_varpool_node *node)
682 {
683   if (!node->needed && node->finalized)
684     {
685       node->next_needed = cgraph_varpool_nodes_queue;
686       cgraph_varpool_nodes_queue = node;
687       notice_global_symbol (node->decl);
688     }
689   node->needed = 1;
690 }
691
692 void
693 cgraph_varpool_finalize_decl (tree decl)
694 {
695   struct cgraph_varpool_node *node = cgraph_varpool_node (decl);
696  
697   /* The first declaration of a variable that comes through this function
698      decides whether it is global (in C, has external linkage)
699      or local (in C, has internal linkage).  So do nothing more
700      if this function has already run.  */
701   if (node->finalized)
702     return;
703   if (node->needed)
704     {
705       node->next_needed = cgraph_varpool_nodes_queue;
706       cgraph_varpool_nodes_queue = node;
707       notice_global_symbol (decl);
708     }
709   node->finalized = true;
710
711   if (/* Externally visible variables must be output.  The exception are
712          COMDAT functions that must be output only when they are needed.  */
713       (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
714       /* Function whose name is output to the assembler file must be produced.
715          It is possible to assemble the name later after finalizing the function
716          and the fact is noticed in assemble_name then.  */
717       || (DECL_ASSEMBLER_NAME_SET_P (decl)
718           && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
719     {
720       cgraph_varpool_mark_needed_node (node);
721     }
722 }
723
724 bool
725 cgraph_varpool_assemble_pending_decls (void)
726 {
727   bool changed = false;
728
729   while (cgraph_varpool_nodes_queue)
730     {
731       struct cgraph_varpool_node *node = cgraph_varpool_nodes_queue;
732       tree decl = node->decl;
733
734       cgraph_varpool_nodes_queue = cgraph_varpool_nodes_queue->next_needed;
735       if (!TREE_ASM_WRITTEN (decl) && !node->alias)
736         {
737           assemble_variable (decl, 0, 1, 0);
738           changed = true;
739         }
740       node->next_needed = NULL;
741     }
742   return changed;
743 }
744
745 /* Return true when the DECL can possibly be inlined.  */
746 bool
747 cgraph_function_possibly_inlined_p (tree decl)
748 {
749   if (!cgraph_global_info_ready)
750     return (DECL_INLINE (decl) && !flag_really_no_inline);
751   return DECL_POSSIBLY_INLINED (decl);
752 }
753
754 /* Create clone of E in the node N represented by CALL_EXPR the callgraph.  */
755 struct cgraph_edge *
756 cgraph_clone_edge (struct cgraph_edge *e, struct cgraph_node *n, tree call_expr)
757 {
758   struct cgraph_edge *new = cgraph_create_edge (n, e->callee, call_expr);
759
760   new->inline_failed = e->inline_failed;
761   return new;
762 }
763
764 /* Create node representing clone of N.  */
765 struct cgraph_node *
766 cgraph_clone_node (struct cgraph_node *n)
767 {
768   struct cgraph_node *new = cgraph_create_node ();
769   struct cgraph_edge *e;
770
771   new->decl = n->decl;
772   new->origin = n->origin;
773   if (new->origin)
774     {
775       new->next_nested = new->origin->nested;
776       new->origin->nested = new;
777     }
778   new->analyzed = n->analyzed;
779   new->local = n->local;
780   new->global = n->global;
781   new->rtl = n->rtl;
782
783   for (e = n->callees;e; e=e->next_callee)
784     cgraph_clone_edge (e, new, e->call_expr);
785
786   new->next_clone = n->next_clone;
787   n->next_clone = new;
788
789   return new;
790 }
791
792 /* NODE is no longer nested function; update cgraph accordingly.  */
793 void
794 cgraph_unnest_node (struct cgraph_node *node)
795 {
796   struct cgraph_node **node2 = &node->origin->nested;
797   gcc_assert (node->origin);
798
799   while (*node2 != node)
800     node2 = &(*node2)->next_nested;
801   *node2 = node->next_nested;
802   node->origin = NULL;
803 }
804 #include "gt-cgraph.h"