[PATCH] D102956: [polly] Port NewPM PassInstrumentation to Scop passes.

2 views
Skip to first unread message

Eli Friedman via Phabricator

unread,
May 21, 2021, 7:25:13 PMMay 21
to efri...@quicinc.com, fedor....@azul.com, aeub...@google.com, yuanfa...@sony.com, ll...@meinersbur.de, pfa...@google.com, siddu...@gmail.com, poll...@googlegroups.com, llvm-c...@lists.llvm.org, bhuvanend...@amd.com, 888...@gmail.com, doug...@gmail.com, czhe...@cn.ibm.com, ruilin...@amd.com, kuh...@google.com
efriedma created this revision.
efriedma added reviewers: fedor.sergeev, aeubanks, ychen, Meinersbur, pfaffe.
Herald added a reviewer: bollu.
efriedma requested review of this revision.
Herald added a project: LLVM.

Makes opt-bisect work with scop passes.


Repository:
rG LLVM Github Monorepo

https://reviews.llvm.org/D102956

Files:
polly/lib/Analysis/ScopPass.cpp


Index: polly/lib/Analysis/ScopPass.cpp
===================================================================
--- polly/lib/Analysis/ScopPass.cpp
+++ polly/lib/Analysis/ScopPass.cpp
@@ -76,10 +76,16 @@
PassManager<Scop, ScopAnalysisManager, ScopStandardAnalysisResults &,
SPMUpdater &>::run(Scop &S, ScopAnalysisManager &AM,
ScopStandardAnalysisResults &AR, SPMUpdater &U) {
+ PassInstrumentation PI = AM.getResult<PassInstrumentationAnalysis>(S, AR);
auto PA = PreservedAnalyses::all();
for (auto &Pass : Passes) {
+ if (!PI.runBeforePass<Scop>(*Pass, S))
+ continue;
+
auto PassPA = Pass->run(S, AM, AR, U);

+ PI.runAfterPass(*Pass, S, PassPA);
+
AM.invalidate(S, PassPA);
PA.intersect(std::move(PassPA));
}


D102956.347149.patch

Arthur Eubanks via Phabricator

unread,
May 21, 2021, 7:42:38 PMMay 21
to efri...@quicinc.com, fedor....@azul.com, aeub...@google.com, yuanfa...@sony.com, ll...@meinersbur.de, pfa...@google.com, siddu...@gmail.com, poll...@googlegroups.com, llvm-c...@lists.llvm.org, bhuvanend...@amd.com, 888...@gmail.com, doug...@gmail.com, czhe...@cn.ibm.com, ruilin...@amd.com, kuh...@google.com
aeubanks added a comment.

I think FunctionToScopPassAdaptor also needs this
any tests?


Repository:
rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102956

Michael Kruse via Phabricator

unread,
May 25, 2021, 7:59:56 PMMay 25
to efri...@quicinc.com, fedor....@azul.com, aeub...@google.com, yuanfa...@sony.com, pfa...@google.com, siddu...@gmail.com, poll...@googlegroups.com, llvm-c...@lists.llvm.org, bhuvanend...@amd.com, 888...@gmail.com, doug...@gmail.com, czhe...@cn.ibm.com, ruilin...@amd.com, kuh...@google.com
Meinersbur added a comment.

If I recall correctly, I also tired to this. Unfortunately I encountered a design problem.

Running `-print-after-all` (which uses PassInstrumentation to insert a printer pass) crashes:

$ opt newpm.ll -polly -O3 -print-after-all
[...]
Unknown wrapped IR type
UNREACHABLE executed at /home/meinersbur/src/llvm-project/llvm/lib/Passes/StandardInstrumentations.cpp:321!
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0. Program arguments: /home/meinersbur/build/llvm-project/release/bin/opt newpm.ll -polly -O3 -print-after-all
#0 0x00007f1ed0880081 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/meinersbur/build/llvm-project/release/bin/opt+0x2cc4081)
#1 0x00007f1ed087dab4 llvm::sys::RunSignalHandlers() (/home/meinersbur/build/llvm-project/release/bin/opt+0x2cc1ab4)
#2 0x00007f1ed087dc2b SignalHandler(int) Signals.cpp:0:0
#3 0x00007f1ecdb643c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
#4 0x00007f1ecd5c618b raise /build/glibc-eX1tMB/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#5 0x00007f1ecd5a5859 abort /build/glibc-eX1tMB/glibc-2.31/stdlib/abort.c:81:7
#6 0x00007f1ed07cdd4e (/home/meinersbur/build/llvm-project/release/bin/opt+0x2c11d4e)
#7 0x00007f1ed0c49807 (anonymous namespace)::shouldPrintIR(llvm::Any) StandardInstrumentations.cpp:0:0
#8 0x00007f1ed0c4fbe0 llvm::PrintIRInstrumentation::printAfterPass(llvm::StringRef, llvm::Any) (/home/meinersbur/build/llvm-project/release/bin/opt+0x3093be0)
#9 0x00007f1ed0c4fe96 void llvm::detail::UniqueFunctionBase<void, llvm::StringRef, llvm::Any, llvm::PreservedAnalyses const&>::CallImpl<llvm::PrintIRInstrumentation::registerCallbacks(llvm::PassInstrumentationCallbacks&)::'lambda0'(llvm::StringRef, llvm::Any, llvm::PreservedAnalyses const&)>(void*, llvm::StringRef, llvm::Any&, llvm::PreservedAnalyses const&) StandardInstrumentations.cpp:0:0
#10 0x00007f1ed0d9d30b llvm::PassManager<polly::Scop, llvm::AnalysisManager<polly::Scop, polly::ScopStandardAnalysisResults&>, polly::ScopStandardAnalysisResults&, polly::SPMUpdater&>::run(polly::Scop&, llvm::AnalysisManager<polly::Scop, polly::ScopStandardAnalysisResults&>&, polly::ScopStandardAnalysisResults&, polly::SPMUpdater&) (/home/meinersbur/build/llvm-project/release/bin/opt+0x31e130b)
#11 0x00007f1ed0d2f913 polly::FunctionToScopPassAdaptor<llvm::PassManager<polly::Scop, llvm::AnalysisManager<polly::Scop, polly::ScopStandardAnalysisResults&>, polly::ScopStandardAnalysisResults&, polly::SPMUpdater&> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) RegisterPasses.cpp:0:0

This is because it calls the instrumentation's IRUnit-generic function meant to handle all IRUints (Module, SCC, Function, Loop). Unfortunately nobody though about custom PassManagers, so it crashes when not knowing what to do with the IRUnit of a Scop.

I settled to just ignoring the Scop pass instrumentations instead of crashing. To fix this properly, PassPlugin would need an additional interface for how to handled additional IRUnits.
Reply all
Reply to author
Forward
0 new messages