OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [cgraph.h] - Blame information for rev 687

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 684 jeremybenn
/* Callgraph handling code.
2
   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
3
   Free Software Foundation, Inc.
4
   Contributed by Jan Hubicka
5
 
6
This file is part of GCC.
7
 
8
GCC is free software; you can redistribute it and/or modify it under
9
the terms of the GNU General Public License as published by the Free
10
Software Foundation; either version 3, or (at your option) any later
11
version.
12
 
13
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14
WARRANTY; without even the implied warranty of MERCHANTABILITY or
15
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16
for more details.
17
 
18
You should have received a copy of the GNU General Public License
19
along with GCC; see the file COPYING3.  If not see
20
<http://www.gnu.org/licenses/>.  */
21
 
22
#ifndef GCC_CGRAPH_H
23
#define GCC_CGRAPH_H
24
 
25
#include "plugin-api.h"
26
#include "vec.h"
27
#include "tree.h"
28
#include "basic-block.h"
29
#include "function.h"
30
#include "ipa-ref.h"    /* FIXME: inappropriate dependency of cgraph on IPA.  */
31
 
32
enum availability
33
{
34
  /* Not yet set by cgraph_function_body_availability.  */
35
  AVAIL_UNSET,
36
  /* Function body/variable initializer is unknown.  */
37
  AVAIL_NOT_AVAILABLE,
38
  /* Function body/variable initializer is known but might be replaced
39
     by a different one from other compilation unit and thus needs to
40
     be dealt with a care.  Like AVAIL_NOT_AVAILABLE it can have
41
     arbitrary side effects on escaping variables and functions, while
42
     like AVAILABLE it might access static variables.  */
43
  AVAIL_OVERWRITABLE,
44
  /* Function body/variable initializer is known and will be used in final
45
     program.  */
46
  AVAIL_AVAILABLE,
47
  /* Function body/variable initializer is known and all it's uses are explicitly
48
     visible within current unit (ie it's address is never taken and it is not
49
     exported to other units).
50
     Currently used only for functions.  */
51
  AVAIL_LOCAL
52
};
53
 
54
/* This is the information that is put into the cgraph local structure
55
   to recover a function.  */
56
struct lto_file_decl_data;
57
 
58
extern const char * const cgraph_availability_names[];
59
extern const char * const ld_plugin_symbol_resolution_names[];
60
 
61
/* Information about thunk, used only for same body aliases.  */
62
 
63
struct GTY(()) cgraph_thunk_info {
64
  /* Information about the thunk.  */
65
  HOST_WIDE_INT fixed_offset;
66
  HOST_WIDE_INT virtual_value;
67
  tree alias;
68
  bool this_adjusting;
69
  bool virtual_offset_p;
70
  /* Set to true when alias node is thunk.  */
71
  bool thunk_p;
72
};
73
 
74
/* Information about the function collected locally.
75
   Available after function is analyzed.  */
76
 
77
struct GTY(()) cgraph_local_info {
78
  /* File stream where this node is being written to.  */
79
  struct lto_file_decl_data * lto_file_data;
80
 
81
  /* Set when function function is visible in current compilation unit only
82
     and its address is never taken.  */
83
  unsigned local : 1;
84
 
85
  /* Set when function is visible by other units.  */
86
  unsigned externally_visible : 1;
87
 
88
  /* Set once it has been finalized so we consider it to be output.  */
89
  unsigned finalized : 1;
90
 
91
  /* False when there is something makes versioning impossible.  */
92
  unsigned versionable : 1;
93
 
94
  /* False when function calling convention and signature can not be changed.
95
     This is the case when __builtin_apply_args is used.  */
96
  unsigned can_change_signature : 1;
97
 
98
  /* True when the function has been originally extern inline, but it is
99
     redefined now.  */
100
  unsigned redefined_extern_inline : 1;
101
 
102
  /* True if the function may enter serial irrevocable mode.  */
103
  unsigned tm_may_enter_irr : 1;
104
};
105
 
106
/* Information about the function that needs to be computed globally
107
   once compilation is finished.  Available only with -funit-at-a-time.  */
108
 
109
struct GTY(()) cgraph_global_info {
110
  /* For inline clones this points to the function they will be
111
     inlined into.  */
112
  struct cgraph_node *inlined_to;
113
};
114
 
115
/* Information about the function that is propagated by the RTL backend.
116
   Available only for functions that has been already assembled.  */
117
 
118
struct GTY(()) cgraph_rtl_info {
119
   unsigned int preferred_incoming_stack_boundary;
120
};
121
 
122
/* Represent which DECL tree (or reference to such tree)
123
   will be replaced by another tree while versioning.  */
124
struct GTY(()) ipa_replace_map
125
{
126
  /* The tree that will be replaced.  */
127
  tree old_tree;
128
  /* The new (replacing) tree.  */
129
  tree new_tree;
130
  /* Parameter number to replace, when old_tree is NULL.  */
131
  int parm_num;
132
  /* True when a substitution should be done, false otherwise.  */
133
  bool replace_p;
134
  /* True when we replace a reference to old_tree.  */
135
  bool ref_p;
136
};
137
typedef struct ipa_replace_map *ipa_replace_map_p;
138
DEF_VEC_P(ipa_replace_map_p);
139
DEF_VEC_ALLOC_P(ipa_replace_map_p,gc);
140
 
141
struct GTY(()) cgraph_clone_info
142
{
143
  VEC(ipa_replace_map_p,gc)* tree_map;
144
  bitmap args_to_skip;
145
  bitmap combined_args_to_skip;
146
};
147
 
148
 
149
/* The cgraph data structure.
150
   Each function decl has assigned cgraph_node listing callees and callers.  */
151
 
152
struct GTY((chain_next ("%h.next"), chain_prev ("%h.previous"))) cgraph_node {
153
  tree decl;
154
  struct cgraph_edge *callees;
155
  struct cgraph_edge *callers;
156
  struct cgraph_node *next;
157
  struct cgraph_node *previous;
158
  /* List of edges representing indirect calls with a yet undetermined
159
     callee.  */
160
  struct cgraph_edge *indirect_calls;
161
  /* For nested functions points to function the node is nested in.  */
162
  struct cgraph_node *origin;
163
  /* Points to first nested function, if any.  */
164
  struct cgraph_node *nested;
165
  /* Pointer to the next function with same origin, if any.  */
166
  struct cgraph_node *next_nested;
167
  /* Pointer to the next function in cgraph_nodes_queue.  */
168
  struct cgraph_node *next_needed;
169
  /* Pointer to the next clone.  */
170
  struct cgraph_node *next_sibling_clone;
171
  struct cgraph_node *prev_sibling_clone;
172
  struct cgraph_node *clones;
173
  struct cgraph_node *clone_of;
174
  /* Circular list of nodes in the same comdat group if non-NULL.  */
175
  struct cgraph_node *same_comdat_group;
176
  /* For functions with many calls sites it holds map from call expression
177
     to the edge to speed up cgraph_edge function.  */
178
  htab_t GTY((param_is (struct cgraph_edge))) call_site_hash;
179
  /* Declaration node used to be clone of. */
180
  tree former_clone_of;
181
 
182
  PTR GTY ((skip)) aux;
183
 
184
  /* Interprocedural passes scheduled to have their transform functions
185
     applied next time we execute local pass on them.  We maintain it
186
     per-function in order to allow IPA passes to introduce new functions.  */
187
  VEC(ipa_opt_pass,heap) * GTY((skip)) ipa_transforms_to_apply;
188
 
189
  struct ipa_ref_list ref_list;
190
  struct cgraph_local_info local;
191
  struct cgraph_global_info global;
192
  struct cgraph_rtl_info rtl;
193
  struct cgraph_clone_info clone;
194
  struct cgraph_thunk_info thunk;
195
 
196
  /* Expected number of executions: calculated in profile.c.  */
197
  gcov_type count;
198
  /* How to scale counts at materialization time; used to merge
199
     LTO units with different number of profile runs.  */
200
  int count_materialization_scale;
201
  /* Unique id of the node.  */
202
  int uid;
203
  /* Ordering of all cgraph nodes.  */
204
  int order;
205
 
206
  enum ld_plugin_symbol_resolution resolution;
207
 
208
  /* Set when function must be output for some reason.  The primary
209
     use of this flag is to mark functions needed to be output for
210
     non-standard reason.  Functions that are externally visible
211
     or reachable from functions needed to be output are marked
212
     by specialized flags.  */
213
  unsigned needed : 1;
214
  /* Set when function has address taken.
215
     In current implementation it imply needed flag. */
216
  unsigned address_taken : 1;
217
  /* Set when decl is an abstract function pointed to by the
218
     ABSTRACT_DECL_ORIGIN of a reachable function.  */
219
  unsigned abstract_and_needed : 1;
220
  /* Set when function is reachable by call from other function
221
     that is either reachable or needed.
222
     This flag is computed at original cgraph construction and then
223
     updated in cgraph_remove_unreachable_nodes.  Note that after
224
     cgraph_remove_unreachable_nodes cgraph still can contain unreachable
225
     nodes when they are needed for virtual clone instantiation.  */
226
  unsigned reachable : 1;
227
  /* Set when function is reachable by call from other LTRANS partition.  */
228
  unsigned reachable_from_other_partition : 1;
229
  /* Set once the function is lowered (i.e. its CFG is built).  */
230
  unsigned lowered : 1;
231
  /* Set once the function has been instantiated and its callee
232
     lists created.  */
233
  unsigned analyzed : 1;
234
  /* Set when function is available in the other LTRANS partition.
235
     During WPA output it is used to mark nodes that are present in
236
     multiple partitions.  */
237
  unsigned in_other_partition : 1;
238
  /* Set when function is scheduled to be processed by local passes.  */
239
  unsigned process : 1;
240
  /* Set for aliases once they got through assemble_alias.  */
241
  unsigned alias : 1;
242
  /* Set for aliases created as C++ same body aliases.  */
243
  unsigned same_body_alias : 1;
244
  /* How commonly executed the node is.  Initialized during branch
245
     probabilities pass.  */
246
  ENUM_BITFIELD (node_frequency) frequency : 2;
247
  /* True when function can only be called at startup (from static ctor).  */
248
  unsigned only_called_at_startup : 1;
249
  /* True when function can only be called at startup (from static dtor).  */
250
  unsigned only_called_at_exit : 1;
251
  /* True when function is the transactional clone of a function which
252
     is called only from inside transactions.  */
253
  /* ?? We should be able to remove this.  We have enough bits in
254
     cgraph to calculate it.  */
255
  unsigned tm_clone : 1;
256
};
257
 
258
typedef struct cgraph_node *cgraph_node_ptr;
259
 
260
DEF_VEC_P(cgraph_node_ptr);
261
DEF_VEC_ALLOC_P(cgraph_node_ptr,heap);
262
DEF_VEC_ALLOC_P(cgraph_node_ptr,gc);
263
 
264
/* A cgraph node set is a collection of cgraph nodes.  A cgraph node
265
   can appear in multiple sets.  */
266
struct cgraph_node_set_def
267
{
268
  struct pointer_map_t *map;
269
  VEC(cgraph_node_ptr, heap) *nodes;
270
};
271
 
272
typedef struct varpool_node *varpool_node_ptr;
273
 
274
DEF_VEC_P(varpool_node_ptr);
275
DEF_VEC_ALLOC_P(varpool_node_ptr,heap);
276
DEF_VEC_ALLOC_P(varpool_node_ptr,gc);
277
 
278
/* A varpool node set is a collection of varpool nodes.  A varpool node
279
   can appear in multiple sets.  */
280
struct varpool_node_set_def
281
{
282
  struct pointer_map_t * map;
283
  VEC(varpool_node_ptr, heap) *nodes;
284
};
285
 
286
typedef struct cgraph_node_set_def *cgraph_node_set;
287
 
288
DEF_VEC_P(cgraph_node_set);
289
DEF_VEC_ALLOC_P(cgraph_node_set,gc);
290
DEF_VEC_ALLOC_P(cgraph_node_set,heap);
291
 
292
typedef struct varpool_node_set_def *varpool_node_set;
293
 
294
DEF_VEC_P(varpool_node_set);
295
DEF_VEC_ALLOC_P(varpool_node_set,gc);
296
DEF_VEC_ALLOC_P(varpool_node_set,heap);
297
 
298
/* Iterator structure for cgraph node sets.  */
299
typedef struct
300
{
301
  cgraph_node_set set;
302
  unsigned index;
303
} cgraph_node_set_iterator;
304
 
305
/* Iterator structure for varpool node sets.  */
306
typedef struct
307
{
308
  varpool_node_set set;
309
  unsigned index;
310
} varpool_node_set_iterator;
311
 
312
#define DEFCIFCODE(code, string)        CIF_ ## code,
313
/* Reasons for inlining failures.  */
314
typedef enum cgraph_inline_failed_enum {
315
#include "cif-code.def"
316
  CIF_N_REASONS
317
} cgraph_inline_failed_t;
318
 
319
/* Structure containing additional information about an indirect call.  */
320
 
321
struct GTY(()) cgraph_indirect_call_info
322
{
323
  /* Offset accumulated from ancestor jump functions of inlined call graph
324
     edges.  */
325
  HOST_WIDE_INT anc_offset;
326
  /* OBJ_TYPE_REF_TOKEN of a polymorphic call (if polymorphic is set).  */
327
  HOST_WIDE_INT otr_token;
328
  /* Type of the object from OBJ_TYPE_REF_OBJECT. */
329
  tree otr_type;
330
  /* Index of the parameter that is called.  */
331
  int param_index;
332
  /* ECF flags determined from the caller.  */
333
  int ecf_flags;
334
 
335
  /* Set when the call is a virtual call with the parameter being the
336
     associated object pointer rather than a simple direct call.  */
337
  unsigned polymorphic : 1;
338
};
339
 
340
struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"))) cgraph_edge {
341
  /* Expected number of executions: calculated in profile.c.  */
342
  gcov_type count;
343
  struct cgraph_node *caller;
344
  struct cgraph_node *callee;
345
  struct cgraph_edge *prev_caller;
346
  struct cgraph_edge *next_caller;
347
  struct cgraph_edge *prev_callee;
348
  struct cgraph_edge *next_callee;
349
  gimple call_stmt;
350
  /* Additional information about an indirect call.  Not cleared when an edge
351
     becomes direct.  */
352
  struct cgraph_indirect_call_info *indirect_info;
353
  PTR GTY ((skip (""))) aux;
354
  /* When equal to CIF_OK, inline this call.  Otherwise, points to the
355
     explanation why function was not inlined.  */
356
  cgraph_inline_failed_t inline_failed;
357
  /* The stmt_uid of call_stmt.  This is used by LTO to recover the call_stmt
358
     when the function is serialized in.  */
359
  unsigned int lto_stmt_uid;
360
  /* Expected frequency of executions within the function.
361
     When set to CGRAPH_FREQ_BASE, the edge is expected to be called once
362
     per function call.  The range is 0 to CGRAPH_FREQ_MAX.  */
363
  int frequency;
364
  /* Unique id of the edge.  */
365
  int uid;
366
  /* Whether this edge was made direct by indirect inlining.  */
367
  unsigned int indirect_inlining_edge : 1;
368
  /* Whether this edge describes an indirect call with an undetermined
369
     callee.  */
370
  unsigned int indirect_unknown_callee : 1;
371
  /* Whether this edge is still a dangling  */
372
  /* True if the corresponding CALL stmt cannot be inlined.  */
373
  unsigned int call_stmt_cannot_inline_p : 1;
374
  /* Can this call throw externally?  */
375
  unsigned int can_throw_external : 1;
376
};
377
 
378
#define CGRAPH_FREQ_BASE 1000
379
#define CGRAPH_FREQ_MAX 100000
380
 
381
typedef struct cgraph_edge *cgraph_edge_p;
382
 
383
DEF_VEC_P(cgraph_edge_p);
384
DEF_VEC_ALLOC_P(cgraph_edge_p,heap);
385
 
386
/* The varpool data structure.
387
   Each static variable decl has assigned varpool_node.  */
388
 
389
struct GTY((chain_next ("%h.next"), chain_prev ("%h.prev"))) varpool_node {
390
  tree decl;
391
  /* For aliases points to declaration DECL is alias of.  */
392
  tree alias_of;
393
  /* Pointer to the next function in varpool_nodes.  */
394
  struct varpool_node *next, *prev;
395
  /* Pointer to the next function in varpool_nodes_queue.  */
396
  struct varpool_node *next_needed, *prev_needed;
397
  /* Circular list of nodes in the same comdat group if non-NULL.  */
398
  struct varpool_node *same_comdat_group;
399
  struct ipa_ref_list ref_list;
400
  /* File stream where this node is being written to.  */
401
  struct lto_file_decl_data * lto_file_data;
402
  PTR GTY ((skip)) aux;
403
  /* Ordering of all cgraph nodes.  */
404
  int order;
405
  enum ld_plugin_symbol_resolution resolution;
406
 
407
  /* Set when function must be output - it is externally visible
408
     or its address is taken.  */
409
  unsigned needed : 1;
410
  /* Needed variables might become dead by optimization.  This flag
411
     forces the variable to be output even if it appears dead otherwise.  */
412
  unsigned force_output : 1;
413
  /* Set once the variable has been instantiated and its callee
414
     lists created.  */
415
  unsigned analyzed : 1;
416
  /* Set once it has been finalized so we consider it to be output.  */
417
  unsigned finalized : 1;
418
  /* Set when variable is scheduled to be assembled.  */
419
  unsigned output : 1;
420
  /* Set when function is visible by other units.  */
421
  unsigned externally_visible : 1;
422
  /* Set for aliases once they got through assemble_alias.  Also set for
423
     extra name aliases in varpool_extra_name_alias.  */
424
  unsigned alias : 1;
425
  unsigned extra_name_alias : 1;
426
  /* Set when variable is used from other LTRANS partition.  */
427
  unsigned used_from_other_partition : 1;
428
  /* Set when variable is available in the other LTRANS partition.
429
     During WPA output it is used to mark nodes that are present in
430
     multiple partitions.  */
431
  unsigned in_other_partition : 1;
432
};
433
 
434
/* Every top level asm statement is put into a cgraph_asm_node.  */
435
 
436
struct GTY(()) cgraph_asm_node {
437
  /* Next asm node.  */
438
  struct cgraph_asm_node *next;
439
  /* String for this asm node.  */
440
  tree asm_str;
441
  /* Ordering of all cgraph nodes.  */
442
  int order;
443
};
444
 
445
extern GTY(()) struct cgraph_node *cgraph_nodes;
446
extern GTY(()) int cgraph_n_nodes;
447
extern GTY(()) int cgraph_max_uid;
448
extern GTY(()) int cgraph_edge_max_uid;
449
extern bool cgraph_global_info_ready;
450
enum cgraph_state
451
{
452
  /* Callgraph is being constructed.  It is safe to add new functions.  */
453
  CGRAPH_STATE_CONSTRUCTION,
454
  /* Callgraph is built and IPA passes are being run.  */
455
  CGRAPH_STATE_IPA,
456
  /* Callgraph is built and all functions are transformed to SSA form.  */
457
  CGRAPH_STATE_IPA_SSA,
458
  /* Functions are now ordered and being passed to RTL expanders.  */
459
  CGRAPH_STATE_EXPANSION,
460
  /* All cgraph expansion is done.  */
461
  CGRAPH_STATE_FINISHED
462
};
463
extern enum cgraph_state cgraph_state;
464
extern bool cgraph_function_flags_ready;
465
extern GTY(()) struct cgraph_node *cgraph_nodes_queue;
466
extern GTY(()) struct cgraph_node *cgraph_new_nodes;
467
 
468
extern GTY(()) struct cgraph_asm_node *cgraph_asm_nodes;
469
extern GTY(()) int cgraph_order;
470
extern bool same_body_aliases_done;
471
 
472
/* In cgraph.c  */
473
void dump_cgraph (FILE *);
474
void debug_cgraph (void);
475
void dump_cgraph_node (FILE *, struct cgraph_node *);
476
void debug_cgraph_node (struct cgraph_node *);
477
void cgraph_insert_node_to_hashtable (struct cgraph_node *node);
478
void cgraph_remove_edge (struct cgraph_edge *);
479
void cgraph_remove_node (struct cgraph_node *);
480
void cgraph_add_to_same_comdat_group (struct cgraph_node *, struct cgraph_node *);
481
void cgraph_remove_node_and_inline_clones (struct cgraph_node *);
482
void cgraph_release_function_body (struct cgraph_node *);
483
void cgraph_node_remove_callees (struct cgraph_node *node);
484
struct cgraph_edge *cgraph_create_edge (struct cgraph_node *,
485
                                        struct cgraph_node *,
486
                                        gimple, gcov_type, int);
487
struct cgraph_edge *cgraph_create_indirect_edge (struct cgraph_node *, gimple,
488
                                                 int, gcov_type, int);
489
struct cgraph_indirect_call_info *cgraph_allocate_init_indirect_info (void);
490
struct cgraph_node * cgraph_get_node (const_tree);
491
struct cgraph_node * cgraph_create_node (tree);
492
struct cgraph_node * cgraph_get_create_node (tree);
493
struct cgraph_node * cgraph_same_body_alias (struct cgraph_node *, tree, tree);
494
struct cgraph_node * cgraph_add_thunk (struct cgraph_node *, tree, tree, bool, HOST_WIDE_INT,
495
                                       HOST_WIDE_INT, tree, tree);
496
struct cgraph_node *cgraph_node_for_asm (tree);
497
struct cgraph_edge *cgraph_edge (struct cgraph_node *, gimple);
498
void cgraph_set_call_stmt (struct cgraph_edge *, gimple);
499
void cgraph_set_call_stmt_including_clones (struct cgraph_node *, gimple, gimple);
500
void cgraph_create_edge_including_clones (struct cgraph_node *,
501
                                          struct cgraph_node *,
502
                                          gimple, gimple, gcov_type, int,
503
                                          cgraph_inline_failed_t);
504
void cgraph_update_edges_for_call_stmt (gimple, tree, gimple);
505
struct cgraph_local_info *cgraph_local_info (tree);
506
struct cgraph_global_info *cgraph_global_info (tree);
507
struct cgraph_rtl_info *cgraph_rtl_info (tree);
508
const char * cgraph_node_name (struct cgraph_node *);
509
struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *,
510
                                        struct cgraph_node *, gimple,
511
                                        unsigned, gcov_type, int, bool);
512
struct cgraph_node * cgraph_clone_node (struct cgraph_node *, tree, gcov_type,
513
                                        int, bool, VEC(cgraph_edge_p,heap) *,
514
                                        bool);
515
struct cgraph_node *cgraph_create_function_alias (tree, tree);
516
void cgraph_call_node_duplication_hooks (struct cgraph_node *node1,
517
                                         struct cgraph_node *node2);
518
 
519
void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *);
520
void cgraph_make_edge_direct (struct cgraph_edge *, struct cgraph_node *);
521
bool cgraph_only_called_directly_p (struct cgraph_node *);
522
 
523
struct cgraph_asm_node *cgraph_add_asm_node (tree);
524
 
525
bool cgraph_function_possibly_inlined_p (tree);
526
void cgraph_unnest_node (struct cgraph_node *);
527
 
528
enum availability cgraph_function_body_availability (struct cgraph_node *);
529
void cgraph_add_new_function (tree, bool);
530
const char* cgraph_inline_failed_string (cgraph_inline_failed_t);
531
struct cgraph_node * cgraph_create_virtual_clone (struct cgraph_node *old_node,
532
                                                  VEC(cgraph_edge_p,heap)*,
533
                                                  VEC(ipa_replace_map_p,gc)* tree_map,
534
                                                  bitmap args_to_skip,
535
                                                  const char *clone_name);
536
 
537
void cgraph_set_nothrow_flag (struct cgraph_node *, bool);
538
void cgraph_set_const_flag (struct cgraph_node *, bool, bool);
539
void cgraph_set_pure_flag (struct cgraph_node *, bool, bool);
540
tree clone_function_name (tree decl, const char *);
541
bool cgraph_node_cannot_return (struct cgraph_node *);
542
bool cgraph_edge_cannot_lead_to_return (struct cgraph_edge *);
543
bool cgraph_will_be_removed_from_program_if_no_direct_calls
544
  (struct cgraph_node *node);
545
bool cgraph_can_remove_if_no_direct_calls_and_refs_p
546
  (struct cgraph_node *node);
547
bool cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node *node);
548
bool resolution_used_from_other_file_p (enum ld_plugin_symbol_resolution);
549
bool cgraph_used_from_object_file_p (struct cgraph_node *);
550
bool varpool_used_from_object_file_p (struct varpool_node *);
551
bool cgraph_for_node_thunks_and_aliases (struct cgraph_node *,
552
                                         bool (*) (struct cgraph_node *, void *),
553
                                         void *,
554
                                         bool);
555
bool cgraph_for_node_and_aliases (struct cgraph_node *,
556
                                  bool (*) (struct cgraph_node *, void *),
557
                                  void *, bool);
558
VEC (cgraph_edge_p, heap) * collect_callers_of_node (struct cgraph_node *node);
559
 
560
 
561
/* In cgraphunit.c  */
562
extern FILE *cgraph_dump_file;
563
void cgraph_finalize_function (tree, bool);
564
void cgraph_mark_if_needed (tree);
565
void cgraph_analyze_function (struct cgraph_node *);
566
void cgraph_finalize_compilation_unit (void);
567
void cgraph_optimize (void);
568
void cgraph_mark_needed_node (struct cgraph_node *);
569
void cgraph_mark_address_taken_node (struct cgraph_node *);
570
void cgraph_mark_reachable_node (struct cgraph_node *);
571
bool cgraph_inline_p (struct cgraph_edge *, cgraph_inline_failed_t *reason);
572
bool cgraph_preserve_function_body_p (struct cgraph_node *);
573
void verify_cgraph (void);
574
void verify_cgraph_node (struct cgraph_node *);
575
void cgraph_build_static_cdtor (char which, tree body, int priority);
576
void cgraph_reset_static_var_maps (void);
577
void init_cgraph (void);
578
struct cgraph_node * cgraph_copy_node_for_versioning (struct cgraph_node *,
579
                tree, VEC(cgraph_edge_p,heap)*, bitmap);
580
struct cgraph_node *cgraph_function_versioning (struct cgraph_node *,
581
                                                VEC(cgraph_edge_p,heap)*,
582
                                                VEC(ipa_replace_map_p,gc)*,
583
                                                bitmap, bool, bitmap,
584
                                                basic_block, const char *);
585
void tree_function_versioning (tree, tree, VEC (ipa_replace_map_p,gc)*,
586
                               bool, bitmap, bool, bitmap, basic_block);
587
void record_references_in_initializer (tree, bool);
588
bool cgraph_process_new_functions (void);
589
void cgraph_process_same_body_aliases (void);
590
 
591
bool cgraph_decide_is_function_needed (struct cgraph_node *, tree);
592
 
593
typedef void (*cgraph_edge_hook)(struct cgraph_edge *, void *);
594
typedef void (*cgraph_node_hook)(struct cgraph_node *, void *);
595
typedef void (*cgraph_2edge_hook)(struct cgraph_edge *, struct cgraph_edge *,
596
                                  void *);
597
typedef void (*cgraph_2node_hook)(struct cgraph_node *, struct cgraph_node *,
598
                                  void *);
599
struct cgraph_edge_hook_list;
600
struct cgraph_node_hook_list;
601
struct cgraph_2edge_hook_list;
602
struct cgraph_2node_hook_list;
603
struct cgraph_edge_hook_list *cgraph_add_edge_removal_hook (cgraph_edge_hook, void *);
604
void cgraph_remove_edge_removal_hook (struct cgraph_edge_hook_list *);
605
struct cgraph_node_hook_list *cgraph_add_node_removal_hook (cgraph_node_hook,
606
                                                            void *);
607
void cgraph_remove_node_removal_hook (struct cgraph_node_hook_list *);
608
struct cgraph_node_hook_list *cgraph_add_function_insertion_hook (cgraph_node_hook,
609
                                                                  void *);
610
void cgraph_remove_function_insertion_hook (struct cgraph_node_hook_list *);
611
void cgraph_call_function_insertion_hooks (struct cgraph_node *node);
612
struct cgraph_2edge_hook_list *cgraph_add_edge_duplication_hook (cgraph_2edge_hook, void *);
613
void cgraph_remove_edge_duplication_hook (struct cgraph_2edge_hook_list *);
614
struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook (cgraph_2node_hook, void *);
615
void cgraph_remove_node_duplication_hook (struct cgraph_2node_hook_list *);
616
void cgraph_materialize_all_clones (void);
617
gimple cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *);
618
bool cgraph_propagate_frequency (struct cgraph_node *node);
619
/* In cgraphbuild.c  */
620
unsigned int rebuild_cgraph_edges (void);
621
void cgraph_rebuild_references (void);
622
void reset_inline_failed (struct cgraph_node *);
623
int compute_call_stmt_bb_frequency (tree, basic_block bb);
624
 
625
/* In ipa.c  */
626
bool cgraph_remove_unreachable_nodes (bool, FILE *);
627
cgraph_node_set cgraph_node_set_new (void);
628
cgraph_node_set_iterator cgraph_node_set_find (cgraph_node_set,
629
                                               struct cgraph_node *);
630
void cgraph_node_set_add (cgraph_node_set, struct cgraph_node *);
631
void cgraph_node_set_remove (cgraph_node_set, struct cgraph_node *);
632
void dump_cgraph_node_set (FILE *, cgraph_node_set);
633
void debug_cgraph_node_set (cgraph_node_set);
634
void free_cgraph_node_set (cgraph_node_set);
635
 
636
varpool_node_set varpool_node_set_new (void);
637
varpool_node_set_iterator varpool_node_set_find (varpool_node_set,
638
                                               struct varpool_node *);
639
void varpool_node_set_add (varpool_node_set, struct varpool_node *);
640
void varpool_node_set_remove (varpool_node_set, struct varpool_node *);
641
void dump_varpool_node_set (FILE *, varpool_node_set);
642
void debug_varpool_node_set (varpool_node_set);
643
void free_varpool_node_set (varpool_node_set);
644
void ipa_discover_readonly_nonaddressable_vars (void);
645
bool cgraph_comdat_can_be_unshared_p (struct cgraph_node *);
646
bool varpool_externally_visible_p (struct varpool_node *, bool);
647
 
648
/* In predict.c  */
649
bool cgraph_maybe_hot_edge_p (struct cgraph_edge *e);
650
bool cgraph_optimize_for_size_p (struct cgraph_node *);
651
 
652
/* In varpool.c  */
653
extern GTY(()) struct varpool_node *varpool_nodes_queue;
654
extern GTY(()) struct varpool_node *varpool_nodes;
655
 
656
struct varpool_node *varpool_node (tree);
657
struct varpool_node *varpool_node_for_asm (tree asmname);
658
void varpool_mark_needed_node (struct varpool_node *);
659
void debug_varpool (void);
660
void dump_varpool (FILE *);
661
void dump_varpool_node (FILE *, struct varpool_node *);
662
 
663
void varpool_finalize_decl (tree);
664
bool decide_is_variable_needed (struct varpool_node *, tree);
665
enum availability cgraph_variable_initializer_availability (struct varpool_node *);
666
void cgraph_make_decl_local (tree);
667
void cgraph_make_node_local (struct cgraph_node *);
668
bool cgraph_node_can_be_local_p (struct cgraph_node *);
669
 
670
 
671
struct varpool_node * varpool_get_node (const_tree decl);
672
void varpool_remove_node (struct varpool_node *node);
673
void varpool_finalize_named_section_flags (struct varpool_node *node);
674
bool varpool_assemble_pending_decls (void);
675
bool varpool_assemble_decl (struct varpool_node *node);
676
bool varpool_analyze_pending_decls (void);
677
void varpool_remove_unreferenced_decls (void);
678
void varpool_empty_needed_queue (void);
679
struct varpool_node * varpool_extra_name_alias (tree, tree);
680
struct varpool_node * varpool_create_variable_alias (tree, tree);
681
const char * varpool_node_name (struct varpool_node *node);
682
void varpool_reset_queue (void);
683
bool const_value_known_p (tree);
684
bool varpool_for_node_and_aliases (struct varpool_node *,
685
                                   bool (*) (struct varpool_node *, void *),
686
                                   void *, bool);
687
void varpool_add_new_variable (tree);
688
 
689
/* Walk all reachable static variables.  */
690
#define FOR_EACH_STATIC_VARIABLE(node) \
691
   for ((node) = varpool_nodes_queue; (node); (node) = (node)->next_needed)
692
 
693
/* Return first reachable static variable with initializer.  */
694
static inline struct varpool_node *
695
varpool_first_static_initializer (void)
696
{
697
  struct varpool_node *node;
698
  for (node = varpool_nodes_queue; node; node = node->next_needed)
699
    {
700
      gcc_checking_assert (TREE_CODE (node->decl) == VAR_DECL);
701
      if (DECL_INITIAL (node->decl))
702
        return node;
703
    }
704
  return NULL;
705
}
706
 
707
/* Return next reachable static variable with initializer after NODE.  */
708
static inline struct varpool_node *
709
varpool_next_static_initializer (struct varpool_node *node)
710
{
711
  for (node = node->next_needed; node; node = node->next_needed)
712
    {
713
      gcc_checking_assert (TREE_CODE (node->decl) == VAR_DECL);
714
      if (DECL_INITIAL (node->decl))
715
        return node;
716
    }
717
  return NULL;
718
}
719
 
720
/* Walk all static variables with initializer set.  */
721
#define FOR_EACH_STATIC_INITIALIZER(node) \
722
   for ((node) = varpool_first_static_initializer (); (node); \
723
        (node) = varpool_next_static_initializer (node))
724
 
725
/* Return first function with body defined.  */
726
static inline struct cgraph_node *
727
cgraph_first_defined_function (void)
728
{
729
  struct cgraph_node *node;
730
  for (node = cgraph_nodes; node; node = node->next)
731
    {
732
      if (node->analyzed)
733
        return node;
734
    }
735
  return NULL;
736
}
737
 
738
/* Return next function with body defined after NODE.  */
739
static inline struct cgraph_node *
740
cgraph_next_defined_function (struct cgraph_node *node)
741
{
742
  for (node = node->next; node; node = node->next)
743
    {
744
      if (node->analyzed)
745
        return node;
746
    }
747
  return NULL;
748
}
749
 
750
/* Walk all functions with body defined.  */
751
#define FOR_EACH_DEFINED_FUNCTION(node) \
752
   for ((node) = cgraph_first_defined_function (); (node); \
753
        (node) = cgraph_next_defined_function (node))
754
 
755
 
756
/* Return true when NODE is a function with Gimple body defined
757
   in current unit.  Functions can also be define externally or they
758
   can be thunks with no Gimple representation.
759
 
760
   Note that at WPA stage, the function body may not be present in memory.  */
761
 
762
static inline bool
763
cgraph_function_with_gimple_body_p (struct cgraph_node *node)
764
{
765
  return node->analyzed && !node->thunk.thunk_p && !node->alias;
766
}
767
 
768
/* Return first function with body defined.  */
769
static inline struct cgraph_node *
770
cgraph_first_function_with_gimple_body (void)
771
{
772
  struct cgraph_node *node;
773
  for (node = cgraph_nodes; node; node = node->next)
774
    {
775
      if (cgraph_function_with_gimple_body_p (node))
776
        return node;
777
    }
778
  return NULL;
779
}
780
 
781
/* Return next reachable static variable with initializer after NODE.  */
782
static inline struct cgraph_node *
783
cgraph_next_function_with_gimple_body (struct cgraph_node *node)
784
{
785
  for (node = node->next; node; node = node->next)
786
    {
787
      if (cgraph_function_with_gimple_body_p (node))
788
        return node;
789
    }
790
  return NULL;
791
}
792
 
793
/* Walk all functions with body defined.  */
794
#define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
795
   for ((node) = cgraph_first_function_with_gimple_body (); (node); \
796
        (node) = cgraph_next_function_with_gimple_body (node))
797
 
798
/* Create a new static variable of type TYPE.  */
799
tree add_new_static_var (tree type);
800
 
801
/* Return true if iterator CSI points to nothing.  */
802
static inline bool
803
csi_end_p (cgraph_node_set_iterator csi)
804
{
805
  return csi.index >= VEC_length (cgraph_node_ptr, csi.set->nodes);
806
}
807
 
808
/* Advance iterator CSI.  */
809
static inline void
810
csi_next (cgraph_node_set_iterator *csi)
811
{
812
  csi->index++;
813
}
814
 
815
/* Return the node pointed to by CSI.  */
816
static inline struct cgraph_node *
817
csi_node (cgraph_node_set_iterator csi)
818
{
819
  return VEC_index (cgraph_node_ptr, csi.set->nodes, csi.index);
820
}
821
 
822
/* Return an iterator to the first node in SET.  */
823
static inline cgraph_node_set_iterator
824
csi_start (cgraph_node_set set)
825
{
826
  cgraph_node_set_iterator csi;
827
 
828
  csi.set = set;
829
  csi.index = 0;
830
  return csi;
831
}
832
 
833
/* Return true if SET contains NODE.  */
834
static inline bool
835
cgraph_node_in_set_p (struct cgraph_node *node, cgraph_node_set set)
836
{
837
  cgraph_node_set_iterator csi;
838
  csi = cgraph_node_set_find (set, node);
839
  return !csi_end_p (csi);
840
}
841
 
842
/* Return number of nodes in SET.  */
843
static inline size_t
844
cgraph_node_set_size (cgraph_node_set set)
845
{
846
  return VEC_length (cgraph_node_ptr, set->nodes);
847
}
848
 
849
/* Return true if iterator VSI points to nothing.  */
850
static inline bool
851
vsi_end_p (varpool_node_set_iterator vsi)
852
{
853
  return vsi.index >= VEC_length (varpool_node_ptr, vsi.set->nodes);
854
}
855
 
856
/* Advance iterator VSI.  */
857
static inline void
858
vsi_next (varpool_node_set_iterator *vsi)
859
{
860
  vsi->index++;
861
}
862
 
863
/* Return the node pointed to by VSI.  */
864
static inline struct varpool_node *
865
vsi_node (varpool_node_set_iterator vsi)
866
{
867
  return VEC_index (varpool_node_ptr, vsi.set->nodes, vsi.index);
868
}
869
 
870
/* Return an iterator to the first node in SET.  */
871
static inline varpool_node_set_iterator
872
vsi_start (varpool_node_set set)
873
{
874
  varpool_node_set_iterator vsi;
875
 
876
  vsi.set = set;
877
  vsi.index = 0;
878
  return vsi;
879
}
880
 
881
/* Return true if SET contains NODE.  */
882
static inline bool
883
varpool_node_in_set_p (struct varpool_node *node, varpool_node_set set)
884
{
885
  varpool_node_set_iterator vsi;
886
  vsi = varpool_node_set_find (set, node);
887
  return !vsi_end_p (vsi);
888
}
889
 
890
/* Return number of nodes in SET.  */
891
static inline size_t
892
varpool_node_set_size (varpool_node_set set)
893
{
894
  return VEC_length (varpool_node_ptr, set->nodes);
895
}
896
 
897
/* Uniquize all constants that appear in memory.
898
   Each constant in memory thus far output is recorded
899
   in `const_desc_table'.  */
900
 
901
struct GTY(()) constant_descriptor_tree {
902
  /* A MEM for the constant.  */
903
  rtx rtl;
904
 
905
  /* The value of the constant.  */
906
  tree value;
907
 
908
  /* Hash of value.  Computing the hash from value each time
909
     hashfn is called can't work properly, as that means recursive
910
     use of the hash table during hash table expansion.  */
911
  hashval_t hash;
912
};
913
 
914
/* Return true if set is nonempty.  */
915
static inline bool
916
cgraph_node_set_nonempty_p (cgraph_node_set set)
917
{
918
  return !VEC_empty (cgraph_node_ptr, set->nodes);
919
}
920
 
921
/* Return true if set is nonempty.  */
922
static inline bool
923
varpool_node_set_nonempty_p (varpool_node_set set)
924
{
925
  return !VEC_empty (varpool_node_ptr, set->nodes);
926
}
927
 
928
/* Return true when function NODE is only called directly or it has alias.
929
   i.e. it is not externally visible, address was not taken and
930
   it is not used in any other non-standard way.  */
931
 
932
static inline bool
933
cgraph_only_called_directly_or_aliased_p (struct cgraph_node *node)
934
{
935
  gcc_assert (!node->global.inlined_to);
936
  return (!node->needed && !node->address_taken
937
          && !node->reachable_from_other_partition
938
          && !DECL_STATIC_CONSTRUCTOR (node->decl)
939
          && !DECL_STATIC_DESTRUCTOR (node->decl)
940
          && !node->local.externally_visible);
941
}
942
 
943
/* Return true when function NODE can be removed from callgraph
944
   if all direct calls are eliminated.  */
945
 
946
static inline bool
947
varpool_can_remove_if_no_refs (struct varpool_node *node)
948
{
949
  return (!node->force_output && !node->used_from_other_partition
950
          && (flag_toplevel_reorder || DECL_COMDAT (node->decl)
951
              || DECL_ARTIFICIAL (node->decl))
952
          && (DECL_COMDAT (node->decl) || !node->externally_visible));
953
}
954
 
955
/* Return true when all references to VNODE must be visible in ipa_ref_list.
956
   i.e. if the variable is not externally visible or not used in some magic
957
   way (asm statement or such).
958
   The magic uses are all summarized in force_output flag.  */
959
 
960
static inline bool
961
varpool_all_refs_explicit_p (struct varpool_node *vnode)
962
{
963
  return (vnode->analyzed
964
          && !vnode->externally_visible
965
          && !vnode->used_from_other_partition
966
          && !vnode->force_output);
967
}
968
 
969
/* Constant pool accessor function.  */
970
htab_t constant_pool_htab (void);
971
 
972
/* FIXME: inappropriate dependency of cgraph on IPA.  */
973
#include "ipa-ref-inline.h"
974
 
975
/* Return node that alias N is aliasing.  */
976
 
977
static inline struct cgraph_node *
978
cgraph_alias_aliased_node (struct cgraph_node *n)
979
{
980
  struct ipa_ref *ref;
981
 
982
  ipa_ref_list_reference_iterate (&n->ref_list, 0, ref);
983
  gcc_checking_assert (ref->use == IPA_REF_ALIAS);
984
  if (ref->refered_type == IPA_REF_CGRAPH)
985
    return ipa_ref_node (ref);
986
  return NULL;
987
}
988
 
989
/* Return node that alias N is aliasing.  */
990
 
991
static inline struct varpool_node *
992
varpool_alias_aliased_node (struct varpool_node *n)
993
{
994
  struct ipa_ref *ref;
995
 
996
  ipa_ref_list_reference_iterate (&n->ref_list, 0, ref);
997
  gcc_checking_assert (ref->use == IPA_REF_ALIAS);
998
  if (ref->refered_type == IPA_REF_VARPOOL)
999
    return ipa_ref_varpool_node (ref);
1000
  return NULL;
1001
}
1002
 
1003
/* Given NODE, walk the alias chain to return the function NODE is alias of.
1004
   Walk through thunk, too.
1005
   When AVAILABILITY is non-NULL, get minimal availablity in the chain.  */
1006
 
1007
static inline struct cgraph_node *
1008
cgraph_function_node (struct cgraph_node *node, enum availability *availability)
1009
{
1010
  if (availability)
1011
    *availability = cgraph_function_body_availability (node);
1012
  while (node)
1013
    {
1014
      if (node->alias && node->analyzed)
1015
        node = cgraph_alias_aliased_node (node);
1016
      else if (node->thunk.thunk_p)
1017
        node = node->callees->callee;
1018
      else
1019
        return node;
1020
      if (node && availability)
1021
        {
1022
          enum availability a;
1023
          a = cgraph_function_body_availability (node);
1024
          if (a < *availability)
1025
            *availability = a;
1026
        }
1027
    }
1028
  if (availability)
1029
    *availability = AVAIL_NOT_AVAILABLE;
1030
  return NULL;
1031
}
1032
 
1033
/* Given NODE, walk the alias chain to return the function NODE is alias of.
1034
   Do not walk through thunks.
1035
   When AVAILABILITY is non-NULL, get minimal availablity in the chain.  */
1036
 
1037
static inline struct cgraph_node *
1038
cgraph_function_or_thunk_node (struct cgraph_node *node, enum availability *availability)
1039
{
1040
  if (availability)
1041
    *availability = cgraph_function_body_availability (node);
1042
  while (node)
1043
    {
1044
      if (node->alias && node->analyzed)
1045
        node = cgraph_alias_aliased_node (node);
1046
      else
1047
        return node;
1048
      if (node && availability)
1049
        {
1050
          enum availability a;
1051
          a = cgraph_function_body_availability (node);
1052
          if (a < *availability)
1053
            *availability = a;
1054
        }
1055
    }
1056
  if (availability)
1057
    *availability = AVAIL_NOT_AVAILABLE;
1058
  return NULL;
1059
}
1060
 
1061
/* Given NODE, walk the alias chain to return the function NODE is alias of.
1062
   Do not walk through thunks.
1063
   When AVAILABILITY is non-NULL, get minimal availablity in the chain.  */
1064
 
1065
static inline struct varpool_node *
1066
varpool_variable_node (struct varpool_node *node, enum availability *availability)
1067
{
1068
  if (availability)
1069
    *availability = cgraph_variable_initializer_availability (node);
1070
  while (node)
1071
    {
1072
      if (node->alias && node->analyzed)
1073
        node = varpool_alias_aliased_node (node);
1074
      else
1075
        return node;
1076
      if (node && availability)
1077
        {
1078
          enum availability a;
1079
          a = cgraph_variable_initializer_availability (node);
1080
          if (a < *availability)
1081
            *availability = a;
1082
        }
1083
    }
1084
  if (availability)
1085
    *availability = AVAIL_NOT_AVAILABLE;
1086
  return NULL;
1087
}
1088
 
1089
/* Return true when the edge E represents a direct recursion.  */
1090
static inline bool
1091
cgraph_edge_recursive_p (struct cgraph_edge *e)
1092
{
1093
  struct cgraph_node *callee = cgraph_function_or_thunk_node (e->callee, NULL);
1094
  if (e->caller->global.inlined_to)
1095
    return e->caller->global.inlined_to->decl == callee->decl;
1096
  else
1097
    return e->caller->decl == callee->decl;
1098
}
1099
 
1100
/* Return true if the TM_CLONE bit is set for a given FNDECL.  */
1101
static inline bool
1102
decl_is_tm_clone (const_tree fndecl)
1103
{
1104
  struct cgraph_node *n = cgraph_get_node (fndecl);
1105
  if (n)
1106
    return n->tm_clone;
1107
  return false;
1108
}
1109
#endif  /* GCC_CGRAPH_H  */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.