Remove attribution from file headers, per discussion on llvmdev.
[oota-llvm.git] / lib / Analysis / IPA / CallGraphSCCPass.cpp
index fcf4202826467f7923cb6709467c21faf7e0c0e6..90e26266f8ba886bbd3b82d3da81995034c545af 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
@@ -30,7 +30,9 @@ using namespace llvm;
 class CGPassManager : public ModulePass, public PMDataManager {
 
 public:
-  CGPassManager(int Depth) : PMDataManager(Depth) { }
+  static char ID;
+  explicit CGPassManager(int Depth) 
+    : ModulePass((intptr_t)&ID), PMDataManager(Depth) { }
 
   /// run - Execute all of the passes scheduled for execution.  Keep track of
   /// whether any of the passes modifies the module, and if so, return true.
@@ -71,6 +73,7 @@ public:
   }
 };
 
+char CGPassManager::ID = 0;
 /// run - Execute all of the passes scheduled for execution.  Keep track of
 /// whether any of the passes modifies the module, and if so, return true.
 bool CGPassManager::runOnModule(Module &M) {
@@ -82,8 +85,7 @@ bool CGPassManager::runOnModule(Module &M) {
        I != E; ++I) {
 
     // Run all passes on current SCC
-    for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {  
-
+    for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
       Pass *P = getContainedPass(Index);
       AnalysisUsage AnUsage;
       P->getAnalysisUsage(AnUsage);
@@ -95,27 +97,28 @@ bool CGPassManager::runOnModule(Module &M) {
 
       StartPassTimer(P);
       if (CallGraphSCCPass *CGSP = dynamic_cast<CallGraphSCCPass *>(P))
-       Changed |= CGSP->runOnSCC(*I);   // TODO : What if CG is changed ?
+        Changed |= CGSP->runOnSCC(*I);   // TODO : What if CG is changed ?
       else {
-       FPPassManager *FPP = dynamic_cast<FPPassManager *>(P);
-       assert (FPP && "Invalid CGPassManager member");
-
-       // Run pass P on all functions current SCC
-       std::vector<CallGraphNode*> &SCC = *I;
-       for (unsigned i = 0, e = SCC.size(); i != e; ++i) {
-         Function *F = SCC[i]->getFunction();
-         if (F) {
-            dumpPassInfo(P, EXECUTION_MSG, ON_FUNCTION_MSG, F->getName());
+        FPPassManager *FPP = dynamic_cast<FPPassManager *>(P);
+        assert (FPP && "Invalid CGPassManager member");
+
+        // Run pass P on all functions current SCC
+        std::vector<CallGraphNode*> &SCC = *I;
+        for (unsigned i = 0, e = SCC.size(); i != e; ++i) {
+          Function *F = SCC[i]->getFunction();
+          if (F) {
+            dumpPassInfo(P, EXECUTION_MSG, ON_FUNCTION_MSG, F->getNameStart());
             Changed |= FPP->runOnFunction(*F);
           }
-       }
+        }
       }
       StopPassTimer(P);
 
       if (Changed)
         dumpPassInfo(P, MODIFICATION_MSG, ON_CG_MSG, "");
       dumpAnalysisSetInfo("Preserved", P, AnUsage.getPreservedSet());
-      
+
+      verifyPreservedAnalysis(P);      
       removeNotPreservedAnalysis(P);
       recordAvailableAnalysis(P);
       removeDeadPasses(P, "", ON_CG_MSG);
@@ -149,14 +152,11 @@ bool CGPassManager::doFinalization(CallGraph &CG) {
 
 /// Assign pass manager to manage this pass.
 void CallGraphSCCPass::assignPassManager(PMStack &PMS,
-                                        PassManagerType PreferredType) {
+                                         PassManagerType PreferredType) {
   // Find CGPassManager 
-  while (!PMS.empty()) {
-    if (PMS.top()->getPassManagerType() > PMT_CallGraphPassManager)
-      PMS.pop();
-    else;
-    break;
-  }
+  while (!PMS.empty() &&
+         PMS.top()->getPassManagerType() > PMT_CallGraphPassManager)
+    PMS.pop();
 
   CGPassManager *CGP = dynamic_cast<CGPassManager *>(PMS.top());
 
@@ -176,7 +176,7 @@ void CallGraphSCCPass::assignPassManager(PMStack &PMS,
     // [3] Assign manager to manage this new manager. This may create
     // and push new managers into PMS
     Pass *P = dynamic_cast<Pass *>(CGP);
-    P->assignPassManager(PMS);
+    TPM->schedulePass(P);
 
     // [4] Push new manager into PMS
     PMS.push(CGP);