summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2016-06-28 00:38:42 +0000
committerChandler Carruth <chandlerc@gmail.com>2016-06-28 00:38:42 +0000
commit6c138ce31c374e3d86989cf6244a94209764990e (patch)
treeba26500a0edb6bdd124b3231fed6065c249a8e54 /llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
parent7de0cf3cf782d3c33d63f106e227ab8fe96291ad (diff)
downloadbcm5719-llvm-6c138ce31c374e3d86989cf6244a94209764990e.tar.gz
bcm5719-llvm-6c138ce31c374e3d86989cf6244a94209764990e.zip
[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. llvm-svn: 273973
Diffstat (limited to 'llvm/unittests/Analysis/CGSCCPassManagerTest.cpp')
-rw-r--r--llvm/unittests/Analysis/CGSCCPassManagerTest.cpp81
1 files changed, 38 insertions, 43 deletions
diff --git a/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp b/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
index bc2601565d3..224f2df1318 100644
--- a/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
+++ b/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
@@ -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); });
OpenPOWER on IntegriCloud