summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ProfileData/SampleProfTest.cpp
diff options
context:
space:
mode:
authorEaswaran Raman <eraman@google.com>2016-03-18 21:29:30 +0000
committerEaswaran Raman <eraman@google.com>2016-03-18 21:29:30 +0000
commit26628d3015028ad2f4d07acea0acc7168db0e107 (patch)
tree5bd6075a8e4d945026f20584e29b96c1ce2851c2 /llvm/unittests/ProfileData/SampleProfTest.cpp
parentc5269c0a4b8ebebc64e58b1bdb921f8f0f1d3164 (diff)
downloadbcm5719-llvm-26628d3015028ad2f4d07acea0acc7168db0e107.tar.gz
bcm5719-llvm-26628d3015028ad2f4d07acea0acc7168db0e107.zip
Interface to get/set profile summary metadata to module
Differential Revision: http://reviews.llvm.org/D17894 llvm-svn: 263835
Diffstat (limited to 'llvm/unittests/ProfileData/SampleProfTest.cpp')
-rw-r--r--llvm/unittests/ProfileData/SampleProfTest.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/unittests/ProfileData/SampleProfTest.cpp b/llvm/unittests/ProfileData/SampleProfTest.cpp
index 9738e9763ca..b2e05c3392b 100644
--- a/llvm/unittests/ProfileData/SampleProfTest.cpp
+++ b/llvm/unittests/ProfileData/SampleProfTest.cpp
@@ -126,6 +126,7 @@ struct SampleProfTest : ::testing::Test {
SampleProfileSummary &Summary = Reader->getSummary();
VerifySummary(Summary);
+ // Test that conversion of summary to and from Metadata works.
Metadata *MD = Summary.getMD(getGlobalContext());
ASSERT_TRUE(MD);
ProfileSummary *PS = ProfileSummary::getFromMD(MD);
@@ -134,6 +135,18 @@ struct SampleProfTest : ::testing::Test {
SampleProfileSummary *SPS = cast<SampleProfileSummary>(PS);
VerifySummary(*SPS);
delete SPS;
+
+ // Test that summary can be attached to and read back from module.
+ Module M("my_module", getGlobalContext());
+ M.setProfileSummary(MD);
+ MD = M.getProfileSummary();
+ ASSERT_TRUE(MD);
+ PS = ProfileSummary::getFromMD(MD);
+ ASSERT_TRUE(PS);
+ ASSERT_TRUE(isa<SampleProfileSummary>(PS));
+ SPS = cast<SampleProfileSummary>(PS);
+ VerifySummary(*SPS);
+ delete SPS;
}
};
OpenPOWER on IntegriCloud