[sledge] Put all the entry points in the config

Summary:
The entry point functions are used in a couple of places, this
puts them in a single source of truth in the config file.

Reviewed By: jvillard

Differential Revision: D15651976

fbshipit-source-id: a572e8d4d
master
Timotej Kapus 6 years ago committed by Facebook Github Bot
parent b9ba97a2fd
commit 9ef992394c

1
sledge/.gitignore vendored

@ -3,6 +3,7 @@
/llvm/ /llvm/
/model/dune /model/dune
/src/dune /src/dune
/src/config/dune
/src/import/dune /src/import/dune
/src/llair/dune /src/llair/dune
/src/symbheap/dune /src/symbheap/dune

@ -30,6 +30,9 @@ let contents =
let find key = Yojson.Basic.Util.(to_string_option (member key contents)) let find key = Yojson.Basic.Util.(to_string_option (member key contents))
let find_list key =
Yojson.Basic.Util.(filter_string (to_list (member key contents)))
let find_exn key = let find_exn key =
match find key with match find key with
| Some data -> data | Some data -> data

@ -9,3 +9,4 @@
val find : string -> string option val find : string -> string option
val find_exn : string -> string val find_exn : string -> string
val find_list : string -> string list

@ -0,0 +1,22 @@
(* -*- tuareg -*- *)
(*
* Copyright (c) 2019-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
let deps = ["import"]
;;
Jbuild_plugin.V1.send
@@ Format.sprintf
{|
(library
(name config)
(public_name llair.config)
%s
(libraries yojson %s))
|}
(flags `lib deps)
(libraries deps)

@ -385,8 +385,9 @@ let exec_block :
let harness : Llair.t -> (int -> Work.t) option = let harness : Llair.t -> (int -> Work.t) option =
fun pgm -> fun pgm ->
List.find_map ["__llair_main"; "_Z12__llair_mainv"; "main"] let entry_points = Config.find_list "entry_points" in
~f:(fun name -> Llair.Func.find pgm.functions (Var.program name)) List.find_map entry_points ~f:(fun name ->
Llair.Func.find pgm.functions (Var.program name) )
|> function |> function
| Some {entry= {params= []} as block} -> | Some {entry= {params= []} as block} ->
Some Some

@ -6,7 +6,7 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*) *)
let deps = ["import"; "llair_"; "symbheap"] let deps = ["import"; "llair_"; "symbheap"; "config"]
;; ;;
Jbuild_plugin.V1.send Jbuild_plugin.V1.send
@ -22,7 +22,7 @@ Jbuild_plugin.V1.send
(public_name sledge) (public_name sledge)
(package sledge) (package sledge)
%s %s
(libraries shexp.process yojson %s)) (libraries shexp.process %s))
|} |}
(flags `exe deps) (flags `exe deps)
(libraries deps) (libraries deps)

@ -6,7 +6,7 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*) *)
let deps = ["model"; "import"; "trace"] let deps = ["model"; "import"; "trace"; "config"]
;; ;;
Jbuild_plugin.V1.send Jbuild_plugin.V1.send

@ -1323,10 +1323,9 @@ let xlate_function : x -> Llvm.llvalue -> Llair.func =
let transform : Llvm.llmodule -> unit = let transform : Llvm.llmodule -> unit =
fun llmodule -> fun llmodule ->
let pm = Llvm.PassManager.create () in let pm = Llvm.PassManager.create () in
let entry_points = Config.find_list "entry_points" in
Llvm_ipo.add_internalize_predicate pm (fun fn -> Llvm_ipo.add_internalize_predicate pm (fun fn ->
List.exists List.exists entry_points ~f:(String.equal fn) ) ;
["__llair_main"; "_Z12__llair_mainv"; "main"]
~f:(String.equal fn) ) ;
Llvm_ipo.add_global_dce pm ; Llvm_ipo.add_global_dce pm ;
Llvm_ipo.add_global_optimizer pm ; Llvm_ipo.add_global_optimizer pm ;
Llvm_scalar_opts.add_lower_atomic pm ; Llvm_scalar_opts.add_lower_atomic pm ;

@ -136,8 +136,10 @@ let llvm_link_opt ~output modules =
eval ~context eval ~context
( run ( run
(Lazy.force llvm_bin ^ "llvm-link") (Lazy.force llvm_bin ^ "llvm-link")
( "-internalize" :: "-internalize-public-api-list=main" :: "-o=-" ( "-internalize"
:: modules ) :: ( "-internalize-public-api-list="
^ String.concat ~sep:"," (Config.find_list "entry_points") )
:: "-o=-" :: modules )
|- run |- run
(Lazy.force llvm_bin ^ "opt") (Lazy.force llvm_bin ^ "opt")
["-o=" ^ output; "-globaldce"; "-globalopt"] ) ["-o=" ^ output; "-globaldce"; "-globalopt"] )

Loading…
Cancel
Save