This patch removes the MachineFunctionAnalysis. Instead we keep a
map from IR Function to MachineFunction in the MachineModuleInfo.
This allows the insertion of ModulePasses into the codegen pipeline
without breaking it because the MachineFunctionAnalysis gets dropped
before a module pass.
Peak memory should stay unchanged without a ModulePass in the codegen
pipeline: Previously the MachineFunction was freed at the end of a codegen
function pipeline because the MachineFunctionAnalysis was dropped; With
this patch the MachineFunction is freed after the AsmPrinter has
finished.
Note that this is not complete yet. It works nice without a ModulePass in the codegen pipeline. It works in many cases with a ModulePass, but still fails in some instances because have some metadata about the current function in MachineModuleInfo which needs to be moved into the MachineFunction class.
And it owns the machine functions.
Doesn't this make it hard to iterate the machine functions in a deterministic order?
Would it be better to have a vector of unique pointers for ownership and iteration, and a map from raw pointer to raw pointer for lookup? (genuine question, you know this area much better.