X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FVMCore%2FPass.cpp;h=85c4dec5fe722876aba27eb79f1a533512f219e2;hb=4d7a75a9e31a1b45e68b9cd3f50f18bd90dd0850;hp=3d09d9d7e1c8b1d78724f00ab8ccf193db48439f;hpb=789bc8426249c3427e7caa7ba7c3ace4400ab2b0;p=oota-llvm.git diff --git a/lib/VMCore/Pass.cpp b/lib/VMCore/Pass.cpp index 3d09d9d7e1c..85c4dec5fe7 100644 --- a/lib/VMCore/Pass.cpp +++ b/lib/VMCore/Pass.cpp @@ -13,9 +13,13 @@ #include "Support/TypeInfo.h" #include #include +#include #include #include +// IncludeFile - Stub function used to help linking out. +IncludeFile::IncludeFile(void*) {} + //===----------------------------------------------------------------------===// // AnalysisID Class Implementation // @@ -252,8 +256,10 @@ void PMDebug::PrintAnalysisSetInfo(unsigned Depth, const char *Msg, Pass *P, const std::vector &Set){ if (PassDebugging >= Details && !Set.empty()) { std::cerr << (void*)P << std::string(Depth*2+3, ' ') << Msg << " Analyses:"; - for (unsigned i = 0; i != Set.size(); ++i) - std::cerr << " " << Set[i]->getPassName(); + for (unsigned i = 0; i != Set.size(); ++i) { + if (i) std::cerr << ","; + std::cerr << " " << Set[i]->getPassName(); + } std::cerr << "\n"; } } @@ -292,6 +298,15 @@ void Pass::dump() const { print(std::cerr, 0); } +//===----------------------------------------------------------------------===// +// ImmutablePass Implementation +// +void ImmutablePass::addToPassManager(PassManagerT *PM, + AnalysisUsage &AU) { + PM->addPass(this, AU); +} + + //===----------------------------------------------------------------------===// // FunctionPass Implementation // @@ -336,18 +351,20 @@ void FunctionPass::addToPassManager(PassManagerT *PM, // function. // bool BasicBlockPass::runOnFunction(Function &F) { - bool Changed = false; + bool Changed = doInitialization(F); for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) Changed |= runOnBasicBlock(*I); - return Changed; + return Changed | doFinalization(F); } // To run directly on the basic block, we initialize, runOnBasicBlock, then // finalize. // bool BasicBlockPass::run(BasicBlock &BB) { - Module &M = *BB.getParent()->getParent(); - return doInitialization(M) | runOnBasicBlock(BB) | doFinalization(M); + Function &F = *BB.getParent(); + Module &M = *F.getParent(); + return doInitialization(M) | doInitialization(F) | runOnBasicBlock(BB) | + doFinalization(F) | doFinalization(M); } void BasicBlockPass::addToPassManager(PassManagerT *PM, @@ -437,8 +454,6 @@ RegisterAGBase::RegisterAGBase(const std::type_info &Interface, const std::type_info *Pass, bool isDefault) : ImplementationInfo(0), isDefaultImplementation(isDefault) { - std::cerr << "Registering interface: " << Interface.name() << "\n"; - InterfaceInfo = const_cast(Pass::lookupPassInfo(Interface)); if (InterfaceInfo == 0) { // First reference to Interface, add it now. InterfaceInfo = // Create the new PassInfo for the interface... @@ -450,12 +465,15 @@ RegisterAGBase::RegisterAGBase(const std::type_info &Interface, "Trying to join an analysis group that is a normal pass!"); if (Pass) { - std::cerr << "Registering interface impl: " << Pass->name() << "\n"; - ImplementationInfo = Pass::lookupPassInfo(*Pass); assert(ImplementationInfo && "Must register pass before adding to AnalysisGroup!"); + // Make sure we keep track of the fact that the implementation implements + // the interface. + PassInfo *IIPI = const_cast(ImplementationInfo); + IIPI->addInterfaceImplemented(InterfaceInfo); + // Lazily allocate to avoid nasty initialization order dependencies if (AnalysisGroupInfoMap == 0) AnalysisGroupInfoMap = new std::map(); @@ -509,34 +527,6 @@ RegisterAGBase::~RegisterAGBase() { } -// findAnalysisGroupMember - Return an iterator pointing to one of the elements -// of Map if there is a pass in Map that is a member of the analysis group for -// the specified AnalysisGroupID. -// -static std::map::const_iterator -findAnalysisGroupMember(const PassInfo *AnalysisGroupID, - const std::map &Map) { - assert(AnalysisGroupID->getPassType() == PassInfo::AnalysisGroup && - "AnalysisGroupID is not an analysis group!"); - assert(AnalysisGroupInfoMap && AnalysisGroupInfoMap->count(AnalysisGroupID) && - "Analysis Group does not have any registered members!"); - - // Get the set of all known implementations of this analysis group... - std::set &Impls = - (*AnalysisGroupInfoMap)[AnalysisGroupID].Implementations; - - // Scan over available passes, checking to see if any is a valid analysis - for (std::map::const_iterator I = Map.begin(), - E = Map.end(); I != E; ++I) - if (Impls.count(I->first)) // This is a valid analysis, return it. - return I; - - return Map.end(); // Nothing of use found. -} - - - - //===----------------------------------------------------------------------===// // PassRegistrationListener implementation //