annotate gcc/lto-cgraph.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents f6334be47118
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /* Write and read the cgraph to the memory mapped representation of a
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 .o file.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3
111
kono
parents: 67
diff changeset
4 Copyright (C) 2009-2017 Free Software Foundation, Inc.
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 Contributed by Kenneth Zadeck <zadeck@naturalbridge.com>
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 This file is part of GCC.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 GCC is free software; you can redistribute it and/or modify it under
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 the terms of the GNU General Public License as published by the Free
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 Software Foundation; either version 3, or (at your option) any later
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 version.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 for more details.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 along with GCC; see the file COPYING3. If not see
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 <http://www.gnu.org/licenses/>. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 #include "config.h"
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 #include "system.h"
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 #include "coretypes.h"
111
kono
parents: 67
diff changeset
26 #include "backend.h"
kono
parents: 67
diff changeset
27 #include "rtl.h"
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 #include "tree.h"
111
kono
parents: 67
diff changeset
29 #include "gimple.h"
kono
parents: 67
diff changeset
30 #include "predict.h"
kono
parents: 67
diff changeset
31 #include "stringpool.h"
kono
parents: 67
diff changeset
32 #include "tree-streamer.h"
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 #include "cgraph.h"
111
kono
parents: 67
diff changeset
34 #include "tree-pass.h"
kono
parents: 67
diff changeset
35 #include "profile.h"
kono
parents: 67
diff changeset
36 #include "context.h"
kono
parents: 67
diff changeset
37 #include "pass_manager.h"
kono
parents: 67
diff changeset
38 #include "ipa-utils.h"
kono
parents: 67
diff changeset
39 #include "omp-offload.h"
kono
parents: 67
diff changeset
40 #include "ipa-chkp.h"
kono
parents: 67
diff changeset
41 #include "stringpool.h"
kono
parents: 67
diff changeset
42 #include "attribs.h"
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43
111
kono
parents: 67
diff changeset
44 /* True when asm nodes has been output. */
kono
parents: 67
diff changeset
45 bool asm_nodes_output = false;
kono
parents: 67
diff changeset
46
kono
parents: 67
diff changeset
47 static void output_cgraph_opt_summary (void);
kono
parents: 67
diff changeset
48 static void input_cgraph_opt_summary (vec<symtab_node *> nodes);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
49
111
kono
parents: 67
diff changeset
50 /* Number of LDPR values known to GCC. */
kono
parents: 67
diff changeset
51 #define LDPR_NUM_KNOWN (LDPR_PREVAILING_DEF_IRONLY_EXP + 1)
kono
parents: 67
diff changeset
52
kono
parents: 67
diff changeset
53 /* All node orders are ofsetted by ORDER_BASE. */
kono
parents: 67
diff changeset
54 static int order_base;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
55
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
56 /* Cgraph streaming is organized as set of record whose type
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
57 is indicated by a tag. */
111
kono
parents: 67
diff changeset
58 enum LTO_symtab_tags
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
59 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
60 /* Must leave 0 for the stopper. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
61
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
62 /* Cgraph node without body available. */
111
kono
parents: 67
diff changeset
63 LTO_symtab_unavail_node = 1,
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
64 /* Cgraph node with function body. */
111
kono
parents: 67
diff changeset
65 LTO_symtab_analyzed_node,
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
66 /* Cgraph edges. */
111
kono
parents: 67
diff changeset
67 LTO_symtab_edge,
kono
parents: 67
diff changeset
68 LTO_symtab_indirect_edge,
kono
parents: 67
diff changeset
69 LTO_symtab_variable,
kono
parents: 67
diff changeset
70 LTO_symtab_last_tag
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
71 };
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
72
111
kono
parents: 67
diff changeset
73 /* Create a new symtab encoder.
kono
parents: 67
diff changeset
74 if FOR_INPUT, the encoder allocate only datastructures needed
kono
parents: 67
diff changeset
75 to read the symtab. */
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
76
111
kono
parents: 67
diff changeset
77 lto_symtab_encoder_t
kono
parents: 67
diff changeset
78 lto_symtab_encoder_new (bool for_input)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 {
111
kono
parents: 67
diff changeset
80 lto_symtab_encoder_t encoder = XCNEW (struct lto_symtab_encoder_d);
kono
parents: 67
diff changeset
81
kono
parents: 67
diff changeset
82 if (!for_input)
kono
parents: 67
diff changeset
83 encoder->map = new hash_map<symtab_node *, size_t>;
kono
parents: 67
diff changeset
84 encoder->nodes.create (0);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 return encoder;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
87
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
88
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 /* Delete ENCODER and its components. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
90
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 void
111
kono
parents: 67
diff changeset
92 lto_symtab_encoder_delete (lto_symtab_encoder_t encoder)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 {
111
kono
parents: 67
diff changeset
94 encoder->nodes.release ();
kono
parents: 67
diff changeset
95 if (encoder->map)
kono
parents: 67
diff changeset
96 delete encoder->map;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 free (encoder);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
99
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
100
111
kono
parents: 67
diff changeset
101 /* Return the existing reference number of NODE in the symtab encoder in
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 output block OB. Assign a new reference if this is the first time
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 NODE is encoded. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
104
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 int
111
kono
parents: 67
diff changeset
106 lto_symtab_encoder_encode (lto_symtab_encoder_t encoder,
kono
parents: 67
diff changeset
107 symtab_node *node)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 int ref;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
110
111
kono
parents: 67
diff changeset
111 if (!encoder->map)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 {
111
kono
parents: 67
diff changeset
113 lto_encoder_entry entry = {node, false, false, false};
kono
parents: 67
diff changeset
114
kono
parents: 67
diff changeset
115 ref = encoder->nodes.length ();
kono
parents: 67
diff changeset
116 encoder->nodes.safe_push (entry);
kono
parents: 67
diff changeset
117 return ref;
kono
parents: 67
diff changeset
118 }
kono
parents: 67
diff changeset
119
kono
parents: 67
diff changeset
120 size_t *slot = encoder->map->get (node);
kono
parents: 67
diff changeset
121 if (!slot || !*slot)
kono
parents: 67
diff changeset
122 {
kono
parents: 67
diff changeset
123 lto_encoder_entry entry = {node, false, false, false};
kono
parents: 67
diff changeset
124 ref = encoder->nodes.length ();
kono
parents: 67
diff changeset
125 if (!slot)
kono
parents: 67
diff changeset
126 encoder->map->put (node, ref + 1);
kono
parents: 67
diff changeset
127 encoder->nodes.safe_push (entry);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
129 else
111
kono
parents: 67
diff changeset
130 ref = *slot - 1;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
131
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 return ref;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
134
111
kono
parents: 67
diff changeset
135 /* Remove NODE from encoder. */
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
136
111
kono
parents: 67
diff changeset
137 bool
kono
parents: 67
diff changeset
138 lto_symtab_encoder_delete_node (lto_symtab_encoder_t encoder,
kono
parents: 67
diff changeset
139 symtab_node *node)
kono
parents: 67
diff changeset
140 {
kono
parents: 67
diff changeset
141 int index;
kono
parents: 67
diff changeset
142 lto_encoder_entry last_node;
kono
parents: 67
diff changeset
143
kono
parents: 67
diff changeset
144 size_t *slot = encoder->map->get (node);
kono
parents: 67
diff changeset
145 if (slot == NULL || !*slot)
kono
parents: 67
diff changeset
146 return false;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
147
111
kono
parents: 67
diff changeset
148 index = *slot - 1;
kono
parents: 67
diff changeset
149 gcc_checking_assert (encoder->nodes[index].node == node);
kono
parents: 67
diff changeset
150
kono
parents: 67
diff changeset
151 /* Remove from vector. We do this by swapping node with the last element
kono
parents: 67
diff changeset
152 of the vector. */
kono
parents: 67
diff changeset
153 last_node = encoder->nodes.pop ();
kono
parents: 67
diff changeset
154 if (last_node.node != node)
kono
parents: 67
diff changeset
155 {
kono
parents: 67
diff changeset
156 gcc_assert (encoder->map->put (last_node.node, index + 1));
kono
parents: 67
diff changeset
157
kono
parents: 67
diff changeset
158 /* Move the last element to the original spot of NODE. */
kono
parents: 67
diff changeset
159 encoder->nodes[index] = last_node;
kono
parents: 67
diff changeset
160 }
kono
parents: 67
diff changeset
161
kono
parents: 67
diff changeset
162 /* Remove element from hash table. */
kono
parents: 67
diff changeset
163 encoder->map->remove (node);
kono
parents: 67
diff changeset
164 return true;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
166
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
167
111
kono
parents: 67
diff changeset
168 /* Return TRUE if we should encode the body of NODE (if any). */
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
169
111
kono
parents: 67
diff changeset
170 bool
kono
parents: 67
diff changeset
171 lto_symtab_encoder_encode_body_p (lto_symtab_encoder_t encoder,
kono
parents: 67
diff changeset
172 struct cgraph_node *node)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
173 {
111
kono
parents: 67
diff changeset
174 int index = lto_symtab_encoder_lookup (encoder, node);
kono
parents: 67
diff changeset
175 return encoder->nodes[index].body;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
176 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
177
111
kono
parents: 67
diff changeset
178 /* Specify that we encode the body of NODE in this partition. */
kono
parents: 67
diff changeset
179
kono
parents: 67
diff changeset
180 static void
kono
parents: 67
diff changeset
181 lto_set_symtab_encoder_encode_body (lto_symtab_encoder_t encoder,
kono
parents: 67
diff changeset
182 struct cgraph_node *node)
kono
parents: 67
diff changeset
183 {
kono
parents: 67
diff changeset
184 int index = lto_symtab_encoder_encode (encoder, node);
kono
parents: 67
diff changeset
185 gcc_checking_assert (encoder->nodes[index].node == node);
kono
parents: 67
diff changeset
186 encoder->nodes[index].body = true;
kono
parents: 67
diff changeset
187 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
188
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
189 /* Return TRUE if we should encode initializer of NODE (if any). */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
190
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
191 bool
111
kono
parents: 67
diff changeset
192 lto_symtab_encoder_encode_initializer_p (lto_symtab_encoder_t encoder,
kono
parents: 67
diff changeset
193 varpool_node *node)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
194 {
111
kono
parents: 67
diff changeset
195 int index = lto_symtab_encoder_lookup (encoder, node);
kono
parents: 67
diff changeset
196 if (index == LCC_NOT_FOUND)
kono
parents: 67
diff changeset
197 return false;
kono
parents: 67
diff changeset
198 return encoder->nodes[index].initializer;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
199 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
200
111
kono
parents: 67
diff changeset
201 /* Specify that we should encode initializer of NODE (if any). */
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
202
111
kono
parents: 67
diff changeset
203 static void
kono
parents: 67
diff changeset
204 lto_set_symtab_encoder_encode_initializer (lto_symtab_encoder_t encoder,
kono
parents: 67
diff changeset
205 varpool_node *node)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
206 {
111
kono
parents: 67
diff changeset
207 int index = lto_symtab_encoder_lookup (encoder, node);
kono
parents: 67
diff changeset
208 encoder->nodes[index].initializer = true;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
209 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
210
111
kono
parents: 67
diff changeset
211 /* Return TRUE if NODE is in this partition. */
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
212
111
kono
parents: 67
diff changeset
213 bool
kono
parents: 67
diff changeset
214 lto_symtab_encoder_in_partition_p (lto_symtab_encoder_t encoder,
kono
parents: 67
diff changeset
215 symtab_node *node)
kono
parents: 67
diff changeset
216 {
kono
parents: 67
diff changeset
217 int index = lto_symtab_encoder_lookup (encoder, node);
kono
parents: 67
diff changeset
218 if (index == LCC_NOT_FOUND)
kono
parents: 67
diff changeset
219 return false;
kono
parents: 67
diff changeset
220 return encoder->nodes[index].in_partition;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
221 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
222
111
kono
parents: 67
diff changeset
223 /* Specify that NODE is in this partition. */
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
224
111
kono
parents: 67
diff changeset
225 void
kono
parents: 67
diff changeset
226 lto_set_symtab_encoder_in_partition (lto_symtab_encoder_t encoder,
kono
parents: 67
diff changeset
227 symtab_node *node)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
228 {
111
kono
parents: 67
diff changeset
229 int index = lto_symtab_encoder_encode (encoder, node);
kono
parents: 67
diff changeset
230 encoder->nodes[index].in_partition = true;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
231 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
232
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
233 /* Output the cgraph EDGE to OB using ENCODER. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
234
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
235 static void
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
236 lto_output_edge (struct lto_simple_output_block *ob, struct cgraph_edge *edge,
111
kono
parents: 67
diff changeset
237 lto_symtab_encoder_t encoder)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
239 unsigned int uid;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
240 intptr_t ref;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
241 struct bitpack_d bp;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
242
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
243 if (edge->indirect_unknown_callee)
111
kono
parents: 67
diff changeset
244 streamer_write_enum (ob->main_stream, LTO_symtab_tags, LTO_symtab_last_tag,
kono
parents: 67
diff changeset
245 LTO_symtab_indirect_edge);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
246 else
111
kono
parents: 67
diff changeset
247 streamer_write_enum (ob->main_stream, LTO_symtab_tags, LTO_symtab_last_tag,
kono
parents: 67
diff changeset
248 LTO_symtab_edge);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
249
111
kono
parents: 67
diff changeset
250 ref = lto_symtab_encoder_lookup (encoder, edge->caller);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
251 gcc_assert (ref != LCC_NOT_FOUND);
111
kono
parents: 67
diff changeset
252 streamer_write_hwi_stream (ob->main_stream, ref);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
253
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
254 if (!edge->indirect_unknown_callee)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
255 {
111
kono
parents: 67
diff changeset
256 ref = lto_symtab_encoder_lookup (encoder, edge->callee);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
257 gcc_assert (ref != LCC_NOT_FOUND);
111
kono
parents: 67
diff changeset
258 streamer_write_hwi_stream (ob->main_stream, ref);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
259 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
260
111
kono
parents: 67
diff changeset
261 edge->count.stream_out (ob->main_stream);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
262
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
263 bp = bitpack_create (ob->main_stream);
111
kono
parents: 67
diff changeset
264 uid = (!gimple_has_body_p (edge->caller->decl) || edge->caller->thunk.thunk_p
kono
parents: 67
diff changeset
265 ? edge->lto_stmt_uid : gimple_uid (edge->call_stmt) + 1);
kono
parents: 67
diff changeset
266 bp_pack_enum (&bp, cgraph_inline_failed_t,
kono
parents: 67
diff changeset
267 CIF_N_REASONS, edge->inline_failed);
kono
parents: 67
diff changeset
268 bp_pack_var_len_unsigned (&bp, uid);
kono
parents: 67
diff changeset
269 bp_pack_var_len_unsigned (&bp, edge->frequency);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
270 bp_pack_value (&bp, edge->indirect_inlining_edge, 1);
111
kono
parents: 67
diff changeset
271 bp_pack_value (&bp, edge->speculative, 1);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
272 bp_pack_value (&bp, edge->call_stmt_cannot_inline_p, 1);
111
kono
parents: 67
diff changeset
273 gcc_assert (!edge->call_stmt_cannot_inline_p
kono
parents: 67
diff changeset
274 || edge->inline_failed != CIF_BODY_NOT_AVAILABLE);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
275 bp_pack_value (&bp, edge->can_throw_external, 1);
111
kono
parents: 67
diff changeset
276 bp_pack_value (&bp, edge->in_polymorphic_cdtor, 1);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
277 if (edge->indirect_unknown_callee)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
278 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
279 int flags = edge->indirect_info->ecf_flags;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
280 bp_pack_value (&bp, (flags & ECF_CONST) != 0, 1);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
281 bp_pack_value (&bp, (flags & ECF_PURE) != 0, 1);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
282 bp_pack_value (&bp, (flags & ECF_NORETURN) != 0, 1);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
283 bp_pack_value (&bp, (flags & ECF_MALLOC) != 0, 1);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
284 bp_pack_value (&bp, (flags & ECF_NOTHROW) != 0, 1);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
285 bp_pack_value (&bp, (flags & ECF_RETURNS_TWICE) != 0, 1);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
286 /* Flags that should not appear on indirect calls. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
287 gcc_assert (!(flags & (ECF_LOOPING_CONST_OR_PURE
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
288 | ECF_MAY_BE_ALLOCA
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
289 | ECF_SIBCALL
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
290 | ECF_LEAF
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
291 | ECF_NOVOPS)));
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
292 }
111
kono
parents: 67
diff changeset
293 streamer_write_bitpack (&bp);
kono
parents: 67
diff changeset
294 if (edge->indirect_unknown_callee)
kono
parents: 67
diff changeset
295 {
kono
parents: 67
diff changeset
296 streamer_write_hwi_stream (ob->main_stream,
kono
parents: 67
diff changeset
297 edge->indirect_info->common_target_id);
kono
parents: 67
diff changeset
298 if (edge->indirect_info->common_target_id)
kono
parents: 67
diff changeset
299 streamer_write_hwi_stream
kono
parents: 67
diff changeset
300 (ob->main_stream, edge->indirect_info->common_target_probability);
kono
parents: 67
diff changeset
301 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
302 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
303
111
kono
parents: 67
diff changeset
304 /* Return if NODE contain references from other partitions. */
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
305
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
306 bool
111
kono
parents: 67
diff changeset
307 referenced_from_other_partition_p (symtab_node *node, lto_symtab_encoder_t encoder)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
308 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
309 int i;
111
kono
parents: 67
diff changeset
310 struct ipa_ref *ref = NULL;
kono
parents: 67
diff changeset
311
kono
parents: 67
diff changeset
312 for (i = 0; node->iterate_referring (i, ref); i++)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
313 {
111
kono
parents: 67
diff changeset
314 /* Ignore references from non-offloadable nodes while streaming NODE into
kono
parents: 67
diff changeset
315 offload LTO section. */
kono
parents: 67
diff changeset
316 if (!ref->referring->need_lto_streaming)
kono
parents: 67
diff changeset
317 continue;
kono
parents: 67
diff changeset
318
kono
parents: 67
diff changeset
319 if (ref->referring->in_other_partition
kono
parents: 67
diff changeset
320 || !lto_symtab_encoder_in_partition_p (encoder, ref->referring))
kono
parents: 67
diff changeset
321 return true;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
322 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
323 return false;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
324 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
325
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
326 /* Return true when node is reachable from other partition. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
327
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
328 bool
111
kono
parents: 67
diff changeset
329 reachable_from_other_partition_p (struct cgraph_node *node, lto_symtab_encoder_t encoder)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
330 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
331 struct cgraph_edge *e;
111
kono
parents: 67
diff changeset
332 if (!node->definition)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
333 return false;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
334 if (node->global.inlined_to)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
335 return false;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
336 for (e = node->callers; e; e = e->next_caller)
111
kono
parents: 67
diff changeset
337 {
kono
parents: 67
diff changeset
338 /* Ignore references from non-offloadable nodes while streaming NODE into
kono
parents: 67
diff changeset
339 offload LTO section. */
kono
parents: 67
diff changeset
340 if (!e->caller->need_lto_streaming)
kono
parents: 67
diff changeset
341 continue;
kono
parents: 67
diff changeset
342
kono
parents: 67
diff changeset
343 if (e->caller->in_other_partition
kono
parents: 67
diff changeset
344 || !lto_symtab_encoder_in_partition_p (encoder, e->caller))
kono
parents: 67
diff changeset
345 return true;
kono
parents: 67
diff changeset
346 }
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
347 return false;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
348 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
349
111
kono
parents: 67
diff changeset
350 /* Return if NODE contain references from other partitions. */
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
351
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
352 bool
111
kono
parents: 67
diff changeset
353 referenced_from_this_partition_p (symtab_node *node,
kono
parents: 67
diff changeset
354 lto_symtab_encoder_t encoder)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
355 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
356 int i;
111
kono
parents: 67
diff changeset
357 struct ipa_ref *ref = NULL;
kono
parents: 67
diff changeset
358
kono
parents: 67
diff changeset
359 for (i = 0; node->iterate_referring (i, ref); i++)
kono
parents: 67
diff changeset
360 if (lto_symtab_encoder_in_partition_p (encoder, ref->referring))
kono
parents: 67
diff changeset
361 return true;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
362 return false;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
363 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
364
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
365 /* Return true when node is reachable from other partition. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
366
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
367 bool
111
kono
parents: 67
diff changeset
368 reachable_from_this_partition_p (struct cgraph_node *node, lto_symtab_encoder_t encoder)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
369 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
370 struct cgraph_edge *e;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
371 for (e = node->callers; e; e = e->next_caller)
111
kono
parents: 67
diff changeset
372 if (lto_symtab_encoder_in_partition_p (encoder, e->caller))
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
373 return true;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
374 return false;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
375 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
376
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
377 /* Output the cgraph NODE to OB. ENCODER is used to find the
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
378 reference number of NODE->inlined_to. SET is the set of nodes we
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
379 are writing to the current file. If NODE is not in SET, then NODE
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
380 is a boundary of a cgraph_node_set and we pretend NODE just has a
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
381 decl and no callees. WRITTEN_DECLS is the set of FUNCTION_DECLs
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
382 that have had their callgraph node written so far. This is used to
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
383 determine if NODE is a clone of a previously written node. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
384
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
385 static void
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
386 lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node,
111
kono
parents: 67
diff changeset
387 lto_symtab_encoder_t encoder)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
388 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
389 unsigned int tag;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
390 struct bitpack_d bp;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
391 bool boundary_p;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
392 intptr_t ref;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
393 bool in_other_partition = false;
111
kono
parents: 67
diff changeset
394 struct cgraph_node *clone_of, *ultimate_clone_of;
kono
parents: 67
diff changeset
395 ipa_opt_pass_d *pass;
kono
parents: 67
diff changeset
396 int i;
kono
parents: 67
diff changeset
397 const char *comdat;
kono
parents: 67
diff changeset
398 const char *section;
kono
parents: 67
diff changeset
399 tree group;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
400
111
kono
parents: 67
diff changeset
401 boundary_p = !lto_symtab_encoder_in_partition_p (encoder, node);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
402
111
kono
parents: 67
diff changeset
403 if (node->analyzed && (!boundary_p || node->alias
kono
parents: 67
diff changeset
404 || (node->thunk.thunk_p && !node->global.inlined_to)))
kono
parents: 67
diff changeset
405 tag = LTO_symtab_analyzed_node;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
406 else
111
kono
parents: 67
diff changeset
407 tag = LTO_symtab_unavail_node;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
408
111
kono
parents: 67
diff changeset
409 streamer_write_enum (ob->main_stream, LTO_symtab_tags, LTO_symtab_last_tag,
kono
parents: 67
diff changeset
410 tag);
kono
parents: 67
diff changeset
411 streamer_write_hwi_stream (ob->main_stream, node->order);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
412
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
413 /* In WPA mode, we only output part of the call-graph. Also, we
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
414 fake cgraph node attributes. There are two cases that we care.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
415
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
416 Boundary nodes: There are nodes that are not part of SET but are
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
417 called from within SET. We artificially make them look like
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
418 externally visible nodes with no function body.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
419
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
420 Cherry-picked nodes: These are nodes we pulled from other
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
421 translation units into SET during IPA-inlining. We make them as
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
422 local static nodes to prevent clashes with other local statics. */
111
kono
parents: 67
diff changeset
423 if (boundary_p && node->analyzed
kono
parents: 67
diff changeset
424 && node->get_partitioning_class () == SYMBOL_PARTITION)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
425 {
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
426 /* Inline clones can not be part of boundary.
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
427 gcc_assert (!node->global.inlined_to);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
428
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
429 FIXME: At the moment they can be, when partition contains an inline
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
430 clone that is clone of inline clone from outside partition. We can
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
431 reshape the clone tree and make other tree to be the root, but it
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
432 needs a bit extra work and will be promplty done by cgraph_remove_node
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
433 after reading back. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
434 in_other_partition = 1;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
435 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
436
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
437 clone_of = node->clone_of;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
438 while (clone_of
111
kono
parents: 67
diff changeset
439 && (ref = lto_symtab_encoder_lookup (encoder, clone_of)) == LCC_NOT_FOUND)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
440 if (clone_of->prev_sibling_clone)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
441 clone_of = clone_of->prev_sibling_clone;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
442 else
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
443 clone_of = clone_of->clone_of;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
444
111
kono
parents: 67
diff changeset
445 /* See if body of the master function is output. If not, we are seeing only
kono
parents: 67
diff changeset
446 an declaration and we do not need to pass down clone tree. */
kono
parents: 67
diff changeset
447 ultimate_clone_of = clone_of;
kono
parents: 67
diff changeset
448 while (ultimate_clone_of && ultimate_clone_of->clone_of)
kono
parents: 67
diff changeset
449 ultimate_clone_of = ultimate_clone_of->clone_of;
kono
parents: 67
diff changeset
450
kono
parents: 67
diff changeset
451 if (clone_of && !lto_symtab_encoder_encode_body_p (encoder, ultimate_clone_of))
kono
parents: 67
diff changeset
452 clone_of = NULL;
kono
parents: 67
diff changeset
453
kono
parents: 67
diff changeset
454 if (tag == LTO_symtab_analyzed_node)
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
455 gcc_assert (clone_of || !node->clone_of);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
456 if (!clone_of)
111
kono
parents: 67
diff changeset
457 streamer_write_hwi_stream (ob->main_stream, LCC_NOT_FOUND);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
458 else
111
kono
parents: 67
diff changeset
459 streamer_write_hwi_stream (ob->main_stream, ref);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
460
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
461
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
462 lto_output_fn_decl_index (ob->decl_state, ob->main_stream, node->decl);
111
kono
parents: 67
diff changeset
463 node->count.stream_out (ob->main_stream);
kono
parents: 67
diff changeset
464 streamer_write_hwi_stream (ob->main_stream, node->count_materialization_scale);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
465
111
kono
parents: 67
diff changeset
466 streamer_write_hwi_stream (ob->main_stream,
kono
parents: 67
diff changeset
467 node->ipa_transforms_to_apply.length ());
kono
parents: 67
diff changeset
468 FOR_EACH_VEC_ELT (node->ipa_transforms_to_apply, i, pass)
kono
parents: 67
diff changeset
469 streamer_write_hwi_stream (ob->main_stream, pass->static_pass_number);
kono
parents: 67
diff changeset
470
kono
parents: 67
diff changeset
471 if (tag == LTO_symtab_analyzed_node)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
472 {
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
473 if (node->global.inlined_to)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
474 {
111
kono
parents: 67
diff changeset
475 ref = lto_symtab_encoder_lookup (encoder, node->global.inlined_to);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
476 gcc_assert (ref != LCC_NOT_FOUND);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
477 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
478 else
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
479 ref = LCC_NOT_FOUND;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
480
111
kono
parents: 67
diff changeset
481 streamer_write_hwi_stream (ob->main_stream, ref);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
482 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
483
111
kono
parents: 67
diff changeset
484 group = node->get_comdat_group ();
kono
parents: 67
diff changeset
485 if (group)
kono
parents: 67
diff changeset
486 comdat = IDENTIFIER_POINTER (group);
kono
parents: 67
diff changeset
487 else
kono
parents: 67
diff changeset
488 comdat = "";
kono
parents: 67
diff changeset
489 streamer_write_data_stream (ob->main_stream, comdat, strlen (comdat) + 1);
kono
parents: 67
diff changeset
490
kono
parents: 67
diff changeset
491 if (group)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
492 {
111
kono
parents: 67
diff changeset
493 if (node->same_comdat_group)
kono
parents: 67
diff changeset
494 {
kono
parents: 67
diff changeset
495 ref = LCC_NOT_FOUND;
kono
parents: 67
diff changeset
496 for (struct symtab_node *n = node->same_comdat_group;
kono
parents: 67
diff changeset
497 ref == LCC_NOT_FOUND && n != node; n = n->same_comdat_group)
kono
parents: 67
diff changeset
498 ref = lto_symtab_encoder_lookup (encoder, n);
kono
parents: 67
diff changeset
499 }
kono
parents: 67
diff changeset
500 else
kono
parents: 67
diff changeset
501 ref = LCC_NOT_FOUND;
kono
parents: 67
diff changeset
502 streamer_write_hwi_stream (ob->main_stream, ref);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
503 }
111
kono
parents: 67
diff changeset
504
kono
parents: 67
diff changeset
505 section = node->get_section ();
kono
parents: 67
diff changeset
506 if (!section)
kono
parents: 67
diff changeset
507 section = "";
kono
parents: 67
diff changeset
508
kono
parents: 67
diff changeset
509 streamer_write_hwi_stream (ob->main_stream, node->tp_first_run);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
510
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
511 bp = bitpack_create (ob->main_stream);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
512 bp_pack_value (&bp, node->local.local, 1);
111
kono
parents: 67
diff changeset
513 bp_pack_value (&bp, node->externally_visible, 1);
kono
parents: 67
diff changeset
514 bp_pack_value (&bp, node->no_reorder, 1);
kono
parents: 67
diff changeset
515 bp_pack_value (&bp, node->definition, 1);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
516 bp_pack_value (&bp, node->local.versionable, 1);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
517 bp_pack_value (&bp, node->local.can_change_signature, 1);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
518 bp_pack_value (&bp, node->local.redefined_extern_inline, 1);
111
kono
parents: 67
diff changeset
519 bp_pack_value (&bp, node->force_output, 1);
kono
parents: 67
diff changeset
520 bp_pack_value (&bp, node->forced_by_abi, 1);
kono
parents: 67
diff changeset
521 bp_pack_value (&bp, node->unique_name, 1);
kono
parents: 67
diff changeset
522 bp_pack_value (&bp, node->body_removed, 1);
kono
parents: 67
diff changeset
523 bp_pack_value (&bp, node->implicit_section, 1);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
524 bp_pack_value (&bp, node->address_taken, 1);
111
kono
parents: 67
diff changeset
525 bp_pack_value (&bp, tag == LTO_symtab_analyzed_node
kono
parents: 67
diff changeset
526 && node->get_partitioning_class () == SYMBOL_PARTITION
kono
parents: 67
diff changeset
527 && (reachable_from_other_partition_p (node, encoder)
kono
parents: 67
diff changeset
528 || referenced_from_other_partition_p (node, encoder)), 1);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
529 bp_pack_value (&bp, node->lowered, 1);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
530 bp_pack_value (&bp, in_other_partition, 1);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
531 bp_pack_value (&bp, node->alias, 1);
111
kono
parents: 67
diff changeset
532 bp_pack_value (&bp, node->transparent_alias, 1);
kono
parents: 67
diff changeset
533 bp_pack_value (&bp, node->weakref, 1);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
534 bp_pack_value (&bp, node->frequency, 2);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
535 bp_pack_value (&bp, node->only_called_at_startup, 1);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
536 bp_pack_value (&bp, node->only_called_at_exit, 1);
111
kono
parents: 67
diff changeset
537 bp_pack_value (&bp, node->tm_clone, 1);
kono
parents: 67
diff changeset
538 bp_pack_value (&bp, node->calls_comdat_local, 1);
kono
parents: 67
diff changeset
539 bp_pack_value (&bp, node->icf_merged, 1);
kono
parents: 67
diff changeset
540 bp_pack_value (&bp, node->nonfreeing_fn, 1);
kono
parents: 67
diff changeset
541 bp_pack_value (&bp, node->thunk.thunk_p, 1);
kono
parents: 67
diff changeset
542 bp_pack_value (&bp, node->parallelized_function, 1);
kono
parents: 67
diff changeset
543 bp_pack_enum (&bp, ld_plugin_symbol_resolution,
kono
parents: 67
diff changeset
544 LDPR_NUM_KNOWN, node->resolution);
kono
parents: 67
diff changeset
545 bp_pack_value (&bp, node->instrumentation_clone, 1);
kono
parents: 67
diff changeset
546 bp_pack_value (&bp, node->split_part, 1);
kono
parents: 67
diff changeset
547 streamer_write_bitpack (&bp);
kono
parents: 67
diff changeset
548 streamer_write_data_stream (ob->main_stream, section, strlen (section) + 1);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
549
111
kono
parents: 67
diff changeset
550 if (node->thunk.thunk_p)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
551 {
111
kono
parents: 67
diff changeset
552 streamer_write_uhwi_stream
kono
parents: 67
diff changeset
553 (ob->main_stream,
kono
parents: 67
diff changeset
554 1 + (node->thunk.this_adjusting != 0) * 2
kono
parents: 67
diff changeset
555 + (node->thunk.virtual_offset_p != 0) * 4
kono
parents: 67
diff changeset
556 + (node->thunk.add_pointer_bounds_args != 0) * 8);
kono
parents: 67
diff changeset
557 streamer_write_uhwi_stream (ob->main_stream, node->thunk.fixed_offset);
kono
parents: 67
diff changeset
558 streamer_write_uhwi_stream (ob->main_stream, node->thunk.virtual_value);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
559 }
111
kono
parents: 67
diff changeset
560 streamer_write_hwi_stream (ob->main_stream, node->profile_id);
kono
parents: 67
diff changeset
561 if (DECL_STATIC_CONSTRUCTOR (node->decl))
kono
parents: 67
diff changeset
562 streamer_write_hwi_stream (ob->main_stream, node->get_init_priority ());
kono
parents: 67
diff changeset
563 if (DECL_STATIC_DESTRUCTOR (node->decl))
kono
parents: 67
diff changeset
564 streamer_write_hwi_stream (ob->main_stream, node->get_fini_priority ());
kono
parents: 67
diff changeset
565
kono
parents: 67
diff changeset
566 if (node->instrumentation_clone)
kono
parents: 67
diff changeset
567 lto_output_fn_decl_index (ob->decl_state, ob->main_stream, node->orig_decl);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
568 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
569
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
570 /* Output the varpool NODE to OB.
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
571 If NODE is not in SET, then NODE is a boundary. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
572
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
573 static void
111
kono
parents: 67
diff changeset
574 lto_output_varpool_node (struct lto_simple_output_block *ob, varpool_node *node,
kono
parents: 67
diff changeset
575 lto_symtab_encoder_t encoder)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
576 {
111
kono
parents: 67
diff changeset
577 bool boundary_p = !lto_symtab_encoder_in_partition_p (encoder, node);
kono
parents: 67
diff changeset
578 bool encode_initializer_p
kono
parents: 67
diff changeset
579 = (node->definition
kono
parents: 67
diff changeset
580 && lto_symtab_encoder_encode_initializer_p (encoder, node));
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
581 struct bitpack_d bp;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
582 int ref;
111
kono
parents: 67
diff changeset
583 const char *comdat;
kono
parents: 67
diff changeset
584 const char *section;
kono
parents: 67
diff changeset
585 tree group;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
586
111
kono
parents: 67
diff changeset
587 gcc_assert (!encode_initializer_p || node->definition);
kono
parents: 67
diff changeset
588 gcc_assert (boundary_p || encode_initializer_p);
kono
parents: 67
diff changeset
589
kono
parents: 67
diff changeset
590 streamer_write_enum (ob->main_stream, LTO_symtab_tags, LTO_symtab_last_tag,
kono
parents: 67
diff changeset
591 LTO_symtab_variable);
kono
parents: 67
diff changeset
592 streamer_write_hwi_stream (ob->main_stream, node->order);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
593 lto_output_var_decl_index (ob->decl_state, ob->main_stream, node->decl);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
594 bp = bitpack_create (ob->main_stream);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
595 bp_pack_value (&bp, node->externally_visible, 1);
111
kono
parents: 67
diff changeset
596 bp_pack_value (&bp, node->no_reorder, 1);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
597 bp_pack_value (&bp, node->force_output, 1);
111
kono
parents: 67
diff changeset
598 bp_pack_value (&bp, node->forced_by_abi, 1);
kono
parents: 67
diff changeset
599 bp_pack_value (&bp, node->unique_name, 1);
kono
parents: 67
diff changeset
600 bp_pack_value (&bp,
kono
parents: 67
diff changeset
601 node->body_removed
kono
parents: 67
diff changeset
602 || (!encode_initializer_p && !node->alias && node->definition),
kono
parents: 67
diff changeset
603 1);
kono
parents: 67
diff changeset
604 bp_pack_value (&bp, node->implicit_section, 1);
kono
parents: 67
diff changeset
605 bp_pack_value (&bp, node->writeonly, 1);
kono
parents: 67
diff changeset
606 bp_pack_value (&bp, node->definition && (encode_initializer_p || node->alias),
kono
parents: 67
diff changeset
607 1);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
608 bp_pack_value (&bp, node->alias, 1);
111
kono
parents: 67
diff changeset
609 bp_pack_value (&bp, node->transparent_alias, 1);
kono
parents: 67
diff changeset
610 bp_pack_value (&bp, node->weakref, 1);
kono
parents: 67
diff changeset
611 bp_pack_value (&bp, node->analyzed && (!boundary_p || node->alias), 1);
kono
parents: 67
diff changeset
612 gcc_assert (node->definition || !node->analyzed);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
613 /* Constant pool initializers can be de-unified into individual ltrans units.
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
614 FIXME: Alternatively at -Os we may want to avoid generating for them the local
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
615 labels and share them across LTRANS partitions. */
111
kono
parents: 67
diff changeset
616 if (node->get_partitioning_class () != SYMBOL_PARTITION)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
617 {
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
618 bp_pack_value (&bp, 0, 1); /* used_from_other_parition. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
619 bp_pack_value (&bp, 0, 1); /* in_other_partition. */
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
620 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
621 else
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
622 {
111
kono
parents: 67
diff changeset
623 bp_pack_value (&bp, node->definition
kono
parents: 67
diff changeset
624 && referenced_from_other_partition_p (node, encoder), 1);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
625 bp_pack_value (&bp, node->analyzed
111
kono
parents: 67
diff changeset
626 && boundary_p && !DECL_EXTERNAL (node->decl), 1);
kono
parents: 67
diff changeset
627 /* in_other_partition. */
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
628 }
111
kono
parents: 67
diff changeset
629 bp_pack_value (&bp, node->tls_model, 3);
kono
parents: 67
diff changeset
630 bp_pack_value (&bp, node->used_by_single_function, 1);
kono
parents: 67
diff changeset
631 bp_pack_value (&bp, node->dynamically_initialized, 1);
kono
parents: 67
diff changeset
632 bp_pack_value (&bp, node->need_bounds_init, 1);
kono
parents: 67
diff changeset
633 streamer_write_bitpack (&bp);
kono
parents: 67
diff changeset
634
kono
parents: 67
diff changeset
635 group = node->get_comdat_group ();
kono
parents: 67
diff changeset
636 if (group)
kono
parents: 67
diff changeset
637 comdat = IDENTIFIER_POINTER (group);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
638 else
111
kono
parents: 67
diff changeset
639 comdat = "";
kono
parents: 67
diff changeset
640 streamer_write_data_stream (ob->main_stream, comdat, strlen (comdat) + 1);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
641
111
kono
parents: 67
diff changeset
642 if (group)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
643 {
111
kono
parents: 67
diff changeset
644 if (node->same_comdat_group)
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
645 {
111
kono
parents: 67
diff changeset
646 ref = LCC_NOT_FOUND;
kono
parents: 67
diff changeset
647 for (struct symtab_node *n = node->same_comdat_group;
kono
parents: 67
diff changeset
648 ref == LCC_NOT_FOUND && n != node; n = n->same_comdat_group)
kono
parents: 67
diff changeset
649 ref = lto_symtab_encoder_lookup (encoder, n);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
650 }
111
kono
parents: 67
diff changeset
651 else
kono
parents: 67
diff changeset
652 ref = LCC_NOT_FOUND;
kono
parents: 67
diff changeset
653 streamer_write_hwi_stream (ob->main_stream, ref);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
654 }
111
kono
parents: 67
diff changeset
655
kono
parents: 67
diff changeset
656 section = node->get_section ();
kono
parents: 67
diff changeset
657 if (!section)
kono
parents: 67
diff changeset
658 section = "";
kono
parents: 67
diff changeset
659 streamer_write_data_stream (ob->main_stream, section, strlen (section) + 1);
kono
parents: 67
diff changeset
660
kono
parents: 67
diff changeset
661 streamer_write_enum (ob->main_stream, ld_plugin_symbol_resolution,
kono
parents: 67
diff changeset
662 LDPR_NUM_KNOWN, node->resolution);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
663 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
664
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
665 /* Output the varpool NODE to OB.
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
666 If NODE is not in SET, then NODE is a boundary. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
667
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
668 static void
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
669 lto_output_ref (struct lto_simple_output_block *ob, struct ipa_ref *ref,
111
kono
parents: 67
diff changeset
670 lto_symtab_encoder_t encoder)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
671 {
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
672 struct bitpack_d bp;
111
kono
parents: 67
diff changeset
673 int nref;
kono
parents: 67
diff changeset
674 int uid = ref->lto_stmt_uid;
kono
parents: 67
diff changeset
675 struct cgraph_node *node;
kono
parents: 67
diff changeset
676
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
677 bp = bitpack_create (ob->main_stream);
111
kono
parents: 67
diff changeset
678 bp_pack_value (&bp, ref->use, 3);
kono
parents: 67
diff changeset
679 bp_pack_value (&bp, ref->speculative, 1);
kono
parents: 67
diff changeset
680 streamer_write_bitpack (&bp);
kono
parents: 67
diff changeset
681 nref = lto_symtab_encoder_lookup (encoder, ref->referred);
kono
parents: 67
diff changeset
682 gcc_assert (nref != LCC_NOT_FOUND);
kono
parents: 67
diff changeset
683 streamer_write_hwi_stream (ob->main_stream, nref);
kono
parents: 67
diff changeset
684
kono
parents: 67
diff changeset
685 node = dyn_cast <cgraph_node *> (ref->referring);
kono
parents: 67
diff changeset
686 if (node)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
687 {
111
kono
parents: 67
diff changeset
688 if (ref->stmt)
kono
parents: 67
diff changeset
689 uid = gimple_uid (ref->stmt) + 1;
kono
parents: 67
diff changeset
690 streamer_write_hwi_stream (ob->main_stream, uid);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
691 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
692 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
693
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
694 /* Stream out profile_summary to OB. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
695
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
696 static void
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
697 output_profile_summary (struct lto_simple_output_block *ob)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
698 {
111
kono
parents: 67
diff changeset
699 unsigned h_ix;
kono
parents: 67
diff changeset
700 struct bitpack_d bp;
kono
parents: 67
diff changeset
701
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
702 if (profile_info)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
703 {
111
kono
parents: 67
diff changeset
704 /* We do not output num and run_max, they are not used by
kono
parents: 67
diff changeset
705 GCC profile feedback and they are difficult to merge from multiple
kono
parents: 67
diff changeset
706 units. */
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
707 gcc_assert (profile_info->runs);
111
kono
parents: 67
diff changeset
708 streamer_write_uhwi_stream (ob->main_stream, profile_info->runs);
kono
parents: 67
diff changeset
709 streamer_write_gcov_count_stream (ob->main_stream, profile_info->sum_max);
kono
parents: 67
diff changeset
710
kono
parents: 67
diff changeset
711 /* sum_all is needed for computing the working set with the
kono
parents: 67
diff changeset
712 histogram. */
kono
parents: 67
diff changeset
713 streamer_write_gcov_count_stream (ob->main_stream, profile_info->sum_all);
kono
parents: 67
diff changeset
714
kono
parents: 67
diff changeset
715 /* Create and output a bitpack of non-zero histogram entries indices. */
kono
parents: 67
diff changeset
716 bp = bitpack_create (ob->main_stream);
kono
parents: 67
diff changeset
717 for (h_ix = 0; h_ix < GCOV_HISTOGRAM_SIZE; h_ix++)
kono
parents: 67
diff changeset
718 bp_pack_value (&bp, profile_info->histogram[h_ix].num_counters > 0, 1);
kono
parents: 67
diff changeset
719 streamer_write_bitpack (&bp);
kono
parents: 67
diff changeset
720 /* Now stream out only those non-zero entries. */
kono
parents: 67
diff changeset
721 for (h_ix = 0; h_ix < GCOV_HISTOGRAM_SIZE; h_ix++)
kono
parents: 67
diff changeset
722 {
kono
parents: 67
diff changeset
723 if (!profile_info->histogram[h_ix].num_counters)
kono
parents: 67
diff changeset
724 continue;
kono
parents: 67
diff changeset
725 streamer_write_gcov_count_stream (ob->main_stream,
kono
parents: 67
diff changeset
726 profile_info->histogram[h_ix].num_counters);
kono
parents: 67
diff changeset
727 streamer_write_gcov_count_stream (ob->main_stream,
kono
parents: 67
diff changeset
728 profile_info->histogram[h_ix].min_value);
kono
parents: 67
diff changeset
729 streamer_write_gcov_count_stream (ob->main_stream,
kono
parents: 67
diff changeset
730 profile_info->histogram[h_ix].cum_value);
kono
parents: 67
diff changeset
731 }
kono
parents: 67
diff changeset
732 /* IPA-profile computes hot bb threshold based on cumulated
kono
parents: 67
diff changeset
733 whole program profile. We need to stream it down to ltrans. */
kono
parents: 67
diff changeset
734 if (flag_wpa)
kono
parents: 67
diff changeset
735 streamer_write_gcov_count_stream (ob->main_stream,
kono
parents: 67
diff changeset
736 get_hot_bb_threshold ());
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
737 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
738 else
111
kono
parents: 67
diff changeset
739 streamer_write_uhwi_stream (ob->main_stream, 0);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
740 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
741
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
742 /* Output all callees or indirect outgoing edges. EDGE must be the first such
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
743 edge. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
744
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
745 static void
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
746 output_outgoing_cgraph_edges (struct cgraph_edge *edge,
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
747 struct lto_simple_output_block *ob,
111
kono
parents: 67
diff changeset
748 lto_symtab_encoder_t encoder)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
749 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
750 if (!edge)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
751 return;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
752
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
753 /* Output edges in backward direction, so the reconstructed callgraph match
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
754 and it is easy to associate call sites in the IPA pass summaries. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
755 while (edge->next_callee)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
756 edge = edge->next_callee;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
757 for (; edge; edge = edge->prev_callee)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
758 lto_output_edge (ob, edge, encoder);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
759 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
760
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
761 /* Output the part of the cgraph in SET. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
762
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
763 static void
111
kono
parents: 67
diff changeset
764 output_refs (lto_symtab_encoder_t encoder)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
765 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
766 struct lto_simple_output_block *ob;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
767 int count;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
768 struct ipa_ref *ref;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
769
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
770 ob = lto_create_simple_output_block (LTO_section_refs);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
771
111
kono
parents: 67
diff changeset
772 for (int i = 0; i < lto_symtab_encoder_size (encoder); i++)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
773 {
111
kono
parents: 67
diff changeset
774 symtab_node *node = lto_symtab_encoder_deref (encoder, i);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
775
111
kono
parents: 67
diff changeset
776 /* IPA_REF_ALIAS and IPA_REF_CHKP references are always preserved
kono
parents: 67
diff changeset
777 in the boundary. Alias node can't have other references and
kono
parents: 67
diff changeset
778 can be always handled as if it's not in the boundary. */
kono
parents: 67
diff changeset
779 if (!node->alias && !lto_symtab_encoder_in_partition_p (encoder, node))
kono
parents: 67
diff changeset
780 {
kono
parents: 67
diff changeset
781 cgraph_node *cnode = dyn_cast <cgraph_node *> (node);
kono
parents: 67
diff changeset
782 /* Output IPA_REF_CHKP reference. */
kono
parents: 67
diff changeset
783 if (cnode
kono
parents: 67
diff changeset
784 && cnode->instrumented_version
kono
parents: 67
diff changeset
785 && !cnode->instrumentation_clone)
kono
parents: 67
diff changeset
786 {
kono
parents: 67
diff changeset
787 for (int i = 0; node->iterate_reference (i, ref); i++)
kono
parents: 67
diff changeset
788 if (ref->use == IPA_REF_CHKP)
kono
parents: 67
diff changeset
789 {
kono
parents: 67
diff changeset
790 if (lto_symtab_encoder_lookup (encoder, ref->referred)
kono
parents: 67
diff changeset
791 != LCC_NOT_FOUND)
kono
parents: 67
diff changeset
792 {
kono
parents: 67
diff changeset
793 int nref = lto_symtab_encoder_lookup (encoder, node);
kono
parents: 67
diff changeset
794 streamer_write_gcov_count_stream (ob->main_stream, 1);
kono
parents: 67
diff changeset
795 streamer_write_uhwi_stream (ob->main_stream, nref);
kono
parents: 67
diff changeset
796 lto_output_ref (ob, ref, encoder);
kono
parents: 67
diff changeset
797 }
kono
parents: 67
diff changeset
798 break;
kono
parents: 67
diff changeset
799 }
kono
parents: 67
diff changeset
800 }
kono
parents: 67
diff changeset
801 continue;
kono
parents: 67
diff changeset
802 }
kono
parents: 67
diff changeset
803
kono
parents: 67
diff changeset
804 count = node->ref_list.nreferences ();
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
805 if (count)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
806 {
111
kono
parents: 67
diff changeset
807 streamer_write_gcov_count_stream (ob->main_stream, count);
kono
parents: 67
diff changeset
808 streamer_write_uhwi_stream (ob->main_stream,
kono
parents: 67
diff changeset
809 lto_symtab_encoder_lookup (encoder, node));
kono
parents: 67
diff changeset
810 for (int i = 0; node->iterate_reference (i, ref); i++)
kono
parents: 67
diff changeset
811 lto_output_ref (ob, ref, encoder);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
812 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
813 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
814
111
kono
parents: 67
diff changeset
815 streamer_write_uhwi_stream (ob->main_stream, 0);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
816
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
817 lto_destroy_simple_output_block (ob);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
818 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
819
111
kono
parents: 67
diff changeset
820 /* Add NODE into encoder as well as nodes it is cloned from.
kono
parents: 67
diff changeset
821 Do it in a way so clones appear first. */
kono
parents: 67
diff changeset
822
kono
parents: 67
diff changeset
823 static void
kono
parents: 67
diff changeset
824 add_node_to (lto_symtab_encoder_t encoder, struct cgraph_node *node,
kono
parents: 67
diff changeset
825 bool include_body)
kono
parents: 67
diff changeset
826 {
kono
parents: 67
diff changeset
827 if (node->clone_of)
kono
parents: 67
diff changeset
828 add_node_to (encoder, node->clone_of, include_body);
kono
parents: 67
diff changeset
829 else if (include_body)
kono
parents: 67
diff changeset
830 lto_set_symtab_encoder_encode_body (encoder, node);
kono
parents: 67
diff changeset
831 lto_symtab_encoder_encode (encoder, node);
kono
parents: 67
diff changeset
832 }
kono
parents: 67
diff changeset
833
kono
parents: 67
diff changeset
834 /* Add all references in NODE to encoders. */
kono
parents: 67
diff changeset
835
kono
parents: 67
diff changeset
836 static void
kono
parents: 67
diff changeset
837 create_references (lto_symtab_encoder_t encoder, symtab_node *node)
kono
parents: 67
diff changeset
838 {
kono
parents: 67
diff changeset
839 int i;
kono
parents: 67
diff changeset
840 struct ipa_ref *ref = NULL;
kono
parents: 67
diff changeset
841 for (i = 0; node->iterate_reference (i, ref); i++)
kono
parents: 67
diff changeset
842 if (is_a <cgraph_node *> (ref->referred))
kono
parents: 67
diff changeset
843 add_node_to (encoder, dyn_cast <cgraph_node *> (ref->referred), false);
kono
parents: 67
diff changeset
844 else
kono
parents: 67
diff changeset
845 lto_symtab_encoder_encode (encoder, ref->referred);
kono
parents: 67
diff changeset
846 }
kono
parents: 67
diff changeset
847
kono
parents: 67
diff changeset
848 /* Select what needs to be streamed out. In regular lto mode stream everything.
kono
parents: 67
diff changeset
849 In offload lto mode stream only nodes marked as offloadable. */
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
850 void
111
kono
parents: 67
diff changeset
851 select_what_to_stream (void)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
852 {
111
kono
parents: 67
diff changeset
853 struct symtab_node *snode;
kono
parents: 67
diff changeset
854 FOR_EACH_SYMBOL (snode)
kono
parents: 67
diff changeset
855 snode->need_lto_streaming = !lto_stream_offload_p || snode->offloadable;
kono
parents: 67
diff changeset
856 }
kono
parents: 67
diff changeset
857
kono
parents: 67
diff changeset
858 /* Find all symbols we want to stream into given partition and insert them
kono
parents: 67
diff changeset
859 to encoders.
kono
parents: 67
diff changeset
860
kono
parents: 67
diff changeset
861 The function actually replaces IN_ENCODER by new one. The reason is that
kono
parents: 67
diff changeset
862 streaming code needs clone's origin to be streamed before clone. This
kono
parents: 67
diff changeset
863 means that we need to insert the nodes in specific order. This order is
kono
parents: 67
diff changeset
864 ignored by the partitioning logic earlier. */
kono
parents: 67
diff changeset
865
kono
parents: 67
diff changeset
866 lto_symtab_encoder_t
kono
parents: 67
diff changeset
867 compute_ltrans_boundary (lto_symtab_encoder_t in_encoder)
kono
parents: 67
diff changeset
868 {
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
869 struct cgraph_edge *edge;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
870 int i;
111
kono
parents: 67
diff changeset
871 lto_symtab_encoder_t encoder;
kono
parents: 67
diff changeset
872 lto_symtab_encoder_iterator lsei;
kono
parents: 67
diff changeset
873 hash_set<void *> reachable_call_targets;
kono
parents: 67
diff changeset
874
kono
parents: 67
diff changeset
875 encoder = lto_symtab_encoder_new (false);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
876
111
kono
parents: 67
diff changeset
877 /* Go over all entries in the IN_ENCODER and duplicate them to
kono
parents: 67
diff changeset
878 ENCODER. At the same time insert masters of clones so
kono
parents: 67
diff changeset
879 every master appears before clone. */
kono
parents: 67
diff changeset
880 for (lsei = lsei_start_function_in_partition (in_encoder);
kono
parents: 67
diff changeset
881 !lsei_end_p (lsei); lsei_next_function_in_partition (&lsei))
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
882 {
111
kono
parents: 67
diff changeset
883 struct cgraph_node *node = lsei_cgraph_node (lsei);
kono
parents: 67
diff changeset
884 if (!node->need_lto_streaming)
kono
parents: 67
diff changeset
885 continue;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
886 add_node_to (encoder, node, true);
111
kono
parents: 67
diff changeset
887 lto_set_symtab_encoder_in_partition (encoder, node);
kono
parents: 67
diff changeset
888 create_references (encoder, node);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
889 }
111
kono
parents: 67
diff changeset
890 for (lsei = lsei_start_variable_in_partition (in_encoder);
kono
parents: 67
diff changeset
891 !lsei_end_p (lsei); lsei_next_variable_in_partition (&lsei))
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
892 {
111
kono
parents: 67
diff changeset
893 varpool_node *vnode = lsei_varpool_node (lsei);
kono
parents: 67
diff changeset
894
kono
parents: 67
diff changeset
895 if (!vnode->need_lto_streaming)
kono
parents: 67
diff changeset
896 continue;
kono
parents: 67
diff changeset
897 lto_set_symtab_encoder_in_partition (encoder, vnode);
kono
parents: 67
diff changeset
898 lto_set_symtab_encoder_encode_initializer (encoder, vnode);
kono
parents: 67
diff changeset
899 create_references (encoder, vnode);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
900 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
901 /* Pickle in also the initializer of all referenced readonly variables
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
902 to help folding. Constant pool variables are not shared, so we must
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
903 pickle those too. */
111
kono
parents: 67
diff changeset
904 for (i = 0; i < lto_symtab_encoder_size (encoder); i++)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
905 {
111
kono
parents: 67
diff changeset
906 symtab_node *node = lto_symtab_encoder_deref (encoder, i);
kono
parents: 67
diff changeset
907 if (varpool_node *vnode = dyn_cast <varpool_node *> (node))
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
908 {
111
kono
parents: 67
diff changeset
909 if (!lto_symtab_encoder_encode_initializer_p (encoder,
kono
parents: 67
diff changeset
910 vnode)
kono
parents: 67
diff changeset
911 && (((vnode->ctor_useable_for_folding_p ()
kono
parents: 67
diff changeset
912 && (!DECL_VIRTUAL_P (vnode->decl)
kono
parents: 67
diff changeset
913 || !flag_wpa
kono
parents: 67
diff changeset
914 || flag_ltrans_devirtualize))
kono
parents: 67
diff changeset
915 || POINTER_BOUNDS_P (vnode->decl))))
kono
parents: 67
diff changeset
916 {
kono
parents: 67
diff changeset
917 lto_set_symtab_encoder_encode_initializer (encoder, vnode);
kono
parents: 67
diff changeset
918 create_references (encoder, vnode);
kono
parents: 67
diff changeset
919 }
kono
parents: 67
diff changeset
920 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
921 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
922
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
923 /* Go over all the nodes again to include callees that are not in
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
924 SET. */
111
kono
parents: 67
diff changeset
925 for (lsei = lsei_start_function_in_partition (encoder);
kono
parents: 67
diff changeset
926 !lsei_end_p (lsei); lsei_next_function_in_partition (&lsei))
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
927 {
111
kono
parents: 67
diff changeset
928 struct cgraph_node *node = lsei_cgraph_node (lsei);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
929 for (edge = node->callees; edge; edge = edge->next_callee)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
930 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
931 struct cgraph_node *callee = edge->callee;
111
kono
parents: 67
diff changeset
932 if (!lto_symtab_encoder_in_partition_p (encoder, callee))
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
933 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
934 /* We should have moved all the inlines. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
935 gcc_assert (!callee->global.inlined_to);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
936 add_node_to (encoder, callee, false);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
937 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
938 }
111
kono
parents: 67
diff changeset
939 /* Add all possible targets for late devirtualization. */
kono
parents: 67
diff changeset
940 if (flag_ltrans_devirtualize || !flag_wpa)
kono
parents: 67
diff changeset
941 for (edge = node->indirect_calls; edge; edge = edge->next_callee)
kono
parents: 67
diff changeset
942 if (edge->indirect_info->polymorphic)
kono
parents: 67
diff changeset
943 {
kono
parents: 67
diff changeset
944 unsigned int i;
kono
parents: 67
diff changeset
945 void *cache_token;
kono
parents: 67
diff changeset
946 bool final;
kono
parents: 67
diff changeset
947 vec <cgraph_node *>targets
kono
parents: 67
diff changeset
948 = possible_polymorphic_call_targets
kono
parents: 67
diff changeset
949 (edge, &final, &cache_token);
kono
parents: 67
diff changeset
950 if (!reachable_call_targets.add (cache_token))
kono
parents: 67
diff changeset
951 {
kono
parents: 67
diff changeset
952 for (i = 0; i < targets.length (); i++)
kono
parents: 67
diff changeset
953 {
kono
parents: 67
diff changeset
954 struct cgraph_node *callee = targets[i];
kono
parents: 67
diff changeset
955
kono
parents: 67
diff changeset
956 /* Adding an external declarations into the unit serves
kono
parents: 67
diff changeset
957 no purpose and just increases its boundary. */
kono
parents: 67
diff changeset
958 if (callee->definition
kono
parents: 67
diff changeset
959 && !lto_symtab_encoder_in_partition_p
kono
parents: 67
diff changeset
960 (encoder, callee))
kono
parents: 67
diff changeset
961 {
kono
parents: 67
diff changeset
962 gcc_assert (!callee->global.inlined_to);
kono
parents: 67
diff changeset
963 add_node_to (encoder, callee, false);
kono
parents: 67
diff changeset
964 }
kono
parents: 67
diff changeset
965 }
kono
parents: 67
diff changeset
966 }
kono
parents: 67
diff changeset
967 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
968 }
111
kono
parents: 67
diff changeset
969 /* Be sure to also insert alias targert and thunk callees. These needs
kono
parents: 67
diff changeset
970 to stay to aid local calling conventions. */
kono
parents: 67
diff changeset
971 for (i = 0; i < lto_symtab_encoder_size (encoder); i++)
kono
parents: 67
diff changeset
972 {
kono
parents: 67
diff changeset
973 symtab_node *node = lto_symtab_encoder_deref (encoder, i);
kono
parents: 67
diff changeset
974 cgraph_node *cnode = dyn_cast <cgraph_node *> (node);
kono
parents: 67
diff changeset
975
kono
parents: 67
diff changeset
976 if (node->alias && node->analyzed)
kono
parents: 67
diff changeset
977 create_references (encoder, node);
kono
parents: 67
diff changeset
978 if (cnode
kono
parents: 67
diff changeset
979 && cnode->thunk.thunk_p && !cnode->global.inlined_to)
kono
parents: 67
diff changeset
980 add_node_to (encoder, cnode->callees->callee, false);
kono
parents: 67
diff changeset
981 while (node->transparent_alias && node->analyzed)
kono
parents: 67
diff changeset
982 {
kono
parents: 67
diff changeset
983 node = node->get_alias_target ();
kono
parents: 67
diff changeset
984 if (is_a <cgraph_node *> (node))
kono
parents: 67
diff changeset
985 add_node_to (encoder, dyn_cast <cgraph_node *> (node),
kono
parents: 67
diff changeset
986 false);
kono
parents: 67
diff changeset
987 else
kono
parents: 67
diff changeset
988 lto_symtab_encoder_encode (encoder, node);
kono
parents: 67
diff changeset
989 }
kono
parents: 67
diff changeset
990 }
kono
parents: 67
diff changeset
991 lto_symtab_encoder_delete (in_encoder);
kono
parents: 67
diff changeset
992 return encoder;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
993 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
994
111
kono
parents: 67
diff changeset
995 /* Output the part of the symtab in SET and VSET. */
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
996
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
997 void
111
kono
parents: 67
diff changeset
998 output_symtab (void)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
999 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1000 struct cgraph_node *node;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1001 struct lto_simple_output_block *ob;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1002 int i, n_nodes;
111
kono
parents: 67
diff changeset
1003 lto_symtab_encoder_t encoder;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1004
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1005 if (flag_wpa)
111
kono
parents: 67
diff changeset
1006 output_cgraph_opt_summary ();
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1007
111
kono
parents: 67
diff changeset
1008 ob = lto_create_simple_output_block (LTO_section_symtab_nodes);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1009
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1010 output_profile_summary (ob);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1011
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1012 /* An encoder for cgraph nodes should have been created by
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1013 ipa_write_summaries_1. */
111
kono
parents: 67
diff changeset
1014 gcc_assert (ob->decl_state->symtab_node_encoder);
kono
parents: 67
diff changeset
1015 encoder = ob->decl_state->symtab_node_encoder;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1016
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1017 /* Write out the nodes. We must first output a node and then its clones,
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1018 otherwise at a time reading back the node there would be nothing to clone
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1019 from. */
111
kono
parents: 67
diff changeset
1020 n_nodes = lto_symtab_encoder_size (encoder);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1021 for (i = 0; i < n_nodes; i++)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1022 {
111
kono
parents: 67
diff changeset
1023 symtab_node *node = lto_symtab_encoder_deref (encoder, i);
kono
parents: 67
diff changeset
1024 if (cgraph_node *cnode = dyn_cast <cgraph_node *> (node))
kono
parents: 67
diff changeset
1025 lto_output_node (ob, cnode, encoder);
kono
parents: 67
diff changeset
1026 else
kono
parents: 67
diff changeset
1027 lto_output_varpool_node (ob, dyn_cast<varpool_node *> (node), encoder);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1028 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1029
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1030 /* Go over the nodes in SET again to write edges. */
111
kono
parents: 67
diff changeset
1031 for (int i = 0; i < lto_symtab_encoder_size (encoder); i++)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1032 {
111
kono
parents: 67
diff changeset
1033 node = dyn_cast <cgraph_node *> (lto_symtab_encoder_deref (encoder, i));
kono
parents: 67
diff changeset
1034 if (node
kono
parents: 67
diff changeset
1035 && ((node->thunk.thunk_p && !node->global.inlined_to)
kono
parents: 67
diff changeset
1036 || lto_symtab_encoder_in_partition_p (encoder, node)))
kono
parents: 67
diff changeset
1037 {
kono
parents: 67
diff changeset
1038 output_outgoing_cgraph_edges (node->callees, ob, encoder);
kono
parents: 67
diff changeset
1039 output_outgoing_cgraph_edges (node->indirect_calls, ob, encoder);
kono
parents: 67
diff changeset
1040 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1041 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1042
111
kono
parents: 67
diff changeset
1043 streamer_write_uhwi_stream (ob->main_stream, 0);
kono
parents: 67
diff changeset
1044
kono
parents: 67
diff changeset
1045 lto_destroy_simple_output_block (ob);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1046
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1047 /* Emit toplevel asms.
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1048 When doing WPA we must output every asm just once. Since we do not partition asm
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1049 nodes at all, output them to first output. This is kind of hack, but should work
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1050 well. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1051 if (!asm_nodes_output)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1052 {
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1053 asm_nodes_output = true;
111
kono
parents: 67
diff changeset
1054 lto_output_toplevel_asms ();
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1055 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1056
111
kono
parents: 67
diff changeset
1057 output_refs (encoder);
kono
parents: 67
diff changeset
1058 }
kono
parents: 67
diff changeset
1059
kono
parents: 67
diff changeset
1060 /* Return identifier encoded in IB as a plain string. */
kono
parents: 67
diff changeset
1061
kono
parents: 67
diff changeset
1062 static tree
kono
parents: 67
diff changeset
1063 read_identifier (struct lto_input_block *ib)
kono
parents: 67
diff changeset
1064 {
kono
parents: 67
diff changeset
1065 unsigned int len = strnlen (ib->data + ib->p, ib->len - ib->p - 1);
kono
parents: 67
diff changeset
1066 tree id;
kono
parents: 67
diff changeset
1067
kono
parents: 67
diff changeset
1068 if (ib->data[ib->p + len])
kono
parents: 67
diff changeset
1069 lto_section_overrun (ib);
kono
parents: 67
diff changeset
1070 if (!len)
kono
parents: 67
diff changeset
1071 {
kono
parents: 67
diff changeset
1072 ib->p++;
kono
parents: 67
diff changeset
1073 return NULL;
kono
parents: 67
diff changeset
1074 }
kono
parents: 67
diff changeset
1075 id = get_identifier (ib->data + ib->p);
kono
parents: 67
diff changeset
1076 ib->p += len + 1;
kono
parents: 67
diff changeset
1077 return id;
kono
parents: 67
diff changeset
1078 }
kono
parents: 67
diff changeset
1079
kono
parents: 67
diff changeset
1080 /* Return string encoded in IB, NULL if string is empty. */
kono
parents: 67
diff changeset
1081
kono
parents: 67
diff changeset
1082 static const char *
kono
parents: 67
diff changeset
1083 read_string (struct lto_input_block *ib)
kono
parents: 67
diff changeset
1084 {
kono
parents: 67
diff changeset
1085 unsigned int len = strnlen (ib->data + ib->p, ib->len - ib->p - 1);
kono
parents: 67
diff changeset
1086 const char *str;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1087
111
kono
parents: 67
diff changeset
1088 if (ib->data[ib->p + len])
kono
parents: 67
diff changeset
1089 lto_section_overrun (ib);
kono
parents: 67
diff changeset
1090 if (!len)
kono
parents: 67
diff changeset
1091 {
kono
parents: 67
diff changeset
1092 ib->p++;
kono
parents: 67
diff changeset
1093 return NULL;
kono
parents: 67
diff changeset
1094 }
kono
parents: 67
diff changeset
1095 str = ib->data + ib->p;
kono
parents: 67
diff changeset
1096 ib->p += len + 1;
kono
parents: 67
diff changeset
1097 return str;
kono
parents: 67
diff changeset
1098 }
kono
parents: 67
diff changeset
1099
kono
parents: 67
diff changeset
1100 /* Output function/variable tables that will allow libgomp to look up offload
kono
parents: 67
diff changeset
1101 target code.
kono
parents: 67
diff changeset
1102 OFFLOAD_FUNCS is filled in expand_omp_target, OFFLOAD_VARS is filled in
kono
parents: 67
diff changeset
1103 varpool_node::get_create. In WHOPR (partitioned) mode during the WPA stage
kono
parents: 67
diff changeset
1104 both OFFLOAD_FUNCS and OFFLOAD_VARS are filled by input_offload_tables. */
kono
parents: 67
diff changeset
1105
kono
parents: 67
diff changeset
1106 void
kono
parents: 67
diff changeset
1107 output_offload_tables (void)
kono
parents: 67
diff changeset
1108 {
kono
parents: 67
diff changeset
1109 if (vec_safe_is_empty (offload_funcs) && vec_safe_is_empty (offload_vars))
kono
parents: 67
diff changeset
1110 return;
kono
parents: 67
diff changeset
1111
kono
parents: 67
diff changeset
1112 struct lto_simple_output_block *ob
kono
parents: 67
diff changeset
1113 = lto_create_simple_output_block (LTO_section_offload_table);
kono
parents: 67
diff changeset
1114
kono
parents: 67
diff changeset
1115 for (unsigned i = 0; i < vec_safe_length (offload_funcs); i++)
kono
parents: 67
diff changeset
1116 {
kono
parents: 67
diff changeset
1117 streamer_write_enum (ob->main_stream, LTO_symtab_tags,
kono
parents: 67
diff changeset
1118 LTO_symtab_last_tag, LTO_symtab_unavail_node);
kono
parents: 67
diff changeset
1119 lto_output_fn_decl_index (ob->decl_state, ob->main_stream,
kono
parents: 67
diff changeset
1120 (*offload_funcs)[i]);
kono
parents: 67
diff changeset
1121 }
kono
parents: 67
diff changeset
1122
kono
parents: 67
diff changeset
1123 for (unsigned i = 0; i < vec_safe_length (offload_vars); i++)
kono
parents: 67
diff changeset
1124 {
kono
parents: 67
diff changeset
1125 streamer_write_enum (ob->main_stream, LTO_symtab_tags,
kono
parents: 67
diff changeset
1126 LTO_symtab_last_tag, LTO_symtab_variable);
kono
parents: 67
diff changeset
1127 lto_output_var_decl_index (ob->decl_state, ob->main_stream,
kono
parents: 67
diff changeset
1128 (*offload_vars)[i]);
kono
parents: 67
diff changeset
1129 }
kono
parents: 67
diff changeset
1130
kono
parents: 67
diff changeset
1131 streamer_write_uhwi_stream (ob->main_stream, 0);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1132 lto_destroy_simple_output_block (ob);
111
kono
parents: 67
diff changeset
1133
kono
parents: 67
diff changeset
1134 /* In WHOPR mode during the WPA stage the joint offload tables need to be
kono
parents: 67
diff changeset
1135 streamed to one partition only. That's why we free offload_funcs and
kono
parents: 67
diff changeset
1136 offload_vars after the first call of output_offload_tables. */
kono
parents: 67
diff changeset
1137 if (flag_wpa)
kono
parents: 67
diff changeset
1138 {
kono
parents: 67
diff changeset
1139 vec_free (offload_funcs);
kono
parents: 67
diff changeset
1140 vec_free (offload_vars);
kono
parents: 67
diff changeset
1141 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1142 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1143
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1144 /* Overwrite the information in NODE based on FILE_DATA, TAG, FLAGS,
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1145 STACK_SIZE, SELF_TIME and SELF_SIZE. This is called either to initialize
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1146 NODE or to replace the values in it, for instance because the first
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1147 time we saw it, the function body was not available but now it
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1148 is. BP is a bitpack with all the bitflags for NODE read from the
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1149 stream. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1150
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1151 static void
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1152 input_overwrite_node (struct lto_file_decl_data *file_data,
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1153 struct cgraph_node *node,
111
kono
parents: 67
diff changeset
1154 enum LTO_symtab_tags tag,
kono
parents: 67
diff changeset
1155 struct bitpack_d *bp)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1156 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1157 node->aux = (void *) tag;
111
kono
parents: 67
diff changeset
1158 node->lto_file_data = file_data;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1159
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1160 node->local.local = bp_unpack_value (bp, 1);
111
kono
parents: 67
diff changeset
1161 node->externally_visible = bp_unpack_value (bp, 1);
kono
parents: 67
diff changeset
1162 node->no_reorder = bp_unpack_value (bp, 1);
kono
parents: 67
diff changeset
1163 node->definition = bp_unpack_value (bp, 1);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1164 node->local.versionable = bp_unpack_value (bp, 1);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1165 node->local.can_change_signature = bp_unpack_value (bp, 1);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1166 node->local.redefined_extern_inline = bp_unpack_value (bp, 1);
111
kono
parents: 67
diff changeset
1167 node->force_output = bp_unpack_value (bp, 1);
kono
parents: 67
diff changeset
1168 node->forced_by_abi = bp_unpack_value (bp, 1);
kono
parents: 67
diff changeset
1169 node->unique_name = bp_unpack_value (bp, 1);
kono
parents: 67
diff changeset
1170 node->body_removed = bp_unpack_value (bp, 1);
kono
parents: 67
diff changeset
1171 node->implicit_section = bp_unpack_value (bp, 1);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1172 node->address_taken = bp_unpack_value (bp, 1);
111
kono
parents: 67
diff changeset
1173 node->used_from_other_partition = bp_unpack_value (bp, 1);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1174 node->lowered = bp_unpack_value (bp, 1);
111
kono
parents: 67
diff changeset
1175 node->analyzed = tag == LTO_symtab_analyzed_node;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1176 node->in_other_partition = bp_unpack_value (bp, 1);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1177 if (node->in_other_partition
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1178 /* Avoid updating decl when we are seeing just inline clone.
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1179 When inlining function that has functions already inlined into it,
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1180 we produce clones of inline clones.
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1181
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1182 WPA partitioning might put each clone into different unit and
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1183 we might end up streaming inline clone from other partition
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1184 to support clone we are interested in. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1185 && (!node->clone_of
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1186 || node->clone_of->decl != node->decl))
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1187 {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1188 DECL_EXTERNAL (node->decl) = 1;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1189 TREE_STATIC (node->decl) = 0;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1190 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1191 node->alias = bp_unpack_value (bp, 1);
111
kono
parents: 67
diff changeset
1192 node->transparent_alias = bp_unpack_value (bp, 1);
kono
parents: 67
diff changeset
1193 node->weakref = bp_unpack_value (bp, 1);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1194 node->frequency = (enum node_frequency)bp_unpack_value (bp, 2);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1195 node->only_called_at_startup = bp_unpack_value (bp, 1);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1196 node->only_called_at_exit = bp_unpack_value (bp, 1);
111
kono
parents: 67
diff changeset
1197 node->tm_clone = bp_unpack_value (bp, 1);
kono
parents: 67
diff changeset
1198 node->calls_comdat_local = bp_unpack_value (bp, 1);
kono
parents: 67
diff changeset
1199 node->icf_merged = bp_unpack_value (bp, 1);
kono
parents: 67
diff changeset
1200 node->nonfreeing_fn = bp_unpack_value (bp, 1);
kono
parents: 67
diff changeset
1201 node->thunk.thunk_p = bp_unpack_value (bp, 1);
kono
parents: 67
diff changeset
1202 node->parallelized_function = bp_unpack_value (bp, 1);
kono
parents: 67
diff changeset
1203 node->resolution = bp_unpack_enum (bp, ld_plugin_symbol_resolution,
kono
parents: 67
diff changeset
1204 LDPR_NUM_KNOWN);
kono
parents: 67
diff changeset
1205 node->instrumentation_clone = bp_unpack_value (bp, 1);
kono
parents: 67
diff changeset
1206 node->split_part = bp_unpack_value (bp, 1);
kono
parents: 67
diff changeset
1207 gcc_assert (flag_ltrans
kono
parents: 67
diff changeset
1208 || (!node->in_other_partition
kono
parents: 67
diff changeset
1209 && !node->used_from_other_partition));
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1210 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1211
111
kono
parents: 67
diff changeset
1212 /* Return string alias is alias of. */
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1213
111
kono
parents: 67
diff changeset
1214 static tree
kono
parents: 67
diff changeset
1215 get_alias_symbol (tree decl)
kono
parents: 67
diff changeset
1216 {
kono
parents: 67
diff changeset
1217 tree alias = lookup_attribute ("alias", DECL_ATTRIBUTES (decl));
kono
parents: 67
diff changeset
1218 return get_identifier (TREE_STRING_POINTER
kono
parents: 67
diff changeset
1219 (TREE_VALUE (TREE_VALUE (alias))));
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1220 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1221
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1222 /* Read a node from input_block IB. TAG is the node's tag just read.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1223 Return the node read or overwriten. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1224
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1225 static struct cgraph_node *
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1226 input_node (struct lto_file_decl_data *file_data,
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1227 struct lto_input_block *ib,
111
kono
parents: 67
diff changeset
1228 enum LTO_symtab_tags tag,
kono
parents: 67
diff changeset
1229 vec<symtab_node *> nodes)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1230 {
111
kono
parents: 67
diff changeset
1231 gcc::pass_manager *passes = g->get_passes ();
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1232 tree fn_decl;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1233 struct cgraph_node *node;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1234 struct bitpack_d bp;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1235 unsigned decl_index;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1236 int ref = LCC_NOT_FOUND, ref2 = LCC_NOT_FOUND;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1237 int clone_ref;
111
kono
parents: 67
diff changeset
1238 int order;
kono
parents: 67
diff changeset
1239 int i, count;
kono
parents: 67
diff changeset
1240 tree group;
kono
parents: 67
diff changeset
1241 const char *section;
kono
parents: 67
diff changeset
1242 order = streamer_read_hwi (ib) + order_base;
kono
parents: 67
diff changeset
1243 clone_ref = streamer_read_hwi (ib);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1244
111
kono
parents: 67
diff changeset
1245 decl_index = streamer_read_uhwi (ib);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1246 fn_decl = lto_file_decl_data_get_fn_decl (file_data, decl_index);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1247
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1248 if (clone_ref != LCC_NOT_FOUND)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1249 {
111
kono
parents: 67
diff changeset
1250 node = dyn_cast<cgraph_node *> (nodes[clone_ref])->create_clone (fn_decl,
kono
parents: 67
diff changeset
1251 profile_count::uninitialized (), CGRAPH_FREQ_BASE, false,
kono
parents: 67
diff changeset
1252 vNULL, false, NULL, NULL);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1253 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1254 else
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1255 {
111
kono
parents: 67
diff changeset
1256 /* Declaration of functions can be already merged with a declaration
kono
parents: 67
diff changeset
1257 from other input file. We keep cgraph unmerged until after streaming
kono
parents: 67
diff changeset
1258 of ipa passes is done. Alays forcingly create a fresh node. */
kono
parents: 67
diff changeset
1259 node = symtab->create_empty ();
kono
parents: 67
diff changeset
1260 node->decl = fn_decl;
kono
parents: 67
diff changeset
1261 node->register_symbol ();
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1262 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1263
111
kono
parents: 67
diff changeset
1264 node->order = order;
kono
parents: 67
diff changeset
1265 if (order >= symtab->order)
kono
parents: 67
diff changeset
1266 symtab->order = order + 1;
kono
parents: 67
diff changeset
1267
kono
parents: 67
diff changeset
1268 node->count = profile_count::stream_in (ib);
kono
parents: 67
diff changeset
1269 node->count_materialization_scale = streamer_read_hwi (ib);
kono
parents: 67
diff changeset
1270
kono
parents: 67
diff changeset
1271 count = streamer_read_hwi (ib);
kono
parents: 67
diff changeset
1272 node->ipa_transforms_to_apply = vNULL;
kono
parents: 67
diff changeset
1273 for (i = 0; i < count; i++)
kono
parents: 67
diff changeset
1274 {
kono
parents: 67
diff changeset
1275 opt_pass *pass;
kono
parents: 67
diff changeset
1276 int pid = streamer_read_hwi (ib);
kono
parents: 67
diff changeset
1277
kono
parents: 67
diff changeset
1278 gcc_assert (pid < passes->passes_by_id_size);
kono
parents: 67
diff changeset
1279 pass = passes->passes_by_id[pid];
kono
parents: 67
diff changeset
1280 node->ipa_transforms_to_apply.safe_push ((ipa_opt_pass_d *) pass);
kono
parents: 67
diff changeset
1281 }
kono
parents: 67
diff changeset
1282
kono
parents: 67
diff changeset
1283 if (tag == LTO_symtab_analyzed_node)
kono
parents: 67
diff changeset
1284 ref = streamer_read_hwi (ib);
kono
parents: 67
diff changeset
1285
kono
parents: 67
diff changeset
1286 group = read_identifier (ib);
kono
parents: 67
diff changeset
1287 if (group)
kono
parents: 67
diff changeset
1288 ref2 = streamer_read_hwi (ib);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1289
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1290 /* Make sure that we have not read this node before. Nodes that
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1291 have already been read will have their tag stored in the 'aux'
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1292 field. Since built-in functions can be referenced in multiple
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1293 functions, they are expected to be read more than once. */
111
kono
parents: 67
diff changeset
1294 if (node->aux && !DECL_BUILT_IN (node->decl))
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1295 internal_error ("bytecode stream: found multiple instances of cgraph "
111
kono
parents: 67
diff changeset
1296 "node with uid %d", node->uid);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1297
111
kono
parents: 67
diff changeset
1298 node->tp_first_run = streamer_read_uhwi (ib);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1299
111
kono
parents: 67
diff changeset
1300 bp = streamer_read_bitpack (ib);
kono
parents: 67
diff changeset
1301
kono
parents: 67
diff changeset
1302 input_overwrite_node (file_data, node, tag, &bp);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1303
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1304 /* Store a reference for now, and fix up later to be a pointer. */
111
kono
parents: 67
diff changeset
1305 node->global.inlined_to = (cgraph_node *) (intptr_t) ref;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1306
111
kono
parents: 67
diff changeset
1307 if (group)
kono
parents: 67
diff changeset
1308 {
kono
parents: 67
diff changeset
1309 node->set_comdat_group (group);
kono
parents: 67
diff changeset
1310 /* Store a reference for now, and fix up later to be a pointer. */
kono
parents: 67
diff changeset
1311 node->same_comdat_group = (symtab_node *) (intptr_t) ref2;
kono
parents: 67
diff changeset
1312 }
kono
parents: 67
diff changeset
1313 else
kono
parents: 67
diff changeset
1314 node->same_comdat_group = (symtab_node *) (intptr_t) LCC_NOT_FOUND;
kono
parents: 67
diff changeset
1315 section = read_string (ib);
kono
parents: 67
diff changeset
1316 if (section)
kono
parents: 67
diff changeset
1317 node->set_section_for_node (section);
kono
parents: 67
diff changeset
1318
kono
parents: 67
diff changeset
1319 if (node->thunk.thunk_p)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1320 {
111
kono
parents: 67
diff changeset
1321 int type = streamer_read_uhwi (ib);
kono
parents: 67
diff changeset
1322 HOST_WIDE_INT fixed_offset = streamer_read_uhwi (ib);
kono
parents: 67
diff changeset
1323 HOST_WIDE_INT virtual_value = streamer_read_uhwi (ib);
kono
parents: 67
diff changeset
1324
kono
parents: 67
diff changeset
1325 node->thunk.fixed_offset = fixed_offset;
kono
parents: 67
diff changeset
1326 node->thunk.this_adjusting = (type & 2);
kono
parents: 67
diff changeset
1327 node->thunk.virtual_value = virtual_value;
kono
parents: 67
diff changeset
1328 node->thunk.virtual_offset_p = (type & 4);
kono
parents: 67
diff changeset
1329 node->thunk.add_pointer_bounds_args = (type & 8);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1330 }
111
kono
parents: 67
diff changeset
1331 if (node->alias && !node->analyzed && node->weakref)
kono
parents: 67
diff changeset
1332 node->alias_target = get_alias_symbol (node->decl);
kono
parents: 67
diff changeset
1333 node->profile_id = streamer_read_hwi (ib);
kono
parents: 67
diff changeset
1334 if (DECL_STATIC_CONSTRUCTOR (node->decl))
kono
parents: 67
diff changeset
1335 node->set_init_priority (streamer_read_hwi (ib));
kono
parents: 67
diff changeset
1336 if (DECL_STATIC_DESTRUCTOR (node->decl))
kono
parents: 67
diff changeset
1337 node->set_fini_priority (streamer_read_hwi (ib));
kono
parents: 67
diff changeset
1338
kono
parents: 67
diff changeset
1339 if (node->instrumentation_clone)
kono
parents: 67
diff changeset
1340 {
kono
parents: 67
diff changeset
1341 decl_index = streamer_read_uhwi (ib);
kono
parents: 67
diff changeset
1342 fn_decl = lto_file_decl_data_get_fn_decl (file_data, decl_index);
kono
parents: 67
diff changeset
1343 node->orig_decl = fn_decl;
kono
parents: 67
diff changeset
1344 }
kono
parents: 67
diff changeset
1345
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1346 return node;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1347 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1348
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1349 /* Read a node from input_block IB. TAG is the node's tag just read.
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1350 Return the node read or overwriten. */
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1351
111
kono
parents: 67
diff changeset
1352 static varpool_node *
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1353 input_varpool_node (struct lto_file_decl_data *file_data,
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1354 struct lto_input_block *ib)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1355 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1356 int decl_index;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1357 tree var_decl;
111
kono
parents: 67
diff changeset
1358 varpool_node *node;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1359 struct bitpack_d bp;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1360 int ref = LCC_NOT_FOUND;
111
kono
parents: 67
diff changeset
1361 int order;
kono
parents: 67
diff changeset
1362 tree group;
kono
parents: 67
diff changeset
1363 const char *section;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1364
111
kono
parents: 67
diff changeset
1365 order = streamer_read_hwi (ib) + order_base;
kono
parents: 67
diff changeset
1366 decl_index = streamer_read_uhwi (ib);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1367 var_decl = lto_file_decl_data_get_var_decl (file_data, decl_index);
111
kono
parents: 67
diff changeset
1368
kono
parents: 67
diff changeset
1369 /* Declaration of functions can be already merged with a declaration
kono
parents: 67
diff changeset
1370 from other input file. We keep cgraph unmerged until after streaming
kono
parents: 67
diff changeset
1371 of ipa passes is done. Alays forcingly create a fresh node. */
kono
parents: 67
diff changeset
1372 node = varpool_node::create_empty ();
kono
parents: 67
diff changeset
1373 node->decl = var_decl;
kono
parents: 67
diff changeset
1374 node->register_symbol ();
kono
parents: 67
diff changeset
1375
kono
parents: 67
diff changeset
1376 node->order = order;
kono
parents: 67
diff changeset
1377 if (order >= symtab->order)
kono
parents: 67
diff changeset
1378 symtab->order = order + 1;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1379 node->lto_file_data = file_data;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1380
111
kono
parents: 67
diff changeset
1381 bp = streamer_read_bitpack (ib);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1382 node->externally_visible = bp_unpack_value (&bp, 1);
111
kono
parents: 67
diff changeset
1383 node->no_reorder = bp_unpack_value (&bp, 1);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1384 node->force_output = bp_unpack_value (&bp, 1);
111
kono
parents: 67
diff changeset
1385 node->forced_by_abi = bp_unpack_value (&bp, 1);
kono
parents: 67
diff changeset
1386 node->unique_name = bp_unpack_value (&bp, 1);
kono
parents: 67
diff changeset
1387 node->body_removed = bp_unpack_value (&bp, 1);
kono
parents: 67
diff changeset
1388 node->implicit_section = bp_unpack_value (&bp, 1);
kono
parents: 67
diff changeset
1389 node->writeonly = bp_unpack_value (&bp, 1);
kono
parents: 67
diff changeset
1390 node->definition = bp_unpack_value (&bp, 1);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1391 node->alias = bp_unpack_value (&bp, 1);
111
kono
parents: 67
diff changeset
1392 node->transparent_alias = bp_unpack_value (&bp, 1);
kono
parents: 67
diff changeset
1393 node->weakref = bp_unpack_value (&bp, 1);
kono
parents: 67
diff changeset
1394 node->analyzed = bp_unpack_value (&bp, 1);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1395 node->used_from_other_partition = bp_unpack_value (&bp, 1);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1396 node->in_other_partition = bp_unpack_value (&bp, 1);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1397 if (node->in_other_partition)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1398 {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1399 DECL_EXTERNAL (node->decl) = 1;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1400 TREE_STATIC (node->decl) = 0;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1401 }
111
kono
parents: 67
diff changeset
1402 if (node->alias && !node->analyzed && node->weakref)
kono
parents: 67
diff changeset
1403 node->alias_target = get_alias_symbol (node->decl);
kono
parents: 67
diff changeset
1404 node->tls_model = (enum tls_model)bp_unpack_value (&bp, 3);
kono
parents: 67
diff changeset
1405 node->used_by_single_function = (enum tls_model)bp_unpack_value (&bp, 1);
kono
parents: 67
diff changeset
1406 node->dynamically_initialized = bp_unpack_value (&bp, 1);
kono
parents: 67
diff changeset
1407 node->need_bounds_init = bp_unpack_value (&bp, 1);
kono
parents: 67
diff changeset
1408 group = read_identifier (ib);
kono
parents: 67
diff changeset
1409 if (group)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1410 {
111
kono
parents: 67
diff changeset
1411 node->set_comdat_group (group);
kono
parents: 67
diff changeset
1412 ref = streamer_read_hwi (ib);
kono
parents: 67
diff changeset
1413 /* Store a reference for now, and fix up later to be a pointer. */
kono
parents: 67
diff changeset
1414 node->same_comdat_group = (symtab_node *) (intptr_t) ref;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1415 }
111
kono
parents: 67
diff changeset
1416 else
kono
parents: 67
diff changeset
1417 node->same_comdat_group = (symtab_node *) (intptr_t) LCC_NOT_FOUND;
kono
parents: 67
diff changeset
1418 section = read_string (ib);
kono
parents: 67
diff changeset
1419 if (section)
kono
parents: 67
diff changeset
1420 node->set_section_for_node (section);
kono
parents: 67
diff changeset
1421 node->resolution = streamer_read_enum (ib, ld_plugin_symbol_resolution,
kono
parents: 67
diff changeset
1422 LDPR_NUM_KNOWN);
kono
parents: 67
diff changeset
1423 gcc_assert (flag_ltrans
kono
parents: 67
diff changeset
1424 || (!node->in_other_partition
kono
parents: 67
diff changeset
1425 && !node->used_from_other_partition));
kono
parents: 67
diff changeset
1426
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1427 return node;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1428 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1429
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1430 /* Read a node from input_block IB. TAG is the node's tag just read.
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1431 Return the node read or overwriten. */
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1432
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1433 static void
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1434 input_ref (struct lto_input_block *ib,
111
kono
parents: 67
diff changeset
1435 symtab_node *referring_node,
kono
parents: 67
diff changeset
1436 vec<symtab_node *> nodes)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1437 {
111
kono
parents: 67
diff changeset
1438 symtab_node *node = NULL;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1439 struct bitpack_d bp;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1440 enum ipa_ref_use use;
111
kono
parents: 67
diff changeset
1441 bool speculative;
kono
parents: 67
diff changeset
1442 struct ipa_ref *ref;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1443
111
kono
parents: 67
diff changeset
1444 bp = streamer_read_bitpack (ib);
kono
parents: 67
diff changeset
1445 use = (enum ipa_ref_use) bp_unpack_value (&bp, 3);
kono
parents: 67
diff changeset
1446 speculative = (enum ipa_ref_use) bp_unpack_value (&bp, 1);
kono
parents: 67
diff changeset
1447 node = nodes[streamer_read_hwi (ib)];
kono
parents: 67
diff changeset
1448 ref = referring_node->create_reference (node, use);
kono
parents: 67
diff changeset
1449 ref->speculative = speculative;
kono
parents: 67
diff changeset
1450 if (is_a <cgraph_node *> (referring_node))
kono
parents: 67
diff changeset
1451 ref->lto_stmt_uid = streamer_read_hwi (ib);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1452 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1453
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1454 /* Read an edge from IB. NODES points to a vector of previously read nodes for
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1455 decoding caller and callee of the edge to be read. If INDIRECT is true, the
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1456 edge being read is indirect (in the sense that it has
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1457 indirect_unknown_callee set). */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1458
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1459 static void
111
kono
parents: 67
diff changeset
1460 input_edge (struct lto_input_block *ib, vec<symtab_node *> nodes,
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1461 bool indirect)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1462 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1463 struct cgraph_node *caller, *callee;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1464 struct cgraph_edge *edge;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1465 unsigned int stmt_id;
111
kono
parents: 67
diff changeset
1466 profile_count count;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1467 int freq;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1468 cgraph_inline_failed_t inline_failed;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1469 struct bitpack_d bp;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1470 int ecf_flags = 0;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1471
111
kono
parents: 67
diff changeset
1472 caller = dyn_cast<cgraph_node *> (nodes[streamer_read_hwi (ib)]);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1473 if (caller == NULL || caller->decl == NULL_TREE)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1474 internal_error ("bytecode stream: no caller found while reading edge");
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1475
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1476 if (!indirect)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1477 {
111
kono
parents: 67
diff changeset
1478 callee = dyn_cast<cgraph_node *> (nodes[streamer_read_hwi (ib)]);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1479 if (callee == NULL || callee->decl == NULL_TREE)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1480 internal_error ("bytecode stream: no callee found while reading edge");
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1481 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1482 else
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1483 callee = NULL;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1484
111
kono
parents: 67
diff changeset
1485 count = profile_count::stream_in (ib);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1486
111
kono
parents: 67
diff changeset
1487 bp = streamer_read_bitpack (ib);
kono
parents: 67
diff changeset
1488 inline_failed = bp_unpack_enum (&bp, cgraph_inline_failed_t, CIF_N_REASONS);
kono
parents: 67
diff changeset
1489 stmt_id = bp_unpack_var_len_unsigned (&bp);
kono
parents: 67
diff changeset
1490 freq = (int) bp_unpack_var_len_unsigned (&bp);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1491
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1492 if (indirect)
111
kono
parents: 67
diff changeset
1493 edge = caller->create_indirect_edge (NULL, 0, count, freq);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1494 else
111
kono
parents: 67
diff changeset
1495 edge = caller->create_edge (callee, NULL, count, freq);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1496
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1497 edge->indirect_inlining_edge = bp_unpack_value (&bp, 1);
111
kono
parents: 67
diff changeset
1498 edge->speculative = bp_unpack_value (&bp, 1);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1499 edge->lto_stmt_uid = stmt_id;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1500 edge->inline_failed = inline_failed;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1501 edge->call_stmt_cannot_inline_p = bp_unpack_value (&bp, 1);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1502 edge->can_throw_external = bp_unpack_value (&bp, 1);
111
kono
parents: 67
diff changeset
1503 edge->in_polymorphic_cdtor = bp_unpack_value (&bp, 1);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1504 if (indirect)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1505 {
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1506 if (bp_unpack_value (&bp, 1))
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1507 ecf_flags |= ECF_CONST;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1508 if (bp_unpack_value (&bp, 1))
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1509 ecf_flags |= ECF_PURE;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1510 if (bp_unpack_value (&bp, 1))
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1511 ecf_flags |= ECF_NORETURN;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1512 if (bp_unpack_value (&bp, 1))
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1513 ecf_flags |= ECF_MALLOC;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1514 if (bp_unpack_value (&bp, 1))
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1515 ecf_flags |= ECF_NOTHROW;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1516 if (bp_unpack_value (&bp, 1))
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1517 ecf_flags |= ECF_RETURNS_TWICE;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1518 edge->indirect_info->ecf_flags = ecf_flags;
111
kono
parents: 67
diff changeset
1519 edge->indirect_info->common_target_id = streamer_read_hwi (ib);
kono
parents: 67
diff changeset
1520 if (edge->indirect_info->common_target_id)
kono
parents: 67
diff changeset
1521 edge->indirect_info->common_target_probability = streamer_read_hwi (ib);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1522 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1523 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1524
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1525
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1526 /* Read a cgraph from IB using the info in FILE_DATA. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1527
111
kono
parents: 67
diff changeset
1528 static vec<symtab_node *>
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1529 input_cgraph_1 (struct lto_file_decl_data *file_data,
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1530 struct lto_input_block *ib)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1531 {
111
kono
parents: 67
diff changeset
1532 enum LTO_symtab_tags tag;
kono
parents: 67
diff changeset
1533 vec<symtab_node *> nodes = vNULL;
kono
parents: 67
diff changeset
1534 symtab_node *node;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1535 unsigned i;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1536
111
kono
parents: 67
diff changeset
1537 tag = streamer_read_enum (ib, LTO_symtab_tags, LTO_symtab_last_tag);
kono
parents: 67
diff changeset
1538 order_base = symtab->order;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1539 while (tag)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1540 {
111
kono
parents: 67
diff changeset
1541 if (tag == LTO_symtab_edge)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1542 input_edge (ib, nodes, false);
111
kono
parents: 67
diff changeset
1543 else if (tag == LTO_symtab_indirect_edge)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1544 input_edge (ib, nodes, true);
111
kono
parents: 67
diff changeset
1545 else if (tag == LTO_symtab_variable)
kono
parents: 67
diff changeset
1546 {
kono
parents: 67
diff changeset
1547 node = input_varpool_node (file_data, ib);
kono
parents: 67
diff changeset
1548 nodes.safe_push (node);
kono
parents: 67
diff changeset
1549 lto_symtab_encoder_encode (file_data->symtab_node_encoder, node);
kono
parents: 67
diff changeset
1550 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1551 else
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1552 {
111
kono
parents: 67
diff changeset
1553 node = input_node (file_data, ib, tag, nodes);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1554 if (node == NULL || node->decl == NULL_TREE)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1555 internal_error ("bytecode stream: found empty cgraph node");
111
kono
parents: 67
diff changeset
1556 nodes.safe_push (node);
kono
parents: 67
diff changeset
1557 lto_symtab_encoder_encode (file_data->symtab_node_encoder, node);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1558 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1559
111
kono
parents: 67
diff changeset
1560 tag = streamer_read_enum (ib, LTO_symtab_tags, LTO_symtab_last_tag);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1561 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1562
111
kono
parents: 67
diff changeset
1563 lto_input_toplevel_asms (file_data, order_base);
kono
parents: 67
diff changeset
1564
kono
parents: 67
diff changeset
1565 /* AUX pointers should be all non-zero for function nodes read from the stream. */
kono
parents: 67
diff changeset
1566 if (flag_checking)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1567 {
111
kono
parents: 67
diff changeset
1568 FOR_EACH_VEC_ELT (nodes, i, node)
kono
parents: 67
diff changeset
1569 gcc_assert (node->aux || !is_a <cgraph_node *> (node));
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1570 }
111
kono
parents: 67
diff changeset
1571 FOR_EACH_VEC_ELT (nodes, i, node)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1572 {
111
kono
parents: 67
diff changeset
1573 int ref;
kono
parents: 67
diff changeset
1574 if (cgraph_node *cnode = dyn_cast <cgraph_node *> (node))
kono
parents: 67
diff changeset
1575 {
kono
parents: 67
diff changeset
1576 ref = (int) (intptr_t) cnode->global.inlined_to;
kono
parents: 67
diff changeset
1577
kono
parents: 67
diff changeset
1578 /* We share declaration of builtins, so we may read same node twice. */
kono
parents: 67
diff changeset
1579 if (!node->aux)
kono
parents: 67
diff changeset
1580 continue;
kono
parents: 67
diff changeset
1581 node->aux = NULL;
kono
parents: 67
diff changeset
1582
kono
parents: 67
diff changeset
1583 /* Fixup inlined_to from reference to pointer. */
kono
parents: 67
diff changeset
1584 if (ref != LCC_NOT_FOUND)
kono
parents: 67
diff changeset
1585 dyn_cast<cgraph_node *> (node)->global.inlined_to
kono
parents: 67
diff changeset
1586 = dyn_cast<cgraph_node *> (nodes[ref]);
kono
parents: 67
diff changeset
1587 else
kono
parents: 67
diff changeset
1588 cnode->global.inlined_to = NULL;
kono
parents: 67
diff changeset
1589
kono
parents: 67
diff changeset
1590 /* Compute instrumented_version. */
kono
parents: 67
diff changeset
1591 if (cnode->instrumentation_clone)
kono
parents: 67
diff changeset
1592 {
kono
parents: 67
diff changeset
1593 gcc_assert (cnode->orig_decl);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1594
111
kono
parents: 67
diff changeset
1595 cnode->instrumented_version = cgraph_node::get (cnode->orig_decl);
kono
parents: 67
diff changeset
1596 if (cnode->instrumented_version)
kono
parents: 67
diff changeset
1597 {
kono
parents: 67
diff changeset
1598 /* We may have multiple nodes for a single function which
kono
parents: 67
diff changeset
1599 will be merged later. To have a proper merge we need
kono
parents: 67
diff changeset
1600 to keep instrumentation_version reference between nodes
kono
parents: 67
diff changeset
1601 consistent: each instrumented_version reference should
kono
parents: 67
diff changeset
1602 have proper reverse reference. Thus don't break existing
kono
parents: 67
diff changeset
1603 instrumented_version reference if it already exists. */
kono
parents: 67
diff changeset
1604 if (cnode->instrumented_version->instrumented_version)
kono
parents: 67
diff changeset
1605 cnode->instrumented_version = NULL;
kono
parents: 67
diff changeset
1606 else
kono
parents: 67
diff changeset
1607 cnode->instrumented_version->instrumented_version = cnode;
kono
parents: 67
diff changeset
1608 }
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1609
111
kono
parents: 67
diff changeset
1610 /* Restore decl names reference except for wrapper functions. */
kono
parents: 67
diff changeset
1611 if (!chkp_wrap_function (cnode->orig_decl))
kono
parents: 67
diff changeset
1612 {
kono
parents: 67
diff changeset
1613 tree name = DECL_ASSEMBLER_NAME (cnode->decl);
kono
parents: 67
diff changeset
1614 IDENTIFIER_TRANSPARENT_ALIAS (name) = 1;
kono
parents: 67
diff changeset
1615 TREE_CHAIN (name) = DECL_ASSEMBLER_NAME (cnode->orig_decl);
kono
parents: 67
diff changeset
1616 }
kono
parents: 67
diff changeset
1617 }
kono
parents: 67
diff changeset
1618 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1619
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1620 ref = (int) (intptr_t) node->same_comdat_group;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1621
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1622 /* Fixup same_comdat_group from reference to pointer. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1623 if (ref != LCC_NOT_FOUND)
111
kono
parents: 67
diff changeset
1624 node->same_comdat_group = nodes[ref];
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1625 else
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1626 node->same_comdat_group = NULL;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1627 }
111
kono
parents: 67
diff changeset
1628 FOR_EACH_VEC_ELT (nodes, i, node)
kono
parents: 67
diff changeset
1629 node->aux = is_a <cgraph_node *> (node) ? (void *)1 : NULL;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1630 return nodes;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1631 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1632
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1633 /* Input ipa_refs. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1634
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1635 static void
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1636 input_refs (struct lto_input_block *ib,
111
kono
parents: 67
diff changeset
1637 vec<symtab_node *> nodes)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1638 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1639 int count;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1640 int idx;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1641 while (true)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1642 {
111
kono
parents: 67
diff changeset
1643 symtab_node *node;
kono
parents: 67
diff changeset
1644 count = streamer_read_uhwi (ib);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1645 if (!count)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1646 break;
111
kono
parents: 67
diff changeset
1647 idx = streamer_read_uhwi (ib);
kono
parents: 67
diff changeset
1648 node = nodes[idx];
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1649 while (count)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1650 {
111
kono
parents: 67
diff changeset
1651 input_ref (ib, node, nodes);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1652 count--;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1653 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1654 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1655 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1656
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1657
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1658 static struct gcov_ctr_summary lto_gcov_summary;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1659
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1660 /* Input profile_info from IB. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1661 static void
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1662 input_profile_summary (struct lto_input_block *ib,
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1663 struct lto_file_decl_data *file_data)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1664 {
111
kono
parents: 67
diff changeset
1665 unsigned h_ix;
kono
parents: 67
diff changeset
1666 struct bitpack_d bp;
kono
parents: 67
diff changeset
1667 unsigned int runs = streamer_read_uhwi (ib);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1668 if (runs)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1669 {
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1670 file_data->profile_info.runs = runs;
111
kono
parents: 67
diff changeset
1671 file_data->profile_info.sum_max = streamer_read_gcov_count (ib);
kono
parents: 67
diff changeset
1672 file_data->profile_info.sum_all = streamer_read_gcov_count (ib);
kono
parents: 67
diff changeset
1673
kono
parents: 67
diff changeset
1674 memset (file_data->profile_info.histogram, 0,
kono
parents: 67
diff changeset
1675 sizeof (gcov_bucket_type) * GCOV_HISTOGRAM_SIZE);
kono
parents: 67
diff changeset
1676 /* Input the bitpack of non-zero histogram indices. */
kono
parents: 67
diff changeset
1677 bp = streamer_read_bitpack (ib);
kono
parents: 67
diff changeset
1678 /* Read in and unpack the full bitpack, flagging non-zero
kono
parents: 67
diff changeset
1679 histogram entries by setting the num_counters non-zero. */
kono
parents: 67
diff changeset
1680 for (h_ix = 0; h_ix < GCOV_HISTOGRAM_SIZE; h_ix++)
kono
parents: 67
diff changeset
1681 {
kono
parents: 67
diff changeset
1682 file_data->profile_info.histogram[h_ix].num_counters
kono
parents: 67
diff changeset
1683 = bp_unpack_value (&bp, 1);
kono
parents: 67
diff changeset
1684 }
kono
parents: 67
diff changeset
1685 for (h_ix = 0; h_ix < GCOV_HISTOGRAM_SIZE; h_ix++)
kono
parents: 67
diff changeset
1686 {
kono
parents: 67
diff changeset
1687 if (!file_data->profile_info.histogram[h_ix].num_counters)
kono
parents: 67
diff changeset
1688 continue;
kono
parents: 67
diff changeset
1689
kono
parents: 67
diff changeset
1690 file_data->profile_info.histogram[h_ix].num_counters
kono
parents: 67
diff changeset
1691 = streamer_read_gcov_count (ib);
kono
parents: 67
diff changeset
1692 file_data->profile_info.histogram[h_ix].min_value
kono
parents: 67
diff changeset
1693 = streamer_read_gcov_count (ib);
kono
parents: 67
diff changeset
1694 file_data->profile_info.histogram[h_ix].cum_value
kono
parents: 67
diff changeset
1695 = streamer_read_gcov_count (ib);
kono
parents: 67
diff changeset
1696 }
kono
parents: 67
diff changeset
1697 /* IPA-profile computes hot bb threshold based on cumulated
kono
parents: 67
diff changeset
1698 whole program profile. We need to stream it down to ltrans. */
kono
parents: 67
diff changeset
1699 if (flag_ltrans)
kono
parents: 67
diff changeset
1700 set_hot_bb_threshold (streamer_read_gcov_count (ib));
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1701 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1702
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1703 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1704
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1705 /* Rescale profile summaries to the same number of runs in the whole unit. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1706
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1707 static void
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1708 merge_profile_summaries (struct lto_file_decl_data **file_data_vec)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1709 {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1710 struct lto_file_decl_data *file_data;
111
kono
parents: 67
diff changeset
1711 unsigned int j, h_ix;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1712 gcov_unsigned_t max_runs = 0;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1713 struct cgraph_node *node;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1714 struct cgraph_edge *edge;
111
kono
parents: 67
diff changeset
1715 gcov_type saved_sum_all = 0;
kono
parents: 67
diff changeset
1716 gcov_ctr_summary *saved_profile_info = 0;
kono
parents: 67
diff changeset
1717 int saved_scale = 0;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1718
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1719 /* Find unit with maximal number of runs. If we ever get serious about
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1720 roundoff errors, we might also consider computing smallest common
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1721 multiply. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1722 for (j = 0; (file_data = file_data_vec[j]) != NULL; j++)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1723 if (max_runs < file_data->profile_info.runs)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1724 max_runs = file_data->profile_info.runs;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1725
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1726 if (!max_runs)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1727 return;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1728
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1729 /* Simple overflow check. We probably don't need to support that many train
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1730 runs. Such a large value probably imply data corruption anyway. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1731 if (max_runs > INT_MAX / REG_BR_PROB_BASE)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1732 {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1733 sorry ("At most %i profile runs is supported. Perhaps corrupted profile?",
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1734 INT_MAX / REG_BR_PROB_BASE);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1735 return;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1736 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1737
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1738 profile_info = &lto_gcov_summary;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1739 lto_gcov_summary.runs = max_runs;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1740 lto_gcov_summary.sum_max = 0;
111
kono
parents: 67
diff changeset
1741 memset (lto_gcov_summary.histogram, 0,
kono
parents: 67
diff changeset
1742 sizeof (gcov_bucket_type) * GCOV_HISTOGRAM_SIZE);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1743
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1744 /* Rescale all units to the maximal number of runs.
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1745 sum_max can not be easily merged, as we have no idea what files come from
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1746 the same run. We do not use the info anyway, so leave it 0. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1747 for (j = 0; (file_data = file_data_vec[j]) != NULL; j++)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1748 if (file_data->profile_info.runs)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1749 {
111
kono
parents: 67
diff changeset
1750 int scale = GCOV_COMPUTE_SCALE (max_runs,
kono
parents: 67
diff changeset
1751 file_data->profile_info.runs);
kono
parents: 67
diff changeset
1752 lto_gcov_summary.sum_max
kono
parents: 67
diff changeset
1753 = MAX (lto_gcov_summary.sum_max,
kono
parents: 67
diff changeset
1754 apply_scale (file_data->profile_info.sum_max, scale));
kono
parents: 67
diff changeset
1755 lto_gcov_summary.sum_all
kono
parents: 67
diff changeset
1756 = MAX (lto_gcov_summary.sum_all,
kono
parents: 67
diff changeset
1757 apply_scale (file_data->profile_info.sum_all, scale));
kono
parents: 67
diff changeset
1758 /* Save a pointer to the profile_info with the largest
kono
parents: 67
diff changeset
1759 scaled sum_all and the scale for use in merging the
kono
parents: 67
diff changeset
1760 histogram. */
kono
parents: 67
diff changeset
1761 if (!saved_profile_info
kono
parents: 67
diff changeset
1762 || lto_gcov_summary.sum_all > saved_sum_all)
kono
parents: 67
diff changeset
1763 {
kono
parents: 67
diff changeset
1764 saved_profile_info = &file_data->profile_info;
kono
parents: 67
diff changeset
1765 saved_sum_all = lto_gcov_summary.sum_all;
kono
parents: 67
diff changeset
1766 saved_scale = scale;
kono
parents: 67
diff changeset
1767 }
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1768 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1769
111
kono
parents: 67
diff changeset
1770 gcc_assert (saved_profile_info);
kono
parents: 67
diff changeset
1771
kono
parents: 67
diff changeset
1772 /* Scale up the histogram from the profile that had the largest
kono
parents: 67
diff changeset
1773 scaled sum_all above. */
kono
parents: 67
diff changeset
1774 for (h_ix = 0; h_ix < GCOV_HISTOGRAM_SIZE; h_ix++)
kono
parents: 67
diff changeset
1775 {
kono
parents: 67
diff changeset
1776 /* Scale up the min value as we did the corresponding sum_all
kono
parents: 67
diff changeset
1777 above. Use that to find the new histogram index. */
kono
parents: 67
diff changeset
1778 gcov_type scaled_min
kono
parents: 67
diff changeset
1779 = apply_scale (saved_profile_info->histogram[h_ix].min_value,
kono
parents: 67
diff changeset
1780 saved_scale);
kono
parents: 67
diff changeset
1781 /* The new index may be shared with another scaled histogram entry,
kono
parents: 67
diff changeset
1782 so we need to account for a non-zero histogram entry at new_ix. */
kono
parents: 67
diff changeset
1783 unsigned new_ix = gcov_histo_index (scaled_min);
kono
parents: 67
diff changeset
1784 lto_gcov_summary.histogram[new_ix].min_value
kono
parents: 67
diff changeset
1785 = (lto_gcov_summary.histogram[new_ix].num_counters
kono
parents: 67
diff changeset
1786 ? MIN (lto_gcov_summary.histogram[new_ix].min_value, scaled_min)
kono
parents: 67
diff changeset
1787 : scaled_min);
kono
parents: 67
diff changeset
1788 /* Some of the scaled counter values would ostensibly need to be placed
kono
parents: 67
diff changeset
1789 into different (larger) histogram buckets, but we keep things simple
kono
parents: 67
diff changeset
1790 here and place the scaled cumulative counter value in the bucket
kono
parents: 67
diff changeset
1791 corresponding to the scaled minimum counter value. */
kono
parents: 67
diff changeset
1792 lto_gcov_summary.histogram[new_ix].cum_value
kono
parents: 67
diff changeset
1793 += apply_scale (saved_profile_info->histogram[h_ix].cum_value,
kono
parents: 67
diff changeset
1794 saved_scale);
kono
parents: 67
diff changeset
1795 lto_gcov_summary.histogram[new_ix].num_counters
kono
parents: 67
diff changeset
1796 += saved_profile_info->histogram[h_ix].num_counters;
kono
parents: 67
diff changeset
1797 }
kono
parents: 67
diff changeset
1798
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1799 /* Watch roundoff errors. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1800 if (lto_gcov_summary.sum_max < max_runs)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1801 lto_gcov_summary.sum_max = max_runs;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1802
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1803 /* If merging already happent at WPA time, we are done. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1804 if (flag_ltrans)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1805 return;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1806
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1807 /* Now compute count_materialization_scale of each node.
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1808 During LTRANS we already have values of count_materialization_scale
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1809 computed, so just update them. */
111
kono
parents: 67
diff changeset
1810 FOR_EACH_FUNCTION (node)
kono
parents: 67
diff changeset
1811 if (node->lto_file_data
kono
parents: 67
diff changeset
1812 && node->lto_file_data->profile_info.runs)
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1813 {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1814 int scale;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1815
111
kono
parents: 67
diff changeset
1816 scale = RDIV (node->count_materialization_scale * max_runs,
kono
parents: 67
diff changeset
1817 node->lto_file_data->profile_info.runs);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1818 node->count_materialization_scale = scale;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1819 if (scale < 0)
111
kono
parents: 67
diff changeset
1820 fatal_error (input_location, "Profile information in %s corrupted",
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1821 file_data->file_name);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1822
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1823 if (scale == REG_BR_PROB_BASE)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1824 continue;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1825 for (edge = node->callees; edge; edge = edge->next_callee)
111
kono
parents: 67
diff changeset
1826 edge->count = edge->count.apply_scale (scale, REG_BR_PROB_BASE);
kono
parents: 67
diff changeset
1827 node->count = node->count.apply_scale (scale, REG_BR_PROB_BASE);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1828 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1829 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1830
111
kono
parents: 67
diff changeset
1831 /* Input and merge the symtab from each of the .o files passed to
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1832 lto1. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1833
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1834 void
111
kono
parents: 67
diff changeset
1835 input_symtab (void)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1836 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1837 struct lto_file_decl_data **file_data_vec = lto_get_file_decl_data ();
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1838 struct lto_file_decl_data *file_data;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1839 unsigned int j = 0;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1840 struct cgraph_node *node;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1841
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1842 while ((file_data = file_data_vec[j++]))
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1843 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1844 const char *data;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1845 size_t len;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1846 struct lto_input_block *ib;
111
kono
parents: 67
diff changeset
1847 vec<symtab_node *> nodes;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1848
111
kono
parents: 67
diff changeset
1849 ib = lto_create_simple_input_block (file_data, LTO_section_symtab_nodes,
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1850 &data, &len);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1851 if (!ib)
111
kono
parents: 67
diff changeset
1852 fatal_error (input_location,
kono
parents: 67
diff changeset
1853 "cannot find LTO cgraph in %s", file_data->file_name);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1854 input_profile_summary (ib, file_data);
111
kono
parents: 67
diff changeset
1855 file_data->symtab_node_encoder = lto_symtab_encoder_new (true);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1856 nodes = input_cgraph_1 (file_data, ib);
111
kono
parents: 67
diff changeset
1857 lto_destroy_simple_input_block (file_data, LTO_section_symtab_nodes,
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1858 ib, data, len);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1859
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1860 ib = lto_create_simple_input_block (file_data, LTO_section_refs,
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1861 &data, &len);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1862 if (!ib)
111
kono
parents: 67
diff changeset
1863 fatal_error (input_location, "cannot find LTO section refs in %s",
kono
parents: 67
diff changeset
1864 file_data->file_name);
kono
parents: 67
diff changeset
1865 input_refs (ib, nodes);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1866 lto_destroy_simple_input_block (file_data, LTO_section_refs,
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1867 ib, data, len);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1868 if (flag_ltrans)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1869 input_cgraph_opt_summary (nodes);
111
kono
parents: 67
diff changeset
1870 nodes.release ();
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1871 }
111
kono
parents: 67
diff changeset
1872
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1873 merge_profile_summaries (file_data_vec);
111
kono
parents: 67
diff changeset
1874
kono
parents: 67
diff changeset
1875 if (!flag_auto_profile)
kono
parents: 67
diff changeset
1876 get_working_sets ();
kono
parents: 67
diff changeset
1877
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1878
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1879 /* Clear out the aux field that was used to store enough state to
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1880 tell which nodes should be overwritten. */
111
kono
parents: 67
diff changeset
1881 FOR_EACH_FUNCTION (node)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1882 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1883 /* Some nodes may have been created by cgraph_node. This
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1884 happens when the callgraph contains nested functions. If the
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1885 node for the parent function was never emitted to the gimple
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1886 file, cgraph_node will create a node for it when setting the
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1887 context of the nested function. */
111
kono
parents: 67
diff changeset
1888 if (node->lto_file_data)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1889 node->aux = NULL;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1890 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1891 }
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1892
111
kono
parents: 67
diff changeset
1893 /* Input function/variable tables that will allow libgomp to look up offload
kono
parents: 67
diff changeset
1894 target code, and store them into OFFLOAD_FUNCS and OFFLOAD_VARS. */
kono
parents: 67
diff changeset
1895
kono
parents: 67
diff changeset
1896 void
kono
parents: 67
diff changeset
1897 input_offload_tables (bool do_force_output)
kono
parents: 67
diff changeset
1898 {
kono
parents: 67
diff changeset
1899 struct lto_file_decl_data **file_data_vec = lto_get_file_decl_data ();
kono
parents: 67
diff changeset
1900 struct lto_file_decl_data *file_data;
kono
parents: 67
diff changeset
1901 unsigned int j = 0;
kono
parents: 67
diff changeset
1902
kono
parents: 67
diff changeset
1903 while ((file_data = file_data_vec[j++]))
kono
parents: 67
diff changeset
1904 {
kono
parents: 67
diff changeset
1905 const char *data;
kono
parents: 67
diff changeset
1906 size_t len;
kono
parents: 67
diff changeset
1907 struct lto_input_block *ib
kono
parents: 67
diff changeset
1908 = lto_create_simple_input_block (file_data, LTO_section_offload_table,
kono
parents: 67
diff changeset
1909 &data, &len);
kono
parents: 67
diff changeset
1910 if (!ib)
kono
parents: 67
diff changeset
1911 continue;
kono
parents: 67
diff changeset
1912
kono
parents: 67
diff changeset
1913 enum LTO_symtab_tags tag
kono
parents: 67
diff changeset
1914 = streamer_read_enum (ib, LTO_symtab_tags, LTO_symtab_last_tag);
kono
parents: 67
diff changeset
1915 while (tag)
kono
parents: 67
diff changeset
1916 {
kono
parents: 67
diff changeset
1917 if (tag == LTO_symtab_unavail_node)
kono
parents: 67
diff changeset
1918 {
kono
parents: 67
diff changeset
1919 int decl_index = streamer_read_uhwi (ib);
kono
parents: 67
diff changeset
1920 tree fn_decl
kono
parents: 67
diff changeset
1921 = lto_file_decl_data_get_fn_decl (file_data, decl_index);
kono
parents: 67
diff changeset
1922 vec_safe_push (offload_funcs, fn_decl);
kono
parents: 67
diff changeset
1923
kono
parents: 67
diff changeset
1924 /* Prevent IPA from removing fn_decl as unreachable, since there
kono
parents: 67
diff changeset
1925 may be no refs from the parent function to child_fn in offload
kono
parents: 67
diff changeset
1926 LTO mode. */
kono
parents: 67
diff changeset
1927 if (do_force_output)
kono
parents: 67
diff changeset
1928 cgraph_node::get (fn_decl)->mark_force_output ();
kono
parents: 67
diff changeset
1929 }
kono
parents: 67
diff changeset
1930 else if (tag == LTO_symtab_variable)
kono
parents: 67
diff changeset
1931 {
kono
parents: 67
diff changeset
1932 int decl_index = streamer_read_uhwi (ib);
kono
parents: 67
diff changeset
1933 tree var_decl
kono
parents: 67
diff changeset
1934 = lto_file_decl_data_get_var_decl (file_data, decl_index);
kono
parents: 67
diff changeset
1935 vec_safe_push (offload_vars, var_decl);
kono
parents: 67
diff changeset
1936
kono
parents: 67
diff changeset
1937 /* Prevent IPA from removing var_decl as unused, since there
kono
parents: 67
diff changeset
1938 may be no refs to var_decl in offload LTO mode. */
kono
parents: 67
diff changeset
1939 if (do_force_output)
kono
parents: 67
diff changeset
1940 varpool_node::get (var_decl)->force_output = 1;
kono
parents: 67
diff changeset
1941 }
kono
parents: 67
diff changeset
1942 else
kono
parents: 67
diff changeset
1943 fatal_error (input_location,
kono
parents: 67
diff changeset
1944 "invalid offload table in %s", file_data->file_name);
kono
parents: 67
diff changeset
1945
kono
parents: 67
diff changeset
1946 tag = streamer_read_enum (ib, LTO_symtab_tags, LTO_symtab_last_tag);
kono
parents: 67
diff changeset
1947 }
kono
parents: 67
diff changeset
1948
kono
parents: 67
diff changeset
1949 lto_destroy_simple_input_block (file_data, LTO_section_offload_table,
kono
parents: 67
diff changeset
1950 ib, data, len);
kono
parents: 67
diff changeset
1951 }
kono
parents: 67
diff changeset
1952 }
kono
parents: 67
diff changeset
1953
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1954 /* True when we need optimization summary for NODE. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1955
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1956 static int
111
kono
parents: 67
diff changeset
1957 output_cgraph_opt_summary_p (struct cgraph_node *node)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1958 {
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1959 return (node->clone_of
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1960 && (node->clone.tree_map
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1961 || node->clone.args_to_skip
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1962 || node->clone.combined_args_to_skip));
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1963 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1964
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1965 /* Output optimization summary for EDGE to OB. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1966 static void
111
kono
parents: 67
diff changeset
1967 output_edge_opt_summary (struct output_block *ob ATTRIBUTE_UNUSED,
kono
parents: 67
diff changeset
1968 struct cgraph_edge *edge ATTRIBUTE_UNUSED)
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1969 {
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1970 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1971
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1972 /* Output optimization summary for NODE to OB. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1973
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1974 static void
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1975 output_node_opt_summary (struct output_block *ob,
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1976 struct cgraph_node *node,
111
kono
parents: 67
diff changeset
1977 lto_symtab_encoder_t encoder)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1978 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1979 unsigned int index;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1980 bitmap_iterator bi;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1981 struct ipa_replace_map *map;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1982 struct bitpack_d bp;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1983 int i;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1984 struct cgraph_edge *e;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1985
111
kono
parents: 67
diff changeset
1986 if (node->clone.args_to_skip)
kono
parents: 67
diff changeset
1987 {
kono
parents: 67
diff changeset
1988 streamer_write_uhwi (ob, bitmap_count_bits (node->clone.args_to_skip));
kono
parents: 67
diff changeset
1989 EXECUTE_IF_SET_IN_BITMAP (node->clone.args_to_skip, 0, index, bi)
kono
parents: 67
diff changeset
1990 streamer_write_uhwi (ob, index);
kono
parents: 67
diff changeset
1991 }
kono
parents: 67
diff changeset
1992 else
kono
parents: 67
diff changeset
1993 streamer_write_uhwi (ob, 0);
kono
parents: 67
diff changeset
1994 if (node->clone.combined_args_to_skip)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1995 {
111
kono
parents: 67
diff changeset
1996 streamer_write_uhwi (ob, bitmap_count_bits (node->clone.combined_args_to_skip));
kono
parents: 67
diff changeset
1997 EXECUTE_IF_SET_IN_BITMAP (node->clone.combined_args_to_skip, 0, index, bi)
kono
parents: 67
diff changeset
1998 streamer_write_uhwi (ob, index);
kono
parents: 67
diff changeset
1999 }
kono
parents: 67
diff changeset
2000 else
kono
parents: 67
diff changeset
2001 streamer_write_uhwi (ob, 0);
kono
parents: 67
diff changeset
2002 streamer_write_uhwi (ob, vec_safe_length (node->clone.tree_map));
kono
parents: 67
diff changeset
2003 FOR_EACH_VEC_SAFE_ELT (node->clone.tree_map, i, map)
kono
parents: 67
diff changeset
2004 {
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2005 /* At the moment we assume all old trees to be PARM_DECLs, because we have no
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2006 mechanism to store function local declarations into summaries. */
111
kono
parents: 67
diff changeset
2007 gcc_assert (!map->old_tree);
kono
parents: 67
diff changeset
2008 streamer_write_uhwi (ob, map->parm_num);
kono
parents: 67
diff changeset
2009 gcc_assert (EXPR_LOCATION (map->new_tree) == UNKNOWN_LOCATION);
kono
parents: 67
diff changeset
2010 stream_write_tree (ob, map->new_tree, true);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2011 bp = bitpack_create (ob->main_stream);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2012 bp_pack_value (&bp, map->replace_p, 1);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2013 bp_pack_value (&bp, map->ref_p, 1);
111
kono
parents: 67
diff changeset
2014 streamer_write_bitpack (&bp);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2015 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2016
111
kono
parents: 67
diff changeset
2017 if (lto_symtab_encoder_in_partition_p (encoder, node))
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2018 {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2019 for (e = node->callees; e; e = e->next_callee)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2020 output_edge_opt_summary (ob, e);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2021 for (e = node->indirect_calls; e; e = e->next_callee)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2022 output_edge_opt_summary (ob, e);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2023 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2024 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2025
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2026 /* Output optimization summaries stored in callgraph.
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2027 At the moment it is the clone info structure. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2028
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2029 static void
111
kono
parents: 67
diff changeset
2030 output_cgraph_opt_summary (void)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2031 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2032 int i, n_nodes;
111
kono
parents: 67
diff changeset
2033 lto_symtab_encoder_t encoder;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2034 struct output_block *ob = create_output_block (LTO_section_cgraph_opt_sum);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2035 unsigned count = 0;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2036
111
kono
parents: 67
diff changeset
2037 ob->symbol = NULL;
kono
parents: 67
diff changeset
2038 encoder = ob->decl_state->symtab_node_encoder;
kono
parents: 67
diff changeset
2039 n_nodes = lto_symtab_encoder_size (encoder);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2040 for (i = 0; i < n_nodes; i++)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2041 {
111
kono
parents: 67
diff changeset
2042 symtab_node *node = lto_symtab_encoder_deref (encoder, i);
kono
parents: 67
diff changeset
2043 cgraph_node *cnode = dyn_cast <cgraph_node *> (node);
kono
parents: 67
diff changeset
2044 if (cnode && output_cgraph_opt_summary_p (cnode))
kono
parents: 67
diff changeset
2045 count++;
kono
parents: 67
diff changeset
2046 }
kono
parents: 67
diff changeset
2047 streamer_write_uhwi (ob, count);
kono
parents: 67
diff changeset
2048 for (i = 0; i < n_nodes; i++)
kono
parents: 67
diff changeset
2049 {
kono
parents: 67
diff changeset
2050 symtab_node *node = lto_symtab_encoder_deref (encoder, i);
kono
parents: 67
diff changeset
2051 cgraph_node *cnode = dyn_cast <cgraph_node *> (node);
kono
parents: 67
diff changeset
2052 if (cnode && output_cgraph_opt_summary_p (cnode))
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2053 {
111
kono
parents: 67
diff changeset
2054 streamer_write_uhwi (ob, i);
kono
parents: 67
diff changeset
2055 output_node_opt_summary (ob, cnode, encoder);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2056 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2057 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2058 produce_asm (ob, NULL);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2059 destroy_output_block (ob);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2060 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2061
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2062 /* Input optimisation summary of EDGE. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2063
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2064 static void
111
kono
parents: 67
diff changeset
2065 input_edge_opt_summary (struct cgraph_edge *edge ATTRIBUTE_UNUSED,
kono
parents: 67
diff changeset
2066 struct lto_input_block *ib_main ATTRIBUTE_UNUSED)
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2067 {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2068 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2069
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2070 /* Input optimisation summary of NODE. */
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2071
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2072 static void
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2073 input_node_opt_summary (struct cgraph_node *node,
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2074 struct lto_input_block *ib_main,
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2075 struct data_in *data_in)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2076 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2077 int i;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2078 int count;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2079 int bit;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2080 struct bitpack_d bp;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2081 struct cgraph_edge *e;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2082
111
kono
parents: 67
diff changeset
2083 count = streamer_read_uhwi (ib_main);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2084 if (count)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2085 node->clone.args_to_skip = BITMAP_GGC_ALLOC ();
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2086 for (i = 0; i < count; i++)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2087 {
111
kono
parents: 67
diff changeset
2088 bit = streamer_read_uhwi (ib_main);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2089 bitmap_set_bit (node->clone.args_to_skip, bit);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2090 }
111
kono
parents: 67
diff changeset
2091 count = streamer_read_uhwi (ib_main);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2092 if (count)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2093 node->clone.combined_args_to_skip = BITMAP_GGC_ALLOC ();
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2094 for (i = 0; i < count; i++)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2095 {
111
kono
parents: 67
diff changeset
2096 bit = streamer_read_uhwi (ib_main);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2097 bitmap_set_bit (node->clone.combined_args_to_skip, bit);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2098 }
111
kono
parents: 67
diff changeset
2099 count = streamer_read_uhwi (ib_main);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2100 for (i = 0; i < count; i++)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2101 {
111
kono
parents: 67
diff changeset
2102 struct ipa_replace_map *map = ggc_alloc<ipa_replace_map> ();
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2103
111
kono
parents: 67
diff changeset
2104 vec_safe_push (node->clone.tree_map, map);
kono
parents: 67
diff changeset
2105 map->parm_num = streamer_read_uhwi (ib_main);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2106 map->old_tree = NULL;
111
kono
parents: 67
diff changeset
2107 map->new_tree = stream_read_tree (ib_main, data_in);
kono
parents: 67
diff changeset
2108 bp = streamer_read_bitpack (ib_main);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2109 map->replace_p = bp_unpack_value (&bp, 1);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2110 map->ref_p = bp_unpack_value (&bp, 1);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2111 }
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2112 for (e = node->callees; e; e = e->next_callee)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2113 input_edge_opt_summary (e, ib_main);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2114 for (e = node->indirect_calls; e; e = e->next_callee)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2115 input_edge_opt_summary (e, ib_main);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2116 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2117
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2118 /* Read section in file FILE_DATA of length LEN with data DATA. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2119
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2120 static void
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2121 input_cgraph_opt_section (struct lto_file_decl_data *file_data,
111
kono
parents: 67
diff changeset
2122 const char *data, size_t len,
kono
parents: 67
diff changeset
2123 vec<symtab_node *> nodes)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2124 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2125 const struct lto_function_header *header =
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2126 (const struct lto_function_header *) data;
111
kono
parents: 67
diff changeset
2127 const int cfg_offset = sizeof (struct lto_function_header);
kono
parents: 67
diff changeset
2128 const int main_offset = cfg_offset + header->cfg_size;
kono
parents: 67
diff changeset
2129 const int string_offset = main_offset + header->main_size;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2130 struct data_in *data_in;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2131 unsigned int i;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2132 unsigned int count;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2133
111
kono
parents: 67
diff changeset
2134 lto_input_block ib_main ((const char *) data + main_offset,
kono
parents: 67
diff changeset
2135 header->main_size, file_data->mode_table);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2136
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2137 data_in =
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2138 lto_data_in_create (file_data, (const char *) data + string_offset,
111
kono
parents: 67
diff changeset
2139 header->string_size, vNULL);
kono
parents: 67
diff changeset
2140 count = streamer_read_uhwi (&ib_main);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2141
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2142 for (i = 0; i < count; i++)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2143 {
111
kono
parents: 67
diff changeset
2144 int ref = streamer_read_uhwi (&ib_main);
kono
parents: 67
diff changeset
2145 input_node_opt_summary (dyn_cast<cgraph_node *> (nodes[ref]),
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2146 &ib_main, data_in);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2147 }
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2148 lto_free_section_data (file_data, LTO_section_cgraph_opt_sum, NULL, data,
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2149 len);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2150 lto_data_in_delete (data_in);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2151 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2152
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2153 /* Input optimization summary of cgraph. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2154
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2155 static void
111
kono
parents: 67
diff changeset
2156 input_cgraph_opt_summary (vec<symtab_node *> nodes)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2157 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2158 struct lto_file_decl_data **file_data_vec = lto_get_file_decl_data ();
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2159 struct lto_file_decl_data *file_data;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2160 unsigned int j = 0;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2161
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2162 while ((file_data = file_data_vec[j++]))
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2163 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2164 size_t len;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2165 const char *data =
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2166 lto_get_section_data (file_data, LTO_section_cgraph_opt_sum, NULL,
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2167 &len);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2168
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2169 if (data)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2170 input_cgraph_opt_section (file_data, data, len, nodes);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2171 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2172 }