Mercurial > hg > CbC > CbC_gcc
comparison gcc/opts.c @ 67:f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author | nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 22 Mar 2011 17:18:12 +0900 |
parents | b7f97abdc517 |
children | 04ced10e8804 |
comparison
equal
deleted
inserted
replaced
65:65488c3d617d | 67:f6334be47118 |
---|---|
1 /* Command line option handling. | 1 /* Command line option handling. |
2 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 | 2 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 |
3 Free Software Foundation, Inc. | 3 Free Software Foundation, Inc. |
4 Contributed by Neil Booth. | 4 Contributed by Neil Booth. |
5 | 5 |
6 This file is part of GCC. | 6 This file is part of GCC. |
7 | 7 |
21 | 21 |
22 #include "config.h" | 22 #include "config.h" |
23 #include "system.h" | 23 #include "system.h" |
24 #include "intl.h" | 24 #include "intl.h" |
25 #include "coretypes.h" | 25 #include "coretypes.h" |
26 #include "tm.h" | 26 #include "tm.h" /* Needed by rtl.h and used for STACK_CHECK_BUILTIN, |
27 #include "tree.h" | 27 STACK_CHECK_STATIC_BUILTIN, DEFAULT_GDB_EXTENSIONS, |
28 #include "rtl.h" | 28 DWARF2_DEBUGGING_INFO and DBX_DEBUGGING_INFO. */ |
29 #include "expr.h" | 29 #include "rtl.h" /* Needed by insn-attr.h. */ |
30 #include "ggc.h" | |
31 #include "output.h" | |
32 #include "langhooks.h" | |
33 #include "opts.h" | 30 #include "opts.h" |
34 #include "options.h" | 31 #include "options.h" |
35 #include "flags.h" | 32 #include "flags.h" |
36 #include "toplev.h" | |
37 #include "params.h" | 33 #include "params.h" |
38 #include "diagnostic.h" | 34 #include "diagnostic.h" |
39 #include "tm_p.h" /* For OPTIMIZATION_OPTIONS. */ | 35 #include "opts-diagnostic.h" |
40 #include "insn-attr.h" /* For INSN_SCHEDULING. */ | 36 #include "insn-attr.h" /* For INSN_SCHEDULING and DELAY_SLOTS. */ |
41 #include "target.h" | 37 #include "target.h" |
42 #include "tree-pass.h" | |
43 #include "dbgcnt.h" | |
44 #include "debug.h" | |
45 #include "plugin.h" | |
46 #include "except.h" | |
47 #include "lto-streamer.h" | |
48 | |
49 /* Value of the -G xx switch, and whether it was passed or not. */ | |
50 unsigned HOST_WIDE_INT g_switch_value; | |
51 bool g_switch_set; | |
52 | |
53 /* Same for selective scheduling. */ | |
54 bool sel_sched_switch_set; | |
55 | |
56 /* True if we should exit after parsing options. */ | |
57 bool exit_after_options; | |
58 | |
59 /* True to warn about any objects definitions whose size is larger | |
60 than N bytes. Also want about function definitions whose returned | |
61 values are larger than N bytes, where N is `larger_than_size'. */ | |
62 bool warn_larger_than; | |
63 HOST_WIDE_INT larger_than_size; | |
64 | |
65 /* True to warn about any function whose frame size is larger | |
66 * than N bytes. */ | |
67 bool warn_frame_larger_than; | |
68 HOST_WIDE_INT frame_larger_than_size; | |
69 | |
70 /* Type(s) of debugging information we are producing (if any). See | |
71 flags.h for the definitions of the different possible types of | |
72 debugging information. */ | |
73 enum debug_info_type write_symbols = NO_DEBUG; | |
74 | |
75 /* Level of debugging information we are producing. See flags.h for | |
76 the definitions of the different possible levels. */ | |
77 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE; | |
78 | |
79 /* A major contribution to object and executable size is debug | |
80 information size. A major contribution to debug information size | |
81 is struct descriptions replicated in several object files. The | |
82 following flags attempt to reduce this information. The basic | |
83 idea is to not emit struct debugging information in the current | |
84 compilation unit when that information will be generated by | |
85 another compilation unit. | |
86 | |
87 Debug information for a struct defined in the current source | |
88 file should be generated in the object file. Likewise the | |
89 debug information for a struct defined in a header should be | |
90 generated in the object file of the corresponding source file. | |
91 Both of these case are handled when the base name of the file of | |
92 the struct definition matches the base name of the source file | |
93 of the current compilation unit. This matching emits minimal | |
94 struct debugging information. | |
95 | |
96 The base file name matching rule above will fail to emit debug | |
97 information for structs defined in system headers. So a second | |
98 category of files includes system headers in addition to files | |
99 with matching bases. | |
100 | |
101 The remaining types of files are library headers and application | |
102 headers. We cannot currently distinguish these two types. */ | |
103 | |
104 enum debug_struct_file | |
105 { | |
106 DINFO_STRUCT_FILE_NONE, /* Debug no structs. */ | |
107 DINFO_STRUCT_FILE_BASE, /* Debug structs defined in files with the | |
108 same base name as the compilation unit. */ | |
109 DINFO_STRUCT_FILE_SYS, /* Also debug structs defined in system | |
110 header files. */ | |
111 DINFO_STRUCT_FILE_ANY /* Debug structs defined in all files. */ | |
112 }; | |
113 | |
114 /* Generic structs (e.g. templates not explicitly specialized) | |
115 may not have a compilation unit associated with them, and so | |
116 may need to be treated differently from ordinary structs. | |
117 | |
118 Structs only handled by reference (indirectly), will also usually | |
119 not need as much debugging information. */ | |
120 | |
121 static enum debug_struct_file debug_struct_ordinary[DINFO_USAGE_NUM_ENUMS] | |
122 = { DINFO_STRUCT_FILE_ANY, DINFO_STRUCT_FILE_ANY, DINFO_STRUCT_FILE_ANY }; | |
123 static enum debug_struct_file debug_struct_generic[DINFO_USAGE_NUM_ENUMS] | |
124 = { DINFO_STRUCT_FILE_ANY, DINFO_STRUCT_FILE_ANY, DINFO_STRUCT_FILE_ANY }; | |
125 | 38 |
126 /* Parse the -femit-struct-debug-detailed option value | 39 /* Parse the -femit-struct-debug-detailed option value |
127 and set the flag variables. */ | 40 and set the flag variables. */ |
128 | 41 |
129 #define MATCH( prefix, string ) \ | 42 #define MATCH( prefix, string ) \ |
130 ((strncmp (prefix, string, sizeof prefix - 1) == 0) \ | 43 ((strncmp (prefix, string, sizeof prefix - 1) == 0) \ |
131 ? ((string += sizeof prefix - 1), 1) : 0) | 44 ? ((string += sizeof prefix - 1), 1) : 0) |
132 | 45 |
133 void | 46 void |
134 set_struct_debug_option (const char *spec) | 47 set_struct_debug_option (struct gcc_options *opts, location_t loc, |
48 const char *spec) | |
135 { | 49 { |
136 /* various labels for comparison */ | 50 /* various labels for comparison */ |
137 static char dfn_lbl[] = "dfn:", dir_lbl[] = "dir:", ind_lbl[] = "ind:"; | 51 static const char dfn_lbl[] = "dfn:", dir_lbl[] = "dir:", ind_lbl[] = "ind:"; |
138 static char ord_lbl[] = "ord:", gen_lbl[] = "gen:"; | 52 static const char ord_lbl[] = "ord:", gen_lbl[] = "gen:"; |
139 static char none_lbl[] = "none", any_lbl[] = "any"; | 53 static const char none_lbl[] = "none", any_lbl[] = "any"; |
140 static char base_lbl[] = "base", sys_lbl[] = "sys"; | 54 static const char base_lbl[] = "base", sys_lbl[] = "sys"; |
141 | 55 |
142 enum debug_struct_file files = DINFO_STRUCT_FILE_ANY; | 56 enum debug_struct_file files = DINFO_STRUCT_FILE_ANY; |
143 /* Default is to apply to as much as possible. */ | 57 /* Default is to apply to as much as possible. */ |
144 enum debug_info_usage usage = DINFO_USAGE_NUM_ENUMS; | 58 enum debug_info_usage usage = DINFO_USAGE_NUM_ENUMS; |
145 int ord = 1, gen = 1; | 59 int ord = 1, gen = 1; |
166 else if (MATCH (sys_lbl, spec)) | 80 else if (MATCH (sys_lbl, spec)) |
167 files = DINFO_STRUCT_FILE_SYS; | 81 files = DINFO_STRUCT_FILE_SYS; |
168 else if (MATCH (base_lbl, spec)) | 82 else if (MATCH (base_lbl, spec)) |
169 files = DINFO_STRUCT_FILE_BASE; | 83 files = DINFO_STRUCT_FILE_BASE; |
170 else | 84 else |
171 error ("argument %qs to %<-femit-struct-debug-detailed%> not recognized", | 85 error_at (loc, |
172 spec); | 86 "argument %qs to %<-femit-struct-debug-detailed%> " |
87 "not recognized", | |
88 spec); | |
173 | 89 |
174 /* Effect the specification. */ | 90 /* Effect the specification. */ |
175 if (usage == DINFO_USAGE_NUM_ENUMS) | 91 if (usage == DINFO_USAGE_NUM_ENUMS) |
176 { | 92 { |
177 if (ord) | 93 if (ord) |
178 { | 94 { |
179 debug_struct_ordinary[DINFO_USAGE_DFN] = files; | 95 opts->x_debug_struct_ordinary[DINFO_USAGE_DFN] = files; |
180 debug_struct_ordinary[DINFO_USAGE_DIR_USE] = files; | 96 opts->x_debug_struct_ordinary[DINFO_USAGE_DIR_USE] = files; |
181 debug_struct_ordinary[DINFO_USAGE_IND_USE] = files; | 97 opts->x_debug_struct_ordinary[DINFO_USAGE_IND_USE] = files; |
182 } | 98 } |
183 if (gen) | 99 if (gen) |
184 { | 100 { |
185 debug_struct_generic[DINFO_USAGE_DFN] = files; | 101 opts->x_debug_struct_generic[DINFO_USAGE_DFN] = files; |
186 debug_struct_generic[DINFO_USAGE_DIR_USE] = files; | 102 opts->x_debug_struct_generic[DINFO_USAGE_DIR_USE] = files; |
187 debug_struct_generic[DINFO_USAGE_IND_USE] = files; | 103 opts->x_debug_struct_generic[DINFO_USAGE_IND_USE] = files; |
188 } | 104 } |
189 } | 105 } |
190 else | 106 else |
191 { | 107 { |
192 if (ord) | 108 if (ord) |
193 debug_struct_ordinary[usage] = files; | 109 opts->x_debug_struct_ordinary[usage] = files; |
194 if (gen) | 110 if (gen) |
195 debug_struct_generic[usage] = files; | 111 opts->x_debug_struct_generic[usage] = files; |
196 } | 112 } |
197 | 113 |
198 if (*spec == ',') | 114 if (*spec == ',') |
199 set_struct_debug_option (spec+1); | 115 set_struct_debug_option (opts, loc, spec+1); |
200 else | 116 else |
201 { | 117 { |
202 /* No more -femit-struct-debug-detailed specifications. | 118 /* No more -femit-struct-debug-detailed specifications. |
203 Do final checks. */ | 119 Do final checks. */ |
204 if (*spec != '\0') | 120 if (*spec != '\0') |
205 error ("argument %qs to %<-femit-struct-debug-detailed%> unknown", | 121 error_at (loc, |
206 spec); | 122 "argument %qs to %<-femit-struct-debug-detailed%> unknown", |
207 if (debug_struct_ordinary[DINFO_USAGE_DIR_USE] | 123 spec); |
208 < debug_struct_ordinary[DINFO_USAGE_IND_USE] | 124 if (opts->x_debug_struct_ordinary[DINFO_USAGE_DIR_USE] |
209 || debug_struct_generic[DINFO_USAGE_DIR_USE] | 125 < opts->x_debug_struct_ordinary[DINFO_USAGE_IND_USE] |
210 < debug_struct_generic[DINFO_USAGE_IND_USE]) | 126 || opts->x_debug_struct_generic[DINFO_USAGE_DIR_USE] |
211 error ("%<-femit-struct-debug-detailed=dir:...%> must allow at least" | 127 < opts->x_debug_struct_generic[DINFO_USAGE_IND_USE]) |
212 " as much as %<-femit-struct-debug-detailed=ind:...%>"); | 128 error_at (loc, |
129 "%<-femit-struct-debug-detailed=dir:...%> must allow " | |
130 "at least as much as " | |
131 "%<-femit-struct-debug-detailed=ind:...%>"); | |
132 } | |
133 } | |
134 | |
135 /* Handle -ftree-vectorizer-verbose=VAL for options OPTS. */ | |
136 | |
137 static void | |
138 vect_set_verbosity_level (struct gcc_options *opts, int val) | |
139 { | |
140 if (val < MAX_VERBOSITY_LEVEL) | |
141 opts->x_user_vect_verbosity_level = (enum vect_verbosity_levels) val; | |
142 else | |
143 opts->x_user_vect_verbosity_level | |
144 = (enum vect_verbosity_levels) (MAX_VERBOSITY_LEVEL - 1); | |
145 } | |
146 | |
147 | |
148 /* Strip off a legitimate source ending from the input string NAME of | |
149 length LEN. Rather than having to know the names used by all of | |
150 our front ends, we strip off an ending of a period followed by | |
151 up to five characters. (Java uses ".class".) */ | |
152 | |
153 void | |
154 strip_off_ending (char *name, int len) | |
155 { | |
156 int i; | |
157 for (i = 2; i < 6 && len > i; i++) | |
158 { | |
159 if (name[len - i] == '.') | |
160 { | |
161 name[len - i] = '\0'; | |
162 break; | |
163 } | |
213 } | 164 } |
214 } | 165 } |
215 | 166 |
216 /* Find the base name of a path, stripping off both directories and | 167 /* Find the base name of a path, stripping off both directories and |
217 a single final extension. */ | 168 a single final extension. */ |
218 static int | 169 int |
219 base_of_path (const char *path, const char **base_out) | 170 base_of_path (const char *path, const char **base_out) |
220 { | 171 { |
221 const char *base = path; | 172 const char *base = path; |
222 const char *dot = 0; | 173 const char *dot = 0; |
223 const char *p = path; | 174 const char *p = path; |
237 dot = p; | 188 dot = p; |
238 *base_out = base; | 189 *base_out = base; |
239 return dot - base; | 190 return dot - base; |
240 } | 191 } |
241 | 192 |
242 /* Match the base name of a file to the base name of a compilation unit. */ | |
243 | |
244 static const char *main_input_basename; | |
245 static int main_input_baselength; | |
246 | |
247 static int | |
248 matches_main_base (const char *path) | |
249 { | |
250 /* Cache the last query. */ | |
251 static const char *last_path = NULL; | |
252 static int last_match = 0; | |
253 if (path != last_path) | |
254 { | |
255 const char *base; | |
256 int length = base_of_path (path, &base); | |
257 last_path = path; | |
258 last_match = (length == main_input_baselength | |
259 && memcmp (base, main_input_basename, length) == 0); | |
260 } | |
261 return last_match; | |
262 } | |
263 | |
264 #ifdef DEBUG_DEBUG_STRUCT | |
265 | |
266 static int | |
267 dump_struct_debug (tree type, enum debug_info_usage usage, | |
268 enum debug_struct_file criterion, int generic, | |
269 int matches, int result) | |
270 { | |
271 /* Find the type name. */ | |
272 tree type_decl = TYPE_STUB_DECL (type); | |
273 tree t = type_decl; | |
274 const char *name = 0; | |
275 if (TREE_CODE (t) == TYPE_DECL) | |
276 t = DECL_NAME (t); | |
277 if (t) | |
278 name = IDENTIFIER_POINTER (t); | |
279 | |
280 fprintf (stderr, " struct %d %s %s %s %s %d %p %s\n", | |
281 criterion, | |
282 DECL_IN_SYSTEM_HEADER (type_decl) ? "sys" : "usr", | |
283 matches ? "bas" : "hdr", | |
284 generic ? "gen" : "ord", | |
285 usage == DINFO_USAGE_DFN ? ";" : | |
286 usage == DINFO_USAGE_DIR_USE ? "." : "*", | |
287 result, | |
288 (void*) type_decl, name); | |
289 return result; | |
290 } | |
291 #define DUMP_GSTRUCT(type, usage, criterion, generic, matches, result) \ | |
292 dump_struct_debug (type, usage, criterion, generic, matches, result) | |
293 | |
294 #else | |
295 | |
296 #define DUMP_GSTRUCT(type, usage, criterion, generic, matches, result) \ | |
297 (result) | |
298 | |
299 #endif | |
300 | |
301 | |
302 bool | |
303 should_emit_struct_debug (tree type, enum debug_info_usage usage) | |
304 { | |
305 enum debug_struct_file criterion; | |
306 tree type_decl; | |
307 bool generic = lang_hooks.types.generic_p (type); | |
308 | |
309 if (generic) | |
310 criterion = debug_struct_generic[usage]; | |
311 else | |
312 criterion = debug_struct_ordinary[usage]; | |
313 | |
314 if (criterion == DINFO_STRUCT_FILE_NONE) | |
315 return DUMP_GSTRUCT (type, usage, criterion, generic, false, false); | |
316 if (criterion == DINFO_STRUCT_FILE_ANY) | |
317 return DUMP_GSTRUCT (type, usage, criterion, generic, false, true); | |
318 | |
319 type_decl = TYPE_STUB_DECL (type); | |
320 | |
321 if (criterion == DINFO_STRUCT_FILE_SYS && DECL_IN_SYSTEM_HEADER (type_decl)) | |
322 return DUMP_GSTRUCT (type, usage, criterion, generic, false, true); | |
323 | |
324 if (matches_main_base (DECL_SOURCE_FILE (type_decl))) | |
325 return DUMP_GSTRUCT (type, usage, criterion, generic, true, true); | |
326 return DUMP_GSTRUCT (type, usage, criterion, generic, false, false); | |
327 } | |
328 | |
329 /* Nonzero means use GNU-only extensions in the generated symbolic | |
330 debugging information. Currently, this only has an effect when | |
331 write_symbols is set to DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */ | |
332 bool use_gnu_debug_info_extensions; | |
333 | |
334 /* The default visibility for all symbols (unless overridden) */ | |
335 enum symbol_visibility default_visibility = VISIBILITY_DEFAULT; | |
336 | |
337 /* Global visibility options. */ | |
338 struct visibility_flags visibility_options; | |
339 | |
340 /* What to print when a switch has no documentation. */ | 193 /* What to print when a switch has no documentation. */ |
341 static const char undocumented_msg[] = N_("This switch lacks documentation"); | 194 static const char undocumented_msg[] = N_("This switch lacks documentation"); |
342 | |
343 /* Used for bookkeeping on whether user set these flags so | |
344 -fprofile-use/-fprofile-generate does not use them. */ | |
345 static bool profile_arc_flag_set, flag_profile_values_set; | |
346 static bool flag_unroll_loops_set, flag_tracer_set; | |
347 static bool flag_value_profile_transformations_set; | |
348 static bool flag_peel_loops_set, flag_branch_probabilities_set; | |
349 static bool flag_inline_functions_set, flag_ipa_cp_set, flag_ipa_cp_clone_set; | |
350 static bool flag_predictive_commoning_set, flag_unswitch_loops_set, flag_gcse_after_reload_set; | |
351 | |
352 /* Functions excluded from profiling. */ | |
353 | 195 |
354 typedef char *char_p; /* For DEF_VEC_P. */ | 196 typedef char *char_p; /* For DEF_VEC_P. */ |
355 DEF_VEC_P(char_p); | 197 DEF_VEC_P(char_p); |
356 DEF_VEC_ALLOC_P(char_p,heap); | 198 DEF_VEC_ALLOC_P(char_p,heap); |
357 | 199 |
358 static VEC(char_p,heap) *flag_instrument_functions_exclude_functions; | 200 static void handle_param (struct gcc_options *opts, |
359 static VEC(char_p,heap) *flag_instrument_functions_exclude_files; | 201 struct gcc_options *opts_set, location_t loc, |
360 | 202 const char *carg); |
361 typedef const char *const_char_p; /* For DEF_VEC_P. */ | |
362 DEF_VEC_P(const_char_p); | |
363 DEF_VEC_ALLOC_P(const_char_p,heap); | |
364 | |
365 static VEC(const_char_p,heap) *ignored_options; | |
366 | |
367 /* Language specific warning pass for unused results. */ | |
368 bool flag_warn_unused_result = false; | |
369 | |
370 /* Input file names. */ | |
371 const char **in_fnames; | |
372 unsigned num_in_fnames; | |
373 | |
374 static int common_handle_option (size_t scode, const char *arg, int value, | |
375 unsigned int lang_mask, int kind); | |
376 static void handle_param (const char *); | |
377 static char *write_langs (unsigned int lang_mask); | |
378 static void complain_wrong_lang (const char *, const struct cl_option *, | |
379 unsigned int lang_mask); | |
380 static void set_debug_level (enum debug_info_type type, int extended, | 203 static void set_debug_level (enum debug_info_type type, int extended, |
381 const char *arg); | 204 const char *arg, struct gcc_options *opts, |
382 | 205 struct gcc_options *opts_set, |
383 /* If ARG is a non-negative integer made up solely of digits, return its | 206 location_t loc); |
384 value, otherwise return -1. */ | 207 static void set_fast_math_flags (struct gcc_options *opts, int set); |
385 static int | 208 static void decode_d_option (const char *arg, struct gcc_options *opts, |
386 integral_argument (const char *arg) | 209 location_t loc, diagnostic_context *dc); |
387 { | 210 static void set_unsafe_math_optimizations_flags (struct gcc_options *opts, |
388 const char *p = arg; | 211 int set); |
389 | 212 static void enable_warning_as_error (const char *arg, int value, |
390 while (*p && ISDIGIT (*p)) | 213 unsigned int lang_mask, |
391 p++; | 214 const struct cl_option_handlers *handlers, |
392 | 215 struct gcc_options *opts, |
393 if (*p == '\0') | 216 struct gcc_options *opts_set, |
394 return atoi (arg); | 217 location_t loc, |
395 | 218 diagnostic_context *dc); |
396 return -1; | 219 |
397 } | 220 /* Handle a back-end option; arguments and return value as for |
398 | 221 handle_option. */ |
399 /* Return a malloced slash-separated list of languages in MASK. */ | 222 |
400 static char * | 223 bool |
401 write_langs (unsigned int mask) | 224 target_handle_option (struct gcc_options *opts, |
402 { | 225 struct gcc_options *opts_set, |
403 unsigned int n = 0, len = 0; | 226 const struct cl_decoded_option *decoded, |
404 const char *lang_name; | 227 unsigned int lang_mask ATTRIBUTE_UNUSED, int kind, |
405 char *result; | 228 location_t loc ATTRIBUTE_UNUSED, |
406 | 229 const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED, |
407 for (n = 0; (lang_name = lang_names[n]) != 0; n++) | 230 diagnostic_context *dc) |
408 if (mask & (1U << n)) | 231 { |
409 len += strlen (lang_name) + 1; | 232 gcc_assert (opts == &global_options); |
410 | 233 gcc_assert (opts_set == &global_options_set); |
411 result = XNEWVEC (char, len); | 234 gcc_assert (dc == global_dc); |
412 len = 0; | 235 gcc_assert (decoded->canonical_option_num_elements <= 2); |
413 for (n = 0; (lang_name = lang_names[n]) != 0; n++) | 236 gcc_assert (kind == DK_UNSPECIFIED); |
414 if (mask & (1U << n)) | 237 /* Although the location is not passed down to |
415 { | 238 targetm.handle_option, do not make assertions about its value; |
416 if (len) | 239 options may come from optimize attributes and having the correct |
417 result[len++] = '/'; | 240 location in the handler is not generally important. */ |
418 strcpy (result + len, lang_name); | 241 return targetm.handle_option (decoded->opt_index, decoded->arg, |
419 len += strlen (lang_name); | 242 decoded->value); |
420 } | 243 } |
421 | 244 |
422 result[len] = 0; | 245 /* Add comma-separated strings to a char_p vector. */ |
423 | 246 |
424 return result; | |
425 } | |
426 | |
427 /* Complain that switch OPT_INDEX does not apply to this front end. */ | |
428 static void | 247 static void |
429 complain_wrong_lang (const char *text, const struct cl_option *option, | 248 add_comma_separated_to_vector (void **pvec, const char *arg) |
430 unsigned int lang_mask) | |
431 { | |
432 char *ok_langs, *bad_lang; | |
433 | |
434 /* The LTO front end inherits all the options from the first front | |
435 end that was used. However, not all the original front end | |
436 options make sense in LTO. | |
437 | |
438 A real solution would be to filter this in collect2, but collect2 | |
439 does not have access to all the option attributes to know what to | |
440 filter. So, in lto1 we silently accept inherited flags and do | |
441 nothing about it. */ | |
442 if (lang_mask & CL_LTO) | |
443 return; | |
444 | |
445 ok_langs = write_langs (option->flags); | |
446 bad_lang = write_langs (lang_mask); | |
447 | |
448 /* Eventually this should become a hard error IMO. */ | |
449 warning (0, "command line option \"%s\" is valid for %s but not for %s", | |
450 text, ok_langs, bad_lang); | |
451 | |
452 free (ok_langs); | |
453 free (bad_lang); | |
454 } | |
455 | |
456 /* Buffer the unknown option described by the string OPT. Currently, | |
457 we only complain about unknown -Wno-* options if they may have | |
458 prevented a diagnostic. Otherwise, we just ignore them. | |
459 Note that if we do complain, it is only as a warning, not an error; | |
460 passing the compiler an unrecognised -Wno-* option should never | |
461 change whether the compilation succeeds or fails. */ | |
462 | |
463 static void postpone_unknown_option_warning(const char *opt) | |
464 { | |
465 VEC_safe_push (const_char_p, heap, ignored_options, opt); | |
466 } | |
467 | |
468 /* Produce a warning for each option previously buffered. */ | |
469 | |
470 void print_ignored_options (void) | |
471 { | |
472 location_t saved_loc = input_location; | |
473 | |
474 input_location = 0; | |
475 | |
476 while (!VEC_empty (const_char_p, ignored_options)) | |
477 { | |
478 const char *opt; | |
479 opt = VEC_pop (const_char_p, ignored_options); | |
480 warning (0, "unrecognized command line option \"%s\"", opt); | |
481 } | |
482 | |
483 input_location = saved_loc; | |
484 } | |
485 | |
486 | |
487 /* Handle option OPT_INDEX, and argument ARG, for the language | |
488 indicated by LANG_MASK. VALUE is true, unless no- form of an -f or | |
489 -W option was given. KIND is the diagnostic_t if this is a | |
490 diagnostics option, DK_UNSPECIFIED otherwise. Returns false if the | |
491 switch was invalid. */ | |
492 bool | |
493 handle_option (int opt_index, int value, const char *arg, | |
494 unsigned int lang_mask, int kind) | |
495 { | |
496 const struct cl_option *option = &cl_options[opt_index]; | |
497 | |
498 if (option->flag_var) | |
499 set_option (opt_index, value, arg, kind); | |
500 | |
501 if (option->flags & lang_mask) | |
502 { | |
503 if (lang_hooks.handle_option (opt_index, arg, value, kind) == 0) | |
504 return false; | |
505 #ifdef ENABLE_LTO | |
506 else | |
507 lto_register_user_option (opt_index, arg, value, lang_mask); | |
508 #endif | |
509 } | |
510 | |
511 if (option->flags & CL_COMMON) | |
512 { | |
513 if (common_handle_option (opt_index, arg, value, lang_mask, kind) == 0) | |
514 return false; | |
515 #ifdef ENABLE_LTO | |
516 else | |
517 lto_register_user_option (opt_index, arg, value, CL_COMMON); | |
518 #endif | |
519 } | |
520 | |
521 if (option->flags & CL_TARGET) | |
522 { | |
523 if (!targetm.handle_option (opt_index, arg, value)) | |
524 return false; | |
525 #ifdef ENABLE_LTO | |
526 else | |
527 lto_register_user_option (opt_index, arg, value, CL_TARGET); | |
528 #endif | |
529 } | |
530 return true; | |
531 } | |
532 | |
533 /* Handle the switch beginning at ARGV for the language indicated by | |
534 LANG_MASK. Returns the number of switches consumed. */ | |
535 static unsigned int | |
536 read_cmdline_option (const char **argv, unsigned int lang_mask) | |
537 { | |
538 size_t opt_index; | |
539 const char *opt, *arg = 0; | |
540 char *dup = 0; | |
541 int value = 1; | |
542 unsigned int result = 0; | |
543 const struct cl_option *option; | |
544 | |
545 opt = argv[0]; | |
546 | |
547 opt_index = find_opt (opt + 1, lang_mask | CL_COMMON | CL_TARGET); | |
548 if (opt_index == cl_options_count | |
549 && (opt[1] == 'W' || opt[1] == 'f' || opt[1] == 'm') | |
550 && opt[2] == 'n' && opt[3] == 'o' && opt[4] == '-') | |
551 { | |
552 /* Drop the "no-" from negative switches. */ | |
553 size_t len = strlen (opt) - 3; | |
554 | |
555 dup = XNEWVEC (char, len + 1); | |
556 dup[0] = '-'; | |
557 dup[1] = opt[1]; | |
558 memcpy (dup + 2, opt + 5, len - 2 + 1); | |
559 opt = dup; | |
560 value = 0; | |
561 opt_index = find_opt (opt + 1, lang_mask | CL_COMMON | CL_TARGET); | |
562 if (opt_index == cl_options_count && opt[1] == 'W') | |
563 { | |
564 /* We don't generate warnings for unknown -Wno-* options | |
565 unless we issue diagnostics. */ | |
566 postpone_unknown_option_warning (argv[0]); | |
567 result = 1; | |
568 goto done; | |
569 } | |
570 } | |
571 | |
572 if (opt_index == cl_options_count) | |
573 goto done; | |
574 | |
575 option = &cl_options[opt_index]; | |
576 | |
577 /* Reject negative form of switches that don't take negatives as | |
578 unrecognized. */ | |
579 if (!value && (option->flags & CL_REJECT_NEGATIVE)) | |
580 goto done; | |
581 | |
582 /* We've recognized this switch. */ | |
583 result = 1; | |
584 | |
585 /* Check to see if the option is disabled for this configuration. */ | |
586 if (option->flags & CL_DISABLED) | |
587 { | |
588 error ("command line option %qs" | |
589 " is not supported by this configuration", opt); | |
590 goto done; | |
591 } | |
592 | |
593 /* Sort out any argument the switch takes. */ | |
594 if (option->flags & CL_JOINED) | |
595 { | |
596 /* Have arg point to the original switch. This is because | |
597 some code, such as disable_builtin_function, expects its | |
598 argument to be persistent until the program exits. */ | |
599 arg = argv[0] + cl_options[opt_index].opt_len + 1; | |
600 if (!value) | |
601 arg += strlen ("no-"); | |
602 | |
603 if (*arg == '\0' && !(option->flags & CL_MISSING_OK)) | |
604 { | |
605 if (option->flags & CL_SEPARATE) | |
606 { | |
607 arg = argv[1]; | |
608 result = 2; | |
609 } | |
610 else | |
611 /* Missing argument. */ | |
612 arg = NULL; | |
613 } | |
614 } | |
615 else if (option->flags & CL_SEPARATE) | |
616 { | |
617 arg = argv[1]; | |
618 result = 2; | |
619 } | |
620 | |
621 /* Now we've swallowed any potential argument, complain if this | |
622 is a switch for a different front end. */ | |
623 if (!(option->flags & (lang_mask | CL_COMMON | CL_TARGET))) | |
624 { | |
625 complain_wrong_lang (argv[0], option, lang_mask); | |
626 goto done; | |
627 } | |
628 else if ((option->flags & CL_TARGET) | |
629 && (option->flags & CL_LANG_ALL) | |
630 && !(option->flags & lang_mask)) | |
631 { | |
632 /* Complain for target flag language mismatches if any languages | |
633 are specified. */ | |
634 complain_wrong_lang (argv[0], option, lang_mask); | |
635 goto done; | |
636 } | |
637 | |
638 if (arg == NULL && (option->flags & (CL_JOINED | CL_SEPARATE))) | |
639 { | |
640 if (!lang_hooks.missing_argument (opt, opt_index)) | |
641 error ("missing argument to \"%s\"", opt); | |
642 goto done; | |
643 } | |
644 | |
645 /* If the switch takes an integer, convert it. */ | |
646 if (arg && (option->flags & CL_UINTEGER)) | |
647 { | |
648 value = integral_argument (arg); | |
649 if (value == -1) | |
650 { | |
651 error ("argument to \"%s\" should be a non-negative integer", | |
652 option->opt_text); | |
653 goto done; | |
654 } | |
655 } | |
656 | |
657 if (!handle_option (opt_index, value, arg, lang_mask, DK_UNSPECIFIED)) | |
658 result = 0; | |
659 | |
660 done: | |
661 if (dup) | |
662 free (dup); | |
663 return result; | |
664 } | |
665 | |
666 /* Handle FILENAME from the command line. */ | |
667 static void | |
668 add_input_filename (const char *filename) | |
669 { | |
670 num_in_fnames++; | |
671 in_fnames = XRESIZEVEC (const char *, in_fnames, num_in_fnames); | |
672 in_fnames[num_in_fnames - 1] = filename; | |
673 } | |
674 | |
675 /* Add comma-separated strings to a char_p vector. */ | |
676 | |
677 static void | |
678 add_comma_separated_to_vector (VEC(char_p,heap) **pvec, const char* arg) | |
679 { | 249 { |
680 char *tmp; | 250 char *tmp; |
681 char *r; | 251 char *r; |
682 char *w; | 252 char *w; |
683 char *token_start; | 253 char *token_start; |
254 VEC(char_p,heap) *vec = (VEC(char_p,heap) *) *pvec; | |
684 | 255 |
685 /* We never free this string. */ | 256 /* We never free this string. */ |
686 tmp = xstrdup (arg); | 257 tmp = xstrdup (arg); |
687 | 258 |
688 r = tmp; | 259 r = tmp; |
693 { | 264 { |
694 if (*r == ',') | 265 if (*r == ',') |
695 { | 266 { |
696 *w++ = '\0'; | 267 *w++ = '\0'; |
697 ++r; | 268 ++r; |
698 VEC_safe_push (char_p, heap, *pvec, token_start); | 269 VEC_safe_push (char_p, heap, vec, token_start); |
699 token_start = w; | 270 token_start = w; |
700 } | 271 } |
701 if (*r == '\\' && r[1] == ',') | 272 if (*r == '\\' && r[1] == ',') |
702 { | 273 { |
703 *w++ = ','; | 274 *w++ = ','; |
705 } | 276 } |
706 else | 277 else |
707 *w++ = *r++; | 278 *w++ = *r++; |
708 } | 279 } |
709 if (*token_start != '\0') | 280 if (*token_start != '\0') |
710 VEC_safe_push (char_p, heap, *pvec, token_start); | 281 VEC_safe_push (char_p, heap, vec, token_start); |
711 } | 282 |
712 | 283 *pvec = vec; |
713 /* Return whether we should exclude FNDECL from instrumentation. */ | 284 } |
714 | 285 |
715 bool | 286 /* Initialize OPTS and OPTS_SET before using them in parsing options. */ |
716 flag_instrument_functions_exclude_p (tree fndecl) | 287 |
717 { | 288 void |
718 if (VEC_length (char_p, flag_instrument_functions_exclude_functions) > 0) | 289 init_options_struct (struct gcc_options *opts, struct gcc_options *opts_set) |
719 { | 290 { |
720 const char *name; | 291 size_t num_params = get_num_compiler_params (); |
721 int i; | 292 |
722 char *s; | 293 *opts = global_options_init; |
723 | 294 memset (opts_set, 0, sizeof (*opts_set)); |
724 name = lang_hooks.decl_printable_name (fndecl, 0); | 295 |
725 for (i = 0; | 296 opts->x_param_values = XNEWVEC (int, num_params); |
726 VEC_iterate (char_p, flag_instrument_functions_exclude_functions, | 297 opts_set->x_param_values = XCNEWVEC (int, num_params); |
727 i, s); | 298 init_param_values (opts->x_param_values); |
728 ++i) | 299 |
729 { | 300 /* Use priority coloring if cover classes is not defined for the |
730 if (strstr (name, s) != NULL) | 301 target. */ |
731 return true; | 302 if (targetm.ira_cover_classes == NULL) |
732 } | 303 opts->x_flag_ira_algorithm = IRA_ALGORITHM_PRIORITY; |
733 } | 304 |
734 | 305 /* Initialize whether `char' is signed. */ |
735 if (VEC_length (char_p, flag_instrument_functions_exclude_files) > 0) | 306 opts->x_flag_signed_char = DEFAULT_SIGNED_CHAR; |
736 { | 307 /* Set this to a special "uninitialized" value. The actual default |
737 const char *name; | 308 is set after target options have been processed. */ |
738 int i; | 309 opts->x_flag_short_enums = 2; |
739 char *s; | 310 |
740 | 311 /* Initialize target_flags before targetm.target_option.optimization |
741 name = DECL_SOURCE_FILE (fndecl); | 312 so the latter can modify it. */ |
742 for (i = 0; | 313 opts->x_target_flags = targetm.default_target_flags; |
743 VEC_iterate (char_p, flag_instrument_functions_exclude_files, i, s); | 314 |
744 ++i) | 315 /* Some targets have ABI-specified unwind tables. */ |
745 { | 316 opts->x_flag_unwind_tables = targetm.unwind_tables_default; |
746 if (strstr (name, s) != NULL) | 317 |
747 return true; | 318 /* Some targets have other target-specific initialization. */ |
748 } | 319 targetm.target_option.init_struct (opts); |
749 } | 320 } |
750 | 321 |
751 return false; | 322 /* If indicated by the optimization level LEVEL (-Os if SIZE is set, |
752 } | 323 -Ofast if FAST is set), apply the option DEFAULT_OPT to OPTS and |
753 | 324 OPTS_SET, diagnostic context DC, location LOC, with language mask |
754 | 325 LANG_MASK and option handlers HANDLERS. */ |
755 /* Decode and handle the vector of command line options. LANG_MASK | 326 |
756 contains has a single bit set representing the current | |
757 language. */ | |
758 static void | 327 static void |
759 read_cmdline_options (unsigned int argc, const char **argv, unsigned int lang_mask) | 328 maybe_default_option (struct gcc_options *opts, |
760 { | 329 struct gcc_options *opts_set, |
761 unsigned int n, i; | 330 const struct default_options *default_opt, |
762 | 331 int level, bool size, bool fast, |
763 for (i = 1; i < argc; i += n) | 332 unsigned int lang_mask, |
764 { | 333 const struct cl_option_handlers *handlers, |
765 const char *opt = argv[i]; | 334 location_t loc, |
766 | 335 diagnostic_context *dc) |
767 /* Interpret "-" or a non-switch as a file name. */ | 336 { |
768 if (opt[0] != '-' || opt[1] == '\0') | 337 const struct cl_option *option = &cl_options[default_opt->opt_index]; |
769 { | 338 bool enabled; |
770 if (main_input_filename == NULL) | 339 |
771 { | 340 if (size) |
772 main_input_filename = opt; | 341 gcc_assert (level == 2); |
773 main_input_baselength | 342 if (fast) |
774 = base_of_path (main_input_filename, &main_input_basename); | 343 gcc_assert (level == 3); |
775 } | 344 |
776 add_input_filename (opt); | 345 switch (default_opt->levels) |
777 n = 1; | 346 { |
778 continue; | 347 case OPT_LEVELS_ALL: |
779 } | 348 enabled = true; |
780 | 349 break; |
781 n = read_cmdline_option (argv + i, lang_mask); | 350 |
782 | 351 case OPT_LEVELS_0_ONLY: |
783 if (!n) | 352 enabled = (level == 0); |
784 { | 353 break; |
785 n = 1; | 354 |
786 error ("unrecognized command line option \"%s\"", opt); | 355 case OPT_LEVELS_1_PLUS: |
787 } | 356 enabled = (level >= 1); |
788 } | 357 break; |
789 } | 358 |
790 | 359 case OPT_LEVELS_1_PLUS_SPEED_ONLY: |
791 /* Parse command line options and set default flag values. Do minimal | 360 enabled = (level >= 1 && !size); |
792 options processing. */ | 361 break; |
362 | |
363 case OPT_LEVELS_2_PLUS: | |
364 enabled = (level >= 2); | |
365 break; | |
366 | |
367 case OPT_LEVELS_2_PLUS_SPEED_ONLY: | |
368 enabled = (level >= 2 && !size); | |
369 break; | |
370 | |
371 case OPT_LEVELS_3_PLUS: | |
372 enabled = (level >= 3); | |
373 break; | |
374 | |
375 case OPT_LEVELS_3_PLUS_AND_SIZE: | |
376 enabled = (level >= 3 || size); | |
377 break; | |
378 | |
379 case OPT_LEVELS_SIZE: | |
380 enabled = size; | |
381 break; | |
382 | |
383 case OPT_LEVELS_FAST: | |
384 enabled = fast; | |
385 break; | |
386 | |
387 case OPT_LEVELS_NONE: | |
388 default: | |
389 gcc_unreachable (); | |
390 } | |
391 | |
392 if (enabled) | |
393 handle_generated_option (opts, opts_set, default_opt->opt_index, | |
394 default_opt->arg, default_opt->value, | |
395 lang_mask, DK_UNSPECIFIED, loc, | |
396 handlers, dc); | |
397 else if (default_opt->arg == NULL | |
398 && !(option->flags & CL_REJECT_NEGATIVE)) | |
399 handle_generated_option (opts, opts_set, default_opt->opt_index, | |
400 default_opt->arg, !default_opt->value, | |
401 lang_mask, DK_UNSPECIFIED, loc, | |
402 handlers, dc); | |
403 } | |
404 | |
405 /* As indicated by the optimization level LEVEL (-Os if SIZE is set, | |
406 -Ofast if FAST is set), apply the options in array DEFAULT_OPTS to | |
407 OPTS and OPTS_SET, diagnostic context DC, location LOC, with | |
408 language mask LANG_MASK and option handlers HANDLERS. */ | |
409 | |
410 static void | |
411 maybe_default_options (struct gcc_options *opts, | |
412 struct gcc_options *opts_set, | |
413 const struct default_options *default_opts, | |
414 int level, bool size, bool fast, | |
415 unsigned int lang_mask, | |
416 const struct cl_option_handlers *handlers, | |
417 location_t loc, | |
418 diagnostic_context *dc) | |
419 { | |
420 size_t i; | |
421 | |
422 for (i = 0; default_opts[i].levels != OPT_LEVELS_NONE; i++) | |
423 maybe_default_option (opts, opts_set, &default_opts[i], | |
424 level, size, fast, lang_mask, handlers, loc, dc); | |
425 } | |
426 | |
427 /* Table of options enabled by default at different levels. */ | |
428 | |
429 static const struct default_options default_options_table[] = | |
430 { | |
431 /* -O1 optimizations. */ | |
432 { OPT_LEVELS_1_PLUS, OPT_fdefer_pop, NULL, 1 }, | |
433 #ifdef DELAY_SLOTS | |
434 { OPT_LEVELS_1_PLUS, OPT_fdelayed_branch, NULL, 1 }, | |
435 #endif | |
436 { OPT_LEVELS_1_PLUS, OPT_fguess_branch_probability, NULL, 1 }, | |
437 { OPT_LEVELS_1_PLUS, OPT_fcprop_registers, NULL, 1 }, | |
438 { OPT_LEVELS_1_PLUS, OPT_fforward_propagate, NULL, 1 }, | |
439 { OPT_LEVELS_1_PLUS, OPT_fif_conversion, NULL, 1 }, | |
440 { OPT_LEVELS_1_PLUS, OPT_fif_conversion2, NULL, 1 }, | |
441 { OPT_LEVELS_1_PLUS, OPT_fipa_pure_const, NULL, 1 }, | |
442 { OPT_LEVELS_1_PLUS, OPT_fipa_reference, NULL, 1 }, | |
443 { OPT_LEVELS_1_PLUS, OPT_fipa_profile, NULL, 1 }, | |
444 { OPT_LEVELS_1_PLUS, OPT_fmerge_constants, NULL, 1 }, | |
445 { OPT_LEVELS_1_PLUS, OPT_fsplit_wide_types, NULL, 1 }, | |
446 { OPT_LEVELS_1_PLUS, OPT_ftree_ccp, NULL, 1 }, | |
447 { OPT_LEVELS_1_PLUS, OPT_ftree_bit_ccp, NULL, 1 }, | |
448 { OPT_LEVELS_1_PLUS, OPT_ftree_dce, NULL, 1 }, | |
449 { OPT_LEVELS_1_PLUS, OPT_ftree_dominator_opts, NULL, 1 }, | |
450 { OPT_LEVELS_1_PLUS, OPT_ftree_dse, NULL, 1 }, | |
451 { OPT_LEVELS_1_PLUS, OPT_ftree_ter, NULL, 1 }, | |
452 { OPT_LEVELS_1_PLUS, OPT_ftree_sra, NULL, 1 }, | |
453 { OPT_LEVELS_1_PLUS, OPT_ftree_copyrename, NULL, 1 }, | |
454 { OPT_LEVELS_1_PLUS, OPT_ftree_fre, NULL, 1 }, | |
455 { OPT_LEVELS_1_PLUS, OPT_ftree_copy_prop, NULL, 1 }, | |
456 { OPT_LEVELS_1_PLUS, OPT_ftree_sink, NULL, 1 }, | |
457 { OPT_LEVELS_1_PLUS, OPT_ftree_ch, NULL, 1 }, | |
458 { OPT_LEVELS_1_PLUS, OPT_fcombine_stack_adjustments, NULL, 1 }, | |
459 { OPT_LEVELS_1_PLUS, OPT_fcompare_elim, NULL, 1 }, | |
460 | |
461 /* -O2 optimizations. */ | |
462 { OPT_LEVELS_2_PLUS, OPT_finline_small_functions, NULL, 1 }, | |
463 { OPT_LEVELS_2_PLUS, OPT_findirect_inlining, NULL, 1 }, | |
464 { OPT_LEVELS_2_PLUS, OPT_fpartial_inlining, NULL, 1 }, | |
465 { OPT_LEVELS_2_PLUS, OPT_fthread_jumps, NULL, 1 }, | |
466 { OPT_LEVELS_2_PLUS, OPT_fcrossjumping, NULL, 1 }, | |
467 { OPT_LEVELS_2_PLUS, OPT_foptimize_sibling_calls, NULL, 1 }, | |
468 { OPT_LEVELS_2_PLUS, OPT_fcse_follow_jumps, NULL, 1 }, | |
469 { OPT_LEVELS_2_PLUS, OPT_fgcse, NULL, 1 }, | |
470 { OPT_LEVELS_2_PLUS, OPT_fexpensive_optimizations, NULL, 1 }, | |
471 { OPT_LEVELS_2_PLUS, OPT_frerun_cse_after_loop, NULL, 1 }, | |
472 { OPT_LEVELS_2_PLUS, OPT_fcaller_saves, NULL, 1 }, | |
473 { OPT_LEVELS_2_PLUS, OPT_fpeephole2, NULL, 1 }, | |
474 #ifdef INSN_SCHEDULING | |
475 /* Only run the pre-regalloc scheduling pass if optimizing for speed. */ | |
476 { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_fschedule_insns, NULL, 1 }, | |
477 { OPT_LEVELS_2_PLUS, OPT_fschedule_insns2, NULL, 1 }, | |
478 #endif | |
479 { OPT_LEVELS_2_PLUS, OPT_fregmove, NULL, 1 }, | |
480 { OPT_LEVELS_2_PLUS, OPT_fstrict_aliasing, NULL, 1 }, | |
481 { OPT_LEVELS_2_PLUS, OPT_fstrict_overflow, NULL, 1 }, | |
482 { OPT_LEVELS_2_PLUS, OPT_freorder_blocks, NULL, 1 }, | |
483 { OPT_LEVELS_2_PLUS, OPT_freorder_functions, NULL, 1 }, | |
484 { OPT_LEVELS_2_PLUS, OPT_ftree_vrp, NULL, 1 }, | |
485 { OPT_LEVELS_2_PLUS, OPT_ftree_builtin_call_dce, NULL, 1 }, | |
486 { OPT_LEVELS_2_PLUS, OPT_ftree_pre, NULL, 1 }, | |
487 { OPT_LEVELS_2_PLUS, OPT_ftree_switch_conversion, NULL, 1 }, | |
488 { OPT_LEVELS_2_PLUS, OPT_fipa_cp, NULL, 1 }, | |
489 { OPT_LEVELS_2_PLUS, OPT_fdevirtualize, NULL, 1 }, | |
490 { OPT_LEVELS_2_PLUS, OPT_fipa_sra, NULL, 1 }, | |
491 { OPT_LEVELS_2_PLUS, OPT_falign_loops, NULL, 1 }, | |
492 { OPT_LEVELS_2_PLUS, OPT_falign_jumps, NULL, 1 }, | |
493 { OPT_LEVELS_2_PLUS, OPT_falign_labels, NULL, 1 }, | |
494 { OPT_LEVELS_2_PLUS, OPT_falign_functions, NULL, 1 }, | |
495 | |
496 /* -O3 optimizations. */ | |
497 { OPT_LEVELS_3_PLUS, OPT_ftree_loop_distribute_patterns, NULL, 1 }, | |
498 { OPT_LEVELS_3_PLUS, OPT_fpredictive_commoning, NULL, 1 }, | |
499 /* Inlining of functions reducing size is a good idea with -Os | |
500 regardless of them being declared inline. */ | |
501 { OPT_LEVELS_3_PLUS_AND_SIZE, OPT_finline_functions, NULL, 1 }, | |
502 { OPT_LEVELS_3_PLUS, OPT_funswitch_loops, NULL, 1 }, | |
503 { OPT_LEVELS_3_PLUS, OPT_fgcse_after_reload, NULL, 1 }, | |
504 { OPT_LEVELS_3_PLUS, OPT_ftree_vectorize, NULL, 1 }, | |
505 { OPT_LEVELS_3_PLUS, OPT_fipa_cp_clone, NULL, 1 }, | |
506 | |
507 /* -Ofast adds optimizations to -O3. */ | |
508 { OPT_LEVELS_FAST, OPT_ffast_math, NULL, 1 }, | |
509 | |
510 { OPT_LEVELS_NONE, 0, NULL, 0 } | |
511 }; | |
512 | |
513 /* Default the options in OPTS and OPTS_SET based on the optimization | |
514 settings in DECODED_OPTIONS and DECODED_OPTIONS_COUNT. */ | |
793 void | 515 void |
794 decode_options (unsigned int argc, const char **argv) | 516 default_options_optimization (struct gcc_options *opts, |
795 { | 517 struct gcc_options *opts_set, |
796 static bool first_time_p = true; | 518 struct cl_decoded_option *decoded_options, |
797 static int initial_min_crossjump_insns; | 519 unsigned int decoded_options_count, |
798 static int initial_max_fields_for_field_sensitive; | 520 location_t loc, |
799 static int initial_loop_invariant_max_bbs_in_loop; | 521 unsigned int lang_mask, |
800 static unsigned int initial_lang_mask; | 522 const struct cl_option_handlers *handlers, |
801 | 523 diagnostic_context *dc) |
802 unsigned int i, lang_mask; | 524 { |
803 int opt1; | 525 unsigned int i; |
804 int opt2; | 526 int opt2; |
805 int opt3; | |
806 int opt1_max; | |
807 | |
808 if (first_time_p) | |
809 { | |
810 /* Perform language-specific options initialization. */ | |
811 initial_lang_mask = lang_mask = lang_hooks.init_options (argc, argv); | |
812 | |
813 lang_hooks.initialize_diagnostics (global_dc); | |
814 | |
815 /* Save initial values of parameters we reset. */ | |
816 initial_min_crossjump_insns | |
817 = compiler_params[PARAM_MIN_CROSSJUMP_INSNS].value; | |
818 initial_max_fields_for_field_sensitive | |
819 = compiler_params[PARAM_MAX_FIELDS_FOR_FIELD_SENSITIVE].value; | |
820 initial_loop_invariant_max_bbs_in_loop | |
821 = compiler_params[PARAM_LOOP_INVARIANT_MAX_BBS_IN_LOOP].value; | |
822 } | |
823 else | |
824 lang_mask = initial_lang_mask; | |
825 | 527 |
826 /* Scan to see what optimization level has been specified. That will | 528 /* Scan to see what optimization level has been specified. That will |
827 determine the default value of many flags. */ | 529 determine the default value of many flags. */ |
828 for (i = 1; i < argc; i++) | 530 for (i = 1; i < decoded_options_count; i++) |
829 { | 531 { |
830 if (!strcmp (argv[i], "-O")) | 532 struct cl_decoded_option *opt = &decoded_options[i]; |
533 switch (opt->opt_index) | |
831 { | 534 { |
832 optimize = 1; | 535 case OPT_O: |
833 optimize_size = 0; | 536 if (*opt->arg == '\0') |
834 } | |
835 else if (argv[i][0] == '-' && argv[i][1] == 'O') | |
836 { | |
837 /* Handle -Os, -O2, -O3, -O69, ... */ | |
838 const char *p = &argv[i][2]; | |
839 | |
840 if ((p[0] == 's') && (p[1] == 0)) | |
841 { | 537 { |
842 optimize_size = 1; | 538 opts->x_optimize = 1; |
843 | 539 opts->x_optimize_size = 0; |
844 /* Optimizing for size forces optimize to be 2. */ | 540 opts->x_optimize_fast = 0; |
845 optimize = 2; | |
846 } | 541 } |
847 else | 542 else |
848 { | 543 { |
849 const int optimize_val = read_integral_parameter (p, p - 2, -1); | 544 const int optimize_val = integral_argument (opt->arg); |
850 if (optimize_val != -1) | 545 if (optimize_val == -1) |
546 error_at (loc, | |
547 "argument to %qs should be a non-negative integer", | |
548 "-O"); | |
549 else | |
851 { | 550 { |
852 optimize = optimize_val; | 551 opts->x_optimize = optimize_val; |
853 if ((unsigned int) optimize > 255) | 552 if ((unsigned int) opts->x_optimize > 255) |
854 optimize = 255; | 553 opts->x_optimize = 255; |
855 optimize_size = 0; | 554 opts->x_optimize_size = 0; |
555 opts->x_optimize_fast = 0; | |
856 } | 556 } |
857 } | 557 } |
558 break; | |
559 | |
560 case OPT_Os: | |
561 opts->x_optimize_size = 1; | |
562 | |
563 /* Optimizing for size forces optimize to be 2. */ | |
564 opts->x_optimize = 2; | |
565 opts->x_optimize_fast = 0; | |
566 break; | |
567 | |
568 case OPT_Ofast: | |
569 /* -Ofast only adds flags to -O3. */ | |
570 opts->x_optimize_size = 0; | |
571 opts->x_optimize = 3; | |
572 opts->x_optimize_fast = 1; | |
573 break; | |
574 | |
575 default: | |
576 /* Ignore other options in this prescan. */ | |
577 break; | |
858 } | 578 } |
859 } | 579 } |
860 | 580 |
861 /* Use priority coloring if cover classes is not defined for the | 581 maybe_default_options (opts, opts_set, default_options_table, |
862 target. */ | 582 opts->x_optimize, opts->x_optimize_size, |
863 if (targetm.ira_cover_classes == NULL) | 583 opts->x_optimize_fast, lang_mask, handlers, loc, dc); |
864 flag_ira_algorithm = IRA_ALGORITHM_PRIORITY; | 584 |
865 | 585 /* -O2 param settings. */ |
866 /* -O1 optimizations. */ | 586 opt2 = (opts->x_optimize >= 2); |
867 opt1 = (optimize >= 1); | |
868 flag_defer_pop = opt1; | |
869 #ifdef DELAY_SLOTS | |
870 flag_delayed_branch = opt1; | |
871 #endif | |
872 #ifdef CAN_DEBUG_WITHOUT_FP | |
873 flag_omit_frame_pointer = opt1; | |
874 #endif | |
875 flag_guess_branch_prob = opt1; | |
876 flag_cprop_registers = opt1; | |
877 flag_forward_propagate = opt1; | |
878 flag_if_conversion = opt1; | |
879 flag_if_conversion2 = opt1; | |
880 flag_ipa_pure_const = opt1; | |
881 flag_ipa_reference = opt1; | |
882 flag_ipa_profile = opt1; | |
883 flag_merge_constants = opt1; | |
884 flag_split_wide_types = opt1; | |
885 flag_tree_ccp = opt1; | |
886 flag_tree_dce = opt1; | |
887 flag_tree_dom = opt1; | |
888 flag_tree_dse = opt1; | |
889 flag_tree_ter = opt1; | |
890 flag_tree_sra = opt1; | |
891 flag_tree_copyrename = opt1; | |
892 flag_tree_fre = opt1; | |
893 flag_tree_copy_prop = opt1; | |
894 flag_tree_sink = opt1; | |
895 flag_tree_ch = opt1; | |
896 | |
897 /* -O2 optimizations. */ | |
898 opt2 = (optimize >= 2); | |
899 flag_inline_small_functions = opt2; | |
900 flag_indirect_inlining = opt2; | |
901 flag_thread_jumps = opt2; | |
902 flag_crossjumping = opt2; | |
903 flag_optimize_sibling_calls = opt2; | |
904 flag_cse_follow_jumps = opt2; | |
905 flag_gcse = opt2; | |
906 flag_expensive_optimizations = opt2; | |
907 flag_rerun_cse_after_loop = opt2; | |
908 flag_caller_saves = opt2; | |
909 flag_peephole2 = opt2; | |
910 #ifdef INSN_SCHEDULING | |
911 /* Only run the pre-regalloc scheduling pass if optimizing for speed. */ | |
912 flag_schedule_insns = opt2 && ! optimize_size; | |
913 flag_schedule_insns_after_reload = opt2; | |
914 #endif | |
915 flag_regmove = opt2; | |
916 flag_strict_aliasing = opt2; | |
917 flag_strict_overflow = opt2; | |
918 flag_reorder_blocks = opt2; | |
919 flag_reorder_functions = opt2; | |
920 flag_tree_vrp = opt2; | |
921 flag_tree_builtin_call_dce = opt2; | |
922 flag_tree_pre = opt2; | |
923 flag_tree_switch_conversion = opt2; | |
924 flag_ipa_cp = opt2; | |
925 flag_ipa_sra = opt2; | |
926 | 587 |
927 /* Track fields in field-sensitive alias analysis. */ | 588 /* Track fields in field-sensitive alias analysis. */ |
928 set_param_value ("max-fields-for-field-sensitive", | 589 maybe_set_param_value |
929 (opt2) ? 100 : initial_max_fields_for_field_sensitive); | 590 (PARAM_MAX_FIELDS_FOR_FIELD_SENSITIVE, |
591 opt2 ? 100 : default_param_value (PARAM_MAX_FIELDS_FOR_FIELD_SENSITIVE), | |
592 opts->x_param_values, opts_set->x_param_values); | |
930 | 593 |
931 /* For -O1 only do loop invariant motion for very small loops. */ | 594 /* For -O1 only do loop invariant motion for very small loops. */ |
932 set_param_value ("loop-invariant-max-bbs-in-loop", | 595 maybe_set_param_value |
933 (opt2) ? initial_loop_invariant_max_bbs_in_loop : 1000); | 596 (PARAM_LOOP_INVARIANT_MAX_BBS_IN_LOOP, |
934 | 597 opt2 ? default_param_value (PARAM_LOOP_INVARIANT_MAX_BBS_IN_LOOP) : 1000, |
935 /* -O3 optimizations. */ | 598 opts->x_param_values, opts_set->x_param_values); |
936 opt3 = (optimize >= 3); | 599 |
937 flag_predictive_commoning = opt3; | 600 if (opts->x_optimize_size) |
938 flag_inline_functions = opt3; | 601 /* We want to crossjump as much as possible. */ |
939 flag_unswitch_loops = opt3; | 602 maybe_set_param_value (PARAM_MIN_CROSSJUMP_INSNS, 1, |
940 flag_gcse_after_reload = opt3; | 603 opts->x_param_values, opts_set->x_param_values); |
941 flag_tree_vectorize = opt3; | |
942 flag_ipa_cp_clone = opt3; | |
943 if (flag_ipa_cp_clone) | |
944 flag_ipa_cp = 1; | |
945 | |
946 /* Just -O1/-O0 optimizations. */ | |
947 opt1_max = (optimize <= 1); | |
948 align_loops = opt1_max; | |
949 align_jumps = opt1_max; | |
950 align_labels = opt1_max; | |
951 align_functions = opt1_max; | |
952 | |
953 if (optimize_size) | |
954 { | |
955 /* Inlining of functions reducing size is a good idea regardless of them | |
956 being declared inline. */ | |
957 flag_inline_functions = 1; | |
958 | |
959 /* Basic optimization options. */ | |
960 optimize_size = 1; | |
961 if (optimize > 2) | |
962 optimize = 2; | |
963 | |
964 /* We want to crossjump as much as possible. */ | |
965 set_param_value ("min-crossjump-insns", 1); | |
966 } | |
967 else | 604 else |
968 set_param_value ("min-crossjump-insns", initial_min_crossjump_insns); | 605 maybe_set_param_value (PARAM_MIN_CROSSJUMP_INSNS, |
969 | 606 default_param_value (PARAM_MIN_CROSSJUMP_INSNS), |
970 /* Enable -Werror=coverage-mismatch by default */ | 607 opts->x_param_values, opts_set->x_param_values); |
971 enable_warning_as_error("coverage-mismatch", 1, lang_mask); | 608 |
972 | |
973 if (first_time_p) | |
974 { | |
975 /* Initialize whether `char' is signed. */ | |
976 flag_signed_char = DEFAULT_SIGNED_CHAR; | |
977 /* Set this to a special "uninitialized" value. The actual default is | |
978 set after target options have been processed. */ | |
979 flag_short_enums = 2; | |
980 | |
981 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can | |
982 modify it. */ | |
983 target_flags = targetm.default_target_flags; | |
984 | |
985 /* Some targets have ABI-specified unwind tables. */ | |
986 flag_unwind_tables = targetm.unwind_tables_default; | |
987 } | |
988 | |
989 #ifdef ENABLE_LTO | |
990 /* Clear any options currently held for LTO. */ | |
991 lto_clear_user_options (); | |
992 #endif | |
993 | |
994 #ifdef OPTIMIZATION_OPTIONS | |
995 /* Allow default optimizations to be specified on a per-machine basis. */ | 609 /* Allow default optimizations to be specified on a per-machine basis. */ |
996 OPTIMIZATION_OPTIONS (optimize, optimize_size); | 610 maybe_default_options (opts, opts_set, |
997 #endif | 611 targetm.target_option.optimization_table, |
998 | 612 opts->x_optimize, opts->x_optimize_size, |
999 read_cmdline_options (argc, argv, lang_mask); | 613 opts->x_optimize_fast, lang_mask, handlers, loc, dc); |
1000 | 614 } |
1001 if (dump_base_name && ! IS_ABSOLUTE_PATH (dump_base_name)) | 615 |
1002 { | 616 /* After all options at LOC have been read into OPTS and OPTS_SET, |
1003 /* First try to make DUMP_BASE_NAME relative to the DUMP_DIR_NAME | 617 finalize settings of those options and diagnose incompatible |
1004 directory. Then try to make DUMP_BASE_NAME relative to the | 618 combinations. */ |
1005 AUX_BASE_NAME directory, typically the directory to contain | 619 void |
1006 the object file. */ | 620 finish_options (struct gcc_options *opts, struct gcc_options *opts_set, |
1007 if (dump_dir_name) | 621 location_t loc) |
1008 dump_base_name = concat (dump_dir_name, dump_base_name, NULL); | 622 { |
1009 else if (aux_base_name) | 623 enum unwind_info_type ui_except; |
624 | |
625 if (opts->x_dump_base_name && ! IS_ABSOLUTE_PATH (opts->x_dump_base_name)) | |
626 { | |
627 /* First try to make OPTS->X_DUMP_BASE_NAME relative to the | |
628 OPTS->X_DUMP_DIR_NAME directory. Then try to make | |
629 OPTS->X_DUMP_BASE_NAME relative to the OPTS->X_AUX_BASE_NAME | |
630 directory, typically the directory to contain the object | |
631 file. */ | |
632 if (opts->x_dump_dir_name) | |
633 opts->x_dump_base_name = concat (opts->x_dump_dir_name, | |
634 opts->x_dump_base_name, NULL); | |
635 else if (opts->x_aux_base_name | |
636 && strcmp (opts->x_aux_base_name, HOST_BIT_BUCKET) != 0) | |
1010 { | 637 { |
1011 const char *aux_base; | 638 const char *aux_base; |
1012 | 639 |
1013 base_of_path (aux_base_name, &aux_base); | 640 base_of_path (opts->x_aux_base_name, &aux_base); |
1014 if (aux_base_name != aux_base) | 641 if (opts->x_aux_base_name != aux_base) |
1015 { | 642 { |
1016 int dir_len = aux_base - aux_base_name; | 643 int dir_len = aux_base - opts->x_aux_base_name; |
1017 char *new_dump_base_name = | 644 char *new_dump_base_name = |
1018 XNEWVEC (char, strlen(dump_base_name) + dir_len + 1); | 645 XNEWVEC (char, strlen (opts->x_dump_base_name) + dir_len + 1); |
1019 | 646 |
1020 /* Copy directory component from AUX_BASE_NAME. */ | 647 /* Copy directory component from OPTS->X_AUX_BASE_NAME. */ |
1021 memcpy (new_dump_base_name, aux_base_name, dir_len); | 648 memcpy (new_dump_base_name, opts->x_aux_base_name, dir_len); |
1022 /* Append existing DUMP_BASE_NAME. */ | 649 /* Append existing OPTS->X_DUMP_BASE_NAME. */ |
1023 strcpy (new_dump_base_name + dir_len, dump_base_name); | 650 strcpy (new_dump_base_name + dir_len, opts->x_dump_base_name); |
1024 dump_base_name = new_dump_base_name; | 651 opts->x_dump_base_name = new_dump_base_name; |
1025 } | 652 } |
1026 } | 653 } |
1027 } | 654 } |
1028 | 655 |
1029 /* Handle related options for unit-at-a-time, toplevel-reorder, and | 656 /* Handle related options for unit-at-a-time, toplevel-reorder, and |
1030 section-anchors. */ | 657 section-anchors. */ |
1031 if (!flag_unit_at_a_time) | 658 if (!opts->x_flag_unit_at_a_time) |
1032 { | 659 { |
1033 if (flag_section_anchors == 1) | 660 if (opts->x_flag_section_anchors && opts_set->x_flag_section_anchors) |
1034 error ("Section anchors must be disabled when unit-at-a-time " | 661 error_at (loc, "section anchors must be disabled when unit-at-a-time " |
1035 "is disabled."); | 662 "is disabled"); |
1036 flag_section_anchors = 0; | 663 opts->x_flag_section_anchors = 0; |
1037 if (flag_toplevel_reorder == 1) | 664 if (opts->x_flag_toplevel_reorder == 1) |
1038 error ("Toplevel reorder must be disabled when unit-at-a-time " | 665 error_at (loc, "toplevel reorder must be disabled when unit-at-a-time " |
1039 "is disabled."); | 666 "is disabled"); |
1040 flag_toplevel_reorder = 0; | 667 opts->x_flag_toplevel_reorder = 0; |
1041 } | 668 } |
669 | |
670 /* -Wmissing-noreturn is alias for -Wsuggest-attribute=noreturn. */ | |
671 if (opts->x_warn_missing_noreturn) | |
672 opts->x_warn_suggest_attribute_noreturn = true; | |
673 | |
1042 /* Unless the user has asked for section anchors, we disable toplevel | 674 /* Unless the user has asked for section anchors, we disable toplevel |
1043 reordering at -O0 to disable transformations that might be surprising | 675 reordering at -O0 to disable transformations that might be surprising |
1044 to end users and to get -fno-toplevel-reorder tested. */ | 676 to end users and to get -fno-toplevel-reorder tested. */ |
1045 if (!optimize && flag_toplevel_reorder == 2 && flag_section_anchors != 1) | 677 if (!opts->x_optimize |
1046 { | 678 && opts->x_flag_toplevel_reorder == 2 |
1047 flag_toplevel_reorder = 0; | 679 && !(opts->x_flag_section_anchors && opts_set->x_flag_section_anchors)) |
1048 flag_section_anchors = 0; | 680 { |
1049 } | 681 opts->x_flag_toplevel_reorder = 0; |
1050 if (!flag_toplevel_reorder) | 682 opts->x_flag_section_anchors = 0; |
1051 { | 683 } |
1052 if (flag_section_anchors == 1) | 684 if (!opts->x_flag_toplevel_reorder) |
1053 error ("section anchors must be disabled when toplevel reorder" | 685 { |
1054 " is disabled"); | 686 if (opts->x_flag_section_anchors && opts_set->x_flag_section_anchors) |
1055 flag_section_anchors = 0; | 687 error_at (loc, "section anchors must be disabled when toplevel reorder" |
1056 } | 688 " is disabled"); |
1057 | 689 opts->x_flag_section_anchors = 0; |
1058 if (first_time_p) | 690 } |
1059 { | 691 |
1060 if (flag_pie) | 692 if (!opts->x_flag_opts_finished) |
1061 flag_pic = flag_pie; | 693 { |
1062 if (flag_pic && !flag_pie) | 694 if (opts->x_flag_pie) |
1063 flag_shlib = 1; | 695 opts->x_flag_pic = opts->x_flag_pie; |
1064 first_time_p = false; | 696 if (opts->x_flag_pic && !opts->x_flag_pie) |
1065 } | 697 opts->x_flag_shlib = 1; |
1066 | 698 opts->x_flag_opts_finished = true; |
1067 if (optimize == 0) | 699 } |
700 | |
701 if (opts->x_optimize == 0) | |
1068 { | 702 { |
1069 /* Inlining does not work if not optimizing, | 703 /* Inlining does not work if not optimizing, |
1070 so force it not to be done. */ | 704 so force it not to be done. */ |
1071 warn_inline = 0; | 705 opts->x_warn_inline = 0; |
1072 flag_no_inline = 1; | 706 opts->x_flag_no_inline = 1; |
1073 } | 707 } |
1074 | 708 |
1075 /* The optimization to partition hot and cold basic blocks into separate | 709 /* The optimization to partition hot and cold basic blocks into separate |
1076 sections of the .o and executable files does not work (currently) | 710 sections of the .o and executable files does not work (currently) |
1077 with exception handling. This is because there is no support for | 711 with exception handling. This is because there is no support for |
1078 generating unwind info. If flag_exceptions is turned on we need to | 712 generating unwind info. If opts->x_flag_exceptions is turned on |
1079 turn off the partitioning optimization. */ | 713 we need to turn off the partitioning optimization. */ |
1080 | 714 |
1081 if (flag_exceptions && flag_reorder_blocks_and_partition | 715 ui_except = targetm.except_unwind_info (opts); |
1082 && (USING_SJLJ_EXCEPTIONS | 716 |
1083 #ifdef TARGET_UNWIND_INFO | 717 if (opts->x_flag_exceptions |
1084 || 1 | 718 && opts->x_flag_reorder_blocks_and_partition |
1085 #endif | 719 && (ui_except == UI_SJLJ || ui_except == UI_TARGET)) |
1086 )) | 720 { |
1087 { | 721 inform (loc, |
1088 inform (input_location, | 722 "-freorder-blocks-and-partition does not work " |
1089 "-freorder-blocks-and-partition does not work with exceptions on this architecture"); | 723 "with exceptions on this architecture"); |
1090 flag_reorder_blocks_and_partition = 0; | 724 opts->x_flag_reorder_blocks_and_partition = 0; |
1091 flag_reorder_blocks = 1; | 725 opts->x_flag_reorder_blocks = 1; |
1092 } | 726 } |
1093 | 727 |
1094 /* If user requested unwind info, then turn off the partitioning | 728 /* If user requested unwind info, then turn off the partitioning |
1095 optimization. */ | 729 optimization. */ |
1096 | 730 |
1097 if (flag_unwind_tables && ! targetm.unwind_tables_default | 731 if (opts->x_flag_unwind_tables |
1098 && flag_reorder_blocks_and_partition | 732 && !targetm.unwind_tables_default |
1099 && (USING_SJLJ_EXCEPTIONS | 733 && opts->x_flag_reorder_blocks_and_partition |
1100 #ifdef TARGET_UNWIND_INFO | 734 && (ui_except == UI_SJLJ || ui_except == UI_TARGET)) |
1101 || 1 | 735 { |
1102 #endif | 736 inform (loc, |
1103 )) | 737 "-freorder-blocks-and-partition does not support " |
1104 { | 738 "unwind info on this architecture"); |
1105 inform (input_location, | 739 opts->x_flag_reorder_blocks_and_partition = 0; |
1106 "-freorder-blocks-and-partition does not support unwind info on this architecture"); | 740 opts->x_flag_reorder_blocks = 1; |
1107 flag_reorder_blocks_and_partition = 0; | |
1108 flag_reorder_blocks = 1; | |
1109 } | 741 } |
1110 | 742 |
1111 /* If the target requested unwind info, then turn off the partitioning | 743 /* If the target requested unwind info, then turn off the partitioning |
1112 optimization with a different message. Likewise, if the target does not | 744 optimization with a different message. Likewise, if the target does not |
1113 support named sections. */ | 745 support named sections. */ |
1114 | 746 |
1115 if (flag_reorder_blocks_and_partition | 747 if (opts->x_flag_reorder_blocks_and_partition |
1116 && (!targetm.have_named_sections | 748 && (!targetm.have_named_sections |
1117 || (flag_unwind_tables && targetm.unwind_tables_default | 749 || (opts->x_flag_unwind_tables |
1118 && (USING_SJLJ_EXCEPTIONS | 750 && targetm.unwind_tables_default |
1119 #ifdef TARGET_UNWIND_INFO | 751 && (ui_except == UI_SJLJ || ui_except == UI_TARGET)))) |
1120 || 1 | 752 { |
1121 #endif | 753 inform (loc, |
1122 )))) | 754 "-freorder-blocks-and-partition does not work " |
1123 { | 755 "on this architecture"); |
1124 inform (input_location, | 756 opts->x_flag_reorder_blocks_and_partition = 0; |
1125 "-freorder-blocks-and-partition does not work on this architecture"); | 757 opts->x_flag_reorder_blocks = 1; |
1126 flag_reorder_blocks_and_partition = 0; | 758 } |
1127 flag_reorder_blocks = 1; | 759 |
1128 } | 760 if (opts->x_flag_reorder_blocks_and_partition |
761 && !opts_set->x_flag_reorder_functions) | |
762 opts->x_flag_reorder_functions = 1; | |
1129 | 763 |
1130 /* Pipelining of outer loops is only possible when general pipelining | 764 /* Pipelining of outer loops is only possible when general pipelining |
1131 capabilities are requested. */ | 765 capabilities are requested. */ |
1132 if (!flag_sel_sched_pipelining) | 766 if (!opts->x_flag_sel_sched_pipelining) |
1133 flag_sel_sched_pipelining_outer_loops = 0; | 767 opts->x_flag_sel_sched_pipelining_outer_loops = 0; |
1134 | 768 |
1135 if (!targetm.ira_cover_classes | 769 if (!targetm.ira_cover_classes |
1136 && flag_ira_algorithm == IRA_ALGORITHM_CB) | 770 && opts->x_flag_ira_algorithm == IRA_ALGORITHM_CB) |
1137 { | 771 { |
1138 inform (input_location, | 772 inform (loc, |
1139 "-fira-algorithm=CB does not work on this architecture"); | 773 "-fira-algorithm=CB does not work on this architecture"); |
1140 flag_ira_algorithm = IRA_ALGORITHM_PRIORITY; | 774 opts->x_flag_ira_algorithm = IRA_ALGORITHM_PRIORITY; |
1141 } | 775 } |
1142 | 776 |
1143 if (flag_conserve_stack) | 777 if (opts->x_flag_conserve_stack) |
1144 { | 778 { |
1145 if (!PARAM_SET_P (PARAM_LARGE_STACK_FRAME)) | 779 maybe_set_param_value (PARAM_LARGE_STACK_FRAME, 100, |
1146 PARAM_VALUE (PARAM_LARGE_STACK_FRAME) = 100; | 780 opts->x_param_values, opts_set->x_param_values); |
1147 if (!PARAM_SET_P (PARAM_STACK_FRAME_GROWTH)) | 781 maybe_set_param_value (PARAM_STACK_FRAME_GROWTH, 40, |
1148 PARAM_VALUE (PARAM_STACK_FRAME_GROWTH) = 40; | 782 opts->x_param_values, opts_set->x_param_values); |
1149 } | 783 } |
1150 if (flag_wpa || flag_ltrans) | 784 if (opts->x_flag_wpa || opts->x_flag_ltrans) |
1151 { | 785 { |
1152 /* These passes are not WHOPR compatible yet. */ | 786 /* These passes are not WHOPR compatible yet. */ |
1153 flag_ipa_pta = 0; | 787 opts->x_flag_ipa_pta = 0; |
1154 flag_ipa_struct_reorg = 0; | 788 opts->x_flag_ipa_struct_reorg = 0; |
1155 } | 789 } |
1156 | 790 |
1157 if (flag_lto || flag_whopr) | 791 if (opts->x_flag_lto) |
1158 { | 792 { |
1159 #ifdef ENABLE_LTO | 793 #ifdef ENABLE_LTO |
1160 flag_generate_lto = 1; | 794 opts->x_flag_generate_lto = 1; |
1161 | 795 |
1162 /* When generating IL, do not operate in whole-program mode. | 796 /* When generating IL, do not operate in whole-program mode. |
1163 Otherwise, symbols will be privatized too early, causing link | 797 Otherwise, symbols will be privatized too early, causing link |
1164 errors later. */ | 798 errors later. */ |
1165 flag_whole_program = 0; | 799 opts->x_flag_whole_program = 0; |
1166 #else | 800 #else |
1167 error ("LTO support has not been enabled in this configuration"); | 801 error_at (loc, "LTO support has not been enabled in this configuration"); |
1168 #endif | 802 #endif |
1169 } | 803 } |
1170 | 804 if ((opts->x_flag_lto_partition_balanced != 0) + (opts->x_flag_lto_partition_1to1 != 0) |
1171 /* Reconcile -flto and -fwhopr. Set additional flags as appropriate and | 805 + (opts->x_flag_lto_partition_none != 0) >= 1) |
1172 check option consistency. */ | 806 { |
1173 if (flag_lto && flag_whopr) | 807 if ((opts->x_flag_lto_partition_balanced != 0) |
1174 error ("-flto and -fwhopr are mutually exclusive"); | 808 + (opts->x_flag_lto_partition_1to1 != 0) |
809 + (opts->x_flag_lto_partition_none != 0) > 1) | |
810 error_at (loc, "only one -flto-partition value can be specified"); | |
811 } | |
812 | |
813 /* We initialize opts->x_flag_split_stack to -1 so that targets can set a | |
814 default value if they choose based on other options. */ | |
815 if (opts->x_flag_split_stack == -1) | |
816 opts->x_flag_split_stack = 0; | |
817 else if (opts->x_flag_split_stack) | |
818 { | |
819 if (!targetm.supports_split_stack (true, opts)) | |
820 { | |
821 error_at (loc, "%<-fsplit-stack%> is not supported by " | |
822 "this compiler configuration"); | |
823 opts->x_flag_split_stack = 0; | |
824 } | |
825 } | |
1175 } | 826 } |
1176 | 827 |
1177 #define LEFT_COLUMN 27 | 828 #define LEFT_COLUMN 27 |
1178 | 829 |
1179 /* Output ITEM, of length ITEM_WIDTH, in the left column, | 830 /* Output ITEM, of length ITEM_WIDTH, in the left column, |
1226 /* Print help for a specific front-end, etc. */ | 877 /* Print help for a specific front-end, etc. */ |
1227 static void | 878 static void |
1228 print_filtered_help (unsigned int include_flags, | 879 print_filtered_help (unsigned int include_flags, |
1229 unsigned int exclude_flags, | 880 unsigned int exclude_flags, |
1230 unsigned int any_flags, | 881 unsigned int any_flags, |
1231 unsigned int columns) | 882 unsigned int columns, |
883 struct gcc_options *opts, | |
884 unsigned int lang_mask) | |
1232 { | 885 { |
1233 unsigned int i; | 886 unsigned int i; |
1234 const char *help; | 887 const char *help; |
1235 static char *printed = NULL; | |
1236 bool found = false; | 888 bool found = false; |
1237 bool displayed = false; | 889 bool displayed = false; |
1238 | 890 |
1239 if (include_flags == CL_PARAMS) | 891 if (include_flags == CL_PARAMS) |
1240 { | 892 { |
1257 } | 909 } |
1258 putchar ('\n'); | 910 putchar ('\n'); |
1259 return; | 911 return; |
1260 } | 912 } |
1261 | 913 |
1262 if (!printed) | 914 if (!opts->x_help_printed) |
1263 printed = XCNEWVAR (char, cl_options_count); | 915 opts->x_help_printed = XCNEWVAR (char, cl_options_count); |
916 | |
917 if (!opts->x_help_enum_printed) | |
918 opts->x_help_enum_printed = XCNEWVAR (char, cl_enums_count); | |
1264 | 919 |
1265 for (i = 0; i < cl_options_count; i++) | 920 for (i = 0; i < cl_options_count; i++) |
1266 { | 921 { |
1267 static char new_help[128]; | 922 char new_help[128]; |
1268 const struct cl_option *option = cl_options + i; | 923 const struct cl_option *option = cl_options + i; |
1269 unsigned int len; | 924 unsigned int len; |
1270 const char *opt; | 925 const char *opt; |
1271 const char *tab; | 926 const char *tab; |
1272 | 927 |
1279 | 934 |
1280 /* Skip unwanted switches. */ | 935 /* Skip unwanted switches. */ |
1281 if ((option->flags & exclude_flags) != 0) | 936 if ((option->flags & exclude_flags) != 0) |
1282 continue; | 937 continue; |
1283 | 938 |
939 /* The driver currently prints its own help text. */ | |
940 if ((option->flags & CL_DRIVER) != 0 | |
941 && (option->flags & (((1U << cl_lang_count) - 1) | |
942 | CL_COMMON | CL_TARGET)) == 0) | |
943 continue; | |
944 | |
1284 found = true; | 945 found = true; |
1285 /* Skip switches that have already been printed. */ | 946 /* Skip switches that have already been printed. */ |
1286 if (printed[i]) | 947 if (opts->x_help_printed[i]) |
1287 continue; | 948 continue; |
1288 | 949 |
1289 printed[i] = true; | 950 opts->x_help_printed[i] = true; |
1290 | 951 |
1291 help = option->help; | 952 help = option->help; |
1292 if (help == NULL) | 953 if (help == NULL) |
1293 { | 954 { |
1294 if (exclude_flags & CL_UNDOCUMENTED) | 955 if (exclude_flags & CL_UNDOCUMENTED) |
1316 | 977 |
1317 /* With the -Q option enabled we change the descriptive text associated | 978 /* With the -Q option enabled we change the descriptive text associated |
1318 with an option to be an indication of its current setting. */ | 979 with an option to be an indication of its current setting. */ |
1319 if (!quiet_flag) | 980 if (!quiet_flag) |
1320 { | 981 { |
982 void *flag_var = option_flag_var (i, opts); | |
983 | |
1321 if (len < (LEFT_COLUMN + 2)) | 984 if (len < (LEFT_COLUMN + 2)) |
1322 strcpy (new_help, "\t\t"); | 985 strcpy (new_help, "\t\t"); |
1323 else | 986 else |
1324 strcpy (new_help, "\t"); | 987 strcpy (new_help, "\t"); |
1325 | 988 |
1326 if (option->flag_var != NULL) | 989 if (flag_var != NULL |
990 && option->var_type != CLVC_DEFER) | |
1327 { | 991 { |
1328 if (option->flags & CL_JOINED) | 992 if (option->flags & CL_JOINED) |
1329 { | 993 { |
1330 if (option->var_type == CLVC_STRING) | 994 if (option->var_type == CLVC_STRING) |
1331 { | 995 { |
1332 if (* (const char **) option->flag_var != NULL) | 996 if (* (const char **) flag_var != NULL) |
1333 snprintf (new_help + strlen (new_help), | 997 snprintf (new_help + strlen (new_help), |
1334 sizeof (new_help) - strlen (new_help), | 998 sizeof (new_help) - strlen (new_help), |
1335 * (const char **) option->flag_var); | 999 * (const char **) flag_var); |
1000 } | |
1001 else if (option->var_type == CLVC_ENUM) | |
1002 { | |
1003 const struct cl_enum *e = &cl_enums[option->var_enum]; | |
1004 int value; | |
1005 const char *arg = NULL; | |
1006 | |
1007 value = e->get (flag_var); | |
1008 enum_value_to_arg (e->values, &arg, value, lang_mask); | |
1009 if (arg == NULL) | |
1010 arg = _("[default]"); | |
1011 snprintf (new_help + strlen (new_help), | |
1012 sizeof (new_help) - strlen (new_help), | |
1013 arg); | |
1336 } | 1014 } |
1337 else | 1015 else |
1338 sprintf (new_help + strlen (new_help), | 1016 sprintf (new_help + strlen (new_help), |
1339 "%#x", * (int *) option->flag_var); | 1017 "%#x", * (int *) flag_var); |
1340 } | 1018 } |
1341 else | 1019 else |
1342 strcat (new_help, option_enabled (i) | 1020 strcat (new_help, option_enabled (i, opts) |
1343 ? _("[enabled]") : _("[disabled]")); | 1021 ? _("[enabled]") : _("[disabled]")); |
1344 } | 1022 } |
1345 | 1023 |
1346 help = new_help; | 1024 help = new_help; |
1347 } | 1025 } |
1348 | 1026 |
1349 wrap_help (help, opt, len, columns); | 1027 wrap_help (help, opt, len, columns); |
1350 displayed = true; | 1028 displayed = true; |
1029 | |
1030 if (option->var_type == CLVC_ENUM | |
1031 && opts->x_help_enum_printed[option->var_enum] != 2) | |
1032 opts->x_help_enum_printed[option->var_enum] = 1; | |
1351 } | 1033 } |
1352 | 1034 |
1353 if (! found) | 1035 if (! found) |
1354 { | 1036 { |
1355 unsigned int langs = include_flags & CL_LANG_ALL; | 1037 unsigned int langs = include_flags & CL_LANG_ALL; |
1371 } | 1053 } |
1372 else if (! displayed) | 1054 else if (! displayed) |
1373 printf (_(" All options with the desired characteristics have already been displayed\n")); | 1055 printf (_(" All options with the desired characteristics have already been displayed\n")); |
1374 | 1056 |
1375 putchar ('\n'); | 1057 putchar ('\n'); |
1058 | |
1059 /* Print details of enumerated option arguments, if those | |
1060 enumerations have help text headings provided. If no help text | |
1061 is provided, presume that the possible values are listed in the | |
1062 help text for the relevant options. */ | |
1063 for (i = 0; i < cl_enums_count; i++) | |
1064 { | |
1065 unsigned int j, pos; | |
1066 | |
1067 if (opts->x_help_enum_printed[i] != 1) | |
1068 continue; | |
1069 if (cl_enums[i].help == NULL) | |
1070 continue; | |
1071 printf (" %s\n ", _(cl_enums[i].help)); | |
1072 pos = 4; | |
1073 for (j = 0; cl_enums[i].values[j].arg != NULL; j++) | |
1074 { | |
1075 unsigned int len = strlen (cl_enums[i].values[j].arg); | |
1076 | |
1077 if (pos > 4 && pos + 1 + len <= columns) | |
1078 { | |
1079 printf (" %s", cl_enums[i].values[j].arg); | |
1080 pos += 1 + len; | |
1081 } | |
1082 else | |
1083 { | |
1084 if (pos > 4) | |
1085 { | |
1086 printf ("\n "); | |
1087 pos = 4; | |
1088 } | |
1089 printf ("%s", cl_enums[i].values[j].arg); | |
1090 pos += len; | |
1091 } | |
1092 } | |
1093 printf ("\n\n"); | |
1094 opts->x_help_enum_printed[i] = 2; | |
1095 } | |
1376 } | 1096 } |
1377 | 1097 |
1378 /* Display help for a specified type of option. | 1098 /* Display help for a specified type of option. |
1379 The options must have ALL of the INCLUDE_FLAGS set | 1099 The options must have ALL of the INCLUDE_FLAGS set |
1380 ANY of the flags in the ANY_FLAGS set | 1100 ANY of the flags in the ANY_FLAGS set |
1381 and NONE of the EXCLUDE_FLAGS set. */ | 1101 and NONE of the EXCLUDE_FLAGS set. The current option state is in |
1102 OPTS; LANG_MASK is used for interpreting enumerated option state. */ | |
1382 static void | 1103 static void |
1383 print_specific_help (unsigned int include_flags, | 1104 print_specific_help (unsigned int include_flags, |
1384 unsigned int exclude_flags, | 1105 unsigned int exclude_flags, |
1385 unsigned int any_flags) | 1106 unsigned int any_flags, |
1107 struct gcc_options *opts, | |
1108 unsigned int lang_mask) | |
1386 { | 1109 { |
1387 unsigned int all_langs_mask = (1U << cl_lang_count) - 1; | 1110 unsigned int all_langs_mask = (1U << cl_lang_count) - 1; |
1388 const char * description = NULL; | 1111 const char * description = NULL; |
1389 const char * descrip_extra = ""; | 1112 const char * descrip_extra = ""; |
1390 size_t i; | 1113 size_t i; |
1391 unsigned int flag; | 1114 unsigned int flag; |
1392 static unsigned int columns = 0; | |
1393 | 1115 |
1394 /* Sanity check: Make sure that we do not have more | 1116 /* Sanity check: Make sure that we do not have more |
1395 languages than we have bits available to enumerate them. */ | 1117 languages than we have bits available to enumerate them. */ |
1396 gcc_assert ((1U << cl_lang_count) < CL_MIN_OPTION_CLASS); | 1118 gcc_assert ((1U << cl_lang_count) < CL_MIN_OPTION_CLASS); |
1397 | 1119 |
1398 /* If we have not done so already, obtain | 1120 /* If we have not done so already, obtain |
1399 the desired maximum width of the output. */ | 1121 the desired maximum width of the output. */ |
1400 if (columns == 0) | 1122 if (opts->x_help_columns == 0) |
1401 { | 1123 { |
1402 const char *p; | 1124 const char *p; |
1403 | 1125 |
1404 GET_ENVIRONMENT (p, "COLUMNS"); | 1126 p = getenv ("COLUMNS"); |
1405 if (p != NULL) | 1127 if (p != NULL) |
1406 { | 1128 { |
1407 int value = atoi (p); | 1129 int value = atoi (p); |
1408 | 1130 |
1409 if (value > 0) | 1131 if (value > 0) |
1410 columns = value; | 1132 opts->x_help_columns = value; |
1411 } | 1133 } |
1412 | 1134 |
1413 if (columns == 0) | 1135 if (opts->x_help_columns == 0) |
1414 /* Use a reasonable default. */ | 1136 /* Use a reasonable default. */ |
1415 columns = 80; | 1137 opts->x_help_columns = 80; |
1416 } | 1138 } |
1417 | 1139 |
1418 /* Decide upon the title for the options that we are going to display. */ | 1140 /* Decide upon the title for the options that we are going to display. */ |
1419 for (i = 0, flag = 1; flag <= CL_MAX_OPTION_CLASS; flag <<= 1, i ++) | 1141 for (i = 0, flag = 1; flag <= CL_MAX_OPTION_CLASS; flag <<= 1, i ++) |
1420 { | 1142 { |
1421 switch (flag & include_flags) | 1143 switch (flag & include_flags) |
1422 { | 1144 { |
1423 case 0: | 1145 case 0: |
1146 case CL_DRIVER: | |
1424 break; | 1147 break; |
1425 | 1148 |
1426 case CL_TARGET: | 1149 case CL_TARGET: |
1427 description = _("The following options are target specific"); | 1150 description = _("The following options are target specific"); |
1428 break; | 1151 break; |
1475 description = _("The following options are language-independent"); | 1198 description = _("The following options are language-independent"); |
1476 } | 1199 } |
1477 } | 1200 } |
1478 | 1201 |
1479 printf ("%s%s:\n", description, descrip_extra); | 1202 printf ("%s%s:\n", description, descrip_extra); |
1480 print_filtered_help (include_flags, exclude_flags, any_flags, columns); | 1203 print_filtered_help (include_flags, exclude_flags, any_flags, |
1204 opts->x_help_columns, opts, lang_mask); | |
1481 } | 1205 } |
1482 | 1206 |
1483 /* Handle target- and language-independent options. Return zero to | 1207 /* Handle target- and language-independent options. Return zero to |
1484 generate an "unknown option" message. Only options that need | 1208 generate an "unknown option" message. Only options that need |
1485 extra handling need to be listed here; if you simply want | 1209 extra handling need to be listed here; if you simply want |
1486 VALUE assigned to a variable, it happens automatically. */ | 1210 DECODED->value assigned to a variable, it happens automatically. */ |
1487 | 1211 |
1488 static int | 1212 bool |
1489 common_handle_option (size_t scode, const char *arg, int value, | 1213 common_handle_option (struct gcc_options *opts, |
1490 unsigned int lang_mask, int kind ATTRIBUTE_UNUSED) | 1214 struct gcc_options *opts_set, |
1491 { | 1215 const struct cl_decoded_option *decoded, |
1492 static bool verbose = false; | 1216 unsigned int lang_mask, int kind ATTRIBUTE_UNUSED, |
1217 location_t loc, | |
1218 const struct cl_option_handlers *handlers, | |
1219 diagnostic_context *dc) | |
1220 { | |
1221 size_t scode = decoded->opt_index; | |
1222 const char *arg = decoded->arg; | |
1223 int value = decoded->value; | |
1493 enum opt_code code = (enum opt_code) scode; | 1224 enum opt_code code = (enum opt_code) scode; |
1494 | 1225 |
1226 gcc_assert (decoded->canonical_option_num_elements <= 2); | |
1227 | |
1495 switch (code) | 1228 switch (code) |
1496 { | 1229 { |
1497 case OPT__param: | 1230 case OPT__param: |
1498 handle_param (arg); | 1231 handle_param (opts, opts_set, loc, arg); |
1499 break; | 1232 break; |
1500 | 1233 |
1501 case OPT_v: | |
1502 verbose = true; | |
1503 break; | |
1504 | |
1505 case OPT_fhelp: | |
1506 case OPT__help: | 1234 case OPT__help: |
1507 { | 1235 { |
1508 unsigned int all_langs_mask = (1U << cl_lang_count) - 1; | 1236 unsigned int all_langs_mask = (1U << cl_lang_count) - 1; |
1509 unsigned int undoc_mask; | 1237 unsigned int undoc_mask; |
1510 unsigned int i; | 1238 unsigned int i; |
1511 | 1239 |
1512 undoc_mask = (verbose | extra_warnings) ? 0 : CL_UNDOCUMENTED; | 1240 undoc_mask = ((opts->x_verbose_flag | opts->x_extra_warnings) |
1241 ? 0 | |
1242 : CL_UNDOCUMENTED); | |
1513 /* First display any single language specific options. */ | 1243 /* First display any single language specific options. */ |
1514 for (i = 0; i < cl_lang_count; i++) | 1244 for (i = 0; i < cl_lang_count; i++) |
1515 print_specific_help | 1245 print_specific_help |
1516 (1U << i, (all_langs_mask & (~ (1U << i))) | undoc_mask, 0); | 1246 (1U << i, (all_langs_mask & (~ (1U << i))) | undoc_mask, 0, opts, |
1247 lang_mask); | |
1517 /* Next display any multi language specific options. */ | 1248 /* Next display any multi language specific options. */ |
1518 print_specific_help (0, undoc_mask, all_langs_mask); | 1249 print_specific_help (0, undoc_mask, all_langs_mask, opts, lang_mask); |
1519 /* Then display any remaining, non-language options. */ | 1250 /* Then display any remaining, non-language options. */ |
1520 for (i = CL_MIN_OPTION_CLASS; i <= CL_MAX_OPTION_CLASS; i <<= 1) | 1251 for (i = CL_MIN_OPTION_CLASS; i <= CL_MAX_OPTION_CLASS; i <<= 1) |
1521 print_specific_help (i, undoc_mask, 0); | 1252 if (i != CL_DRIVER) |
1522 exit_after_options = true; | 1253 print_specific_help (i, undoc_mask, 0, opts, lang_mask); |
1254 opts->x_exit_after_options = true; | |
1523 break; | 1255 break; |
1524 } | 1256 } |
1525 | 1257 |
1526 case OPT_ftarget_help: | |
1527 case OPT__target_help: | 1258 case OPT__target_help: |
1528 print_specific_help (CL_TARGET, CL_UNDOCUMENTED, 0); | 1259 print_specific_help (CL_TARGET, CL_UNDOCUMENTED, 0, opts, lang_mask); |
1529 exit_after_options = true; | 1260 opts->x_exit_after_options = true; |
1530 | 1261 |
1531 /* Allow the target a chance to give the user some additional information. */ | 1262 /* Allow the target a chance to give the user some additional information. */ |
1532 if (targetm.target_help) | 1263 if (targetm.help) |
1533 targetm.target_help (); | 1264 targetm.help (); |
1534 break; | 1265 break; |
1535 | 1266 |
1536 case OPT_fhelp_: | |
1537 case OPT__help_: | 1267 case OPT__help_: |
1538 { | 1268 { |
1539 const char * a = arg; | 1269 const char * a = arg; |
1540 unsigned int include_flags = 0; | 1270 unsigned int include_flags = 0; |
1541 /* Note - by default we include undocumented options when listing | 1271 /* Note - by default we include undocumented options when listing |
1550 arg = [^]{word}[,{arg}] | 1280 arg = [^]{word}[,{arg}] |
1551 word = {optimizers|target|warnings|undocumented| | 1281 word = {optimizers|target|warnings|undocumented| |
1552 params|common|<language>} */ | 1282 params|common|<language>} */ |
1553 while (* a != 0) | 1283 while (* a != 0) |
1554 { | 1284 { |
1555 static struct | 1285 static const struct |
1556 { | 1286 { |
1557 const char * string; | 1287 const char * string; |
1558 unsigned int flag; | 1288 unsigned int flag; |
1559 } | 1289 } |
1560 specifics[] = | 1290 specifics[] = |
1627 specified "--help=c", but otherwise we have to issue | 1357 specified "--help=c", but otherwise we have to issue |
1628 a warning. */ | 1358 a warning. */ |
1629 if (strncasecmp (a, "c", len) == 0) | 1359 if (strncasecmp (a, "c", len) == 0) |
1630 * pflags |= lang_flag; | 1360 * pflags |= lang_flag; |
1631 else | 1361 else |
1632 fnotice (stderr, | 1362 warning_at (loc, 0, |
1633 "warning: --help argument %.*s is ambiguous, please be more specific\n", | 1363 "--help argument %q.*s is ambiguous, " |
1634 len, a); | 1364 "please be more specific", |
1365 len, a); | |
1635 } | 1366 } |
1636 } | 1367 } |
1637 else if (lang_flag != 0) | 1368 else if (lang_flag != 0) |
1638 * pflags |= lang_flag; | 1369 * pflags |= lang_flag; |
1639 else | 1370 else |
1640 fnotice (stderr, | 1371 warning_at (loc, 0, |
1641 "warning: unrecognized argument to --help= option: %.*s\n", | 1372 "unrecognized argument to --help= option: %q.*s", |
1642 len, a); | 1373 len, a); |
1643 | 1374 |
1644 if (comma == NULL) | 1375 if (comma == NULL) |
1645 break; | 1376 break; |
1646 a = comma + 1; | 1377 a = comma + 1; |
1647 } | 1378 } |
1648 | 1379 |
1649 if (include_flags) | 1380 if (include_flags) |
1650 print_specific_help (include_flags, exclude_flags, 0); | 1381 print_specific_help (include_flags, exclude_flags, 0, opts, |
1651 exit_after_options = true; | 1382 lang_mask); |
1383 opts->x_exit_after_options = true; | |
1652 break; | 1384 break; |
1653 } | 1385 } |
1654 | 1386 |
1655 case OPT_fversion: | |
1656 case OPT__version: | 1387 case OPT__version: |
1657 exit_after_options = true; | 1388 opts->x_exit_after_options = true; |
1658 break; | |
1659 | |
1660 case OPT_G: | |
1661 g_switch_value = value; | |
1662 g_switch_set = true; | |
1663 break; | 1389 break; |
1664 | 1390 |
1665 case OPT_O: | 1391 case OPT_O: |
1666 case OPT_Os: | 1392 case OPT_Os: |
1393 case OPT_Ofast: | |
1667 /* Currently handled in a prescan. */ | 1394 /* Currently handled in a prescan. */ |
1668 break; | 1395 break; |
1669 | 1396 |
1670 case OPT_Werror_: | 1397 case OPT_Werror_: |
1671 enable_warning_as_error (arg, value, lang_mask); | 1398 enable_warning_as_error (arg, value, lang_mask, handlers, |
1399 opts, opts_set, loc, dc); | |
1672 break; | 1400 break; |
1673 | 1401 |
1674 case OPT_Wlarger_than_: | 1402 case OPT_Wlarger_than_: |
1675 /* This form corresponds to -Wlarger-than-. | 1403 opts->x_larger_than_size = value; |
1676 Kept for backward compatibility. | 1404 opts->x_warn_larger_than = value != -1; |
1677 Don't use it as the first argument of warning(). */ | 1405 break; |
1678 | 1406 |
1679 case OPT_Wlarger_than_eq: | 1407 case OPT_Wfatal_errors: |
1680 larger_than_size = value; | 1408 dc->fatal_errors = value; |
1681 warn_larger_than = value != -1; | |
1682 break; | 1409 break; |
1683 | 1410 |
1684 case OPT_Wframe_larger_than_: | 1411 case OPT_Wframe_larger_than_: |
1685 frame_larger_than_size = value; | 1412 opts->x_frame_larger_than_size = value; |
1686 warn_frame_larger_than = value != -1; | 1413 opts->x_warn_frame_larger_than = value != -1; |
1687 break; | 1414 break; |
1688 | 1415 |
1689 case OPT_Wstrict_aliasing: | 1416 case OPT_Wstrict_aliasing: |
1690 set_Wstrict_aliasing (value); | 1417 set_Wstrict_aliasing (opts, value); |
1691 break; | |
1692 | |
1693 case OPT_Wstrict_aliasing_: | |
1694 warn_strict_aliasing = value; | |
1695 break; | 1418 break; |
1696 | 1419 |
1697 case OPT_Wstrict_overflow: | 1420 case OPT_Wstrict_overflow: |
1698 warn_strict_overflow = (value | 1421 opts->x_warn_strict_overflow = (value |
1699 ? (int) WARN_STRICT_OVERFLOW_CONDITIONAL | 1422 ? (int) WARN_STRICT_OVERFLOW_CONDITIONAL |
1700 : 0); | 1423 : 0); |
1701 break; | 1424 break; |
1702 | 1425 |
1703 case OPT_Wstrict_overflow_: | 1426 case OPT_Wsystem_headers: |
1704 warn_strict_overflow = value; | 1427 dc->dc_warn_system_headers = value; |
1705 break; | |
1706 | |
1707 case OPT_Wunused: | |
1708 warn_unused = value; | |
1709 break; | 1428 break; |
1710 | 1429 |
1711 case OPT_aux_info: | 1430 case OPT_aux_info: |
1712 case OPT_aux_info_: | 1431 opts->x_flag_gen_aux_info = 1; |
1713 aux_info_file_name = arg; | |
1714 flag_gen_aux_info = 1; | |
1715 break; | |
1716 | |
1717 case OPT_auxbase: | |
1718 aux_base_name = arg; | |
1719 break; | 1432 break; |
1720 | 1433 |
1721 case OPT_auxbase_strip: | 1434 case OPT_auxbase_strip: |
1722 { | 1435 { |
1723 char *tmp = xstrdup (arg); | 1436 char *tmp = xstrdup (arg); |
1724 strip_off_ending (tmp, strlen (tmp)); | 1437 strip_off_ending (tmp, strlen (tmp)); |
1725 if (tmp[0]) | 1438 if (tmp[0]) |
1726 aux_base_name = tmp; | 1439 opts->x_aux_base_name = tmp; |
1727 } | 1440 } |
1728 break; | 1441 break; |
1729 | 1442 |
1730 case OPT_d: | 1443 case OPT_d: |
1731 decode_d_option (arg); | 1444 decode_d_option (arg, opts, loc, dc); |
1732 break; | |
1733 | |
1734 case OPT_dumpbase: | |
1735 dump_base_name = arg; | |
1736 break; | |
1737 | |
1738 case OPT_dumpdir: | |
1739 dump_dir_name = arg; | |
1740 break; | |
1741 | |
1742 case OPT_falign_functions_: | |
1743 align_functions = value; | |
1744 break; | |
1745 | |
1746 case OPT_falign_jumps_: | |
1747 align_jumps = value; | |
1748 break; | |
1749 | |
1750 case OPT_falign_labels_: | |
1751 align_labels = value; | |
1752 break; | |
1753 | |
1754 case OPT_falign_loops_: | |
1755 align_loops = value; | |
1756 break; | |
1757 | |
1758 case OPT_fbranch_probabilities: | |
1759 flag_branch_probabilities_set = true; | |
1760 break; | 1445 break; |
1761 | 1446 |
1762 case OPT_fcall_used_: | 1447 case OPT_fcall_used_: |
1763 fix_register (arg, 0, 1); | |
1764 break; | |
1765 | |
1766 case OPT_fcall_saved_: | 1448 case OPT_fcall_saved_: |
1767 fix_register (arg, 0, 0); | 1449 /* Deferred. */ |
1768 break; | 1450 break; |
1769 | 1451 |
1770 case OPT_fdbg_cnt_: | 1452 case OPT_fdbg_cnt_: |
1771 dbg_cnt_process_opt (arg); | |
1772 break; | |
1773 | |
1774 case OPT_fdbg_cnt_list: | 1453 case OPT_fdbg_cnt_list: |
1775 dbg_cnt_list_all_counters (); | 1454 /* Deferred. */ |
1776 break; | 1455 break; |
1777 | 1456 |
1778 case OPT_fdebug_prefix_map_: | 1457 case OPT_fdebug_prefix_map_: |
1779 add_debug_prefix_map (arg); | 1458 /* Deferred. */ |
1780 break; | 1459 break; |
1781 | 1460 |
1782 case OPT_fdiagnostics_show_location_: | 1461 case OPT_fdiagnostics_show_location_: |
1783 if (!strcmp (arg, "once")) | 1462 diagnostic_prefixing_rule (dc) = (diagnostic_prefixing_rule_t) value; |
1784 diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_ONCE; | |
1785 else if (!strcmp (arg, "every-line")) | |
1786 diagnostic_prefixing_rule (global_dc) | |
1787 = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE; | |
1788 else | |
1789 return 0; | |
1790 break; | 1463 break; |
1791 | 1464 |
1792 case OPT_fdiagnostics_show_option: | 1465 case OPT_fdiagnostics_show_option: |
1793 global_dc->show_option_requested = value; | 1466 dc->show_option_requested = value; |
1794 break; | 1467 break; |
1795 | 1468 |
1796 case OPT_fdump_: | 1469 case OPT_fdump_: |
1797 if (!dump_switch_p (arg)) | 1470 /* Deferred. */ |
1798 return 0; | |
1799 break; | |
1800 | |
1801 case OPT_fexcess_precision_: | |
1802 if (!strcmp (arg, "fast")) | |
1803 flag_excess_precision_cmdline = EXCESS_PRECISION_FAST; | |
1804 else if (!strcmp (arg, "standard")) | |
1805 flag_excess_precision_cmdline = EXCESS_PRECISION_STANDARD; | |
1806 else | |
1807 error ("unknown excess precision style \"%s\"", arg); | |
1808 break; | 1471 break; |
1809 | 1472 |
1810 case OPT_ffast_math: | 1473 case OPT_ffast_math: |
1811 set_fast_math_flags (value); | 1474 set_fast_math_flags (opts, value); |
1812 break; | 1475 break; |
1813 | 1476 |
1814 case OPT_funsafe_math_optimizations: | 1477 case OPT_funsafe_math_optimizations: |
1815 set_unsafe_math_optimizations_flags (value); | 1478 set_unsafe_math_optimizations_flags (opts, value); |
1816 break; | 1479 break; |
1817 | 1480 |
1818 case OPT_ffixed_: | 1481 case OPT_ffixed_: |
1819 fix_register (arg, 1, 1); | 1482 /* Deferred. */ |
1820 break; | 1483 break; |
1821 | 1484 |
1822 case OPT_finline_limit_: | 1485 case OPT_finline_limit_: |
1823 case OPT_finline_limit_eq: | 1486 set_param_value ("max-inline-insns-single", value / 2, |
1824 set_param_value ("max-inline-insns-single", value / 2); | 1487 opts->x_param_values, opts_set->x_param_values); |
1825 set_param_value ("max-inline-insns-auto", value / 2); | 1488 set_param_value ("max-inline-insns-auto", value / 2, |
1489 opts->x_param_values, opts_set->x_param_values); | |
1826 break; | 1490 break; |
1827 | 1491 |
1828 case OPT_finstrument_functions_exclude_function_list_: | 1492 case OPT_finstrument_functions_exclude_function_list_: |
1829 add_comma_separated_to_vector | 1493 add_comma_separated_to_vector |
1830 (&flag_instrument_functions_exclude_functions, arg); | 1494 (&opts->x_flag_instrument_functions_exclude_functions, arg); |
1831 break; | 1495 break; |
1832 | 1496 |
1833 case OPT_finstrument_functions_exclude_file_list_: | 1497 case OPT_finstrument_functions_exclude_file_list_: |
1834 add_comma_separated_to_vector | 1498 add_comma_separated_to_vector |
1835 (&flag_instrument_functions_exclude_files, arg); | 1499 (&opts->x_flag_instrument_functions_exclude_files, arg); |
1836 break; | 1500 break; |
1837 | 1501 |
1838 case OPT_fmessage_length_: | 1502 case OPT_fmessage_length_: |
1839 pp_set_line_maximum_length (global_dc->printer, value); | 1503 pp_set_line_maximum_length (dc->printer, value); |
1840 break; | 1504 break; |
1841 | 1505 |
1842 case OPT_fpack_struct_: | 1506 case OPT_fpack_struct_: |
1843 if (value <= 0 || (value & (value - 1)) || value > 16) | 1507 if (value <= 0 || (value & (value - 1)) || value > 16) |
1844 error ("structure alignment must be a small power of two, not %d", value); | 1508 error_at (loc, |
1509 "structure alignment must be a small power of two, not %d", | |
1510 value); | |
1845 else | 1511 else |
1846 { | 1512 opts->x_initial_max_fld_align = value; |
1847 initial_max_fld_align = value; | |
1848 maximum_field_alignment = value * BITS_PER_UNIT; | |
1849 } | |
1850 break; | |
1851 | |
1852 case OPT_fpeel_loops: | |
1853 flag_peel_loops_set = true; | |
1854 break; | 1513 break; |
1855 | 1514 |
1856 case OPT_fplugin_: | 1515 case OPT_fplugin_: |
1857 #ifdef ENABLE_PLUGIN | |
1858 add_new_plugin (arg); | |
1859 #else | |
1860 error ("Plugin support is disabled. Configure with --enable-plugin."); | |
1861 #endif | |
1862 break; | |
1863 | |
1864 case OPT_fplugin_arg_: | 1516 case OPT_fplugin_arg_: |
1865 #ifdef ENABLE_PLUGIN | 1517 /* Deferred. */ |
1866 parse_plugin_arg_opt (arg); | |
1867 #else | |
1868 error ("Plugin support is disabled. Configure with --enable-plugin."); | |
1869 #endif | |
1870 break; | |
1871 | |
1872 case OPT_fprofile_arcs: | |
1873 profile_arc_flag_set = true; | |
1874 break; | |
1875 | |
1876 case OPT_finline_functions: | |
1877 flag_inline_functions_set = true; | |
1878 break; | |
1879 | |
1880 case OPT_fprofile_dir_: | |
1881 profile_data_prefix = xstrdup (arg); | |
1882 break; | 1518 break; |
1883 | 1519 |
1884 case OPT_fprofile_use_: | 1520 case OPT_fprofile_use_: |
1885 profile_data_prefix = xstrdup (arg); | 1521 opts->x_profile_data_prefix = xstrdup (arg); |
1886 flag_profile_use = true; | 1522 opts->x_flag_profile_use = true; |
1887 value = true; | 1523 value = true; |
1888 /* No break here - do -fprofile-use processing. */ | 1524 /* No break here - do -fprofile-use processing. */ |
1889 case OPT_fprofile_use: | 1525 case OPT_fprofile_use: |
1890 if (!flag_branch_probabilities_set) | 1526 if (!opts_set->x_flag_branch_probabilities) |
1891 flag_branch_probabilities = value; | 1527 opts->x_flag_branch_probabilities = value; |
1892 if (!flag_profile_values_set) | 1528 if (!opts_set->x_flag_profile_values) |
1893 flag_profile_values = value; | 1529 opts->x_flag_profile_values = value; |
1894 if (!flag_unroll_loops_set) | 1530 if (!opts_set->x_flag_unroll_loops) |
1895 flag_unroll_loops = value; | 1531 opts->x_flag_unroll_loops = value; |
1896 if (!flag_peel_loops_set) | 1532 if (!opts_set->x_flag_peel_loops) |
1897 flag_peel_loops = value; | 1533 opts->x_flag_peel_loops = value; |
1898 if (!flag_tracer_set) | 1534 if (!opts_set->x_flag_tracer) |
1899 flag_tracer = value; | 1535 opts->x_flag_tracer = value; |
1900 if (!flag_value_profile_transformations_set) | 1536 if (!opts_set->x_flag_value_profile_transformations) |
1901 flag_value_profile_transformations = value; | 1537 opts->x_flag_value_profile_transformations = value; |
1902 if (!flag_inline_functions_set) | 1538 if (!opts_set->x_flag_inline_functions) |
1903 flag_inline_functions = value; | 1539 opts->x_flag_inline_functions = value; |
1904 if (!flag_ipa_cp_set) | 1540 if (!opts_set->x_flag_ipa_cp) |
1905 flag_ipa_cp = value; | 1541 opts->x_flag_ipa_cp = value; |
1906 if (!flag_ipa_cp_clone_set | 1542 if (!opts_set->x_flag_ipa_cp_clone |
1907 && value && flag_ipa_cp) | 1543 && value && opts->x_flag_ipa_cp) |
1908 flag_ipa_cp_clone = value; | 1544 opts->x_flag_ipa_cp_clone = value; |
1909 if (!flag_predictive_commoning_set) | 1545 if (!opts_set->x_flag_predictive_commoning) |
1910 flag_predictive_commoning = value; | 1546 opts->x_flag_predictive_commoning = value; |
1911 if (!flag_unswitch_loops_set) | 1547 if (!opts_set->x_flag_unswitch_loops) |
1912 flag_unswitch_loops = value; | 1548 opts->x_flag_unswitch_loops = value; |
1913 if (!flag_gcse_after_reload_set) | 1549 if (!opts_set->x_flag_gcse_after_reload) |
1914 flag_gcse_after_reload = value; | 1550 opts->x_flag_gcse_after_reload = value; |
1915 break; | 1551 break; |
1916 | 1552 |
1917 case OPT_fprofile_generate_: | 1553 case OPT_fprofile_generate_: |
1918 profile_data_prefix = xstrdup (arg); | 1554 opts->x_profile_data_prefix = xstrdup (arg); |
1919 value = true; | 1555 value = true; |
1920 /* No break here - do -fprofile-generate processing. */ | 1556 /* No break here - do -fprofile-generate processing. */ |
1921 case OPT_fprofile_generate: | 1557 case OPT_fprofile_generate: |
1922 if (!profile_arc_flag_set) | 1558 if (!opts_set->x_profile_arc_flag) |
1923 profile_arc_flag = value; | 1559 opts->x_profile_arc_flag = value; |
1924 if (!flag_profile_values_set) | 1560 if (!opts_set->x_flag_profile_values) |
1925 flag_profile_values = value; | 1561 opts->x_flag_profile_values = value; |
1926 if (!flag_value_profile_transformations_set) | 1562 if (!opts_set->x_flag_value_profile_transformations) |
1927 flag_value_profile_transformations = value; | 1563 opts->x_flag_value_profile_transformations = value; |
1928 if (!flag_inline_functions_set) | 1564 if (!opts_set->x_flag_inline_functions) |
1929 flag_inline_functions = value; | 1565 opts->x_flag_inline_functions = value; |
1930 break; | 1566 /* FIXME: Instrumentation we insert makes ipa-reference bitmaps |
1931 | 1567 quadratic. Disable the pass until better memory representation |
1932 case OPT_fprofile_values: | 1568 is done. */ |
1933 flag_profile_values_set = true; | 1569 if (!opts_set->x_flag_ipa_reference && in_lto_p) |
1934 break; | 1570 opts->x_flag_ipa_reference = false; |
1935 | 1571 break; |
1936 case OPT_fvisibility_: | 1572 |
1937 { | 1573 case OPT_fshow_column: |
1938 if (!strcmp(arg, "default")) | 1574 dc->show_column = value; |
1939 default_visibility = VISIBILITY_DEFAULT; | |
1940 else if (!strcmp(arg, "internal")) | |
1941 default_visibility = VISIBILITY_INTERNAL; | |
1942 else if (!strcmp(arg, "hidden")) | |
1943 default_visibility = VISIBILITY_HIDDEN; | |
1944 else if (!strcmp(arg, "protected")) | |
1945 default_visibility = VISIBILITY_PROTECTED; | |
1946 else | |
1947 error ("unrecognized visibility value \"%s\"", arg); | |
1948 } | |
1949 break; | |
1950 | |
1951 case OPT_fvpt: | |
1952 flag_value_profile_transformations_set = true; | |
1953 break; | 1575 break; |
1954 | 1576 |
1955 case OPT_frandom_seed: | 1577 case OPT_frandom_seed: |
1956 /* The real switch is -fno-random-seed. */ | 1578 /* The real switch is -fno-random-seed. */ |
1957 if (value) | 1579 if (value) |
1958 return 0; | 1580 return false; |
1959 set_random_seed (NULL); | 1581 /* Deferred. */ |
1960 break; | 1582 break; |
1961 | 1583 |
1962 case OPT_frandom_seed_: | 1584 case OPT_frandom_seed_: |
1963 set_random_seed (arg); | 1585 /* Deferred. */ |
1964 break; | |
1965 | |
1966 case OPT_fselective_scheduling: | |
1967 case OPT_fselective_scheduling2: | |
1968 sel_sched_switch_set = true; | |
1969 break; | 1586 break; |
1970 | 1587 |
1971 case OPT_fsched_verbose_: | 1588 case OPT_fsched_verbose_: |
1972 #ifdef INSN_SCHEDULING | 1589 #ifdef INSN_SCHEDULING |
1973 fix_sched_param ("verbose", arg); | 1590 /* Handled with Var in common.opt. */ |
1974 break; | 1591 break; |
1975 #else | 1592 #else |
1976 return 0; | 1593 return false; |
1977 #endif | 1594 #endif |
1978 | 1595 |
1979 case OPT_fsched_stalled_insns_: | 1596 case OPT_fsched_stalled_insns_: |
1980 flag_sched_stalled_insns = value; | 1597 opts->x_flag_sched_stalled_insns = value; |
1981 if (flag_sched_stalled_insns == 0) | 1598 if (opts->x_flag_sched_stalled_insns == 0) |
1982 flag_sched_stalled_insns = -1; | 1599 opts->x_flag_sched_stalled_insns = -1; |
1983 break; | 1600 break; |
1984 | 1601 |
1985 case OPT_fsched_stalled_insns_dep_: | 1602 case OPT_fsched_stalled_insns_dep_: |
1986 flag_sched_stalled_insns_dep = value; | 1603 opts->x_flag_sched_stalled_insns_dep = value; |
1987 break; | 1604 break; |
1988 | 1605 |
1989 case OPT_fstack_check_: | 1606 case OPT_fstack_check_: |
1990 if (!strcmp (arg, "no")) | 1607 if (!strcmp (arg, "no")) |
1991 flag_stack_check = NO_STACK_CHECK; | 1608 opts->x_flag_stack_check = NO_STACK_CHECK; |
1992 else if (!strcmp (arg, "generic")) | 1609 else if (!strcmp (arg, "generic")) |
1993 /* This is the old stack checking method. */ | 1610 /* This is the old stack checking method. */ |
1994 flag_stack_check = STACK_CHECK_BUILTIN | 1611 opts->x_flag_stack_check = STACK_CHECK_BUILTIN |
1995 ? FULL_BUILTIN_STACK_CHECK | 1612 ? FULL_BUILTIN_STACK_CHECK |
1996 : GENERIC_STACK_CHECK; | 1613 : GENERIC_STACK_CHECK; |
1997 else if (!strcmp (arg, "specific")) | 1614 else if (!strcmp (arg, "specific")) |
1998 /* This is the new stack checking method. */ | 1615 /* This is the new stack checking method. */ |
1999 flag_stack_check = STACK_CHECK_BUILTIN | 1616 opts->x_flag_stack_check = STACK_CHECK_BUILTIN |
2000 ? FULL_BUILTIN_STACK_CHECK | 1617 ? FULL_BUILTIN_STACK_CHECK |
2001 : STACK_CHECK_STATIC_BUILTIN | 1618 : STACK_CHECK_STATIC_BUILTIN |
2002 ? STATIC_BUILTIN_STACK_CHECK | 1619 ? STATIC_BUILTIN_STACK_CHECK |
2003 : GENERIC_STACK_CHECK; | 1620 : GENERIC_STACK_CHECK; |
2004 else | 1621 else |
2005 warning (0, "unknown stack check parameter \"%s\"", arg); | 1622 warning_at (loc, 0, "unknown stack check parameter \"%s\"", arg); |
2006 break; | |
2007 | |
2008 case OPT_fstack_check: | |
2009 /* This is the same as the "specific" mode above. */ | |
2010 if (value) | |
2011 flag_stack_check = STACK_CHECK_BUILTIN | |
2012 ? FULL_BUILTIN_STACK_CHECK | |
2013 : STACK_CHECK_STATIC_BUILTIN | |
2014 ? STATIC_BUILTIN_STACK_CHECK | |
2015 : GENERIC_STACK_CHECK; | |
2016 else | |
2017 flag_stack_check = NO_STACK_CHECK; | |
2018 break; | 1623 break; |
2019 | 1624 |
2020 case OPT_fstack_limit: | 1625 case OPT_fstack_limit: |
2021 /* The real switch is -fno-stack-limit. */ | 1626 /* The real switch is -fno-stack-limit. */ |
2022 if (value) | 1627 if (value) |
2023 return 0; | 1628 return false; |
2024 stack_limit_rtx = NULL_RTX; | 1629 /* Deferred. */ |
2025 break; | 1630 break; |
2026 | 1631 |
2027 case OPT_fstack_limit_register_: | 1632 case OPT_fstack_limit_register_: |
2028 { | |
2029 int reg = decode_reg_name (arg); | |
2030 if (reg < 0) | |
2031 error ("unrecognized register name \"%s\"", arg); | |
2032 else | |
2033 stack_limit_rtx = gen_rtx_REG (Pmode, reg); | |
2034 } | |
2035 break; | |
2036 | |
2037 case OPT_fstack_limit_symbol_: | 1633 case OPT_fstack_limit_symbol_: |
2038 stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (arg)); | 1634 /* Deferred. */ |
2039 break; | 1635 break; |
2040 | 1636 |
2041 case OPT_ftree_vectorizer_verbose_: | 1637 case OPT_ftree_vectorizer_verbose_: |
2042 vect_set_verbosity_level (arg); | 1638 vect_set_verbosity_level (opts, value); |
2043 break; | |
2044 | |
2045 case OPT_ftls_model_: | |
2046 if (!strcmp (arg, "global-dynamic")) | |
2047 flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC; | |
2048 else if (!strcmp (arg, "local-dynamic")) | |
2049 flag_tls_default = TLS_MODEL_LOCAL_DYNAMIC; | |
2050 else if (!strcmp (arg, "initial-exec")) | |
2051 flag_tls_default = TLS_MODEL_INITIAL_EXEC; | |
2052 else if (!strcmp (arg, "local-exec")) | |
2053 flag_tls_default = TLS_MODEL_LOCAL_EXEC; | |
2054 else | |
2055 warning (0, "unknown tls-model \"%s\"", arg); | |
2056 break; | |
2057 | |
2058 case OPT_fira_algorithm_: | |
2059 if (!strcmp (arg, "CB")) | |
2060 flag_ira_algorithm = IRA_ALGORITHM_CB; | |
2061 else if (!strcmp (arg, "priority")) | |
2062 flag_ira_algorithm = IRA_ALGORITHM_PRIORITY; | |
2063 else | |
2064 warning (0, "unknown ira algorithm \"%s\"", arg); | |
2065 break; | |
2066 | |
2067 case OPT_fira_region_: | |
2068 if (!strcmp (arg, "one")) | |
2069 flag_ira_region = IRA_REGION_ONE; | |
2070 else if (!strcmp (arg, "all")) | |
2071 flag_ira_region = IRA_REGION_ALL; | |
2072 else if (!strcmp (arg, "mixed")) | |
2073 flag_ira_region = IRA_REGION_MIXED; | |
2074 else | |
2075 warning (0, "unknown ira region \"%s\"", arg); | |
2076 break; | |
2077 | |
2078 case OPT_fira_verbose_: | |
2079 flag_ira_verbose = value; | |
2080 break; | |
2081 | |
2082 case OPT_ftracer: | |
2083 flag_tracer_set = true; | |
2084 break; | |
2085 | |
2086 case OPT_fipa_cp: | |
2087 flag_ipa_cp_set = true; | |
2088 break; | |
2089 | |
2090 case OPT_fipa_cp_clone: | |
2091 flag_ipa_cp_clone_set = true; | |
2092 break; | |
2093 | |
2094 case OPT_fpredictive_commoning: | |
2095 flag_predictive_commoning_set = true; | |
2096 break; | |
2097 | |
2098 case OPT_funswitch_loops: | |
2099 flag_unswitch_loops_set = true; | |
2100 break; | |
2101 | |
2102 case OPT_fgcse_after_reload: | |
2103 flag_gcse_after_reload_set = true; | |
2104 break; | |
2105 | |
2106 case OPT_funroll_loops: | |
2107 flag_unroll_loops_set = true; | |
2108 break; | 1639 break; |
2109 | 1640 |
2110 case OPT_g: | 1641 case OPT_g: |
2111 set_debug_level (NO_DEBUG, DEFAULT_GDB_EXTENSIONS, arg); | 1642 set_debug_level (NO_DEBUG, DEFAULT_GDB_EXTENSIONS, arg, opts, opts_set, |
1643 loc); | |
2112 break; | 1644 break; |
2113 | 1645 |
2114 case OPT_gcoff: | 1646 case OPT_gcoff: |
2115 set_debug_level (SDB_DEBUG, false, arg); | 1647 set_debug_level (SDB_DEBUG, false, arg, opts, opts_set, loc); |
2116 break; | 1648 break; |
2117 | 1649 |
2118 case OPT_gdwarf_: | 1650 case OPT_gdwarf_: |
2119 if (value < 2 || value > 4) | 1651 if (value < 2 || value > 4) |
2120 error ("dwarf version %d is not supported", value); | 1652 error_at (loc, "dwarf version %d is not supported", value); |
2121 else | 1653 else |
2122 dwarf_version = value; | 1654 dwarf_version = value; |
2123 set_debug_level (DWARF2_DEBUG, false, ""); | 1655 set_debug_level (DWARF2_DEBUG, false, "", opts, opts_set, loc); |
2124 break; | 1656 break; |
2125 | 1657 |
2126 case OPT_ggdb: | 1658 case OPT_ggdb: |
2127 set_debug_level (NO_DEBUG, 2, arg); | 1659 set_debug_level (NO_DEBUG, 2, arg, opts, opts_set, loc); |
2128 break; | 1660 break; |
2129 | 1661 |
2130 case OPT_gstabs: | 1662 case OPT_gstabs: |
2131 case OPT_gstabs_: | 1663 case OPT_gstabs_: |
2132 set_debug_level (DBX_DEBUG, code == OPT_gstabs_, arg); | 1664 set_debug_level (DBX_DEBUG, code == OPT_gstabs_, arg, opts, opts_set, |
1665 loc); | |
2133 break; | 1666 break; |
2134 | 1667 |
2135 case OPT_gvms: | 1668 case OPT_gvms: |
2136 set_debug_level (VMS_DEBUG, false, arg); | 1669 set_debug_level (VMS_DEBUG, false, arg, opts, opts_set, loc); |
2137 break; | 1670 break; |
2138 | 1671 |
2139 case OPT_gxcoff: | 1672 case OPT_gxcoff: |
2140 case OPT_gxcoff_: | 1673 case OPT_gxcoff_: |
2141 set_debug_level (XCOFF_DEBUG, code == OPT_gxcoff_, arg); | 1674 set_debug_level (XCOFF_DEBUG, code == OPT_gxcoff_, arg, opts, opts_set, |
2142 break; | 1675 loc); |
2143 | |
2144 case OPT_o: | |
2145 asm_file_name = arg; | |
2146 break; | 1676 break; |
2147 | 1677 |
2148 case OPT_pedantic_errors: | 1678 case OPT_pedantic_errors: |
2149 flag_pedantic_errors = pedantic = 1; | 1679 opts->x_pedantic = 1; |
2150 break; | 1680 dc->pedantic_errors = 1; |
2151 | 1681 break; |
2152 case OPT_fwhopr: | 1682 |
2153 flag_whopr = value; | 1683 case OPT_flto: |
2154 break; | 1684 opts->x_flag_lto = value ? "" : NULL; |
2155 | 1685 break; |
2156 case OPT_fsee: | 1686 |
2157 case OPT_fcse_skip_blocks: | 1687 case OPT_w: |
2158 case OPT_floop_optimize: | 1688 dc->dc_inhibit_warnings = true; |
2159 case OPT_frerun_loop_opt: | 1689 break; |
2160 case OPT_fsched2_use_traces: | 1690 |
2161 case OPT_fstrength_reduce: | 1691 case OPT_fmax_errors_: |
2162 case OPT_ftree_store_copy_prop: | 1692 dc->max_errors = value; |
2163 case OPT_fforce_addr: | |
2164 case OPT_ftree_salias: | |
2165 case OPT_ftree_store_ccp: | |
2166 case OPT_Wunreachable_code: | |
2167 case OPT_fargument_alias: | |
2168 case OPT_fargument_noalias: | |
2169 case OPT_fargument_noalias_anything: | |
2170 case OPT_fargument_noalias_global: | |
2171 /* These are no-ops, preserved for backward compatibility. */ | |
2172 break; | 1693 break; |
2173 | 1694 |
2174 case OPT_fuse_linker_plugin: | 1695 case OPT_fuse_linker_plugin: |
2175 /* No-op. Used by the driver and passed to us because it starts with f.*/ | 1696 /* No-op. Used by the driver and passed to us because it starts with f.*/ |
2176 break; | 1697 break; |
2177 | 1698 |
2178 default: | 1699 default: |
2179 /* If the flag was handled in a standard way, assume the lack of | 1700 /* If the flag was handled in a standard way, assume the lack of |
2180 processing here is intentional. */ | 1701 processing here is intentional. */ |
2181 gcc_assert (cl_options[scode].flag_var); | 1702 gcc_assert (option_flag_var (scode, opts)); |
2182 break; | 1703 break; |
2183 } | 1704 } |
2184 | 1705 |
2185 return 1; | 1706 return true; |
2186 } | 1707 } |
2187 | 1708 |
2188 /* Handle --param NAME=VALUE. */ | 1709 /* Handle --param NAME=VALUE. */ |
2189 static void | 1710 static void |
2190 handle_param (const char *carg) | 1711 handle_param (struct gcc_options *opts, struct gcc_options *opts_set, |
1712 location_t loc, const char *carg) | |
2191 { | 1713 { |
2192 char *equal, *arg; | 1714 char *equal, *arg; |
2193 int value; | 1715 int value; |
2194 | 1716 |
2195 arg = xstrdup (carg); | 1717 arg = xstrdup (carg); |
2196 equal = strchr (arg, '='); | 1718 equal = strchr (arg, '='); |
2197 if (!equal) | 1719 if (!equal) |
2198 error ("%s: --param arguments should be of the form NAME=VALUE", arg); | 1720 error_at (loc, "%s: --param arguments should be of the form NAME=VALUE", |
1721 arg); | |
2199 else | 1722 else |
2200 { | 1723 { |
2201 value = integral_argument (equal + 1); | 1724 value = integral_argument (equal + 1); |
2202 if (value == -1) | 1725 if (value == -1) |
2203 error ("invalid --param value %qs", equal + 1); | 1726 error_at (loc, "invalid --param value %qs", equal + 1); |
2204 else | 1727 else |
2205 { | 1728 { |
2206 *equal = '\0'; | 1729 *equal = '\0'; |
2207 set_param_value (arg, value); | 1730 set_param_value (arg, value, |
1731 opts->x_param_values, opts_set->x_param_values); | |
2208 } | 1732 } |
2209 } | 1733 } |
2210 | 1734 |
2211 free (arg); | 1735 free (arg); |
2212 } | 1736 } |
2213 | 1737 |
2214 /* Used to set the level of strict aliasing warnings, | 1738 /* Used to set the level of strict aliasing warnings in OPTS, |
2215 when no level is specified (i.e., when -Wstrict-aliasing, and not | 1739 when no level is specified (i.e., when -Wstrict-aliasing, and not |
2216 -Wstrict-aliasing=level was given). | 1740 -Wstrict-aliasing=level was given). |
2217 ONOFF is assumed to take value 1 when -Wstrict-aliasing is specified, | 1741 ONOFF is assumed to take value 1 when -Wstrict-aliasing is specified, |
2218 and 0 otherwise. After calling this function, wstrict_aliasing will be | 1742 and 0 otherwise. After calling this function, wstrict_aliasing will be |
2219 set to the default value of -Wstrict_aliasing=level, currently 3. */ | 1743 set to the default value of -Wstrict_aliasing=level, currently 3. */ |
2220 void | 1744 void |
2221 set_Wstrict_aliasing (int onoff) | 1745 set_Wstrict_aliasing (struct gcc_options *opts, int onoff) |
2222 { | 1746 { |
2223 gcc_assert (onoff == 0 || onoff == 1); | 1747 gcc_assert (onoff == 0 || onoff == 1); |
2224 if (onoff != 0) | 1748 if (onoff != 0) |
2225 warn_strict_aliasing = 3; | 1749 opts->x_warn_strict_aliasing = 3; |
2226 else | 1750 else |
2227 warn_strict_aliasing = 0; | 1751 opts->x_warn_strict_aliasing = 0; |
2228 } | 1752 } |
2229 | 1753 |
2230 /* The following routines are useful in setting all the flags that | 1754 /* The following routines are useful in setting all the flags that |
2231 -ffast-math and -fno-fast-math imply. */ | 1755 -ffast-math and -fno-fast-math imply. */ |
2232 void | 1756 static void |
2233 set_fast_math_flags (int set) | 1757 set_fast_math_flags (struct gcc_options *opts, int set) |
2234 { | 1758 { |
2235 flag_unsafe_math_optimizations = set; | 1759 if (!opts->frontend_set_flag_unsafe_math_optimizations) |
2236 set_unsafe_math_optimizations_flags (set); | 1760 { |
2237 flag_finite_math_only = set; | 1761 opts->x_flag_unsafe_math_optimizations = set; |
2238 flag_errno_math = !set; | 1762 set_unsafe_math_optimizations_flags (opts, set); |
1763 } | |
1764 if (!opts->frontend_set_flag_finite_math_only) | |
1765 opts->x_flag_finite_math_only = set; | |
1766 if (!opts->frontend_set_flag_errno_math) | |
1767 opts->x_flag_errno_math = !set; | |
2239 if (set) | 1768 if (set) |
2240 { | 1769 { |
2241 flag_signaling_nans = 0; | 1770 if (!opts->frontend_set_flag_signaling_nans) |
2242 flag_rounding_math = 0; | 1771 opts->x_flag_signaling_nans = 0; |
2243 flag_cx_limited_range = 1; | 1772 if (!opts->frontend_set_flag_rounding_math) |
1773 opts->x_flag_rounding_math = 0; | |
1774 if (!opts->frontend_set_flag_cx_limited_range) | |
1775 opts->x_flag_cx_limited_range = 1; | |
2244 } | 1776 } |
2245 } | 1777 } |
2246 | 1778 |
2247 /* When -funsafe-math-optimizations is set the following | 1779 /* When -funsafe-math-optimizations is set the following |
2248 flags are set as well. */ | 1780 flags are set as well. */ |
2249 void | 1781 static void |
2250 set_unsafe_math_optimizations_flags (int set) | 1782 set_unsafe_math_optimizations_flags (struct gcc_options *opts, int set) |
2251 { | 1783 { |
2252 flag_trapping_math = !set; | 1784 if (!opts->frontend_set_flag_trapping_math) |
2253 flag_signed_zeros = !set; | 1785 opts->x_flag_trapping_math = !set; |
2254 flag_associative_math = set; | 1786 if (!opts->frontend_set_flag_signed_zeros) |
2255 flag_reciprocal_math = set; | 1787 opts->x_flag_signed_zeros = !set; |
2256 } | 1788 if (!opts->frontend_set_flag_associative_math) |
2257 | 1789 opts->x_flag_associative_math = set; |
2258 /* Return true iff flags are set as if -ffast-math. */ | 1790 if (!opts->frontend_set_flag_reciprocal_math) |
1791 opts->x_flag_reciprocal_math = set; | |
1792 } | |
1793 | |
1794 /* Return true iff flags in OPTS are set as if -ffast-math. */ | |
2259 bool | 1795 bool |
2260 fast_math_flags_set_p (void) | 1796 fast_math_flags_set_p (const struct gcc_options *opts) |
2261 { | 1797 { |
2262 return (!flag_trapping_math | 1798 return (!opts->x_flag_trapping_math |
2263 && flag_unsafe_math_optimizations | 1799 && opts->x_flag_unsafe_math_optimizations |
2264 && flag_finite_math_only | 1800 && opts->x_flag_finite_math_only |
2265 && !flag_signed_zeros | 1801 && !opts->x_flag_signed_zeros |
2266 && !flag_errno_math); | 1802 && !opts->x_flag_errno_math); |
2267 } | 1803 } |
2268 | 1804 |
2269 /* Return true iff flags are set as if -ffast-math but using the flags stored | 1805 /* Return true iff flags are set as if -ffast-math but using the flags stored |
2270 in the struct cl_optimization structure. */ | 1806 in the struct cl_optimization structure. */ |
2271 bool | 1807 bool |
2272 fast_math_flags_struct_set_p (struct cl_optimization *opt) | 1808 fast_math_flags_struct_set_p (struct cl_optimization *opt) |
2273 { | 1809 { |
2274 return (!opt->flag_trapping_math | 1810 return (!opt->x_flag_trapping_math |
2275 && opt->flag_unsafe_math_optimizations | 1811 && opt->x_flag_unsafe_math_optimizations |
2276 && opt->flag_finite_math_only | 1812 && opt->x_flag_finite_math_only |
2277 && !opt->flag_signed_zeros | 1813 && !opt->x_flag_signed_zeros |
2278 && !opt->flag_errno_math); | 1814 && !opt->x_flag_errno_math); |
2279 } | 1815 } |
2280 | 1816 |
2281 /* Handle a debug output -g switch. EXTENDED is true or false to support | 1817 /* Handle a debug output -g switch for options OPTS |
1818 (OPTS_SET->x_write_symbols storing whether a debug type was passed | |
1819 explicitly), location LOC. EXTENDED is true or false to support | |
2282 extended output (2 is special and means "-ggdb" was given). */ | 1820 extended output (2 is special and means "-ggdb" was given). */ |
2283 static void | 1821 static void |
2284 set_debug_level (enum debug_info_type type, int extended, const char *arg) | 1822 set_debug_level (enum debug_info_type type, int extended, const char *arg, |
2285 { | 1823 struct gcc_options *opts, struct gcc_options *opts_set, |
2286 static bool type_explicit; | 1824 location_t loc) |
2287 | 1825 { |
2288 use_gnu_debug_info_extensions = extended; | 1826 opts->x_use_gnu_debug_info_extensions = extended; |
2289 | 1827 |
2290 if (type == NO_DEBUG) | 1828 if (type == NO_DEBUG) |
2291 { | 1829 { |
2292 if (write_symbols == NO_DEBUG) | 1830 if (opts->x_write_symbols == NO_DEBUG) |
2293 { | 1831 { |
2294 write_symbols = PREFERRED_DEBUGGING_TYPE; | 1832 opts->x_write_symbols = PREFERRED_DEBUGGING_TYPE; |
2295 | 1833 |
2296 if (extended == 2) | 1834 if (extended == 2) |
2297 { | 1835 { |
2298 #ifdef DWARF2_DEBUGGING_INFO | 1836 #ifdef DWARF2_DEBUGGING_INFO |
2299 write_symbols = DWARF2_DEBUG; | 1837 opts->x_write_symbols = DWARF2_DEBUG; |
2300 #elif defined DBX_DEBUGGING_INFO | 1838 #elif defined DBX_DEBUGGING_INFO |
2301 write_symbols = DBX_DEBUG; | 1839 opts->x_write_symbols = DBX_DEBUG; |
2302 #endif | 1840 #endif |
2303 } | 1841 } |
2304 | 1842 |
2305 if (write_symbols == NO_DEBUG) | 1843 if (opts->x_write_symbols == NO_DEBUG) |
2306 warning (0, "target system does not support debug output"); | 1844 warning_at (loc, 0, "target system does not support debug output"); |
2307 } | 1845 } |
2308 } | 1846 } |
2309 else | 1847 else |
2310 { | 1848 { |
2311 /* Does it conflict with an already selected type? */ | 1849 /* Does it conflict with an already selected type? */ |
2312 if (type_explicit && write_symbols != NO_DEBUG && type != write_symbols) | 1850 if (opts_set->x_write_symbols != NO_DEBUG |
2313 error ("debug format \"%s\" conflicts with prior selection", | 1851 && opts->x_write_symbols != NO_DEBUG |
2314 debug_type_names[type]); | 1852 && type != opts->x_write_symbols) |
2315 write_symbols = type; | 1853 error_at (loc, "debug format \"%s\" conflicts with prior selection", |
2316 type_explicit = true; | 1854 debug_type_names[type]); |
1855 opts->x_write_symbols = type; | |
1856 opts_set->x_write_symbols = type; | |
2317 } | 1857 } |
2318 | 1858 |
2319 /* A debug flag without a level defaults to level 2. */ | 1859 /* A debug flag without a level defaults to level 2. */ |
2320 if (*arg == '\0') | 1860 if (*arg == '\0') |
2321 { | 1861 { |
2322 if (!debug_info_level) | 1862 if (!opts->x_debug_info_level) |
2323 debug_info_level = DINFO_LEVEL_NORMAL; | 1863 opts->x_debug_info_level = DINFO_LEVEL_NORMAL; |
2324 } | 1864 } |
2325 else | 1865 else |
2326 { | 1866 { |
2327 int argval = integral_argument (arg); | 1867 int argval = integral_argument (arg); |
2328 if (argval == -1) | 1868 if (argval == -1) |
2329 error ("unrecognised debug output level \"%s\"", arg); | 1869 error_at (loc, "unrecognised debug output level \"%s\"", arg); |
2330 else if (argval > 3) | 1870 else if (argval > 3) |
2331 error ("debug output level %s is too high", arg); | 1871 error_at (loc, "debug output level %s is too high", arg); |
2332 else | 1872 else |
2333 debug_info_level = (enum debug_info_level) argval; | 1873 opts->x_debug_info_level = (enum debug_info_levels) argval; |
2334 } | 1874 } |
2335 } | 1875 } |
2336 | 1876 |
2337 /* Return 1 if OPTION is enabled, 0 if it is disabled, or -1 if it isn't | 1877 /* Arrange to dump core on error for diagnostic context DC. (The |
2338 a simple on-off switch. */ | 1878 regular error message is still printed first, except in the case of |
2339 | 1879 abort ().) */ |
2340 int | 1880 |
2341 option_enabled (int opt_idx) | 1881 static void |
2342 { | 1882 setup_core_dumping (diagnostic_context *dc) |
2343 const struct cl_option *option = &(cl_options[opt_idx]); | 1883 { |
2344 | 1884 #ifdef SIGABRT |
2345 if (option->flag_var) | 1885 signal (SIGABRT, SIG_DFL); |
2346 switch (option->var_type) | 1886 #endif |
1887 #if defined(HAVE_SETRLIMIT) | |
1888 { | |
1889 struct rlimit rlim; | |
1890 if (getrlimit (RLIMIT_CORE, &rlim) != 0) | |
1891 fatal_error ("getting core file size maximum limit: %m"); | |
1892 rlim.rlim_cur = rlim.rlim_max; | |
1893 if (setrlimit (RLIMIT_CORE, &rlim) != 0) | |
1894 fatal_error ("setting core file size limit to maximum: %m"); | |
1895 } | |
1896 #endif | |
1897 diagnostic_abort_on_error (dc); | |
1898 } | |
1899 | |
1900 /* Parse a -d<ARG> command line switch for OPTS, location LOC, | |
1901 diagnostic context DC. */ | |
1902 | |
1903 static void | |
1904 decode_d_option (const char *arg, struct gcc_options *opts, | |
1905 location_t loc, diagnostic_context *dc) | |
1906 { | |
1907 int c; | |
1908 | |
1909 while (*arg) | |
1910 switch (c = *arg++) | |
2347 { | 1911 { |
2348 case CLVC_BOOLEAN: | 1912 case 'A': |
2349 return *(int *) option->flag_var != 0; | 1913 opts->x_flag_debug_asm = 1; |
2350 | 1914 break; |
2351 case CLVC_EQUAL: | 1915 case 'p': |
2352 return *(int *) option->flag_var == option->var_value; | 1916 opts->x_flag_print_asm_name = 1; |
2353 | 1917 break; |
2354 case CLVC_BIT_CLEAR: | 1918 case 'P': |
2355 return (*(int *) option->flag_var & option->var_value) == 0; | 1919 opts->x_flag_dump_rtl_in_asm = 1; |
2356 | 1920 opts->x_flag_print_asm_name = 1; |
2357 case CLVC_BIT_SET: | 1921 break; |
2358 return (*(int *) option->flag_var & option->var_value) != 0; | 1922 case 'v': |
2359 | 1923 opts->x_graph_dump_format = vcg; |
2360 case CLVC_STRING: | 1924 break; |
1925 case 'x': | |
1926 opts->x_rtl_dump_and_exit = 1; | |
1927 break; | |
1928 case 'D': /* These are handled by the preprocessor. */ | |
1929 case 'I': | |
1930 case 'M': | |
1931 case 'N': | |
1932 case 'U': | |
1933 break; | |
1934 case 'H': | |
1935 setup_core_dumping (dc); | |
1936 break; | |
1937 case 'a': | |
1938 opts->x_flag_dump_all_passed = true; | |
1939 break; | |
1940 | |
1941 default: | |
1942 warning_at (loc, 0, "unrecognized gcc debugging option: %c", c); | |
2361 break; | 1943 break; |
2362 } | 1944 } |
2363 return -1; | 1945 } |
2364 } | 1946 |
2365 | 1947 /* Enable (or disable if VALUE is 0) a warning option ARG (language |
2366 /* Fill STATE with the current state of option OPTION. Return true if | 1948 mask LANG_MASK, option handlers HANDLERS) as an error for option |
2367 there is some state to store. */ | 1949 structures OPTS and OPTS_SET, diagnostic context DC (possibly |
2368 | 1950 NULL), location LOC. This is used by -Werror=. */ |
2369 bool | 1951 |
2370 get_option_state (int option, struct cl_option_state *state) | 1952 static void |
2371 { | 1953 enable_warning_as_error (const char *arg, int value, unsigned int lang_mask, |
2372 if (cl_options[option].flag_var == 0) | 1954 const struct cl_option_handlers *handlers, |
2373 return false; | 1955 struct gcc_options *opts, |
2374 | 1956 struct gcc_options *opts_set, |
2375 switch (cl_options[option].var_type) | 1957 location_t loc, diagnostic_context *dc) |
2376 { | |
2377 case CLVC_BOOLEAN: | |
2378 case CLVC_EQUAL: | |
2379 state->data = cl_options[option].flag_var; | |
2380 state->size = sizeof (int); | |
2381 break; | |
2382 | |
2383 case CLVC_BIT_CLEAR: | |
2384 case CLVC_BIT_SET: | |
2385 state->ch = option_enabled (option); | |
2386 state->data = &state->ch; | |
2387 state->size = 1; | |
2388 break; | |
2389 | |
2390 case CLVC_STRING: | |
2391 state->data = *(const char **) cl_options[option].flag_var; | |
2392 if (state->data == 0) | |
2393 state->data = ""; | |
2394 state->size = strlen ((const char *) state->data) + 1; | |
2395 break; | |
2396 } | |
2397 return true; | |
2398 } | |
2399 | |
2400 /* Set *OPTION according to VALUE and ARG. */ | |
2401 | |
2402 void | |
2403 set_option (int opt_index, int value, const char *arg, int kind) | |
2404 { | |
2405 const struct cl_option *option = &cl_options[opt_index]; | |
2406 | |
2407 if (!option->flag_var) | |
2408 return; | |
2409 | |
2410 switch (option->var_type) | |
2411 { | |
2412 case CLVC_BOOLEAN: | |
2413 *(int *) option->flag_var = value; | |
2414 break; | |
2415 | |
2416 case CLVC_EQUAL: | |
2417 *(int *) option->flag_var = (value | |
2418 ? option->var_value | |
2419 : !option->var_value); | |
2420 break; | |
2421 | |
2422 case CLVC_BIT_CLEAR: | |
2423 case CLVC_BIT_SET: | |
2424 if ((value != 0) == (option->var_type == CLVC_BIT_SET)) | |
2425 *(int *) option->flag_var |= option->var_value; | |
2426 else | |
2427 *(int *) option->flag_var &= ~option->var_value; | |
2428 if (option->flag_var == &target_flags) | |
2429 target_flags_explicit |= option->var_value; | |
2430 break; | |
2431 | |
2432 case CLVC_STRING: | |
2433 *(const char **) option->flag_var = arg; | |
2434 break; | |
2435 } | |
2436 | |
2437 if ((diagnostic_t)kind != DK_UNSPECIFIED) | |
2438 diagnostic_classify_diagnostic (global_dc, opt_index, (diagnostic_t)kind); | |
2439 } | |
2440 | |
2441 | |
2442 /* Callback function, called when -Werror= enables a warning. */ | |
2443 | |
2444 static void (*warning_as_error_callback) (int) = NULL; | |
2445 | |
2446 /* Register a callback for enable_warning_as_error calls. */ | |
2447 | |
2448 void | |
2449 register_warning_as_error_callback (void (*callback) (int)) | |
2450 { | |
2451 gcc_assert (warning_as_error_callback == NULL || callback == NULL); | |
2452 warning_as_error_callback = callback; | |
2453 } | |
2454 | |
2455 /* Enable a warning option as an error. This is used by -Werror= and | |
2456 also by legacy Werror-implicit-function-declaration. */ | |
2457 | |
2458 void | |
2459 enable_warning_as_error (const char *arg, int value, unsigned int lang_mask) | |
2460 { | 1958 { |
2461 char *new_option; | 1959 char *new_option; |
2462 int option_index; | 1960 int option_index; |
2463 | 1961 |
2464 new_option = XNEWVEC (char, strlen (arg) + 2); | 1962 new_option = XNEWVEC (char, strlen (arg) + 2); |
2465 new_option[0] = 'W'; | 1963 new_option[0] = 'W'; |
2466 strcpy (new_option + 1, arg); | 1964 strcpy (new_option + 1, arg); |
2467 option_index = find_opt (new_option, lang_mask); | 1965 option_index = find_opt (new_option, lang_mask); |
2468 if (option_index == N_OPTS) | 1966 if (option_index == OPT_SPECIAL_unknown) |
2469 { | 1967 { |
2470 error ("-Werror=%s: No option -%s", arg, new_option); | 1968 error_at (loc, "-Werror=%s: no option -%s", arg, new_option); |
2471 } | 1969 } |
2472 else | 1970 else |
2473 { | 1971 { |
2474 const diagnostic_t kind = value ? DK_ERROR : DK_WARNING; | 1972 const diagnostic_t kind = value ? DK_ERROR : DK_WARNING; |
2475 | 1973 |
2476 diagnostic_classify_diagnostic (global_dc, option_index, kind); | 1974 control_warning_option (option_index, (int) kind, value, |
2477 if (kind == DK_ERROR) | 1975 loc, lang_mask, |
2478 { | 1976 handlers, opts, opts_set, dc); |
2479 const struct cl_option * const option = cl_options + option_index; | |
2480 | |
2481 /* -Werror=foo implies -Wfoo. */ | |
2482 if (option->var_type == CLVC_BOOLEAN) | |
2483 handle_option (option_index, value, arg, lang_mask, (int)kind); | |
2484 | |
2485 if (warning_as_error_callback) | |
2486 warning_as_error_callback (option_index); | |
2487 } | |
2488 } | 1977 } |
2489 free (new_option); | 1978 free (new_option); |
2490 } | 1979 } |
1980 | |
1981 /* Return malloced memory for the name of the option OPTION_INDEX | |
1982 which enabled a diagnostic (context CONTEXT), originally of type | |
1983 ORIG_DIAG_KIND but possibly converted to DIAG_KIND by options such | |
1984 as -Werror. */ | |
1985 | |
1986 char * | |
1987 option_name (diagnostic_context *context, int option_index, | |
1988 diagnostic_t orig_diag_kind, diagnostic_t diag_kind) | |
1989 { | |
1990 if (option_index) | |
1991 { | |
1992 /* A warning classified as an error. */ | |
1993 if ((orig_diag_kind == DK_WARNING || orig_diag_kind == DK_PEDWARN) | |
1994 && diag_kind == DK_ERROR) | |
1995 return concat (cl_options[OPT_Werror_].opt_text, | |
1996 /* Skip over "-W". */ | |
1997 cl_options[option_index].opt_text + 2, | |
1998 NULL); | |
1999 /* A warning with option. */ | |
2000 else | |
2001 return xstrdup (cl_options[option_index].opt_text); | |
2002 } | |
2003 /* A warning without option classified as an error. */ | |
2004 else if (orig_diag_kind == DK_WARNING || orig_diag_kind == DK_PEDWARN | |
2005 || diag_kind == DK_WARNING) | |
2006 { | |
2007 if (context->warning_as_error_requested) | |
2008 return xstrdup (cl_options[OPT_Werror].opt_text); | |
2009 else | |
2010 return xstrdup (_("enabled by default")); | |
2011 } | |
2012 else | |
2013 return NULL; | |
2014 } |