[cfe-dev] Patch for fixing infinite rec. within PMTopLevelManager::schedulePass
Chris Lattner
clattner at apple.com
Thu Feb 25 08:52:49 PST 2010
On Feb 25, 2010, at 8:24 AM, philipp.legrum at daimler.com 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
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100225/661c17f3/attachment.html>
More information about the cfe-dev
mailing list