blob: 8e23e70cc4020052bdf38f7a8690bfc1870ae54e [file] [log] [blame]
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +00001llvm-extract - extract a function from an LLVM module
2=====================================================
3
James Hendersona0566842019-06-27 13:24:46 +00004.. program:: llvm-extract
5
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +00006SYNOPSIS
7--------
8
Dmitri Gribenko8cac8352013-08-18 08:32:32 +00009:program:`llvm-extract` [*options*] **--func** *function-name* [*filename*]
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000010
11DESCRIPTION
12-----------
13
Dmitri Gribenko8cac8352013-08-18 08:32:32 +000014The :program:`llvm-extract` command takes the name of a function and extracts
15it from the specified LLVM bitcode file. It is primarily used as a debugging
16tool to reduce test cases from larger programs that are triggering a bug.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000017
18In addition to extracting the bitcode of the specified function,
Dmitri Gribenko8cac8352013-08-18 08:32:32 +000019:program:`llvm-extract` will also remove unreachable global variables,
20prototypes, and unused types.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000021
Dmitri Gribenko8cac8352013-08-18 08:32:32 +000022The :program:`llvm-extract` command reads its input from standard input if
23filename is omitted or if filename is ``-``. The output is always written to
24standard output, unless the **-o** option is specified (see below).
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000025
26OPTIONS
27-------
28
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000029**-f**
30
Dmitri Gribenko8cac8352013-08-18 08:32:32 +000031 Enable binary output on terminals. Normally, :program:`llvm-extract` will
32 refuse to write raw bitcode output if the output stream is a terminal. With
33 this option, :program:`llvm-extract` will write raw bitcode regardless of the
34 output device.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000035
36**--func** *function-name*
37
Dmitri Gribenko8cac8352013-08-18 08:32:32 +000038 Extract the function named *function-name* from the LLVM bitcode. May be
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000039 specified multiple times to extract multiple functions at once.
40
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000041**--rfunc** *function-regular-expr*
42
43 Extract the function(s) matching *function-regular-expr* from the LLVM bitcode.
44 All functions matching the regular expression will be extracted. May be
45 specified multiple times.
46
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000047**--glob** *global-name*
48
Dmitri Gribenko8cac8352013-08-18 08:32:32 +000049 Extract the global variable named *global-name* from the LLVM bitcode. May be
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000050 specified multiple times to extract multiple global variables at once.
51
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000052**--rglob** *glob-regular-expr*
53
54 Extract the global variable(s) matching *global-regular-expr* from the LLVM
Dmitri Gribenko8cac8352013-08-18 08:32:32 +000055 bitcode. All global variables matching the regular expression will be
56 extracted. May be specified multiple times.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000057
Juneyoung Lee578d2e22020-02-02 02:34:10 +090058**--keep-const-init**
59
60 Preserve the values of constant globals.
61
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000062**-help**
63
64 Print a summary of command line options.
65
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000066**-o** *filename*
67
68 Specify the output filename. If filename is "-" (the default), then
Dmitri Gribenko8cac8352013-08-18 08:32:32 +000069 :program:`llvm-extract` sends its output to standard output.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000070
71**-S**
72
73 Write output in LLVM intermediate language (instead of bitcode).
74
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000075EXIT STATUS
76-----------
77
Dmitri Gribenko8cac8352013-08-18 08:32:32 +000078If :program:`llvm-extract` succeeds, it will exit with 0. Otherwise, if an error
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000079occurs, it will exit with a non-zero value.
80
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000081SEE ALSO
82--------
83
Alex Brachet09a066b2019-07-04 21:19:05 +000084:manpage:`bugpoint(1)`