[llvm] d8690bc - [llvm-profdata] Add more unit tests to check --output-size-limit feature when compression is enabled
William Huang via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 15 17:34:15 PDT 2023
Author: William Huang
Date: 2023-03-16T00:33:00Z
New Revision: d8690bc1eae053a123da54316a64e28c20c287fb
URL: https://github.com/llvm/llvm-project/commit/d8690bc1eae053a123da54316a64e28c20c287fb
DIFF: https://github.com/llvm/llvm-project/commit/d8690bc1eae053a123da54316a64e28c20c287fb.diff
LOG: [llvm-profdata] Add more unit tests to check --output-size-limit feature when compression is enabled
Add unit tests for ExtBinary format with compression. This patch doesn't imply there's a bug in the existing implementation,
but as a precaution that planned changes to SampleProfileReader may cause it to break.
Reviewed By: snehasish
Differential Revision: https://reviews.llvm.org/D144524
Added:
Modified:
llvm/unittests/tools/llvm-profdata/OutputSizeLimitTest.cpp
Removed:
################################################################################
diff --git a/llvm/unittests/tools/llvm-profdata/OutputSizeLimitTest.cpp b/llvm/unittests/tools/llvm-profdata/OutputSizeLimitTest.cpp
index c4f8248358969..51ceb5b520fa1 100644
--- a/llvm/unittests/tools/llvm-profdata/OutputSizeLimitTest.cpp
+++ b/llvm/unittests/tools/llvm-profdata/OutputSizeLimitTest.cpp
@@ -77,7 +77,8 @@ template <typename T> class ExpectedErrorOr : public Expected<T> {
/// Note that even though by default samples with fewest total count are dropped
/// first, this is not a requirement. Samples can be dropped by any order.
static ExpectedErrorOr<void *> RunTest(StringRef Input, size_t SizeLimit,
- SampleProfileFormat Format) {
+ SampleProfileFormat Format,
+ bool Compress = false) {
// Read Input profile.
auto FS = vfs::getRealFileSystem();
LLVMContext Context;
@@ -93,6 +94,8 @@ static ExpectedErrorOr<void *> RunTest(StringRef Input, size_t SizeLimit,
{
DEF_VAR_RETURN_IF_ERROR(Writer,
SampleProfileWriter::create(Temp.path(), Format));
+ if (Compress)
+ Writer->setToCompressAllSections();
std::error_code EC = Writer->writeWithSizeLimit(OldProfiles, SizeLimit);
// too_large means no sample could be written because SizeLimit is too
// small. Otherwise any other error code indicates unexpected failure.
@@ -180,3 +183,11 @@ TEST(TestOutputSizeLimit, TestOutputSizeLimitText) {
RunTest(Input1, OutputSizeLimit, llvm::sampleprof::SPF_Text),
Succeeded());
}
+
+TEST(TestOutputSizeLimit, TestOutputSizeLimitExtBinaryCompressed) {
+ for (size_t OutputSizeLimit :
+ {507, 506, 505, 494, 493, 492, 483, 482, 481, 480})
+ ASSERT_THAT_EXPECTED(RunTest(Input1, OutputSizeLimit,
+ llvm::sampleprof::SPF_Ext_Binary, true),
+ Succeeded());
+}
More information about the llvm-commits
mailing list