[PATCH] LPM: Print after/before all passes during -print-{after, before}-all even if not registered.

Chandler Carruth chandlerc at gmail.com
Thu May 21 00:04:42 PDT 2015


Is this still relevant? If so, I'll put it in my queue.

On Mon, May 4, 2015 at 11:54 AM Peter Collingbourne <peter at pcc.me.uk> wrote:

> Hi chandlerc,
>
> Some MachineFunction passes are not properly registered using
> INITIALIZE_PASS,
> but this doesn't normally seem to matter. One way in which it does matter
> is
> that the -print-{after,before}-all flags have no effect when running those
> passes. This change modifies the code that implements these flags so that
> they print even if the pass is not registered (i.e. the PassInfo is null).
>
> It doesn't seem worth going through the existing MachineFunction passes to
> add
> registration, as the new pass manager seems to not require registration for
> most passes, and in any case one would expect the -print-{after,before}-all
> flags to do what they say, and not silently skip certain passes.
>
> http://reviews.llvm.org/D9482
>
> Files:
>   lib/IR/LegacyPassManager.cpp
>
> Index: lib/IR/LegacyPassManager.cpp
> ===================================================================
> --- lib/IR/LegacyPassManager.cpp
> +++ lib/IR/LegacyPassManager.cpp
> @@ -100,13 +100,19 @@
>  /// This is a utility to check whether a pass should have IR dumped
>  /// before it.
>  static bool ShouldPrintBeforePass(const PassInfo *PI) {
> -  return PrintBeforeAll || ShouldPrintBeforeOrAfterPass(PI, PrintBefore);
> +  if (PrintBeforeAll && !(PI && PI->isAnalysis()))
> +    return true;
> +  return PI && !PI->isAnalysis() &&
> +         ShouldPrintBeforeOrAfterPass(PI, PrintBefore);
>  }
>
>  /// This is a utility to check whether a pass should have IR dumped
>  /// after it.
>  static bool ShouldPrintAfterPass(const PassInfo *PI) {
> -  return PrintAfterAll || ShouldPrintBeforeOrAfterPass(PI, PrintAfter);
> +  if (PrintAfterAll && !(PI && PI->isAnalysis()))
> +    return true;
> +  return PI && !PI->isAnalysis() &&
> +         ShouldPrintBeforeOrAfterPass(PI, PrintAfter);
>  }
>
>  /// isPassDebuggingExecutionsOrMore - Return true if
> -debug-pass=Executions
> @@ -671,16 +677,16 @@
>      return;
>    }
>
> -  if (PI && !PI->isAnalysis() && ShouldPrintBeforePass(PI)) {
> +  if (ShouldPrintBeforePass(PI)) {
>      Pass *PP = P->createPrinterPass(
>        dbgs(), std::string("*** IR Dump Before ") + P->getPassName() + "
> ***");
>      PP->assignPassManager(activeStack, getTopLevelPassManagerType());
>    }
>
>    // Add the requested pass to the best available pass manager.
>    P->assignPassManager(activeStack, getTopLevelPassManagerType());
>
> -  if (PI && !PI->isAnalysis() && ShouldPrintAfterPass(PI)) {
> +  if (ShouldPrintAfterPass(PI)) {
>      Pass *PP = P->createPrinterPass(
>        dbgs(), std::string("*** IR Dump After ") + P->getPassName() + "
> ***");
>      PP->assignPassManager(activeStack, getTopLevelPassManagerType());
>
> EMAIL PREFERENCES
>   http://reviews.llvm.org/settings/panel/emailpreferences/
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150521/a8554fe5/attachment.html>


More information about the llvm-commits mailing list