AsmPrinter needs to hold state between doInitialization, runOnMachineFunction, and doFinalization, which are all separate passes in the NewPM. Storing this state externally somewhere like MachineModuleInfo or a new analysis is possible, but a bit messy given some state, particularly EHHandler objects, has backreferences into the AsmPrinter and assumes there is a single AsmPrinter throughout the entire compilation. So instead, store AsmPrinter in an analysis that stays constant throughout compilation which solves all these problems. This also means we can also just let AsmPrinter continue to own the MCStreamer, which means object file emission should work after this as well. This does require passing the ModuleAnalysisManager into buildCodeGenPipeline to register the AsmPrinterAnalysis, but that seems pretty reasonable to do. Reviewers: paperchalice, RKSimon, arsenm Pull Request: https://github.com/llvm/llvm-project/pull/191535
7.5 KiB
7.5 KiB