diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2016-09-26 06:29:21 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2016-09-26 06:29:21 +0000 |
commit | dc288a896e2ab837ef5062a85dc061e105ae5a62 (patch) | |
tree | 69ed92e9e2f1643a82009295134f8ae350c0600a /llvm/unittests/Analysis/CGSCCPassManagerTest.cpp | |
parent | 6c9e06a95c0a6cb3d8a80a3af18332326501e8a8 (diff) | |
download | bcm5719-llvm-dc288a896e2ab837ef5062a85dc061e105ae5a62.tar.gz bcm5719-llvm-dc288a896e2ab837ef5062a85dc061e105ae5a62.zip |
[PM] Refactor this unittest a bit to remove duplicated code. This was
suggested at one point during code review and I deferred it to
a follow-up commit.
llvm-svn: 282383
Diffstat (limited to 'llvm/unittests/Analysis/CGSCCPassManagerTest.cpp')
-rw-r--r-- | llvm/unittests/Analysis/CGSCCPassManagerTest.cpp | 110 |
1 files changed, 45 insertions, 65 deletions
diff --git a/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp b/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp index 8ef3f9ea436..fb48f83180e 100644 --- a/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp +++ b/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp @@ -175,46 +175,58 @@ std::unique_ptr<Module> parseIR(const char *IR) { class CGSCCPassManagerTest : public ::testing::Test { protected: LLVMContext Context; + FunctionAnalysisManager FAM; + CGSCCAnalysisManager CGAM; + ModuleAnalysisManager MAM; + std::unique_ptr<Module> M; public: CGSCCPassManagerTest() - : 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")) {} + : FAM(/*DebugLogging*/ true), CGAM(/*DebugLogging*/ true), + MAM(/*DebugLogging*/ true), 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")) { + MAM.registerPass([&] { return LazyCallGraphAnalysis(); }); + MAM.registerPass([&] { return FunctionAnalysisManagerModuleProxy(FAM); }); + MAM.registerPass([&] { return CGSCCAnalysisManagerModuleProxy(CGAM); }); + CGAM.registerPass([&] { return FunctionAnalysisManagerCGSCCProxy(FAM); }); + CGAM.registerPass([&] { return ModuleAnalysisManagerCGSCCProxy(MAM); }); + FAM.registerPass([&] { return CGSCCAnalysisManagerFunctionProxy(CGAM); }); + FAM.registerPass([&] { return ModuleAnalysisManagerFunctionProxy(MAM); }); + } }; TEST_F(CGSCCPassManagerTest, Basic) { - FunctionAnalysisManager FAM(/*DebugLogging*/ true); int FunctionAnalysisRuns = 0; FAM.registerPass([&] { return TestFunctionAnalysis(FunctionAnalysisRuns); }); int ImmutableFunctionAnalysisRuns = 0; @@ -222,22 +234,12 @@ TEST_F(CGSCCPassManagerTest, Basic) { return TestImmutableFunctionAnalysis(ImmutableFunctionAnalysisRuns); }); - CGSCCAnalysisManager CGAM(/*DebugLogging*/ true); int SCCAnalysisRuns = 0; CGAM.registerPass([&] { return TestSCCAnalysis(SCCAnalysisRuns); }); - ModuleAnalysisManager MAM(/*DebugLogging*/ true); int ModuleAnalysisRuns = 0; - MAM.registerPass([&] { return LazyCallGraphAnalysis(); }); MAM.registerPass([&] { return TestModuleAnalysis(ModuleAnalysisRuns); }); - MAM.registerPass([&] { return FunctionAnalysisManagerModuleProxy(FAM); }); - MAM.registerPass([&] { return CGSCCAnalysisManagerModuleProxy(CGAM); }); - CGAM.registerPass([&] { return FunctionAnalysisManagerCGSCCProxy(FAM); }); - CGAM.registerPass([&] { return ModuleAnalysisManagerCGSCCProxy(MAM); }); - FAM.registerPass([&] { return CGSCCAnalysisManagerFunctionProxy(CGAM); }); - FAM.registerPass([&] { return ModuleAnalysisManagerFunctionProxy(MAM); }); - ModulePassManager MPM(/*DebugLogging*/ true); MPM.addPass(RequireAnalysisPass<TestModuleAnalysis, Module>()); @@ -299,17 +301,6 @@ TEST_F(CGSCCPassManagerTest, Basic) { // Test that an SCC pass which fails to preserve a module analysis does in fact // invalidate that module analysis. TEST_F(CGSCCPassManagerTest, TestSCCPassInvalidatesModuleAnalysis) { - FunctionAnalysisManager FAM(/*DebugLogging*/ true); - CGSCCAnalysisManager CGAM(/*DebugLogging*/ true); - ModuleAnalysisManager MAM(/*DebugLogging*/ true); - MAM.registerPass([&] { return FunctionAnalysisManagerModuleProxy(FAM); }); - MAM.registerPass([&] { return CGSCCAnalysisManagerModuleProxy(CGAM); }); - CGAM.registerPass([&] { return FunctionAnalysisManagerCGSCCProxy(FAM); }); - CGAM.registerPass([&] { return ModuleAnalysisManagerCGSCCProxy(MAM); }); - FAM.registerPass([&] { return CGSCCAnalysisManagerFunctionProxy(CGAM); }); - FAM.registerPass([&] { return ModuleAnalysisManagerFunctionProxy(MAM); }); - MAM.registerPass([&] { return LazyCallGraphAnalysis(); }); - int ModuleAnalysisRuns = 0; MAM.registerPass([&] { return TestModuleAnalysis(ModuleAnalysisRuns); }); @@ -388,17 +379,6 @@ TEST_F(CGSCCPassManagerTest, TestSCCPassInvalidatesModuleAnalysis) { // Similar to the above, but test that this works for function passes embedded // *within* a CGSCC layer. TEST_F(CGSCCPassManagerTest, TestFunctionPassInsideCGSCCInvalidatesModuleAnalysis) { - FunctionAnalysisManager FAM(/*DebugLogging*/ true); - CGSCCAnalysisManager CGAM(/*DebugLogging*/ true); - ModuleAnalysisManager MAM(/*DebugLogging*/ true); - MAM.registerPass([&] { return FunctionAnalysisManagerModuleProxy(FAM); }); - MAM.registerPass([&] { return CGSCCAnalysisManagerModuleProxy(CGAM); }); - CGAM.registerPass([&] { return FunctionAnalysisManagerCGSCCProxy(FAM); }); - CGAM.registerPass([&] { return ModuleAnalysisManagerCGSCCProxy(MAM); }); - FAM.registerPass([&] { return CGSCCAnalysisManagerFunctionProxy(CGAM); }); - FAM.registerPass([&] { return ModuleAnalysisManagerFunctionProxy(MAM); }); - MAM.registerPass([&] { return LazyCallGraphAnalysis(); }); - int ModuleAnalysisRuns = 0; MAM.registerPass([&] { return TestModuleAnalysis(ModuleAnalysisRuns); }); |