diff options
Diffstat (limited to 'llvm/unittests/Transforms/Vectorize/VPlanHCFGTest.cpp')
-rw-r--r-- | llvm/unittests/Transforms/Vectorize/VPlanHCFGTest.cpp | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/llvm/unittests/Transforms/Vectorize/VPlanHCFGTest.cpp b/llvm/unittests/Transforms/Vectorize/VPlanHCFGTest.cpp index 215c3ef40da..e2b8a8ab5d8 100644 --- a/llvm/unittests/Transforms/Vectorize/VPlanHCFGTest.cpp +++ b/llvm/unittests/Transforms/Vectorize/VPlanHCFGTest.cpp @@ -8,16 +8,35 @@ //===----------------------------------------------------------------------===// #include "../lib/Transforms/Vectorize/VPlan.h" +#include "../lib/Transforms/Vectorize/VPlanHCFGBuilder.h" #include "../lib/Transforms/Vectorize/VPlanHCFGTransforms.h" -#include "VPlanTestBase.h" +#include "llvm/AsmParser/Parser.h" +#include "llvm/IR/Dominators.h" #include "gtest/gtest.h" namespace llvm { namespace { -class VPlanHCFGTest : public VPlanTestBase {}; +class VPlanHCFGTest : public testing::Test { +protected: + std::unique_ptr<DominatorTree> DT; + std::unique_ptr<LoopInfo> LI; + + VPlanHCFGTest() {} + + VPlanPtr doBuildPlan(BasicBlock *LoopHeader) { + DT.reset(new DominatorTree(*LoopHeader->getParent())); + LI.reset(new LoopInfo(*DT)); + + auto Plan = llvm::make_unique<VPlan>(); + VPlanHCFGBuilder HCFGBuilder(LI->getLoopFor(LoopHeader), LI.get()); + HCFGBuilder.buildHierarchicalCFG(*Plan.get()); + return Plan; + } +}; TEST_F(VPlanHCFGTest, testBuildHCFGInnerLoop) { + LLVMContext Ctx; const char *ModuleString = "define void @f(i32* %A, i64 %N) {\n" "entry:\n" @@ -35,11 +54,12 @@ TEST_F(VPlanHCFGTest, testBuildHCFGInnerLoop) { " ret void\n" "}\n"; - Module &M = parseModule(ModuleString); + SMDiagnostic Err; + std::unique_ptr<Module> M = parseAssemblyString(ModuleString, Err, Ctx); - Function *F = M.getFunction("f"); + Function *F = M->getFunction("f"); BasicBlock *LoopHeader = F->getEntryBlock().getSingleSuccessor(); - auto Plan = buildHCFG(LoopHeader); + auto Plan = doBuildPlan(LoopHeader); VPBasicBlock *Entry = Plan->getEntry()->getEntryBasicBlock(); EXPECT_NE(nullptr, Entry->getSingleSuccessor()); @@ -95,6 +115,7 @@ TEST_F(VPlanHCFGTest, testBuildHCFGInnerLoop) { } TEST_F(VPlanHCFGTest, testVPInstructionToVPRecipesInner) { + LLVMContext Ctx; const char *ModuleString = "define void @f(i32* %A, i64 %N) {\n" "entry:\n" @@ -112,11 +133,12 @@ TEST_F(VPlanHCFGTest, testVPInstructionToVPRecipesInner) { " ret void\n" "}\n"; - Module &M = parseModule(ModuleString); + SMDiagnostic Err; + std::unique_ptr<Module> M = parseAssemblyString(ModuleString, Err, Ctx); - Function *F = M.getFunction("f"); + Function *F = M->getFunction("f"); BasicBlock *LoopHeader = F->getEntryBlock().getSingleSuccessor(); - auto Plan = buildHCFG(LoopHeader); + auto Plan = doBuildPlan(LoopHeader); LoopVectorizationLegality::InductionList Inductions; SmallPtrSet<Instruction *, 1> DeadInstructions; |