Mercurial > hg > CbC > CbC_gcc
annotate gcc/lto-opts.c @ 158:494b0b89df80 default tip
...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 25 May 2020 18:13:55 +0900 |
parents | 1830386684a0 |
children |
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 |
145 | 3 Copyright (C) 2009-2020 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 |
145 | 68 section_name = lto_get_section_name (LTO_section_opts, NULL, 0, NULL); |
111 | 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 if (!global_options_set.x_flag_openmp |
74 && !global_options.x_flag_openmp) | |
131 | 75 append_to_collect_gcc_options (&temporary_obstack, &first_p, |
76 "-fno-openmp"); | |
111 | 77 if (!global_options_set.x_flag_openacc |
78 && !global_options.x_flag_openacc) | |
79 append_to_collect_gcc_options (&temporary_obstack, &first_p, | |
80 "-fno-openacc"); | |
131 | 81 /* Append PIC/PIE mode because its default depends on target and it is |
82 subject of merging in lto-wrapper. */ | |
83 if (!global_options_set.x_flag_pic && !global_options_set.x_flag_pie) | |
84 { | |
85 append_to_collect_gcc_options (&temporary_obstack, &first_p, | |
86 global_options.x_flag_pic == 2 | |
87 ? "-fPIC" | |
88 : global_options.x_flag_pic == 1 | |
89 ? "-fpic" | |
90 : global_options.x_flag_pie == 2 | |
91 ? "-fPIE" | |
92 : global_options.x_flag_pie == 1 | |
93 ? "-fpie" | |
94 : "-fno-pie"); | |
95 } | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
96 |
145 | 97 /* If debug info is enabled append -g. */ |
98 if (debug_info_level > DINFO_LEVEL_NONE) | |
99 append_to_collect_gcc_options (&temporary_obstack, &first_p, "-g"); | |
100 | |
111 | 101 /* Append options from target hook and store them to offload_lto section. */ |
102 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
|
103 { |
111 | 104 char *offload_opts = targetm.offload_options (); |
105 char *offload_ptr = offload_opts; | |
106 while (offload_ptr) | |
107 { | |
108 char *next = strchr (offload_ptr, ' '); | |
109 if (next) | |
110 *next++ = '\0'; | |
111 append_to_collect_gcc_options (&temporary_obstack, &first_p, | |
112 offload_ptr); | |
113 offload_ptr = next; | |
114 } | |
115 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
|
116 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
117 |
111 | 118 /* Output explicitly passed options. */ |
119 for (i = 1; i < save_decoded_options_count; ++i) | |
120 { | |
121 struct cl_decoded_option *option = &save_decoded_options[i]; | |
122 | |
123 /* Skip explicitly some common options that we do not need. */ | |
124 switch (option->opt_index) | |
125 { | |
126 case OPT_dumpbase: | |
127 case OPT_SPECIAL_unknown: | |
128 case OPT_SPECIAL_ignore: | |
145 | 129 case OPT_SPECIAL_warn_removed: |
111 | 130 case OPT_SPECIAL_program_name: |
131 case OPT_SPECIAL_input_file: | |
131 | 132 case OPT_dumpdir: |
133 case OPT_fresolution_: | |
111 | 134 continue; |
135 | |
136 default: | |
137 break; | |
138 } | |
139 | |
140 /* Skip frontend and driver specific options here. */ | |
141 if (!(cl_options[option->opt_index].flags & (CL_COMMON|CL_TARGET|CL_LTO))) | |
142 continue; | |
143 | |
144 /* Do not store target-specific options in offload_lto section. */ | |
145 if ((cl_options[option->opt_index].flags & CL_TARGET) | |
146 && lto_stream_offload_p) | |
147 continue; | |
148 | |
149 /* Drop options created from the gcc driver that will be rejected | |
150 when passed on to the driver again. */ | |
151 if (cl_options[option->opt_index].cl_reject_driver) | |
152 continue; | |
153 | |
154 /* Also drop all options that are handled by the driver as well, | |
155 which includes things like -o and -v or -fhelp for example. | |
156 We do not need those. The only exception is -foffload option, if we | |
157 write it in offload_lto section. Also drop all diagnostic options. */ | |
158 if ((cl_options[option->opt_index].flags & (CL_DRIVER|CL_WARNING)) | |
159 && (!lto_stream_offload_p || option->opt_index != OPT_foffload_)) | |
160 continue; | |
161 | |
162 for (j = 0; j < option->canonical_option_num_elements; ++j) | |
163 append_to_collect_gcc_options (&temporary_obstack, &first_p, | |
164 option->canonical_option[j]); | |
165 } | |
166 obstack_grow (&temporary_obstack, "\0", 1); | |
167 args = XOBFINISH (&temporary_obstack, char *); | |
168 lto_write_data (args, strlen (args) + 1); | |
169 lto_end_section (); | |
170 | |
171 obstack_free (&temporary_obstack, NULL); | |
172 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
|
173 } |