[llvm-profdata] Add option to cap profile output size
authorWilliam Huang <williamjhuang@google.com>
Thu, 29 Dec 2022 00:35:06 +0000 (00:35 +0000)
committerWilliam Huang <williamjhuang@google.com>
Mon, 9 Jan 2023 22:01:10 +0000 (22:01 +0000)
commit5b72d0e4f5eeb8f90c744cac8e0728cffeca61a9
treebfdfc4d7a09b20ed7b1963d9bdcceb0ffd220da5
parent13b909ef27e7cb7a4c55d1778254be1ac5c0884d
[llvm-profdata] Add option to cap profile output size

Allow user to specify `--output-size-limit=n` to cap the size of generated profile to be strictly under n. Functions with the lowest total sample count are dropped first if necessary. Due to using a heuristic, excessive functions may be dropped to satisfy the size requirement

Reviewed By: snehasish

Differential Revision: https://reviews.llvm.org/D139603
llvm/include/llvm/ProfileData/SampleProfWriter.h
llvm/lib/ProfileData/SampleProfWriter.cpp
llvm/test/tools/llvm-profdata/output-size-limit.test [new file with mode: 0644]
llvm/tools/llvm-profdata/llvm-profdata.cpp