X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=unittests%2FVMCore%2FPassManagerTest.cpp;h=0073751e4cd6108b91ea79c48ca5fcd71d9ffb03;hb=a75ce9f5d2236d93c117e861e60e6f3f748c9555;hp=cabfc44602cf00a95b34a77dffd143f9d1994bf7;hpb=48b17fa5bebf46ecdbcb51ebab1c3d8b483afd3c;p=oota-llvm.git diff --git a/unittests/VMCore/PassManagerTest.cpp b/unittests/VMCore/PassManagerTest.cpp index cabfc44602c..0073751e4cd 100644 --- a/unittests/VMCore/PassManagerTest.cpp +++ b/unittests/VMCore/PassManagerTest.cpp @@ -32,7 +32,15 @@ #include "llvm/Assembly/PrintModulePass.h" #include "gtest/gtest.h" +using namespace llvm; + namespace llvm { + void initializeModuleNDMPass(PassRegistry&); + void initializeFPassPass(PassRegistry&); + void initializeCGPassPass(PassRegistry&); + void initializeLPassPass(PassRegistry&); + void initializeBPassPass(PassRegistry&); + namespace { // ND = no deps // NM = no modifications @@ -40,7 +48,7 @@ namespace llvm { public: static char run; static char ID; - ModuleNDNM() : ModulePass(&ID) {} + ModuleNDNM() : ModulePass(ID) { } virtual bool runOnModule(Module &M) { run++; return false; @@ -56,7 +64,7 @@ namespace llvm { public: static char run; static char ID; - ModuleNDM() : ModulePass(&ID) {} + ModuleNDM() : ModulePass(ID) {} virtual bool runOnModule(Module &M) { run++; return true; @@ -64,13 +72,12 @@ namespace llvm { }; char ModuleNDM::ID=0; char ModuleNDM::run=0; - RegisterPass X("mndm","mndm",false,false); struct ModuleNDM2 : public ModulePass { public: static char run; static char ID; - ModuleNDM2() : ModulePass(&ID) {} + ModuleNDM2() : ModulePass(ID) {} virtual bool runOnModule(Module &M) { run++; return true; @@ -83,7 +90,9 @@ namespace llvm { public: static char run; static char ID; - ModuleDNM() : ModulePass(&ID) {} + ModuleDNM() : ModulePass(ID) { + initializeModuleNDMPass(*PassRegistry::getPassRegistry()); + } virtual bool runOnModule(Module &M) { EXPECT_TRUE(getAnalysisIfAvailable()); run++; @@ -119,7 +128,7 @@ namespace llvm { EXPECT_TRUE(finalized); EXPECT_EQ(run, runc); } - PassTestBase() : P(&ID), allocated(0) { + PassTestBase() : P(ID), allocated(0) { initialized = false; finalized = false; runc = 0; @@ -154,13 +163,15 @@ namespace llvm { struct CGPass : public PassTest { public: + CGPass() { + initializeCGPassPass(*PassRegistry::getPassRegistry()); + } virtual bool runOnSCC(CallGraphSCC &SCMM) { EXPECT_TRUE(getAnalysisIfAvailable()); run(); return false; } }; - RegisterPass X1("cgp","cgp"); struct FPass : public PassTest { public: @@ -171,7 +182,6 @@ namespace llvm { return false; } }; - RegisterPass X2("fp","fp"); struct LPass : public PassTestBase { private: @@ -179,6 +189,7 @@ namespace llvm { static int fincount; public: LPass() { + initializeLPassPass(*PassRegistry::getPassRegistry()); initcount = 0; fincount=0; EXPECT_FALSE(initialized); } @@ -205,7 +216,6 @@ namespace llvm { }; int LPass::initcount=0; int LPass::fincount=0; - RegisterPass X3("lp","lp"); struct BPass : public PassTestBase { private: @@ -248,12 +258,13 @@ namespace llvm { }; int BPass::inited=0; int BPass::fin=0; - RegisterPass X4("bp","bp"); struct OnTheFlyTest: public ModulePass { public: static char ID; - OnTheFlyTest() : ModulePass(&ID) {} + OnTheFlyTest() : ModulePass(ID) { + initializeFPassPass(*PassRegistry::getPassRegistry()); + } virtual bool runOnModule(Module &M) { EXPECT_TRUE(getAnalysisIfAvailable()); for (Module::iterator I=M.begin(),E=M.end(); I != E; ++I) { @@ -525,3 +536,13 @@ namespace llvm { } } + +INITIALIZE_PASS(ModuleNDM, "mndm", "mndm", false, false) +INITIALIZE_PASS_BEGIN(CGPass, "cgp","cgp", false, false) +INITIALIZE_AG_DEPENDENCY(CallGraph) +INITIALIZE_PASS_END(CGPass, "cgp","cgp", false, false) +INITIALIZE_PASS(FPass, "fp","fp", false, false) +INITIALIZE_PASS_BEGIN(LPass, "lp","lp", false, false) +INITIALIZE_PASS_DEPENDENCY(LoopInfo) +INITIALIZE_PASS_END(LPass, "lp","lp", false, false) +INITIALIZE_PASS(BPass, "bp","bp", false, false)