LLVM-EXTRACT(1)

πŸ“¦
version 16.0.6 Β· 3 versions
, in ubuntu noble

🌸 NAME 🌸

llvm-extract β€” grab a single function out of an LLVM module, no cap πŸ’…

So bestie, you found your way into the LLVM-EXTRACT(1) page of the LLVM manual β€” section 1, the real one, the command-line one 🫢. This is the tool you call when a giant program is doing something cursed and you just want the one little function that's misbehaving.


✨ SYNOPSIS ✨

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

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the tea, bestie β˜•. llvm-extract takes the name of a function and pulls it out of whatever LLVM bitcode file you point it at. That's the whole vibe.

It's mainly a debugging tool, and its main character moment is reducing test cases β€” like, you've got a massive program that's triggering a bug, and you want to shrink it down to just the guilty little function so you can actually look at it without your brain melting 😭. It's giving lab scientist with tiny tweezers 🧚.

And it doesn't stop at just copying the function out β€” it also sweeps away the stuff nobody needs anymore:

  • unreachable global variables 🧹
  • prototypes 🧹
  • unused types 🧹

Where does it read from? If you skip filename entirely, or if you pass filename as -, it reads its input from standard input. And where does the output go? Always to standard output, unless you say otherwise with the -o option (peep the OPTIONS section below, it's right there πŸ‘€).


πŸ‘‘ OPTIONS πŸ‘‘

Every single one, in order, no skips, periodt πŸ’–

  • –alias alias-name β€” Extract the alias named function-name from the LLVM bitcode. You can hit this one more than once to extract multiple aliases at the same time. (And yes, the page literally says function-name in this one's description, we're not editing the queen's words πŸ’€)
  • –ralias alias-regular-expr β€” Extract the alias matching alias-regular-expr from the LLVM bitcode. All aliases matching that regular expression get extracted. May be specified multiple times.
  • –bb basic-block-specifier β€” Extract the basic block(s) specified in basic-block-specifier. May be specified multiple times. Each <function:bb[;bb]> specifier pair will create a function. And if you list multiple basic blocks inside one pair, the first block in the sequence should dominate the rest πŸ”₯.
  • –delete β€” Delete specified Globals from Module.
  • -f β€” Enable binary output on terminals. Normally llvm-extract will refuse to write raw bitcode output if the output stream is a terminal πŸ™ˆ. With this option, llvm-extract will write raw bitcode regardless of the output device.
  • –func function-name β€” Extract the function named function-name from the LLVM bitcode. May be specified multiple times to extract multiple functions at once. This is the one you'll be typing the most, fr fr.
  • –rfunc function-regular-expr β€” Extract the function(s) matching function-regular-expr from the LLVM bitcode. All functions matching the regular expression will be extracted. May be specified multiple times. Regex girlies, this one's for you πŸŽ€.
  • –glob global-name β€” Extract the global variable named global-name from the LLVM bitcode. May be specified multiple times to extract multiple global variables at once.
  • –rglob glob-regular-expr β€” Extract the global variable(s) matching global-regular-expr from the LLVM bitcode. All global variables matching the regular expression will be extracted. May be specified multiple times.
  • –keep-const-init β€” Preserve the values of constant globals. Don't let them get dropped, bestie 🫢.
  • –recursive β€” Recursively extract all called functions. It's giving "bring the whole friend group" energy 🌈.
  • -help β€” Print a summary of command line options.
  • -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). Human-readable era ✨.

πŸ’€ EXIT STATUS πŸ’€

If llvm-extract succeeds, it will exit with 0 πŸŽ‰. Otherwise, if an error occurs, it will exit with a non-zero value 😭.


⭐ SEE ALSO ⭐


πŸ’œ AUTHOR πŸ’œ

Maintained by the LLVM Team (https://llvm.org/).


2003-2024, LLVM Project


and that's the whole page, bestie β€” go extract something iconic πŸ’…βœ¨πŸ¦‹

tiny sign-off: this whole thing lives in the LLVM manual, version 15, dated 2024-04-14, filed under LLVM-EXTRACT(1). mwah 🫢

πŸ“¦ where this page comes from