Patch for fixing infinite rec. within PMTopLevelManager::schedulePass

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Patch for fixing infinite rec. within PMTopLevelManager::schedulePass

philipp.legrum

Hello Developers,

I figured, that trying to load two passes that require each other results in an infinite recursion of PMTopLevelManager::schedulePass
So I added tracing if schedulePass processes a pass that an outer invocation of schedulePass is already processing.
If so, it aborts with an error message and outputs the cycle.

Would be nice if someone could review the patch and apply if suitable and/or give me feedback.

Thank you.
Philipp



Index: include/llvm/PassManagers.h
===================================================================
--- include/llvm/PassManagers.h        (revision 97141)
+++ include/llvm/PassManagers.h        (working copy)
@@ -256,6 +256,10 @@
   SmallVector<ImmutablePass *, 8> ImmutablePasses;
 
   DenseMap<Pass *, AnalysisUsage *> AnUsageMap;
+
+  // Stack to keep track of circular module dependencies
+  // during pass scheduling.
+  SmallVector<const PassInfo *, 12> schedulingTrace;
 };
 
 
Index: lib/VMCore/PassManager.cpp
===================================================================
--- lib/VMCore/PassManager.cpp        (revision 97141)
+++ lib/VMCore/PassManager.cpp        (working copy)
@@ -495,6 +495,26 @@
   // TODO : Allocate function manager for this pass, other wise required set
   // may be inserted into previous function manager
 
+  // Monitor circular dependencies of passes
+  SmallVector<const PassInfo *, 12>::iterator result =
+  std::find(schedulingTrace.begin(), schedulingTrace.end(),
+            P->getPassInfo());
+  
+  // If we are about to schedule a pass we are already scheduling
+  // we have detected a cyclic requirement.
+  if (result != schedulingTrace.end()){
+    errs() << "Error: Pass scheduler detected cyclic requirement in passes:\n";
+    for (SmallVector<const PassInfo *, 12>::iterator I = result,
+         E = schedulingTrace.end(); I != E; ++I){
+      errs() << "  " << (*I)->getPassName() << "\n";
+    }
+    errs() << "  " << (*result)->getPassName() << "\n";
+    exit(-1);
+  }
+  
+  // Track the recursive pass scheduling
+  schedulingTrace.push_back(P->getPassInfo());
+
   // Give pass a chance to prepare the stage.
   P->preparePassManager(activeStack);
 
@@ -539,6 +559,7 @@
       }
     }
   }
+  schedulingTrace.pop_back();
 
   // Now all required passes are available.
   addTopLevelPass(P);
If you are not the intended addressee, please inform us immediately that you have received this e-mail in error, and delete it. We thank you for your cooperation.


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Patch for fixing infinite rec. within PMTopLevelManager::schedulePass

Chris Lattner

On Feb 25, 2010, at 8:24 AM, [hidden email] wrote:


Hello Developers,

I figured, that trying to load two passes that require each other results in an infinite recursion of PMTopLevelManager::schedulePass
So I added tracing if schedulePass processes a pass that an outer invocation of schedulePass is already processing.
If so, it aborts with an error message and outputs the cycle.

Would be nice if someone could review the patch and apply if suitable and/or give me feedback.

Hi Phillipp, this would probably be best if directed to the llvmdev mailing list, since it's about the LLVM passmanager,

-Chris


Thank you.
Philipp



Index: include/llvm/PassManagers.h
===================================================================
--- include/llvm/PassManagers.h        (revision 97141)
+++ include/llvm/PassManagers.h        (working copy)
@@ -256,6 +256,10 @@
   SmallVector<ImmutablePass *, 8> ImmutablePasses;
 
   DenseMap<Pass *, AnalysisUsage *> AnUsageMap;
+
+  // Stack to keep track of circular module dependencies
+  // during pass scheduling.
+  SmallVector<const PassInfo *, 12> schedulingTrace;
 };
 
 
Index: lib/VMCore/PassManager.cpp
===================================================================
--- lib/VMCore/PassManager.cpp        (revision 97141)
+++ lib/VMCore/PassManager.cpp        (working copy)
@@ -495,6 +495,26 @@
   // TODO : Allocate function manager for this pass, other wise required set
   // may be inserted into previous function manager
 
+  // Monitor circular dependencies of passes
+  SmallVector<const PassInfo *, 12>::iterator result =
+  std::find(schedulingTrace.begin(), schedulingTrace.end(),
+            P->getPassInfo());
+  
+  // If we are about to schedule a pass we are already scheduling
+  // we have detected a cyclic requirement.
+  if (result != schedulingTrace.end()){
+    errs() << "Error: Pass scheduler detected cyclic requirement in passes:\n";
+    for (SmallVector<const PassInfo *, 12>::iterator I = result,
+         E = schedulingTrace.end(); I != E; ++I){
+      errs() << "  " << (*I)->getPassName() << "\n";
+    }
+    errs() << "  " << (*result)->getPassName() << "\n";
+    exit(-1);
+  }
+  
+  // Track the recursive pass scheduling
+  schedulingTrace.push_back(P->getPassInfo());
+
   // Give pass a chance to prepare the stage.
   P->preparePassManager(activeStack);
 
@@ -539,6 +559,7 @@
       }
     }
   }
+  schedulingTrace.pop_back();
 
   // Now all required passes are available.
   addTopLevelPass(P);
If you are not the intended addressee, please inform us immediately that you have received this e-mail in error, and delete it. We thank you for your cooperation.

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Debugging clang

Alexander Herz
In reply to this post by philipp.legrum
Hi,

I'm trying to debug the clang cpp compiler because I suspect a bug in
the creation of the debug meta data for some cpp source. Is there an
easy way to stop clang from spawning a new clang process (which does the
compilation) and have the original instance of clang just do it so I can
debug into the compilation process??

Thx,
Alex
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Debugging clang

Jean-Daniel Dupas-2

Le 9 août 2010 à 14:12, Alexander Herz a écrit :

> Hi,
>
> I'm trying to debug the clang cpp compiler because I suspect a bug in
> the creation of the debug meta data for some cpp source. Is there an
> easy way to stop clang from spawning a new clang process (which does the
> compilation) and have the original instance of clang just do it so I can
> debug into the compilation process??
>
> Thx,

When you try to compile your file, add the '-v' argument. Clang will output the full invocation of the spawned process.
Then, you can just copy this line and launch clang using it.

-- Jean-Daniel





_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Debugging clang

Alexander Herz
Ok, that helps.

Is there a way to make gdb pretty print all the llvm::SmallVector
thingies so that one can actually read a string and the like while
debugging?

Thx,
Alex

On 08/09/2010 02:33 PM, Jean-Daniel Dupas wrote:

> Le 9 août 2010 à 14:12, Alexander Herz a écrit :
>
>    
>> Hi,
>>
>> I'm trying to debug the clang cpp compiler because I suspect a bug in
>> the creation of the debug meta data for some cpp source. Is there an
>> easy way to stop clang from spawning a new clang process (which does the
>> compilation) and have the original instance of clang just do it so I can
>> debug into the compilation process??
>>
>> Thx,
>>      
> When you try to compile your file, add the '-v' argument. Clang will output the full invocation of the spawned process.
> Then, you can just copy this line and launch clang using it.
>
> -- Jean-Daniel
>
>
>
>
>    

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Debug Info, access modifier for methods missing?

Alexander Herz
Hi,

I'm toying with the debug info from a cpp class def. Aparently the
access modifiers for member variables and inheritance (private,
protected, public) are maintained (DIType::isPrivate() , ...). Is there
a way to figure out whether a subprogram is private or not??

Thx,
Alex
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev