LLVM-REMARK-SIZE-DIFF(1)
π LLVM-REMARK-SIZE-DIFF(1) β bestie's guide to diffing size remarks β¨
okay so this is a page from the LLVM manual, and it's genuinely a little hidden gem β it's the llvm-remark-size-diff tool, and no cap, it's giving "which functions got bigger/smaller" main character energy. let's get into it π«Ά
β¨ NAME β¨
llvm-remark-size-diff β it diffs size remarks. that's it. that's the vibe.
πΈ SYNOPSIS πΈ
llvm-remark-size-diff [options] file_a file_b --parser parser
two files, some options, and a --parser β and --parser is required, so don't forget it, bestie π
π DESCRIPTION π
so llvm-remark-size-diff diffs the size remarks in two remark files: file_a and file_b. that's literally the whole gig π
you'd use it to get actual insight into which functions got impacted the most by code generation changes β like, who ate, and who got ate π
in most common use-cases, file_a and file_b are remarks output by compiling a fixed source with differing compilers or differing optimization settings. so same source, different compiler vibes, and this tool spills the tea on the differences.
and the good news? llvm-remark-size-diff handles both YAML and bitstream remarks. versatile icon π
π¦ OPTIONS π¦
--parser=<yaml|bitstream>β pick the type of input remark parser. this one is required, so no skipping it πyaml: the tool will parse YAML remarks.bitstream: the tool will parse bitstream remarks.
--report-style=<human|json>β the output style β¨human: human-readable textual report. this is the default option.json: JSON report.
--prettyβ pretty-print JSON output. optional.- > heads up: if output is not set to JSON, this does literally nothing. like, zero. nada. π
-o=<file>β output file for the report. outputs tostdoutby default.
π HUMAN-READABLE OUTPUT π
the human-readable format for llvm-remark-size-diff is composed of two sections, bestie:
- Per-function changes.
- A high-level summary of all changes.
π Changed Function Section π
suppose you are comparing two remark files OLD and NEW.
for each function with a changed instruction count in OLD and NEW, llvm-remark-size-diff will emit a line like this:
(++|--|==) (>|<) function_name, N instrs, M stack B
a breakdown of the format is below β pay attention, this is the good part π
(++|--|==) which of OLD and NEW the function_name is present in.
++: only inNEW. ("Added") β¨--: only inOLD. ("Removed") π==: in both. π«Ά
(>|<) denotes if function_name has more instructions or fewer instructions in the second file.
>: more instructions in second file than first file.<: fewer instructions in second file than in first file.
function_name the name of the changed function. (iconic, honestly)
N instrs second file instruction count β first file instruction count. i.e. the diff, periodt.
M stack B second file stack byte count β first file stack byte count.
β Summary Section β
llvm-remark-size-diff will output a high-level summary after printing all changed functions. so you get the whole picture at the end, and it's giving finale π¬
instruction count: N (inst_pct_change%)
stack byte usage: M (sb_pct_change%)
N β sum of all instruction count changes between the second and first file.
inst_pct_change% β percent increase or decrease in instruction count between the second and first file.
M β sum of all stack byte count changes between the second and first file.
sb_pct_change% β percent increase or decrease in stack byte usage between the second and first file.
π₯ JSON OUTPUT π₯
π§ High-Level view π§
suppose we are comparing two files, OLD and NEW.
llvm-remark-size-diff will output JSON as follows:
"Files": [
"A": "path/to/OLD",
"B": "path/to/NEW"
]
"InBoth": [
...
],
"OnlyInA": [
...
],
"OnlyInB": [
...
]
Files β original paths to remark files.
A: path to the first file.B: path to the second file.
InBoth β functions present in both files.
OnlyInA β functions only present in the first file.
OnlyInB β functions only present in the second file.
π Function JSON π
the InBoth, OnlyInA, and OnlyInB sections contain size information for each function in the input remark files.
{
"FunctionName" : "function_name"
"InstCount": [
INST_COUNT_A,
INST_COUNT_B
],
"StackSize": [
STACK_BYTES_A,
STACK_BYTES_B
],
}
FunctionName β name of the function.
InstCount β instruction counts for the function.
INST_COUNT_A: instruction count inOLD.INST_COUNT_B: instruction count inNEW.
StackSize β stack byte counts for the function.
STACK_BYTES_A: stack bytes inOLD.STACK_BYTES_B: stack bytes inNEW.
π Computing Diffs From Function JSON π
okay important β Function JSON does not contain the diffs. tools consuming JSON output from llvm-remark-size-diff are responsible for computing the diffs separately. yeah, you gotta do the math yourself, sorry bestie π
to compute the diffs:
- Instruction count diff:
INST_COUNT_B - INST_COUNT_A - Stack byte count diff:
STACK_BYTES_B - STACK_BYTES_A
π EXIT STATUS π
llvm-remark-size-diff returns 0 on success, and a non-zero value otherwise. classic. slay. β¨
π AUTHOR π
maintained by the LLVM Team (https://llvm.org/). kings of the compiler world, fr fr π«Ά
π COPYRIGHT π
2003-2023, LLVM Project
and that's the whole page, bestie! π sign-off time: this one's dated 2023-12-01, from the LLVM Project, year range 2003-2023, and it lives on page 17 of the manual. go diff some remarks and slay π β¨π
π¦ where this page comes from
- opensuse-leap 16.0: llvm17 17.0.6-160000.3.1 Β· Apache-2.0 WITH LLVM-exception AND NCSA
- opensuse-leap 16.0: llvm17 17.0.6-160000.3.1 Β· Apache-2.0 WITH LLVM-exception AND NCSA
- opensuse-leap 16.0: llvm17 17.0.6-160000.3.1 Β· Apache-2.0 WITH LLVM-exception AND NCSA
- opensuse-leap 16.0: llvm17 17.0.6-160000.3.1 Β· Apache-2.0 WITH LLVM-exception AND NCSA
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms