1 //===-- ContextCompressionTest.cpp -------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
8 #include "../tools/llvm-profgen/ProfileGenerator.h"
9 #include "llvm/DebugInfo/Symbolize/SymbolizableModule.h"
10 #include "gtest/gtest.h"
13 using namespace sampleprof
;
15 TEST(TestCompression
, TestNoSizeLimit1
) {
16 SmallVector
<std::string
, 16> Context
= {"a", "b", "c", "a", "b", "c"};
17 SmallVector
<std::string
, 16> Expect
= {"a", "b", "c"};
18 CSProfileGenerator::compressRecursionContext(Context
, -1);
19 EXPECT_TRUE(std::equal(Context
.begin(), Context
.end(), Expect
.begin()));
22 TEST(TestCompression
, TestNoSizeLimit2
) {
23 SmallVector
<std::string
, 16> Context
= {"m", "a", "a", "b", "c", "a",
24 "b", "c", "b", "c", "d"};
25 SmallVector
<std::string
, 16> Expect
= {"m", "a", "b", "c", "d"};
26 CSProfileGenerator::compressRecursionContext(Context
, -1);
27 EXPECT_TRUE(std::equal(Context
.begin(), Context
.end(), Expect
.begin()));
30 TEST(TestCompression
, TestMaxDedupSize
) {
31 SmallVector
<std::string
, 16> Context
= {"m", "a", "a", "b", "c", "a",
32 "b", "c", "b", "c", "d"};
33 SmallVector
<std::string
, 16> Expect
= {"m", "a", "b", "c",
35 CSProfileGenerator::compressRecursionContext(Context
, 2);
36 EXPECT_TRUE(std::equal(Context
.begin(), Context
.end(), Expect
.begin()));