1llvm-extract - extract a function from an LLVM module
2=====================================================
3
4.. program:: llvm-extract
5
6SYNOPSIS
7--------
8
9:program:`llvm-extract` [*options*] **--func** *function-name* [*filename*]
10
11DESCRIPTION
12-----------
13
14The :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.
17
18In addition to extracting the bitcode of the specified function,
19:program:`llvm-extract` will also remove unreachable global variables,
20prototypes, and unused types.
21
22The :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).
25
26OPTIONS
27-------
28
29**--alias** *alias-name*
30
31 Extract the alias named *function-name* from the LLVM bitcode.  May be
32 specified multiple times to extract multiple alias at once.
33
34**--ralias** *alias-regular-expr*
35
36 Extract the alias matching *alias-regular-expr* from the LLVM bitcode.
37 All alias matching the regular expression will be extracted.  May be
38 specified multiple times.
39
40**--bb** *basic-block-specifier*
41
42 Extract basic blocks(s) specified in *basic-block-specifier*. May be
43 specified multiple times. Each <function:bb[;bb]> specifier pair will create
44 a function. If multiple basic blocks are specified in one pair, the first
45 block in the sequence should dominate the rest.
46
47**--delete**
48
49 Delete specified Globals from Module.
50
51**-f**
52
53 Enable binary output on terminals.  Normally, :program:`llvm-extract` will
54 refuse to write raw bitcode output if the output stream is a terminal.  With
55 this option, :program:`llvm-extract` will write raw bitcode regardless of the
56 output device.
57
58**--func** *function-name*
59
60 Extract the function named *function-name* from the LLVM bitcode.  May be
61 specified multiple times to extract multiple functions at once.
62
63**--rfunc** *function-regular-expr*
64
65 Extract the function(s) matching *function-regular-expr* from the LLVM bitcode.
66 All functions matching the regular expression will be extracted.  May be
67 specified multiple times.
68
69**--glob** *global-name*
70
71 Extract the global variable named *global-name* from the LLVM bitcode.  May be
72 specified multiple times to extract multiple global variables at once.
73
74**--rglob** *glob-regular-expr*
75
76 Extract the global variable(s) matching *global-regular-expr* from the LLVM
77 bitcode.  All global variables matching the regular expression will be
78 extracted.  May be specified multiple times.
79
80**--keep-const-init**
81
82 Preserve the values of constant globals.
83
84**--recursive**
85
86 Recursively extract all called functions
87
88**-help**
89
90 Print a summary of command line options.
91
92**-o** *filename*
93
94 Specify the output filename.  If filename is "-" (the default), then
95 :program:`llvm-extract` sends its output to standard output.
96
97**-S**
98
99 Write output in LLVM intermediate language (instead of bitcode).
100
101EXIT STATUS
102-----------
103
104If :program:`llvm-extract` succeeds, it will exit with 0.  Otherwise, if an error
105occurs, it will exit with a non-zero value.
106
107SEE ALSO
108--------
109
110:manpage:`bugpoint(1)`
111