Skip to content

Commit 0bd539a

Browse files
mshinwelldra27
authored andcommitted
GPR#2082: New option -no-insn-sched
1 parent baa1888 commit 0bd539a

File tree

11 files changed

+44
-2
lines changed

11 files changed

+44
-2
lines changed

Changes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,10 @@ OCaml 4.08.0
464464
- MPR#6242, GPR#2143: optimize some local functions
465465
(Alain Frisch, review by Gabriel Scherer)
466466

467+
- GPR#2082: New options [-insn-sched] and [-no-insn-sched] to control
468+
instruction scheduling.
469+
(Mark Shinwell, review by Damien Doligez)
470+
467471
- GPR#2239: Fix match miscompilation with flambda
468472
(Leo White, review by Alain Frisch)
469473

asmcomp/schedgen.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ method schedule_fundecl f =
384384
self#reschedule ready_queue 0 (schedule i try_nesting)
385385
end in
386386

387-
if f.fun_fast then begin
387+
if f.fun_fast && !Clflags.insn_sched then begin
388388
let new_body = schedule f.fun_body 0 in
389389
clear_code_dag();
390390
{ fun_name = f.fun_name;

driver/compenv.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,8 @@ let read_one_param ppf position name v =
339339
set "flambda-invariants" [ flambda_invariant_checks ] v
340340
| "linscan" ->
341341
set "linscan" [ use_linscan ] v
342+
| "insn-sched" -> set "insn-sched" [ insn_sched ] v
343+
| "no-insn-sched" -> clear "insn-sched" [ insn_sched ] v
342344

343345
(* color output *)
344346
| "color" ->

driver/main_args.ml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,18 @@ let mk_intf_suffix_2 f =
245245
"-intf_suffix", Arg.String f, "<string> (deprecated) same as -intf-suffix"
246246
;;
247247

248+
let mk_insn_sched f =
249+
"-insn-sched", Arg.Unit f,
250+
Printf.sprintf " Run the instruction scheduling pass%s"
251+
(if Clflags.insn_sched_default then " (default)" else "")
252+
;;
253+
254+
let mk_no_insn_sched f =
255+
"-no-insn-sched", Arg.Unit f,
256+
Printf.sprintf " Do not run the instruction scheduling pass%s"
257+
(if not Clflags.insn_sched_default then " (default)" else "")
258+
;;
259+
248260
let mk_keep_docs f =
249261
"-keep-docs", Arg.Unit f, " Keep documentation strings in .cmi files"
250262
;;
@@ -1002,6 +1014,8 @@ module type Optcommon_options = sig
10021014
val _no_unbox_specialised_args : unit -> unit
10031015
val _o2 : unit -> unit
10041016
val _o3 : unit -> unit
1017+
val _insn_sched : unit -> unit
1018+
val _no_insn_sched : unit -> unit
10051019

10061020
val _clambda_checks : unit -> unit
10071021
val _dflambda : unit -> unit
@@ -1280,6 +1294,7 @@ struct
12801294
mk_inline_indirect_cost F._inline_indirect_cost;
12811295
mk_inline_lifting_benefit F._inline_lifting_benefit;
12821296
mk_inlining_report F._inlining_report;
1297+
mk_insn_sched F._insn_sched;
12831298
mk_intf F._intf;
12841299
mk_intf_suffix F._intf_suffix;
12851300
mk_keep_docs F._keep_docs;
@@ -1298,6 +1313,7 @@ struct
12981313
mk_noassert F._noassert;
12991314
mk_noautolink_opt F._noautolink;
13001315
mk_nodynlink F._nodynlink;
1316+
mk_no_insn_sched F._no_insn_sched;
13011317
mk_nolabels F._nolabels;
13021318
mk_nostdlib F._nostdlib;
13031319
mk_nopervasives F._nopervasives;

driver/main_args.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ module type Optcommon_options = sig
178178
val _no_unbox_specialised_args : unit -> unit
179179
val _o2 : unit -> unit
180180
val _o3 : unit -> unit
181+
val _insn_sched : unit -> unit
182+
val _no_insn_sched : unit -> unit
181183

182184
val _clambda_checks : unit -> unit
183185
val _dflambda : unit -> unit

driver/optmain.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ module Options = Main_args.Make_optcomp_options (struct
118118
Float_arg_helper.parse spec
119119
"Syntax: -inline-branch-factor <n> | <round>=<n>[,...]"
120120
inline_branch_factor
121-
let _intf = intf
122121
let _intf_suffix s = Config.interface_suffix := s
122+
let _insn_sched = set insn_sched
123+
let _intf = intf
123124
let _keep_docs = set keep_docs
124125
let _no_keep_docs = clear keep_docs
125126
let _keep_locs = set keep_locs
@@ -139,6 +140,7 @@ module Options = Main_args.Make_optcomp_options (struct
139140
let _noassert = set noassert
140141
let _noautolink = set no_auto_link
141142
let _nodynlink = clear dlcode
143+
let _no_insn_sched = clear insn_sched
142144
let _nolabels = set classic
143145
let _nostdlib = set no_std_include
144146
let _no_unbox_free_vars_of_closures = clear unbox_free_vars_of_closures

man/ocamlopt.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,9 @@ and libraries (.cmxa). By default, the current directory is searched
349349
option cause larger and larger functions to become candidate for
350350
inlining, but can result in a serious increase in code size.
351351
.TP
352+
.B \-insn\-sched
353+
Enables the instruction scheduling pass in the compiler backend.
354+
.TP
352355
.BI \-intf \ filename
353356
Compile the file
354357
.I filename
@@ -426,6 +429,9 @@ options potentially contained in the libraries (if these options were
426429
Allow the compiler to use some optimizations that are valid only for code
427430
that is never dynlinked.
428431
.TP
432+
.B \-no\-insn\-sched
433+
Disables the instruction scheduling pass in the compiler backend.
434+
.TP
429435
.B -nostdlib
430436
Do not automatically add the standard library directory to the list of
431437
directories searched for compiled interface files (.cmi), compiled

tools/ocamloptp.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ module Options = Main_args.Make_optcomp_options (struct
6969
let _inline_lifting_benefit = ignore
7070
let _inline_branch_factor = ignore
7171
let _classic_inlining = ignore
72+
let _insn_sched = ignore
7273
let _intf _ = with_intf := true
7374
let _intf_suffix = ignore
7475
let _keep_docs = ignore
@@ -85,6 +86,7 @@ module Options = Main_args.Make_optcomp_options (struct
8586
let _noassert = ignore
8687
let _noautolink = ignore
8788
let _nodynlink = ignore
89+
let _no_insn_sched = ignore
8890
let _nolabels = ignore
8991
let _nostdlib = ignore
9092
let _no_unbox_free_vars_of_closures = ignore

toplevel/opttopmain.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ module Options = Main_args.Make_opttop_options (struct
153153
Int_arg_helper.parse spec
154154
"Syntax: -inline-max-depth <n> | <round>=<n>[,...]"
155155
inline_max_depth
156+
let _insn_sched = set insn_sched
157+
let _no_insn_sched = clear insn_sched
156158
let _no_unbox_free_vars_of_closures = clear unbox_free_vars_of_closures
157159
let _no_unbox_specialised_args = clear unbox_specialised_args
158160
let _o s = output_name := Some s

utils/clflags.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ let flambda_invariant_checks =
144144

145145
let dont_write_files = ref false (* set to true under ocamldoc *)
146146

147+
let insn_sched_default = true
148+
let insn_sched = ref insn_sched_default (* -[no-]insn-sched *)
149+
147150
let std_include_flag prefix =
148151
if !no_std_include then ""
149152
else (prefix ^ (Filename.quote Config.standard_library))

0 commit comments

Comments
 (0)