<div dir="ltr">Hi Arthur,<div><br></div><div>Thanks for that update. Do you mean to say that runSinglePass is a (one of the) common place(s) where we can pass the Loop to PassInstrumentation even in LoopNest Mode? That would be ideal rather than updating PassInstrumentation as I could see other places also (similar to the following) where we should do the same.</div><div><br></div><div>--- a/llvm/lib/Passes/StandardInstrumentations.cpp<br>+++ b/llvm/lib/Passes/StandardInstrumentations.cpp<br>@@ -861,6 +861,13 @@ bool OptNoneInstrumentation::shouldRun(StringRef PassID, Any IR) {<br> } else if (any_isa<const Loop *>(IR)) {<br> F = any_cast<const Loop *>(IR)->getHeader()->getParent();<br> }<br>+ else if (any_isa<const LoopNest *>(IR)) {<br>+ const Loop *L = &any_cast<const LoopNest *>(IR)->getOutermostLoop();<br>+ F = L->getHeader()->getParent();<br>+ }<br>+<br> bool ShouldRun = !(F && F->hasOptNone());<br> if (!ShouldRun && DebugLogging) {<br> errs() << "Skipping pass " << PassID << " on " << F->getName()</div><div><br></div><div>Regards,<br><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>------------------------------</div><div>Raghesh Aloor</div><div>AMD India Pvt. Ltd.</div><div>Bengaluru.</div><div>------------------------------</div></div></div></div></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, May 12, 2021 at 10:07 PM Arthur Eubanks <<a href="mailto:aeubanks@google.com">aeubanks@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Looks like even in LoopNest mode, FunctionToLoopPassAdaptor passes a Loop to PassInstrumentation. But LoopPassManager::runSinglePass either passes a Loop or LoopNest. Seems like that should be fixed to always pass the Loop to PassInstrumentation.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, May 11, 2021 at 11:26 PM raghesh via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi All<div><br></div><div>While working on a LoopNest pass, I hit 'unreachable code' in the getIRName, which is invoked as part of debugging options (like -debug-pass-manager). It is figured out that within getIRName, LoopNest is not handled. I could fix it with the following patch.</div><div><br></div><div>diff --git a/llvm/lib/Passes/StandardInstrumentations.cpp b/llvm/lib/Passes/StandardInstrumentations.cpp<br>index e64df0b1147f..65e0e7d4cf27 100644<br>--- a/llvm/lib/Passes/StandardInstrumentations.cpp<br>+++ b/llvm/lib/Passes/StandardInstrumentations.cpp<br>@@ -20,6 +20,7 @@<br> #include "llvm/Analysis/LazyCallGraph.h"<br> #include "llvm/Analysis/LoopInfo.h"<br> #include "llvm/IR/Function.h"<br>+#include "llvm/Analysis/LoopNestAnalysis.h" <br> #include "llvm/IR/Module.h"<br> #include "llvm/IR/PassInstrumentation.h"<br> #include "llvm/IR/PassManager.h"<br>@@ -285,6 +286,17 @@ std::string getIRName(Any IR) {<br> return OS.str();<br> }<br> <br>+ if (any_isa<const LoopNest *>(IR)) {<br>+ const Loop *L = &any_cast<const LoopNest *>(IR)->getOutermostLoop();<br>+ std::string S;<br>+ raw_string_ostream OS(S);<br>+ assert(L && "Loop should be valid for printing");<br>+ L->print(OS, /*Verbose*/ false, /*PrintNested*/ false);<br>+ return OS.str();<br>+ }<br>+<br> llvm_unreachable("Unknown wrapped IR type");<br> }</div><div><br></div><div>Just wanted to make sure that this is the right fix and if it is so we can upstream this change.</div><div><br></div><div>Regards,</div><div><div><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>------------------------------</div><div>Raghesh Aloor</div><div>AMD India Pvt. Ltd.</div><div>Bengaluru.</div><div>------------------------------</div></div></div></div></div></div></div></div></div></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>
</blockquote></div>