[llvm] [tools][llc] Add `--save-stats` option (PR #163967)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 22 07:54:34 PDT 2025


dtcxzyw wrote:

> I think having ad hoc --save-stats gives you a more structured approach. A generic output like --info-output-file=xxxx.json can mix other streams which are not statistics too, then you'll have to parse it somehow.

Agree. In my [downstream project](https://github.com/dtcxzyw/llvm-opt-benchmark/blob/20437bacf19197e59dafec61dbdc5c7d5aa78e5c/scripts/update.py#L231-L253) I have to do the extra substr to get the JSON body.

> Adding it to libSupport would require some API so each tool submits an output filename, as each resolves it independently and the statistics object is static. So we'll need to inject it out of order and independently of statistics options, which I think can be a bit odd, but tolerable to reduce code duplication.

Adding this option to opt is enough. I don't see the value of putting the logic in libSupport. A bit of code duplication should be acceptable.


https://github.com/llvm/llvm-project/pull/163967


More information about the llvm-commits mailing list