LLVM-EXTRACT(1)

πŸ’… llvm-extract β€” the manual page, but make it make sense

okay so real talk, this is llvm-extract from the LLVM manual set (that's the LLVM-EXTRACT(1) header energy right there), and it's genuinely one of the most useful little gremlin tools in the whole suite. let's get into it 🫢


✨ NAME ✨

llvm-extract β€” extract a function from an LLVM module. that's it. that's the whole job. and it ate. πŸ‘‘


🌸 SYNOPSIS 🌸

llvm-extract [options] --func function-name [filename]

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so picture this: llvm-extract takes the name of a function and pulls it out of the LLVM bitcode file you point it at. literally just yoink βœ‚οΈ

its main character purpose? debugging. it's a test-case-reduction tool β€” when some giant program is triggering a bug and you're drowning in a million lines of bitcode, you use this to shrink it down to just the interesting bits. big "cut the filler, keep the plot" energy fr fr.

and it's not just the function itself, bestie β€” it also cleans up after itself: any unreachable global variables, prototypes, and unused types get removed too. it's giving responsible roommate. 🧹✨

input handling, super simple:

  • no filename? reads from standard input.
  • filename is -? also reads from standard input.
  • output? always standard output, unless you pass -o (see below, iykyk).

πŸ’– OPTIONS πŸ’–

  • --alias alias-name β€” extract the alias named function-name from the LLVM bitcode. (yes, the page literally says function-name in this description β€” we're keeping the facts exactly as written, bestie πŸ’€). can be specified multiple times to extract multiple aliases at once.
  • --ralias alias-regular-expr β€” extract the alias matching alias-regular-expr from the LLVM bitcode. all aliases matching that regular expression get extracted. can be specified multiple times.
  • --bb basic-block-specifier β€” extract the basic block(s) specified in basic-block-specifier. can be specified multiple times. each <function:bb[;bb]> specifier pair creates a function. and heads up: if multiple basic blocks are specified in one pair, the first block in the sequence should dominate the rest. no cap, that one matters.
  • --delete β€” delete the specified Globals from the Module. πŸ—‘οΈ
  • -f β€” enable binary output on terminals. normally llvm-extract will refuse to write raw bitcode output if the output stream is a terminal (it's protecting you from yourself, honestly). with this flag it writes raw bitcode regardless of the output device. use responsibly, bestie 😭
  • --func function-name β€” extract the function named function-name from the LLVM bitcode. can be specified multiple times to extract multiple functions at once. this is the classic, the staple, the go-to.
  • --rfunc function-regular-expr β€” extract the function(s) matching function-regular-expr from the LLVM bitcode. all functions matching the regular expression get extracted. can be specified multiple times.
  • --glob global-name β€” extract the global variable named global-name from the LLVM bitcode. can be specified multiple times to grab multiple globals at once.
  • --rglob glob-regular-expr β€” extract the global variable(s) matching global-regular-expr from the LLVM bitcode. all globals matching the regular expression get extracted. can be specified multiple times.
  • --keep-const-init β€” preserve the values of constant globals. 🫢
  • --recursive β€” recursively extract all called functions. the way this one just keeps pulling in more functions… it's giving completionist. πŸ”₯
  • -help β€” print a summary of command line options. when in doubt, ask for help, that's growth. πŸ’œ
  • -o filename β€” specify the output filename. if filename is "-" (the default), then llvm-extract sends its output to standard output.
  • -S β€” write output in LLVM intermediate language instead of bitcode. textual slay. ✨

πŸŽ€ EXIT STATUS πŸŽ€

  • success? exits with 0. iconic, flawless, no notes. πŸ‘‘
  • error? exits with a non-zero value. 😭 it happens to the best of us.

🌈 SEE ALSO 🌈

  • bugpoint(1) <bugpoint.html> β€” its partner in crime for hunting down bugs. dynamic duo behavior honestly. πŸ¦‹

⭐ Author ⭐

maintained by the LLVM Team (https://llvm.org/). absolute legends, all of them. 🫢


2003-2026, LLVM Project


and that's the whole page, bestie β€” you're now fully fluent. mwah πŸ’‹

okay so tiny sign-off: this is the LLVM version of the page, the one stamped 15 in the corner, dated 2026-09-09, aka LLVM-EXTRACT(1). go reduce some test cases, you've got this. πŸŒΈπŸ’…
πŸ“¦ where this page comes from