Page MenuHomePhabricator

[NewPM] Use the default AA pipeline by default
ClosedPublic

Authored by aeubanks on Thu, Nov 4, 11:26 AM.

Details

Summary

We almost always want to use the default AA pipeline. It's very easy for
users of PassBuilder to forget to customize the AAManager to use the
default AA pipeline (for example, the NewPM C API forgets to do this).

If somebody wants a custom AA pipeline, similar to what is being done
now with the default AA pipeline registration, they can

FAM.registerPass([&] { return std::move(MyAA); });

before calling

PB.registerFunctionAnalyses(FAM);

For example, LTOBackend.cpp and NewPMDriver.cpp do this.

Diff Detail

Event Timeline

aeubanks created this revision.Thu, Nov 4, 11:26 AM
aeubanks requested review of this revision.Thu, Nov 4, 11:26 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptThu, Nov 4, 11:26 AM

Can you also update lib/LTO/LTOBackend.cpp to something like:

// Parse a custom AA pipeline if asked to, otherwise the default will be used.
if (!Conf.AAPipeline.empty()) {
  AAManager AA;
  if (auto Err = PB.parseAAPipeline(AA, Conf.AAPipeline)) {
    report_fatal_error(Twine("unable to parse AA pipeline description '") +
                       Conf.AAPipeline + "': " + toString(std::move(Err)));
  }
  // Register the AA manager first so that our version is the one used.
  FAM.registerPass([&] { return std::move(AA); });
}
aeubanks updated this revision to Diff 384842.Thu, Nov 4, 12:17 PM

update LTOBackend.cpp

asbirlea accepted this revision.Thu, Nov 4, 12:22 PM
This revision is now accepted and ready to land.Thu, Nov 4, 12:22 PM
This revision was landed with ongoing or failed builds.Thu, Nov 4, 3:11 PM
This revision was automatically updated to reflect the committed changes.

This change caused the Polly build to fail: https://lab.llvm.org/buildbot/#/builders/10/builds/7501

opt: /home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.src/llvm/include/llvm/IR/PassManager.h:784: typename PassT::Result& llvm::AnalysisManager<IRUnitT, ExtraArgTs>::getResult(IRUnitT&, ExtraArgTs ...) [with PassT = llvm::OuterAnalysisManagerProxy<llvm::AnalysisManager<llvm::Module>, llvm::Function>; IRUnitT = llvm::Function; ExtraArgTs = {}; typename PassT::Result = llvm::OuterAnalysisManagerProxy<llvm::AnalysisManager<llvm::Module>, llvm::Function>::Result]: Assertion `AnalysisPasses.count(PassT::ID()) && "This analysis pass was not registered prior to being queried"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.obj/bin/opt -polly-process-unprofitable -polly-remarks-minimal -polly-use-llvm-names -polly-import-jscop-dir=/home/worker/src/llvm-project/polly/test/ScopInliner -polly-codegen-verify -polly-detect-full-functions -polly-scop-inliner -polly-scops -analyze
1.	Running pass 'CallGraph Pass Manager' on module '<stdin>'.
 #0 0x00007fcc7bb29644 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x00007fcc7bb26d5e SignalHandler(int) Signals.cpp:0:0
 #2 0x00007fcc7b541210 (/lib/x86_64-linux-gnu/libc.so.6+0x46210)
 #3 0x00007fcc7b54118b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4618b)
 #4 0x00007fcc7b520859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x25859)
 #5 0x00007fcc7b520729 (/lib/x86_64-linux-gnu/libc.so.6+0x25729)
 #6 0x00007fcc7b531f36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
 #7 0x00007fcc7dbcb34f void llvm::AAManager::getModuleAAResultImpl<llvm::GlobalsAA>(llvm::Function&, llvm::AnalysisManager<llvm::Function>&, llvm::AAResults&) PassBuilder.cpp:0:0
 #8 0x00007fcc7c3c5363 llvm::AAManager::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.obj/./lib/libLLVMAnalysis.so.14git+0x257363)
 #9 0x0000563487033358 llvm::detail::AnalysisPassModel<llvm::Function, llvm::AAManager, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>::Invalidator>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) NewPMDriver.cpp:0:0
#10 0x00007fcc7bf95dd8 llvm::AnalysisManager<llvm::Function>::getResultImpl(llvm::AnalysisKey*, llvm::Function&) (/home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.obj/./lib/libLLVMCore.so.14git+0x450dd8)
#11 0x00007fcc7e84892a polly::ScopAnalysis::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.obj/./lib/libPolly.so.14git+0x13c92a)
#12 0x00007fcc7e962aa4 llvm::detail::AnalysisPassModel<llvm::Function, polly::ScopAnalysis, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>::Invalidator>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) RegisterPasses.cpp:0:0
#13 0x00007fcc7bf95dd8 llvm::AnalysisManager<llvm::Function>::getResultImpl(llvm::AnalysisKey*, llvm::Function&) (/home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.obj/./lib/libLLVMCore.so.14git+0x450dd8)
#14 0x00007fcc7e9d7d7c (anonymous namespace)::ScopInliner::runOnSCC(llvm::CallGraphSCC&) ScopInliner.cpp:0:0
#15 0x00007fcc7c46dfef (anonymous namespace)::CGPassManager::runOnModule(llvm::Module&) CallGraphSCCPass.cpp:0:0
#16 0x00007fcc7bf4dee2 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.obj/./lib/libLLVMCore.so.14git+0x408ee2)
#17 0x0000563487054571 main (/home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.obj/bin/opt+0x48571)
#18 0x00007fcc7b5220b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b3)
#19 0x0000563487030c8e _start (/home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.obj/bin/opt+0x24c8e)

Polly is not using custom AliasAnalysis. Any idea how to fix this?

Btw, the pre-merge check failed because of this as well.

This change caused the Polly build to fail: https://lab.llvm.org/buildbot/#/builders/10/builds/7501

opt: /home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.src/llvm/include/llvm/IR/PassManager.h:784: typename PassT::Result& llvm::AnalysisManager<IRUnitT, ExtraArgTs>::getResult(IRUnitT&, ExtraArgTs ...) [with PassT = llvm::OuterAnalysisManagerProxy<llvm::AnalysisManager<llvm::Module>, llvm::Function>; IRUnitT = llvm::Function; ExtraArgTs = {}; typename PassT::Result = llvm::OuterAnalysisManagerProxy<llvm::AnalysisManager<llvm::Module>, llvm::Function>::Result]: Assertion `AnalysisPasses.count(PassT::ID()) && "This analysis pass was not registered prior to being queried"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.obj/bin/opt -polly-process-unprofitable -polly-remarks-minimal -polly-use-llvm-names -polly-import-jscop-dir=/home/worker/src/llvm-project/polly/test/ScopInliner -polly-codegen-verify -polly-detect-full-functions -polly-scop-inliner -polly-scops -analyze
1.	Running pass 'CallGraph Pass Manager' on module '<stdin>'.
 #0 0x00007fcc7bb29644 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x00007fcc7bb26d5e SignalHandler(int) Signals.cpp:0:0
 #2 0x00007fcc7b541210 (/lib/x86_64-linux-gnu/libc.so.6+0x46210)
 #3 0x00007fcc7b54118b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4618b)
 #4 0x00007fcc7b520859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x25859)
 #5 0x00007fcc7b520729 (/lib/x86_64-linux-gnu/libc.so.6+0x25729)
 #6 0x00007fcc7b531f36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
 #7 0x00007fcc7dbcb34f void llvm::AAManager::getModuleAAResultImpl<llvm::GlobalsAA>(llvm::Function&, llvm::AnalysisManager<llvm::Function>&, llvm::AAResults&) PassBuilder.cpp:0:0
 #8 0x00007fcc7c3c5363 llvm::AAManager::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.obj/./lib/libLLVMAnalysis.so.14git+0x257363)
 #9 0x0000563487033358 llvm::detail::AnalysisPassModel<llvm::Function, llvm::AAManager, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>::Invalidator>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) NewPMDriver.cpp:0:0
#10 0x00007fcc7bf95dd8 llvm::AnalysisManager<llvm::Function>::getResultImpl(llvm::AnalysisKey*, llvm::Function&) (/home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.obj/./lib/libLLVMCore.so.14git+0x450dd8)
#11 0x00007fcc7e84892a polly::ScopAnalysis::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.obj/./lib/libPolly.so.14git+0x13c92a)
#12 0x00007fcc7e962aa4 llvm::detail::AnalysisPassModel<llvm::Function, polly::ScopAnalysis, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>::Invalidator>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) RegisterPasses.cpp:0:0
#13 0x00007fcc7bf95dd8 llvm::AnalysisManager<llvm::Function>::getResultImpl(llvm::AnalysisKey*, llvm::Function&) (/home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.obj/./lib/libLLVMCore.so.14git+0x450dd8)
#14 0x00007fcc7e9d7d7c (anonymous namespace)::ScopInliner::runOnSCC(llvm::CallGraphSCC&) ScopInliner.cpp:0:0
#15 0x00007fcc7c46dfef (anonymous namespace)::CGPassManager::runOnModule(llvm::Module&) CallGraphSCCPass.cpp:0:0
#16 0x00007fcc7bf4dee2 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.obj/./lib/libLLVMCore.so.14git+0x408ee2)
#17 0x0000563487054571 main (/home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.obj/bin/opt+0x48571)
#18 0x00007fcc7b5220b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b3)
#19 0x0000563487030c8e _start (/home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.obj/bin/opt+0x24c8e)

Polly is not using custom AliasAnalysis. Any idea how to fix this?

Btw, the pre-merge check failed because of this as well.

Sorry about that, I saw the legacy pass manager infra stack frames and assumed this wasn't related to my patch.
I'll send out a fix.