diff options
Diffstat (limited to 'unittests/Analysis/ScalarEvolutionTest.cpp')
-rw-r--r-- | unittests/Analysis/ScalarEvolutionTest.cpp | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/unittests/Analysis/ScalarEvolutionTest.cpp b/unittests/Analysis/ScalarEvolutionTest.cpp index 6ce7ff43a312..938dafe60384 100644 --- a/unittests/Analysis/ScalarEvolutionTest.cpp +++ b/unittests/Analysis/ScalarEvolutionTest.cpp @@ -8,9 +8,13 @@ //===----------------------------------------------------------------------===// #include "llvm/Analysis/ScalarEvolutionExpressions.h" +#include "llvm/Analysis/AssumptionCache.h" +#include "llvm/Analysis/LoopInfo.h" +#include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Analysis/LoopInfo.h" #include "llvm/IR/Constants.h" +#include "llvm/IR/Dominators.h" #include "llvm/IR/GlobalVariable.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" @@ -24,16 +28,23 @@ namespace { // deleting the PassManager. class ScalarEvolutionsTest : public testing::Test { protected: - ScalarEvolutionsTest() : M("", Context), SE(*new ScalarEvolution) {} - ~ScalarEvolutionsTest() override { - // Manually clean up, since we allocated new SCEV objects after the - // pass was finished. - SE.releaseMemory(); - } LLVMContext Context; Module M; - legacy::PassManager PM; - ScalarEvolution &SE; + TargetLibraryInfoImpl TLII; + TargetLibraryInfo TLI; + + std::unique_ptr<AssumptionCache> AC; + std::unique_ptr<DominatorTree> DT; + std::unique_ptr<LoopInfo> LI; + + ScalarEvolutionsTest() : M("", Context), TLII(), TLI(TLII) {} + + ScalarEvolution buildSE(Function &F) { + AC.reset(new AssumptionCache(F)); + DT.reset(new DominatorTree(F)); + LI.reset(new LoopInfo(*DT)); + return ScalarEvolution(F, TLI, *AC, *DT, *LI); + } }; TEST_F(ScalarEvolutionsTest, SCEVUnknownRAUW) { @@ -49,9 +60,7 @@ TEST_F(ScalarEvolutionsTest, SCEVUnknownRAUW) { Value *V1 = new GlobalVariable(M, Ty, false, GlobalValue::ExternalLinkage, Init, "V1"); Value *V2 = new GlobalVariable(M, Ty, false, GlobalValue::ExternalLinkage, Init, "V2"); - // Create a ScalarEvolution and "run" it so that it gets initialized. - PM.add(&SE); - PM.run(M); + ScalarEvolution SE = buildSE(*F); const SCEV *S0 = SE.getSCEV(V0); const SCEV *S1 = SE.getSCEV(V1); @@ -96,9 +105,7 @@ TEST_F(ScalarEvolutionsTest, SCEVMultiplyAddRecs) { BasicBlock *BB = BasicBlock::Create(Context, "entry", F); ReturnInst::Create(Context, nullptr, BB); - // Create a ScalarEvolution and "run" it so that it gets initialized. - PM.add(&SE); - PM.run(M); + ScalarEvolution SE = buildSE(*F); // It's possible to produce an empty loop through the default constructor, // but you can't add any blocks to it without a LoopInfo pass. |