It is necessary to summarize the work up to now because there are some things different with this RFC as the development progresses:
- In NPM,
FunctionAnalysisManager
owns theMachineFunction
(yes,MachineFunctionAnalysis
is revived) rather thanMachineModuleInfo
. - Due to 1, we can support “machine module pass” naturally, machine module pass is just a kind of module pass that iterates over all
MachineFunctionAnalysis::Result
, and like other pass manager,MachineFunctionPassManager
is a instance of templatePassManager
. Memory footprint should not change much if there is no machine module pass in pipeline. - Like IR pass,
doInitialization
anddoFinalization
are not supported. If a pass really need to iterate over a module to initialize or finalize some things, it should be converted to a normal module pass, e.g. the legacyMIRPrintingPass
is divided intoPrintMIRPreparePass
andPrintMIRPass
, see PR79440. Some non-trivial logic in these functions, e.g. machine learning based advisors, should move them to constructors and handle input parameters inPassBuilder.cpp
. It may introduce granularity issues, but we can handle the order ofGlobalMerge
,AsmPrinter
and other passes in backend comments correctly. - A new CodeGen pipeline builder by extending
PassBuilder
is proposed, which reusesregisterPassBuilderCallbacks
(PR116913).
Now llc
can run machine function passes over mir
file by option -passes=...
and can generate mir
after instruction selection on some targets. All target independent machine function passes are ported to NPM (thanks to Akshat Oke).
Finally, thanks to aeubanks, arsenm and other code reviewers for reviewing these changes and suggestions.