diff options
author | Rong Xu <xur@google.com> | 2014-07-21 16:47:22 -0700 |
---|---|---|
committer | Rong Xu <xur@google.com> | 2014-07-29 15:31:03 -0700 |
commit | 38a8aecfb882072900434499696b5c32a2274515 (patch) | |
tree | 2aac97f0ae24b03cd98c1a06e989c031c173f889 /gcc-4.9/gcc/c-family/c-opts.c | |
parent | c231900e5dcc14d8296bd9f62b45997a49d4d5e7 (diff) | |
download | toolchain_gcc-38a8aecfb882072900434499696b5c32a2274515.tar.gz toolchain_gcc-38a8aecfb882072900434499696b5c32a2274515.tar.bz2 toolchain_gcc-38a8aecfb882072900434499696b5c32a2274515.zip |
[4.9] Switch gcc-4.9 to use google/gcc-4_9 branch.
This source drop uses svn version r212828 of google/gcc-4.9 branch.
We also cherry-picked r213062, r213063 and r213064 to fix windows
build issues.
All gcc-4.9 patches before July 3rd are ported to google/gcc-4.9.
The following prior commits has not been merged to google branch yet.
(They are included in this commit).
e7af147f979e657fe2df00808e5b4319b0e088c6,
baf87df3cb2683649ba7e9872362a7e721117c23, and
c231900e5dcc14d8296bd9f62b45997a49d4d5e7.
Change-Id: I4bea3ea470387ff751c2be4cb0d4a12059b9299b
Diffstat (limited to 'gcc-4.9/gcc/c-family/c-opts.c')
-rw-r--r-- | gcc-4.9/gcc/c-family/c-opts.c | 126 |
1 files changed, 120 insertions, 6 deletions
diff --git a/gcc-4.9/gcc/c-family/c-opts.c b/gcc-4.9/gcc/c-family/c-opts.c index 29e9a355b..60d7145b7 100644 --- a/gcc-4.9/gcc/c-family/c-opts.c +++ b/gcc-4.9/gcc/c-family/c-opts.c @@ -43,6 +43,10 @@ along with GCC; see the file COPYING3. If not see TARGET_FLT_EVAL_METHOD_NON_DEFAULT and TARGET_OPTF. */ #include "tm_p.h" /* For C_COMMON_OVERRIDE_OPTIONS. */ +#include "function.h" +#include "params.h" +#include "l-ipo.h" +#include "dumpfile.h" #ifndef DOLLARS_IN_IDENTIFIERS # define DOLLARS_IN_IDENTIFIERS true @@ -102,6 +106,14 @@ static size_t deferred_count; /* Number of deferred options scanned for -include. */ static size_t include_cursor; +static bool parsing_done_p = false; + +/* Dump files/flags to use during parsing. */ +static FILE *original_dump_file = NULL; +static int original_dump_flags; +static FILE *class_dump_file = NULL; +static int class_dump_flags; + /* Whether any standard preincluded header has been preincluded. */ static bool done_preinclude; @@ -199,8 +211,10 @@ c_common_init_options_struct (struct gcc_options *opts) opts->x_warn_write_strings = c_dialect_cxx (); opts->x_flag_warn_unused_result = true; - /* By default, C99-like requirements for complex multiply and divide. */ - opts->x_flag_complex_method = 2; + /* By default, C99-like requirements for complex multiply and divide. + But for C++ this should not be required. */ + if (c_language != clk_cxx) + opts->x_flag_complex_method = 2; } /* Common initialization before calling option handlers. */ @@ -845,6 +859,10 @@ c_common_post_options (const char **pfilename) else if (!flag_gnu89_inline && !flag_isoc99) error ("-fno-gnu89-inline is only supported in GNU99 or C99 mode"); + if (flag_dyn_ipa && cpp_opts->preprocessed) + error ("-fpreprocessed/-save-temps are not supported with -fripa"); + + /* Default to ObjC sjlj exception handling if NeXT runtime. */ if (flag_objc_sjlj_exceptions < 0) flag_objc_sjlj_exceptions = flag_next_runtime; @@ -1051,6 +1069,34 @@ c_common_init (void) return true; } +/* Return TRUE if the lipo maximum memory consumption limit is reached, and + we should not import any further auxiliary modules. Check after parsing + each module, the Ith module being the just parsed module. */ +static bool +lipo_max_mem_reached (unsigned int i) +{ + if (L_IPO_COMP_MODE && PARAM_VALUE (PARAM_MAX_LIPO_MEMORY) + && i < (num_in_fnames - 1) + /* Scale up memory usage by 25% to account for memory consumption + by the optimizer. */ + && ((ggc_total_allocated () >> 10) * 1.25 + > (size_t) PARAM_VALUE (PARAM_MAX_LIPO_MEMORY))) { + if (dump_enabled_p ()) + { + i++; + do { + dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, input_location, + "Not importing %s: maximum memory " + "consumption reached", in_fnames[i]); + i++; + } while (i < num_in_fnames); + } + return true; + } + return false; +} + + /* Initialize the integrated preprocessor after debug output has been initialized; loop over each input file. */ void @@ -1062,9 +1108,26 @@ c_common_parse_file (void) for (;;) { c_finish_options (); + /* Open the dump files to use for the original and class dump output + here, to be used during parsing for the current file. */ + original_dump_file = dump_begin (TDI_original, &original_dump_flags); + class_dump_file = dump_begin (TDI_class, &class_dump_flags); pch_init (); + set_lipo_c_parsing_context (parse_in, i, verbose); push_file_scope (); c_parse_file (); + if (i == 0 && flag_record_compilation_info_in_elf) + write_compilation_flags_to_asm (); + + if (i == 0) + ggc_total_memory = (ggc_total_allocated () >> 10); + + /* In lipo mode, processing too many auxiliary files will cause us + to hit memory limits, and cause thrashing -- prevent this by not + processing any further auxiliary modules if we reach a certain + memory limit. */ + if (!include_all_aux && lipo_max_mem_reached (i)) + num_in_fnames = i + 1; pop_file_scope (); /* And end the main input file, if the debug writer wants it */ if (debug_hooks->start_end_main_source_file) @@ -1073,13 +1136,50 @@ c_common_parse_file (void) break; cpp_undef_all (parse_in); cpp_clear_file_cache (parse_in); + deferred_count = 0; this_input_filename = cpp_read_main_file (parse_in, in_fnames[i]); + if (original_dump_file) + { + dump_end (TDI_original, original_dump_file); + original_dump_file = NULL; + } + if (class_dump_file) + { + dump_end (TDI_class, class_dump_file); + class_dump_file = NULL; + } /* If an input file is missing, abandon further compilation. cpplib has issued a diagnostic. */ if (!this_input_filename) break; } + parsing_done_p = true; +} + +/* Returns true if parsing is done */ + +bool +is_parsing_done_p (void) +{ + return parsing_done_p; +} + +/* Returns the appropriate dump file for PHASE to dump with FLAGS. */ +FILE * +get_dump_info (int phase, int *flags) +{ + gcc_assert (phase == TDI_original || phase == TDI_class); + if (phase == TDI_original) + { + *flags = original_dump_flags; + return original_dump_file; + } + else + { + *flags = class_dump_flags; + return class_dump_file; + } } /* Common finish hook for the C, ObjC and C++ front ends. */ @@ -1089,7 +1189,11 @@ c_common_finish (void) FILE *deps_stream = NULL; /* Don't write the deps file if there are errors. */ - if (cpp_opts->deps.style != DEPS_NONE && !seen_error ()) + /* FIXME. We are emitting the deps file even if there were errors. + This is a temporary workaround to avoid confusing Google's build + system. It assumes that deps files are always emitted even + in the presence of errors. */ + if (cpp_opts->deps.style != DEPS_NONE /*&& !seen_error ()*/) { /* If -M or -MM was seen without -MF, default output to the output stream. */ @@ -1313,9 +1417,15 @@ c_finish_options (void) struct deferred_opt *opt = &deferred_opts[i]; if (opt->code == OPT_D) - cpp_define (parse_in, opt->arg); + { + cpp_define (parse_in, opt->arg); + coverage_note_define (opt->arg, true); + } else if (opt->code == OPT_U) - cpp_undef (parse_in, opt->arg); + { + cpp_undef (parse_in, opt->arg); + coverage_note_define (opt->arg, false); + } else if (opt->code == OPT_A) { if (opt->arg[0] == '-') @@ -1338,6 +1448,7 @@ c_finish_options (void) if (opt->code == OPT_imacros && cpp_push_include (parse_in, opt->arg)) { + coverage_note_include (opt->arg); /* Disable push_command_line_include callback for now. */ include_cursor = deferred_count + 1; cpp_scan_nooutput (parse_in); @@ -1382,7 +1493,10 @@ push_command_line_include (void) if (!cpp_opts->preprocessed && opt->code == OPT_include && cpp_push_include (parse_in, opt->arg)) - return; + { + coverage_note_include (opt->arg); + return; + } } if (include_cursor == deferred_count) |