<br><font size=2 face="sans-serif">Hello Developers,</font><br><br><font size=2 face="sans-serif">I figured, that trying to load two passes
that require each other results in an infinite recursion of PMTopLevelManager::schedulePass</font><br><font size=2 face="sans-serif">So I added tracing if schedulePass processes
a pass that an outer invocation of schedulePass is already processing.</font><br><font size=2 face="sans-serif">If so, it aborts with an error message
and outputs the cycle.</font><br><br><font size=2 face="sans-serif">Would be nice if someone could review
the patch and apply if suitable and/or give me feedback.</font><br><br><font size=2 face="sans-serif">Thank you.</font><br><font size=2 face="sans-serif">Philipp</font><br><br><br><br><font size=2 face="sans-serif">Index: include/llvm/PassManagers.h</font><br><font size=2 face="sans-serif">===================================================================</font><br><font size=2 face="sans-serif">--- include/llvm/PassManagers.h
(revision 97141)</font><br><font size=2 face="sans-serif">+++ include/llvm/PassManagers.h
(working copy)</font><br><font size=2 face="sans-serif">@@ -256,6 +256,10 @@</font><br><font size=2 face="sans-serif"> SmallVector<ImmutablePass
*, 8> ImmutablePasses;</font><br><font size=2 face="sans-serif"> </font><br><font size=2 face="sans-serif"> DenseMap<Pass *, AnalysisUsage
*> AnUsageMap;</font><br><font size=2 face="sans-serif">+</font><br><font size=2 face="sans-serif">+ // Stack to keep track of circular
module dependencies</font><br><font size=2 face="sans-serif">+ // during pass scheduling.</font><br><font size=2 face="sans-serif">+ SmallVector<const PassInfo
*, 12> schedulingTrace;</font><br><font size=2 face="sans-serif"> };</font><br><font size=2 face="sans-serif"> </font><br><font size=2 face="sans-serif"> </font><br><font size=2 face="sans-serif">Index: lib/VMCore/PassManager.cpp</font><br><font size=2 face="sans-serif">===================================================================</font><br><font size=2 face="sans-serif">--- lib/VMCore/PassManager.cpp
(revision 97141)</font><br><font size=2 face="sans-serif">+++ lib/VMCore/PassManager.cpp
(working copy)</font><br><font size=2 face="sans-serif">@@ -495,6 +495,26 @@</font><br><font size=2 face="sans-serif"> // TODO : Allocate function
manager for this pass, other wise required set</font><br><font size=2 face="sans-serif"> // may be inserted into
previous function manager</font><br><font size=2 face="sans-serif"> </font><br><font size=2 face="sans-serif">+ // Monitor circular dependencies
of passes</font><br><font size=2 face="sans-serif">+ SmallVector<const PassInfo
*, 12>::iterator result =</font><br><font size=2 face="sans-serif">+ std::find(schedulingTrace.begin(),
schedulingTrace.end(),</font><br><font size=2 face="sans-serif">+
P->getPassInfo());</font><br><font size=2 face="sans-serif">+ </font><br><font size=2 face="sans-serif">+ // If we are about to schedule
a pass we are already scheduling</font><br><font size=2 face="sans-serif">+ // we have detected a cyclic
requirement.</font><br><font size=2 face="sans-serif">+ if (result != schedulingTrace.end()){</font><br><font size=2 face="sans-serif">+ errs() << "Error:
Pass scheduler detected cyclic requirement in passes:\n";</font><br><font size=2 face="sans-serif">+ for (SmallVector<const
PassInfo *, 12>::iterator I = result,</font><br><font size=2 face="sans-serif">+ E = schedulingTrace.end();
I != E; ++I){</font><br><font size=2 face="sans-serif">+ errs() <<
" " << (*I)->getPassName() << "\n";</font><br><font size=2 face="sans-serif">+ }</font><br><font size=2 face="sans-serif">+ errs() << "
" << (*result)->getPassName() << "\n";</font><br><font size=2 face="sans-serif">+ exit(-1);</font><br><font size=2 face="sans-serif">+ }</font><br><font size=2 face="sans-serif">+ </font><br><font size=2 face="sans-serif">+ // Track the recursive pass
scheduling</font><br><font size=2 face="sans-serif">+ schedulingTrace.push_back(P->getPassInfo());</font><br><font size=2 face="sans-serif">+</font><br><font size=2 face="sans-serif"> // Give pass a chance to
prepare the stage.</font><br><font size=2 face="sans-serif"> P->preparePassManager(activeStack);</font><br><font size=2 face="sans-serif"> </font><br><font size=2 face="sans-serif">@@ -539,6 +559,7 @@</font><br><font size=2 face="sans-serif"> }</font><br><font size=2 face="sans-serif"> }</font><br><font size=2 face="sans-serif"> }</font><br><font size=2 face="sans-serif">+ schedulingTrace.pop_back();</font><br><font size=2 face="sans-serif"> </font><br><font size=2 face="sans-serif"> // Now all required passes
are available.</font><br><font size=2 face="sans-serif"> addTopLevelPass(P);</font><font face="sans-serif"><font face="sans-serif, Arial, Helvetica" size="-1" color="#808080"><br>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.
<br></br>
</font></font>