summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/IR/MetadataTest.cpp
diff options
context:
space:
mode:
authorEaswaran Raman <eraman@google.com>2018-01-17 22:24:23 +0000
committerEaswaran Raman <eraman@google.com>2018-01-17 22:24:23 +0000
commite5b8de2f1f4b785fe4105c74aa055e9319ebd9ac (patch)
tree735025f7c1b406cf0db165a0255412cc40de212c /llvm/unittests/IR/MetadataTest.cpp
parentd109b5e0273565d3af272d8c3660a4ce233f6494 (diff)
downloadbcm5719-llvm-e5b8de2f1f4b785fe4105c74aa055e9319ebd9ac.tar.gz
bcm5719-llvm-e5b8de2f1f4b785fe4105c74aa055e9319ebd9ac.zip
Add a ProfileCount class to represent entry counts.
Summary: The class wraps a uint64_t and an enum to represent the type of profile count (real and synthetic) with some helper methods. Reviewers: davidxl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D41883 llvm-svn: 322771
Diffstat (limited to 'llvm/unittests/IR/MetadataTest.cpp')
-rw-r--r--llvm/unittests/IR/MetadataTest.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/llvm/unittests/IR/MetadataTest.cpp b/llvm/unittests/IR/MetadataTest.cpp
index 672de55fbde..51ca8408f1a 100644
--- a/llvm/unittests/IR/MetadataTest.cpp
+++ b/llvm/unittests/IR/MetadataTest.cpp
@@ -2436,9 +2436,20 @@ TEST_F(FunctionAttachmentTest, Verifier) {
TEST_F(FunctionAttachmentTest, EntryCount) {
Function *F = getFunction("foo");
EXPECT_FALSE(F->getEntryCount().hasValue());
- F->setEntryCount(12304);
- EXPECT_TRUE(F->getEntryCount().hasValue());
- EXPECT_EQ(12304u, *F->getEntryCount());
+ F->setEntryCount(12304, Function::PCT_Real);
+ auto Count = F->getEntryCount();
+ EXPECT_TRUE(Count.hasValue());
+ EXPECT_EQ(12304u, Count.getCount());
+ EXPECT_EQ(Function::PCT_Real, Count.getType());
+
+ // Repeat the same for synthetic counts.
+ F = getFunction("bar");
+ EXPECT_FALSE(F->getEntryCount().hasValue());
+ F->setEntryCount(123, Function::PCT_Synthetic);
+ Count = F->getEntryCount();
+ EXPECT_TRUE(Count.hasValue());
+ EXPECT_EQ(123u, Count.getCount());
+ EXPECT_EQ(Function::PCT_Synthetic, Count.getType());
}
TEST_F(FunctionAttachmentTest, SubprogramAttachment) {
OpenPOWER on IntegriCloud