OSDN Git Service

The pass manager is not able to schedule -loop-deletion -loop-index-split.
authorDevang Patel <dpatel@apple.com>
Thu, 14 Aug 2008 23:07:48 +0000 (23:07 +0000)
committerDevang Patel <dpatel@apple.com>
Thu, 14 Aug 2008 23:07:48 +0000 (23:07 +0000)
The loop-deletion pass does not preserve dom frontier, which is required by
loop-index-split. When the PM checks dom frontier for loop-index-split, it has
already verified that lcssa is availalble. However, new dom frontier forces new
loop pass manager, which does not  have lcssa yet.

The PM should recheck availability of required analysis passes in such cases.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54805 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/PassManager.cpp
test/Other/2008-08-14-PassManager.ll [new file with mode: 0644]

index 68a856a..d7b3cc7 100644 (file)
@@ -463,20 +463,34 @@ void PMTopLevelManager::schedulePass(Pass *P) {
 
   AnalysisUsage *AnUsage = findAnalysisUsage(P);
 
-  const AnalysisUsage::VectorType &RequiredSet = AnUsage->getRequiredSet();
-  for (AnalysisUsage::VectorType::const_iterator I = RequiredSet.begin(),
-         E = RequiredSet.end(); I != E; ++I) {
-
-    Pass *AnalysisPass = findAnalysisPass(*I);
-    if (!AnalysisPass) {
-      AnalysisPass = (*I)->createPass();
-      // Schedule this analysis run first only if it is not a lower level
-      // analysis pass. Lower level analsyis passes are run on the fly.
-      if (P->getPotentialPassManagerType () >=
-          AnalysisPass->getPotentialPassManagerType())
-        schedulePass(AnalysisPass);
-      else
-        delete AnalysisPass;
+  bool checkAnalysis = true;
+  while (checkAnalysis) {
+    checkAnalysis = false;
+  
+    const AnalysisUsage::VectorType &RequiredSet = AnUsage->getRequiredSet();
+    for (AnalysisUsage::VectorType::const_iterator I = RequiredSet.begin(),
+           E = RequiredSet.end(); I != E; ++I) {
+      
+      Pass *AnalysisPass = findAnalysisPass(*I);
+      if (!AnalysisPass) {
+        AnalysisPass = (*I)->createPass();
+        if (P->getPotentialPassManagerType () ==
+            AnalysisPass->getPotentialPassManagerType())
+          // Schedule analysis pass that is managed by the same pass manager.
+          schedulePass(AnalysisPass);
+        else if (P->getPotentialPassManagerType () >
+                 AnalysisPass->getPotentialPassManagerType()) {
+          // Schedule analysis pass that is managed by a new manager.
+          schedulePass(AnalysisPass);
+          // Recheck analysis passes to ensure that required analysises that
+          // are already checked are still available.
+          checkAnalysis = true;
+        }
+        else
+          // Do not schedule this analysis. Lower level analsyis 
+          // passes are run on the fly.
+          delete AnalysisPass;
+      }
     }
   }
 
diff --git a/test/Other/2008-08-14-PassManager.ll b/test/Other/2008-08-14-PassManager.ll
new file mode 100644 (file)
index 0000000..110f380
--- /dev/null
@@ -0,0 +1,5 @@
+; RUN:  llvm-as < %s |  opt -loop-deletion -loop-index-split -disable-output
+; PR 2640
+define i32 @test1() {
+       ret i32 0;
+}