/* Parse command line options and set default flag values. Do minimal options processing. */ void decode_options (unsigned int argc, const char **argv) { unsigned int i, lang_mask; /* APPLE LOCAL 4231773 */ unsigned int optimize_size_z = 0; /* APPLE LOCAL AV 3846092 */ int saved_flag_strict_aliasing; /* Perform language-specific options initialization. */ lang_mask = lang_hooks.init_options (argc, argv); lang_hooks.initialize_diagnostics (global_dc); /* Make a backup copy of the default, pre-command line options. Note this includes "optimize" and "optimize_size". */ cl_pf_opts_raw = cl_pf_opts; /* Scan to see what optimization level has been specified. That will determine the default value of many flags. */ for (i = 1; i < argc; i++) { if (!strcmp (argv[i], "-O")) { optimize = 1; optimize_size = 0; } else if (argv[i][0] == '-' && argv[i][1] == 'O') { /* Handle -Os, -O2, -O3, -O69, ... */ const char *p = &argv[i][2]; /* APPLE LOCAL begin 4231773 */ if ((p[0] == 's' || p[0] == 'z') && (p[1] == 0)) { optimize_size = 1; optimize_size_z = (p[0] == 'z'); /* APPLE LOCAL end 4231773 */ /* Optimizing for size forces optimize to be 2. */ optimize = 2; } else { const int optimize_val = read_integral_parameter (p, p - 2, -1); if (optimize_val != -1) { optimize = optimize_val; optimize_size = 0; } } } /* APPLE LOCAL begin -fast or -fastf or -fastcp */ else if (argv[i][0] == '-' && argv[i][1] == 'f') { const char *p = &argv[i][2]; if (!strcmp(p, "ast")) flag_fast = 1; else if (!strcmp(p, "astf")) flag_fastf = 1; else if (!strcmp(p, "astcp")) flag_fastcp = 1; } } if (flag_fast || flag_fastf || flag_fastcp ) { optimize = 3; optimize_size = 0; /* This goes here, rather than in rs6000.c, so that later -fcommon can override it. */ if (flag_fast || flag_fastcp) flag_no_common = 1; } /* APPLE LOCAL end -fast or -fastf or -fastcp */ set_flags_from_O (true); /* APPLE LOCAL end optimization pragmas 3124235/3420242 */ /* Initialize whether `char' is signed. */ flag_signed_char = DEFAULT_SIGNED_CHAR; /* Set this to a special "uninitialized" value. The actual default is set after target options have been processed. */ flag_short_enums = 2; /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can modify it. */ target_flags = 0; set_target_switch (""); /* APPLE LOCAL begin LLVM */ /* Some tagets have ABI-specified unwind tables. */ flag_unwind_tables = targetm.unwind_tables_default; /* APPLE LOCAL end LLVM */ #ifdef OPTIMIZATION_OPTIONS /* Allow default optimizations to be specified on a per-machine basis. */ OPTIMIZATION_OPTIONS (optimize, optimize_size); #endif /* APPLE LOCAL begin AV 3846092 */ /* We have apple local patch to disable -fstrict-aliasing when -O2 is used. However do not disable it when -ftree-vectorize is used. Clobber its value here to catch command line use of strict aliasing option. */ saved_flag_strict_aliasing = flag_strict_aliasing; flag_strict_aliasing = 9; /* APPLE LOCAL end AV 3846092 */ handle_options (argc, argv, lang_mask); if (flag_pie) flag_pic = flag_pie; if (flag_pic && !flag_pie) flag_shlib = 1; if (flag_no_inline == 2) flag_no_inline = 0; else flag_really_no_inline = flag_no_inline; /* Set flag_no_inline before the post_options () hook. The C front ends use it to determine tree inlining defaults. FIXME: such code should be lang-independent when all front ends use tree inlining, in which case it, and this condition, should be moved to the top of process_options() instead. */ if (optimize == 0) { /* Inlining does not work if not optimizing, so force it not to be done. */ flag_no_inline = 1; warn_inline = 0; /* The c_decode_option function and decode_option hook set this to `2' if -Wall is used, so we can avoid giving out lots of errors for people who don't realize what -Wall does. */ if (warn_uninitialized == 1) warning ("-Wuninitialized is not supported without -O"); } if (flag_really_no_inline == 2) flag_really_no_inline = flag_no_inline; /* The optimization to partition hot and cold basic blocks into separate sections of the .o and executable files does not work (currently) with exception handling. If flag_exceptions is turned on we need to turn off the partitioning optimization. */ if (flag_exceptions && flag_reorder_blocks_and_partition) { warning ("-freorder-blocks-and-partition does not work with exceptions"); flag_reorder_blocks_and_partition = 0; flag_reorder_blocks = 1; } /* The optimization to partition hot and cold basic blocks into separate sections of the .o and executable files does not currently work correctly with DWARF debugging turned on. Until this is fixed we will disable the optimization when DWARF debugging is set. */ if (flag_reorder_blocks_and_partition && write_symbols == DWARF2_DEBUG) { warning ("-freorder-blocks-and-partition does not work with -g (currently)"); flag_reorder_blocks_and_partition = 0; flag_reorder_blocks = 1; } /* APPLE LOCAL begin AV 3846092 */ /* We have apple local patch to disable -fstrict-aliasing when -O2 is used. Do not disable it when -ftree-vectorize is used. */ if (optimize >= 2 && flag_tree_vectorize) { /* If user explicitly requested to turn off strict aliasing then ignore user request in this case. However issue warning to remind user that -ftree-vectorize and -fno-strict-aliasing are conflicting options. In this situation, -ftree-vectorize wins. */ if (flag_strict_aliasing == 0) warning ("-ftree-vectorize enables strict aliasing. -fno-strict-aliasing is ignored when Auto Vectorization is used."); flag_strict_aliasing = 1; } else if (flag_strict_aliasing == 9) /* User did not use any strict aliasing related command line option. Restore saved value of this flag. */ flag_strict_aliasing = saved_flag_strict_aliasing; /* APPLE LOCAL end AV 3846092 */ /* APPLE LOCAL begin 4224227, 4231773 */ if (!optimize_size_z) optimize_size = 0; /* APPLE LOCAL end 4224227, 4231773 */ }
/* Parse command line options and set default flag values. Do minimal options processing. */ void decode_options (unsigned int argc, const char **argv) { unsigned int i, lang_mask; /* Perform language-specific options initialization. */ lang_mask = lang_hooks.init_options (argc, argv); lang_hooks.initialize_diagnostics (global_dc); /* Scan to see what optimization level has been specified. That will determine the default value of many flags. */ for (i = 1; i < argc; i++) { if (!strcmp (argv[i], "-O")) { optimize = 1; optimize_size = 0; } else if (argv[i][0] == '-' && argv[i][1] == 'O') { /* Handle -Os, -O2, -O3, -O69, ... */ const char *p = &argv[i][2]; if ((p[0] == 's') && (p[1] == 0)) { optimize_size = 1; /* Optimizing for size forces optimize to be 2. */ optimize = 2; } else { const int optimize_val = read_integral_parameter (p, p - 2, -1); if (optimize_val != -1) { optimize = optimize_val; optimize_size = 0; } } } } if (!optimize) { flag_merge_constants = 0; } if (optimize >= 1) { flag_defer_pop = 1; #ifdef DELAY_SLOTS flag_delayed_branch = 1; #endif #ifdef CAN_DEBUG_WITHOUT_FP flag_omit_frame_pointer = 1; #endif flag_guess_branch_prob = 1; flag_cprop_registers = 1; flag_loop_optimize = 1; flag_if_conversion = 1; flag_if_conversion2 = 1; flag_tree_ccp = 1; flag_tree_dce = 1; flag_tree_dom = 1; flag_tree_dse = 1; flag_tree_ter = 1; flag_tree_live_range_split = 1; flag_tree_sra = 1; flag_tree_copyrename = 1; flag_tree_fre = 1; if (!optimize_size) { /* Loop header copying usually increases size of the code. This used not to be true, since quite often it is possible to verify that the condition is satisfied in the first iteration and therefore to eliminate it. Jump threading handles these cases now. */ flag_tree_ch = 1; } } if (optimize >= 2) { flag_thread_jumps = 1; flag_crossjumping = 1; flag_optimize_sibling_calls = 1; flag_cse_follow_jumps = 1; flag_cse_skip_blocks = 1; flag_gcse = 1; flag_expensive_optimizations = 1; flag_strength_reduce = 1; flag_rerun_cse_after_loop = 1; flag_rerun_loop_opt = 1; flag_caller_saves = 1; flag_force_mem = 1; flag_peephole2 = 1; #ifdef INSN_SCHEDULING flag_schedule_insns = 1; flag_schedule_insns_after_reload = 1; #endif flag_regmove = 1; flag_strict_aliasing = 1; flag_delete_null_pointer_checks = 1; flag_reorder_blocks = 1; flag_reorder_functions = 1; flag_unit_at_a_time = 1; if (!optimize_size) { /* PRE tends to generate bigger code. */ flag_tree_pre = 1; } } if (optimize >= 3) { flag_inline_functions = 1; flag_unswitch_loops = 1; flag_gcse_after_reload = 1; } if (optimize < 2 || optimize_size) { align_loops = 1; align_jumps = 1; align_labels = 1; align_functions = 1; /* Don't reorder blocks when optimizing for size because extra jump insns may be created; also barrier may create extra padding. More correctly we should have a block reordering mode that tried to minimize the combined size of all the jumps. This would more or less automatically remove extra jumps, but would also try to use more short jumps instead of long jumps. */ flag_reorder_blocks = 0; flag_reorder_blocks_and_partition = 0; } if (optimize_size) { /* Inlining of very small functions usually reduces total size. */ set_param_value ("max-inline-insns-single", 5); set_param_value ("max-inline-insns-auto", 5); flag_inline_functions = 1; /* We want to crossjump as much as possible. */ set_param_value ("min-crossjump-insns", 1); } /* Initialize whether `char' is signed. */ flag_signed_char = DEFAULT_SIGNED_CHAR; /* Set this to a special "uninitialized" value. The actual default is set after target options have been processed. */ flag_short_enums = 2; /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can modify it. */ target_flags = 0; set_target_switch (""); /* Unwind tables are always present when a target has ABI-specified unwind tables, so the default should be ON. */ #ifdef TARGET_UNWIND_INFO flag_unwind_tables = TARGET_UNWIND_INFO; #endif #ifdef OPTIMIZATION_OPTIONS /* Allow default optimizations to be specified on a per-machine basis. */ OPTIMIZATION_OPTIONS (optimize, optimize_size); #endif handle_options (argc, argv, lang_mask); if (flag_pie) flag_pic = flag_pie; if (flag_pic && !flag_pie) flag_shlib = 1; if (flag_no_inline == 2) flag_no_inline = 0; else flag_really_no_inline = flag_no_inline; /* Set flag_no_inline before the post_options () hook. The C front ends use it to determine tree inlining defaults. FIXME: such code should be lang-independent when all front ends use tree inlining, in which case it, and this condition, should be moved to the top of process_options() instead. */ if (optimize == 0) { /* Inlining does not work if not optimizing, so force it not to be done. */ flag_no_inline = 1; warn_inline = 0; /* The c_decode_option function and decode_option hook set this to `2' if -Wall is used, so we can avoid giving out lots of errors for people who don't realize what -Wall does. */ if (warn_uninitialized == 1) warning ("-Wuninitialized is not supported without -O"); } if (flag_really_no_inline == 2) flag_really_no_inline = flag_no_inline; /* The optimization to partition hot and cold basic blocks into separate sections of the .o and executable files does not work (currently) with exception handling. If flag_exceptions is turned on we need to turn off the partitioning optimization. */ if (flag_exceptions && flag_reorder_blocks_and_partition) { warning ("-freorder-blocks-and-partition does not work with exceptions"); flag_reorder_blocks_and_partition = 0; flag_reorder_blocks = 1; } /* The optimization to partition hot and cold basic blocks into separate sections of the .o and executable files does not currently work correctly with DWARF debugging turned on. Until this is fixed we will disable the optimization when DWARF debugging is set. */ if (flag_reorder_blocks_and_partition && write_symbols == DWARF2_DEBUG) { warning ("-freorder-blocks-and-partition does not work with -g (currently)"); flag_reorder_blocks_and_partition = 0; flag_reorder_blocks = 1; } }