[llvm-commits] [llvm] r40062 - in /llvm/trunk: include/llvm/Analysis/LoopInfo.h include/llvm/Analysis/LoopPass.h include/llvm/Pass.h include/llvm/PassManagers.h lib/Analysis/IPA/CallGraphSCCPass.cpp lib/Analysis/LoopInfo.cpp lib/Analysis/LoopPass.cpp lib/Transforms/Utils/LoopSimplify.cpp lib/VMCore/PassManager.cpp

Devang Patel dpatel at apple.com
Thu Jul 19 11:02:33 PDT 2007


Author: dpatel
Date: Thu Jul 19 13:02:32 2007
New Revision: 40062

URL: http://llvm.org/viewvc/llvm-project?rev=40062&view=rev
Log:
Verify loop info.

Modified:
    llvm/trunk/include/llvm/Analysis/LoopInfo.h
    llvm/trunk/include/llvm/Analysis/LoopPass.h
    llvm/trunk/include/llvm/Pass.h
    llvm/trunk/include/llvm/PassManagers.h
    llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp
    llvm/trunk/lib/Analysis/LoopInfo.cpp
    llvm/trunk/lib/Analysis/LoopPass.cpp
    llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp
    llvm/trunk/lib/VMCore/PassManager.cpp

Modified: llvm/trunk/include/llvm/Analysis/LoopInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopInfo.h?rev=40062&r1=40061&r2=40062&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Analysis/LoopInfo.h (original)
+++ llvm/trunk/include/llvm/Analysis/LoopInfo.h Thu Jul 19 13:02:32 2007
@@ -217,6 +217,9 @@
   /// the mapping in the LoopInfo class.
   void removeBlockFromLoop(BasicBlock *BB);
 
+  /// verifyLoop - Verify loop structure
+  void verifyLoop() const;
+
   void print(std::ostream &O, unsigned Depth = 0) const;
   void print(std::ostream *O, unsigned Depth = 0) const {
     if (O) print(*O, Depth);

Modified: llvm/trunk/include/llvm/Analysis/LoopPass.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopPass.h?rev=40062&r1=40061&r2=40062&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Analysis/LoopPass.h (original)
+++ llvm/trunk/include/llvm/Analysis/LoopPass.h Thu Jul 19 13:02:32 2007
@@ -116,10 +116,6 @@
   void redoLoop(Loop *L);
 
 private:
-  /// verifyLoopInfo - Verify loop nest.
-  void verifyLoopInfo();
-
-private:
   std::deque<Loop *> LQ;
   bool skipThisLoop;
   bool redoThisLoop;

Modified: llvm/trunk/include/llvm/Pass.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Pass.h?rev=40062&r1=40061&r2=40062&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Pass.h (original)
+++ llvm/trunk/include/llvm/Pass.h Thu Jul 19 13:02:32 2007
@@ -163,7 +163,7 @@
 
   /// verifyAnalysis() - This member can be implemented by a analysis pass to
   /// check state of analysis information. 
-  virtual void verifyAnalysis() {}
+  virtual void verifyAnalysis() const {}
 
   // dumpPassStructure - Implement the -debug-passes=PassStructure option
   virtual void dumpPassStructure(unsigned Offset = 0);

Modified: llvm/trunk/include/llvm/PassManagers.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/PassManagers.h?rev=40062&r1=40061&r2=40062&view=diff

==============================================================================
--- llvm/trunk/include/llvm/PassManagers.h (original)
+++ llvm/trunk/include/llvm/PassManagers.h Thu Jul 19 13:02:32 2007
@@ -211,6 +211,9 @@
   /// Augment AvailableAnalysis by adding analysis made available by pass P.
   void recordAvailableAnalysis(Pass *P);
 
+  /// verifyPreservedAnalysis -- Verify analysis presreved by pass P.
+  void verifyPreservedAnalysis(Pass *P);
+
   /// Remove Analysis that is not preserved by the pass
   void removeNotPreservedAnalysis(Pass *P);
   

Modified: llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp?rev=40062&r1=40061&r2=40062&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp (original)
+++ llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp Thu Jul 19 13:02:32 2007
@@ -117,7 +117,8 @@
       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);

Modified: llvm/trunk/lib/Analysis/LoopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopInfo.cpp?rev=40062&r1=40061&r2=40062&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/LoopInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/LoopInfo.cpp Thu Jul 19 13:02:32 2007
@@ -81,6 +81,18 @@
     (*I)->print(OS, Depth+2);
 }
 
+/// verifyLoop - Verify loop structure
+void Loop::verifyLoop() const {
+#ifndef NDEBUG
+  assert (getHeader() && "Loop header is missing");
+  assert (getLoopPreheader() && "Loop preheader is missing");
+  assert (getLoopLatch() && "Loop latch is missing");
+  for (std::vector<Loop*>::const_iterator I = SubLoops.begin(), E = SubLoops.end();
+       I != E; ++I)
+    (*I)->verifyLoop();
+#endif
+}
+
 void Loop::dump() const {
   print(cerr);
 }
@@ -104,7 +116,6 @@
   TopLevelLoops.clear();
 }
 
-
 void LoopInfo::Calculate(DominatorTree &DT) {
   BasicBlock *RootNode = DT.getRootNode()->getBlock();
 

Modified: llvm/trunk/lib/Analysis/LoopPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopPass.cpp?rev=40062&r1=40061&r2=40062&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/LoopPass.cpp (original)
+++ llvm/trunk/lib/Analysis/LoopPass.cpp Thu Jul 19 13:02:32 2007
@@ -157,18 +157,6 @@
   Info.setPreservesAll();
 }
 
-/// verifyLoopInfo - Verify loop nest.
-void LPPassManager::verifyLoopInfo() {
-  assert (LI && "Loop Info is missing");
-
-  for (LoopInfo::iterator I = LI->begin(), E = LI->end(); I != E; ++I) {
-    Loop *L = *I;
-    assert (L->getHeader() && "Loop header is missing");
-    assert (L->getLoopPreheader() && "Loop preheader is missing");
-    assert (L->getLoopLatch() && "Loop latch is missing");
-  }
-}
-
 /// run - Execute all of the passes scheduled for execution.  Keep track of
 /// whether any of the passes modifies the function, and if so, return true.
 bool LPPassManager::runOnFunction(Function &F) {
@@ -214,13 +202,13 @@
       LoopPass *LP = dynamic_cast<LoopPass *>(P);
       assert (LP && "Invalid LPPassManager member");
       LP->runOnLoop(CurrentLoop, *this);
-      verifyLoopInfo();
       StopPassTimer(P);
 
       if (Changed)
         dumpPassInfo(P, MODIFICATION_MSG, ON_LOOP_MSG, "");
       dumpAnalysisSetInfo("Preserved", P, AnUsage.getPreservedSet());
-      
+
+      verifyPreservedAnalysis(LP);
       removeNotPreservedAnalysis(P);
       recordAvailableAnalysis(P);
       removeDeadPasses(P, "", ON_LOOP_MSG);

Modified: llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp?rev=40062&r1=40061&r2=40062&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp Thu Jul 19 13:02:32 2007
@@ -74,6 +74,16 @@
       AU.addPreserved<DominanceFrontier>();
       AU.addPreservedID(BreakCriticalEdgesID);  // No critical edges added.
     }
+
+    /// verifyAnalysis() - Verify loop nest.
+    void verifyAnalysis() const {
+#ifndef NDEBUG
+      LoopInfo *NLI = &getAnalysis<LoopInfo>();
+      for (LoopInfo::iterator I = NLI->begin(), E = NLI->end(); I != E; ++I) 
+        (*I)->verifyLoop();
+#endif  
+    }
+
   private:
     bool ProcessLoop(Loop *L);
     BasicBlock *SplitBlockPredecessors(BasicBlock *BB, const char *Suffix,

Modified: llvm/trunk/lib/VMCore/PassManager.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PassManager.cpp?rev=40062&r1=40061&r2=40062&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/PassManager.cpp (original)
+++ llvm/trunk/lib/VMCore/PassManager.cpp Thu Jul 19 13:02:32 2007
@@ -594,22 +594,30 @@
   return true;
 }
 
-/// Remove Analyss not preserved by Pass P
-void PMDataManager::removeNotPreservedAnalysis(Pass *P) {
+/// verifyPreservedAnalysis -- Verify analysis presreved by pass P.
+void PMDataManager::verifyPreservedAnalysis(Pass *P) {
   AnalysisUsage AnUsage;
   P->getAnalysisUsage(AnUsage);
   const std::vector<AnalysisID> &PreservedSet = AnUsage.getPreservedSet();
 
   // Verify preserved analysis
-  for (std::map<AnalysisID, Pass*>::iterator I = AvailableAnalysis.begin(),
-         E = AvailableAnalysis.end(); I != E; ++I) {
-    Pass *AP = I->second;
-    AP->verifyAnalysis();
+  for (std::vector<AnalysisID>::const_iterator I = PreservedSet.begin(),
+         E = PreservedSet.end(); I != E; ++I) {
+    AnalysisID AID = *I;
+    Pass *AP = findAnalysisPass(AID, true);
+    if (AP)
+      AP->verifyAnalysis();
   }
-  
+}
+
+/// Remove Analyss not preserved by Pass P
+void PMDataManager::removeNotPreservedAnalysis(Pass *P) {
+  AnalysisUsage AnUsage;
+  P->getAnalysisUsage(AnUsage);
   if (AnUsage.getPreservesAll())
     return;
 
+  const std::vector<AnalysisID> &PreservedSet = AnUsage.getPreservedSet();
   for (std::map<AnalysisID, Pass*>::iterator I = AvailableAnalysis.begin(),
          E = AvailableAnalysis.end(); I != E; ) {
     std::map<AnalysisID, Pass*>::iterator Info = I++;
@@ -954,6 +962,7 @@
         dumpPassInfo(BP, MODIFICATION_MSG, ON_BASICBLOCK_MSG, (*I).getName());
       dumpAnalysisSetInfo("Preserved", BP, AnUsage.getPreservedSet());
 
+      verifyPreservedAnalysis(BP);
       removeNotPreservedAnalysis(BP);
       recordAvailableAnalysis(BP);
       removeDeadPasses(BP, (*I).getName(), ON_BASICBLOCK_MSG);
@@ -1151,6 +1160,7 @@
       dumpPassInfo(FP, MODIFICATION_MSG, ON_FUNCTION_MSG, F.getName());
     dumpAnalysisSetInfo("Preserved", FP, AnUsage.getPreservedSet());
 
+    verifyPreservedAnalysis(FP);
     removeNotPreservedAnalysis(FP);
     recordAvailableAnalysis(FP);
     removeDeadPasses(FP, F.getName(), ON_FUNCTION_MSG);
@@ -1220,6 +1230,7 @@
                    M.getModuleIdentifier());
     dumpAnalysisSetInfo("Preserved", MP, AnUsage.getPreservedSet());
       
+    verifyPreservedAnalysis(MP);
     removeNotPreservedAnalysis(MP);
     recordAvailableAnalysis(MP);
     removeDeadPasses(MP, M.getModuleIdentifier(), ON_MODULE_MSG);





More information about the llvm-commits mailing list