diff --git a/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp b/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp index bc2601565d37..224f2df13181 100644 --- a/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp +++ b/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp @@ -208,53 +208,48 @@ struct TestFunctionPass { int &RunCount; }; -std::unique_ptr parseIR(LLVMContext &C, const char *IR) { +std::unique_ptr parseIR(const char *IR) { + // We just use a static context here. This is never called from multiple + // threads so it is harmless no matter how it is implemented. We just need + // the context to outlive the module which it does. + static LLVMContext C; SMDiagnostic Err; return parseAssemblyString(IR, Err, C); } -class CGSCCPassManagerTest : public ::testing::Test { -protected: - LLVMContext Context; - std::unique_ptr M; - -public: - CGSCCPassManagerTest() - : M(parseIR(Context, "define void @f() {\n" - "entry:\n" - " call void @g()\n" - " call void @h1()\n" - " ret void\n" - "}\n" - "define void @g() {\n" - "entry:\n" - " call void @g()\n" - " call void @x()\n" - " ret void\n" - "}\n" - "define void @h1() {\n" - "entry:\n" - " call void @h2()\n" - " ret void\n" - "}\n" - "define void @h2() {\n" - "entry:\n" - " call void @h3()\n" - " call void @x()\n" - " ret void\n" - "}\n" - "define void @h3() {\n" - "entry:\n" - " call void @h1()\n" - " ret void\n" - "}\n" - "define void @x() {\n" - "entry:\n" - " ret void\n" - "}\n")) {} -}; - -TEST_F(CGSCCPassManagerTest, Basic) { +TEST(CGSCCPassManagerTest, Basic) { + auto M = parseIR("define void @f() {\n" + "entry:\n" + " call void @g()\n" + " call void @h1()\n" + " ret void\n" + "}\n" + "define void @g() {\n" + "entry:\n" + " call void @g()\n" + " call void @x()\n" + " ret void\n" + "}\n" + "define void @h1() {\n" + "entry:\n" + " call void @h2()\n" + " ret void\n" + "}\n" + "define void @h2() {\n" + "entry:\n" + " call void @h3()\n" + " call void @x()\n" + " ret void\n" + "}\n" + "define void @h3() {\n" + "entry:\n" + " call void @h1()\n" + " ret void\n" + "}\n" + "define void @x() {\n" + "entry:\n" + " ret void\n" + "}\n"); FunctionAnalysisManager FAM(/*DebugLogging*/ true); int FunctionAnalysisRuns = 0; FAM.registerPass([&] { return TestFunctionAnalysis(FunctionAnalysisRuns); });