[llvm] r280446 - [PM] (NFC) Split the IR parsing into a fixture so that I can split out

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 1 18:14:06 PDT 2016


Author: chandlerc
Date: Thu Sep  1 20:14:05 2016
New Revision: 280446

URL: http://llvm.org/viewvc/llvm-project?rev=280446&view=rev
Log:
[PM] (NFC) Split the IR parsing into a fixture so that I can split out
more testing into other test routines while using the same core module.

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=280446&r1=280445&r2=280446&view=diff
==============================================================================
--- llvm/trunk/unittests/Analysis/CGSCCPassManagerTest.cpp (original)
+++ llvm/trunk/unittests/Analysis/CGSCCPassManagerTest.cpp Thu Sep  1 20:14:05 2016
@@ -158,39 +158,48 @@ std::unique_ptr<Module> parseIR(const ch
   return parseAssemblyString(IR, Err, C);
 }
 
-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");
+class CGSCCPassManagerTest : public ::testing::Test {
+protected:
+  LLVMContext Context;
+  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")) {}
+};
+
+TEST_F(CGSCCPassManagerTest, Basic) {
   FunctionAnalysisManager FAM(/*DebugLogging*/ true);
   int FunctionAnalysisRuns = 0;
   FAM.registerPass([&] { return TestFunctionAnalysis(FunctionAnalysisRuns); });




More information about the llvm-commits mailing list