I have a ModulePass in LLC that runs after most of codegen completes,
right before OBJ emission. I want the ModulePass to iterate over all
MachineFunctions, emulating them. I used to do this by iterating over
all Module Function's, and using MachineFunction::get() to get the
MachineFunction associated with said Function.

In LLVM 2.6, MachineFunction::get() is gone. What is the new way of
doing what I need?


The proper incantation appears to be:

  MachineFunction &MF = getAnalysis<MachineFunctionAnalysis>().getMF();

I found that in lib/CodeGen/MachineFunctionPass.cpp. On the other
hand, that means it probably doesn't exist in a ModulePass, since the
MachineFunctionAnalysis is itself a FunctionPass, so any particular
Function's MachineFunction will only exist while that function is
being emitted.

CodeGen doesn't attempt to keep the MachineFunctions for all the
Functions allocated at the same time. Looking back at 2.5, it seems
it may have been possible to get CodeGen to do this, though it was
probably accidental.

MachineFunctions are now allocated and deallocated with the
MachineFunctionAnalysis pass. It's very straight-forward; it's just
a FunctionPass which allocates a new MachineFunction in its
runOnFunction and deallocates it in its releaseMemory. You may
be able to change it to fit your needs.