Mercurial > hg > CbC > CbC_gcc
annotate gcc/lto-cgraph.c @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | f6334be47118 |
children | 84e7813d76e9 |
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 | 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 | 26 #include "backend.h" |
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 | 29 #include "gimple.h" |
30 #include "predict.h" | |
31 #include "stringpool.h" | |
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 | 34 #include "tree-pass.h" |
35 #include "profile.h" | |
36 #include "context.h" | |
37 #include "pass_manager.h" | |
38 #include "ipa-utils.h" | |
39 #include "omp-offload.h" | |
40 #include "ipa-chkp.h" | |
41 #include "stringpool.h" | |
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 | 44 /* True when asm nodes has been output. */ |
45 bool asm_nodes_output = false; | |
46 | |
47 static void output_cgraph_opt_summary (void); | |
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 | 50 /* Number of LDPR values known to GCC. */ |
51 #define LDPR_NUM_KNOWN (LDPR_PREVAILING_DEF_IRONLY_EXP + 1) | |
52 | |
53 /* All node orders are ofsetted by ORDER_BASE. */ | |
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 | 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 | 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 | 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 | 67 LTO_symtab_edge, |
68 LTO_symtab_indirect_edge, | |
69 LTO_symtab_variable, | |
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 | 73 /* Create a new symtab encoder. |
74 if FOR_INPUT, the encoder allocate only datastructures needed | |
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 | 77 lto_symtab_encoder_t |
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 | 80 lto_symtab_encoder_t encoder = XCNEW (struct lto_symtab_encoder_d); |
81 | |
82 if (!for_input) | |
83 encoder->map = new hash_map<symtab_node *, size_t>; | |
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 | 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 | 94 encoder->nodes.release (); |
95 if (encoder->map) | |
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 | 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 | 106 lto_symtab_encoder_encode (lto_symtab_encoder_t encoder, |
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 | 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 | 113 lto_encoder_entry entry = {node, false, false, false}; |
114 | |
115 ref = encoder->nodes.length (); | |
116 encoder->nodes.safe_push (entry); | |
117 return ref; | |
118 } | |
119 | |
120 size_t *slot = encoder->map->get (node); | |
121 if (!slot || !*slot) | |
122 { | |
123 lto_encoder_entry entry = {node, false, false, false}; | |
124 ref = encoder->nodes.length (); | |
125 if (!slot) | |
126 encoder->map->put (node, ref + 1); | |
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 | 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 | 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 | 137 bool |
138 lto_symtab_encoder_delete_node (lto_symtab_encoder_t encoder, | |
139 symtab_node *node) | |
140 { | |
141 int index; | |
142 lto_encoder_entry last_node; | |
143 | |
144 size_t *slot = encoder->map->get (node); | |
145 if (slot == NULL || !*slot) | |
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 | 148 index = *slot - 1; |
149 gcc_checking_assert (encoder->nodes[index].node == node); | |
150 | |
151 /* Remove from vector. We do this by swapping node with the last element | |
152 of the vector. */ | |
153 last_node = encoder->nodes.pop (); | |
154 if (last_node.node != node) | |
155 { | |
156 gcc_assert (encoder->map->put (last_node.node, index + 1)); | |
157 | |
158 /* Move the last element to the original spot of NODE. */ | |
159 encoder->nodes[index] = last_node; | |
160 } | |
161 | |
162 /* Remove element from hash table. */ | |
163 encoder->map->remove (node); | |
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 | 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 | 170 bool |
171 lto_symtab_encoder_encode_body_p (lto_symtab_encoder_t encoder, | |
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 | 174 int index = lto_symtab_encoder_lookup (encoder, node); |
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 | 178 /* Specify that we encode the body of NODE in this partition. */ |
179 | |
180 static void | |
181 lto_set_symtab_encoder_encode_body (lto_symtab_encoder_t encoder, | |
182 struct cgraph_node *node) | |
183 { | |
184 int index = lto_symtab_encoder_encode (encoder, node); | |
185 gcc_checking_assert (encoder->nodes[index].node == node); | |
186 encoder->nodes[index].body = true; | |
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 | 192 lto_symtab_encoder_encode_initializer_p (lto_symtab_encoder_t encoder, |
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 | 195 int index = lto_symtab_encoder_lookup (encoder, node); |
196 if (index == LCC_NOT_FOUND) | |
197 return false; | |
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 | 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 | 203 static void |
204 lto_set_symtab_encoder_encode_initializer (lto_symtab_encoder_t encoder, | |
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 | 207 int index = lto_symtab_encoder_lookup (encoder, node); |
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 | 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 | 213 bool |
214 lto_symtab_encoder_in_partition_p (lto_symtab_encoder_t encoder, | |
215 symtab_node *node) | |
216 { | |
217 int index = lto_symtab_encoder_lookup (encoder, node); | |
218 if (index == LCC_NOT_FOUND) | |
219 return false; | |
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 | 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 | 225 void |
226 lto_set_symtab_encoder_in_partition (lto_symtab_encoder_t encoder, | |
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 | 229 int index = lto_symtab_encoder_encode (encoder, node); |
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 | 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 | 244 streamer_write_enum (ob->main_stream, LTO_symtab_tags, LTO_symtab_last_tag, |
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 | 247 streamer_write_enum (ob->main_stream, LTO_symtab_tags, LTO_symtab_last_tag, |
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 | 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 | 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 | 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 | 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 | 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 | 264 uid = (!gimple_has_body_p (edge->caller->decl) || edge->caller->thunk.thunk_p |
265 ? edge->lto_stmt_uid : gimple_uid (edge->call_stmt) + 1); | |
266 bp_pack_enum (&bp, cgraph_inline_failed_t, | |
267 CIF_N_REASONS, edge->inline_failed); | |
268 bp_pack_var_len_unsigned (&bp, uid); | |
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 | 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 | 273 gcc_assert (!edge->call_stmt_cannot_inline_p |
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 | 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 | 293 streamer_write_bitpack (&bp); |
294 if (edge->indirect_unknown_callee) | |
295 { | |
296 streamer_write_hwi_stream (ob->main_stream, | |
297 edge->indirect_info->common_target_id); | |
298 if (edge->indirect_info->common_target_id) | |
299 streamer_write_hwi_stream | |
300 (ob->main_stream, edge->indirect_info->common_target_probability); | |
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 | 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 | 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 | 310 struct ipa_ref *ref = NULL; |
311 | |
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 | 314 /* Ignore references from non-offloadable nodes while streaming NODE into |
315 offload LTO section. */ | |
316 if (!ref->referring->need_lto_streaming) | |
317 continue; | |
318 | |
319 if (ref->referring->in_other_partition | |
320 || !lto_symtab_encoder_in_partition_p (encoder, ref->referring)) | |
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 | 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 | 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 | 337 { |
338 /* Ignore references from non-offloadable nodes while streaming NODE into | |
339 offload LTO section. */ | |
340 if (!e->caller->need_lto_streaming) | |
341 continue; | |
342 | |
343 if (e->caller->in_other_partition | |
344 || !lto_symtab_encoder_in_partition_p (encoder, e->caller)) | |
345 return true; | |
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 | 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 | 353 referenced_from_this_partition_p (symtab_node *node, |
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 | 357 struct ipa_ref *ref = NULL; |
358 | |
359 for (i = 0; node->iterate_referring (i, ref); i++) | |
360 if (lto_symtab_encoder_in_partition_p (encoder, ref->referring)) | |
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 | 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 | 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 | 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 | 394 struct cgraph_node *clone_of, *ultimate_clone_of; |
395 ipa_opt_pass_d *pass; | |
396 int i; | |
397 const char *comdat; | |
398 const char *section; | |
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 | 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 | 403 if (node->analyzed && (!boundary_p || node->alias |
404 || (node->thunk.thunk_p && !node->global.inlined_to))) | |
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 | 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 | 409 streamer_write_enum (ob->main_stream, LTO_symtab_tags, LTO_symtab_last_tag, |
410 tag); | |
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 | 423 if (boundary_p && node->analyzed |
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 | 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 | 445 /* See if body of the master function is output. If not, we are seeing only |
446 an declaration and we do not need to pass down clone tree. */ | |
447 ultimate_clone_of = clone_of; | |
448 while (ultimate_clone_of && ultimate_clone_of->clone_of) | |
449 ultimate_clone_of = ultimate_clone_of->clone_of; | |
450 | |
451 if (clone_of && !lto_symtab_encoder_encode_body_p (encoder, ultimate_clone_of)) | |
452 clone_of = NULL; | |
453 | |
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 | 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 | 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 | 463 node->count.stream_out (ob->main_stream); |
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 | 466 streamer_write_hwi_stream (ob->main_stream, |
467 node->ipa_transforms_to_apply.length ()); | |
468 FOR_EACH_VEC_ELT (node->ipa_transforms_to_apply, i, pass) | |
469 streamer_write_hwi_stream (ob->main_stream, pass->static_pass_number); | |
470 | |
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 | 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 | 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 | 484 group = node->get_comdat_group (); |
485 if (group) | |
486 comdat = IDENTIFIER_POINTER (group); | |
487 else | |
488 comdat = ""; | |
489 streamer_write_data_stream (ob->main_stream, comdat, strlen (comdat) + 1); | |
490 | |
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 | 493 if (node->same_comdat_group) |
494 { | |
495 ref = LCC_NOT_FOUND; | |
496 for (struct symtab_node *n = node->same_comdat_group; | |
497 ref == LCC_NOT_FOUND && n != node; n = n->same_comdat_group) | |
498 ref = lto_symtab_encoder_lookup (encoder, n); | |
499 } | |
500 else | |
501 ref = LCC_NOT_FOUND; | |
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 | 504 |
505 section = node->get_section (); | |
506 if (!section) | |
507 section = ""; | |
508 | |
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 | 513 bp_pack_value (&bp, node->externally_visible, 1); |
514 bp_pack_value (&bp, node->no_reorder, 1); | |
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 | 519 bp_pack_value (&bp, node->force_output, 1); |
520 bp_pack_value (&bp, node->forced_by_abi, 1); | |
521 bp_pack_value (&bp, node->unique_name, 1); | |
522 bp_pack_value (&bp, node->body_removed, 1); | |
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 | 525 bp_pack_value (&bp, tag == LTO_symtab_analyzed_node |
526 && node->get_partitioning_class () == SYMBOL_PARTITION | |
527 && (reachable_from_other_partition_p (node, encoder) | |
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 | 532 bp_pack_value (&bp, node->transparent_alias, 1); |
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 | 537 bp_pack_value (&bp, node->tm_clone, 1); |
538 bp_pack_value (&bp, node->calls_comdat_local, 1); | |
539 bp_pack_value (&bp, node->icf_merged, 1); | |
540 bp_pack_value (&bp, node->nonfreeing_fn, 1); | |
541 bp_pack_value (&bp, node->thunk.thunk_p, 1); | |
542 bp_pack_value (&bp, node->parallelized_function, 1); | |
543 bp_pack_enum (&bp, ld_plugin_symbol_resolution, | |
544 LDPR_NUM_KNOWN, node->resolution); | |
545 bp_pack_value (&bp, node->instrumentation_clone, 1); | |
546 bp_pack_value (&bp, node->split_part, 1); | |
547 streamer_write_bitpack (&bp); | |
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 | 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 | 552 streamer_write_uhwi_stream |
553 (ob->main_stream, | |
554 1 + (node->thunk.this_adjusting != 0) * 2 | |
555 + (node->thunk.virtual_offset_p != 0) * 4 | |
556 + (node->thunk.add_pointer_bounds_args != 0) * 8); | |
557 streamer_write_uhwi_stream (ob->main_stream, node->thunk.fixed_offset); | |
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 | 560 streamer_write_hwi_stream (ob->main_stream, node->profile_id); |
561 if (DECL_STATIC_CONSTRUCTOR (node->decl)) | |
562 streamer_write_hwi_stream (ob->main_stream, node->get_init_priority ()); | |
563 if (DECL_STATIC_DESTRUCTOR (node->decl)) | |
564 streamer_write_hwi_stream (ob->main_stream, node->get_fini_priority ()); | |
565 | |
566 if (node->instrumentation_clone) | |
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 | 574 lto_output_varpool_node (struct lto_simple_output_block *ob, varpool_node *node, |
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 | 577 bool boundary_p = !lto_symtab_encoder_in_partition_p (encoder, node); |
578 bool encode_initializer_p | |
579 = (node->definition | |
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 | 583 const char *comdat; |
584 const char *section; | |
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 | 587 gcc_assert (!encode_initializer_p || node->definition); |
588 gcc_assert (boundary_p || encode_initializer_p); | |
589 | |
590 streamer_write_enum (ob->main_stream, LTO_symtab_tags, LTO_symtab_last_tag, | |
591 LTO_symtab_variable); | |
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 | 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 | 598 bp_pack_value (&bp, node->forced_by_abi, 1); |
599 bp_pack_value (&bp, node->unique_name, 1); | |
600 bp_pack_value (&bp, | |
601 node->body_removed | |
602 || (!encode_initializer_p && !node->alias && node->definition), | |
603 1); | |
604 bp_pack_value (&bp, node->implicit_section, 1); | |
605 bp_pack_value (&bp, node->writeonly, 1); | |
606 bp_pack_value (&bp, node->definition && (encode_initializer_p || node->alias), | |
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 | 609 bp_pack_value (&bp, node->transparent_alias, 1); |
610 bp_pack_value (&bp, node->weakref, 1); | |
611 bp_pack_value (&bp, node->analyzed && (!boundary_p || node->alias), 1); | |
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 | 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 | 623 bp_pack_value (&bp, node->definition |
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 | 626 && boundary_p && !DECL_EXTERNAL (node->decl), 1); |
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 | 629 bp_pack_value (&bp, node->tls_model, 3); |
630 bp_pack_value (&bp, node->used_by_single_function, 1); | |
631 bp_pack_value (&bp, node->dynamically_initialized, 1); | |
632 bp_pack_value (&bp, node->need_bounds_init, 1); | |
633 streamer_write_bitpack (&bp); | |
634 | |
635 group = node->get_comdat_group (); | |
636 if (group) | |
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 | 639 comdat = ""; |
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 | 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 | 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 | 646 ref = LCC_NOT_FOUND; |
647 for (struct symtab_node *n = node->same_comdat_group; | |
648 ref == LCC_NOT_FOUND && n != node; n = n->same_comdat_group) | |
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 | 651 else |
652 ref = LCC_NOT_FOUND; | |
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 | 655 |
656 section = node->get_section (); | |
657 if (!section) | |
658 section = ""; | |
659 streamer_write_data_stream (ob->main_stream, section, strlen (section) + 1); | |
660 | |
661 streamer_write_enum (ob->main_stream, ld_plugin_symbol_resolution, | |
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 | 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 | 673 int nref; |
674 int uid = ref->lto_stmt_uid; | |
675 struct cgraph_node *node; | |
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 | 678 bp_pack_value (&bp, ref->use, 3); |
679 bp_pack_value (&bp, ref->speculative, 1); | |
680 streamer_write_bitpack (&bp); | |
681 nref = lto_symtab_encoder_lookup (encoder, ref->referred); | |
682 gcc_assert (nref != LCC_NOT_FOUND); | |
683 streamer_write_hwi_stream (ob->main_stream, nref); | |
684 | |
685 node = dyn_cast <cgraph_node *> (ref->referring); | |
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 | 688 if (ref->stmt) |
689 uid = gimple_uid (ref->stmt) + 1; | |
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 | 699 unsigned h_ix; |
700 struct bitpack_d bp; | |
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 | 704 /* We do not output num and run_max, they are not used by |
705 GCC profile feedback and they are difficult to merge from multiple | |
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 | 708 streamer_write_uhwi_stream (ob->main_stream, profile_info->runs); |
709 streamer_write_gcov_count_stream (ob->main_stream, profile_info->sum_max); | |
710 | |
711 /* sum_all is needed for computing the working set with the | |
712 histogram. */ | |
713 streamer_write_gcov_count_stream (ob->main_stream, profile_info->sum_all); | |
714 | |
715 /* Create and output a bitpack of non-zero histogram entries indices. */ | |
716 bp = bitpack_create (ob->main_stream); | |
717 for (h_ix = 0; h_ix < GCOV_HISTOGRAM_SIZE; h_ix++) | |
718 bp_pack_value (&bp, profile_info->histogram[h_ix].num_counters > 0, 1); | |
719 streamer_write_bitpack (&bp); | |
720 /* Now stream out only those non-zero entries. */ | |
721 for (h_ix = 0; h_ix < GCOV_HISTOGRAM_SIZE; h_ix++) | |
722 { | |
723 if (!profile_info->histogram[h_ix].num_counters) | |
724 continue; | |
725 streamer_write_gcov_count_stream (ob->main_stream, | |
726 profile_info->histogram[h_ix].num_counters); | |
727 streamer_write_gcov_count_stream (ob->main_stream, | |
728 profile_info->histogram[h_ix].min_value); | |
729 streamer_write_gcov_count_stream (ob->main_stream, | |
730 profile_info->histogram[h_ix].cum_value); | |
731 } | |
732 /* IPA-profile computes hot bb threshold based on cumulated | |
733 whole program profile. We need to stream it down to ltrans. */ | |
734 if (flag_wpa) | |
735 streamer_write_gcov_count_stream (ob->main_stream, | |
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 | 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 | 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 | 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 | 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 | 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 | 776 /* IPA_REF_ALIAS and IPA_REF_CHKP references are always preserved |
777 in the boundary. Alias node can't have other references and | |
778 can be always handled as if it's not in the boundary. */ | |
779 if (!node->alias && !lto_symtab_encoder_in_partition_p (encoder, node)) | |
780 { | |
781 cgraph_node *cnode = dyn_cast <cgraph_node *> (node); | |
782 /* Output IPA_REF_CHKP reference. */ | |
783 if (cnode | |
784 && cnode->instrumented_version | |
785 && !cnode->instrumentation_clone) | |
786 { | |
787 for (int i = 0; node->iterate_reference (i, ref); i++) | |
788 if (ref->use == IPA_REF_CHKP) | |
789 { | |
790 if (lto_symtab_encoder_lookup (encoder, ref->referred) | |
791 != LCC_NOT_FOUND) | |
792 { | |
793 int nref = lto_symtab_encoder_lookup (encoder, node); | |
794 streamer_write_gcov_count_stream (ob->main_stream, 1); | |
795 streamer_write_uhwi_stream (ob->main_stream, nref); | |
796 lto_output_ref (ob, ref, encoder); | |
797 } | |
798 break; | |
799 } | |
800 } | |
801 continue; | |
802 } | |
803 | |
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 | 807 streamer_write_gcov_count_stream (ob->main_stream, count); |
808 streamer_write_uhwi_stream (ob->main_stream, | |
809 lto_symtab_encoder_lookup (encoder, node)); | |
810 for (int i = 0; node->iterate_reference (i, ref); i++) | |
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 | 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 | 820 /* Add NODE into encoder as well as nodes it is cloned from. |
821 Do it in a way so clones appear first. */ | |
822 | |
823 static void | |
824 add_node_to (lto_symtab_encoder_t encoder, struct cgraph_node *node, | |
825 bool include_body) | |
826 { | |
827 if (node->clone_of) | |
828 add_node_to (encoder, node->clone_of, include_body); | |
829 else if (include_body) | |
830 lto_set_symtab_encoder_encode_body (encoder, node); | |
831 lto_symtab_encoder_encode (encoder, node); | |
832 } | |
833 | |
834 /* Add all references in NODE to encoders. */ | |
835 | |
836 static void | |
837 create_references (lto_symtab_encoder_t encoder, symtab_node *node) | |
838 { | |
839 int i; | |
840 struct ipa_ref *ref = NULL; | |
841 for (i = 0; node->iterate_reference (i, ref); i++) | |
842 if (is_a <cgraph_node *> (ref->referred)) | |
843 add_node_to (encoder, dyn_cast <cgraph_node *> (ref->referred), false); | |
844 else | |
845 lto_symtab_encoder_encode (encoder, ref->referred); | |
846 } | |
847 | |
848 /* Select what needs to be streamed out. In regular lto mode stream everything. | |
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 | 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 | 853 struct symtab_node *snode; |
854 FOR_EACH_SYMBOL (snode) | |
855 snode->need_lto_streaming = !lto_stream_offload_p || snode->offloadable; | |
856 } | |
857 | |
858 /* Find all symbols we want to stream into given partition and insert them | |
859 to encoders. | |
860 | |
861 The function actually replaces IN_ENCODER by new one. The reason is that | |
862 streaming code needs clone's origin to be streamed before clone. This | |
863 means that we need to insert the nodes in specific order. This order is | |
864 ignored by the partitioning logic earlier. */ | |
865 | |
866 lto_symtab_encoder_t | |
867 compute_ltrans_boundary (lto_symtab_encoder_t in_encoder) | |
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 | 871 lto_symtab_encoder_t encoder; |
872 lto_symtab_encoder_iterator lsei; | |
873 hash_set<void *> reachable_call_targets; | |
874 | |
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 | 877 /* Go over all entries in the IN_ENCODER and duplicate them to |
878 ENCODER. At the same time insert masters of clones so | |
879 every master appears before clone. */ | |
880 for (lsei = lsei_start_function_in_partition (in_encoder); | |
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 | 883 struct cgraph_node *node = lsei_cgraph_node (lsei); |
884 if (!node->need_lto_streaming) | |
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 | 887 lto_set_symtab_encoder_in_partition (encoder, node); |
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 | 890 for (lsei = lsei_start_variable_in_partition (in_encoder); |
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 | 893 varpool_node *vnode = lsei_varpool_node (lsei); |
894 | |
895 if (!vnode->need_lto_streaming) | |
896 continue; | |
897 lto_set_symtab_encoder_in_partition (encoder, vnode); | |
898 lto_set_symtab_encoder_encode_initializer (encoder, vnode); | |
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 | 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 | 906 symtab_node *node = lto_symtab_encoder_deref (encoder, i); |
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 | 909 if (!lto_symtab_encoder_encode_initializer_p (encoder, |
910 vnode) | |
911 && (((vnode->ctor_useable_for_folding_p () | |
912 && (!DECL_VIRTUAL_P (vnode->decl) | |
913 || !flag_wpa | |
914 || flag_ltrans_devirtualize)) | |
915 || POINTER_BOUNDS_P (vnode->decl)))) | |
916 { | |
917 lto_set_symtab_encoder_encode_initializer (encoder, vnode); | |
918 create_references (encoder, vnode); | |
919 } | |
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 | 925 for (lsei = lsei_start_function_in_partition (encoder); |
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 | 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 | 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 | 939 /* Add all possible targets for late devirtualization. */ |
940 if (flag_ltrans_devirtualize || !flag_wpa) | |
941 for (edge = node->indirect_calls; edge; edge = edge->next_callee) | |
942 if (edge->indirect_info->polymorphic) | |
943 { | |
944 unsigned int i; | |
945 void *cache_token; | |
946 bool final; | |
947 vec <cgraph_node *>targets | |
948 = possible_polymorphic_call_targets | |
949 (edge, &final, &cache_token); | |
950 if (!reachable_call_targets.add (cache_token)) | |
951 { | |
952 for (i = 0; i < targets.length (); i++) | |
953 { | |
954 struct cgraph_node *callee = targets[i]; | |
955 | |
956 /* Adding an external declarations into the unit serves | |
957 no purpose and just increases its boundary. */ | |
958 if (callee->definition | |
959 && !lto_symtab_encoder_in_partition_p | |
960 (encoder, callee)) | |
961 { | |
962 gcc_assert (!callee->global.inlined_to); | |
963 add_node_to (encoder, callee, false); | |
964 } | |
965 } | |
966 } | |
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 | 969 /* Be sure to also insert alias targert and thunk callees. These needs |
970 to stay to aid local calling conventions. */ | |
971 for (i = 0; i < lto_symtab_encoder_size (encoder); i++) | |
972 { | |
973 symtab_node *node = lto_symtab_encoder_deref (encoder, i); | |
974 cgraph_node *cnode = dyn_cast <cgraph_node *> (node); | |
975 | |
976 if (node->alias && node->analyzed) | |
977 create_references (encoder, node); | |
978 if (cnode | |
979 && cnode->thunk.thunk_p && !cnode->global.inlined_to) | |
980 add_node_to (encoder, cnode->callees->callee, false); | |
981 while (node->transparent_alias && node->analyzed) | |
982 { | |
983 node = node->get_alias_target (); | |
984 if (is_a <cgraph_node *> (node)) | |
985 add_node_to (encoder, dyn_cast <cgraph_node *> (node), | |
986 false); | |
987 else | |
988 lto_symtab_encoder_encode (encoder, node); | |
989 } | |
990 } | |
991 lto_symtab_encoder_delete (in_encoder); | |
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 | 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 | 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 | 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 | 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 | 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 | 1014 gcc_assert (ob->decl_state->symtab_node_encoder); |
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 | 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 | 1023 symtab_node *node = lto_symtab_encoder_deref (encoder, i); |
1024 if (cgraph_node *cnode = dyn_cast <cgraph_node *> (node)) | |
1025 lto_output_node (ob, cnode, encoder); | |
1026 else | |
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 | 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 | 1033 node = dyn_cast <cgraph_node *> (lto_symtab_encoder_deref (encoder, i)); |
1034 if (node | |
1035 && ((node->thunk.thunk_p && !node->global.inlined_to) | |
1036 || lto_symtab_encoder_in_partition_p (encoder, node))) | |
1037 { | |
1038 output_outgoing_cgraph_edges (node->callees, ob, encoder); | |
1039 output_outgoing_cgraph_edges (node->indirect_calls, ob, encoder); | |
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 | 1043 streamer_write_uhwi_stream (ob->main_stream, 0); |
1044 | |
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 | 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 | 1057 output_refs (encoder); |
1058 } | |
1059 | |
1060 /* Return identifier encoded in IB as a plain string. */ | |
1061 | |
1062 static tree | |
1063 read_identifier (struct lto_input_block *ib) | |
1064 { | |
1065 unsigned int len = strnlen (ib->data + ib->p, ib->len - ib->p - 1); | |
1066 tree id; | |
1067 | |
1068 if (ib->data[ib->p + len]) | |
1069 lto_section_overrun (ib); | |
1070 if (!len) | |
1071 { | |
1072 ib->p++; | |
1073 return NULL; | |
1074 } | |
1075 id = get_identifier (ib->data + ib->p); | |
1076 ib->p += len + 1; | |
1077 return id; | |
1078 } | |
1079 | |
1080 /* Return string encoded in IB, NULL if string is empty. */ | |
1081 | |
1082 static const char * | |
1083 read_string (struct lto_input_block *ib) | |
1084 { | |
1085 unsigned int len = strnlen (ib->data + ib->p, ib->len - ib->p - 1); | |
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 | 1088 if (ib->data[ib->p + len]) |
1089 lto_section_overrun (ib); | |
1090 if (!len) | |
1091 { | |
1092 ib->p++; | |
1093 return NULL; | |
1094 } | |
1095 str = ib->data + ib->p; | |
1096 ib->p += len + 1; | |
1097 return str; | |
1098 } | |
1099 | |
1100 /* Output function/variable tables that will allow libgomp to look up offload | |
1101 target code. | |
1102 OFFLOAD_FUNCS is filled in expand_omp_target, OFFLOAD_VARS is filled in | |
1103 varpool_node::get_create. In WHOPR (partitioned) mode during the WPA stage | |
1104 both OFFLOAD_FUNCS and OFFLOAD_VARS are filled by input_offload_tables. */ | |
1105 | |
1106 void | |
1107 output_offload_tables (void) | |
1108 { | |
1109 if (vec_safe_is_empty (offload_funcs) && vec_safe_is_empty (offload_vars)) | |
1110 return; | |
1111 | |
1112 struct lto_simple_output_block *ob | |
1113 = lto_create_simple_output_block (LTO_section_offload_table); | |
1114 | |
1115 for (unsigned i = 0; i < vec_safe_length (offload_funcs); i++) | |
1116 { | |
1117 streamer_write_enum (ob->main_stream, LTO_symtab_tags, | |
1118 LTO_symtab_last_tag, LTO_symtab_unavail_node); | |
1119 lto_output_fn_decl_index (ob->decl_state, ob->main_stream, | |
1120 (*offload_funcs)[i]); | |
1121 } | |
1122 | |
1123 for (unsigned i = 0; i < vec_safe_length (offload_vars); i++) | |
1124 { | |
1125 streamer_write_enum (ob->main_stream, LTO_symtab_tags, | |
1126 LTO_symtab_last_tag, LTO_symtab_variable); | |
1127 lto_output_var_decl_index (ob->decl_state, ob->main_stream, | |
1128 (*offload_vars)[i]); | |
1129 } | |
1130 | |
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 | 1133 |
1134 /* In WHOPR mode during the WPA stage the joint offload tables need to be | |
1135 streamed to one partition only. That's why we free offload_funcs and | |
1136 offload_vars after the first call of output_offload_tables. */ | |
1137 if (flag_wpa) | |
1138 { | |
1139 vec_free (offload_funcs); | |
1140 vec_free (offload_vars); | |
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 | 1154 enum LTO_symtab_tags tag, |
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 | 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 | 1161 node->externally_visible = bp_unpack_value (bp, 1); |
1162 node->no_reorder = bp_unpack_value (bp, 1); | |
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 | 1167 node->force_output = bp_unpack_value (bp, 1); |
1168 node->forced_by_abi = bp_unpack_value (bp, 1); | |
1169 node->unique_name = bp_unpack_value (bp, 1); | |
1170 node->body_removed = bp_unpack_value (bp, 1); | |
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 | 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 | 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 | 1192 node->transparent_alias = bp_unpack_value (bp, 1); |
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 | 1197 node->tm_clone = bp_unpack_value (bp, 1); |
1198 node->calls_comdat_local = bp_unpack_value (bp, 1); | |
1199 node->icf_merged = bp_unpack_value (bp, 1); | |
1200 node->nonfreeing_fn = bp_unpack_value (bp, 1); | |
1201 node->thunk.thunk_p = bp_unpack_value (bp, 1); | |
1202 node->parallelized_function = bp_unpack_value (bp, 1); | |
1203 node->resolution = bp_unpack_enum (bp, ld_plugin_symbol_resolution, | |
1204 LDPR_NUM_KNOWN); | |
1205 node->instrumentation_clone = bp_unpack_value (bp, 1); | |
1206 node->split_part = bp_unpack_value (bp, 1); | |
1207 gcc_assert (flag_ltrans | |
1208 || (!node->in_other_partition | |
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 | 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 | 1214 static tree |
1215 get_alias_symbol (tree decl) | |
1216 { | |
1217 tree alias = lookup_attribute ("alias", DECL_ATTRIBUTES (decl)); | |
1218 return get_identifier (TREE_STRING_POINTER | |
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 | 1228 enum LTO_symtab_tags tag, |
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 | 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 | 1238 int order; |
1239 int i, count; | |
1240 tree group; | |
1241 const char *section; | |
1242 order = streamer_read_hwi (ib) + order_base; | |
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 | 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 | 1250 node = dyn_cast<cgraph_node *> (nodes[clone_ref])->create_clone (fn_decl, |
1251 profile_count::uninitialized (), CGRAPH_FREQ_BASE, false, | |
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 | 1256 /* Declaration of functions can be already merged with a declaration |
1257 from other input file. We keep cgraph unmerged until after streaming | |
1258 of ipa passes is done. Alays forcingly create a fresh node. */ | |
1259 node = symtab->create_empty (); | |
1260 node->decl = fn_decl; | |
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 | 1264 node->order = order; |
1265 if (order >= symtab->order) | |
1266 symtab->order = order + 1; | |
1267 | |
1268 node->count = profile_count::stream_in (ib); | |
1269 node->count_materialization_scale = streamer_read_hwi (ib); | |
1270 | |
1271 count = streamer_read_hwi (ib); | |
1272 node->ipa_transforms_to_apply = vNULL; | |
1273 for (i = 0; i < count; i++) | |
1274 { | |
1275 opt_pass *pass; | |
1276 int pid = streamer_read_hwi (ib); | |
1277 | |
1278 gcc_assert (pid < passes->passes_by_id_size); | |
1279 pass = passes->passes_by_id[pid]; | |
1280 node->ipa_transforms_to_apply.safe_push ((ipa_opt_pass_d *) pass); | |
1281 } | |
1282 | |
1283 if (tag == LTO_symtab_analyzed_node) | |
1284 ref = streamer_read_hwi (ib); | |
1285 | |
1286 group = read_identifier (ib); | |
1287 if (group) | |
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 | 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 | 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 | 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 | 1300 bp = streamer_read_bitpack (ib); |
1301 | |
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 | 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 | 1307 if (group) |
1308 { | |
1309 node->set_comdat_group (group); | |
1310 /* Store a reference for now, and fix up later to be a pointer. */ | |
1311 node->same_comdat_group = (symtab_node *) (intptr_t) ref2; | |
1312 } | |
1313 else | |
1314 node->same_comdat_group = (symtab_node *) (intptr_t) LCC_NOT_FOUND; | |
1315 section = read_string (ib); | |
1316 if (section) | |
1317 node->set_section_for_node (section); | |
1318 | |
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 | 1321 int type = streamer_read_uhwi (ib); |
1322 HOST_WIDE_INT fixed_offset = streamer_read_uhwi (ib); | |
1323 HOST_WIDE_INT virtual_value = streamer_read_uhwi (ib); | |
1324 | |
1325 node->thunk.fixed_offset = fixed_offset; | |
1326 node->thunk.this_adjusting = (type & 2); | |
1327 node->thunk.virtual_value = virtual_value; | |
1328 node->thunk.virtual_offset_p = (type & 4); | |
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 | 1331 if (node->alias && !node->analyzed && node->weakref) |
1332 node->alias_target = get_alias_symbol (node->decl); | |
1333 node->profile_id = streamer_read_hwi (ib); | |
1334 if (DECL_STATIC_CONSTRUCTOR (node->decl)) | |
1335 node->set_init_priority (streamer_read_hwi (ib)); | |
1336 if (DECL_STATIC_DESTRUCTOR (node->decl)) | |
1337 node->set_fini_priority (streamer_read_hwi (ib)); | |
1338 | |
1339 if (node->instrumentation_clone) | |
1340 { | |
1341 decl_index = streamer_read_uhwi (ib); | |
1342 fn_decl = lto_file_decl_data_get_fn_decl (file_data, decl_index); | |
1343 node->orig_decl = fn_decl; | |
1344 } | |
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 | 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 | 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 | 1361 int order; |
1362 tree group; | |
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 | 1365 order = streamer_read_hwi (ib) + order_base; |
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 | 1368 |
1369 /* Declaration of functions can be already merged with a declaration | |
1370 from other input file. We keep cgraph unmerged until after streaming | |
1371 of ipa passes is done. Alays forcingly create a fresh node. */ | |
1372 node = varpool_node::create_empty (); | |
1373 node->decl = var_decl; | |
1374 node->register_symbol (); | |
1375 | |
1376 node->order = order; | |
1377 if (order >= symtab->order) | |
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 | 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 | 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 | 1385 node->forced_by_abi = bp_unpack_value (&bp, 1); |
1386 node->unique_name = bp_unpack_value (&bp, 1); | |
1387 node->body_removed = bp_unpack_value (&bp, 1); | |
1388 node->implicit_section = bp_unpack_value (&bp, 1); | |
1389 node->writeonly = bp_unpack_value (&bp, 1); | |
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 | 1392 node->transparent_alias = bp_unpack_value (&bp, 1); |
1393 node->weakref = bp_unpack_value (&bp, 1); | |
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 | 1402 if (node->alias && !node->analyzed && node->weakref) |
1403 node->alias_target = get_alias_symbol (node->decl); | |
1404 node->tls_model = (enum tls_model)bp_unpack_value (&bp, 3); | |
1405 node->used_by_single_function = (enum tls_model)bp_unpack_value (&bp, 1); | |
1406 node->dynamically_initialized = bp_unpack_value (&bp, 1); | |
1407 node->need_bounds_init = bp_unpack_value (&bp, 1); | |
1408 group = read_identifier (ib); | |
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 | 1411 node->set_comdat_group (group); |
1412 ref = streamer_read_hwi (ib); | |
1413 /* Store a reference for now, and fix up later to be a pointer. */ | |
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 | 1416 else |
1417 node->same_comdat_group = (symtab_node *) (intptr_t) LCC_NOT_FOUND; | |
1418 section = read_string (ib); | |
1419 if (section) | |
1420 node->set_section_for_node (section); | |
1421 node->resolution = streamer_read_enum (ib, ld_plugin_symbol_resolution, | |
1422 LDPR_NUM_KNOWN); | |
1423 gcc_assert (flag_ltrans | |
1424 || (!node->in_other_partition | |
1425 && !node->used_from_other_partition)); | |
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 | 1435 symtab_node *referring_node, |
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 | 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 | 1441 bool speculative; |
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 | 1444 bp = streamer_read_bitpack (ib); |
1445 use = (enum ipa_ref_use) bp_unpack_value (&bp, 3); | |
1446 speculative = (enum ipa_ref_use) bp_unpack_value (&bp, 1); | |
1447 node = nodes[streamer_read_hwi (ib)]; | |
1448 ref = referring_node->create_reference (node, use); | |
1449 ref->speculative = speculative; | |
1450 if (is_a <cgraph_node *> (referring_node)) | |
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 | 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 | 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 | 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 | 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 | 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 | 1487 bp = streamer_read_bitpack (ib); |
1488 inline_failed = bp_unpack_enum (&bp, cgraph_inline_failed_t, CIF_N_REASONS); | |
1489 stmt_id = bp_unpack_var_len_unsigned (&bp); | |
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 | 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 | 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 | 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 | 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 | 1519 edge->indirect_info->common_target_id = streamer_read_hwi (ib); |
1520 if (edge->indirect_info->common_target_id) | |
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 | 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 | 1532 enum LTO_symtab_tags tag; |
1533 vec<symtab_node *> nodes = vNULL; | |
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 | 1537 tag = streamer_read_enum (ib, LTO_symtab_tags, LTO_symtab_last_tag); |
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 | 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 | 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 | 1545 else if (tag == LTO_symtab_variable) |
1546 { | |
1547 node = input_varpool_node (file_data, ib); | |
1548 nodes.safe_push (node); | |
1549 lto_symtab_encoder_encode (file_data->symtab_node_encoder, node); | |
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 | 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 | 1556 nodes.safe_push (node); |
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 | 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 | 1563 lto_input_toplevel_asms (file_data, order_base); |
1564 | |
1565 /* AUX pointers should be all non-zero for function nodes read from the stream. */ | |
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 | 1568 FOR_EACH_VEC_ELT (nodes, i, node) |
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 | 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 | 1573 int ref; |
1574 if (cgraph_node *cnode = dyn_cast <cgraph_node *> (node)) | |
1575 { | |
1576 ref = (int) (intptr_t) cnode->global.inlined_to; | |
1577 | |
1578 /* We share declaration of builtins, so we may read same node twice. */ | |
1579 if (!node->aux) | |
1580 continue; | |
1581 node->aux = NULL; | |
1582 | |
1583 /* Fixup inlined_to from reference to pointer. */ | |
1584 if (ref != LCC_NOT_FOUND) | |
1585 dyn_cast<cgraph_node *> (node)->global.inlined_to | |
1586 = dyn_cast<cgraph_node *> (nodes[ref]); | |
1587 else | |
1588 cnode->global.inlined_to = NULL; | |
1589 | |
1590 /* Compute instrumented_version. */ | |
1591 if (cnode->instrumentation_clone) | |
1592 { | |
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 | 1595 cnode->instrumented_version = cgraph_node::get (cnode->orig_decl); |
1596 if (cnode->instrumented_version) | |
1597 { | |
1598 /* We may have multiple nodes for a single function which | |
1599 will be merged later. To have a proper merge we need | |
1600 to keep instrumentation_version reference between nodes | |
1601 consistent: each instrumented_version reference should | |
1602 have proper reverse reference. Thus don't break existing | |
1603 instrumented_version reference if it already exists. */ | |
1604 if (cnode->instrumented_version->instrumented_version) | |
1605 cnode->instrumented_version = NULL; | |
1606 else | |
1607 cnode->instrumented_version->instrumented_version = cnode; | |
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 | 1610 /* Restore decl names reference except for wrapper functions. */ |
1611 if (!chkp_wrap_function (cnode->orig_decl)) | |
1612 { | |
1613 tree name = DECL_ASSEMBLER_NAME (cnode->decl); | |
1614 IDENTIFIER_TRANSPARENT_ALIAS (name) = 1; | |
1615 TREE_CHAIN (name) = DECL_ASSEMBLER_NAME (cnode->orig_decl); | |
1616 } | |
1617 } | |
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 | 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 | 1628 FOR_EACH_VEC_ELT (nodes, i, node) |
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 | 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 | 1643 symtab_node *node; |
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 | 1647 idx = streamer_read_uhwi (ib); |
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 | 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 | 1665 unsigned h_ix; |
1666 struct bitpack_d bp; | |
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 | 1671 file_data->profile_info.sum_max = streamer_read_gcov_count (ib); |
1672 file_data->profile_info.sum_all = streamer_read_gcov_count (ib); | |
1673 | |
1674 memset (file_data->profile_info.histogram, 0, | |
1675 sizeof (gcov_bucket_type) * GCOV_HISTOGRAM_SIZE); | |
1676 /* Input the bitpack of non-zero histogram indices. */ | |
1677 bp = streamer_read_bitpack (ib); | |
1678 /* Read in and unpack the full bitpack, flagging non-zero | |
1679 histogram entries by setting the num_counters non-zero. */ | |
1680 for (h_ix = 0; h_ix < GCOV_HISTOGRAM_SIZE; h_ix++) | |
1681 { | |
1682 file_data->profile_info.histogram[h_ix].num_counters | |
1683 = bp_unpack_value (&bp, 1); | |
1684 } | |
1685 for (h_ix = 0; h_ix < GCOV_HISTOGRAM_SIZE; h_ix++) | |
1686 { | |
1687 if (!file_data->profile_info.histogram[h_ix].num_counters) | |
1688 continue; | |
1689 | |
1690 file_data->profile_info.histogram[h_ix].num_counters | |
1691 = streamer_read_gcov_count (ib); | |
1692 file_data->profile_info.histogram[h_ix].min_value | |
1693 = streamer_read_gcov_count (ib); | |
1694 file_data->profile_info.histogram[h_ix].cum_value | |
1695 = streamer_read_gcov_count (ib); | |
1696 } | |
1697 /* IPA-profile computes hot bb threshold based on cumulated | |
1698 whole program profile. We need to stream it down to ltrans. */ | |
1699 if (flag_ltrans) | |
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 | 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 | 1715 gcov_type saved_sum_all = 0; |
1716 gcov_ctr_summary *saved_profile_info = 0; | |
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 = <o_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 | 1741 memset (lto_gcov_summary.histogram, 0, |
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 | 1750 int scale = GCOV_COMPUTE_SCALE (max_runs, |
1751 file_data->profile_info.runs); | |
1752 lto_gcov_summary.sum_max | |
1753 = MAX (lto_gcov_summary.sum_max, | |
1754 apply_scale (file_data->profile_info.sum_max, scale)); | |
1755 lto_gcov_summary.sum_all | |
1756 = MAX (lto_gcov_summary.sum_all, | |
1757 apply_scale (file_data->profile_info.sum_all, scale)); | |
1758 /* Save a pointer to the profile_info with the largest | |
1759 scaled sum_all and the scale for use in merging the | |
1760 histogram. */ | |
1761 if (!saved_profile_info | |
1762 || lto_gcov_summary.sum_all > saved_sum_all) | |
1763 { | |
1764 saved_profile_info = &file_data->profile_info; | |
1765 saved_sum_all = lto_gcov_summary.sum_all; | |
1766 saved_scale = scale; | |
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 | 1770 gcc_assert (saved_profile_info); |
1771 | |
1772 /* Scale up the histogram from the profile that had the largest | |
1773 scaled sum_all above. */ | |
1774 for (h_ix = 0; h_ix < GCOV_HISTOGRAM_SIZE; h_ix++) | |
1775 { | |
1776 /* Scale up the min value as we did the corresponding sum_all | |
1777 above. Use that to find the new histogram index. */ | |
1778 gcov_type scaled_min | |
1779 = apply_scale (saved_profile_info->histogram[h_ix].min_value, | |
1780 saved_scale); | |
1781 /* The new index may be shared with another scaled histogram entry, | |
1782 so we need to account for a non-zero histogram entry at new_ix. */ | |
1783 unsigned new_ix = gcov_histo_index (scaled_min); | |
1784 lto_gcov_summary.histogram[new_ix].min_value | |
1785 = (lto_gcov_summary.histogram[new_ix].num_counters | |
1786 ? MIN (lto_gcov_summary.histogram[new_ix].min_value, scaled_min) | |
1787 : scaled_min); | |
1788 /* Some of the scaled counter values would ostensibly need to be placed | |
1789 into different (larger) histogram buckets, but we keep things simple | |
1790 here and place the scaled cumulative counter value in the bucket | |
1791 corresponding to the scaled minimum counter value. */ | |
1792 lto_gcov_summary.histogram[new_ix].cum_value | |
1793 += apply_scale (saved_profile_info->histogram[h_ix].cum_value, | |
1794 saved_scale); | |
1795 lto_gcov_summary.histogram[new_ix].num_counters | |
1796 += saved_profile_info->histogram[h_ix].num_counters; | |
1797 } | |
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 | 1810 FOR_EACH_FUNCTION (node) |
1811 if (node->lto_file_data | |
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 | 1816 scale = RDIV (node->count_materialization_scale * max_runs, |
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 | 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 | 1826 edge->count = edge->count.apply_scale (scale, REG_BR_PROB_BASE); |
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 | 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 | 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 | 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 | 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 | 1852 fatal_error (input_location, |
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 | 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 | 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 | 1863 fatal_error (input_location, "cannot find LTO section refs in %s", |
1864 file_data->file_name); | |
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 | 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 | 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 | 1874 |
1875 if (!flag_auto_profile) | |
1876 get_working_sets (); | |
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 | 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 | 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 | 1893 /* Input function/variable tables that will allow libgomp to look up offload |
1894 target code, and store them into OFFLOAD_FUNCS and OFFLOAD_VARS. */ | |
1895 | |
1896 void | |
1897 input_offload_tables (bool do_force_output) | |
1898 { | |
1899 struct lto_file_decl_data **file_data_vec = lto_get_file_decl_data (); | |
1900 struct lto_file_decl_data *file_data; | |
1901 unsigned int j = 0; | |
1902 | |
1903 while ((file_data = file_data_vec[j++])) | |
1904 { | |
1905 const char *data; | |
1906 size_t len; | |
1907 struct lto_input_block *ib | |
1908 = lto_create_simple_input_block (file_data, LTO_section_offload_table, | |
1909 &data, &len); | |
1910 if (!ib) | |
1911 continue; | |
1912 | |
1913 enum LTO_symtab_tags tag | |
1914 = streamer_read_enum (ib, LTO_symtab_tags, LTO_symtab_last_tag); | |
1915 while (tag) | |
1916 { | |
1917 if (tag == LTO_symtab_unavail_node) | |
1918 { | |
1919 int decl_index = streamer_read_uhwi (ib); | |
1920 tree fn_decl | |
1921 = lto_file_decl_data_get_fn_decl (file_data, decl_index); | |
1922 vec_safe_push (offload_funcs, fn_decl); | |
1923 | |
1924 /* Prevent IPA from removing fn_decl as unreachable, since there | |
1925 may be no refs from the parent function to child_fn in offload | |
1926 LTO mode. */ | |
1927 if (do_force_output) | |
1928 cgraph_node::get (fn_decl)->mark_force_output (); | |
1929 } | |
1930 else if (tag == LTO_symtab_variable) | |
1931 { | |
1932 int decl_index = streamer_read_uhwi (ib); | |
1933 tree var_decl | |
1934 = lto_file_decl_data_get_var_decl (file_data, decl_index); | |
1935 vec_safe_push (offload_vars, var_decl); | |
1936 | |
1937 /* Prevent IPA from removing var_decl as unused, since there | |
1938 may be no refs to var_decl in offload LTO mode. */ | |
1939 if (do_force_output) | |
1940 varpool_node::get (var_decl)->force_output = 1; | |
1941 } | |
1942 else | |
1943 fatal_error (input_location, | |
1944 "invalid offload table in %s", file_data->file_name); | |
1945 | |
1946 tag = streamer_read_enum (ib, LTO_symtab_tags, LTO_symtab_last_tag); | |
1947 } | |
1948 | |
1949 lto_destroy_simple_input_block (file_data, LTO_section_offload_table, | |
1950 ib, data, len); | |
1951 } | |
1952 } | |
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 | 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 | 1967 output_edge_opt_summary (struct output_block *ob ATTRIBUTE_UNUSED, |
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 | 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 | 1986 if (node->clone.args_to_skip) |
1987 { | |
1988 streamer_write_uhwi (ob, bitmap_count_bits (node->clone.args_to_skip)); | |
1989 EXECUTE_IF_SET_IN_BITMAP (node->clone.args_to_skip, 0, index, bi) | |
1990 streamer_write_uhwi (ob, index); | |
1991 } | |
1992 else | |
1993 streamer_write_uhwi (ob, 0); | |
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 | 1996 streamer_write_uhwi (ob, bitmap_count_bits (node->clone.combined_args_to_skip)); |
1997 EXECUTE_IF_SET_IN_BITMAP (node->clone.combined_args_to_skip, 0, index, bi) | |
1998 streamer_write_uhwi (ob, index); | |
1999 } | |
2000 else | |
2001 streamer_write_uhwi (ob, 0); | |
2002 streamer_write_uhwi (ob, vec_safe_length (node->clone.tree_map)); | |
2003 FOR_EACH_VEC_SAFE_ELT (node->clone.tree_map, i, map) | |
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 | 2007 gcc_assert (!map->old_tree); |
2008 streamer_write_uhwi (ob, map->parm_num); | |
2009 gcc_assert (EXPR_LOCATION (map->new_tree) == UNKNOWN_LOCATION); | |
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 | 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 | 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 | 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 | 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 | 2037 ob->symbol = NULL; |
2038 encoder = ob->decl_state->symtab_node_encoder; | |
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 | 2042 symtab_node *node = lto_symtab_encoder_deref (encoder, i); |
2043 cgraph_node *cnode = dyn_cast <cgraph_node *> (node); | |
2044 if (cnode && output_cgraph_opt_summary_p (cnode)) | |
2045 count++; | |
2046 } | |
2047 streamer_write_uhwi (ob, count); | |
2048 for (i = 0; i < n_nodes; i++) | |
2049 { | |
2050 symtab_node *node = lto_symtab_encoder_deref (encoder, i); | |
2051 cgraph_node *cnode = dyn_cast <cgraph_node *> (node); | |
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 | 2054 streamer_write_uhwi (ob, i); |
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 | 2065 input_edge_opt_summary (struct cgraph_edge *edge ATTRIBUTE_UNUSED, |
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 | 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 | 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 | 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 | 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 | 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 | 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 | 2104 vec_safe_push (node->clone.tree_map, map); |
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 | 2107 map->new_tree = stream_read_tree (ib_main, data_in); |
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 | 2122 const char *data, size_t len, |
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 | 2127 const int cfg_offset = sizeof (struct lto_function_header); |
2128 const int main_offset = cfg_offset + header->cfg_size; | |
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 | 2134 lto_input_block ib_main ((const char *) data + main_offset, |
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 | 2139 header->string_size, vNULL); |
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 | 2144 int ref = streamer_read_uhwi (&ib_main); |
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 | 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 } |