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

Peter Collingbourne peter at pcc.me.uk
Mon May 4 11:50:35 PDT 2015


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/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9482.24901.patch
Type: text/x-patch
Size: 1792 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150504/eac08fa2/attachment.bin>


More information about the llvm-commits mailing list