[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

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

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

Loading…
Cancel
Save