diff options
author | Mehdi Amini <mehdi.amini@apple.com> | 2016-04-14 21:59:01 +0000 |
---|---|---|
committer | Mehdi Amini <mehdi.amini@apple.com> | 2016-04-14 21:59:01 +0000 |
commit | 03b42e41bf4bdd9ab05ea4c6905bae5d19971960 (patch) | |
tree | d4249845a564b11af673299653e7c4e876d8c4f2 /llvm/unittests/ProfileData | |
parent | 3d1c1deb04efe0022f11ebc18bb43d7341ba0c75 (diff) | |
download | bcm5719-llvm-03b42e41bf4bdd9ab05ea4c6905bae5d19971960.tar.gz bcm5719-llvm-03b42e41bf4bdd9ab05ea4c6905bae5d19971960.zip |
Remove every uses of getGlobalContext() in LLVM (but the C API)
At the same time, fixes InstructionsTest::CastInst unittest: yes
you can leave the IR in an invalid state and exit when you don't
destroy the context (like the global one), no longer now.
This is the first part of http://reviews.llvm.org/D19094
From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 266379
Diffstat (limited to 'llvm/unittests/ProfileData')
-rw-r--r-- | llvm/unittests/ProfileData/InstrProfTest.cpp | 5 | ||||
-rw-r--r-- | llvm/unittests/ProfileData/SampleProfTest.cpp | 7 |
2 files changed, 7 insertions, 5 deletions
diff --git a/llvm/unittests/ProfileData/InstrProfTest.cpp b/llvm/unittests/ProfileData/InstrProfTest.cpp index 24e2a4ecc3a..a80be3d444a 100644 --- a/llvm/unittests/ProfileData/InstrProfTest.cpp +++ b/llvm/unittests/ProfileData/InstrProfTest.cpp @@ -180,7 +180,8 @@ TEST_F(InstrProfTest, get_profile_summary) { VerifySummary(PS); // Test that conversion of summary to and from Metadata works. - Metadata *MD = PS.getMD(getGlobalContext()); + LLVMContext Context; + Metadata *MD = PS.getMD(Context); ASSERT_TRUE(MD); ProfileSummary *PSFromMD = ProfileSummary::getFromMD(MD); ASSERT_TRUE(PSFromMD); @@ -190,7 +191,7 @@ TEST_F(InstrProfTest, get_profile_summary) { delete IPS; // Test that summary can be attached to and read back from module. - Module M("my_module", getGlobalContext()); + Module M("my_module", Context); M.setProfileSummary(MD); MD = M.getProfileSummary(); ASSERT_TRUE(MD); diff --git a/llvm/unittests/ProfileData/SampleProfTest.cpp b/llvm/unittests/ProfileData/SampleProfTest.cpp index 12533fa6656..24ffee72d3c 100644 --- a/llvm/unittests/ProfileData/SampleProfTest.cpp +++ b/llvm/unittests/ProfileData/SampleProfTest.cpp @@ -29,6 +29,7 @@ namespace { struct SampleProfTest : ::testing::Test { std::string Data; + LLVMContext Context; std::unique_ptr<raw_ostream> OS; std::unique_ptr<SampleProfileWriter> Writer; std::unique_ptr<SampleProfileReader> Reader; @@ -43,7 +44,7 @@ struct SampleProfTest : ::testing::Test { } void readProfile(std::unique_ptr<MemoryBuffer> &Profile) { - auto ReaderOrErr = SampleProfileReader::create(Profile, getGlobalContext()); + auto ReaderOrErr = SampleProfileReader::create(Profile, Context); ASSERT_TRUE(NoError(ReaderOrErr.getError())); Reader = std::move(ReaderOrErr.get()); } @@ -127,7 +128,7 @@ struct SampleProfTest : ::testing::Test { VerifySummary(Summary); // Test that conversion of summary to and from Metadata works. - Metadata *MD = Summary.getMD(getGlobalContext()); + Metadata *MD = Summary.getMD(Context); ASSERT_TRUE(MD); ProfileSummary *PS = ProfileSummary::getFromMD(MD); ASSERT_TRUE(PS); @@ -137,7 +138,7 @@ struct SampleProfTest : ::testing::Test { delete SPS; // Test that summary can be attached to and read back from module. - Module M("my_module", getGlobalContext()); + Module M("my_module", Context); M.setProfileSummary(MD); MD = M.getProfileSummary(); ASSERT_TRUE(MD); |