1*d415bd75Srobertllvm-remark-size-diff - diff size remarks 2*d415bd75Srobert========================================= 3*d415bd75Srobert 4*d415bd75Srobert.. program:: llvm-remark-size-diff 5*d415bd75Srobert 6*d415bd75SrobertSYNOPSIS 7*d415bd75Srobert-------- 8*d415bd75Srobert 9*d415bd75Srobert:program:`llvm-remark-size-diff` [*options*] *file_a* *file_b* **--parser** *parser* 10*d415bd75Srobert 11*d415bd75SrobertDESCRIPTION 12*d415bd75Srobert----------- 13*d415bd75Srobert 14*d415bd75Srobert:program:`llvm-remark-size-diff` diffs size 15*d415bd75Srobert`remarks <https://llvm.org/docs/Remarks.html>`_ in two remark files: ``file_a`` 16*d415bd75Srobertand ``file_b``. 17*d415bd75Srobert 18*d415bd75Srobert:program:`llvm-remark-size-diff` can be used to gain insight into which 19*d415bd75Srobertfunctions were impacted the most by code generation changes. 20*d415bd75Srobert 21*d415bd75SrobertIn most common use-cases ``file_a`` and ``file_b`` will be remarks output by 22*d415bd75Srobertcompiling a **fixed source** with **differing compilers** or 23*d415bd75Srobert**differing optimization settings**. 24*d415bd75Srobert 25*d415bd75Srobert:program:`llvm-remark-size-diff` handles both 26*d415bd75Srobert`YAML <https://llvm.org/docs/Remarks.html#yaml-remarks>`_ and 27*d415bd75Srobert`bitstream <https://llvm.org/docs/Remarks.html#llvm-bitstream-remarks>`_ 28*d415bd75Srobertremarks. 29*d415bd75Srobert 30*d415bd75SrobertOPTIONS 31*d415bd75Srobert------- 32*d415bd75Srobert 33*d415bd75Srobert.. option:: --parser=<yaml|bitstream> 34*d415bd75Srobert 35*d415bd75Srobert Select the type of input remark parser. Required. 36*d415bd75Srobert * ``yaml``: The tool will parse YAML remarks. 37*d415bd75Srobert * ``bitstream``: The tool will parse bitstream remarks. 38*d415bd75Srobert 39*d415bd75Srobert.. option:: --report-style=<human|json> 40*d415bd75Srobert 41*d415bd75Srobert Output style. 42*d415bd75Srobert * ``human``: Human-readable textual report. Default option. 43*d415bd75Srobert * ``json``: JSON report. 44*d415bd75Srobert 45*d415bd75Srobert.. option:: --pretty 46*d415bd75Srobert 47*d415bd75Srobert Pretty-print JSON output. Optional. 48*d415bd75Srobert 49*d415bd75Srobert If output is not set to JSON, this does nothing. 50*d415bd75Srobert 51*d415bd75Srobert.. option:: -o=<file> 52*d415bd75Srobert 53*d415bd75Srobert Output file for the report. Outputs to stdout by default. 54*d415bd75Srobert 55*d415bd75SrobertHUMAN-READABLE OUTPUT 56*d415bd75Srobert--------------------- 57*d415bd75Srobert 58*d415bd75SrobertThe human-readable format for :program:`llvm-remark-size-diff` is composed of 59*d415bd75Sroberttwo sections: 60*d415bd75Srobert 61*d415bd75Srobert* Per-function changes. 62*d415bd75Srobert* A high-level summary of all changes. 63*d415bd75Srobert 64*d415bd75SrobertChanged Function Section 65*d415bd75Srobert######################## 66*d415bd75Srobert 67*d415bd75SrobertSuppose you are comparing two remark files OLD and NEW. 68*d415bd75Srobert 69*d415bd75SrobertFor each function with a **changed instruction count** in OLD and NEW, 70*d415bd75Srobert:program:`llvm-remark-size-diff` will emit a line like below: 71*d415bd75Srobert 72*d415bd75Srobert:: 73*d415bd75Srobert 74*d415bd75Srobert (++|--|==) (>|<) function_name, N instrs, M stack B 75*d415bd75Srobert 76*d415bd75SrobertA breakdown of the format is below: 77*d415bd75Srobert 78*d415bd75Srobert``(++|--|==)`` 79*d415bd75Srobert Which of OLD and NEW the ``function_name`` is present in. 80*d415bd75Srobert 81*d415bd75Srobert * ``++``: Only in NEW. ("Added") 82*d415bd75Srobert * ``--``: Only in OLD. ("Removed") 83*d415bd75Srobert * ``==``: In both. 84*d415bd75Srobert 85*d415bd75Srobert``(>|<)`` 86*d415bd75Srobert Denotes if ``function_name`` has more instructions or fewer instructions in 87*d415bd75Srobert the second file. 88*d415bd75Srobert 89*d415bd75Srobert * ``>``: More instructions in second file than first file. 90*d415bd75Srobert * ``<``: Fewer instructions in second file than in first file. 91*d415bd75Srobert 92*d415bd75Srobert``function_name`` 93*d415bd75Srobert The name of the changed function. 94*d415bd75Srobert 95*d415bd75Srobert``N instrs`` 96*d415bd75Srobert Second file instruction count - first file instruction count. 97*d415bd75Srobert 98*d415bd75Srobert``M stack B`` 99*d415bd75Srobert Second file stack byte count - first file stack byte count. 100*d415bd75Srobert 101*d415bd75SrobertSummary Section 102*d415bd75Srobert############### 103*d415bd75Srobert 104*d415bd75Srobert:program:`llvm-remark-size-diff` will output a high-level summary after 105*d415bd75Srobertprinting all changed functions. 106*d415bd75Srobert 107*d415bd75Srobert:: 108*d415bd75Srobert 109*d415bd75Srobert instruction count: N (inst_pct_change%) 110*d415bd75Srobert stack byte usage: M (sb_pct_change%) 111*d415bd75Srobert 112*d415bd75Srobert``N`` 113*d415bd75Srobert Sum of all instruction count changes between the second and first file. 114*d415bd75Srobert 115*d415bd75Srobert``inst_pct_change%`` 116*d415bd75Srobert Percent increase or decrease in instruction count between the second and first 117*d415bd75Srobert file. 118*d415bd75Srobert 119*d415bd75Srobert``M`` 120*d415bd75Srobert Sum of all stack byte count changes between the second and first file. 121*d415bd75Srobert 122*d415bd75Srobert``sb_pct_change%`` 123*d415bd75Srobert Percent increase or decrease in stack byte usage between the second and first 124*d415bd75Srobert file. 125*d415bd75Srobert 126*d415bd75SrobertJSON OUTPUT 127*d415bd75Srobert----------- 128*d415bd75Srobert 129*d415bd75SrobertHigh-Level view 130*d415bd75Srobert############### 131*d415bd75Srobert 132*d415bd75SrobertSuppose we are comparing two files, OLD and NEW. 133*d415bd75Srobert 134*d415bd75Srobert:program:`llvm-remark-size-diff` will output JSON as follows. 135*d415bd75Srobert 136*d415bd75Srobert:: 137*d415bd75Srobert 138*d415bd75Srobert "Files": [ 139*d415bd75Srobert "A": "path/to/OLD", 140*d415bd75Srobert "B": "path/to/NEW" 141*d415bd75Srobert ] 142*d415bd75Srobert 143*d415bd75Srobert "InBoth": [ 144*d415bd75Srobert ... 145*d415bd75Srobert ], 146*d415bd75Srobert 147*d415bd75Srobert "OnlyInA": [ 148*d415bd75Srobert ... 149*d415bd75Srobert ], 150*d415bd75Srobert 151*d415bd75Srobert "OnlyInB": [ 152*d415bd75Srobert ... 153*d415bd75Srobert ] 154*d415bd75Srobert 155*d415bd75Srobert 156*d415bd75Srobert``Files`` 157*d415bd75Srobert Original paths to remark files. 158*d415bd75Srobert 159*d415bd75Srobert * ``A``: Path to the first file. 160*d415bd75Srobert * ``B``: Path to the second file. 161*d415bd75Srobert 162*d415bd75Srobert``InBoth`` 163*d415bd75Srobert Functions present in both files. 164*d415bd75Srobert 165*d415bd75Srobert``OnlyInA`` 166*d415bd75Srobert Functions only present in the first file. 167*d415bd75Srobert 168*d415bd75Srobert``OnlyInB`` 169*d415bd75Srobert Functions only present in the second file. 170*d415bd75Srobert 171*d415bd75SrobertFunction JSON 172*d415bd75Srobert############# 173*d415bd75Srobert 174*d415bd75SrobertThe ``InBoth``, ``OnlyInA``, and ``OnlyInB`` sections contain size information 175*d415bd75Srobertfor each function in the input remark files. 176*d415bd75Srobert 177*d415bd75Srobert:: 178*d415bd75Srobert 179*d415bd75Srobert { 180*d415bd75Srobert "FunctionName" : "function_name" 181*d415bd75Srobert "InstCount": [ 182*d415bd75Srobert INST_COUNT_A, 183*d415bd75Srobert INST_COUNT_B 184*d415bd75Srobert ], 185*d415bd75Srobert "StackSize": [ 186*d415bd75Srobert STACK_BYTES_A, 187*d415bd75Srobert STACK_BYTES_B 188*d415bd75Srobert ], 189*d415bd75Srobert } 190*d415bd75Srobert 191*d415bd75Srobert``FunctionName`` 192*d415bd75Srobert Name of the function. 193*d415bd75Srobert 194*d415bd75Srobert``InstCount`` 195*d415bd75Srobert Instruction counts for the function. 196*d415bd75Srobert 197*d415bd75Srobert * ``INST_COUNT_A``: Instruction count in OLD. 198*d415bd75Srobert * ``INST_COUNT_B``: Instruction count in NEW. 199*d415bd75Srobert 200*d415bd75Srobert``StackSize`` 201*d415bd75Srobert Stack byte counts for the function. 202*d415bd75Srobert 203*d415bd75Srobert * ``STACK_BYTES_A``: Stack bytes in OLD. 204*d415bd75Srobert * ``STACK_BYTES_B``: Stack bytes in NEW. 205*d415bd75Srobert 206*d415bd75SrobertComputing Diffs From Function JSON 207*d415bd75Srobert********************************** 208*d415bd75Srobert 209*d415bd75SrobertFunction JSON does not contain the diffs. Tools consuming JSON output from 210*d415bd75Srobert:program:`llvm-remark-size-diff` are responsible for computing the diffs 211*d415bd75Srobertseparately. 212*d415bd75Srobert 213*d415bd75Srobert**To compute the diffs:** 214*d415bd75Srobert 215*d415bd75Srobert* Instruction count diff: ``INST_COUNT_B - INST_COUNT_A`` 216*d415bd75Srobert* Stack byte count diff: ``STACK_BYTES_B - STACK_BYTES_A`` 217*d415bd75Srobert 218*d415bd75SrobertEXIT STATUS 219*d415bd75Srobert----------- 220*d415bd75Srobert 221*d415bd75Srobert:program:`llvm-remark-size-diff` returns 0 on success, and a non-zero value 222*d415bd75Srobertotherwise. 223