[llvm] r273973 - [PM] Sink the module parsing from the fixture to the test as subsequent
Chandler Carruth via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 27 17:38:42 PDT 2016
Author: chandlerc
Date: Mon Jun 27 19:38:42 2016
New Revision: 273973
URL: http://llvm.org/viewvc/llvm-project?rev=273973&view=rev
Log:
[PM] Sink the module parsing from the fixture to the test as subsequent
tests will want different IR.
Wanted this when writing tests for the proposed CG update stuff, and
this is an easily separable piece.
Modified:
llvm/trunk/unittests/Analysis/CGSCCPassManagerTest.cpp
Modified: llvm/trunk/unittests/Analysis/CGSCCPassManagerTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Analysis/CGSCCPassManagerTest.cpp?rev=273973&r1=273972&r2=273973&view=diff
==============================================================================
--- llvm/trunk/unittests/Analysis/CGSCCPassManagerTest.cpp (original)
+++ llvm/trunk/unittests/Analysis/CGSCCPassManagerTest.cpp Mon Jun 27 19:38:42 2016
@@ -208,53 +208,48 @@ struct TestFunctionPass {
int &RunCount;
};
-std::unique_ptr<Module> parseIR(LLVMContext &C, const char *IR) {
+std::unique_ptr<Module> 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<Module> 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); });
More information about the llvm-commits
mailing list