[PATCH] D102463: Making Instrumentation aware of LoopNest Pass

Raghesh Aloor via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 16 23:25:24 PDT 2021


raghesh updated this revision to Diff 345754.
raghesh added a comment.

Passing the outermost loop from LoopPassManager to the call backs in case of LoopNest pass.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102463/new/

https://reviews.llvm.org/D102463

Files:
  llvm/include/llvm/Transforms/Scalar/LoopPassManager.h


Index: llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
===================================================================
--- llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
+++ llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
@@ -358,9 +358,14 @@
 Optional<PreservedAnalyses> LoopPassManager::runSinglePass(
     IRUnitT &IR, PassT &Pass, LoopAnalysisManager &AM,
     LoopStandardAnalysisResults &AR, LPMUpdater &U, PassInstrumentation &PI) {
+  // Pass the outermost loop to BeforePass and AfterPass callbacks in case of
+  // LoopNest Pass.
+  const Loop *L = any_isa<const LoopNest *>(&IR)
+                      ? &any_cast<const LoopNest *>(&IR)->getOutermostLoop()
+                      : any_cast<const Loop *>(&IR);
   // Check the PassInstrumentation's BeforePass callbacks before running the
   // pass, skip its execution completely if asked to (callback returns false).
-  if (!PI.runBeforePass<IRUnitT>(*Pass, IR))
+  if (!PI.runBeforePass<Loop>(*Pass, *L))
     return None;
 
   PreservedAnalyses PA;
@@ -373,7 +378,7 @@
   if (U.skipCurrentLoop())
     PI.runAfterPassInvalidated<IRUnitT>(*Pass, PA);
   else
-    PI.runAfterPass<IRUnitT>(*Pass, IR, PA);
+    PI.runAfterPass<Loop>(*Pass, *L, PA);
   return PA;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102463.345754.patch
Type: text/x-patch
Size: 1254 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210517/9da2d158/attachment.bin>


More information about the llvm-commits mailing list