[PATCH] D102463: Making Instrumentation aware of LoopNest Pass

Raghesh Aloor via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 13 21:44:41 PDT 2021


raghesh created this revision.
raghesh added a reviewer: aeubanks.
Herald added a subscriber: hiraditya.
raghesh requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Intrumentation callbacks are not made aware of LoopNest passes. From the loop pass manager, we now pass the outermost loop of the LoopNest to instrumentation in case of LoopNest passes.

The current patch made the change in two places in StandardInstrumentation.cpp. I will submit a proper patch where the OuterMostLoop is passed from the LoopPassManager to the call backs. That way we will avoid making changes at multiple places in StandardInstrumentation.cpp.

A testcase also will be submitted.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102463

Files:
  llvm/lib/Passes/StandardInstrumentations.cpp


Index: llvm/lib/Passes/StandardInstrumentations.cpp
===================================================================
--- llvm/lib/Passes/StandardInstrumentations.cpp
+++ llvm/lib/Passes/StandardInstrumentations.cpp
@@ -19,6 +19,7 @@
 #include "llvm/Analysis/CallGraphSCCPass.h"
 #include "llvm/Analysis/LazyCallGraph.h"
 #include "llvm/Analysis/LoopInfo.h"
+#include "llvm/Analysis/LoopNestAnalysis.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/LegacyPassManager.h"
 #include "llvm/IR/Module.h"
@@ -290,6 +291,15 @@
     return OS.str();
   }
 
+  if (any_isa<const LoopNest *>(IR)) {
+    const Loop *L = &any_cast<const LoopNest *>(IR)->getOutermostLoop();
+    std::string S;
+    raw_string_ostream OS(S);
+    assert(L && "Loop should be valid for printing");
+    L->print(OS, /*Verbose*/ false, /*PrintNested*/ false);
+    return OS.str();
+  }
+
   llvm_unreachable("Unknown wrapped IR type");
 }
 
@@ -858,7 +868,11 @@
   if (!ShouldRun && DebugLogging) {
     errs() << "Skipping pass " << PassID << " on " << F->getName()
            << " due to optnone attribute\n";
+  } else if (any_isa<const LoopNest *>(IR)) {
+    const Loop *L = &any_cast<const LoopNest *>(IR)->getOutermostLoop();
+    F = L->getHeader()->getParent();
   }
+
   return ShouldRun;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102463.345349.patch
Type: text/x-patch
Size: 1282 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210514/8a5fa1f5/attachment.bin>


More information about the llvm-commits mailing list