This is an archive of the discontinued LLVM Phabricator instance.

[PassManager] add setupAnalysis() to customize analyses registered in AnalysisManager
AbandonedPublic

Authored by fedor.sergeev on Aug 6 2019, 7:07 AM.

Details

Summary

One of the problems we have in customization of compilation pipeline is inability to construct
a customized analysis. Currently the only way to customize is to use a global option.
This does not work when per-compilation-context or per-module customization is required
(say, in JIT scenario).

Our current downstream need is to customize MemoryDependenceAnalysis with a different
block scan limit (to make compile-time/run-time tradeoff choice per individual JIT compilation).

Plan is to register analysis normally (through e.g. PassBuilder) and then run:

   FAM.setupAnalysis([](MemoryDependenceAnalysis& MDep) {
	 MDep.setDefaultBlockScanLimit(NonDefaultBlockScanLimit);
   }

Event Timeline

fedor.sergeev created this revision.Aug 6 2019, 7:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 6 2019, 7:08 AM
Herald added a subscriber: mehdi_amini. · View Herald Transcript

( D65805 is not really a parent, just showing parts of the changes supporting my usecase )

and yes, this is more of a request for feedback than anything else...

fedor.sergeev abandoned this revision.Aug 7 2019, 8:46 AM

Had a chat with @ppf and there is a feeling that we are getting too many ways of customizing the pass (global command line options, explicit arguments passed to constructors, command line parsing etc).
If there is a need to customize passes/analyzes in a way similar to this patch then it should better be done by introducing a generic notion of PassSettings, handled in somewhat general manner through PassManager/PassBuilder.

Yet, as this particular patch and this particular need is concerned, colleague of mine just found a way to customize the analysis during the registration time.
Apparently, it is allowed to "pre-register" analysis by doing PM.addPass(ParticularAnalysis(parameters)) before registering all the "standard" PassRegistry.def analyses.
Then "standard" analysis will just be skipped (as AnalysisManager::addPass just skips analyses that are already registered).
This approach, while being a bit fragile to my tastes, completely solves our current need of customized analysis without any PassManager changes.