From 26628d3015028ad2f4d07acea0acc7168db0e107 Mon Sep 17 00:00:00 2001 From: Easwaran Raman Date: Fri, 18 Mar 2016 21:29:30 +0000 Subject: Interface to get/set profile summary metadata to module Differential Revision: http://reviews.llvm.org/D17894 llvm-svn: 263835 --- llvm/unittests/ProfileData/SampleProfTest.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'llvm/unittests/ProfileData/SampleProfTest.cpp') 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(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(PS)); + SPS = cast(PS); + VerifySummary(*SPS); + delete SPS; } }; -- cgit v1.2.3