[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/
/model/dune
/src/dune
/src/config/dune
/src/import/dune
/src/llair/dune
/src/symbheap/dune

@ -30,6 +30,9 @@ let 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 =
match find key with
| Some data -> data

@ -9,3 +9,4 @@
val find : string -> string option
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 =
fun pgm ->
List.find_map ["__llair_main"; "_Z12__llair_mainv"; "main"]
~f:(fun name -> Llair.Func.find pgm.functions (Var.program name))
let entry_points = Config.find_list "entry_points" in
List.find_map entry_points ~f:(fun name ->
Llair.Func.find pgm.functions (Var.program name) )
|> function
| Some {entry= {params= []} as block} ->
Some

@ -6,7 +6,7 @@
* 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
@ -22,7 +22,7 @@ Jbuild_plugin.V1.send
(public_name sledge)
(package sledge)
%s
(libraries shexp.process yojson %s))
(libraries shexp.process %s))
|}
(flags `exe deps)
(libraries deps)

@ -6,7 +6,7 @@
* 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

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

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

Loading…
Cancel
Save