Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / llvm / unittests / ProfileData / BPFunctionNodeTest.cpp
blob97ff5c1edf5efc99da0c6bbcb3179d9c7788e7f4
1 //===- BPFunctionNodeTest.cpp - BPFunctionNode tests ----------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 #include "llvm/ProfileData/InstrProf.h"
10 #include "llvm/Support/BalancedPartitioning.h"
11 #include "llvm/Testing/Support/SupportHelpers.h"
12 #include "gmock/gmock.h"
13 #include "gtest/gtest.h"
15 using testing::Field;
16 using testing::UnorderedElementsAre;
17 using testing::UnorderedElementsAreArray;
19 namespace llvm {
21 void PrintTo(const BPFunctionNode &Node, std::ostream *OS) {
22 raw_os_ostream ROS(*OS);
23 Node.dump(ROS);
26 TEST(BPFunctionNodeTest, Basic) {
27 auto Nodes = TemporalProfTraceTy::createBPFunctionNodes({
28 TemporalProfTraceTy({0, 1, 2, 3, 4}),
29 TemporalProfTraceTy({4, 2}),
30 });
32 auto NodeIs = [](BPFunctionNode::IDT Id,
33 ArrayRef<BPFunctionNode::UtilityNodeT> UNs) {
34 return AllOf(Field("Id", &BPFunctionNode::Id, Id),
35 Field("UtilityNodes", &BPFunctionNode::UtilityNodes,
36 UnorderedElementsAreArray(UNs)));
39 EXPECT_THAT(Nodes,
40 UnorderedElementsAre(NodeIs(0, {0, 1, 2}), NodeIs(1, {1, 2}),
41 NodeIs(2, {1, 2, 4, 5}), NodeIs(3, {2}),
42 NodeIs(4, {2, 3, 4, 5})));
45 } // end namespace llvm