LLVM-EXTRACT(1)

πŸ’… llvm-extract β€” extract a function from an LLVM module πŸ‘‘

okay so this is the man page for llvm-extract, bestie, and it lives in the LLVM manual family. let me walk you through it 🫢


🌸 SYNOPSIS 🌸

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

that's the whole vibe. options, then –func plus a function name, then optionally a filename. iconic ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

so llvm-extract takes the name of a function and pulls it out of the LLVM bitcode file you point it at. it's primarily a debugging tool β€” think of it as a little scalpel for shrinking test cases out of bigger programs that are triggering a bug. literally so useful ngl πŸ”ͺπŸ’€

and it doesn't just carve out the bitcode of the function you named β€” it also removes unreachable global variables, prototypes, and unused types. cleanup era ✨🧹

also important: llvm-extract reads its input from standard input if filename is omitted, or if filename is -. and the output always goes to standard output, unless you use the -o option (peep below πŸ‘€).


πŸŽ€ OPTIONS πŸŽ€

  • –alias alias-name β€” extracts the alias named function-name from the LLVM bitcode. yes, the page really says function-name there, don't come for me πŸ’€ it may be specified multiple times to extract multiple alias at once. slay πŸ’…
  • –ralias alias-regular-expr β€” extracts the alias matching alias-regular-expr from the LLVM bitcode. every alias matching the regular expression gets extracted. may be specified multiple times. regex girlies rise 🌈
  • –bb basic-block-specifier β€” extracts basic block(s) specified in basic-block-specifier. may be specified multiple times. each <function:bb[;bb]> specifier pair will create a function. if multiple basic blocks are specified in one pair, the first block in the sequence should dominate the rest β€” that's a real constraint, don't ignore it bestie 😭
  • –delete β€” delete specified Globals from Module. simple as that πŸ—‘οΈ
  • -f β€” enable binary output on terminals. normally llvm-extract refuses to write raw bitcode output if the output stream is a terminal, but with this option it'll write raw bitcode regardless of the output device. it's giving "I know what I'm doing" energy πŸ”₯
  • –func function-name β€” extracts the function named function-name from the LLVM bitcode. may be specified multiple times to extract multiple functions at once. the main character option, honestly πŸ‘‘
  • –rfunc function-regular-expr β€” extracts 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. batch extraction, we love to see it πŸ’–
  • –glob global-name β€” extracts 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 β€” extracts 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. no cap, this one keeps your constants intact πŸŽ€
  • –recursive β€” recursively extract all called functions. it goes deep, bestie πŸŒ€
  • -help β€” print a summary of command line options. when in doubt 🫢
  • -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, we stan πŸ‘€βœ¨
⚠️ friendly reminder that -f is the one that overrides the terminal safety check for raw bitcode output β€” the default behavior is to refuse, so only flex it when you mean it πŸ’…

πŸ’€ EXIT STATUS πŸ’€

if llvm-extract succeeds, it exits with 0. otherwise, if an error occurs, it exits with a non-zero value. that's it, that's the check 🫑


πŸ”— SEE ALSO πŸ”—


🌟 AUTHOR 🌟

maintained by the LLVM Team (https://llvm.org/). absolute legends πŸ«ΆπŸ‘‘


2003-2023, LLVM Project


okay that's the whole page bestie, you're officially an llvm-extract expert now πŸ’œ mwah πŸ’‹ β€” page 15, dated 2023-07-14, from the LLVM manual, for LLVM-EXTRACT(1). go forth and shrink those test cases πŸ¦‹βœ¨

πŸ“¦ where this page comes from