From bda5ee25ac991c38f5541a234936f1f6e2226072 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Sun, 16 Nov 2014 18:39:43 +0100 Subject: Add flags to control individual optimization passes + flag -O0 for turning them off. --- driver/Driver.ml | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) (limited to 'driver/Driver.ml') diff --git a/driver/Driver.ml b/driver/Driver.ml index 602b01be..76509f41 100644 --- a/driver/Driver.ml +++ b/driver/Driver.ml @@ -393,15 +393,21 @@ Language support options (use -fno- to turn off -f) : -fnone Turn off all language support options above Debugging options: -g Generate debugging information -Code generation options: (use -fno- to turn off -f) : - -O Optimize for speed [on by default] - -Os Optimize for code size +Optimization options: (use -fno- to turn off -f) + -O Optimize the compiled code [on by default] + -O0 Do not optimize the compiled code + -O1 -O2 -O3 Synonymous for -O + -Os Optimize for code size in preference to code speed + -ftailcalls Optimize function calls in tail position [on] + -fconst-prop Perform global constant propagation [on] + -ffloat-const-prop Control constant propagation of floats + (=0: none, =1: limited, =2: full; default is full) + -fcse Perform common subexpression elimination [on] + -fredundancy Perform redundancy elimination [on] +Code generation options: (use -fno- to turn off -f) -ffpu Use FP registers for some integer operations [on] -fsmall-data Set maximal size for allocation in small data area -fsmall-const Set maximal size for allocation in small constant area - -ffloat-const-prop Control constant propagation of floats - (=0: none, =1: limited, =2: full; default is full) - -ftailcalls Optimize function calls in tail position [on] -falign-functions Set alignment (in bytes) of function entry points -falign-branch-targets Set alignment (in bytes) of branch targets -falign-cond-branches Set alignment (in bytes) of conditional branches @@ -442,6 +448,13 @@ let language_support_options = [ option_fpacked_structs; option_finline_asm ] +let optimization_options = [ + option_ftailcalls; option_fconstprop; option_fcse; option_fredundancy +] + +let set_all opts = List.iter (fun r -> r := true) opts +let unset_all opts = List.iter (fun r -> r := false) opts + let num_source_files = ref 0 let cmdline_actions = @@ -483,15 +496,15 @@ let cmdline_actions = Prefix "-Wp,", Self (fun s -> prepro_options := List.rev_append (explode_comma_option s) !prepro_options); (* Language support options -- more below *) - Exact "-fall", Self (fun _ -> - List.iter (fun r -> r := true) language_support_options); - Exact "-fnone", Self (fun _ -> - List.iter (fun r -> r := false) language_support_options); + Exact "-fall", Self (fun _ -> set_all language_support_options); + Exact "-fnone", Self (fun _ -> unset_all language_support_options); (* Debugging options *) Exact "-g", Self (fun s -> option_g := true; push_linker_arg s); (* Code generation options -- more below *) + Exact "-O0", Self (fun _ -> unset_all optimization_options); + Exact "-O", Self (fun _ -> set_all optimization_options); + _Regexp "-O[123]$", Self (fun _ -> set_all optimization_options); Exact "-Os", Set option_Osize; - Exact "-O", Unset option_Osize; Exact "-fsmall-data", Integer(fun n -> option_small_data := n); Exact "-fsmall-const", Integer(fun n -> option_small_const := n); Exact "-ffloat-const-prop", Integer(fun n -> option_ffloatconstprop := n); @@ -538,8 +551,12 @@ let cmdline_actions = @ f_opt "unprototyped" option_funprototyped @ f_opt "packed-structs" option_fpacked_structs @ f_opt "inline-asm" option_finline_asm -(* Code generation options *) +(* Optimization options *) @ f_opt "tailcalls" option_ftailcalls + @ f_opt "const-prop" option_fconstprop + @ f_opt "cse" option_fcse + @ f_opt "redundancy" option_fredundancy +(* Code generation options *) @ f_opt "fpu" option_ffpu @ f_opt "sse" option_ffpu (* backward compatibility *) -- cgit