Hi 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? thanks Sumesh
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. On Fri, Nov 6, 2009 at 5:43 PM, Sumesh Udayakumaran <sumesh.uk at gmail.com> wrote:> Hi > 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? > > thanks > Sumesh > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
On Nov 6, 2009, at 5:43 PM, Sumesh Udayakumaran wrote:> Hi > 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?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. Dan