[sledge] Give more specific names to `-output` flags

Summary: This also improves the cli parser's prefix-based disambiguation.

Reviewed By: kren1

Differential Revision: D16060635

fbshipit-source-id: 626f93641
master
Josh Berdine 6 years ago committed by Facebook Github Bot
parent 39fe848146
commit 03e338b2b9

@ -45,16 +45,16 @@ Analyze code in a buck target. This is a convenience wrapper for the sequence `s
=== flags ===
[-bound <int>] stop execution exploration at depth <int>
[-function-summaries] use function summaries (in development)
[-lib-fuzzer] add a harness for lib fuzzer binaries
[-output-llair <file>] write generated LLAIR to <file>
[-output-modules <file>] write list of bitcode files to <file>, or to
standard output if <file> is `-`
[-skip-throw] do not explore past throwing an exception
[-trace <spec>] enable debug tracing
[-help] print this help text and exit
(alias: -?)
[-bound <int>] stop execution exploration at depth <int>
[-function-summaries] use function summaries (in development)
[-lib-fuzzer] add a harness for lib fuzzer binaries
[-llair-output <file>] write generated LLAIR to <file>
[-modules <file>] write list of bitcode files to <file>, or to standard
output if <file> is `-`
[-skip-throw] do not explore past throwing an exception
[-trace <spec>] enable debug tracing
[-help] print this help text and exit
(alias: -?)
====== sledge buck bitcode ======
@ -67,11 +67,11 @@ Build a buck target and report the included bitcode files.
=== flags ===
[-output-modules <file>] write list of bitcode files to <file>, or to
standard output if <file> is `-`
[-trace <spec>] enable debug tracing
[-help] print this help text and exit
(alias: -?)
[-modules <file>] write list of bitcode files to <file>, or to standard
output if <file> is `-`
[-trace <spec>] enable debug tracing
[-help] print this help text and exit
(alias: -?)
====== sledge buck link ======
@ -84,13 +84,13 @@ Link code in a buck target to a single LLVM bitcode module. This also internaliz
=== flags ===
-output <file> write linked output to <file>
[-lib-fuzzer] add a harness for lib fuzzer binaries
[-output-modules <file>] write list of bitcode files to <file>, or to
standard output if <file> is `-`
[-trace <spec>] enable debug tracing
[-help] print this help text and exit
(alias: -?)
-bitcode-output <file> write linked bitcode to <file>
[-lib-fuzzer] add a harness for lib fuzzer binaries
[-modules <file>] write list of bitcode files to <file>, or to standard
output if <file> is `-`
[-trace <spec>] enable debug tracing
[-help] print this help text and exit
(alias: -?)
====== sledge llvm ======
@ -121,7 +121,7 @@ Analyze code in one or more LLVM bitcode files. This is a convenience wrapper fo
[-bound <int>] stop execution exploration at depth <int>
[-function-summaries] use function summaries (in development)
[-lib-fuzzer] add a harness for lib fuzzer binaries
[-output-llair <file>] write generated LLAIR to <file>
[-llair-output <file>] write generated LLAIR to <file>
[-skip-throw] do not explore past throwing an exception
[-trace <spec>] enable debug tracing
[-help] print this help text and exit
@ -139,7 +139,7 @@ Translate one or more LLVM bitcode files to LLAIR. Each <input> filename may be
=== flags ===
[-lib-fuzzer] add a harness for lib fuzzer binaries
[-output-llair <file>] write generated LLAIR to <file>
[-llair-output <file>] write generated LLAIR to <file>
[-trace <spec>] enable debug tracing
[-help] print this help text and exit
(alias: -?)
@ -173,11 +173,11 @@ The <input> file must be LLAIR code, as produced by `sledge llvm translate`.
=== flags ===
[-output <file>] write generated textual LLAIR to <file>, or to standard
output if omitted
[-trace <spec>] enable debug tracing
[-help] print this help text and exit
(alias: -?)
[-llair <file>] write generated textual LLAIR to <file>, or to standard
output if omitted
[-trace <spec>] enable debug tracing
[-help] print this help text and exit
(alias: -?)
====== sledge version ======

@ -85,15 +85,15 @@ let analyze_cmd =
command ~summary ~readme param
let translate =
let%map_open output =
flag "output-llair" (optional string)
let%map_open llair_output =
flag "llair-output" (optional string)
~doc:"<file> write generated LLAIR to <file>"
and lib_fuzzer_harness =
flag "lib-fuzzer" no_arg ~doc:"add a harness for lib fuzzer binaries"
in
fun bitcode_inputs () ->
let program = Frontend.translate ~lib_fuzzer_harness bitcode_inputs in
Option.iter ~f:(marshal program) output ;
Option.iter ~f:(marshal program) llair_output ;
program
let llvm_grp =
@ -147,15 +147,15 @@ let disassemble_cmd =
in
let param =
let%map_open input = anon ("<input>" %: string)
and output =
flag "output" (optional string)
and llair =
flag "llair" (optional string)
~doc:
"<file> write generated textual LLAIR to <file>, or to standard \
output if omitted"
in
fun () ->
let program = unmarshal input () in
match output with
match llair with
| None -> Format.printf "%a@." Llair.pp program
| Some file ->
Out_channel.with_file file ~f:(fun oc ->

@ -141,7 +141,7 @@ let bitcode_files_of ~target =
List.map ~f:(make_absolute (Lazy.force buck_root)) modules
(* link and optimize the modules *)
let llvm_link_opt ~lib_fuzzer_harness ~output modules =
let llvm_link_opt ~lib_fuzzer_harness ~bitcode_output modules =
let context = context () in
let modules = if lib_fuzzer_harness then "-" :: modules else modules in
let open Process in
@ -157,7 +157,7 @@ let llvm_link_opt ~lib_fuzzer_harness ~output modules =
:: "-o=-" :: modules )
|- run
(Lazy.force llvm_bin ^ "opt")
[ "-o=" ^ output; "-globaldce"; "-globalopt"; "-mergefunc"
[ "-o=" ^ bitcode_output; "-globaldce"; "-globalopt"; "-mergefunc"
; "-constmerge"; "-argpromotion"; "-ipsccp"; "-mem2reg"; "-dce"
; "-globaldce"; "-deadargelim" ] )
@ -175,14 +175,14 @@ let main ~(command : unit Command.basic_command) ~analyze =
let target_flag = Command.Param.(anon ("<target>" %: string)) in
let bitcode_inputs =
let%map_open target = target_flag
and output =
flag "output-modules" (optional string)
and modules =
flag "modules" (optional string)
~doc:
"<file> write list of bitcode files to <file>, or to standard \
output if <file> is `-`"
in
let bitcode_files = bitcode_files_of ~target in
( match output with
( match modules with
| Some "-" ->
Format.printf "%a"
(List.pp " " Format.pp_print_string)
@ -216,14 +216,14 @@ let main ~(command : unit Command.basic_command) ~analyze =
also internalizes all symbols except `main` and removes dead code."
in
let link =
let%map_open output =
flag "output" (required abs_path_arg)
~doc:"<file> write linked output to <file>"
let%map_open bitcode_output =
flag "bitcode-output" (required abs_path_arg)
~doc:"<file> write linked bitcode to <file>"
and lib_fuzzer_harness =
flag "lib-fuzzer" no_arg
~doc:"add a harness for lib fuzzer binaries"
in
fun () -> llvm_link_opt ~lib_fuzzer_harness ~output
fun () -> llvm_link_opt ~lib_fuzzer_harness ~bitcode_output
in
let param = bitcode_inputs |**> link in
command ~summary ~readme param

Loading…
Cancel
Save