Mercurial > hg > CbC > CbC_gcc
annotate gcc/lto-opts.c @ 120:f93fa5091070
fix conv1.c
author | mir3636 |
---|---|
date | Thu, 08 Mar 2018 14:53:42 +0900 |
parents | 04ced10e8804 |
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 /* LTO IL options. |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 |
111 | 3 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
|
4 Contributed by Simon Baldwin <simonb@google.com> |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 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
|
7 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 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
|
9 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
|
10 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
|
11 version. |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
12 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
13 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
|
14 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
|
15 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
|
16 for more details. |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
17 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
18 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
|
19 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
|
20 <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
|
21 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
22 #include "config.h" |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
23 #include "system.h" |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
24 #include "coretypes.h" |
111 | 25 #include "backend.h" |
26 #include "target.h" | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
27 #include "tree.h" |
111 | 28 #include "gimple.h" |
29 #include "cgraph.h" | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
30 #include "lto-streamer.h" |
111 | 31 #include "opts.h" |
32 #include "toplev.h" | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
33 |
111 | 34 /* Append the option piece OPT to the COLLECT_GCC_OPTIONS string |
35 set up by OB, appropriately quoted and separated by spaces | |
36 (if !*FIRST_P). */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
37 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
38 static void |
111 | 39 append_to_collect_gcc_options (struct obstack *ob, |
40 bool *first_p, const char *opt) | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
41 { |
111 | 42 const char *p, *q = opt; |
43 if (!*first_p) | |
44 obstack_grow (ob, " ", 1); | |
45 obstack_grow (ob, "'", 1); | |
46 while ((p = strchr (q, '\''))) | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
47 { |
111 | 48 obstack_grow (ob, q, p - q); |
49 obstack_grow (ob, "'\\''", 4); | |
50 q = ++p; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
51 } |
111 | 52 obstack_grow (ob, q, strlen (q)); |
53 obstack_grow (ob, "'", 1); | |
54 *first_p = false; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
55 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
56 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
57 /* Write currently held options to an LTO IL section. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
58 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
59 void |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
60 lto_write_options (void) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
61 { |
111 | 62 char *section_name; |
63 struct obstack temporary_obstack; | |
64 unsigned int i, j; | |
65 char *args; | |
66 bool first_p = true; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
67 |
111 | 68 section_name = lto_get_section_name (LTO_section_opts, NULL, NULL); |
69 lto_begin_section (section_name, false); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
70 |
111 | 71 obstack_init (&temporary_obstack); |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
72 |
111 | 73 /* Output options that affect GIMPLE IL semantics and are implicitly |
74 enabled by the frontend. | |
75 This for now includes an explicit set of options that we also handle | |
76 explicitly in lto-wrapper.c. In the end the effects on GIMPLE IL | |
77 semantics should be explicitely encoded in the IL or saved per | |
78 function rather than per compilation unit. */ | |
79 /* -fexceptions causes the EH machinery to be initialized, enabling | |
80 generation of unwind data so that explicit throw() calls work. */ | |
81 if (!global_options_set.x_flag_exceptions | |
82 && global_options.x_flag_exceptions) | |
83 append_to_collect_gcc_options (&temporary_obstack, &first_p, | |
84 "-fexceptions"); | |
85 /* -fnon-call-exceptions changes the generation of exception | |
86 regions. It is enabled implicitly by the Go frontend. */ | |
87 if (!global_options_set.x_flag_non_call_exceptions | |
88 && global_options.x_flag_non_call_exceptions) | |
89 append_to_collect_gcc_options (&temporary_obstack, &first_p, | |
90 "-fnon-call-exceptions"); | |
91 /* The default -ffp-contract changes depending on the language | |
92 standard. Pass thru conservative standard settings. */ | |
93 if (!global_options_set.x_flag_fp_contract_mode) | |
94 switch (global_options.x_flag_fp_contract_mode) | |
95 { | |
96 case FP_CONTRACT_OFF: | |
97 append_to_collect_gcc_options (&temporary_obstack, &first_p, | |
98 "-ffp-contract=off"); | |
99 break; | |
100 case FP_CONTRACT_ON: | |
101 append_to_collect_gcc_options (&temporary_obstack, &first_p, | |
102 "-ffp-contract=on"); | |
103 break; | |
104 case FP_CONTRACT_FAST: | |
105 /* Nothing. That merges conservatively and is the default for LTO. */ | |
106 break; | |
107 default: | |
108 gcc_unreachable (); | |
109 } | |
110 /* The default -fmath-errno, -fsigned-zeros and -ftrapping-math change | |
111 depending on the language (they can be disabled by the Ada front-end). | |
112 Pass thru conservative standard settings. */ | |
113 if (!global_options_set.x_flag_errno_math) | |
114 append_to_collect_gcc_options (&temporary_obstack, &first_p, | |
115 global_options.x_flag_errno_math | |
116 ? "-fmath-errno" | |
117 : "-fno-math-errno"); | |
118 if (!global_options_set.x_flag_signed_zeros) | |
119 append_to_collect_gcc_options (&temporary_obstack, &first_p, | |
120 global_options.x_flag_signed_zeros | |
121 ? "-fsigned-zeros" | |
122 : "-fno-signed-zeros"); | |
123 if (!global_options_set.x_flag_trapping_math) | |
124 append_to_collect_gcc_options (&temporary_obstack, &first_p, | |
125 global_options.x_flag_trapping_math | |
126 ? "-ftrapping-math" | |
127 : "-fno-trapping-math"); | |
128 /* We need to merge -f[no-]strict-overflow, -f[no-]wrapv and -f[no-]trapv | |
129 conservatively, so stream out their defaults. */ | |
130 if (!global_options_set.x_flag_wrapv | |
131 && global_options.x_flag_wrapv) | |
132 append_to_collect_gcc_options (&temporary_obstack, &first_p, "-fwrapv"); | |
133 if (!global_options_set.x_flag_trapv | |
134 && !global_options.x_flag_trapv) | |
135 append_to_collect_gcc_options (&temporary_obstack, &first_p, "-fno-trapv"); | |
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 if (!global_options_set.x_flag_openmp |
138 && !global_options.x_flag_openmp) | |
139 append_to_collect_gcc_options (&temporary_obstack, &first_p, "-fno-openmp"); | |
140 if (!global_options_set.x_flag_openacc | |
141 && !global_options.x_flag_openacc) | |
142 append_to_collect_gcc_options (&temporary_obstack, &first_p, | |
143 "-fno-openacc"); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
144 |
111 | 145 /* Append options from target hook and store them to offload_lto section. */ |
146 if (lto_stream_offload_p) | |
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 char *offload_opts = targetm.offload_options (); |
149 char *offload_ptr = offload_opts; | |
150 while (offload_ptr) | |
151 { | |
152 char *next = strchr (offload_ptr, ' '); | |
153 if (next) | |
154 *next++ = '\0'; | |
155 append_to_collect_gcc_options (&temporary_obstack, &first_p, | |
156 offload_ptr); | |
157 offload_ptr = next; | |
158 } | |
159 free (offload_opts); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
160 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
161 |
111 | 162 /* Output explicitly passed options. */ |
163 for (i = 1; i < save_decoded_options_count; ++i) | |
164 { | |
165 struct cl_decoded_option *option = &save_decoded_options[i]; | |
166 | |
167 /* Skip explicitly some common options that we do not need. */ | |
168 switch (option->opt_index) | |
169 { | |
170 case OPT_dumpbase: | |
171 case OPT_SPECIAL_unknown: | |
172 case OPT_SPECIAL_ignore: | |
173 case OPT_SPECIAL_program_name: | |
174 case OPT_SPECIAL_input_file: | |
175 continue; | |
176 | |
177 default: | |
178 break; | |
179 } | |
180 | |
181 /* Skip frontend and driver specific options here. */ | |
182 if (!(cl_options[option->opt_index].flags & (CL_COMMON|CL_TARGET|CL_LTO))) | |
183 continue; | |
184 | |
185 /* Do not store target-specific options in offload_lto section. */ | |
186 if ((cl_options[option->opt_index].flags & CL_TARGET) | |
187 && lto_stream_offload_p) | |
188 continue; | |
189 | |
190 /* Drop options created from the gcc driver that will be rejected | |
191 when passed on to the driver again. */ | |
192 if (cl_options[option->opt_index].cl_reject_driver) | |
193 continue; | |
194 | |
195 /* Also drop all options that are handled by the driver as well, | |
196 which includes things like -o and -v or -fhelp for example. | |
197 We do not need those. The only exception is -foffload option, if we | |
198 write it in offload_lto section. Also drop all diagnostic options. */ | |
199 if ((cl_options[option->opt_index].flags & (CL_DRIVER|CL_WARNING)) | |
200 && (!lto_stream_offload_p || option->opt_index != OPT_foffload_)) | |
201 continue; | |
202 | |
203 for (j = 0; j < option->canonical_option_num_elements; ++j) | |
204 append_to_collect_gcc_options (&temporary_obstack, &first_p, | |
205 option->canonical_option[j]); | |
206 } | |
207 obstack_grow (&temporary_obstack, "\0", 1); | |
208 args = XOBFINISH (&temporary_obstack, char *); | |
209 lto_write_data (args, strlen (args) + 1); | |
210 lto_end_section (); | |
211 | |
212 obstack_free (&temporary_obstack, NULL); | |
213 free (section_name); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
214 } |